diff --git a/doc/运营小程序接口文档.md b/doc/运营小程序接口文档.md index dd2f3d272..a7824ac36 100644 --- a/doc/运营小程序接口文档.md +++ b/doc/运营小程序接口文档.md @@ -298,3 +298,20 @@ 4、预约充电订单目前不显示实时充电数据 5、桩主需要能看到桩的实时状态 + + + + + + + +1、在 ==站点管理== ——> ==运营管理== 中勾选浙江省平台,点击保存按钮 + +image-20240816100744446 + +2、在 ==三方平台管理== ——> ==对接第三方平台关系== 页面中找到浙江省平台,点击 ==同步数据==,找到对应站点,点击 ==打开推送菜单== 页面, 点击右侧 ==推送充电站信息变化== 右侧的 ==推送== 按钮 + +image-20240816100551217 + + + diff --git a/jsowell-admin/src/main/java/com/jsowell/web/controller/thirdparty/ThirdPartyNotificationController.java b/jsowell-admin/src/main/java/com/jsowell/web/controller/thirdparty/ThirdPartyNotificationController.java index adde4d372..eb77908bb 100644 --- a/jsowell-admin/src/main/java/com/jsowell/web/controller/thirdparty/ThirdPartyNotificationController.java +++ b/jsowell-admin/src/main/java/com/jsowell/web/controller/thirdparty/ThirdPartyNotificationController.java @@ -93,6 +93,26 @@ public class ThirdPartyNotificationController extends BaseController { return result; } + /** + * 历史充电订单信息推送 + */ + @PostMapping("/notificationChargeOrderInfoHistory") + public AjaxResult notificationChargeOrderInfoHistory(@RequestBody NotificationDTO dto) { + AjaxResult result; + try { + notificationService.notificationChargeOrderInfoHistory(dto); + result = AjaxResult.success(); + } catch (BusinessException e) { + logger.error("历史充电订单信息推送失败", e); + result = AjaxResult.error(e.getMessage()); + } catch (Exception e) { + logger.error("历史充电订单信息推送失败", e); + result = AjaxResult.error(); + } + return result; + } + + /** * 站点功率信息推送 */ diff --git a/jsowell-common/src/main/java/com/jsowell/common/enums/thirdparty/ThirdPlatformTypeEnum.java b/jsowell-common/src/main/java/com/jsowell/common/enums/thirdparty/ThirdPlatformTypeEnum.java index 38b0db2b4..09a3c8989 100644 --- a/jsowell-common/src/main/java/com/jsowell/common/enums/thirdparty/ThirdPlatformTypeEnum.java +++ b/jsowell-common/src/main/java/com/jsowell/common/enums/thirdparty/ThirdPlatformTypeEnum.java @@ -23,7 +23,7 @@ public enum ThirdPlatformTypeEnum { DIAN_XING_PLATFORM("12", "宁波点行停车平台", ""), NING_XIA_PLATFORM("13", "宁夏平台", "MA01H3BQ9"), SHEN_ZHEN_PLATFORM("14", "深圳平台", ""), - ZHE_JIANG_PLATFORM("15", "浙江省平台", ""), + ZHE_JIANG_PLATFORM("15", "浙江省平台", "002485048"), ; private String typeCode; 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 1141aa51a..d3cac126c 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 @@ -273,9 +273,9 @@ public class CommonService { if (StringUtils.equals(connectorStatus, "03")) { // 充电中 lianLianService.pushPileChargeStatusChange(orderInfo.getOrderCode()); + // 推送充电状态 + lianLianService.pushChargeStatus(orderInfo.getOrderCode()); } - // 推送充电状态 - lianLianService.pushChargeStatus(orderInfo.getOrderCode()); } if (StringUtils.equals(ThirdPlatformTypeEnum.NING_BO_PLATFORM.getTypeCode(), thirdPartyType)) { // 中电联 @@ -422,12 +422,6 @@ public class CommonService { return; } - // 查询订单信息 - OrderBasicInfo orderInfo = orderBasicInfoService.getOrderInfoByTransactionCode(transactionCode); - if (Objects.isNull(orderInfo)) { - return; - } - // 推送 for (ThirdPartySecretInfoVO thirdPartySecretInfoVO : thirdPartySecretInfoVOS) { NotificationDTO dto = new NotificationDTO(); @@ -435,11 +429,17 @@ public class CommonService { dto.setPileConnectorCode(pileConnectorCode); dto.setStatus(changedStatus); dto.setPlatformType(thirdPartySecretInfoVO.getPlatformType()); - dto.setOrderCode(orderInfo.getOrderCode()); - - notificationService.notificationConnectorChargeStatus(dto); notificationService.notificationStationStatus(dto); + + // 查询订单信息 + OrderBasicInfo orderInfo = orderBasicInfoService.getOrderInfoByTransactionCode(transactionCode); + if (Objects.isNull(orderInfo)) { + return; + } + dto.setOrderCode(orderInfo.getOrderCode()); + notificationService.notificationConnectorChargeStatus(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 0a495b9d1..47d2f9ba6 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 @@ -224,4 +224,36 @@ public class NotificationService { } } } + + /** + * 历史充电订单信息推送 + * notification_orderInfo/notification_charge_order_info + */ + public void notificationChargeOrderInfoHistory(NotificationDTO dto) { + 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)) { + return; + } + // 调用相应平台的处理方法 + for (ThirdPartySecretInfoVO secretInfoVO : secretInfoVOS) { + if (StringUtils.isNotBlank(platformType) && !StringUtils.equals(platformType, secretInfoVO.getPlatformType())) { + // 如果dto中的platformType不为空,并且不等于secretInfoVO.getPlatformType(),continue + continue; + } + try { + // 根据平台类型获取Service + ThirdPartyPlatformService platformService = ThirdPartyPlatformFactory.getInvokeStrategy(secretInfoVO.getPlatformType()); + platformService.notificationChargeOrderInfoHistory(orderCode); + } catch (Exception e) { + logger.error("历史充电订单信息推送error", e); + } + } + } } diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/ZheJiangPlatformServiceImpl.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/ZheJiangPlatformServiceImpl.java index 92fde80b9..29fdebb8e 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/ZheJiangPlatformServiceImpl.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/ZheJiangPlatformServiceImpl.java @@ -657,8 +657,54 @@ public class ZheJiangPlatformServiceImpl implements ThirdPartyPlatformService { return null; } // 调用联联平台接口 - JSONObject json = new JSONObject(); - json.put("ChargeOrderInfo", orderInfo); + String jsonString = JSON.toJSONString(orderInfo); + String result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret); + return result; + } + + /** + * 推送历史充电订单信息 + * @param orderCode + * @return + */ + @Override + public String notificationChargeOrderInfoHistory(String orderCode) { + // 根据订单号查询出信息 + OrderBasicInfo orderBasicInfo = orderBasicInfoService.getOrderInfoByOrderCode(orderCode); + + ThirdPartySecretInfoVO zheJiangPlatformSecretInfo = getZheJiangPlatformSecretInfo(); + + String operatorId = zheJiangPlatformSecretInfo.getOurOperatorId(); + String operatorSecret = zheJiangPlatformSecretInfo.getTheirOperatorSecret(); + String signSecret = zheJiangPlatformSecretInfo.getTheirSigSecret(); + String dataSecret = zheJiangPlatformSecretInfo.getTheirDataSecret(); + String dataSecretIv = zheJiangPlatformSecretInfo.getTheirDataSecretIv(); + String urlAddress = zheJiangPlatformSecretInfo.getTheirUrlPrefix(); + + + OrderDetail orderDetail = orderBasicInfoService.getOrderDetailByOrderCode(orderCode); + String url = urlAddress + "supervise_notification_charge_order_info_history"; + + // 拼装成平台所需格式对象 + ChargeOrderInfo orderInfo = transformChargeOrderInfo(orderBasicInfo, orderDetail); + orderInfo.setOperatorID(operatorId); + PileMerchantInfoVO pileMerchantInfoVO = pileMerchantInfoService.queryMerchantInfoByStationId(orderInfo.getStationID()); + String equipmentOwnerID = ThirdPartyPlatformUtils.extractEquipmentOwnerID(pileMerchantInfoVO.getOrganizationCode()); + orderInfo.setEquipmentOwnerID(equipmentOwnerID); + + List billingList = pileBillingTemplateService.queryBillingPrice(orderBasicInfo.getStationId()); + // 先将list按照 尖、峰、平、谷 时段排序 + // List collect = billingList.stream().sorted(Comparator.comparing(BillingPriceVO::getTimeType)).collect(Collectors.toList()); + // 再循环该list,拼装对应的充电价格、费率 + List chargeDetails = transformSupChargeDetails(orderDetail, billingList); + orderInfo.setChargeDetails(chargeDetails); + + // 获取令牌 + String token = getToken(urlAddress, operatorId, operatorSecret, dataSecretIv, signSecret, dataSecret); + if (StringUtils.isBlank(token)) { + return null; + } + // 调用联联平台接口 String jsonString = JSON.toJSONString(orderInfo); String result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret); return result;