请求费率模型响应END.
This commit is contained in:
parent
b0ef15d6a8
commit
0bff19684a
26
pom.xml
26
pom.xml
@ -264,18 +264,18 @@
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<!-- <build>-->
|
||||
<!-- <plugins>-->
|
||||
<!-- <plugin>-->
|
||||
<!-- <groupId>org.apache.maven.plugins</groupId>-->
|
||||
<!-- <artifactId>maven-compiler-plugin</artifactId>-->
|
||||
<!-- <configuration>-->
|
||||
<!-- <source>${java.version}</source>-->
|
||||
<!-- <target>${java.version}</target>-->
|
||||
<!-- <encoding>${project.build.sourceEncoding}</encoding>-->
|
||||
<!-- </configuration>-->
|
||||
<!-- </plugin>-->
|
||||
<!-- </plugins>-->
|
||||
<!-- </build>-->
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>${java.version}</source>
|
||||
<target>${java.version}</target>
|
||||
<encoding>${project.build.sourceEncoding}</encoding>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
@ -105,6 +105,14 @@
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>8</source>
|
||||
<target>8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
<resources>
|
||||
<resource>
|
||||
|
||||
@ -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<String> piles = cacheStation.getPiles();
|
||||
if (piles!=null) {
|
||||
String rmskey = "rateModelStation:".concat(stationId.toString());
|
||||
REDIS.setCacheSet(rmskey, piles);
|
||||
}
|
||||
return R.ok();
|
||||
|
||||
@ -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<String, Object> req = sp.getParameters();
|
||||
String pileNo = (String) req.get("pileNo");
|
||||
Map<String, Object> cachePile = REDIS.getCacheMap(pileNo);
|
||||
String stationId = (String) cachePile.get("stationId");
|
||||
CacheStation cacheStation = REDIS.getCacheObject("station:".concat(stationId));
|
||||
Map<String, Object> 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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user