充电桩费率模型请求逻辑

This commit is contained in:
ZZ 2021-07-19 14:30:58 +08:00
parent c4ff945d21
commit ce881f81eb
2 changed files with 58 additions and 1 deletions

View File

@ -89,7 +89,6 @@
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.4.0</version>
<executions>
<execution>
<goals>
@ -99,6 +98,16 @@
</executions>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*.xml</include>
<include>**/*.properties</include>
</includes>
<filtering>true</filtering>
</resource>
</resources>
</build>
</project>

View File

@ -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<String, Object> req = sp.getParameters();
String pileNo = (String) req.get("pileNo");
Map<String, Integer> cachePile = REDIS.getCacheMap(pileNo);
Integer stationId = cachePile.get("stationId");
Map<String, Object> 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);
}
}