From ff1e8baad52212b1073c9b1e4a77102853bd3ff2 Mon Sep 17 00:00:00 2001 From: ZZ Date: Sat, 7 May 2022 16:12:09 +0800 Subject: [PATCH] manual config time n rate model altered --- .../xhpc/pp/controller/PileController.java | 67 +++++++++---------- 1 file changed, 32 insertions(+), 35 deletions(-) diff --git a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/controller/PileController.java b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/controller/PileController.java index 554a1a15..3baee5ec 100644 --- a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/controller/PileController.java +++ b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/controller/PileController.java @@ -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 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 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; } } }