From d9a51e83427f4e1fa688ddf0092c726dd05c87fe Mon Sep 17 00:00:00 2001 From: ZZ Date: Thu, 25 Nov 2021 14:48:09 +0800 Subject: [PATCH] perfecting --- .../evcs/http/GlobalExceptionController.java | 1 + .../api/QueryEquipChargeStatusController.java | 19 ++++++++++++------- .../java/com/xhpc/evcs/config/EvcsFilter.java | 14 +++++++------- .../NotificationEquipChargeStatusTask.java | 8 +++++--- .../NotificationStopChargeResultTask.java | 2 +- .../com/xhpc/pp/logic/OrderDataLogic.java | 1 + .../com/xhpc/pp/logic/RealtimeDataLogic.java | 2 ++ 7 files changed, 29 insertions(+), 18 deletions(-) diff --git a/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/http/GlobalExceptionController.java b/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/http/GlobalExceptionController.java index 9f171b42..3ea7b936 100644 --- a/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/http/GlobalExceptionController.java +++ b/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/http/GlobalExceptionController.java @@ -24,6 +24,7 @@ public class GlobalExceptionController extends ResponseEntityExceptionHandler { CommonResponse commonResponse = new CommonResponse(); commonResponse.setRet(EvcsConst.RET_FAIL); commonResponse.setMsg(e.getMessage()); + e.printStackTrace(); logger.error(e.getMessage()); return commonResponse; } diff --git a/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/api/QueryEquipChargeStatusController.java b/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/api/QueryEquipChargeStatusController.java index 300ae18e..9ab17482 100644 --- a/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/api/QueryEquipChargeStatusController.java +++ b/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/api/QueryEquipChargeStatusController.java @@ -50,7 +50,9 @@ public class QueryEquipChargeStatusController { Map order = REDIS.getCacheMap("order:" + internalOrderNum); String orderStatus = (String) order.get("status"); int startChargeSeqStat = 0; - switch (orderStatus) { + if (orderStatus == null) { + startChargeSeqStat = 5; + } else switch (orderStatus) { case "启动中": startChargeSeqStat = 1; break; @@ -107,14 +109,17 @@ public class QueryEquipChargeStatusController { equipChargeStatus.setStartTime(startTime); //本次采样时间 直接new一个当前时间的Date就可以了 CacheRealtimeData lord = REDIS.getCacheObject("order:" + internalOrderNum + ".lord"); - equipChargeStatus.setEndTime(lord.getCreateTime()); + if (lord != null) { + equipChargeStatus.setEndTime(lord.getCreateTime()); + equipChargeStatus.setTotalMoney(lord.getAmountCharged() / 10000.0); + equipChargeStatus.setTotalPower(lord.getChargingDegree() / 10000.0); + } else { + equipChargeStatus.setEndTime(equipChargeStatus.getStartTime()); + equipChargeStatus.setTotalMoney(0.0); + equipChargeStatus.setTotalPower(0.0); + } Integer chargeModel = (Integer) order.get("chargeModel"); equipChargeStatus.setChargeModel(chargeModel == null ? 0 : chargeModel); - //累计充电量 - Double chargingDegree = Double.valueOf(lord.getChargingDegree() == null ? 0 : lord.getChargingDegree()); - equipChargeStatus.setTotalPower(chargingDegree / 10000); - //总金额 - equipChargeStatus.setTotalMoney(lord.getAmountCharged() == null ? 0 : lord.getAmountCharged() / 10000.0); final Long rateModelId = REDIS.getCacheMapValue("pile:".concat(connectorId.substring(0, 14)), "rateModelId"); final CacheRateModel cacheRateModel = REDIS.getCacheObject("rateModel:" + rateModelId); calculateEm(equipChargeStatus, cacheRateModel); diff --git a/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/config/EvcsFilter.java b/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/config/EvcsFilter.java index 5d56823b..e69dfa20 100644 --- a/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/config/EvcsFilter.java +++ b/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/config/EvcsFilter.java @@ -109,13 +109,13 @@ public class EvcsFilter extends OncePerRequestFilter { (now.before(authSecretTokenIn.getTokenExpiry()) && authorization != null && authorization.substring(7).equals(authSecretTokenIn.getToken()))) { try { - if (authSecretTokenIn.isEncrypt() && !"false".equals(encin)) { - decryptedReq = decrypt(request, authSecretTokenIn, commonRequest, bodyString); - } else { - String data = commonRequest.getData(); - if (data == null) data = bodyString; - decryptedReq = data.getBytes(StandardCharsets.UTF_8); - } +// if (authSecretTokenIn.isEncrypt() && !"false".equals(encin)) { // test code + decryptedReq = decrypt(request, authSecretTokenIn, commonRequest, bodyString); +// } else { +// String data = commonRequest.getData(); +// if (data == null) data = bodyString; +// decryptedReq = data.getBytes(StandardCharsets.UTF_8); +// } commonRequest.setData(new String(decryptedReq)); log.debug("in.dec: {}", commonRequest); } catch (BadPaddingException | InvalidAlgorithmParameterException | NoSuchAlgorithmException | IllegalBlockSizeException | NoSuchPaddingException | InvalidKeyException e) { diff --git a/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/notification/NotificationEquipChargeStatusTask.java b/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/notification/NotificationEquipChargeStatusTask.java index 2a79d6e0..419262a8 100644 --- a/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/notification/NotificationEquipChargeStatusTask.java +++ b/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/notification/NotificationEquipChargeStatusTask.java @@ -165,9 +165,11 @@ public class NotificationEquipChargeStatusTask extends CoreDispatcher { final BigDecimal oddm = BigDecimal.valueOf(totalMoney).subtract(BigDecimal.valueOf(firstNElecMoney)).subtract(BigDecimal.valueOf(firstNSeviceMony)); final BigDecimal oddp = BigDecimal.valueOf(totalPower).subtract(BigDecimal.valueOf(firstNPower)); - ChargeDetails peek = chargeDetailsStack.peek(); - peek.setDetailElecMoney(BigDecimal.valueOf(peek.getDetailElecMoney()).add(oddm).setScale(2, RoundingMode.HALF_UP).doubleValue()); - peek.setDetailPower(BigDecimal.valueOf(peek.getDetailPower()).add(oddp).setScale(2, RoundingMode.HALF_UP).doubleValue()); + if (!chargeDetailsStack.isEmpty()) { + ChargeDetails peek = chargeDetailsStack.peek(); + peek.setDetailElecMoney(BigDecimal.valueOf(peek.getDetailElecMoney()).add(oddm).setScale(2, RoundingMode.HALF_UP).doubleValue()); + peek.setDetailPower(BigDecimal.valueOf(peek.getDetailPower()).add(oddp).setScale(2, RoundingMode.HALF_UP).doubleValue()); + } } private static void calculateCD(CacheRateModel cacheRateModel, String rtf, diff --git a/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/notification/NotificationStopChargeResultTask.java b/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/notification/NotificationStopChargeResultTask.java index c7539b5d..ad431142 100644 --- a/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/notification/NotificationStopChargeResultTask.java +++ b/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/notification/NotificationStopChargeResultTask.java @@ -58,7 +58,7 @@ public class NotificationStopChargeResultTask extends CoreDispatcher { if (isStopNotified == null || !isStopNotified) { String internetSerialNumber = (String) pushOrder.get("internetSerialNumber"); if (internetSerialNumber == null) { - log.error("null isn: {}", pushOrderKey); + continue; } String operatorId3rdpty = internetSerialNumber.substring(0, 9); AuthSecretToken authSecretTokenOut = diff --git a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/OrderDataLogic.java b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/OrderDataLogic.java index 38dd1f67..b39a30b0 100644 --- a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/OrderDataLogic.java +++ b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/OrderDataLogic.java @@ -49,6 +49,7 @@ public class OrderDataLogic implements ServiceLogic { cacheOrderData.setStatus(1); cacheOrderData.setCreateTime(DateUtil.now()); cacheOrder.put("orderData", cacheOrderData); + cacheOrder.put("status", "已结束"); REDIS.setCacheMap(orderkey, cacheOrder); String gunkey = "gun:".concat(orderData.getPileNo()).concat(orderData.getGunId()); Map cacheGun = REDIS.getCacheMap(gunkey); 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 6cb56ef7..6d6638c0 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 @@ -200,6 +200,7 @@ public class RealtimeDataLogic implements ServiceLogic { REDIS.setCacheMap(orderkey, cacheOrder); cacheOrder.put("abnormal", "1.2");//lord as orderData log.error("abnormal.1.2 order[{}]", orderNo); + cacheOrder.put("status", "已结束"); } if (r == null || r.getCode() != 200) { log.error("errorfreecnt r{}", JSONUtil.toJsonStr(r)); @@ -227,6 +228,7 @@ public class RealtimeDataLogic implements ServiceLogic { startSoc == null ? 0 : startSoc, endSoc == null ? 0 : endSoc)); log.error("abnormal.2.1 order[{}]", orderNo); cacheOrder.put("abnormal", "2.1"); + cacheOrder.put("status", "已结束"); } else { log.error("abnormal.2.2 order[{}]", orderNo); cacheOrder.put("abnormal", "2.2");//not respond