mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-06-12 19:29:52 +08:00
update 华为Service
This commit is contained in:
@@ -40,10 +40,8 @@ import com.jsowell.pile.service.*;
|
||||
import com.jsowell.pile.service.programlogic.AbstractProgramLogic;
|
||||
import com.jsowell.pile.service.programlogic.ProgramLogicFactory;
|
||||
import com.jsowell.pile.util.UserUtils;
|
||||
import com.jsowell.pile.vo.base.OrderAmountDetailVO;
|
||||
import com.jsowell.pile.vo.base.OrderPeriodAmountVO;
|
||||
import com.jsowell.pile.vo.base.*;
|
||||
import com.jsowell.pile.vo.base.PileInfoVO;
|
||||
import com.jsowell.pile.vo.base.StationInfoVO;
|
||||
import com.jsowell.pile.vo.uniapp.InvoiceRecordVO;
|
||||
import com.jsowell.pile.vo.uniapp.*;
|
||||
import com.jsowell.pile.vo.web.*;
|
||||
@@ -131,6 +129,9 @@ public class OrderService {
|
||||
@Resource
|
||||
private ClearingBillInfoService clearingBillInfoService;
|
||||
|
||||
@Autowired
|
||||
private ThirdPartyStationRelationService thirdPartyStationRelationService;
|
||||
|
||||
@Autowired
|
||||
private CommonService commonService;
|
||||
|
||||
@@ -1097,6 +1098,15 @@ public class OrderService {
|
||||
.build();
|
||||
// 订单支付成功 支付回调
|
||||
orderBasicInfoService.payOrderSuccessCallback(callbackDTO); // 订单在线支付成功回调
|
||||
|
||||
// 异步判断是否对接了类似华为平台,如果是,走通用第三方平台启动充电逻辑
|
||||
CompletableFuture.runAsync(() -> {
|
||||
try {
|
||||
checkThirdPartyQueryStartCharge(orderCode);
|
||||
} catch (Exception e) {
|
||||
log.error("异步推送第三方平台启动充电逻辑 error", e);
|
||||
}
|
||||
});
|
||||
} else if (StringUtils.equals(scenarioType, ScenarioEnum.BALANCE.getValue())) { // 2-充值余额
|
||||
// 充值余额成功
|
||||
UpdateMemberBalanceDTO dto = new UpdateMemberBalanceDTO();
|
||||
@@ -1286,5 +1296,32 @@ public class OrderService {
|
||||
return orderPileOccupyService.payOccupyPileOrder(dto);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 异步判断是否对接了类似华为平台的第三方平台,并启动充电
|
||||
* @param orderCode
|
||||
*/
|
||||
private void checkThirdPartyQueryStartCharge(String orderCode) {
|
||||
// 根据订单号查询订单信息
|
||||
OrderBasicInfo orderInfoByOrderCode = orderBasicInfoService.getOrderInfoByOrderCode(orderCode);
|
||||
String stationId = orderInfoByOrderCode.getStationId();
|
||||
// 判断是否对接了类似华为平台
|
||||
List<ThirdPartyStationRelationVO> relationInfoList = thirdPartyStationRelationService.getRelationInfoList(stationId);
|
||||
if (CollectionUtils.isEmpty(relationInfoList)) {
|
||||
return;
|
||||
}
|
||||
for (ThirdPartyStationRelationVO vo : relationInfoList) {
|
||||
String startMode = vo.getStartMode();
|
||||
if (StringUtils.equals(Constants.TWO, startMode)) {
|
||||
continue;
|
||||
}
|
||||
ThirdPartyCommonStartChargeDTO dto = new ThirdPartyCommonStartChargeDTO();
|
||||
dto.setPayMode(orderInfoByOrderCode.getPayMode());
|
||||
dto.setStationIds(Lists.newArrayList(stationId));
|
||||
dto.setPileConnectorCode(orderInfoByOrderCode.getPileConnectorCode());
|
||||
dto.setThirdPartyType(vo.getThirdPartyType());
|
||||
|
||||
String result = commonService.commonQueryStartCharge(dto);
|
||||
log.info("异步判断是否对接第三方平台 result:{}", result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3069,18 +3069,16 @@ public class OrderBasicInfoServiceImpl implements OrderBasicInfoService {
|
||||
}
|
||||
|
||||
// 判断该桩所在的站点是否推送了第三方站点(需要我方平台发送启动指令的,如:华为平台)
|
||||
// List<ThirdPartyStationRelationVO> relationInfoList = thirdPartyStationRelationService.getRelationInfoList(orderInfo.getStationId());
|
||||
// if (CollectionUtils.isNotEmpty(relationInfoList)) {
|
||||
// for (ThirdPartyStationRelationVO vo : relationInfoList) {
|
||||
// String startMode = vo.getStartMode();
|
||||
// if (StringUtils.equals(Constants.ONE, startMode)) {
|
||||
// // todo 调用通用推送启动充电接口
|
||||
// String thirdPartyType = vo.getThirdPartyType();
|
||||
//
|
||||
// sendStartCharging = false;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
List<ThirdPartyStationRelationVO> relationInfoList = thirdPartyStationRelationService.getRelationInfoList(orderInfo.getStationId());
|
||||
if (CollectionUtils.isNotEmpty(relationInfoList)) {
|
||||
for (ThirdPartyStationRelationVO vo : relationInfoList) {
|
||||
String startMode = vo.getStartMode();
|
||||
if (StringUtils.equals(Constants.ONE, startMode)) {
|
||||
// 无需发送启机指令,在汇付回调中发送
|
||||
sendStartCharging = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
// 修改订单
|
||||
orderInfo.setPayMode(dto.getPayMode());
|
||||
orderInfo.setPayStatus(OrderPayStatusEnum.paid.getValue());
|
||||
|
||||
@@ -26,6 +26,7 @@ import com.jsowell.pile.mapper.PileBasicInfoMapper;
|
||||
import com.jsowell.pile.mapper.PileConnectorInfoMapper;
|
||||
import com.jsowell.pile.service.*;
|
||||
import com.jsowell.pile.vo.base.ConnectorInfoVO;
|
||||
import com.jsowell.pile.vo.base.ThirdPartyStationRelationVO;
|
||||
import com.jsowell.pile.vo.web.PileConnectorInfoVO;
|
||||
import com.jsowell.pile.vo.web.PileDetailVO;
|
||||
import com.jsowell.pile.vo.web.PileModelInfoVO;
|
||||
@@ -70,6 +71,9 @@ public class PileConnectorInfoServiceImpl implements PileConnectorInfoService {
|
||||
@Autowired
|
||||
private OrderBasicInfoService orderBasicInfoService;
|
||||
|
||||
@Autowired
|
||||
private ThirdPartyStationRelationService thirdPartyStationRelationService;
|
||||
|
||||
@Autowired
|
||||
private PileStationInfoService pileStationInfoService;
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
<if test="pileSn != null and pileSn != ''"> and pile_sn = #{pileSn}</if>
|
||||
<if test="thirdpartyType != null and thirdpartyType != ''"> and thirdparty_type = #{thirdpartyType}</if>
|
||||
<if test="thirdpartyPileSn != null and thirdpartyPileSn != ''"> and thirdparty_pile_sn = #{thirdpartyPileSn}</if>
|
||||
<if test="stationId != null and stationId != ''"> and station_id = #{stationId}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
|
||||
@@ -261,10 +261,14 @@ public class HuaweiServiceV2 {
|
||||
for (HWStationStatusInfo.ConnectorStatusInfo connectorStatusInfo : connectorStatusInfos) {
|
||||
String connectorId = connectorStatusInfo.getConnectorId();
|
||||
String status = connectorStatusInfo.getStatus();
|
||||
String pileSn = StringUtils.substring(connectorId, 0, 14);
|
||||
// 修改对应枪口状态
|
||||
pileConnectorInfoService.updateConnectorStatus(connectorId, status);
|
||||
// 将对应枪口的订单存入map
|
||||
resultMap.put(connectorId, status);
|
||||
if (!StringUtils.equals(Constants.ZERO, status)) {
|
||||
setPileAlive(pileSn);
|
||||
}
|
||||
}
|
||||
}
|
||||
return resultMap;
|
||||
@@ -281,6 +285,10 @@ public class HuaweiServiceV2 {
|
||||
public Map<String, String> receiveNotificationStationStatus(ConnectorStatusInfo connectorStatusInfo) {
|
||||
String pileConnectorCode = connectorStatusInfo.getConnectorID();
|
||||
Integer status = connectorStatusInfo.getStatus();
|
||||
String pileSn = StringUtils.substring(pileConnectorCode, 0, 14);
|
||||
if (status != 0) {
|
||||
setPileAlive(pileSn);
|
||||
}
|
||||
ThirdPartyPlatformConfig configInfo = thirdPartyPlatformConfigService.getInfoByOperatorId(connectorStatusInfo.getOperatorId());
|
||||
if (configInfo == null) {
|
||||
return null;
|
||||
@@ -325,6 +333,9 @@ public class HuaweiServiceV2 {
|
||||
|
||||
// 转换成 StationStatus 对象
|
||||
QueryEquipAuthVO queryEquipAuthVO = JSON.parseObject(result, QueryEquipAuthVO.class);
|
||||
String connectorID = queryEquipAuthVO.getConnectorID();
|
||||
String pileSn = StringUtils.substring(connectorID, 0, 14);
|
||||
setPileAlive(pileSn);
|
||||
return queryEquipAuthVO;
|
||||
}
|
||||
|
||||
@@ -553,6 +564,9 @@ public class HuaweiServiceV2 {
|
||||
Integer startChargeSeqStat = dto.getStartChargeSeqStat(); // 充电订单状态
|
||||
Integer failReason = dto.getFailReason();
|
||||
String startTime = dto.getStartTime();
|
||||
String connectorID = dto.getConnectorID();
|
||||
String pileSn = StringUtils.substring(connectorID, 0, 14);
|
||||
setPileAlive(pileSn);
|
||||
// 根据订单号查询订单信息
|
||||
OrderBasicInfo orderBasicInfo = orderBasicInfoService.getOrderInfoByOrderCode(startChargeSeq);
|
||||
// 判断订单状态
|
||||
@@ -602,10 +616,26 @@ public class HuaweiServiceV2 {
|
||||
}
|
||||
// 转换成 QueryChargeStatusVO 对象
|
||||
QueryChargeStatusVO vo = JSON.parseObject(result, QueryChargeStatusVO.class);
|
||||
Integer connectorStatus = vo.getConnectorStatus();
|
||||
String connectorID = vo.getConnectorID();
|
||||
String pileSn = StringUtils.substring(connectorID, 0, 14);
|
||||
if (connectorStatus != 0) {
|
||||
setPileAlive(pileSn);
|
||||
}
|
||||
return vo;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置桩上次连接时间
|
||||
* @param pileSn
|
||||
*/
|
||||
private void setPileAlive(String pileSn) {
|
||||
// 设置桩上次连接时间
|
||||
String redisKey = CacheConstants.PILE_LAST_CONNECTION + pileSn;
|
||||
redisCache.setCacheObject(redisKey, DateUtils.getDateTime(), CacheConstants.cache_expire_time_1d);
|
||||
}
|
||||
|
||||
/**
|
||||
* 接收华为所推送的设备充电状态
|
||||
* @param dto
|
||||
@@ -614,6 +644,12 @@ public class HuaweiServiceV2 {
|
||||
String startChargeSeq = dto.getStartChargeSeq(); // 订单号
|
||||
String startTime = dto.getStartTime();
|
||||
String endTime = dto.getEndTime();
|
||||
String connectorID = dto.getConnectorID();
|
||||
Integer connectorStatus = dto.getConnectorStatus();
|
||||
String pileSn = StringUtils.substring(connectorID, 0, 14);
|
||||
if (connectorStatus != 0) {
|
||||
setPileAlive(pileSn);
|
||||
}
|
||||
// 计算时间间隔
|
||||
String poorDays = DateUtils.getDatePoor(DateUtils.parseDate(endTime), DateUtils.parseDate(startTime));
|
||||
// 通过订单号查询交易流水号
|
||||
@@ -632,7 +668,7 @@ public class HuaweiServiceV2 {
|
||||
.transactionCode(orderBasicInfo.getTransactionCode())
|
||||
.pileSn(orderBasicInfo.getPileSn())
|
||||
.connectorCode(orderBasicInfo.getConnectorCode())
|
||||
.connectorStatus(String.valueOf(dto.getConnectorStatus()))
|
||||
.connectorStatus(String.valueOf(connectorStatus))
|
||||
.pileConnectorCode(orderBasicInfo.getPileConnectorCode())
|
||||
.outputVoltage(String.valueOf(dto.getVoltageA()))
|
||||
.outputCurrent(String.valueOf(dto.getCurrentA()))
|
||||
@@ -682,6 +718,9 @@ public class HuaweiServiceV2 {
|
||||
}
|
||||
// 转换成 QueryStartChargeVO 对象
|
||||
QueryStartChargeVO vo = JSON.parseObject(result, QueryStartChargeVO.class);
|
||||
String connectorID = vo.getConnectorID();
|
||||
String pileSn = StringUtils.substring(connectorID, 0, 14);
|
||||
setPileAlive(pileSn);
|
||||
return vo;
|
||||
}
|
||||
|
||||
@@ -695,6 +734,9 @@ public class HuaweiServiceV2 {
|
||||
Integer startChargeSeqStat = vo.getStartChargeSeqStat();
|
||||
Integer succStat = vo.getSuccStat();
|
||||
Integer failReasonCode = vo.getFailReason();
|
||||
String connectorID = vo.getConnectorID();
|
||||
String pileSn = StringUtils.substring(connectorID, 0, 14);
|
||||
setPileAlive(pileSn);
|
||||
OrderBasicInfo orderBasicInfo = orderBasicInfoService.getOrderInfoByOrderCode(startChargeSeq);
|
||||
if (orderBasicInfo == null) {
|
||||
return null;
|
||||
@@ -728,6 +770,8 @@ public class HuaweiServiceV2 {
|
||||
String startChargeSeq = dto.getStartChargeSeq();
|
||||
List<QueryChargeStatusVO.ChargeDetail> chargeDetails = dto.getChargeDetails();
|
||||
String pileConnectorCode = dto.getConnectorID();
|
||||
String pileSn = StringUtils.substring(pileConnectorCode, 0, 14);
|
||||
setPileAlive(pileSn);
|
||||
|
||||
// 将源数据存缓存
|
||||
String redisKey = CacheConstants.HUA_WEI_ORDER_INFO_BY_ORDER_CODE + startChargeSeq;
|
||||
|
||||
Reference in New Issue
Block a user