diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/common/CommonService.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/common/CommonService.java index c3e7b6597..856cd183c 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/common/CommonService.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/common/CommonService.java @@ -392,6 +392,9 @@ public class CommonService { // 查询订单信息 OrderBasicInfo orderInfo = orderBasicInfoService.getOrderInfoByTransactionCode(transactionCode); + if (Objects.isNull(orderInfo)) { + return; + } // 推送 for (ThirdPartySecretInfoVO thirdPartySecretInfoVO : thirdPartySecretInfoVOS) { @@ -400,9 +403,7 @@ public class CommonService { dto.setPileConnectorCode(pileConnectorCode); dto.setStatus(changedStatus); dto.setPlatformType(thirdPartySecretInfoVO.getPlatformType()); - if (Objects.nonNull(orderInfo)) { - dto.setOrderCode(orderInfo.getOrderCode()); - } + dto.setOrderCode(orderInfo.getOrderCode()); notificationService.notificationConnectorChargeStatus(dto); } @@ -483,6 +484,23 @@ public class CommonService { } } + public void commonPushOrderInfoV2(OrderBasicInfo orderBasicInfo) { + String stationId = orderBasicInfo.getStationId(); + // 查询该站点是否推送第三方平台 + List relationInfoList = thirdpartySecretInfoService.queryStationToPlatformList(stationId); + // ThirdPartyStationRelationVO relationInfo = thirdPartyStationRelationService.selectRelationInfo(relation); + if (CollectionUtils.isEmpty(relationInfoList)) { + return; + } + for (ThirdPartySecretInfoVO relationVO : relationInfoList) { + NotificationDTO dto = new NotificationDTO(); + dto.setStationId(stationId); + dto.setPlatformType(relationVO.getPlatformType()); + dto.setOrderCode(orderBasicInfo.getOrderCode()); + notificationService.notificationChargeOrderInfo(dto); + } + } + /** * 统一推送启动充电结果 diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/common/NotificationService.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/common/NotificationService.java index 91a6e9b17..90f9251a5 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/common/NotificationService.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/common/NotificationService.java @@ -33,10 +33,12 @@ public class NotificationService { * notification_stationInfo */ public void notificationStationInfo(NotificationDTO dto) { - if (StringUtils.isBlank(dto.getStationId())) { + String stationId = dto.getStationId(); + String platformType = dto.getPlatformType(); + + if (StringUtils.isBlank(stationId)) { throw new BusinessException(ReturnCodeEnum.CODE_PARAM_NOT_NULL_ERROR); } - String stationId = dto.getStationId(); // 通过stationId 查询该站点需要对接的平台配置 List secretInfoVOS = thirdpartySecretInfoService.queryStationToPlatformList(stationId); if (CollectionUtils.isEmpty(secretInfoVOS)) { @@ -44,13 +46,12 @@ public class NotificationService { } // 调用相应平台的处理方法 for (ThirdPartySecretInfoVO secretInfoVO : secretInfoVOS) { - if (StringUtils.isNotBlank(dto.getPlatformType()) && !StringUtils.equals(dto.getPlatformType(), secretInfoVO.getPlatformType())) { + if (StringUtils.isNotBlank(platformType) && !StringUtils.equals(platformType, secretInfoVO.getPlatformType())) { // 如果dto中的platformType不为空,并且不等于secretInfoVO.getPlatformType(),continue continue; } try { ThirdPartyPlatformService platformService = ThirdPartyPlatformFactory.getInvokeStrategy(secretInfoVO.getPlatformType()); - // platformService.printServiceName(); platformService.notificationStationInfo(stationId); } catch (Exception e) { logger.error("充电站信息变化推送error", e); @@ -63,12 +64,14 @@ public class NotificationService { * notification_stationStatus */ public void notificationStationStatus(NotificationDTO dto) { - if (StringUtils.isBlank(dto.getStationId()) || StringUtils.isBlank(dto.getPileConnectorCode()) || StringUtils.isBlank(dto.getStatus())) { - throw new BusinessException(ReturnCodeEnum.CODE_PARAM_NOT_NULL_ERROR); - } String stationId = dto.getStationId(); String pileConnectorCode = dto.getPileConnectorCode(); String status = dto.getStatus(); + String platformType = dto.getPlatformType(); + + if (StringUtils.isBlank(stationId) || StringUtils.isBlank(pileConnectorCode) || StringUtils.isBlank(status)) { + throw new BusinessException(ReturnCodeEnum.CODE_PARAM_NOT_NULL_ERROR); + } // 通过stationId 查询该站点需要对接的平台配置 List secretInfoVOS = thirdpartySecretInfoService.queryStationToPlatformList(stationId); if (CollectionUtils.isEmpty(secretInfoVOS)) { @@ -76,7 +79,7 @@ public class NotificationService { } // 调用相应平台的处理方法 for (ThirdPartySecretInfoVO secretInfoVO : secretInfoVOS) { - if (StringUtils.isNotBlank(dto.getPlatformType()) && !StringUtils.equals(dto.getPlatformType(), secretInfoVO.getPlatformType())) { + if (StringUtils.isNotBlank(platformType) && !StringUtils.equals(platformType, secretInfoVO.getPlatformType())) { // 如果dto中的platformType不为空,并且不等于secretInfoVO.getPlatformType(),continue continue; } @@ -96,11 +99,12 @@ public class NotificationService { * notification_equip_charge_status */ public void notificationConnectorChargeStatus(NotificationDTO dto) { - if (StringUtils.isBlank(dto.getStationId()) || StringUtils.isBlank(dto.getOrderCode())) { - throw new BusinessException(ReturnCodeEnum.CODE_PARAM_NOT_NULL_ERROR); - } String stationId = dto.getStationId(); String orderCode = dto.getOrderCode(); + String platformType = dto.getPlatformType(); + if (StringUtils.isBlank(stationId) || StringUtils.isBlank(orderCode)) { + throw new BusinessException(ReturnCodeEnum.CODE_PARAM_NOT_NULL_ERROR); + } // 通过stationId 查询该站点需要对接的平台配置 List secretInfoVOS = thirdpartySecretInfoService.queryStationToPlatformList(stationId); if (CollectionUtils.isEmpty(secretInfoVOS)) { @@ -108,7 +112,7 @@ public class NotificationService { } // 调用相应平台的处理方法 for (ThirdPartySecretInfoVO secretInfoVO : secretInfoVOS) { - if (StringUtils.isNotBlank(dto.getPlatformType()) && !StringUtils.equals(dto.getPlatformType(), secretInfoVO.getPlatformType())) { + if (StringUtils.isNotBlank(platformType) && !StringUtils.equals(platformType, secretInfoVO.getPlatformType())) { // 如果dto中的platformType不为空,并且不等于secretInfoVO.getPlatformType(),continue continue; } @@ -127,11 +131,12 @@ public class NotificationService { * notification_orderInfo/notification_charge_order_info */ public void notificationChargeOrderInfo(NotificationDTO dto) { - if (StringUtils.isBlank(dto.getStationId()) || StringUtils.isBlank(dto.getOrderCode())) { - throw new BusinessException(ReturnCodeEnum.CODE_PARAM_NOT_NULL_ERROR); - } String stationId = dto.getStationId(); String orderCode = dto.getOrderCode(); + String platformType = dto.getPlatformType(); + if (StringUtils.isBlank(stationId) || StringUtils.isBlank(orderCode)) { + throw new BusinessException(ReturnCodeEnum.CODE_PARAM_NOT_NULL_ERROR); + } // 通过stationId 查询该站点需要对接的平台配置 List secretInfoVOS = thirdpartySecretInfoService.queryStationToPlatformList(stationId); if (CollectionUtils.isEmpty(secretInfoVOS)) { @@ -139,7 +144,7 @@ public class NotificationService { } // 调用相应平台的处理方法 for (ThirdPartySecretInfoVO secretInfoVO : secretInfoVOS) { - if (StringUtils.isNotBlank(dto.getPlatformType()) && !StringUtils.equals(dto.getPlatformType(), secretInfoVO.getPlatformType())) { + if (StringUtils.isNotBlank(platformType) && !StringUtils.equals(platformType, secretInfoVO.getPlatformType())) { // 如果dto中的platformType不为空,并且不等于secretInfoVO.getPlatformType(),continue continue; } @@ -148,7 +153,7 @@ public class NotificationService { ThirdPartyPlatformService platformService = ThirdPartyPlatformFactory.getInvokeStrategy(secretInfoVO.getPlatformType()); platformService.notificationChargeOrderInfo(orderCode, secretInfoVO); } catch (Exception e) { - logger.error("设备充电中状态变化推送error", e); + logger.error("充电订单信息推送error", e); } } } @@ -158,10 +163,12 @@ public class NotificationService { * notification_stationFee */ public void notificationStationFee(NotificationDTO dto) { - if (StringUtils.isBlank(dto.getStationId())) { + String stationId = dto.getStationId(); + String platformType = dto.getPlatformType(); + + if (StringUtils.isBlank(stationId)) { throw new BusinessException(ReturnCodeEnum.CODE_PARAM_NOT_NULL_ERROR); } - String stationId = dto.getStationId(); // 通过stationId 查询该站点需要对接的平台配置 List secretInfoVOS = thirdpartySecretInfoService.queryStationToPlatformList(stationId); if (CollectionUtils.isEmpty(secretInfoVOS)) { @@ -169,7 +176,7 @@ public class NotificationService { } // 调用相应平台的处理方法 for (ThirdPartySecretInfoVO secretInfoVO : secretInfoVOS) { - if (StringUtils.isNotBlank(dto.getPlatformType()) && !StringUtils.equals(dto.getPlatformType(), secretInfoVO.getPlatformType())) { + if (StringUtils.isNotBlank(platformType) && !StringUtils.equals(platformType, secretInfoVO.getPlatformType())) { // 如果dto中的platformType不为空,并且不等于secretInfoVO.getPlatformType(),continue continue; } @@ -178,7 +185,7 @@ public class NotificationService { ThirdPartyPlatformService platformService = ThirdPartyPlatformFactory.getInvokeStrategy(secretInfoVO.getPlatformType()); platformService.notificationStationFee(stationId, secretInfoVO); } catch (Exception e) { - logger.error("设备充电中状态变化推送error", e); + logger.error("站点费率变化推送error", e); } } }