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 4bb779a64..8dcd40ea1 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 @@ -5,6 +5,8 @@ import com.jsowell.thirdparty.platform.ThirdPartyPlatformService; import com.jsowell.thirdparty.platform.factory.ThirdPartyPlatformFactory; import com.jsowell.thirdparty.service.ThirdpartySecretInfoService; import org.apache.commons.collections4.CollectionUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -18,6 +20,7 @@ import java.util.List; */ @Service public class NotificationService { + private final Logger logger = LoggerFactory.getLogger(this.getClass()); @Autowired private ThirdpartySecretInfoService thirdpartySecretInfoService; @@ -34,9 +37,13 @@ public class NotificationService { } // 调用相应平台的处理方法 for (ThirdPartySecretInfoVO secretInfoVO : secretInfoVOS) { - ThirdPartyPlatformService platformService = ThirdPartyPlatformFactory.getInvokeStrategy(secretInfoVO.getPlatformType()); - // platformService.printServiceName(); - platformService.notificationStationInfo(stationId); + try { + ThirdPartyPlatformService platformService = ThirdPartyPlatformFactory.getInvokeStrategy(secretInfoVO.getPlatformType()); + // platformService.printServiceName(); + platformService.notificationStationInfo(stationId); + } catch (Exception e) { + logger.error("充电站信息变化推送error", e); + } } } @@ -52,9 +59,13 @@ public class NotificationService { } // 调用相应平台的处理方法 for (ThirdPartySecretInfoVO secretInfoVO : secretInfoVOS) { - // 根据平台类型获取Service - ThirdPartyPlatformService platformService = ThirdPartyPlatformFactory.getInvokeStrategy(secretInfoVO.getPlatformType()); - platformService.notificationStationStatus(stationId, pileConnectorCode, status, secretInfoVO); + try { + // 根据平台类型获取Service + ThirdPartyPlatformService platformService = ThirdPartyPlatformFactory.getInvokeStrategy(secretInfoVO.getPlatformType()); + platformService.notificationStationStatus(stationId, pileConnectorCode, status, secretInfoVO); + } catch (Exception e) { + logger.error("设备状态变化推送error", e); + } } } @@ -63,23 +74,65 @@ public class NotificationService { * notification_connector_charge_status * notification_equip_charge_status */ - public void notificationConnectorChargeStatus() { - + public void notificationConnectorChargeStatus(String stationId, String orderCode) { + // 通过stationId 查询该站点需要对接的平台配置 + List secretInfoVOS = thirdpartySecretInfoService.queryStationToPlatformList(stationId); + if (CollectionUtils.isEmpty(secretInfoVOS)) { + return; + } + // 调用相应平台的处理方法 + for (ThirdPartySecretInfoVO secretInfoVO : secretInfoVOS) { + try { + // 根据平台类型获取Service + ThirdPartyPlatformService platformService = ThirdPartyPlatformFactory.getInvokeStrategy(secretInfoVO.getPlatformType()); + platformService.notificationConnectorChargeStatus(orderCode, secretInfoVO); + } catch (Exception e) { + logger.error("设备充电中状态变化推送error", e); + } + } } /** - * 订单信息推送 + * 充电订单信息推送 * notification_orderInfo/notification_charge_order_info */ - public void notificationOrderInfo() { - + public void notificationChargeOrderInfo(String stationId, String orderCode) { + // 通过stationId 查询该站点需要对接的平台配置 + List secretInfoVOS = thirdpartySecretInfoService.queryStationToPlatformList(stationId); + if (CollectionUtils.isEmpty(secretInfoVOS)) { + return; + } + // 调用相应平台的处理方法 + for (ThirdPartySecretInfoVO secretInfoVO : secretInfoVOS) { + try { + // 根据平台类型获取Service + ThirdPartyPlatformService platformService = ThirdPartyPlatformFactory.getInvokeStrategy(secretInfoVO.getPlatformType()); + platformService.notificationChargeOrderInfo(orderCode, secretInfoVO); + } catch (Exception e) { + logger.error("设备充电中状态变化推送error", e); + } + } } /** * 站点费率变化推送 * notification_stationFee */ - public void notificationStationFee() { - + public void notificationStationFee(String stationId) { + // 通过stationId 查询该站点需要对接的平台配置 + List secretInfoVOS = thirdpartySecretInfoService.queryStationToPlatformList(stationId); + if (CollectionUtils.isEmpty(secretInfoVOS)) { + return; + } + // 调用相应平台的处理方法 + for (ThirdPartySecretInfoVO secretInfoVO : secretInfoVOS) { + try { + // 根据平台类型获取Service + ThirdPartyPlatformService platformService = ThirdPartyPlatformFactory.getInvokeStrategy(secretInfoVO.getPlatformType()); + platformService.notificationStationFee(stationId, secretInfoVO); + } catch (Exception e) { + logger.error("设备充电中状态变化推送error", e); + } + } } } diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/ThirdPartyPlatformService.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/ThirdPartyPlatformService.java index 8948d6aef..97d70908d 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/ThirdPartyPlatformService.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/ThirdPartyPlatformService.java @@ -253,6 +253,10 @@ public interface ThirdPartyPlatformService extends InitializingBean { throw new UnsupportedOperationException("This method is not yet implemented"); } + default String notificationConnectorChargeStatus(String orderCode, ThirdPartySecretInfoVO secretInfoVO) { + throw new UnsupportedOperationException("This method is not yet implemented"); + } + /** * 站点费率变化推送 notification_stationFee * @@ -261,6 +265,9 @@ public interface ThirdPartyPlatformService extends InitializingBean { default String notificationStationFee(String stationId) { throw new UnsupportedOperationException("This method is not yet implemented"); } + default String notificationStationFee(String stationId, ThirdPartySecretInfoVO secretInfoVO) { + throw new UnsupportedOperationException("This method is not yet implemented"); + } /** * 充电订单推送 notification_charge_order_info/notification_orderInfo @@ -272,6 +279,10 @@ public interface ThirdPartyPlatformService extends InitializingBean { throw new UnsupportedOperationException("This method is not yet implemented"); } + default String notificationChargeOrderInfo(String orderCode, ThirdPartySecretInfoVO secretInfoVO) { + throw new UnsupportedOperationException("This method is not yet implemented"); + } + /** * 告警信息推送 notification_alarmInfo * diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/hainan/service/HaiNanPlatformServiceImpl.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/hainan/service/HaiNanPlatformServiceImpl.java index 321ac5bc0..c0cb120d3 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/hainan/service/HaiNanPlatformServiceImpl.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/hainan/service/HaiNanPlatformServiceImpl.java @@ -22,6 +22,7 @@ import com.jsowell.pile.domain.ykcCommond.StartChargingCommand; import com.jsowell.pile.dto.*; import com.jsowell.pile.service.*; import com.jsowell.pile.thirdparty.ZDLEquipmentInfo; +import com.jsowell.pile.vo.ThirdPartySecretInfoVO; import com.jsowell.pile.vo.base.ConnectorInfoVO; import com.jsowell.pile.vo.base.ThirdPartyStationInfoVO; import com.jsowell.pile.vo.base.ThirdPartyStationRelationVO; @@ -374,6 +375,49 @@ public class HaiNanPlatformServiceImpl implements ThirdPartyPlatformService { return result; } + @Override + public String notificationChargeOrderInfo(String orderCode, ThirdPartySecretInfoVO secretInfoVO) { + // 获取数据 + OrderBasicInfo orderBasicInfo = orderBasicInfoService.getOrderInfoByOrderCode(orderCode); + OrderDetail orderDetail = orderBasicInfoService.getOrderDetailByOrderCode(orderCode); + + // 通过第三方平台类型查询相关配置信息 + // ThirdPartyStationRelation relation = new ThirdPartyStationRelation(); + // relation.setThirdPartyType(orderBasicInfo.getThirdPartyType()); + // ThirdPartyStationRelationVO relationInfo = thirdPartyStationRelationService.selectRelationInfo(relation); + // if (relationInfo == null) { + // return null; + // } + + // 向三方平台推送 + String operatorId = secretInfoVO.getTheirOperatorId(); + String operatorSecret = secretInfoVO.getTheirOperatorSecret(); + String signSecret = secretInfoVO.getTheirSigSecret(); + String dataSecret = secretInfoVO.getTheirDataSecret(); + String dataSecretIv = secretInfoVO.getTheirDataSecretIv(); + String urlAddress = secretInfoVO.getTheirUrlPrefix(); + String thirdPartyType = secretInfoVO.getPlatformType(); + + String url = urlAddress + BusinessInformationExchangeEnum.NOTIFICATION_CHARGE_ORDER_INFO.getValue(); + JSONObject json = new JSONObject(); + json.put("StartChargeSeq", orderCode); + json.put("ConnectorID", orderBasicInfo.getPileConnectorCode()); + json.put("StartTime", DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, orderBasicInfo.getChargeStartTime())); + json.put("EndTime", DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, orderBasicInfo.getChargeEndTime())); + json.put("TotalPower", orderDetail.getTotalUsedElectricity().setScale(2, RoundingMode.HALF_UP)); + json.put("TotalElecMoney", orderDetail.getTotalElectricityAmount().setScale(2, RoundingMode.HALF_UP)); + json.put("TotalSeviceMoney", orderDetail.getTotalServiceAmount().setScale(2, RoundingMode.HALF_UP)); + json.put("TotalMoney", orderDetail.getTotalOrderAmount().setScale(2, RoundingMode.HALF_UP)); + json.put("StopReason", 2); // 2:BMS 停止充电 + + String jsonString = JSON.toJSONString(json); + + // 获取令牌 + String token = getToken(urlAddress, operatorId, operatorSecret, dataSecretIv, signSecret, dataSecret); + String result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret); + return result; + } + /** * 6.5 设备接口状态查询 * diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/lianlian/service/LianLianPlatformServiceImpl.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/lianlian/service/LianLianPlatformServiceImpl.java index f328b0376..e5212e9a6 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/lianlian/service/LianLianPlatformServiceImpl.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/lianlian/service/LianLianPlatformServiceImpl.java @@ -28,6 +28,7 @@ import com.jsowell.pile.service.*; import com.jsowell.pile.thirdparty.CommonParamsDTO; import com.jsowell.pile.thirdparty.EquipmentInfo; import com.jsowell.pile.util.MerchantUtils; +import com.jsowell.pile.vo.ThirdPartySecretInfoVO; import com.jsowell.pile.vo.base.*; import com.jsowell.pile.vo.lianlian.AccumulativeInfoVO; import com.jsowell.pile.vo.lianlian.PushStationFeeVO; @@ -85,15 +86,6 @@ public class LianLianPlatformServiceImpl implements ThirdPartyPlatformService { @Resource private ThirdPartyStationRelationService thirdPartyStationRelationService; - /** - * Invoked by the containing {@code BeanFactory} after it has set all bean properties - * and satisfied {@link BeanFactoryAware}, {@code ApplicationContextAware} etc. - *

This method allows the bean instance to perform validation of its overall - * configuration and final initialization when all bean properties have been set. - * - * @throws Exception in the event of misconfiguration (such as failure to set an - * essential property) or if initialization fails for any other reason - */ @Override public void afterPropertiesSet() throws Exception { ThirdPartyPlatformFactory.register(thirdPlatformType, this); @@ -692,6 +684,57 @@ public class LianLianPlatformServiceImpl implements ThirdPartyPlatformService { return result; } + @Override + public String notificationConnectorChargeStatus(String orderCode, ThirdPartySecretInfoVO secretInfoVO) { + // 通过订单号查询信息 + OrderBasicInfo orderInfo = orderBasicInfoService.getOrderInfoByOrderCode(orderCode); + // 根据枪口号查询充电实时状态 + // OrderBasicInfo orderBasicInfo = orderBasicInfoService.queryChargingByPileConnectorCode(orderInfo.getPileConnectorCode()); + List list = orderBasicInfoService.getChargingRealTimeData(orderInfo.getTransactionCode()); + RealTimeMonitorData realTimeMonitorData = list.get(0); + // 拼装联联参数 + ConnectorChargeStatusInfo info = ConnectorChargeStatusInfo.builder() + .startChargeSeq(orderCode) + .connectorID(orderInfo.getPileConnectorCode()) + .connectorStatus(Integer.valueOf(realTimeMonitorData.getConnectorStatus())) + .currentA(new BigDecimal(realTimeMonitorData.getOutputCurrent())) + .voltageA(new BigDecimal(realTimeMonitorData.getOutputVoltage())) + .soc(new BigDecimal(realTimeMonitorData.getSOC())) + .startTime(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, orderInfo.getChargeStartTime())) + .endTime(DateUtils.getDateTime()) + .totalPower(new BigDecimal(realTimeMonitorData.getChargingDegree())) + .elecMoney(new BigDecimal("0")) // TODO + .seviceMoney(new BigDecimal("0")) // TODO + .totalMoney(new BigDecimal(realTimeMonitorData.getChargingAmount()).setScale(2, BigDecimal.ROUND_HALF_UP)) + .build(); + + // 通过站点id查询相关配置信息 + // ThirdPartyStationRelationVO relationInfo = thirdPartyStationRelationService.selectRelationInfo(orderInfo.getStationId()); + // if (relationInfo == null) { + // return null; + // } + String operatorId = secretInfoVO.getTheirOperatorId(); + String operatorSecret = secretInfoVO.getTheirOperatorSecret(); + String signSecret = secretInfoVO.getTheirSigSecret(); + String dataSecret = secretInfoVO.getTheirDataSecret(); + String dataSecretIv = secretInfoVO.getTheirDataSecretIv(); + String urlAddress = secretInfoVO.getTheirUrlPrefix(); + + String url = urlAddress + "notification_connector_charge_status"; + + // 获取令牌 + String token = getToken(urlAddress, operatorId, operatorSecret, dataSecretIv, signSecret, dataSecret); + if (StringUtils.isBlank(token)) { + return null; + } + JSONObject json = new JSONObject(); + json.put("ConnectorChargeStatusInfo", info); + String jsonString = JSON.toJSONString(json); + // 发送请求 + String result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret); + return result; + } + /** * 订单信息推送 notification_orderInfo * @@ -817,6 +860,125 @@ public class LianLianPlatformServiceImpl implements ThirdPartyPlatformService { return result; } + @Override + public String notificationChargeOrderInfo(String orderCode, ThirdPartySecretInfoVO secretInfoVO) { + + // 根据订单号查询出信息 + OrderBasicInfo orderBasicInfo = orderBasicInfoService.getOrderInfoByOrderCode(orderCode); + OrderDetail orderDetail = orderBasicInfoService.getOrderDetailByOrderCode(orderCode); + + // 通过站点id查询相关配置信息 + // ThirdPartyStationRelationVO relationInfo = thirdPartyStationRelationService.selectRelationInfo(orderBasicInfo.getStationId()); + // if (relationInfo == null) { + // return null; + // } + String operatorId = secretInfoVO.getTheirOperatorId(); + String operatorSecret = secretInfoVO.getTheirOperatorSecret(); + String signSecret = secretInfoVO.getTheirSigSecret(); + String dataSecret = secretInfoVO.getTheirDataSecret(); + String dataSecretIv = secretInfoVO.getTheirDataSecretIv(); + String urlAddress = secretInfoVO.getTheirUrlPrefix(); + + String url = urlAddress + "notification_orderInfo"; + + // 拼装成联联平台所需格式对象 + OrderInfo orderInfo = OrderInfo.builder() + .operatorID(operatorId) + .equipmentOwnerID(Constants.OPERATORID_LIANLIAN) + .stationID("LC" + orderBasicInfo.getStationId()) + .equipmentID(orderBasicInfo.getPileSn()) + .connectorID(orderBasicInfo.getPileConnectorCode()) + .startChargeSeq(orderCode) + .userChargeType(Constants.one) + .money(new BigDecimal(String.valueOf(orderBasicInfo.getOrderAmount())).setScale(2, BigDecimal.ROUND_HALF_UP)) + .electMoney(new BigDecimal(String.valueOf(orderDetail.getTotalElectricityAmount())).setScale(2, BigDecimal.ROUND_HALF_UP)) + .serviceMoney(new BigDecimal(String.valueOf(orderDetail.getTotalServiceAmount())).setScale(2, BigDecimal.ROUND_HALF_UP)) + .elect(new BigDecimal(String.valueOf(orderDetail.getTotalUsedElectricity())).setScale(2, BigDecimal.ROUND_HALF_UP)) + .startTime(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, orderBasicInfo.getChargeStartTime())) + .endTime(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, orderBasicInfo.getChargeEndTime())) + .paymentAmount(orderBasicInfo.getPayAmount()) + // .payChannel() + .stopReason(0) + // .chargeDetails() + .build(); + if (MerchantUtils.isXiXiaoMerchant(orderBasicInfo.getMerchantId())) { + orderInfo.setEquipmentOwnerID(Constants.OPERATORID_XI_XIAO); + } + // 支付方式 + if (StringUtils.equals(orderBasicInfo.getPayMode(), OrderPayModeEnum.PAYMENT_OF_WECHATPAY.getValue())) { + // 微信支付 + orderInfo.setPayChannel(Integer.valueOf(PayChannelEnum.WEXIN_PAY.getCode())); + } else if (StringUtils.equals(orderBasicInfo.getPayMode(), OrderPayModeEnum.PAYMENT_OF_ALIPAY.getValue())) { + // 支付宝支付 + orderInfo.setPayChannel(Integer.valueOf(PayChannelEnum.ALI_PAY.getCode())); + } else { + // 其他 + orderInfo.setPayChannel(Integer.valueOf(PayChannelEnum.OTHER.getCode())); + } + // 订单详情 + ChargeDetail detail; + + List billingList = pileBillingTemplateService.queryBillingPrice(orderBasicInfo.getStationId()); + // 先将list按照 尖、峰、平、谷 时段排序 + // List collect = billingList.stream().sorted(Comparator.comparing(BillingPriceVO::getTimeType)).collect(Collectors.toList()); + // 再循环该list,拼装对应的充电价格、费率 + List chargeDetails = new ArrayList<>(); + for (BillingPriceVO billingPriceVO : billingList) { + detail = new ChargeDetail(); + if (StringUtils.equals(billingPriceVO.getTimeType(), "1")) { + // 尖时段 + detail.setDetailStartTime(billingPriceVO.getStartTime()); + detail.setDetailEndTime(billingPriceVO.getEndTime()); + detail.setElecPrice(new BigDecimal(billingPriceVO.getElectricityPrice()).setScale(4, BigDecimal.ROUND_HALF_UP)); + detail.setSevicePrice(new BigDecimal(billingPriceVO.getServicePrice()).setScale(4, BigDecimal.ROUND_HALF_UP)); + detail.setDetailPower(orderDetail.getSharpUsedElectricity()); + detail.setDetailElecMoney(orderDetail.getSharpElectricityPrice()); + detail.setDetailSeviceMoney(orderDetail.getSharpServicePrice()); + } else if (StringUtils.equals(billingPriceVO.getTimeType(), "2")) { + // 峰时段 + detail.setDetailStartTime(billingPriceVO.getStartTime()); + detail.setDetailEndTime(billingPriceVO.getEndTime()); + detail.setElecPrice(new BigDecimal(billingPriceVO.getElectricityPrice()).setScale(4, BigDecimal.ROUND_HALF_UP)); + detail.setSevicePrice(new BigDecimal(billingPriceVO.getServicePrice()).setScale(4, BigDecimal.ROUND_HALF_UP)); + detail.setDetailPower(orderDetail.getPeakUsedElectricity()); + detail.setDetailElecMoney(orderDetail.getPeakElectricityPrice()); + detail.setDetailSeviceMoney(orderDetail.getPeakServicePrice()); + } else if (StringUtils.equals(billingPriceVO.getTimeType(), "3")) { + // 平时段 + detail.setDetailStartTime(billingPriceVO.getStartTime()); + detail.setDetailEndTime(billingPriceVO.getEndTime()); + detail.setElecPrice(new BigDecimal(billingPriceVO.getElectricityPrice()).setScale(4, BigDecimal.ROUND_HALF_UP)); + detail.setSevicePrice(new BigDecimal(billingPriceVO.getServicePrice()).setScale(4, BigDecimal.ROUND_HALF_UP)); + detail.setDetailPower(orderDetail.getFlatUsedElectricity()); + detail.setDetailElecMoney(orderDetail.getFlatElectricityPrice()); + detail.setDetailSeviceMoney(orderDetail.getFlatServicePrice()); + } else if (StringUtils.equals(billingPriceVO.getTimeType(), "4")) { + // 谷时段 + detail.setDetailStartTime(billingPriceVO.getStartTime()); + detail.setDetailEndTime(billingPriceVO.getEndTime()); + detail.setElecPrice(new BigDecimal(billingPriceVO.getElectricityPrice()).setScale(4, BigDecimal.ROUND_HALF_UP)); + detail.setSevicePrice(new BigDecimal(billingPriceVO.getServicePrice()).setScale(4, BigDecimal.ROUND_HALF_UP)); + detail.setDetailPower(orderDetail.getValleyUsedElectricity()); + detail.setDetailElecMoney(orderDetail.getValleyElectricityPrice()); + detail.setDetailSeviceMoney(orderDetail.getValleyServicePrice()); + } + chargeDetails.add(detail); + } + orderInfo.setChargeDetails(chargeDetails); + + // 获取令牌 + String token = getToken(urlAddress, operatorId, operatorSecret, dataSecretIv, signSecret, dataSecret); + if (StringUtils.isBlank(token)) { + return null; + } + // 调用联联平台接口 + JSONObject json = new JSONObject(); + json.put("OrderInfo", orderInfo); + String jsonString = JSON.toJSONString(json); + String result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret); + return result; + } + /** * 站点费率变化推送 notification_stationFee * @@ -880,6 +1042,63 @@ public class LianLianPlatformServiceImpl implements ThirdPartyPlatformService { return result; } + @Override + public String notificationStationFee(String stationId, ThirdPartySecretInfoVO secretInfoVO) { + PushStationFeeVO vo = new PushStationFeeVO(); + List chargeFeeDetailList = new ArrayList<>(); + PushStationFeeVO.ChargeFeeDetail chargeFeeDetail = null; + // 根据站点 id 查询出正在使用的计费模板详情 + List billingPriceVOList = pileBillingTemplateService.queryBillingPrice(stationId); + // 查询设备列表 + List pileDetailVOS = pileBasicInfoService.queryPileDetailList(Lists.newArrayList(stationId)); + + // 获取充电桩类型 + Set equipmentTypeList = pileDetailVOS.stream() + .map(PileInfoVO::getSpeedType) + .collect(Collectors.toSet()); + vo.setOperatorId(Constants.OPERATORID_LIANLIAN); + vo.setStationId("LC" + stationId); + + for (String equipmentType : equipmentTypeList) { + for (BillingPriceVO billingPriceVO : billingPriceVOList) { + chargeFeeDetail = new PushStationFeeVO.ChargeFeeDetail(); + chargeFeeDetail.setEquipmentType(Integer.parseInt(equipmentType)); + chargeFeeDetail.setStartTime(billingPriceVO.getStartTime()); + chargeFeeDetail.setEndTime(billingPriceVO.getEndTime()); + chargeFeeDetail.setElectricityFee(new BigDecimal(billingPriceVO.getElectricityPrice()).setScale(2, RoundingMode.DOWN)); + chargeFeeDetail.setServiceFee(new BigDecimal(billingPriceVO.getServicePrice()).setScale(2, RoundingMode.DOWN)); + chargeFeeDetailList.add(chargeFeeDetail); + } + } + vo.setChargeFeeDetail(chargeFeeDetailList); + + // 通过站点id查询相关配置信息 + // ThirdPartyStationRelationVO relationInfo = thirdPartyStationRelationService.selectRelationInfo(stationId); + // if (relationInfo == null) { + // return null; + // } + String operatorId = secretInfoVO.getTheirOperatorId(); + String operatorSecret = secretInfoVO.getTheirOperatorSecret(); + String signSecret = secretInfoVO.getTheirSigSecret(); + String dataSecret = secretInfoVO.getTheirDataSecret(); + String dataSecretIv = secretInfoVO.getTheirDataSecretIv(); + String urlAddress = secretInfoVO.getTheirUrlPrefix(); + + String url = urlAddress + "notification_stationFee"; + + // 获取令牌 + String token = getToken(urlAddress, operatorId, operatorSecret, dataSecretIv, signSecret, dataSecret); + if (StringUtils.isBlank(token)) { + return null; + } + JSONObject json = new JSONObject(); + json.put("StationFee", vo); + String jsonString = JSON.toJSONString(json); + // 发送请求 + String result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret); + return result; + } + /** * */ diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/neimenggu/service/NeiMengGuPlatformServiceImpl.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/neimenggu/service/NeiMengGuPlatformServiceImpl.java index 708a856e0..8e895898b 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/neimenggu/service/NeiMengGuPlatformServiceImpl.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/neimenggu/service/NeiMengGuPlatformServiceImpl.java @@ -476,6 +476,67 @@ public class NeiMengGuPlatformServiceImpl implements ThirdPartyPlatformService { return result; } + @Override + public String notificationChargeOrderInfo(String orderCode, ThirdPartySecretInfoVO secretInfoVO) { + // 根据订单号查询出信息 + OrderBasicInfo orderBasicInfo = orderBasicInfoService.getOrderInfoByOrderCode(orderCode); + if (orderBasicInfo == null) { + return null; + } + + // 通过站点id查询相关配置信息 + // ThirdPartyStationRelationVO relationInfo = thirdPartyStationRelationService.selectRelationInfo(orderBasicInfo.getStationId()); + // if (relationInfo == null) { + // return null; + // } + + String operatorId = secretInfoVO.getTheirOperatorId(); + String operatorSecret = secretInfoVO.getTheirOperatorSecret(); + String signSecret = secretInfoVO.getTheirSigSecret(); + String dataSecret = secretInfoVO.getTheirDataSecret(); + String dataSecretIv = secretInfoVO.getTheirDataSecretIv(); + String urlAddress = secretInfoVO.getTheirUrlPrefix(); + + // 根据订单号查询订单详情 + OrderDetail orderDetail = orderBasicInfoService.getOrderDetailByOrderCode(orderCode); + if (orderDetail == null) { + return null; + } + + // 推送地址 + String url = urlAddress + "notification_orderInfo"; + + // 拼装成内蒙古平台所需格式对象 + ChargeOrderInfo orderInfo = transformChargeOrderInfo(orderBasicInfo, orderDetail); + orderInfo.setOperatorID(operatorId); + String equipmentOwnerID; + if (MerchantUtils.isXiXiaoMerchant(orderBasicInfo.getMerchantId())) { + equipmentOwnerID = Constants.OPERATORID_XI_XIAO; + } else { + equipmentOwnerID = Constants.OPERATORID_LIANLIAN; + } + 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; + } + // 调用联联平台接口 + JSONObject json = new JSONObject(); + json.put("ChargeOrderInfo", orderInfo); + String jsonString = JSON.toJSONString(json); + String result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret); + return result; + } + /** * 推送充电状态 notification_equip_charge_status * 推送充电状态信息 supervise_notification_equip_charge_status