From 38b04df6a5b10757df70059fcbd304d7f324d4f5 Mon Sep 17 00:00:00 2001 From: ZZ Date: Tue, 14 Sep 2021 14:26:24 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=AA=E8=83=BD=E5=AF=B9=E5=85=85=E7=94=B5?= =?UTF-8?q?=E4=B8=AD=E7=9A=84=E7=AB=AF=E5=8F=A3=E5=81=9C=E6=AD=A2=E5=85=85?= =?UTF-8?q?=E7=94=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pp/controller/ChargingController.java | 25 +++++++++++-------- .../pp/logic/RemoteStopReplyDataLogic.java | 20 ++++++++------- 2 files changed, 26 insertions(+), 19 deletions(-) diff --git a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/controller/ChargingController.java b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/controller/ChargingController.java index aac1e2c8..d375330c 100644 --- a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/controller/ChargingController.java +++ b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/controller/ChargingController.java @@ -74,11 +74,10 @@ public class ChargingController { r = R.fail("Native服务调用失败"); } else { int code = responseJson.getInteger("code"); + log.info(response); if (code != 200) {//todo rat - log.error("!200:" + response); r = R.fail(code, responseJson.getString("msg")); } else { - log.error("200:" + response); r = R.ok(responseJson.get("data"), responseJson.getString("msg")); } } @@ -146,14 +145,20 @@ public class ChargingController { if (!REGISTERED.equals(status)) { r = R.fail("充电桩离线"); } - if (r.getCode() == 200) { - String svcSrv = cachePile.get("svcSrv"); - String response = HttpUtils.get(fmt(svcSrv) - .concat("/native/charging/stop/") - .concat(pileNo).concat("/") - .concat(gunId).concat("/") - .concat(version)); - r = getRR(response); + String gunkey = pkey.concat(gunId); + String gunStatus = REDIS.getCacheMapValue(gunkey, "status"); + if (!("空闲".equals(gunStatus) || "离线".equals(gunStatus) || "故障".equals(gunStatus))) { + if (r.getCode() == 200) { + String svcSrv = cachePile.get("svcSrv"); + String response = HttpUtils.get(fmt(svcSrv) + .concat("/native/charging/stop/") + .concat(pileNo).concat("/") + .concat(gunId).concat("/") + .concat(version)); + r = getRR(response); + } + } else { + r = R.fail("端口不在充电中"); } return r; } diff --git a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/RemoteStopReplyDataLogic.java b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/RemoteStopReplyDataLogic.java index fd61eb3d..d928fa5a 100644 --- a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/RemoteStopReplyDataLogic.java +++ b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/RemoteStopReplyDataLogic.java @@ -36,15 +36,17 @@ public class RemoteStopReplyDataLogic implements ServiceLogic { String gunkey = "gun:".concat(remoteStopReplyData.getPileNo()).concat(remoteStopReplyData.getGunId()); Map cacheGun = REDIS.getCacheMap(gunkey); String orderkey = (String) cacheGun.get("orderkey"); - Map cacheOrder = REDIS.getCacheMap(orderkey); - String stopResult = remoteStopReplyData.getStopResult(); - cacheOrder.put("stopResult", stopResult); - REDIS.setCacheMap(orderkey, cacheOrder); - String orderNo = orderkey.replace("order:", ""); - if (HEX_01.equals(remoteStopReplyData.getStopResult())) { - pileOrderService.pileStop(orderNo, 1, "停止充电成功"); - } else { - pileOrderService.pileStop(orderNo, 2, frs[Integer.parseInt(remoteStopReplyData.getFailReason())]); + if (orderkey != null) { + Map cacheOrder = REDIS.getCacheMap(orderkey); + String stopResult = remoteStopReplyData.getStopResult(); + cacheOrder.put("stopResult", stopResult); + REDIS.setCacheMap(orderkey, cacheOrder); + String orderNo = orderkey.replace("order:", ""); + if (HEX_01.equals(remoteStopReplyData.getStopResult())) { + pileOrderService.pileStop(orderNo, 1, "停止充电成功"); + } else { + pileOrderService.pileStop(orderNo, 2, frs[Integer.parseInt(remoteStopReplyData.getFailReason())]); + } } return new ServiceResult(false); }