manual config time n rate model altered

This commit is contained in:
ZZ 2022-05-07 16:12:09 +08:00
parent a6a7d92277
commit ff1e8baad5

View File

@ -91,7 +91,7 @@ public class PileController {
public R nativeConfigTimeNRateModel(@PathVariable("pileNo") String pileNo) {
ClientHandler handler = getHandler(pileNo);
R r = R.fail("校时校费下发失败,充电桩未注册.");
R r = R.fail("校时校费下发失败,充电桩未注册,或场站费率未设置.");
if (handler != null && handler.isOpen()) {
if (!handler.isOpen()) {
log.error("send message failed. [{}]({}) connection lost", handler.getName(), pileNo);
@ -107,43 +107,40 @@ public class PileController {
if (pns != null) for (String pn : pns) {
if (pn.equals(pileNo)) {
String pk = "pile:".concat(pileNo);
Long rateModelIdPile = REDIS.getCacheMapValue(pk, "rateModelId");
if (!rateModelIdStation.equals(rateModelIdPile)) {
String gkPattern = ("gun:").concat(pileNo).concat("*");
Collection<String> gks = REDIS.keys(gkPattern);
boolean charging = false;
for (String gk : gks) {
if (gk.length() == 20 && isInteger(REDIS.getCacheMapValue(gk, "status"))) {
charging = true;
break;
}
}
if (!charging) {
String rsmsg = RateModelRequestLogic.translate(pileNo, rateModelIdStation, "0058",
REDIS.getCacheMapValue(pk, "version"));
try {
handler.sendClientBinary(HexUtils.toBytes(rsmsg));
log.info("pile[{}] rate model[{}] sent ⚪ {}", pileNo, rateModelIdStation, rsmsg);
String configRmReply = pk.concat(".configRateReply");
REDIS.setCacheObject(configRmReply, "已下发", 30L, TimeUnit.MINUTES);
String skey = pk.concat(".seqhex");
Thread.sleep(500);
Date date = Calendar.getInstance().getTime();
String timebin = getTimeBin(seqHex(skey), pileNo, date);
handler.sendClientBinary(HexUtils.toBytes(timebin));
REDIS.setCacheMapValue(pk, "manConfTime", DateUtil.format(date, NORM_DATETIME_FORMAT));
String configTimeReply = pk.concat(".configTimeReply");
REDIS.setCacheObject(configTimeReply, "已下发", 30L, TimeUnit.MINUTES);
r = R.fail("校时校费下发成功.");
} catch (IOException | InterruptedException e) {
r = R.fail("校时|校费下发失败,请重试.");
}
} else {
r = R.fail("校时校费下发失败,充电桩在充电中.");
String gkPattern = ("gun:").concat(pileNo).concat("*");
Collection<String> gks = REDIS.keys(gkPattern);
boolean charging = false;
for (String gk : gks) {
if (gk.length() == 20 && isInteger(REDIS.getCacheMapValue(gk, "status"))) {
charging = true;
break;
}
}
break;
if (!charging) {
String rsmsg = RateModelRequestLogic.translate(pileNo, rateModelIdStation, "0058",
REDIS.getCacheMapValue(pk, "version"));
try {
handler.sendClientBinary(HexUtils.toBytes(rsmsg));
log.info("pile[{}] rate model[{}] sent ⚪ {}", pileNo, rateModelIdStation, rsmsg);
String configRmReply = pk.concat(".configRateReply");
REDIS.setCacheObject(configRmReply, "已下发", 30L, TimeUnit.MINUTES);
String skey = pk.concat(".seqhex");
Thread.sleep(500);
Date date = Calendar.getInstance().getTime();
String timebin = getTimeBin(seqHex(skey), pileNo, date);
handler.sendClientBinary(HexUtils.toBytes(timebin));
REDIS.setCacheMapValue(pk, "manConfTime", DateUtil.format(date, NORM_DATETIME_FORMAT));
String configTimeReply = pk.concat(".configTimeReply");
REDIS.setCacheObject(configTimeReply, "已下发", 30L, TimeUnit.MINUTES);
r = R.fail("校时校费下发成功.");
} catch (IOException | InterruptedException e) {
r = R.fail("校时|校费下发失败,请重试.");
}
} else {
r = R.fail("校时校费下发失败,充电桩在充电中.");
}
}
break;
}
}
}