记损比率

This commit is contained in:
ZZ 2021-09-09 13:11:43 +08:00
parent fbfbad7708
commit d00966b1fc
5 changed files with 10 additions and 25 deletions

View File

@ -107,14 +107,13 @@ public class ChargingController {
if (!stationRateModelId.equals(pileRateModelId)) {
CacheRateModel cacheRateModel = REDIS.getCacheObject("rateModel:".concat(stationRateModelId.toString()));
String rateModel = RateModelRequestLogic.translate(cacheRateModel);
String gunkey = "gun:".concat(pileNo).concat(startChargingData.getGunId());
String skey = gunkey.concat(".seqhex");
String seq = seqHex(skey);
String rateModelMsg = "685E".concat(seq).concat("0058").concat(pileNo)
String skey = pkey.concat(".seqhex");
String rateModelMsg = "68C2".concat(seqHex(skey)).concat("0058").concat(pileNo)
.concat(String.format("%04X", stationRateModelId))
.concat(rateModel);
rateModelMsg = rateModelMsg.concat(CRCCalculator.calcCrc(rateModel));
String response = HttpUtils.post(fmt(svcSrv).concat("/native/pile/".concat(pileNo).concat("/rateModel")), rateModelMsg);
rateModelMsg = rateModelMsg.concat(CRCCalculator.calcCrc(rateModelMsg.substring(4)));
String response = HttpUtils.post(fmt(svcSrv).concat("/native/pile/".concat(pileNo).concat("/rateModel")),
rateModelMsg);
JSONObject responseJson = (JSONObject) JSON.parse(response);
assert responseJson != null;
int code = responseJson.getInteger("code");

View File

@ -67,7 +67,7 @@ public class PileController {
R r;
if (handler != null) {
try {
log.info("server send msg >>>> ({}) |{}|", pileNo, msg);
log.info("[{}] - server send msg >>>> ({}) |{}|", handler.getName(), pileNo, msg);
handler.sendClientBinary(HexUtils.toBytes(msg));
r = R.ok(null, "费率模型已下发,请再次启动充电");
} catch (IOException e) {

View File

@ -35,7 +35,7 @@ public class PileTimeConfigReplyDataLogic implements ServiceLogic {
Map<String, Object> cachePile = REDIS.getCacheMap(pk);
cachePile.put("configTime", configTime);
REDIS.setCacheMap(pk, cachePile);
log.info("({}) set time success: [{}]", pileNo, configTime);
log.info("({}) set time success: [{}]", pileNo, configTime);
return new ServiceResult(false);
}

View File

@ -63,7 +63,7 @@ public class RateModelRequestLogic implements ServiceLogic {
.concat(toHexInt(cacheRateModel.getT3SvcPrice()))
.concat(toHexInt(cacheRateModel.getT4Price()))
.concat(toHexInt(cacheRateModel.getT4SvcPrice()))
.concat(toHexInt(cacheRateModel.getLossRate()))
.concat(String.format("%02X", cacheRateModel.getLossRate()))
.concat(String.join("", cacheRateModel.getTfPricesSeq()));
return rateModel;
}

View File

@ -3,10 +3,8 @@ package com.xhpc.pp.server;
import cn.hutool.core.date.DateUtil;
import com.alibaba.nacos.api.exception.NacosException;
import com.xhpc.common.api.dto.ChargingStationDto;
import com.xhpc.common.data.redis.CacheRateModel;
import com.xhpc.pp.domain.ServiceField;
import com.xhpc.pp.logic.FieldLogic;
import com.xhpc.pp.logic.RateModelRequestLogic;
import com.xhpc.pp.logic.ServiceMainLogic;
import com.xhpc.pp.tx.ServiceParameter;
import com.xhpc.pp.tx.ServiceResult;
@ -103,7 +101,7 @@ public class ChargingPileBinaryHandler implements ClientBinaryHandler {
REDIS.setCacheMap(pilekey, cachePile);
regHandler(handler, pileNo, req);
}
if (SERVICE_RMCR.equals(serviceName) && OK.equals(resultCode)) {
if (SERVICE_RMR.equals(serviceName) && OK.equals(resultCode)) {
setCachePileRM(pilekey);
}
if (result.getBinary() != null) {
@ -129,18 +127,6 @@ public class ChargingPileBinaryHandler implements ClientBinaryHandler {
}
cachePile.put("tcfg", true);
REDIS.setCacheMap(pilekey, cachePile);
Thread.sleep(500);
Long stationId = (Long) cachePile.get("stationId");
ChargingStationDto cacheStation = REDIS.getCacheObject("station:".concat(stationId.toString()));
Long stationRateModelId = cacheStation.getRateModelId();
CacheRateModel cacheRateModel = REDIS.getCacheObject("rateModel:".concat(stationRateModelId.toString()));
String rateModel = RateModelRequestLogic.translate(cacheRateModel);
String rateModelMsg = "685E".concat(seqHex(skey)).concat("0058").concat(pileNo)
.concat(String.format("%04X", stationRateModelId))
.concat(rateModel);
rateModelMsg = rateModelMsg.concat(CRCCalculator.calcCrc(rateModel));
log.info("server send msg >>>> ({}) |{}|", pileNo, rateModelMsg);
handler.sendClientBinary(HexUtils.toBytes(rateModelMsg));
}
}
}
@ -165,7 +151,7 @@ public class ChargingPileBinaryHandler implements ClientBinaryHandler {
ChargingStationDto cacheStation = REDIS.getCacheObject("station:".concat(cachePile.get("stationId").toString()));
cachePile.put("rateModelId", cacheStation.getRateModelId());
REDIS.setCacheMap(pilekey, cachePile);
log.info("rate model responds success ");
log.info("rate model responds success");
}
private List<byte[]> parseDataList(byte[] data) {