From 7ed701baea2e88892f096d2fd3d36709034b4a58 Mon Sep 17 00:00:00 2001 From: ZZ Date: Fri, 12 Nov 2021 11:59:26 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8D=8F=E8=AE=AE=E4=BE=8B=E5=A4=96:=E8=8B=A5?= =?UTF-8?q?=E5=81=9C=E6=AD=A2=E5=9B=9E=E5=A4=8D=E6=88=90=E5=8A=9F=E5=90=8E?= =?UTF-8?q?=E5=AE=9E=E6=97=B6=E6=95=B0=E6=8D=AE=E4=B8=AD=E6=9C=89=E4=B8=A4?= =?UTF-8?q?=E5=B8=A7=E4=B8=BA=E7=A9=BA=E9=97=B2=EF=BC=8C=E6=8C=89=E7=85=A7?= =?UTF-8?q?=E6=9C=80=E5=90=8E=E4=B8=80=E5=B8=A7=E8=BF=9B=E8=A1=8C=E7=BB=93?= =?UTF-8?q?=E7=AE=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/data/redis/CacheOrderData.java | 42 +++++++++++++++++++ .../com/xhpc/pp/logic/RealtimeDataLogic.java | 18 +++++++- .../pp/logic/RemoteStartReplyDataLogic.java | 6 ++- 3 files changed, 62 insertions(+), 4 deletions(-) diff --git a/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/data/redis/CacheOrderData.java b/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/data/redis/CacheOrderData.java index c24e61e2..cd189b37 100644 --- a/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/data/redis/CacheOrderData.java +++ b/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/data/redis/CacheOrderData.java @@ -40,6 +40,48 @@ public class CacheOrderData extends BaseData { private Integer endSoc; private Integer status;//1自动结算,2异常 + public CacheOrderData() { + + } + + public CacheOrderData(CacheRealtimeData cacheRData, String startTime, Integer startSoc, Integer endSoc) { + + this.orderNo = cacheRData.getOrderNo(); + this.pileNo = cacheRData.getPileNo(); + this.gunId = cacheRData.getGunId(); + this.startTime = startTime; + this.endTime = cacheRData.getCreateTime(); +// this.t1Price = cacheRData.gett1Price; //todo: after v1.1 realtime data from pile +// this.t1PowerQuantity = t1PowerQuantity; +// this.t1LossQuantity = t1LossQuantity; +// this.t1Cost = t1Cost; +// this.t2Price = t2Price; +// this.t2PowerQuantity = t2PowerQuantity; +// this.t2LossQuantity = t2LossQuantity; +// this.t2Cost = t2Cost; +// this.t3Price = t3Price; +// this.t3PowerQuantity = t3PowerQuantity; +// this.t3LossQuantity = t3LossQuantity; +// this.t3Cost = t3Cost; +// this.t4Price = t4Price; +// this.t4PowerQuantity = t4PowerQuantity; +// this.t4LossQuantity = t4LossQuantity; +// this.t4Cost = t4Cost; +// this.electricMeterStart = electricMeterStart; //不会有 +// this.electricMeterEnd = electricMeterEnd; //不会有 + this.totalPowerQuantity = cacheRData.getChargingDegree(); + this.totalLossPowerQuantity = cacheRData.getLossChargingDegree(); + this.cost = cacheRData.getAmountCharged(); +// this.vinNormal = vinNormal; //不会有 +// this.transactionFlag = transactionFlag; +// this.transactionDatetime = transactionDatetime; +// this.stopReason = stopReason; +// this.cardNo = cardNo; + this.startSoc = startSoc; + this.endSoc = endSoc; +// this.status = status; //todo 字段成谜 + } + public String getOrderNo() { return orderNo; diff --git a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/RealtimeDataLogic.java b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/RealtimeDataLogic.java index ebdcc386..e4babcd5 100644 --- a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/RealtimeDataLogic.java +++ b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/RealtimeDataLogic.java @@ -6,6 +6,7 @@ import com.xhpc.common.api.PileOrderService; import com.xhpc.common.api.SmsService; import com.xhpc.common.core.domain.R; import com.xhpc.common.data.down.StartChargingData; +import com.xhpc.common.data.redis.CacheOrderData; import com.xhpc.common.data.redis.CacheRealtimeData; import com.xhpc.common.data.up.RealtimeData; import com.xhpc.pp.controller.ChargingController; @@ -174,10 +175,23 @@ public class RealtimeDataLogic implements ServiceLogic { Integer errorfreecnt = (Integer) cacheOrder.get("errorfreecnt"); errorfreecnt = errorfreecnt == null ? 1 : ++errorfreecnt; if (errorfreecnt == 2) { - final R r = pileOrderService.abnormalOrder(orderNo); - if (r.getCode() != 200) { + CacheRealtimeData cacheRData = REDIS.getCacheObject(orderkey.concat(".lord")); + R r = null; + final String stopResult = (String) cacheOrder.get("stopResult"); + if (cacheRData == null) { + r = pileOrderService.abnormalOrder(orderNo); + } else if ("01".equals(stopResult)) { + CacheOrderData lordAsOd = new CacheOrderData(cacheRData, (String) cacheOrder.get("orderstarttime"), + (Integer) cacheOrder.get("startSoc"), (Integer) cacheOrder.get("stopSoc")); + cacheOrder.put("orderData", lordAsOd); + r = pileOrderService.pileEndOrder(orderNo); + REDIS.setCacheMap(orderkey, cacheOrder); + } + if (r == null || r.getCode() != 200) { + log.error("errorfreecnt r{}", r); errorfreecnt = 1; } + cacheOrder.put("abnormal.1", "lord as order data"); log.error("abnormal.1 order[{}]", orderNo); } cacheOrder.put("errorfreecnt", errorfreecnt); diff --git a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/RemoteStartReplyDataLogic.java b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/RemoteStartReplyDataLogic.java index 684f4bdf..d498405e 100644 --- a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/RemoteStartReplyDataLogic.java +++ b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/RemoteStartReplyDataLogic.java @@ -54,17 +54,19 @@ public class RemoteStartReplyDataLogic implements ServiceLogic { cacheOrder.put("startResult", startResult); String gunkey = "gun:".concat(remoteStartReplyData.getPileNo()).concat(remoteStartReplyData.getGunId()); Map cacheGun = REDIS.getCacheMap(gunkey); - REDIS.setCacheMap(gunkey, cacheGun); REDIS.setCacheMap(orderkey, cacheOrder); + REDIS.setCacheMap(gunkey, cacheGun); if (HEX_01.equals(remoteStartReplyData.getStartResult())) { final String orderstarttime = DateUtil.format(Calendar.getInstance().getTime(), NORM_DATETIME_FORMAT); - cacheOrder.put("startTime", orderstarttime); cacheGun.put("orderstarttime", orderstarttime); cacheGun.put("orderstoptime", null); cacheGun.put("orderkey", orderkey); + cacheOrder.put("orderstarttime", orderstarttime); REDIS.setCacheMap(gunkey, cacheGun); + REDIS.setCacheMap(orderkey, cacheOrder); pileOrderService.pileStartup(orderNo, 1, "启动充电成功"); } else { + final String remark = frs.get(remoteStartReplyData.getFailReason()); pileOrderService.pileStartup(orderNo, 2, remark == null ? "未知错误" : remark); }