feat:()修改策略信息存储方法
parent
2695602972
commit
51ca5ef6f4
|
@ -0,0 +1,27 @@
|
|||
package com.muyu.enterprise.cache;
|
||||
|
||||
import com.muyu.common.cache.CacheAbsBacis;
|
||||
import com.muyu.domain.resp.WarnStrategyAndVinResp;
|
||||
import com.muyu.domain.resp.WarnVehicleResp;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 预警策略缓存服务
|
||||
*/
|
||||
public class AllWarnStrategyAndVinCacheService extends CacheAbsBacis<String, List<WarnStrategyAndVinResp>> {
|
||||
@Override
|
||||
public void clear() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String keyPre() {
|
||||
return "AllWarnStrategy:info:";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String decode(String key) {
|
||||
return key.replace("AllWarnStrategy:info:", "");
|
||||
}
|
||||
}
|
|
@ -2,8 +2,11 @@ package com.muyu.enterprise.cache;
|
|||
|
||||
import com.muyu.common.cache.CacheAbsBacis;
|
||||
import com.muyu.domain.WarnStrategy;
|
||||
import com.muyu.domain.resp.WarnStrategyAndVinResp;
|
||||
import com.muyu.domain.resp.WarnVehicleResp;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 预警策略缓存服务
|
||||
*/
|
||||
|
|
|
@ -4,6 +4,7 @@ com.muyu.enterprise.cache.AllMessageValueCacheService
|
|||
com.muyu.enterprise.cache.AllVehicleCacheService
|
||||
com.muyu.enterprise.cache.AllVehicleTypeCacheService
|
||||
com.muyu.enterprise.cache.AllWarnRuleCacheService
|
||||
com.muyu.enterprise.cache.AllWarnStrategyAndVinCacheService
|
||||
com.muyu.enterprise.cache.AllWarnStrategyCacheService
|
||||
com.muyu.enterprise.cache.FaultCacheService
|
||||
com.muyu.enterprise.cache.FenceCahceService
|
||||
|
|
|
@ -12,12 +12,7 @@ import lombok.NoArgsConstructor;
|
|||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
/**
|
||||
* @Author: LiDongJia
|
||||
* @Package: com.muyu.car.domain
|
||||
* @Project: 2112-car-cloud-server
|
||||
* @name: MessageTemplate
|
||||
* @Date: 2024/9/18 21:11
|
||||
* @Description: 报文模版
|
||||
* 报文模版
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
|
|
|
@ -119,6 +119,10 @@ public class Vehicle extends BaseEntity {
|
|||
@Schema(type = "Integer",description = "电子围栏外键")
|
||||
private Integer fenceGroupId;
|
||||
|
||||
/** 策略id */
|
||||
@Schema(type = "Long",description = "策略id")
|
||||
private Long warnStrategyId;
|
||||
|
||||
public static Vehicle addBuild(VehicleAddReq vehicleAddReq){
|
||||
return Vehicle.builder()
|
||||
.licenceNumber(vehicleAddReq.getLicenceNumber())
|
||||
|
@ -132,6 +136,7 @@ public class Vehicle extends BaseEntity {
|
|||
.vehicleStatus(vehicleAddReq.getVehicleStatus())
|
||||
.companyId(vehicleAddReq.getCompanyId())
|
||||
.fenceGroupId(vehicleAddReq.getFenceGroupId())
|
||||
.warnStrategyId(vehicleAddReq.getWarnStrategyId())
|
||||
.build();
|
||||
}
|
||||
|
||||
|
@ -149,6 +154,7 @@ public class Vehicle extends BaseEntity {
|
|||
.vehicleStatus(vehicleUpdReq.getVehicleStatus())
|
||||
.companyId(vehicleUpdReq.getCompanyId())
|
||||
.fenceGroupId(vehicleUpdReq.getFenceGroupId())
|
||||
.warnStrategyId(vehicleUpdReq.getWarnStrategyId())
|
||||
.build();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package com.muyu.domain.req;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.muyu.common.core.annotation.Excel;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
@ -94,4 +96,9 @@ public class VehicleAddReq {
|
|||
*/
|
||||
@Schema(title = "电子围栏外键", type = "Integer", defaultValue = "1", description = "电子围栏外键")
|
||||
private Integer fenceGroupId;
|
||||
|
||||
/** 策略id */
|
||||
@Schema(type = "Long",description = "策略id")
|
||||
@TableId( type = IdType.AUTO)
|
||||
private Long warnStrategyId;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package com.muyu.domain.req;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.muyu.common.core.annotation.Excel;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
@ -94,4 +96,11 @@ public class VehicleUpdReq {
|
|||
*/
|
||||
@Schema(title = "电子围栏外键", type = "Integer", defaultValue = "1", description = "电子围栏外键")
|
||||
private Integer fenceGroupId;
|
||||
|
||||
/** 策略id */
|
||||
@Schema(type = "Long",description = "策略id")
|
||||
@TableId( type = IdType.AUTO)
|
||||
private Long warnStrategyId;
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,56 @@
|
|||
package com.muyu.domain.resp;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.muyu.common.core.annotation.Excel;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Builder
|
||||
@Tag(name = "WarnStrategyAndVin缓存预警信息获取vin")
|
||||
public class WarnStrategyAndVinResp {
|
||||
|
||||
|
||||
/**
|
||||
* 车辆VIN
|
||||
*/
|
||||
@Schema(type = "String",description = "车辆VIN")
|
||||
@Excel(name = "车辆VIN")
|
||||
private String vehicleVin;
|
||||
|
||||
/**
|
||||
* 策略id
|
||||
*/
|
||||
@Schema(type = "Long",description = "策略id")
|
||||
@TableId( type = IdType.AUTO)
|
||||
private Long warnStrategyId;
|
||||
|
||||
/**
|
||||
* 策略名称
|
||||
*/
|
||||
@Schema(type = "String",description = "策略名称")
|
||||
@Excel(name = "策略名称")
|
||||
private String strategyName;
|
||||
|
||||
/**
|
||||
* 报文模版id
|
||||
*/
|
||||
@Schema(type = "Integer",description = "报文模版id")
|
||||
@Excel(name = "报文模版id")
|
||||
private Integer messageTemplateId;
|
||||
|
||||
/**
|
||||
* 车辆类型id
|
||||
*/
|
||||
@Schema(type = "Long",description = "车辆类型id")
|
||||
@Excel(name = "车辆类型id")
|
||||
private Long vehicleTypeId;
|
||||
|
||||
}
|
|
@ -66,4 +66,13 @@ public class WarnVehicleResp {
|
|||
@Schema(type = "String",description = "报文模版名称")
|
||||
private String messageTemplateName;
|
||||
|
||||
|
||||
/**
|
||||
* 报文模版id
|
||||
*/
|
||||
@Schema(type = "Integer",description = "报文模版id")
|
||||
@Excel(name = "报文模版id")
|
||||
private Integer messageTemplateId;
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -4,6 +4,8 @@ import com.muyu.common.core.domain.Result;
|
|||
import com.muyu.common.security.utils.SecurityUtils;
|
||||
import com.muyu.common.system.domain.LoginUser;
|
||||
import com.muyu.domain.WarnStrategy;
|
||||
import com.muyu.domain.resp.WarnStrategyAndVinResp;
|
||||
import com.muyu.enterprise.cache.AllWarnStrategyAndVinCacheService;
|
||||
import com.muyu.enterprise.cache.AllWarnStrategyCacheService;
|
||||
import com.muyu.enterprise.cache.WarnStrategyCacheService;
|
||||
import com.muyu.enterprise.service.WarnStrategyService;
|
||||
|
@ -31,26 +33,23 @@ public class WarnStrategyController {
|
|||
@Autowired
|
||||
private AllWarnStrategyCacheService allWarnStrategyCacheService;
|
||||
|
||||
//缓存策略和vin
|
||||
@Autowired
|
||||
private AllWarnStrategyAndVinCacheService allWarnStrategyAndVinCacheService;
|
||||
|
||||
|
||||
/**
|
||||
* 策略列表
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(path = "/strategyList",method = RequestMethod.POST)
|
||||
@Operation(summary = "策略列表", description = "获取所有策略列表")
|
||||
// public Result<List<WarnStrategy>> strategyList() {
|
||||
// List<WarnStrategy> list = warnStrategyService.list();
|
||||
// //存进Redis
|
||||
// for (WarnStrategy warnStrategy : list) {
|
||||
// allWarnStrategyCacheService.put(String.valueOf(warnStrategy.getWarnStrategyId()),warnStrategy);
|
||||
// }
|
||||
// return Result.success(list);
|
||||
// }
|
||||
public Result<List<WarnVehicleResp>> strategyList(@RequestBody @Validated WarnVehicleReq req) {
|
||||
List<WarnVehicleResp> list = warnStrategyService.selectList(req);
|
||||
for (WarnVehicleResp warnVehicleResp : list) {
|
||||
//存进Redis
|
||||
allWarnStrategyCacheService.put(String.valueOf(warnVehicleResp.getVehicleTypeId()),warnVehicleResp);
|
||||
}
|
||||
// for (WarnVehicleResp warnVehicleResp : list) {
|
||||
// //存进Redis
|
||||
// allWarnStrategyCacheService.put(String.valueOf(warnVehicleResp.getVehicleVin()), warnVehicleResp);
|
||||
// }
|
||||
return Result.success(list);
|
||||
}
|
||||
|
||||
|
@ -117,4 +116,18 @@ public class WarnStrategyController {
|
|||
public Result strategyDelete(@PathVariable("id") Long id){
|
||||
return Result.success(warnStrategyService.removeById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过vin缓存策略信息
|
||||
*/
|
||||
@RequestMapping(path = "/vinStrategyList/{vehicleId}",method = RequestMethod.POST)
|
||||
@Operation(summary = "通过vin缓存策略信息", description = "通过vin缓存策略信息")
|
||||
public Result<List<WarnStrategyAndVinResp>> vinStrategyList(@PathVariable("vehicleId") Long vehicleId) {
|
||||
List<WarnStrategyAndVinResp> warnStrategyAndVinResp = warnStrategyService.findById(vehicleId);
|
||||
for (WarnStrategyAndVinResp strategyAndVinResp : warnStrategyAndVinResp) {
|
||||
allWarnStrategyAndVinCacheService.put(strategyAndVinResp.getVehicleVin(), warnStrategyAndVinResp);
|
||||
}
|
||||
return Result.success(warnStrategyAndVinResp);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,8 +2,18 @@ package com.muyu.enterprise.mapper;
|
|||
|
||||
import com.github.yulichang.base.MPJBaseMapper;
|
||||
import com.muyu.domain.WarnStrategy;
|
||||
import com.muyu.domain.resp.WarnStrategyAndVinResp;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
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}")
|
||||
List<WarnStrategyAndVinResp> findById(Long vehicleId);
|
||||
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.muyu.enterprise.service;
|
|||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.muyu.domain.WarnStrategy;
|
||||
import com.muyu.domain.req.WarnVehicleReq;
|
||||
import com.muyu.domain.resp.WarnStrategyAndVinResp;
|
||||
import com.muyu.domain.resp.WarnVehicleResp;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -11,6 +12,13 @@ public interface WarnStrategyService extends IService<WarnStrategy> {
|
|||
|
||||
// List<WarnVehicleResp>ruleStrategyList(WarnVehicleReq warnVehicleReq);
|
||||
|
||||
/**
|
||||
* 预警列表
|
||||
*/
|
||||
List<WarnVehicleResp> selectList(WarnVehicleReq req);
|
||||
|
||||
|
||||
List<WarnStrategyAndVinResp> findById(Long vehicleId);
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -70,11 +70,6 @@ public class ElectServiceImpl
|
|||
return fences;
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public Fence boundFence(Long fenceId) {
|
||||
// Fence fence = electMapper.boundFence(fenceId);
|
||||
// return fence;
|
||||
// }
|
||||
|
||||
@Override
|
||||
public List<Fence> showFenceBound(Long fenceGroupId) {
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
package com.muyu.enterprise.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
import com.muyu.domain.MessageTemplate;
|
||||
import com.muyu.domain.resp.WarnStrategyAndVinResp;
|
||||
import com.muyu.enterprise.mapper.WarnStrategyMapper;
|
||||
import com.muyu.enterprise.service.WarnStrategyService;
|
||||
import com.muyu.common.core.utils.StringUtils;
|
||||
|
@ -23,19 +25,6 @@ public class WarnStrategyServiceImpl extends ServiceImpl<WarnStrategyMapper, War
|
|||
@Autowired
|
||||
private WarnStrategyMapper warnStrategyMapper;
|
||||
|
||||
// @Override
|
||||
// public List<WarnVehicleResp> ruleStrategyList(WarnVehicleReq warnVehicleReq) {
|
||||
// MPJLambdaWrapper<WarnStrategy> wrapper = new MPJLambdaWrapper<>();
|
||||
// wrapper.selectAll(WarnStrategy.class)
|
||||
// .selectAs(VehicleType::getVehicleTypeName,WarnVehicleResp::getVehicleTypeName)
|
||||
// .leftJoin(VehicleType.class, VehicleType::getVehicleTypeId,WarnStrategy::getVehicleTypeId)
|
||||
// .like(
|
||||
// StringUtils.isNotEmpty(warnVehicleReq.getStrategyName()),
|
||||
// WarnStrategy::getStrategyName,warnVehicleReq.getStrategyName()
|
||||
// );
|
||||
// List<WarnVehicleResp> list = warnStrategyMapper.selectJoinList(WarnVehicleResp.class, wrapper);
|
||||
// return list;
|
||||
// }
|
||||
|
||||
@Override
|
||||
public List<WarnVehicleResp> selectList(WarnVehicleReq req) {
|
||||
|
@ -52,4 +41,14 @@ public class WarnStrategyServiceImpl extends ServiceImpl<WarnStrategyMapper, War
|
|||
List<WarnVehicleResp> list = warnStrategyMapper.selectJoinList(WarnVehicleResp.class, wrapper);
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<WarnStrategyAndVinResp> findById(Long vehicleId) {
|
||||
List<WarnStrategyAndVinResp> byId = warnStrategyMapper.findById(vehicleId);
|
||||
if (byId == null) {
|
||||
return null;
|
||||
}
|
||||
return byId;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue