diff --git a/xhpc-modules/xhpc-power-pile/pom.xml b/xhpc-modules/xhpc-power-pile/pom.xml index 2c6fb0b5..994b70cb 100644 --- a/xhpc-modules/xhpc-power-pile/pom.xml +++ b/xhpc-modules/xhpc-power-pile/pom.xml @@ -89,7 +89,6 @@ org.springframework.boot spring-boot-maven-plugin - 2.4.0 @@ -99,6 +98,16 @@ + + + src/main/resources + + **/*.xml + **/*.properties + + true + + diff --git a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/service/RateModelRequestLogic.java b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/service/RateModelRequestLogic.java new file mode 100644 index 00000000..ac79d61b --- /dev/null +++ b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/service/RateModelRequestLogic.java @@ -0,0 +1,48 @@ +package com.xhpc.pp.service; + +import com.xhpc.pp.tx.ServiceParameter; +import com.xhpc.pp.tx.ServiceResult; +import com.xhpc.pp.tx.logic.ServiceLogic; +import com.xhpc.pp.utils.security.CRCCalculator; +import com.xhpc.pp.utils.security.HexUtils; +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("RateModelRequestLogic") +public class RateModelRequestLogic implements ServiceLogic { + + private static Logger log = LoggerFactory.getLogger(RateModelRequestLogic.class); + + @Override + public ServiceResult service(ServiceParameter sp) throws Exception { + + Map req = sp.getParameters(); + String pileNo = (String) req.get("pileNo"); + Map cachePile = REDIS.getCacheMap(pileNo); + Integer stationId = cachePile.get("stationId"); + Map stations = REDIS.getCacheMap("stations"); + Object cacheStation = stations.get(stationId); //todo + String resultCode = ServiceResult.OK; + String hexCode = ServiceResult.HEX_OK; +// Integer rateModelIdCache = cacheStation.get("rateModelId"); +// Object rateModelId = station.getRateModelId() ; +// if (rateModelId==null) { +// hexCode = ServiceResult.HEX_FAIL; +// resultCode = ServiceResult.FAIL; +// } + String resultStr = "680E00000006".concat(pileNo) + .concat(String.format("%04d", "rateModelIdCache")) +// .concat(rateModel) + .concat(hexCode); + resultStr = resultStr.concat(CRCCalculator.calcCrc(resultStr)); + return new ServiceResult(HexUtils.toBytes(resultStr), resultCode); + } + +}