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