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 833cf6022..5e763b546 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 @@ -37,6 +37,8 @@ public class CacheConstants { */ public static final String PILE_REAL_TIME_MONITOR_DATA = "pile_real_time_monitor_data:"; + public static final String PILE_IS_CHARGING = "pile_is_charging:"; + /** * 充电桩最后连接时间 */ diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileBasicInfoServiceImpl.java b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileBasicInfoServiceImpl.java index 3d71241e3..6a8f5d73d 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileBasicInfoServiceImpl.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileBasicInfoServiceImpl.java @@ -470,6 +470,10 @@ public class PileBasicInfoServiceImpl implements IPileBasicInfoService { String jsonMsg = JSONObject.toJSONString(realTimeMonitorData); // 上传实时数据每10秒发送一次,1分钟6次,在同一分钟内,只保留最后一条实时数据 redisCache.hset(redisKey, DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:00", now), jsonMsg); + + // 把充电桩正在充电中的状态存到redis + String pileIsChargingKey = CacheConstants.PILE_IS_CHARGING + realTimeMonitorData.getPileSn(); + redisCache.setCacheObject(pileIsChargingKey, Constants.one, 12); } @Override diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileConnectorInfoServiceImpl.java b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileConnectorInfoServiceImpl.java index bbcc67e51..dd8275cb3 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileConnectorInfoServiceImpl.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileConnectorInfoServiceImpl.java @@ -39,6 +39,7 @@ import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Set; +import java.util.concurrent.CompletableFuture; import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; @@ -528,8 +529,10 @@ public class PileConnectorInfoServiceImpl implements IPileConnectorInfoService { if (connectorStatusList.contains(PileConnectorDataBaseStatusEnum.OFF_NETWORK.getValue())) { pileStatus = PileStatusEnum.OFF_LINE.getValue(); flag = true; - // 将此桩正在进行充电的订单状态改为 异常 - orderBasicInfoService.updateOrderStatusAsAbnormal(pileSn); + // 异步将此桩正在进行充电的订单状态改为 异常 + CompletableFuture.runAsync(() -> { + orderBasicInfoService.updateOrderStatusAsAbnormal(pileSn); + }); } // 没有故障或者离线,就是在线状态