请求费率模型响应END.
This commit is contained in:
parent
b0ef15d6a8
commit
0bff19684a
26
pom.xml
26
pom.xml
@ -264,18 +264,18 @@
|
|||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<!-- <build>-->
|
<build>
|
||||||
<!-- <plugins>-->
|
<plugins>
|
||||||
<!-- <plugin>-->
|
<plugin>
|
||||||
<!-- <groupId>org.apache.maven.plugins</groupId>-->
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<!-- <artifactId>maven-compiler-plugin</artifactId>-->
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<!-- <configuration>-->
|
<configuration>
|
||||||
<!-- <source>${java.version}</source>-->
|
<source>${java.version}</source>
|
||||||
<!-- <target>${java.version}</target>-->
|
<target>${java.version}</target>
|
||||||
<!-- <encoding>${project.build.sourceEncoding}</encoding>-->
|
<encoding>${project.build.sourceEncoding}</encoding>
|
||||||
<!-- </configuration>-->
|
</configuration>
|
||||||
<!-- </plugin>-->
|
</plugin>
|
||||||
<!-- </plugins>-->
|
</plugins>
|
||||||
<!-- </build>-->
|
</build>
|
||||||
|
|
||||||
</project>
|
</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>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<source>8</source>
|
||||||
|
<target>8</target>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
<resources>
|
<resources>
|
||||||
<resource>
|
<resource>
|
||||||
|
|||||||
@ -25,9 +25,9 @@ public class StationController {
|
|||||||
REDIS.setCacheObject(skey, cacheStation);
|
REDIS.setCacheObject(skey, cacheStation);
|
||||||
String rkey = "rateModel:".concat(rateModelId.toString());
|
String rkey = "rateModel:".concat(rateModelId.toString());
|
||||||
REDIS.setCacheObject(rkey, rateModel);
|
REDIS.setCacheObject(rkey, rateModel);
|
||||||
String rmskey = "rateModelStation:".concat(stationId.toString());
|
|
||||||
Set<String> piles = cacheStation.getPiles();
|
Set<String> piles = cacheStation.getPiles();
|
||||||
if (piles!=null) {
|
if (piles!=null) {
|
||||||
|
String rmskey = "rateModelStation:".concat(stationId.toString());
|
||||||
REDIS.setCacheSet(rmskey, piles);
|
REDIS.setCacheSet(rmskey, piles);
|
||||||
}
|
}
|
||||||
return R.ok();
|
return R.ok();
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
package com.xhpc.pp.logic;
|
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.ServiceParameter;
|
||||||
import com.xhpc.pp.tx.ServiceResult;
|
import com.xhpc.pp.tx.ServiceResult;
|
||||||
import com.xhpc.pp.tx.logic.ServiceLogic;
|
import com.xhpc.pp.tx.logic.ServiceLogic;
|
||||||
@ -14,6 +15,7 @@ import org.springframework.stereotype.Component;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import static com.xhpc.pp.server.ChargingPileServer.REDIS;
|
import static com.xhpc.pp.server.ChargingPileServer.REDIS;
|
||||||
|
import static com.xhpc.pp.utils.security.HexUtils.toHexInt;
|
||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
@Component("RateModelRequestLogic")
|
@Component("RateModelRequestLogic")
|
||||||
@ -26,18 +28,37 @@ public class RateModelRequestLogic implements ServiceLogic {
|
|||||||
|
|
||||||
Map<String, Object> req = sp.getParameters();
|
Map<String, Object> req = sp.getParameters();
|
||||||
String pileNo = (String) req.get("pileNo");
|
String pileNo = (String) req.get("pileNo");
|
||||||
Map<String, Object> cachePile = REDIS.getCacheMap(pileNo);
|
Map<String, Object> cachePile = REDIS.getCacheMap("pile:".concat(pileNo));
|
||||||
String stationId = (String) cachePile.get("stationId");
|
Integer stationId = (Integer) cachePile.get("stationId");
|
||||||
CacheStation cacheStation = REDIS.getCacheObject("station:".concat(stationId));
|
ChargingStationDto cacheStation = REDIS.getCacheObject("station:".concat(stationId.toString()));
|
||||||
Long rateModelId = cacheStation.getRateModelId();
|
Long rateModelId = cacheStation.getRateModelId();
|
||||||
if (rateModelId == null) {
|
if (rateModelId == null) {
|
||||||
return new ServiceResult((byte[]) null, ServiceResult.FAIL);
|
return new ServiceResult((byte[]) null, ServiceResult.FAIL);
|
||||||
}
|
}
|
||||||
|
CacheRateModel cacheRateModel = REDIS.getCacheObject("rateModel:".concat(rateModelId.toString()));
|
||||||
|
String rateModel = translate(cacheRateModel);
|
||||||
String resultStr = "680E00000006".concat(pileNo)
|
String resultStr = "680E00000006".concat(pileNo)
|
||||||
.concat(String.format("%04d", rateModelId))
|
.concat(String.format("%04d", rateModelId))
|
||||||
// .concat(rateModel) // todo
|
.concat(rateModel)
|
||||||
.concat(ServiceResult.HEX_OK);
|
.concat(ServiceResult.HEX_OK);
|
||||||
resultStr = resultStr.concat(CRCCalculator.calcCrc(resultStr));
|
resultStr = resultStr.concat(CRCCalculator.calcCrc(resultStr));
|
||||||
return new ServiceResult(HexUtils.toBytes(resultStr), ServiceResult.OK);
|
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