From e7ebf9a7229ea09b58dcb1253ac9c0438f7f7c53 Mon Sep 17 00:00:00 2001 From: ZZ Date: Thu, 22 Jul 2021 19:49:56 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=85=E7=94=B5=E6=A1=A9=E5=8D=8F=E8=AE=AE?= =?UTF-8?q?=E6=95=B0=E6=8D=AE:0x19=E5=85=85=E7=94=B5=E7=BB=93=E6=9D=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/pilemsg/ChargingCompletedData.java | 127 ++++++++++++++++++ .../service/ChargingCompletedDataLogic.java | 36 +++++ .../com/xhpc/pp/service/RegisterLogic.java | 12 ++ .../src/main/resources/svcmainlogic.xml | 1 + 4 files changed, 176 insertions(+) create mode 100644 xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/pilemsg/ChargingCompletedData.java create mode 100644 xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/service/ChargingCompletedDataLogic.java diff --git a/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/pilemsg/ChargingCompletedData.java b/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/pilemsg/ChargingCompletedData.java new file mode 100644 index 00000000..015b2b94 --- /dev/null +++ b/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/pilemsg/ChargingCompletedData.java @@ -0,0 +1,127 @@ +package com.xhpc.common.pilemsg; + +public class ChargingCompletedData extends BaseData { + + private String orderNo; //交易流水号 + private String pileNo; //桩号 + private String gunId; //枪号 + private String soc; //结束SOC + private String bmsBatteryMonoMinimumVoltage; //BMS单体电池最低电压V + private String bmsBatteryMonoMaximumVoltage; //BMS单体电池最高电压V + private String bmsBatteryMinimumTemperature; //BMS电池最低温度° + private String bmsBatteryMaximumTemperature; //BMS电池最高温度° + private String totalChargingTime; //累计充电时间min + private String outputEnergy; //电桩输出能量kWh + private String chargerSn; //电桩充电机编号 + + public String getOrderNo() { + + return orderNo; + } + + public void setOrderNo(String orderNo) { + + this.orderNo = orderNo; + } + + public String getPileNo() { + + return pileNo; + } + + public void setPileNo(String pileNo) { + + this.pileNo = pileNo; + } + + public String getGunId() { + + return gunId; + } + + public void setGunId(String gunId) { + + this.gunId = gunId; + } + + public String getSoc() { + + return soc; + } + + public void setSoc(String soc) { + + this.soc = soc; + } + + public String getBmsBatteryMonoMinimumVoltage() { + + return bmsBatteryMonoMinimumVoltage; + } + + public void setBmsBatteryMonoMinimumVoltage(String bmsBatteryMonoMinimumVoltage) { + + this.bmsBatteryMonoMinimumVoltage = bmsBatteryMonoMinimumVoltage; + } + + public String getBmsBatteryMonoMaximumVoltage() { + + return bmsBatteryMonoMaximumVoltage; + } + + public void setBmsBatteryMonoMaximumVoltage(String bmsBatteryMonoMaximumVoltage) { + + this.bmsBatteryMonoMaximumVoltage = bmsBatteryMonoMaximumVoltage; + } + + public String getBmsBatteryMinimumTemperature() { + + return bmsBatteryMinimumTemperature; + } + + public void setBmsBatteryMinimumTemperature(String bmsBatteryMinimumTemperature) { + + this.bmsBatteryMinimumTemperature = bmsBatteryMinimumTemperature; + } + + public String getBmsBatteryMaximumTemperature() { + + return bmsBatteryMaximumTemperature; + } + + public void setBmsBatteryMaximumTemperature(String bmsBatteryMaximumTemperature) { + + this.bmsBatteryMaximumTemperature = bmsBatteryMaximumTemperature; + } + + public String getTotalChargingTime() { + + return totalChargingTime; + } + + public void setTotalChargingTime(String totalChargingTime) { + + this.totalChargingTime = totalChargingTime; + } + + public String getOutputEnergy() { + + return outputEnergy; + } + + public void setOutputEnergy(String outputEnergy) { + + this.outputEnergy = outputEnergy; + } + + public String getChargerSn() { + + return chargerSn; + } + + public void setChargerSn(String chargerSn) { + + this.chargerSn = chargerSn; + } + +} diff --git a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/service/ChargingCompletedDataLogic.java b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/service/ChargingCompletedDataLogic.java new file mode 100644 index 00000000..f1f34bdf --- /dev/null +++ b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/service/ChargingCompletedDataLogic.java @@ -0,0 +1,36 @@ +package com.xhpc.pp.service; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.xhpc.common.pilemsg.ChargingCompletedData; +import com.xhpc.pp.tx.ServiceParameter; +import com.xhpc.pp.tx.ServiceResult; +import com.xhpc.pp.tx.logic.ServiceLogic; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.context.annotation.Lazy; +import org.springframework.stereotype.Component; + +import java.util.Map; + +import static com.xhpc.pp.server.ChargingPileServer.REDIS; + +@Lazy +@Component("ChargingCompletedDataLogic") +public class ChargingCompletedDataLogic implements ServiceLogic { + + private static Logger log = LoggerFactory.getLogger(ChargingCompletedDataLogic.class); + + @Override + public ServiceResult service(ServiceParameter sp) throws Exception { + + Map req = sp.getParameters(); + ObjectMapper objectMapper = new ObjectMapper(); + ChargingCompletedData chargingCompletedData = objectMapper.convertValue(req, ChargingCompletedData.class); + String orderNo = chargingCompletedData.getOrderNo(); + Map cacheOrder = REDIS.getCacheMap(orderNo); + cacheOrder.put("completed", chargingCompletedData); + REDIS.setCacheMap(orderNo, cacheOrder); + return new ServiceResult(false); + } + +} diff --git a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/service/RegisterLogic.java b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/service/RegisterLogic.java index 43e378fd..58482340 100644 --- a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/service/RegisterLogic.java +++ b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/service/RegisterLogic.java @@ -10,6 +10,7 @@ import org.slf4j.LoggerFactory; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Component; +import java.util.HashMap; import java.util.Map; import java.util.Set; @@ -36,6 +37,17 @@ public class RegisterLogic implements ServiceLogic { hexCode = ServiceResult.HEX_FAIL; resultCode = ServiceResult.FAIL; } + int gunNum = Integer.parseInt(req.get("gunNum").toString()); + for (int gunN = 1; gunN <= gunNum; gunN++) { + String gunId = String.format("%02d", (int) gunN); + Map cacheGun = REDIS.getCacheMap(pileNo.concat(gunId)); + if (cacheGun == null) { + cacheGun = new HashMap<>(); + } + int seq = (int) cacheGun.getOrDefault("seq", 0); + cacheGun.put("seq", seq); + REDIS.setCacheMap(pileNo.concat(gunId), cacheGun); + } String resultStr = "680C00000002".concat(pileNo).concat(hexCode); resultStr = resultStr.concat(CRCCalculator.calcCrc(resultStr)); return new ServiceResult(HexUtils.toBytes(resultStr), resultCode); diff --git a/xhpc-modules/xhpc-power-pile/src/main/resources/svcmainlogic.xml b/xhpc-modules/xhpc-power-pile/src/main/resources/svcmainlogic.xml index 55ea5d3a..e16a06f0 100644 --- a/xhpc-modules/xhpc-power-pile/src/main/resources/svcmainlogic.xml +++ b/xhpc-modules/xhpc-power-pile/src/main/resources/svcmainlogic.xml @@ -15,5 +15,6 @@ +