From 6ea0b1e43374b49b9e423dc2d1275a698d68bcc4 Mon Sep 17 00:00:00 2001 From: Lemon Date: Wed, 22 May 2024 09:38:34 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=20=20=E6=B7=B1=E5=9C=B3?= =?UTF-8?q?=E5=B9=B3=E5=8F=B0=20=E8=BF=87=E7=A8=8B=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E6=8E=A8=E9=80=81=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BusinessInformationExchangeEnum.java | 1 + .../thirdparty/platform/domain/BMSInfo.java | 148 ++++++++++++++++++ .../service/ThirdPartyPlatformService.java | 10 ++ .../impl/ShenZhenPlatformServiceImpl.java | 85 +++++++++- 4 files changed, 239 insertions(+), 5 deletions(-) create mode 100644 jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/domain/BMSInfo.java diff --git a/jsowell-common/src/main/java/com/jsowell/common/enums/thirdparty/BusinessInformationExchangeEnum.java b/jsowell-common/src/main/java/com/jsowell/common/enums/thirdparty/BusinessInformationExchangeEnum.java index 9a9cf44ff..c8451ac68 100644 --- a/jsowell-common/src/main/java/com/jsowell/common/enums/thirdparty/BusinessInformationExchangeEnum.java +++ b/jsowell-common/src/main/java/com/jsowell/common/enums/thirdparty/BusinessInformationExchangeEnum.java @@ -10,6 +10,7 @@ public enum BusinessInformationExchangeEnum { NOTIFICATION_START_CHARGE_RESULT("notification_start_charge_result", "推送启动充电结果"), NOTIFICATION_EQUIP_CHARGE_STATUS("notification_equip_charge_status", "推送充电状态"), NOTIFICATION_STOP_CHARGE_RESULT("notification_stop_charge_result", "推送停止充电结果"), + NOTIFICATION_BMS_INFO("notification_bmsInfo", "过程信息推送"), CHECK_CHARGE_ORDERS("check_charge_orders", "推送订单对账结果信息"), ; private String value; diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/domain/BMSInfo.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/domain/BMSInfo.java new file mode 100644 index 000000000..2f159c503 --- /dev/null +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/domain/BMSInfo.java @@ -0,0 +1,148 @@ +package com.jsowell.thirdparty.platform.domain; + +import com.alibaba.fastjson2.annotation.JSONField; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.math.BigDecimal; + +/** + * 车辆充放电过程信息 + * + * @author Lemon + * @Date 2024/5/21 10:01:02 + */ +@Data +@NoArgsConstructor +@AllArgsConstructor +@Builder +public class BMSInfo { + + /** + * 车辆 VIN 码 + */ + @JSONField(name = "vinCode") + private String vinCode; + + /** + * 车辆 BMS 编码 + */ + @JSONField(name = "BMSCode") + private String bmsCode; + + /** + * 车辆 BMS 版本 + */ + @JSONField(name = "BMSVer") + private String bmsVer; + + /** + * 充电机接口编码 + */ + @JSONField(name = "ConnectorID") + private String connectorID; + + /** + * 最高允许充电电流 + */ + @JSONField(name = "MaxChargeCurrent") + private BigDecimal maxChargeCurrent; + + /** + * 单体最高允许电压 + */ + @JSONField(name = "MaxChargeCellVoltage") + private BigDecimal maxChargeCellVoltage; + + /** + * 最高允许温度 + */ + @JSONField(name = "MaxTemp") + private Integer maxTemp; + + /** + * 电池额定容量 + */ + @JSONField(name = "RatedCapacity") + private Integer ratedCapacity; + + /** + * 总电压 + */ + @JSONField(name = "TatalVoltage") + private BigDecimal tatalVoltage; + + /** + * 总电流 + */ + @JSONField(name = "TotalCurrent") + private BigDecimal totalCurrent; + + /** + * 荷电状态 + */ + @JSONField(name = "Soc") + private Integer soc; + + /** + * 单体最高电压 + */ + @JSONField(name = "VoltageH") + private BigDecimal voltageH; + + /** + * 单体最高电压编号 + */ + @JSONField(name = "VoltageHNumIndex") + private Integer voltageHNumIndex; + + /** + * 单体最高温度 + */ + @JSONField(name = "TemptureH") + private Integer temptureH; + + /** + * 单体最高温度编号 + */ + @JSONField(name = "TemptureHNumIndex") + private Integer temptureHNumIndex; + + /** + * 单体最低温度 + */ + @JSONField(name = "TemptureL") + private Integer temptureL; + + /** + * 单体最低温度编号 + */ + @JSONField(name = "TemptureLNumIndex") + private Integer temptureLNumIndex; + + /** + * 充放电侧能量变化 + */ + @JSONField(name = "CurrentCapacity") + private BigDecimal currentCapacity; + + /** + * 采集时间 + */ + @JSONField(name = "FreshTime") + private String freshTime; + + /** + * 开始充电时间 + */ + @JSONField(name = "StartChargingTime") + private String startChargingTime; + + /** + * 充电时长 + */ + @JSONField(name = "ChargingSessionMin") + private Integer chargingSessionMin; +} 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 497f816f3..5d93fe826 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 @@ -207,6 +207,16 @@ public interface ThirdPartyPlatformService extends InitializingBean { // ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ 由对方平台实现此接口,我方平台调用的通知接口 ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ // // =================================================================================== // + /** + * 过程信息推送 notification_bmsInfo + * 当运营商平台有充放电电池数据过程信息时,推送最新的信息通知到市级监控平台 + * @param pileConnectorCode + * @return + */ + default String notificationBMSInfo(String pileConnectorCode) { + throw new UnsupportedOperationException("This method is not yet implemented"); + } + /** * 充电站信息变化推送 notification_stationInfo * 新站需要推送。当站点信息发生变化时,推送新的信息通知到市级平台 diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/ShenZhenPlatformServiceImpl.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/ShenZhenPlatformServiceImpl.java index 69aa9c9a7..3cde69c7c 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/ShenZhenPlatformServiceImpl.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/ShenZhenPlatformServiceImpl.java @@ -31,10 +31,13 @@ import com.jsowell.pile.vo.base.ConnectorInfoVO; import com.jsowell.pile.vo.base.ThirdPartyStationInfoVO; import com.jsowell.pile.vo.base.ThirdPartyStationRelationVO; import com.jsowell.pile.vo.lianlian.AccumulativeInfoVO; +import com.jsowell.pile.vo.web.OrderListVO; +import com.jsowell.pile.vo.web.PileConnectorInfoVO; import com.jsowell.pile.vo.web.PileStationVO; import com.jsowell.thirdparty.lianlian.domain.*; import com.jsowell.thirdparty.lianlian.vo.AccessTokenVO; import com.jsowell.thirdparty.platform.common.StationInfo; +import com.jsowell.thirdparty.platform.domain.BMSInfo; import com.jsowell.thirdparty.platform.domain.StationChargeStatsInfo; import com.jsowell.thirdparty.platform.factory.ThirdPartyPlatformFactory; import com.jsowell.thirdparty.platform.service.ThirdPartyPlatformService; @@ -389,11 +392,8 @@ public class ShenZhenPlatformServiceImpl implements ThirdPartyPlatformService { */ @Override public Map queryStationStats(QueryStationInfoDTO dto) { - // 根据 operatorId 查出配置密钥信息 - ThirdPartySecretInfoVO secretInfoVO = thirdpartySecretInfoService.queryByOperatorId(dto.getOperatorId()); - if (secretInfoVO == null) { - return null; - } + // 查出配置密钥信息 + ThirdPartySecretInfoVO secretInfoVO = getShenZhenSecretInfo(); // 根据站点id 查出这段时间的充电量 List list = orderBasicInfoService.getAccumulativeInfoForLianLian(dto); if (CollectionUtils.isEmpty(list)) { @@ -477,6 +477,81 @@ public class ShenZhenPlatformServiceImpl implements ThirdPartyPlatformService { } + /** + * 过程信息推送 notification_bmsInfo + * 当运营商平台有充放电电池数据过程信息时,推送最新的信息通知到市级监控平台 + * @param pileConnectorCode + * @return + */ + @Override + public String notificationBMSInfo(String pileConnectorCode) { + BMSInfo bmsInfo = null; + JSONObject resultJson = new JSONObject(); + String pileSn = StringUtils.substring(pileConnectorCode, 0, 14); + // 查询枪口状态 + PileConnectorInfoVO info = pileConnectorInfoService.getPileConnectorInfoByConnectorCode(pileConnectorCode); + Integer connectorStatus = info.getStatus(); + resultJson.put("ConnectorID", pileConnectorCode); + resultJson.put("Status", connectorStatus); + if (!StringUtils.equals(PileConnectorDataBaseStatusEnum.OCCUPIED_CHARGING.getValue(), String.valueOf(connectorStatus))) { + resultJson.put("BmsInfo", null); + }else { + // 获取正在充电的订单信息 + List orderListVOS = orderBasicInfoService.selectChargingOrder(pileSn); + if (CollectionUtils.isEmpty(orderListVOS)) { + return null; + } + OrderListVO orderVO = orderListVOS.get(0); + // 获取充电电池信息 + List chargingRealTimeData = orderBasicInfoService.getChargingRealTimeData(orderVO.getTransactionCode()); + if (CollectionUtils.isEmpty(chargingRealTimeData)) { + return null; + } + RealTimeMonitorData data = chargingRealTimeData.get(0); + bmsInfo = BMSInfo.builder() + .vinCode(orderVO.getVinCode()) + .bmsCode("") + .bmsVer("") + .connectorID(orderVO.getPileConnectorCode()) + .maxChargeCurrent(new BigDecimal("")) + .maxChargeCellVoltage(new BigDecimal("")) + .maxTemp(0) + .ratedCapacity(0) + .tatalVoltage(new BigDecimal(data.getOutputVoltage())) + .totalCurrent(new BigDecimal(data.getOutputCurrent())) + .soc(Integer.parseInt(data.getSOC())) + .voltageH(new BigDecimal("")) + .voltageHNumIndex(0) + .temptureH(0) + .temptureHNumIndex(0) + .temptureL(0) + .temptureLNumIndex(0) + .currentCapacity(new BigDecimal("")) + .freshTime(DateUtils.getDateTime()) + .startChargingTime(orderVO.getChargeStartTime()) + .chargingSessionMin(Integer.parseInt(data.getSumChargingTime()) * 60) + + .build(); + + resultJson.put("BmsInfo", bmsInfo); + } + ThirdPartySecretInfoVO shenZhenSecretInfo = getShenZhenSecretInfo(); + String operatorId = shenZhenSecretInfo.getTheirOperatorId(); + String operatorSecret = shenZhenSecretInfo.getTheirOperatorSecret(); + String signSecret = shenZhenSecretInfo.getTheirSigSecret(); + String dataSecret = shenZhenSecretInfo.getTheirDataSecret(); + String dataSecretIv = shenZhenSecretInfo.getTheirDataSecretIv(); + String urlAddress = shenZhenSecretInfo.getTheirUrlPrefix(); + String url = urlAddress + BusinessInformationExchangeEnum.NOTIFICATION_BMS_INFO.getValue(); + + // 调用平台接口 + String jsonString = JSON.toJSONString(resultJson); + // 获取令牌 + String token = getToken(urlAddress, operatorId, operatorSecret, dataSecretIv, signSecret, dataSecret); + String result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret); + return result; + } + /** * 获取深圳平台相关密钥信息 * @return