diff --git a/pom.xml b/pom.xml index ca3a6444..48c12193 100644 --- a/pom.xml +++ b/pom.xml @@ -264,18 +264,18 @@ - - - - - - - - - - - - - + + + + org.apache.maven.plugins + maven-compiler-plugin + + ${java.version} + ${java.version} + ${project.build.sourceEncoding} + + + + diff --git a/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/data/redis/CacheStation.java b/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/data/redis/CacheStation.java deleted file mode 100644 index d51807c0..00000000 --- a/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/data/redis/CacheStation.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.xhpc.common.data.redis; - -public class CacheStation { - - private Long chargingPileId; - private Long chargingStationId; - private Long rateModelId; - - public Long getChargingPileId() { - - return chargingPileId; - } - - public void setChargingPileId(Long chargingPileId) { - - this.chargingPileId = chargingPileId; - } - - public Long getChargingStationId() { - - return chargingStationId; - } - - public void setChargingStationId(Long chargingStationId) { - - this.chargingStationId = chargingStationId; - } - - public Long getRateModelId() { - - return rateModelId; - } - - public void setRateModelId(Long rateModelId) { - - this.rateModelId = rateModelId; - } - -} diff --git a/xhpc-modules/xhpc-power-pile/pom.xml b/xhpc-modules/xhpc-power-pile/pom.xml index cb5c27ec..e14767a0 100644 --- a/xhpc-modules/xhpc-power-pile/pom.xml +++ b/xhpc-modules/xhpc-power-pile/pom.xml @@ -105,6 +105,14 @@ + + org.apache.maven.plugins + maven-compiler-plugin + + 8 + 8 + + diff --git a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/controller/StationController.java b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/controller/StationController.java index e80b096f..9311d177 100644 --- a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/controller/StationController.java +++ b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/controller/StationController.java @@ -25,9 +25,9 @@ public class StationController { REDIS.setCacheObject(skey, cacheStation); String rkey = "rateModel:".concat(rateModelId.toString()); REDIS.setCacheObject(rkey, rateModel); - String rmskey = "rateModelStation:".concat(stationId.toString()); Set piles = cacheStation.getPiles(); if (piles!=null) { + String rmskey = "rateModelStation:".concat(stationId.toString()); REDIS.setCacheSet(rmskey, piles); } return R.ok(); diff --git a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/RateModelRequestLogic.java b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/RateModelRequestLogic.java index f70a73dd..bd31a58f 100644 --- a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/RateModelRequestLogic.java +++ b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/RateModelRequestLogic.java @@ -1,6 +1,7 @@ package com.xhpc.pp.logic; -import com.xhpc.common.data.redis.CacheStation; +import com.xhpc.common.api.dto.ChargingStationDto; +import com.xhpc.common.data.redis.CacheRateModel; import com.xhpc.pp.tx.ServiceParameter; import com.xhpc.pp.tx.ServiceResult; import com.xhpc.pp.tx.logic.ServiceLogic; @@ -14,6 +15,7 @@ import org.springframework.stereotype.Component; import java.util.Map; import static com.xhpc.pp.server.ChargingPileServer.REDIS; +import static com.xhpc.pp.utils.security.HexUtils.toHexInt; @Lazy @Component("RateModelRequestLogic") @@ -26,18 +28,37 @@ public class RateModelRequestLogic implements ServiceLogic { Map req = sp.getParameters(); String pileNo = (String) req.get("pileNo"); - Map cachePile = REDIS.getCacheMap(pileNo); - String stationId = (String) cachePile.get("stationId"); - CacheStation cacheStation = REDIS.getCacheObject("station:".concat(stationId)); + Map cachePile = REDIS.getCacheMap("pile:".concat(pileNo)); + Integer stationId = (Integer) cachePile.get("stationId"); + ChargingStationDto cacheStation = REDIS.getCacheObject("station:".concat(stationId.toString())); Long rateModelId = cacheStation.getRateModelId(); if (rateModelId == null) { return new ServiceResult((byte[]) null, ServiceResult.FAIL); } + CacheRateModel cacheRateModel = REDIS.getCacheObject("rateModel:".concat(rateModelId.toString())); + String rateModel = translate(cacheRateModel); String resultStr = "680E00000006".concat(pileNo) .concat(String.format("%04d", rateModelId)) -// .concat(rateModel) // todo + .concat(rateModel) .concat(ServiceResult.HEX_OK); resultStr = resultStr.concat(CRCCalculator.calcCrc(resultStr)); return new ServiceResult(HexUtils.toBytes(resultStr), ServiceResult.OK); } + + private String translate(CacheRateModel cacheRateModel) { + + String rateModel = ""; + rateModel = rateModel.concat(toHexInt(cacheRateModel.getT1Price())) + .concat(toHexInt(cacheRateModel.getT1SvcPrice())) + .concat(toHexInt(cacheRateModel.getT2Price())) + .concat(toHexInt(cacheRateModel.getT2SvcPrice())) + .concat(toHexInt(cacheRateModel.getT3Price())) + .concat(toHexInt(cacheRateModel.getT3SvcPrice())) + .concat(toHexInt(cacheRateModel.getT4Price())) + .concat(toHexInt(cacheRateModel.getT4SvcPrice())) + .concat(toHexInt(cacheRateModel.getLossRate())) + .concat(String.join("", cacheRateModel.getTfPricesSeq())); + return rateModel; + } + }