mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-20 02:55:04 +08:00
bugfix 华为启动充电不再重复生成订单
This commit is contained in:
@@ -13,6 +13,7 @@ import com.jsowell.pile.dto.QueryStationDTO;
|
||||
import com.jsowell.pile.dto.RemoteGroundLockDTO;
|
||||
import com.jsowell.pile.service.*;
|
||||
import com.jsowell.pile.vo.uniapp.BillingPriceVO;
|
||||
import com.jsowell.pile.vo.web.PileConnectorInfoVO;
|
||||
import com.jsowell.pile.vo.web.ThirdPartySnRelationVO;
|
||||
import com.jsowell.thirdparty.common.CommonService;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
@@ -21,6 +22,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 充电桩相关接口
|
||||
@@ -121,9 +123,6 @@ public class PileController extends BaseController {
|
||||
RestApiResponse<?> response = null;
|
||||
try {
|
||||
PageResponse pageResponse = pileConnectorInfoService.getUniAppConnectorInfoListByParams(dto);
|
||||
if (CollectionUtils.isNotEmpty(dto.getStationIdList())) {
|
||||
updateThirdPartyConnectorStatus(dto.getStationIdList());
|
||||
}
|
||||
response = new RestApiResponse<>(pageResponse);
|
||||
} catch (Exception e) {
|
||||
logger.error("查询充电枪口列表异常", e);
|
||||
@@ -146,6 +145,8 @@ public class PileController extends BaseController {
|
||||
RestApiResponse<?> response = null;
|
||||
try {
|
||||
PageResponse pageResponse = pileConnectorInfoService.selectStationConnectorList(dto);
|
||||
List<PileConnectorInfoVO> list = (List<PileConnectorInfoVO>) pageResponse.getList();
|
||||
updateThirdPartyConnectorStatus(list);
|
||||
response = new RestApiResponse<>(pageResponse);
|
||||
} catch (Exception e) {
|
||||
logger.error("查询充电枪口列表异常", e);
|
||||
@@ -186,12 +187,15 @@ public class PileController extends BaseController {
|
||||
/**
|
||||
* 修改第三方平台枪口状态
|
||||
*/
|
||||
private void updateThirdPartyConnectorStatus(List<Long> stationIdList) {
|
||||
if (CollectionUtils.isEmpty(stationIdList)) {
|
||||
public void updateThirdPartyConnectorStatus(List<PileConnectorInfoVO> connectorList) {
|
||||
if (CollectionUtils.isEmpty(connectorList)) {
|
||||
return;
|
||||
}
|
||||
List<String> stationIdList = connectorList.stream()
|
||||
.map(PileConnectorInfoVO::getStationId)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
for (Long stationId : stationIdList) {
|
||||
for (String stationId : stationIdList) {
|
||||
String stationIdStr = String.valueOf(stationId);
|
||||
List<ThirdPartySnRelationVO> list = snRelationService.selectSnRelationListByParams(stationIdStr, null);
|
||||
if (CollectionUtils.isEmpty(list)) {
|
||||
|
||||
@@ -23,6 +23,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 充电桩枪口信息Controller
|
||||
@@ -74,10 +75,8 @@ public class PileConnectorInfoController extends BaseController {
|
||||
public TableDataInfo getConnectorInfoListByParams(@RequestBody QueryConnectorListDTO dto) {
|
||||
logger.info("查询接口列表 param:{}", JSON.toJSONString(dto));
|
||||
List<PileConnectorInfoVO> list = pileConnectorInfoService.getConnectorInfoListByParams(dto);
|
||||
if (CollectionUtils.isNotEmpty(dto.getStationIdList())) {
|
||||
// 修改对接第三方平台的枪口状态
|
||||
updateThirdPartyConnectorStatus(dto.getStationIdList());
|
||||
}
|
||||
// 修改对接第三方平台的枪口状态
|
||||
updateThirdPartyConnectorStatus(list);
|
||||
logger.info("查询接口列表 result:{}", JSON.toJSONString(list));
|
||||
return getDataTable(list);
|
||||
}
|
||||
@@ -146,12 +145,15 @@ public class PileConnectorInfoController extends BaseController {
|
||||
/**
|
||||
* 修改第三方平台枪口状态
|
||||
*/
|
||||
public void updateThirdPartyConnectorStatus(List<Long> stationIdList) {
|
||||
if (CollectionUtils.isEmpty(stationIdList)) {
|
||||
public void updateThirdPartyConnectorStatus(List<PileConnectorInfoVO> connectorList) {
|
||||
if (CollectionUtils.isEmpty(connectorList)) {
|
||||
return;
|
||||
}
|
||||
List<String> stationIdList = connectorList.stream()
|
||||
.map(PileConnectorInfoVO::getStationId)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
for (Long stationId : stationIdList) {
|
||||
for (String stationId : stationIdList) {
|
||||
String stationIdStr = String.valueOf(stationId);
|
||||
List<ThirdPartySnRelationVO> list = snRelationService.selectSnRelationListByParams(stationIdStr, null);
|
||||
if (CollectionUtils.isEmpty(list)) {
|
||||
|
||||
@@ -516,24 +516,23 @@ public class HuaweiServiceV2 {
|
||||
String pileConnectorCode = dto.getConnectorID();
|
||||
BigDecimal chargeAmount = dto.getMoneyLimit();
|
||||
String payMode = dto.getPayMode();
|
||||
String orderCode = dto.getStartChargeSeq();
|
||||
|
||||
String requestName = "query_start_charge";
|
||||
|
||||
// 生成订单
|
||||
String orderCode = dto.getStartChargeSeq();
|
||||
// String startChargeSeq = orderCode;
|
||||
QueryStartChargeDTO startChargeDTO = new QueryStartChargeDTO();
|
||||
startChargeDTO.setOperatorId(ThirdPartyOperatorIdEnum.HUA_WEI.getOperatorId());
|
||||
startChargeDTO.setStartChargeSeq(orderCode);
|
||||
startChargeDTO.setConnectorID(pileConnectorCode);
|
||||
startChargeDTO.setAccountBalance(chargeAmount);
|
||||
startChargeDTO.setPayMode(dto.getPayMode());
|
||||
Map<String, Object> map = orderBasicInfoService.generateOrderForThirdParty(startChargeDTO);
|
||||
// QueryStartChargeDTO startChargeDTO = new QueryStartChargeDTO();
|
||||
// startChargeDTO.setOperatorId(ThirdPartyOperatorIdEnum.HUA_WEI.getOperatorId());
|
||||
// startChargeDTO.setStartChargeSeq(orderCode);
|
||||
// startChargeDTO.setConnectorID(pileConnectorCode);
|
||||
// startChargeDTO.setAccountBalance(chargeAmount);
|
||||
// startChargeDTO.setPayMode(dto.getPayMode());
|
||||
// Map<String, Object> map = orderBasicInfoService.generateOrderForThirdParty(startChargeDTO);
|
||||
|
||||
if (map == null) {
|
||||
log.error("华为平台生成订单 error");
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_GENERATE_ORDER_ERROR);
|
||||
}
|
||||
// if (map == null) {
|
||||
// log.error("华为平台生成订单 error");
|
||||
// throw new BusinessException(ReturnCodeEnum.CODE_GENERATE_ORDER_ERROR);
|
||||
// }
|
||||
// 拼装参数
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("StartChargeSeq", orderCode);
|
||||
@@ -575,6 +574,8 @@ public class HuaweiServiceV2 {
|
||||
orderBasicInfo.setOrderStatus(OrderStatusEnum.IN_THE_CHARGING.getValue());
|
||||
// 设置开始时间
|
||||
orderBasicInfo.setChargeStartTime(DateUtils.parseDate(startTime));
|
||||
// 设置启动平台类型
|
||||
orderBasicInfo.setThirdPartyType(ThirdPlatformTypeEnum.HUA_WEI.getTypeCode());
|
||||
orderBasicInfoService.updateOrderBasicInfo(orderBasicInfo);
|
||||
}
|
||||
if (failReason != 0) {
|
||||
@@ -801,6 +802,9 @@ public class HuaweiServiceV2 {
|
||||
|
||||
// 结算订单
|
||||
TransactionRecordsData data = TransactionRecordsData.builder()
|
||||
.transactionCode(orderBasicInfo.getTransactionCode())
|
||||
.pileSn(orderBasicInfo.getPileSn())
|
||||
.connectorCode(orderBasicInfo.getConnectorCode())
|
||||
.consumptionAmount(String.valueOf(dto.getTotalMoney())) // 订单总金额
|
||||
.stopReasonMsg(String.valueOf(dto.getStopReason())) // 停止原因
|
||||
.totalElectricity(String.valueOf(dto.getTotalPower())) // 总用电量
|
||||
|
||||
Reference in New Issue
Block a user