正在充电中的桩不校验费率模型直接返回
This commit is contained in:
parent
97e4d7c506
commit
4155b52a7f
@ -13,6 +13,7 @@ import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import static cn.hutool.core.util.NumberUtil.isInteger;
|
||||
import static com.xhpc.common.data.redis.StaticBeanUtil.REDIS;
|
||||
import static com.xhpc.common.data.redis.StaticBeanUtil.seqHex;
|
||||
|
||||
@ -29,18 +30,33 @@ public class RateModelValidateLogic implements ServiceLogic {
|
||||
String pileNo = (String) req.get("pileNo");
|
||||
String rateModelIdStr = (String) req.get("rateModelId");
|
||||
Map<String, Object> cachePile = REDIS.getCacheMap("pile:".concat(pileNo));
|
||||
Integer gunNum = (Integer) cachePile.get("gunNum");
|
||||
boolean charging = false;
|
||||
for (int gunN = 1; gunN <= gunNum; gunN++) {
|
||||
String gunId = String.format("%02d", gunN);
|
||||
String gunkey = "gun:".concat(pileNo.concat(gunId));
|
||||
Map<String, Object> cacheGun = REDIS.getCacheMap(gunkey);
|
||||
Object status = cacheGun.get("status");
|
||||
if (isInteger(status.toString())) {
|
||||
charging = true;
|
||||
}
|
||||
}
|
||||
String resultCode = ServiceResult.OK;
|
||||
String hexCode = ServiceResult.HEX_00;
|
||||
ChargingStationDto cacheStation = REDIS.getCacheObject("station:".concat(cachePile.get("stationId").toString()));
|
||||
Long csRateModelId = cacheStation.getRateModelId();
|
||||
int rateModelId = Integer.parseInt(rateModelIdStr, 16);
|
||||
if (csRateModelId.intValue() != rateModelId) {
|
||||
hexCode = ServiceResult.HEX_01;
|
||||
resultCode = ServiceResult.FAIL;
|
||||
Long rateModelId = Long.valueOf(Integer.parseInt(rateModelIdStr, 16));
|
||||
Long csRateModelId = rateModelId;
|
||||
if (!charging) {
|
||||
ChargingStationDto cacheStation = REDIS.getCacheObject("station:".concat(cachePile.get("stationId").toString()));
|
||||
csRateModelId = cacheStation.getRateModelId();
|
||||
if (csRateModelId.intValue() != rateModelId) {
|
||||
hexCode = ServiceResult.HEX_01;
|
||||
resultCode = ServiceResult.FAIL;
|
||||
}
|
||||
}
|
||||
String skey = "pile:".concat(pileNo).concat(".seqhex");
|
||||
String seq = seqHex(skey);
|
||||
String resultStr = "680E".concat(seq).concat("0006").concat(pileNo).concat(String.format("%04X", csRateModelId)).concat(hexCode);
|
||||
String resultStr =
|
||||
"680E".concat(seq).concat("0006").concat(pileNo).concat(String.format("%04X", csRateModelId)).concat(hexCode);
|
||||
resultStr = resultStr.concat(CRCCalculator.calcCrc(resultStr));
|
||||
return new ServiceResult(HexUtils.toBytes(resultStr), resultCode);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user