feat:()修改策略信息存储方法
parent
51ca5ef6f4
commit
2e5cb19f4f
|
@ -9,7 +9,7 @@ import java.util.List;
|
|||
/**
|
||||
* 预警策略缓存服务
|
||||
*/
|
||||
public class AllWarnStrategyAndVinCacheService extends CacheAbsBacis<String, List<WarnStrategyAndVinResp>> {
|
||||
public class AllWarnStrategyAndVinCacheService extends CacheAbsBacis<String, WarnStrategyAndVinResp> {
|
||||
@Override
|
||||
public void clear() {
|
||||
|
||||
|
|
|
@ -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<TableDataInfo<VehicleManageResp>> getVehicleList(@RequestBody VehicleManageReq vehicleManageReq) {
|
||||
startPage();
|
||||
List<VehicleManageResp> list = vehicleService.getVehicleList(vehicleManageReq);
|
||||
// 将车辆信息存到Redis
|
||||
// for (VehicleManageResp resp : list) {
|
||||
// allVehicleCacheService.put(resp.getVehicleVin(), resp);
|
||||
// }
|
||||
|
||||
List<Vehicle> 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);
|
||||
}
|
||||
|
|
|
@ -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<List<WarnStrategyAndVinResp>> vinStrategyList(@PathVariable("vehicleId") Long vehicleId) {
|
||||
List<WarnStrategyAndVinResp> warnStrategyAndVinResp = warnStrategyService.findById(vehicleId);
|
||||
public Result<List<WarnStrategyAndVinResp>> vinStrategyList(@PathVariable("warnStrategyId") Long warnStrategyId) {
|
||||
List<WarnStrategyAndVinResp> warnStrategyAndVinResp = warnStrategyService.findById(warnStrategyId);
|
||||
for (WarnStrategyAndVinResp strategyAndVinResp : warnStrategyAndVinResp) {
|
||||
allWarnStrategyAndVinCacheService.put(strategyAndVinResp.getVehicleVin(), warnStrategyAndVinResp);
|
||||
allWarnStrategyAndVinCacheService.put(strategyAndVinResp.getVehicleVin(), (WarnStrategyAndVinResp) warnStrategyAndVinResp);
|
||||
}
|
||||
return Result.success(warnStrategyAndVinResp);
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ import java.util.List;
|
|||
public interface WarnStrategyMapper extends MPJBaseMapper<WarnStrategy> {
|
||||
|
||||
|
||||
@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<WarnStrategyAndVinResp> findById(Long vehicleId);
|
||||
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ public interface WarnStrategyService extends IService<WarnStrategy> {
|
|||
List<WarnVehicleResp> selectList(WarnVehicleReq req);
|
||||
|
||||
|
||||
List<WarnStrategyAndVinResp> findById(Long vehicleId);
|
||||
List<WarnStrategyAndVinResp> findById(Long warnStrategyId);
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -43,8 +43,8 @@ public class WarnStrategyServiceImpl extends ServiceImpl<WarnStrategyMapper, War
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<WarnStrategyAndVinResp> findById(Long vehicleId) {
|
||||
List<WarnStrategyAndVinResp> byId = warnStrategyMapper.findById(vehicleId);
|
||||
public List<WarnStrategyAndVinResp> findById(Long warnStrategyId) {
|
||||
List<WarnStrategyAndVinResp> byId = warnStrategyMapper.findById(warnStrategyId);
|
||||
if (byId == null) {
|
||||
return null;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue