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); }