diff --git a/cloud-modules/cloud-modules-enterprise/cloud-modules-enterprise-cache/src/main/java/com/muyu/enterprise/cache/AllWarnStrategyAndVinCacheService.java b/cloud-modules/cloud-modules-enterprise/cloud-modules-enterprise-cache/src/main/java/com/muyu/enterprise/cache/AllWarnStrategyAndVinCacheService.java index 5ef51f7..3f407ae 100644 --- a/cloud-modules/cloud-modules-enterprise/cloud-modules-enterprise-cache/src/main/java/com/muyu/enterprise/cache/AllWarnStrategyAndVinCacheService.java +++ b/cloud-modules/cloud-modules-enterprise/cloud-modules-enterprise-cache/src/main/java/com/muyu/enterprise/cache/AllWarnStrategyAndVinCacheService.java @@ -9,7 +9,7 @@ import java.util.List; /** * 预警策略缓存服务 */ -public class AllWarnStrategyAndVinCacheService extends CacheAbsBacis> { +public class AllWarnStrategyAndVinCacheService extends CacheAbsBacis { @Override public void clear() { diff --git a/cloud-modules/cloud-modules-enterprise/cloud-modules-enterprise-server/src/main/java/com/muyu/enterprise/controller/VehicleController.java b/cloud-modules/cloud-modules-enterprise/cloud-modules-enterprise-server/src/main/java/com/muyu/enterprise/controller/VehicleController.java index 125aaed..6ae4fc5 100644 --- a/cloud-modules/cloud-modules-enterprise/cloud-modules-enterprise-server/src/main/java/com/muyu/enterprise/controller/VehicleController.java +++ b/cloud-modules/cloud-modules-enterprise/cloud-modules-enterprise-server/src/main/java/com/muyu/enterprise/controller/VehicleController.java @@ -2,9 +2,13 @@ package com.muyu.enterprise.controller; import com.muyu.common.security.utils.SecurityUtils; import com.muyu.common.system.domain.LoginUser; +import com.muyu.domain.WarnStrategy; import com.muyu.domain.req.BoundFenceGroupReq; +import com.muyu.domain.resp.WarnStrategyAndVinResp; import com.muyu.enterprise.cache.AllVehicleCacheService; +import com.muyu.enterprise.cache.AllWarnStrategyAndVinCacheService; import com.muyu.enterprise.cache.VehicleCacheService; +import com.muyu.enterprise.cache.WarnStrategyCacheService; import com.muyu.enterprise.service.VehicleService; import com.muyu.common.core.domain.Result; import com.muyu.common.core.utils.poi.ExcelUtil; @@ -16,6 +20,7 @@ import com.muyu.domain.req.VehicleAddReq; import com.muyu.domain.req.VehicleManageReq; import com.muyu.domain.req.VehicleUpdReq; import com.muyu.domain.resp.VehicleManageResp; +import com.muyu.enterprise.service.WarnStrategyService; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.servlet.http.HttpServletResponse; @@ -51,6 +56,14 @@ public class VehicleController extends BaseController { //车辆信息 @Autowired private AllVehicleCacheService allVehicleCacheService; + //缓存策略和vin + @Autowired + private AllWarnStrategyAndVinCacheService allWarnStrategyAndVinCacheService; + //缓存策略 + @Autowired + private WarnStrategyService warnStrategyService; + @Autowired + private WarnStrategyCacheService warnStrategyCacheService; /** @@ -63,13 +76,14 @@ public class VehicleController extends BaseController { public Result> getVehicleList(@RequestBody VehicleManageReq vehicleManageReq) { startPage(); List list = vehicleService.getVehicleList(vehicleManageReq); -// 将车辆信息存到Redis -// for (VehicleManageResp resp : list) { -// allVehicleCacheService.put(resp.getVehicleVin(), resp); -// } + List vehicleList = vehicleService.list(); vehicleList.forEach(vehicle -> { vehicleCacheService.put(vehicle.getVehicleVin(), vehicle); + if(vehicle.getWarnStrategyId()!=null){ + WarnStrategy warnStrategy = warnStrategyService.getById(vehicle.getWarnStrategyId()); + warnStrategyCacheService.put(vehicle.getVehicleVin(),warnStrategy); + } }); return getDataTable(list); } diff --git a/cloud-modules/cloud-modules-enterprise/cloud-modules-enterprise-server/src/main/java/com/muyu/enterprise/controller/WarnStrategyController.java b/cloud-modules/cloud-modules-enterprise/cloud-modules-enterprise-server/src/main/java/com/muyu/enterprise/controller/WarnStrategyController.java index b080f53..b27b013 100644 --- a/cloud-modules/cloud-modules-enterprise/cloud-modules-enterprise-server/src/main/java/com/muyu/enterprise/controller/WarnStrategyController.java +++ b/cloud-modules/cloud-modules-enterprise/cloud-modules-enterprise-server/src/main/java/com/muyu/enterprise/controller/WarnStrategyController.java @@ -120,12 +120,12 @@ public class WarnStrategyController { /** * 通过vin缓存策略信息 */ - @RequestMapping(path = "/vinStrategyList/{vehicleId}",method = RequestMethod.POST) + @RequestMapping(path = "/vinStrategyList/{warnStrategyId}",method = RequestMethod.POST) @Operation(summary = "通过vin缓存策略信息", description = "通过vin缓存策略信息") - public Result> vinStrategyList(@PathVariable("vehicleId") Long vehicleId) { - List warnStrategyAndVinResp = warnStrategyService.findById(vehicleId); + public Result> vinStrategyList(@PathVariable("warnStrategyId") Long warnStrategyId) { + List warnStrategyAndVinResp = warnStrategyService.findById(warnStrategyId); for (WarnStrategyAndVinResp strategyAndVinResp : warnStrategyAndVinResp) { - allWarnStrategyAndVinCacheService.put(strategyAndVinResp.getVehicleVin(), warnStrategyAndVinResp); + allWarnStrategyAndVinCacheService.put(strategyAndVinResp.getVehicleVin(), (WarnStrategyAndVinResp) warnStrategyAndVinResp); } return Result.success(warnStrategyAndVinResp); } diff --git a/cloud-modules/cloud-modules-enterprise/cloud-modules-enterprise-server/src/main/java/com/muyu/enterprise/mapper/WarnStrategyMapper.java b/cloud-modules/cloud-modules-enterprise/cloud-modules-enterprise-server/src/main/java/com/muyu/enterprise/mapper/WarnStrategyMapper.java index 22d0c2b..f82c21e 100644 --- a/cloud-modules/cloud-modules-enterprise/cloud-modules-enterprise-server/src/main/java/com/muyu/enterprise/mapper/WarnStrategyMapper.java +++ b/cloud-modules/cloud-modules-enterprise/cloud-modules-enterprise-server/src/main/java/com/muyu/enterprise/mapper/WarnStrategyMapper.java @@ -13,7 +13,7 @@ import java.util.List; public interface WarnStrategyMapper extends MPJBaseMapper { - @Select("SELECT vehicle.vehicle_vin, warn_strategy.warn_strategy_id, warn_strategy.vehicle_type_id, warn_strategy.message_template_id FROM vehicle LEFT JOIN warn_strategy ON vehicle.warn_strategy_id = warn_strategy.warn_strategy_id WHERE vehicle.vehicle_id = #{vehicleId}") + @Select("SELECT vehicle.vehicle_vin, warn_strategy.warn_strategy_id, warn_strategy.vehicle_type_id, warn_strategy.message_template_id FROM vehicle LEFT JOIN warn_strategy ON vehicle.warn_strategy_id = warn_strategy.warn_strategy_id WHERE vehicle.warn_strategy_id = #{warn_strategy_id}") List findById(Long vehicleId); } diff --git a/cloud-modules/cloud-modules-enterprise/cloud-modules-enterprise-server/src/main/java/com/muyu/enterprise/service/WarnStrategyService.java b/cloud-modules/cloud-modules-enterprise/cloud-modules-enterprise-server/src/main/java/com/muyu/enterprise/service/WarnStrategyService.java index a32ba1b..0cd2b2d 100644 --- a/cloud-modules/cloud-modules-enterprise/cloud-modules-enterprise-server/src/main/java/com/muyu/enterprise/service/WarnStrategyService.java +++ b/cloud-modules/cloud-modules-enterprise/cloud-modules-enterprise-server/src/main/java/com/muyu/enterprise/service/WarnStrategyService.java @@ -18,7 +18,7 @@ public interface WarnStrategyService extends IService { List selectList(WarnVehicleReq req); - List findById(Long vehicleId); + List findById(Long warnStrategyId); } diff --git a/cloud-modules/cloud-modules-enterprise/cloud-modules-enterprise-server/src/main/java/com/muyu/enterprise/service/impl/WarnStrategyServiceImpl.java b/cloud-modules/cloud-modules-enterprise/cloud-modules-enterprise-server/src/main/java/com/muyu/enterprise/service/impl/WarnStrategyServiceImpl.java index 449ba18..baa3553 100644 --- a/cloud-modules/cloud-modules-enterprise/cloud-modules-enterprise-server/src/main/java/com/muyu/enterprise/service/impl/WarnStrategyServiceImpl.java +++ b/cloud-modules/cloud-modules-enterprise/cloud-modules-enterprise-server/src/main/java/com/muyu/enterprise/service/impl/WarnStrategyServiceImpl.java @@ -43,8 +43,8 @@ public class WarnStrategyServiceImpl extends ServiceImpl findById(Long vehicleId) { - List byId = warnStrategyMapper.findById(vehicleId); + public List findById(Long warnStrategyId) { + List byId = warnStrategyMapper.findById(warnStrategyId); if (byId == null) { return null; }