只能对充电中的端口停止充电

This commit is contained in:
ZZ 2021-09-14 14:26:24 +08:00
parent ac5d959214
commit 38b04df6a5
2 changed files with 26 additions and 19 deletions

View File

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

View File

@ -36,15 +36,17 @@ public class RemoteStopReplyDataLogic implements ServiceLogic {
String gunkey = "gun:".concat(remoteStopReplyData.getPileNo()).concat(remoteStopReplyData.getGunId());
Map<String, Object> cacheGun = REDIS.getCacheMap(gunkey);
String orderkey = (String) cacheGun.get("orderkey");
Map<String, Object> 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<String, Object> 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);
}