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 new file mode 100644 index 0000000..5ef51f7 --- /dev/null +++ b/cloud-modules/cloud-modules-enterprise/cloud-modules-enterprise-cache/src/main/java/com/muyu/enterprise/cache/AllWarnStrategyAndVinCacheService.java @@ -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> { + @Override + public void clear() { + + } + + @Override + public String keyPre() { + return "AllWarnStrategy:info:"; + } + + @Override + public String decode(String key) { + return key.replace("AllWarnStrategy:info:", ""); + } +} diff --git a/cloud-modules/cloud-modules-enterprise/cloud-modules-enterprise-cache/src/main/java/com/muyu/enterprise/cache/AllWarnStrategyCacheService.java b/cloud-modules/cloud-modules-enterprise/cloud-modules-enterprise-cache/src/main/java/com/muyu/enterprise/cache/AllWarnStrategyCacheService.java index 320d65b..58db6db 100644 --- a/cloud-modules/cloud-modules-enterprise/cloud-modules-enterprise-cache/src/main/java/com/muyu/enterprise/cache/AllWarnStrategyCacheService.java +++ b/cloud-modules/cloud-modules-enterprise/cloud-modules-enterprise-cache/src/main/java/com/muyu/enterprise/cache/AllWarnStrategyCacheService.java @@ -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; + /** * 预警策略缓存服务 */ diff --git a/cloud-modules/cloud-modules-enterprise/cloud-modules-enterprise-cache/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/cloud-modules/cloud-modules-enterprise/cloud-modules-enterprise-cache/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports index b2cefc8..65df736 100644 --- a/cloud-modules/cloud-modules-enterprise/cloud-modules-enterprise-cache/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports +++ b/cloud-modules/cloud-modules-enterprise/cloud-modules-enterprise-cache/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports @@ -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 diff --git a/cloud-modules/cloud-modules-enterprise/cloud-modules-enterprise-common/src/main/java/com/muyu/domain/MessageTemplate.java b/cloud-modules/cloud-modules-enterprise/cloud-modules-enterprise-common/src/main/java/com/muyu/domain/MessageTemplate.java index 24e12a4..1794765 100644 --- a/cloud-modules/cloud-modules-enterprise/cloud-modules-enterprise-common/src/main/java/com/muyu/domain/MessageTemplate.java +++ b/cloud-modules/cloud-modules-enterprise/cloud-modules-enterprise-common/src/main/java/com/muyu/domain/MessageTemplate.java @@ -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 diff --git a/cloud-modules/cloud-modules-enterprise/cloud-modules-enterprise-common/src/main/java/com/muyu/domain/Vehicle.java b/cloud-modules/cloud-modules-enterprise/cloud-modules-enterprise-common/src/main/java/com/muyu/domain/Vehicle.java index 8c827a7..d58d855 100644 --- a/cloud-modules/cloud-modules-enterprise/cloud-modules-enterprise-common/src/main/java/com/muyu/domain/Vehicle.java +++ b/cloud-modules/cloud-modules-enterprise/cloud-modules-enterprise-common/src/main/java/com/muyu/domain/Vehicle.java @@ -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(); } diff --git a/cloud-modules/cloud-modules-enterprise/cloud-modules-enterprise-common/src/main/java/com/muyu/domain/req/VehicleAddReq.java b/cloud-modules/cloud-modules-enterprise/cloud-modules-enterprise-common/src/main/java/com/muyu/domain/req/VehicleAddReq.java index cec6378..664a6fa 100644 --- a/cloud-modules/cloud-modules-enterprise/cloud-modules-enterprise-common/src/main/java/com/muyu/domain/req/VehicleAddReq.java +++ b/cloud-modules/cloud-modules-enterprise/cloud-modules-enterprise-common/src/main/java/com/muyu/domain/req/VehicleAddReq.java @@ -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; } diff --git a/cloud-modules/cloud-modules-enterprise/cloud-modules-enterprise-common/src/main/java/com/muyu/domain/req/VehicleUpdReq.java b/cloud-modules/cloud-modules-enterprise/cloud-modules-enterprise-common/src/main/java/com/muyu/domain/req/VehicleUpdReq.java index 41ace43..51fcd7e 100644 --- a/cloud-modules/cloud-modules-enterprise/cloud-modules-enterprise-common/src/main/java/com/muyu/domain/req/VehicleUpdReq.java +++ b/cloud-modules/cloud-modules-enterprise/cloud-modules-enterprise-common/src/main/java/com/muyu/domain/req/VehicleUpdReq.java @@ -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; + + } diff --git a/cloud-modules/cloud-modules-enterprise/cloud-modules-enterprise-common/src/main/java/com/muyu/domain/resp/WarnStrategyAndVinResp.java b/cloud-modules/cloud-modules-enterprise/cloud-modules-enterprise-common/src/main/java/com/muyu/domain/resp/WarnStrategyAndVinResp.java new file mode 100644 index 0000000..99d657e --- /dev/null +++ b/cloud-modules/cloud-modules-enterprise/cloud-modules-enterprise-common/src/main/java/com/muyu/domain/resp/WarnStrategyAndVinResp.java @@ -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; + +} diff --git a/cloud-modules/cloud-modules-enterprise/cloud-modules-enterprise-common/src/main/java/com/muyu/domain/resp/WarnVehicleResp.java b/cloud-modules/cloud-modules-enterprise/cloud-modules-enterprise-common/src/main/java/com/muyu/domain/resp/WarnVehicleResp.java index 7c24ec8..f367d72 100644 --- a/cloud-modules/cloud-modules-enterprise/cloud-modules-enterprise-common/src/main/java/com/muyu/domain/resp/WarnVehicleResp.java +++ b/cloud-modules/cloud-modules-enterprise/cloud-modules-enterprise-common/src/main/java/com/muyu/domain/resp/WarnVehicleResp.java @@ -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; + + } 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 8b84f48..b080f53 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 @@ -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> strategyList() { -// List list = warnStrategyService.list(); -// //存进Redis -// for (WarnStrategy warnStrategy : list) { -// allWarnStrategyCacheService.put(String.valueOf(warnStrategy.getWarnStrategyId()),warnStrategy); -// } -// return Result.success(list); -// } public Result> strategyList(@RequestBody @Validated WarnVehicleReq req) { List 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> vinStrategyList(@PathVariable("vehicleId") Long vehicleId) { + List warnStrategyAndVinResp = warnStrategyService.findById(vehicleId); + for (WarnStrategyAndVinResp strategyAndVinResp : warnStrategyAndVinResp) { + allWarnStrategyAndVinCacheService.put(strategyAndVinResp.getVehicleVin(), 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 5e0a799..22d0c2b 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 @@ -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 { + + + @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 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 dda68c5..a32ba1b 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 @@ -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 { // ListruleStrategyList(WarnVehicleReq warnVehicleReq); + /** + * 预警列表 + */ List selectList(WarnVehicleReq req); + + List findById(Long vehicleId); + + } diff --git a/cloud-modules/cloud-modules-enterprise/cloud-modules-enterprise-server/src/main/java/com/muyu/enterprise/service/impl/ElectServiceImpl.java b/cloud-modules/cloud-modules-enterprise/cloud-modules-enterprise-server/src/main/java/com/muyu/enterprise/service/impl/ElectServiceImpl.java index 05bafda..72512d2 100644 --- a/cloud-modules/cloud-modules-enterprise/cloud-modules-enterprise-server/src/main/java/com/muyu/enterprise/service/impl/ElectServiceImpl.java +++ b/cloud-modules/cloud-modules-enterprise/cloud-modules-enterprise-server/src/main/java/com/muyu/enterprise/service/impl/ElectServiceImpl.java @@ -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 showFenceBound(Long fenceGroupId) { 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 75db16c..449ba18 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 @@ -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 ruleStrategyList(WarnVehicleReq warnVehicleReq) { -// MPJLambdaWrapper 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 list = warnStrategyMapper.selectJoinList(WarnVehicleResp.class, wrapper); -// return list; -// } @Override public List selectList(WarnVehicleReq req) { @@ -52,4 +41,14 @@ public class WarnStrategyServiceImpl extends ServiceImpl list = warnStrategyMapper.selectJoinList(WarnVehicleResp.class, wrapper); return list; } + + @Override + public List findById(Long vehicleId) { + List byId = warnStrategyMapper.findById(vehicleId); + if (byId == null) { + return null; + } + return byId; + } + }