From b5266d90b1e4025666459f4f5c643ef3aa747703 Mon Sep 17 00:00:00 2001 From: Lemon Date: Tue, 7 Jan 2025 08:50:34 +0800 Subject: [PATCH] =?UTF-8?q?update=20=20=E5=B9=BF=E8=A5=BF=E5=B9=B3?= =?UTF-8?q?=E5=8F=B0=E6=8E=A8=E9=80=81=E8=AE=BE=E5=A4=87=E5=85=85=E7=94=B5?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E6=94=B9=E4=B8=BA5=E5=88=86=E9=92=9F?= =?UTF-8?q?=E4=BC=A0=E4=B8=80=E6=AC=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/constant/CacheConstants.java | 5 +++++ .../impl/GuangXiPlatformServiceImpl.java | 21 ++++++++++++------- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/jsowell-common/src/main/java/com/jsowell/common/constant/CacheConstants.java b/jsowell-common/src/main/java/com/jsowell/common/constant/CacheConstants.java index 1b47baf73..1540aca9f 100644 --- a/jsowell-common/src/main/java/com/jsowell/common/constant/CacheConstants.java +++ b/jsowell-common/src/main/java/com/jsowell/common/constant/CacheConstants.java @@ -195,6 +195,11 @@ public class CacheConstants { */ public static final String THIRD_PARTY_TOKEN_BY_OPERATOR_SECRET = "third_party_token_by_operator_secret:"; + /** + * 推送设备充电状态信息数据缓存 + */ + public static final String NOTIFICATION_EQUIP_CHARGE_STATUS_BY_ORDER_CODE = "notification_equip_charge_status_by_order_code:"; + /** * 充电桩状态前缀 */ diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/GuangXiPlatformServiceImpl.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/GuangXiPlatformServiceImpl.java index def8fa1fe..e41ee3fba 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/GuangXiPlatformServiceImpl.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/GuangXiPlatformServiceImpl.java @@ -4,6 +4,7 @@ import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSONObject; import com.github.pagehelper.PageInfo; import com.google.common.collect.Lists; +import com.jsowell.common.constant.CacheConstants; import com.jsowell.common.constant.Constants; import com.jsowell.common.core.domain.ykc.RealTimeMonitorData; import com.jsowell.common.core.redis.RedisCache; @@ -604,8 +605,12 @@ public class GuangXiPlatformServiceImpl implements ThirdPartyPlatformService { */ @Override public String notificationEquipChargeStatus(String orderCode) { - // 根据订单号查询订单信息 - OrderBasicInfo orderInfo = orderBasicInfoService.getOrderInfoByOrderCode(orderCode); + // 先查缓存中是否有数据 + String redisKey = CacheConstants.NOTIFICATION_EQUIP_CHARGE_STATUS_BY_ORDER_CODE + orderCode; + Object cacheObject = redisCache.getCacheObject(redisKey); + if (cacheObject != null) { + return "距上次推送未超过5分钟,本次不予推送"; + } // 查询相关配置信息 ThirdPartySecretInfoVO thirdPartySecretInfoVO = getGuangXiSecretInfo(); @@ -616,6 +621,8 @@ public class GuangXiPlatformServiceImpl implements ThirdPartyPlatformService { String dataSecretIv = thirdPartySecretInfoVO.getTheirDataSecretIv(); String urlAddress = thirdPartySecretInfoVO.getTheirUrlPrefix(); + // 根据订单号查询订单信息 + OrderBasicInfo orderInfo = orderBasicInfoService.getOrderInfoByOrderCode(orderCode); // 查询枪口实时状态 List chargingRealTimeData = orderBasicInfoService.getChargingRealTimeData(orderInfo.getTransactionCode()); RealTimeMonitorData realTimeMonitorData; @@ -653,20 +660,14 @@ public class GuangXiPlatformServiceImpl implements ThirdPartyPlatformService { SupEquipChargeStatusInfo supEquipChargeStatusInfo = SupEquipChargeStatusInfo.builder() .startChargeSeq(startChargeSeq) .startChargeSeqStat(Integer.parseInt(orderStatus)) - // .startChargeSeqStat(2) .connectorID(orderInfo.getPileConnectorCode()) .connectorStatus(Integer.parseInt(realTimeMonitorData.getConnectorStatus())) // 3-充电中 - // .connectorStatus(3) // 3-充电中 .currentA(current.setScale(1, RoundingMode.HALF_UP)) - // .currentA(new BigDecimal("20.3")) .voltageA(voltage.setScale(1, RoundingMode.HALF_UP)) - // .voltageA(new BigDecimal("260.7")) .soc(new BigDecimal(soc)) - // .soc(new BigDecimal("79")) .startTime(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, orderInfo.getChargeStartTime())) .endTime(dateTime) .totalPower(new BigDecimal(realTimeMonitorData.getChargingDegree())) - // .totalPower(new BigDecimal("5292.21")) .build(); @@ -677,6 +678,10 @@ public class GuangXiPlatformServiceImpl implements ThirdPartyPlatformService { // 获取令牌 String token = getToken(urlAddress, operatorId, operatorSecret, dataSecretIv, signSecret, dataSecret); String result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret); + if (StringUtils.equals("成功", result)) { + // 将数据存入缓存,5分钟失效 + redisCache.setCacheObject(redisKey, result, 5, TimeUnit.MINUTES); + } return result; }