diff --git a/jsowell-admin/src/test/java/SpringBootTestController.java b/jsowell-admin/src/test/java/SpringBootTestController.java index 53c548d91..debf1d1bb 100644 --- a/jsowell-admin/src/test/java/SpringBootTestController.java +++ b/jsowell-admin/src/test/java/SpringBootTestController.java @@ -8,6 +8,7 @@ import com.fasterxml.jackson.databind.PropertyNamingStrategies; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Lists; import com.google.common.collect.Maps; +import com.google.common.collect.Sets; import com.google.common.primitives.Bytes; import com.huifu.adapay.core.exception.BaseAdaPayException; import com.huifu.adapay.model.Refund; @@ -184,6 +185,21 @@ public class SpringBootTestController { @Autowired private IMemberBasicInfoService memberBasicInfoService; + @Test + public void testRedisSet() { + String redisKey = "push_station_connector"; + redisCache.setCacheSet(redisKey, Sets.newHashSet("1")); + redisCache.setCacheSet(redisKey, Sets.newHashSet("3")); + redisCache.setCacheSet(redisKey, Sets.newHashSet("5")); + redisCache.setCacheSet(redisKey, Sets.newHashSet("1")); + redisCache.setCacheSet(redisKey, Sets.newHashSet("1")); + redisCache.setCacheSet(redisKey, Sets.newHashSet("7")); + redisCache.setCacheSet(redisKey, Sets.newHashSet("3")); + + Set cacheSet = redisCache.getCacheSet(redisKey); + System.out.println(cacheSet); + } + @Test public void testSettleOrder() { Map returnAmountMap = Maps.newHashMap(); @@ -827,7 +843,7 @@ public class SpringBootTestController { @Test public void testupdateElecAmount() { - orderBasicInfoService.updateElecAmount(); + // orderBasicInfoService.updateElecAmount(); } @Test 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 de89ff523..c0be95e5e 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 @@ -19,6 +19,8 @@ public class CacheConstants { public static final int cache_expire_time_1d = 60 * 60 * 24; + public static final String PUSH_STATION_CONNECTOR = "push_station_connector"; + public static final String PLATFORM_TESTER = "platform_tester:"; public static final String GET_PILE_MODEL_INFO_BY_MODEL_ID = "get_pile_model_info_by_model_id:"; diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/service/IPileConnectorInfoService.java b/jsowell-pile/src/main/java/com/jsowell/pile/service/IPileConnectorInfoService.java index 0b0d45eaf..245040220 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/service/IPileConnectorInfoService.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/service/IPileConnectorInfoService.java @@ -35,30 +35,6 @@ public interface IPileConnectorInfoService { List selectPileConnectorInfoList(String pileSn); - /** - * 新增充电桩枪口信息 - * - * @param pileConnectorInfo 充电桩枪口信息 - * @return 结果 - */ - // int insertPileConnectorInfo(PileConnectorInfo pileConnectorInfo); - - /** - * 修改充电桩枪口信息 - * - * @param pileConnectorInfo 充电桩枪口信息 - * @return 结果 - */ - // int updatePileConnectorInfo(PileConnectorInfo pileConnectorInfo); - - /** - * 批量删除充电桩枪口信息 - * - * @param ids 需要删除的充电桩枪口信息主键集合 - * @return 结果 - */ - // int deletePileConnectorInfoByIds(Integer[] ids); - int deletePileConnectorInfoByPileSnList(List pileSnList); int batchInsertConnectorInfo(List pileConnectorInfoList); 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 862dafc2c..b5358cbd7 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 @@ -5,6 +5,7 @@ import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import com.google.common.collect.Lists; import com.google.common.collect.Maps; +import com.google.common.collect.Sets; import com.jsowell.common.constant.CacheConstants; import com.jsowell.common.constant.Constants; import com.jsowell.common.core.domain.ykc.RealTimeMonitorData; @@ -531,10 +532,23 @@ public class PileConnectorInfoServiceImpl implements IPileConnectorInfoService { // TODO 推送联联平台 设备状态变化推送接口 ConnectorStatusInfo + // 异步放缓存 + CompletableFuture.runAsync(() -> statusChange(pileConnectorCode)); } return num; } + // 枪口状态变更,站点id放缓存 + private void statusChange(String pileConnectorCode) { + // 查询枪口信息 + PileConnectorInfoVO connectorInfoVO = getPileConnectorInfoByConnectorCode(pileConnectorCode); + if (connectorInfoVO == null) { + return; + } + String redisKey = CacheConstants.PUSH_STATION_CONNECTOR; + redisCache.setCacheSet(redisKey, Sets.newHashSet(connectorInfoVO.getStationId())); + } + /** * 批量获取桩状态 * 桩的状态有 在线 离线 故障 diff --git a/jsowell-quartz/pom.xml b/jsowell-quartz/pom.xml index 1530ba2af..1cbeda7f7 100644 --- a/jsowell-quartz/pom.xml +++ b/jsowell-quartz/pom.xml @@ -39,13 +39,16 @@ com.jsowell jsowell-pile - 1.0.0 com.jsowell jsowell-netty - 1.0.0 + + + + com.jsowell + jsowell-thirdparty diff --git a/jsowell-quartz/src/main/java/com/jsowell/quartz/task/JsowellTask.java b/jsowell-quartz/src/main/java/com/jsowell/quartz/task/JsowellTask.java index 1721e5214..ac7f98bd5 100644 --- a/jsowell-quartz/src/main/java/com/jsowell/quartz/task/JsowellTask.java +++ b/jsowell-quartz/src/main/java/com/jsowell/quartz/task/JsowellTask.java @@ -1,6 +1,8 @@ package com.jsowell.quartz.task; +import com.jsowell.common.constant.CacheConstants; import com.jsowell.common.constant.Constants; +import com.jsowell.common.core.redis.RedisCache; import com.jsowell.common.util.DateUtils; import com.jsowell.common.util.StringUtils; import com.jsowell.pile.domain.OrderBasicInfo; @@ -12,6 +14,7 @@ import com.jsowell.pile.service.IPileBillingTemplateService; import com.jsowell.pile.service.IPileStationInfoService; import com.jsowell.pile.service.YKCPushCommandService; import com.jsowell.pile.vo.web.BillingTemplateVO; +import com.jsowell.thirdparty.amap.service.AMapService; import org.apache.commons.collections4.CollectionUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -23,6 +26,7 @@ import java.time.LocalDate; import java.time.LocalDateTime; import java.util.Date; import java.util.List; +import java.util.Set; @Component("jsowellTask") public class JsowellTask { @@ -41,6 +45,12 @@ public class JsowellTask { @Autowired private IPileStationInfoService pileStationInfoService; + @Autowired + private RedisCache redisCache; + + @Autowired + private AMapService aMapService; + /** * 关闭15分钟未支付的订单 * close15MinutesOfUnpaidOrders @@ -126,4 +136,22 @@ public class JsowellTask { } } } + + /** + * 站点的枪口数据推送到高德 + */ + public void pushToAMap() { + Set stationIds = redisCache.getCacheSet(CacheConstants.PUSH_STATION_CONNECTOR); + if (CollectionUtils.isEmpty(stationIds)) { + return; + } + log.info("推送到高德的stationId:{}", stationIds); + // for (String stationId : stationIds) { + // try { + // aMapService.pushChargingDeviceDynamics(stationId); + // } catch (Exception e) { + // log.error("推送到高德error", e); + // } + // } + } }