From fb23c9c4349664139f74bad48bc7a6b36fc20e92 Mon Sep 17 00:00:00 2001 From: Lemon Date: Wed, 14 Aug 2024 10:36:03 +0800 Subject: [PATCH] =?UTF-8?q?update=20=20=E6=B5=99=E6=B1=9F=E7=9C=81?= =?UTF-8?q?=E5=B9=B3=E5=8F=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../thirdparty/common/CommonService.java | 3 + .../common/NotificationService.java | 4 +- .../platform/common/StationInfo.java | 17 +++ .../domain/SupEquipChargeStatusInfo.java | 24 ++++ .../impl/ZheJiangPlatformServiceImpl.java | 109 ++++++++++++------ 5 files changed, 118 insertions(+), 39 deletions(-) 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 482cad3cb..1141aa51a 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 @@ -436,7 +436,10 @@ public class CommonService { dto.setStatus(changedStatus); dto.setPlatformType(thirdPartySecretInfoVO.getPlatformType()); dto.setOrderCode(orderInfo.getOrderCode()); + notificationService.notificationConnectorChargeStatus(dto); + + notificationService.notificationStationStatus(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 ebcad5745..d57f12a2c 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 @@ -120,8 +120,10 @@ public class NotificationService { // 根据平台类型获取Service ThirdPartyPlatformService platformService = ThirdPartyPlatformFactory.getInvokeStrategy(secretInfoVO.getPlatformType()); platformService.notificationConnectorChargeStatus(orderCode, secretInfoVO); + + platformService.notificationEquipChargeStatus(orderCode); } catch (Exception e) { - logger.error("设备充电中状态变化推送error:{}", e.getMessage()); + logger.error("设备充电中状态变化推送error:", e); } } } diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/common/StationInfo.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/common/StationInfo.java index 30d917f22..203210485 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/common/StationInfo.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/common/StationInfo.java @@ -370,4 +370,21 @@ public class StationInfo extends BaseStationInfo { @JSONField(name = "ParkingLockFlag") private Integer parkingLockFlag; + /** + * 充电计费信息 + */ + @JSONField(name = "PolicyInfos") + private List policyInfos; + + @Data + public static class PolicyInfo{ + @JSONField(name = "StartTime") + private String startTime; + + @JSONField(name = "ElecFee") + private BigDecimal elecFee; + + @JSONField(name = "ServiceFee") + private BigDecimal serviceFee; + } } diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/domain/SupEquipChargeStatusInfo.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/domain/SupEquipChargeStatusInfo.java index 5496ff1e6..7517c5f17 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/domain/SupEquipChargeStatusInfo.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/domain/SupEquipChargeStatusInfo.java @@ -102,6 +102,12 @@ public class SupEquipChargeStatusInfo { @JSONField(name = "CurrentA") private BigDecimal currentA; + /** + * A相电压 + */ + @JSONField(name = "VoltageA") + private BigDecimal voltageA; + /** * 电池剩余电量 * 小数点后1位 @@ -127,4 +133,22 @@ public class SupEquipChargeStatusInfo { */ @JSONField(name = "TotalPower") private BigDecimal totalPower; + + /** + * 上报时间 + */ + @JSONField(name = "EventTime") + private String eventTime; + + /** + * 输出电压 + */ + @JSONField(name = "ChargeVoltage") + private BigDecimal chargeVoltage; + + /** + * 输出电流 + */ + @JSONField(name = "ChargeCurrent") + private BigDecimal chargeCurrent; } 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 bcbb5e7d9..f7840fa74 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 @@ -20,6 +20,7 @@ import com.jsowell.common.util.JWTUtils; import com.jsowell.common.util.PageUtils; import com.jsowell.common.util.StringUtils; import com.jsowell.pile.domain.*; +import com.jsowell.pile.dto.PushRealTimeInfoDTO; import com.jsowell.pile.dto.QueryEquipChargeStatusDTO; import com.jsowell.pile.dto.QueryOperatorInfoDTO; import com.jsowell.pile.dto.QueryStationInfoDTO; @@ -32,8 +33,11 @@ import com.jsowell.pile.vo.base.MerchantInfoVO; 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.uniapp.customer.CurrentTimePriceDetails; import com.jsowell.pile.vo.web.PileConnectorInfoVO; +import com.jsowell.pile.vo.web.PileMerchantInfoVO; import com.jsowell.pile.vo.web.PileStationVO; +import com.jsowell.pile.vo.zdl.EquipBusinessPolicyVO; import com.jsowell.thirdparty.lianlian.vo.AccessTokenVO; import com.jsowell.thirdparty.lianlian.vo.QueryChargingStatusVO; import com.jsowell.thirdparty.platform.domain.*; @@ -257,12 +261,35 @@ public class ZheJiangPlatformServiceImpl implements ThirdPartyPlatformService { stationInfo.setPrinterFlag(Integer.valueOf(pileStationInfo.getPrinterFlag())); stationInfo.setBarrierFlag(Integer.valueOf(pileStationInfo.getBarrierFlag())); stationInfo.setParkingLockFlag(Integer.valueOf(pileStationInfo.getParkingLockFlag())); + // 根据桩号查询正在使用的计费模板 + List billingPriceVOList = pileBillingTemplateService.queryBillingPrice(String.valueOf(pileStationInfo.getId())); + + if (CollectionUtils.isEmpty(billingPriceVOList)) { + return null; + } + SupStationInfo.PolicyInfo policyInfo = null; + // 获取计费模板 + List policyInfoList = new ArrayList<>(); + for (BillingPriceVO billingPriceVO : billingPriceVOList) { + // 将时段开始时间、电费、服务费信息进行封装 + policyInfo = new SupStationInfo.PolicyInfo(); + String startTime = billingPriceVO.getStartTime() + ":00"; // 00:00:00 格式 + // 需要将中间的冒号去掉,改为 000000 格式 + String replace = StringUtils.replace(startTime, ":", ""); + policyInfo.setStartTime(replace); + policyInfo.setElecFee(new BigDecimal(billingPriceVO.getElectricityPrice()).setScale(4, BigDecimal.ROUND_HALF_UP)); + policyInfo.setServiceFee(new BigDecimal(billingPriceVO.getServicePrice()).setScale(4, BigDecimal.ROUND_HALF_UP)); + + policyInfoList.add(policyInfo); + } + stationInfo.setPolicyInfos(policyInfoList); List pileList = pileBasicInfoService.getPileListForLianLian(stationId); if (CollectionUtils.isNotEmpty(pileList)) { stationInfo.setEquipmentInfos(pileList); // 充电设备信息列表 } resultList.add(stationInfo); } + Map map = new LinkedHashMap<>(); map.put("PageNo", pageInfo.getPageNum()); map.put("PageCount", pageInfo.getPages()); @@ -292,10 +319,8 @@ public class ZheJiangPlatformServiceImpl implements ThirdPartyPlatformService { PileStationInfo pileStationInfo = pileStationInfoService.selectPileStationInfoById(Long.parseLong(stationId)); // 查询第三方平台配置信息 - ThirdPartySecretInfoVO thirdPartySecretInfoVO = thirdpartySecretInfoService.queryByThirdPlatformType(thirdPlatformType); - if (thirdPartySecretInfoVO == null) { - throw new BusinessException("", "无此平台配置信息"); - } + ThirdPartySecretInfoVO thirdPartySecretInfoVO = getZheJiangPlatformSecretInfo(); + String operatorId = thirdPartySecretInfoVO.getOurOperatorId(); String operatorSecret = thirdPartySecretInfoVO.getTheirOperatorSecret(); String signSecret = thirdPartySecretInfoVO.getTheirSigSecret(); @@ -454,44 +479,52 @@ public class ZheJiangPlatformServiceImpl implements ThirdPartyPlatformService { public String notificationEquipChargeStatus(String orderCode) { // 根据订单号查询订单信息 OrderBasicInfo orderInfo = orderBasicInfoService.getOrderInfoByOrderCode(orderCode); - // 通过第三方平台类型查询相关配置信息 - ThirdPartyStationRelation relation = new ThirdPartyStationRelation(); - relation.setThirdPartyType(orderInfo.getThirdPartyType()); - ThirdPartyStationRelationVO relationInfo = thirdPartyStationRelationService.selectRelationInfo(relation); - if (relationInfo == null) { - return null; - } - String operatorId = relationInfo.getOperatorId(); - String operatorSecret = relationInfo.getOperatorSecret(); - String signSecret = relationInfo.getSignSecret(); - String dataSecret = relationInfo.getDataSecret(); - String dataSecretIv = relationInfo.getDataSecretIv(); - String urlAddress = relationInfo.getUrlAddress(); - String thirdPartyType = relationInfo.getThirdPartyType(); + // 查询枪口状态 + PileConnectorInfoVO info = pileConnectorInfoService.getPileConnectorInfoByConnectorCode(orderInfo.getPileConnectorCode()); - // 调用 查询充电状态方法 - QueryEquipChargeStatusDTO dto = new QueryEquipChargeStatusDTO(); - dto.setStartChargeSeq(orderCode); - // 根据type获取operatorId - String operatorIdByType = ThirdPartyOperatorIdEnum.getOperatorIdByType(thirdPartyType); - dto.setOperatorID(operatorIdByType); - Map map = queryEquipChargeStatus(dto); - if (map == null) { - return null; + // 查询相关配置信息 + ThirdPartySecretInfoVO zheJiangPlatformSecretInfo = getZheJiangPlatformSecretInfo(); + + String operatorId = zheJiangPlatformSecretInfo.getTheirOperatorId(); + String operatorSecret = zheJiangPlatformSecretInfo.getTheirOperatorSecret(); + String signSecret = zheJiangPlatformSecretInfo.getTheirSigSecret(); + String dataSecret = zheJiangPlatformSecretInfo.getTheirDataSecret(); + String dataSecretIv = zheJiangPlatformSecretInfo.getTheirDataSecretIv(); + String urlAddress = zheJiangPlatformSecretInfo.getTheirUrlPrefix(); + + String dateTime = DateUtils.getDateTime(); + SupEquipChargeStatusInfo supEquipChargeStatusInfo = SupEquipChargeStatusInfo.builder() + .operatorID(Constants.OPERATORID_JIANG_SU) + .equipmentOwnerID(Constants.OPERATORID_JIANG_SU) + .stationID(orderInfo.getStationId()) + .equipmentID(orderInfo.getPileSn()) + .connectorID(orderInfo.getPileConnectorCode()) + .orderNo(orderInfo.getOrderCode()) + .orderStatus(2) + .pushTimeStamp(dateTime) + .connectorStatus(info.getStatus()) // 3-充电中 + .currentA(info.getCurrent().setScale(1, BigDecimal.ROUND_HALF_UP)) + .voltageA(info.getVoltage().setScale(1, BigDecimal.ROUND_HALF_UP)) + .soc(new BigDecimal(info.getSOC())) + .startTime(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, orderInfo.getChargeStartTime())) + .endTime(dateTime) + .totalPower(info.getChargingDegree()) + .eventTime(dateTime) + .chargeVoltage(info.getVoltage().setScale(1, BigDecimal.ROUND_HALF_UP)) + .chargeCurrent(info.getCurrent().setScale(1, BigDecimal.ROUND_HALF_UP)) + .build(); + + // 查询运营商信息 + PileMerchantInfoVO pileMerchantInfoVO = pileMerchantInfoService.queryMerchantInfoByStationId(orderInfo.getStationId()); + String organizationCode = pileMerchantInfoVO.getOrganizationCode(); + if (StringUtils.isNotBlank(organizationCode) && organizationCode.length() == 18) { + String equipmentOwnerId = StringUtils.substring(organizationCode, organizationCode.length() - 10, organizationCode.length() - 1); + supEquipChargeStatusInfo.setEquipmentOwnerID(equipmentOwnerId); } - String data = map.get("Data"); - // 解密data (此处解密需用 thirdparty_platform_config 的密钥配置) - ThirdPartyPlatformConfig configInfo = thirdPartyPlatformConfigService.getInfoByOperatorId(operatorIdByType); - ThirdPartySecretInfoVO thirdPartySecretInfoVO = thirdpartySecretInfoService.queryByThirdPlatformType(thirdPlatformType); - byte[] plainText = Cryptos.aesDecrypt(Encodes.decodeBase64(data), - configInfo.getDataSecret().getBytes(), configInfo.getDataSecretIv().getBytes()); - String dataStr = new String(plainText, StandardCharsets.UTF_8); - // 转成对应的对象 - QueryChargingStatusVO vo = JSONObject.parseObject(dataStr, QueryChargingStatusVO.class); String url = urlAddress + BusinessInformationExchangeEnum.NOTIFICATION_EQUIP_CHARGE_STATUS.getValue(); - // 调用联联平台接口 - String jsonString = JSON.toJSONString(vo); + // 调用平台接口 + String jsonString = JSON.toJSONString(supEquipChargeStatusInfo); // 获取令牌 String token = getToken(urlAddress, operatorId, operatorSecret, dataSecretIv, signSecret, dataSecret);