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) { public R nativeConfigTimeNRateModel(@PathVariable("pileNo") String pileNo) {
ClientHandler handler = getHandler(pileNo); ClientHandler handler = getHandler(pileNo);
R r = R.fail("校时校费下发失败,充电桩未注册."); R r = R.fail("校时校费下发失败,充电桩未注册,或场站费率未设置.");
if (handler != null && handler.isOpen()) { if (handler != null && handler.isOpen()) {
if (!handler.isOpen()) { if (!handler.isOpen()) {
log.error("send message failed. [{}]({}) connection lost", handler.getName(), pileNo); 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 (pns != null) for (String pn : pns) {
if (pn.equals(pileNo)) { if (pn.equals(pileNo)) {
String pk = "pile:".concat(pileNo); String pk = "pile:".concat(pileNo);
Long rateModelIdPile = REDIS.getCacheMapValue(pk, "rateModelId"); String gkPattern = ("gun:").concat(pileNo).concat("*");
if (!rateModelIdStation.equals(rateModelIdPile)) { Collection<String> gks = REDIS.keys(gkPattern);
String gkPattern = ("gun:").concat(pileNo).concat("*"); boolean charging = false;
Collection<String> gks = REDIS.keys(gkPattern); for (String gk : gks) {
boolean charging = false; if (gk.length() == 20 && isInteger(REDIS.getCacheMapValue(gk, "status"))) {
for (String gk : gks) { charging = true;
if (gk.length() == 20 && isInteger(REDIS.getCacheMapValue(gk, "status"))) { break;
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("校时校费下发失败,充电桩在充电中.");
} }
} }
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;
} }
} }
} }