diff --git a/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/pilemsg/BaseData.java b/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/pilemsg/BaseData.java new file mode 100644 index 00000000..5206864f --- /dev/null +++ b/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/pilemsg/BaseData.java @@ -0,0 +1,60 @@ +package com.xhpc.common.pilemsg; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +import java.io.Serializable; +import java.util.Date; + +@JsonIgnoreProperties +public class BaseData implements Serializable { + + private static final long serialVersionUID = 1L; + + private String createBy; + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date createTime; + private String hex; + private int seq; + + public int getSeq() { + + return seq; + } + + public void setSeq(int seq) { + + this.seq = seq; + } + + public String getCreateBy() { + + return createBy; + } + + public void setCreateBy(String createBy) { + + this.createBy = createBy; + } + + public Date getCreateTime() { + + return createTime; + } + + public void setCreateTime(Date createTime) { + + this.createTime = createTime; + } + + public String getHex() { + + return hex; + } + + public void setHex(String hex) { + + this.hex = hex; + } + +} diff --git a/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/pilemsg/ChargingHandshakeData.java b/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/pilemsg/ChargingHandshakeData.java new file mode 100644 index 00000000..660756c7 --- /dev/null +++ b/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/pilemsg/ChargingHandshakeData.java @@ -0,0 +1,193 @@ +package com.xhpc.common.pilemsg; + +public class ChargingHandshakeData extends BaseData { + + private String orderNo; //交易流水号 + private String pileNo; //桩号 + private String gunId; //枪号 + private String bmsProtocolVersion; //BMS协议版本 + private String bmsBatteryType; //BMS电池类型 + private String bmsBatteryNominalTotalCapacity; //BMS整车额定容量Ah + private String bmsBatteryNominalTotalVoltage; //BMS整车额定电压V + private String bmsBatteryFactory; //BMS电池厂商 + private String bmsBatteryPackSn; //BMS电池组序号 + private String bmsBatteryPackProdYear; //BMS电池组生产年偏移量(+1985年) + private String bmsBatteryPackProdMonth; //BMS电池组生产月 + private String bmsBatteryPackProdDate; //BMS电池组生产日 + private String bmsBatteryRecycleTime; //BMS电池组充电次数 + private String bmsBatteryOwnership; //BMS电池组产权标识 + private String reserved; //预留位 + private String vin; //vin码 + private String bmsSoftwareVersion; //BMS软件版本号 + + 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 getBmsProtocolVersion() { + + return bmsProtocolVersion; + } + + public void setBmsProtocolVersion(String bmsProtocolVersion) { + + this.bmsProtocolVersion = bmsProtocolVersion; + } + + public String getBmsBatteryType() { + + return bmsBatteryType; + } + + public void setBmsBatteryType(String bmsBatteryType) { + + this.bmsBatteryType = bmsBatteryType; + } + + public String getBmsBatteryNominalTotalCapacity() { + + return bmsBatteryNominalTotalCapacity; + } + + public void setBmsBatteryNominalTotalCapacity(String bmsBatteryNominalTotalCapacity) { + + this.bmsBatteryNominalTotalCapacity = bmsBatteryNominalTotalCapacity; + } + + public String getBmsBatteryNominalTotalVoltage() { + + return bmsBatteryNominalTotalVoltage; + } + + public void setBmsBatteryNominalTotalVoltage(String bmsBatteryNominalTotalVoltage) { + + this.bmsBatteryNominalTotalVoltage = bmsBatteryNominalTotalVoltage; + } + + public String getBmsBatteryFactory() { + + return bmsBatteryFactory; + } + + public void setBmsBatteryFactory(String bmsBatteryFactory) { + + this.bmsBatteryFactory = bmsBatteryFactory; + } + + public String getBmsBatteryPackSn() { + + return bmsBatteryPackSn; + } + + public void setBmsBatteryPackSn(String bmsBatteryPackSn) { + + this.bmsBatteryPackSn = bmsBatteryPackSn; + } + + public String getBmsBatteryPackProdYear() { + + return bmsBatteryPackProdYear; + } + + public void setBmsBatteryPackProdYear(String bmsBatteryPackProdYear) { + + this.bmsBatteryPackProdYear = bmsBatteryPackProdYear; + } + + public String getBmsBatteryPackProdMonth() { + + return bmsBatteryPackProdMonth; + } + + public void setBmsBatteryPackProdMonth(String bmsBatteryPackProdMonth) { + + this.bmsBatteryPackProdMonth = bmsBatteryPackProdMonth; + } + + public String getBmsBatteryPackProdDate() { + + return bmsBatteryPackProdDate; + } + + public void setBmsBatteryPackProdDate(String bmsBatteryPackProdDate) { + + this.bmsBatteryPackProdDate = bmsBatteryPackProdDate; + } + + public String getBmsBatteryRecycleTime() { + + return bmsBatteryRecycleTime; + } + + public void setBmsBatteryRecycleTime(String bmsBatteryRecycleTime) { + + this.bmsBatteryRecycleTime = bmsBatteryRecycleTime; + } + + public String getBmsBatteryOwnership() { + + return bmsBatteryOwnership; + } + + public void setBmsBatteryOwnership(String bmsBatteryOwnership) { + + this.bmsBatteryOwnership = bmsBatteryOwnership; + } + + public String getReserved() { + + return reserved; + } + + public void setReserved(String reserved) { + + this.reserved = reserved; + } + + public String getVin() { + + return vin; + } + + public void setVin(String vin) { + + this.vin = vin; + } + + public String getBmsSoftwareVersion() { + + return bmsSoftwareVersion; + } + + public void setBmsSoftwareVersion(String bmsSoftwareVersion) { + + this.bmsSoftwareVersion = bmsSoftwareVersion; + } + +} diff --git a/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/pilemsg/RealtimeData.java b/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/pilemsg/RealtimeData.java new file mode 100644 index 00000000..d9e3aca8 --- /dev/null +++ b/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/pilemsg/RealtimeData.java @@ -0,0 +1,204 @@ +package com.xhpc.common.pilemsg; + +public class RealtimeData extends BaseData { + + private String orderNo; //交易流水号 + private String pileNo; //桩号 + private String gunId; //枪号 + private String status; //状态 + private String pileGunStatus; //枪是否归位 + private String vehicleGunStatus; //是否插枪 + private String workingVoltage; //输出电压 + private String workingCurrent; //输出电流 + private String gunLineTemperature; //枪线温度 + private String gunLineNumber; //枪线编码 + private String soc; // + private String maxTemperature; //电池组最高温度 + private String chargingTime; //累计充电时间 + private String remainingTime; //剩余时间 + private String chargingDegree; //充电度数 + private String lossChargingDegree; //记损充电度数 + private String amountCharged; //已充金额 + private String hardwareFault; //硬件故障 + + 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 getStatus() { + + return status; + } + + public void setStatus(String status) { + + this.status = status; + } + + public String getPileGunStatus() { + + return pileGunStatus; + } + + public void setPileGunStatus(String pileGunStatus) { + + this.pileGunStatus = pileGunStatus; + } + + public String getVehicleGunStatus() { + + return vehicleGunStatus; + } + + public void setVehicleGunStatus(String vehicleGunStatus) { + + this.vehicleGunStatus = vehicleGunStatus; + } + + public String getWorkingVoltage() { + + return workingVoltage; + } + + public void setWorkingVoltage(String workingVoltage) { + + this.workingVoltage = workingVoltage; + } + + public String getWorkingCurrent() { + + return workingCurrent; + } + + public void setWorkingCurrent(String workingCurrent) { + + this.workingCurrent = workingCurrent; + } + + public String getGunLineTemperature() { + + return gunLineTemperature; + } + + public void setGunLineTemperature(String gunLineTemperature) { + + this.gunLineTemperature = gunLineTemperature; + } + + public String getGunLineNumber() { + + return gunLineNumber; + } + + public void setGunLineNumber(String gunLineNumber) { + + this.gunLineNumber = gunLineNumber; + } + + public String getSoc() { + + return soc; + } + + public void setSoc(String soc) { + + this.soc = soc; + } + + public String getMaxTemperature() { + + return maxTemperature; + } + + public void setMaxTemperature(String maxTemperature) { + + this.maxTemperature = maxTemperature; + } + + public String getChargingTime() { + + return chargingTime; + } + + public void setChargingTime(String chargingTime) { + + this.chargingTime = chargingTime; + } + + public String getRemainingTime() { + + return remainingTime; + } + + public void setRemainingTime(String remainingTime) { + + this.remainingTime = remainingTime; + } + + public String getChargingDegree() { + + return chargingDegree; + } + + public void setChargingDegree(String chargingDegree) { + + this.chargingDegree = chargingDegree; + } + + public String getLossChargingDegree() { + + return lossChargingDegree; + } + + public void setLossChargingDegree(String lossChargingDegree) { + + this.lossChargingDegree = lossChargingDegree; + } + + public String getAmountCharged() { + + return amountCharged; + } + + public void setAmountCharged(String amountCharged) { + + this.amountCharged = amountCharged; + } + + public String getHardwareFault() { + + return hardwareFault; + } + + public void setHardwareFault(String hardwareFault) { + + this.hardwareFault = hardwareFault; + } + +} diff --git a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/server/ChargingPileBinaryHandler.java b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/server/ChargingPileBinaryHandler.java index 66c697de..e0d27fe7 100644 --- a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/server/ChargingPileBinaryHandler.java +++ b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/server/ChargingPileBinaryHandler.java @@ -78,6 +78,8 @@ public class ChargingPileBinaryHandler implements ClientBinaryHandler { String serviceName = HexUtils.toHex(data, 5, 6); String version = ChargingPileServer.getVersion(handler.getName()); Map req = analysis(data, serviceName, version); + int seq = HexUtils.toInteger(data, 2, 4); + req.put("seq", seq); String pileNo = (String) req.get("pileNo"); ServiceParameter sp = new ServiceParameter(serviceName, pileNo, req); ServiceResult result = servicemainLogic.process(sp); diff --git a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/service/ChargingHandshakeDataLogic.java b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/service/ChargingHandshakeDataLogic.java new file mode 100644 index 00000000..19017472 --- /dev/null +++ b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/service/ChargingHandshakeDataLogic.java @@ -0,0 +1,36 @@ +package com.xhpc.pp.service; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.xhpc.common.pilemsg.ChargingHandshakeData; +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("ChargingHandshakeDataLogic") +public class ChargingHandshakeDataLogic implements ServiceLogic { + + private static Logger log = LoggerFactory.getLogger(ChargingHandshakeDataLogic.class); + + @Override + public ServiceResult service(ServiceParameter sp) throws Exception { + + Map req = sp.getParameters(); + ObjectMapper objectMapper = new ObjectMapper(); + ChargingHandshakeData chargingHandshakeData = objectMapper.convertValue(req, ChargingHandshakeData.class); + String orderNo = chargingHandshakeData.getOrderNo(); + Map cacheOrder = REDIS.getCacheMap(orderNo); + cacheOrder.put("handshake", chargingHandshakeData); + REDIS.setCacheMap(orderNo, cacheOrder); + return new ServiceResult(false); + } + +} diff --git a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/service/RealtimeDataLogic.java b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/service/RealtimeDataLogic.java index eecdd56e..9dd89083 100644 --- a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/service/RealtimeDataLogic.java +++ b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/service/RealtimeDataLogic.java @@ -1,7 +1,7 @@ package com.xhpc.pp.service; -//import com.xhpc.common.domain.XhpcChargeOrderStatus; - +import com.fasterxml.jackson.databind.ObjectMapper; +import com.xhpc.common.pilemsg.RealtimeData; import com.xhpc.pp.tx.ServiceParameter; import com.xhpc.pp.tx.ServiceResult; import com.xhpc.pp.tx.logic.ServiceLogic; @@ -10,6 +10,9 @@ import org.slf4j.LoggerFactory; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Component; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.List; import java.util.Map; import static com.xhpc.pp.server.ChargingPileServer.REDIS; @@ -24,19 +27,27 @@ public class RealtimeDataLogic implements ServiceLogic { public ServiceResult service(ServiceParameter sp) throws Exception { Map req = sp.getParameters(); - String pileNo = (String) req.get("pileNo"); - String gunId = (String) req.get("gunId"); - String status = (String) req.get("status"); + ObjectMapper objectMapper = new ObjectMapper(); + RealtimeData realtimeData = objectMapper.convertValue(req, RealtimeData.class); + String pileNo = realtimeData.getPileNo(); + String gunId = realtimeData.getGunId(); + String status = realtimeData.getStatus(); + realtimeData.setCreateBy("SYSTEM"); + realtimeData.setCreateTime(Calendar.getInstance().getTime()); String pileGun = pileNo.concat(gunId); Map cacheGun = REDIS.getCacheMap(pileGun); cacheGun.put("status", status); -// List realTimeDataList = (List) cacheGun.get("realTimeData"); -// XhpcChargeOrderStatus newData = new XhpcChargeOrderStatus(); -// newData.setStatus(Integer.parseInt(status)); -// if(realTimeDataList==null) realTimeDataList = new ArrayList<>(); -// realTimeDataList.add(newData); -// cacheGun.put("realTimeData", realTimeDataList); REDIS.setCacheMap(pileGun, cacheGun); + String orderNo = realtimeData.getOrderNo(); + Map order = REDIS.getCacheMap(orderNo); + List realtimeDataList = (List) order.get("realtimeDataList"); + if (realtimeDataList == null) { + realtimeDataList = new ArrayList<>(); + } + realtimeDataList.add(realtimeData); + order.put("status", status); + order.put("realtimeDataList", realtimeDataList); + REDIS.setCacheMap(orderNo, order); return new ServiceResult(false); } 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 4aefe650..5912c1ce 100644 --- a/xhpc-modules/xhpc-power-pile/src/main/resources/svcmainlogic.xml +++ b/xhpc-modules/xhpc-power-pile/src/main/resources/svcmainlogic.xml @@ -13,5 +13,6 @@ +