From ca3de9673812cc963238fc4a53561a3d3bd3f640 Mon Sep 17 00:00:00 2001 From: Guoqs <123@jsowell.com> Date: Fri, 9 Aug 2024 11:19:32 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=B9=E6=8E=A5=E6=B5=99=E6=B1=9F=E5=B9=B3?= =?UTF-8?q?=E5=8F=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/ThirdPartyPlatformService.java | 1 + .../impl/QingHaiPlatformServiceImpl.java | 34 ++++---- .../impl/ZheJiangPlatformServiceImpl.java | 86 +++++++++++++++++++ 3 files changed, 103 insertions(+), 18 deletions(-) diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/ThirdPartyPlatformService.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/ThirdPartyPlatformService.java index 33caaf1e8..3bb383ec7 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/ThirdPartyPlatformService.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/ThirdPartyPlatformService.java @@ -385,6 +385,7 @@ public interface ThirdPartyPlatformService extends InitializingBean { /** * 推送充换电站实时功率 + * 浙江省平台: 推送充电站实时功率信息 supervise_notification_realtime_power_info * @param stationIds * @return */ diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/QingHaiPlatformServiceImpl.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/QingHaiPlatformServiceImpl.java index 39adb17ba..8a85568b3 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/QingHaiPlatformServiceImpl.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/QingHaiPlatformServiceImpl.java @@ -108,11 +108,12 @@ public class QingHaiPlatformServiceImpl implements ThirdPartyPlatformService { /** * 请求令牌 query_token + * * @param dto * @return */ @Override - public Map queryToken(CommonParamsDTO dto) { + public Map queryToken(CommonParamsDTO dto) { String operatorId = dto.getOperatorID(); // 通过operatorId 查出 operatorSecret ThirdPartyPlatformConfig platformConfig = thirdPartyPlatformConfigService.getInfoByOperatorId(operatorId); @@ -183,6 +184,7 @@ public class QingHaiPlatformServiceImpl implements ThirdPartyPlatformService { /** * 查询站点信息 query_stations_info + * * @param dto 查询站点信息dto * @return */ @@ -289,6 +291,7 @@ public class QingHaiPlatformServiceImpl implements ThirdPartyPlatformService { /** * 设备状态变化推送(在0x13中调用统一推送接口) * notification_stationStatus + * * @param dto * @return */ @@ -350,7 +353,7 @@ public class QingHaiPlatformServiceImpl implements ThirdPartyPlatformService { ConnectorChargeStatusInfo info; if (CollectionUtils.isEmpty(realTimeData)) { info = new ConnectorChargeStatusInfo(); - }else { + } else { RealTimeMonitorData data = realTimeData.get(0); String orderStatus = orderInfo.getOrderStatus(); if (StringUtils.equals(orderStatus, OrderStatusEnum.IN_THE_CHARGING.getValue())) { @@ -405,6 +408,7 @@ public class QingHaiPlatformServiceImpl implements ThirdPartyPlatformService { /** * 推送充换电站实时功率 supervise_notification_realtime_power_info + * * @return */ public String notificationPowerInfo(List stationIds) { @@ -412,17 +416,11 @@ public class QingHaiPlatformServiceImpl implements ThirdPartyPlatformService { List list = new ArrayList<>(); String dateTimeNow = DateUtils.dateTimeNow(DateUtils.YYYY_MM_DD_HH_MM_SS); - List supPileInfoList = null; - SupStationPowerInfo - .EquipmentPowerInfo supPileInfo = null; + List supPileInfoList = null; + SupStationPowerInfo.EquipmentPowerInfo supPileInfo = null; - List connectorPowerInfoList = null; - SupStationPowerInfo - .EquipmentPowerInfo - .ConnectorPowerInfo connectorPowerInfo = null; + List connectorPowerInfoList; + SupStationPowerInfo.EquipmentPowerInfo.ConnectorPowerInfo connectorPowerInfo; for (String stationId : stationIds) { BigDecimal stationPower = BigDecimal.ZERO; supStationPowerInfo = new SupStationPowerInfo(); @@ -437,7 +435,7 @@ public class QingHaiPlatformServiceImpl implements ThirdPartyPlatformService { if (StringUtils.isNotBlank(organizationCode) && organizationCode.length() == 18) { String equipmentOwnerId = StringUtils.substring(organizationCode, organizationCode.length() - 10, organizationCode.length() - 1); supStationPowerInfo.setEquipmentOwnerID(equipmentOwnerId); - }else { + } else { supStationPowerInfo.setEquipmentOwnerID(Constants.OPERATORID_JIANG_SU); } @@ -471,9 +469,7 @@ public class QingHaiPlatformServiceImpl implements ThirdPartyPlatformService { continue; } BigDecimal instantPower = pileConnectorInfoVO.getInstantPower() == null ? BigDecimal.ZERO : pileConnectorInfoVO.getInstantPower(); - connectorPowerInfo = new SupStationPowerInfo - .EquipmentPowerInfo - .ConnectorPowerInfo(); + connectorPowerInfo = new SupStationPowerInfo.EquipmentPowerInfo.ConnectorPowerInfo(); connectorPowerInfo.setConnectorID(pileConnectorInfoVO.getPileConnectorCode()); connectorPowerInfo.setEquipmentClassification(Constants.one); connectorPowerInfo.setDataTime(dateTimeNow); @@ -525,6 +521,7 @@ public class QingHaiPlatformServiceImpl implements ThirdPartyPlatformService { /** * 查询业务策略信息结果 query_equip_business_policy + * * @param dto 请求启动充电DTO * @return */ @@ -585,6 +582,7 @@ public class QingHaiPlatformServiceImpl implements ThirdPartyPlatformService { /** * 推送充电订单信息 notification_charge_order_info + * * @param orderCode 订单编号 * @return */ @@ -632,7 +630,7 @@ public class QingHaiPlatformServiceImpl implements ThirdPartyPlatformService { if (StringUtils.equals("4", payMode)) { // 微信支付 chargeOrderInfo.setPayWay(2); - }else { + } else { chargeOrderInfo.setPayWay(6); } @@ -662,7 +660,6 @@ public class QingHaiPlatformServiceImpl implements ThirdPartyPlatformService { } - // 获取青海平台配置密钥信息 private ThirdPartyStationRelationVO getQingHaiSettingInfo() { // 通过第三方平台类型查询相关配置信息 @@ -675,6 +672,7 @@ public class QingHaiPlatformServiceImpl implements ThirdPartyPlatformService { /** * 将需要发送至对接平台的的返回参数加密返回 + * * @param jsonObject * @return */ 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 28ec123c7..a590a4906 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 @@ -33,6 +33,7 @@ import com.jsowell.pile.vo.base.ThirdPartyStationInfoVO; import com.jsowell.pile.vo.base.ThirdPartyStationRelationVO; import com.jsowell.pile.vo.uniapp.customer.BillingPriceVO; import com.jsowell.pile.vo.web.PileConnectorInfoVO; +import com.jsowell.pile.vo.web.PileStationVO; import com.jsowell.thirdparty.lianlian.vo.AccessTokenVO; import com.jsowell.thirdparty.lianlian.vo.QueryChargingStatusVO; import com.jsowell.thirdparty.platform.common.StationInfo; @@ -630,4 +631,89 @@ public class ZheJiangPlatformServiceImpl implements ThirdPartyPlatformService { * 推送充电站实时功率信息 * supervise_notification_realtime_power_info */ + @Override + public String notificationPowerInfo(List stationIds) { + List supStationPowerInfoList = new ArrayList<>(); + stationIds.forEach(stationId -> { + PileStationVO stationInfo = pileStationInfoService.getStationInfo(stationId); + String dateTimeNow = DateUtils.dateTimeNow(DateUtils.YYYY_MM_DD_HH_MM_SS); + SupStationPowerInfo supStationPowerInfo = new SupStationPowerInfo(); + // 根据站点id查询桩列表 + List pileList = pileBasicInfoService.getPileListByStationId(stationId); + SupStationPowerInfo.EquipmentPowerInfo equipmentPowerInfo = null; + List equipmentPowerInfoList = new ArrayList<>(); + BigDecimal stationInstantPower = BigDecimal.ZERO; + supStationPowerInfo.setOperatorId(Constants.OPERATORID_LIANLIAN); + supStationPowerInfo.setEquipmentOwnerID(stationInfo.getMerchantId()); + supStationPowerInfo.setStationId(stationId); + supStationPowerInfo.setStationClassification(1); + supStationPowerInfo.setDataTime(dateTimeNow); + + for (PileBasicInfo pileBasicInfo : pileList) { + equipmentPowerInfo = new SupStationPowerInfo.EquipmentPowerInfo(); + equipmentPowerInfo.setEquipmentID(pileBasicInfo.getSn()); + equipmentPowerInfo.setEquipmentClassification(1); + equipmentPowerInfo.setDataTime(dateTimeNow); + + // 根据桩sn查询枪口列表 + List pileConnectorInfos = pileConnectorInfoService.selectPileConnectorInfoList(pileBasicInfo.getSn()); + // 如果枪口状态为充电中,则查询枪口功率等信息 + SupStationPowerInfo.EquipmentPowerInfo.ConnectorPowerInfo connectorPowerInfo = null; + List connectorPowerInfoList = new ArrayList<>(); + // 初始化桩功率 + BigDecimal pileInstantPower = BigDecimal.ZERO; + for (PileConnectorInfo pileConnectorInfo : pileConnectorInfos) { + if (StringUtils.equals(PileConnectorDataBaseStatusEnum.OCCUPIED_CHARGING.getValue(), pileConnectorInfo.getStatus())) { + // 查询充电枪口状态 + PileConnectorInfoVO connectorInfo = pileConnectorInfoService.getPileConnectorInfoByConnectorCode(pileConnectorInfo.getPileConnectorCode()); + if (Objects.isNull(connectorInfo)) { + throw new BusinessException(ReturnCodeEnum.CODE_CONNECTOR_INFO_NULL_ERROR); + } + BigDecimal instantPower = connectorInfo.getInstantPower(); + pileInstantPower = pileInstantPower.add(instantPower); + + connectorPowerInfo = new SupStationPowerInfo.EquipmentPowerInfo.ConnectorPowerInfo(); + connectorPowerInfo.setConnectorID(connectorInfo.getPileConnectorCode()); + connectorPowerInfo.setEquipmentClassification(1); + connectorPowerInfo.setDataTime(dateTimeNow); + connectorPowerInfo.setConnectorRealTimePower(instantPower); + + connectorPowerInfoList.add(connectorPowerInfo); + } + // 计算桩的功率(枪口功率之和) + equipmentPowerInfo.setEquipRealTimePower(pileInstantPower); + // 汇总站点功率 + stationInstantPower = stationInstantPower.add(pileInstantPower); + + equipmentPowerInfo.setConnectorPowerInfos(connectorPowerInfoList); + equipmentPowerInfoList.add(equipmentPowerInfo); + } + } + supStationPowerInfo.setStationRealTimePower(stationInstantPower); + supStationPowerInfo.setEquipmentPowerInfos(equipmentPowerInfoList); + supStationPowerInfoList.add(supStationPowerInfo); + }); + // 发送请求 + ThirdPartySecretInfoVO ningXiaSecretInfo = getZheJiangPlatformSecretInfo(); + + String operatorId = ningXiaSecretInfo.getOurOperatorId(); + String operatorSecret = ningXiaSecretInfo.getTheirOperatorSecret(); + String signSecret = ningXiaSecretInfo.getTheirSigSecret(); + String dataSecret = ningXiaSecretInfo.getTheirDataSecret(); + String dataSecretIv = ningXiaSecretInfo.getTheirDataSecretIv(); + String urlAddress = ningXiaSecretInfo.getTheirUrlPrefix(); + String url = urlAddress + "supervise_notification_realtime_power_info"; + // 获取令牌 + String token = getToken(urlAddress, operatorId, operatorSecret, dataSecretIv, signSecret, dataSecret); + if (StringUtils.isBlank(token)) { + return null; + } + // 调用平台接口 + JSONObject json = new JSONObject(); + json.put("SupStationPowerInfos", supStationPowerInfoList); + String jsonString = JSON.toJSONString(json); + String result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret); + return result; + + } }