Merge remote-tracking branch 'origin/dev.operation' into dev
# Conflicts: # cloud-auth/src/main/resources/bootstrap.yml # cloud-gateway/src/main/resources/bootstrap.yml # cloud-modules/cloud-event/src/main/resources/bootstrap.yml # cloud-modules/cloud-modules-file/src/main/resources/bootstrap.yml # cloud-modules/cloud-modules-gen/src/main/resources/bootstrap.yml # cloud-modules/cloud-modules-system/src/main/resources/bootstrap.yml # cloud-modules/saas/saas-server/src/main/java/com/muyu/server/service/impl/SysCarServiceImpl.java # cloud-modules/saas/saas-server/src/main/java/com/muyu/server/service/impl/TemplateServiceImpl.java # cloud-modules/saas/saas-server/src/main/resources/bootstrap.ymldev.operation
commit
b5a2687491
|
@ -8,6 +8,9 @@ package com.muyu.cache;/**
|
||||||
import com.muyu.common.redis.service.RedisService;
|
import com.muyu.common.redis.service.RedisService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
import static cn.hutool.core.lang.ansi.AnsiEncoder.encode;
|
import static cn.hutool.core.lang.ansi.AnsiEncoder.encode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package com.muyu.cache;
|
package com.muyu.cache;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author yuping
|
* @author yuping
|
||||||
* @package com.muyu.cache
|
* @package com.muyu.cache
|
||||||
|
|
|
@ -33,4 +33,5 @@
|
||||||
cloud-common通用模块
|
cloud-common通用模块
|
||||||
</description>
|
</description>
|
||||||
|
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
package com.muyu.cache;
|
||||||
|
|
||||||
|
import com.muyu.common.domain.CarType;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author YuPing
|
||||||
|
* @Description 车辆类型缓存
|
||||||
|
* @Version 1.0
|
||||||
|
* @Data 2024-09-30 16:31:44
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
public class CarTypeCacheService extends CacheAbsBasic<String, CarType> {
|
||||||
|
/**
|
||||||
|
* 缓存key前缀
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String keyPre() {
|
||||||
|
return "carType:";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 解码key
|
||||||
|
* @param key 编码key
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String decode(String key) {
|
||||||
|
return key.replace(keyPre(), "");
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,33 @@
|
||||||
|
package com.muyu.cache;
|
||||||
|
|
||||||
|
import com.muyu.common.domain.DataType;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author YuPing
|
||||||
|
* @Description 数据类型缓存
|
||||||
|
* @Version 1.0
|
||||||
|
* @Data 2024-09-30 10:57:24
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
public class DataTypeCacheService extends CacheAbsBasic<String, DataType> {
|
||||||
|
/**
|
||||||
|
* key前缀
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String keyPre() {
|
||||||
|
return "DataType";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 解码
|
||||||
|
* @param key 编码key
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String decode(String key) {
|
||||||
|
return key.replace(keyPre(), "");
|
||||||
|
}
|
||||||
|
}
|
|
@ -3,6 +3,8 @@ package com.muyu.cache;
|
||||||
import com.muyu.common.domain.database.ElectronicFence;
|
import com.muyu.common.domain.database.ElectronicFence;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Author YuPing
|
* @Author YuPing
|
||||||
* @Description 电子围栏缓存
|
* @Description 电子围栏缓存
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
package com.muyu.cache;
|
||||||
|
|
||||||
|
import com.muyu.common.domain.MessageTemplate;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author YuPing
|
||||||
|
* @Description 报文缓存
|
||||||
|
* @Version 1.0
|
||||||
|
* @Data 2024-09-30 11:01:13
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
public class MessageTemplateCacheService extends CacheAbsBasic<String, MessageTemplate>{
|
||||||
|
/**
|
||||||
|
* key前缀
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String keyPre() {
|
||||||
|
return "message_template";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 解码
|
||||||
|
* @param key 编码key
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String decode(String key) {
|
||||||
|
return key.replace(keyPre(), "");
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,32 @@
|
||||||
|
package com.muyu.cache;
|
||||||
|
|
||||||
|
import com.muyu.common.domain.MessageTemplateType;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author YuPing
|
||||||
|
* @Description 报文模版类型缓存
|
||||||
|
* @Version 1.0
|
||||||
|
* @Data 2024-09-30 11:04:43
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
public class MessageTemplateTypeCacheService extends CacheAbsBasic<String, MessageTemplateType>{
|
||||||
|
/**
|
||||||
|
* 缓存key前缀
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String keyPre() {
|
||||||
|
return "messageTemplateType";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 解码
|
||||||
|
* @param key 编码key
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String decode(String key) {
|
||||||
|
return key.replace(keyPre(), "");
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,32 @@
|
||||||
|
package com.muyu.cache;
|
||||||
|
|
||||||
|
import com.muyu.common.domain.SysCar;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author YuPing
|
||||||
|
* @Description 车辆缓存
|
||||||
|
* @Version 1.0
|
||||||
|
* @Data 2024-09-30 16:35:14
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
public class SysCarCacheService extends CacheAbsBasic<String, SysCar>{
|
||||||
|
/**
|
||||||
|
* key前缀
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String keyPre() {
|
||||||
|
return "car:";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 解码
|
||||||
|
* @param key 编码key
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String decode(String key) {
|
||||||
|
return key.replace(keyPre(), "");
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,32 @@
|
||||||
|
package com.muyu.cache;
|
||||||
|
|
||||||
|
import com.muyu.common.domain.Template;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author YuPing
|
||||||
|
* @Description 报文模版缓存
|
||||||
|
* @Version 1.0
|
||||||
|
* @Data 2024-09-30 18:21:46
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
public class TemplateCacheService extends CacheAbsBasic<String, Template>{
|
||||||
|
/**
|
||||||
|
* 缓存key前缀
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String keyPre() {
|
||||||
|
return "template";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 解码
|
||||||
|
* @param key 编码key
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String decode(String key) {
|
||||||
|
return key.replace(keyPre(), "");
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,32 @@
|
||||||
|
package com.muyu.cache;
|
||||||
|
|
||||||
|
import com.muyu.common.domain.WarnRule;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author YuPing
|
||||||
|
* @Description 预警规则缓存
|
||||||
|
* @Version 1.0
|
||||||
|
* @Data 2024-09-30 16:37:09
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
public class WarnRuleCacheService extends CacheAbsBasic<String, WarnRule>{
|
||||||
|
/**
|
||||||
|
* 缓存key前缀
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String keyPre() {
|
||||||
|
return "warnRule";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 解码
|
||||||
|
* @param key 编码key
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String decode(String key) {
|
||||||
|
return key.replace(keyPre(), "");
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,32 @@
|
||||||
|
package com.muyu.cache;
|
||||||
|
|
||||||
|
import com.muyu.common.domain.WarnStrategy;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author YuPing
|
||||||
|
* @Description 预警策略缓存
|
||||||
|
* @Version 1.0
|
||||||
|
* @Data 2024-09-30 16:38:35
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
public class WarnStrategyCacheService extends CacheAbsBasic<String, WarnStrategy> {
|
||||||
|
/**
|
||||||
|
* 缓存key前缀
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String keyPre() {
|
||||||
|
return "warnStrategy";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 解码key
|
||||||
|
* @param key 编码key
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String decode(String key) {
|
||||||
|
return key.replace(keyPre(), "");
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,5 +1,13 @@
|
||||||
|
com.muyu.cache.CarTypeCacheService
|
||||||
|
com.muyu.cache.DataTypeCacheService
|
||||||
com.muyu.cache.ElectronicFenceCacheService
|
com.muyu.cache.ElectronicFenceCacheService
|
||||||
com.muyu.cache.ElectronicFenceGroupCacheService
|
com.muyu.cache.ElectronicFenceGroupCacheService
|
||||||
com.muyu.cache.EnterpriseCacheService
|
com.muyu.cache.EnterpriseCacheService
|
||||||
|
com.muyu.cache.MessageTemplateCacheService
|
||||||
|
com.muyu.cache.MessageTemplateTypeCacheService
|
||||||
|
com.muyu.cache.SysCarCacheService
|
||||||
com.muyu.cache.SysCarFaultCacheService
|
com.muyu.cache.SysCarFaultCacheService
|
||||||
com.muyu.cache.SysCarFaultMessageCacheService
|
com.muyu.cache.SysCarFaultMessageCacheService
|
||||||
|
com.muyu.cache.TemplateCacheService
|
||||||
|
com.muyu.cache.WarnRuleCacheService
|
||||||
|
com.muyu.cache.WarnStrategyCacheService
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package com.muyu.server.controller;
|
package com.muyu.server.controller;
|
||||||
|
|
||||||
|
import com.muyu.cache.DataTypeCacheService;
|
||||||
import com.muyu.common.core.domain.Result;
|
import com.muyu.common.core.domain.Result;
|
||||||
import com.muyu.common.domain.DataType;
|
import com.muyu.common.domain.DataType;
|
||||||
import com.muyu.server.service.DataTypeService;
|
import com.muyu.server.service.DataTypeService;
|
||||||
|
@ -34,6 +35,9 @@ public class DataTypeController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private DataTypeService dataTypeService;
|
private DataTypeService dataTypeService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private DataTypeCacheService dataTypeCacheService;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 数据类型列表
|
* 数据类型列表
|
||||||
|
@ -42,7 +46,13 @@ public class DataTypeController {
|
||||||
@PostMapping("/dataTypeList")
|
@PostMapping("/dataTypeList")
|
||||||
@Operation(summary = "数据类型列表",description = "数据类型列表")
|
@Operation(summary = "数据类型列表",description = "数据类型列表")
|
||||||
public Result<List<DataType>> dataTypeList() {
|
public Result<List<DataType>> dataTypeList() {
|
||||||
return Result.success(dataTypeService.list());
|
|
||||||
|
List<DataType> list = dataTypeService.list();
|
||||||
|
|
||||||
|
// 缓存数据
|
||||||
|
list.forEach(item->dataTypeCacheService.put(item.getDataTypeId().toString(),item));
|
||||||
|
|
||||||
|
return Result.success(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,7 +60,7 @@ public class SysCarController {
|
||||||
return Result.success(sysCarService.addSysCar(sysCar));
|
return Result.success(sysCarService.addSysCar(sysCar));
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/updateSysCar")
|
@PutMapping
|
||||||
@Operation(summary = "车辆修改",description = "车辆修改")
|
@Operation(summary = "车辆修改",description = "车辆修改")
|
||||||
public Result updateSysCar(@RequestBody SysCar sysCar){
|
public Result updateSysCar(@RequestBody SysCar sysCar){
|
||||||
return Result.success(sysCarService.updateSysCar(sysCar));
|
return Result.success(sysCarService.updateSysCar(sysCar));
|
||||||
|
@ -79,7 +79,7 @@ public class SysCarController {
|
||||||
* @param carVin
|
* @param carVin
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@PostMapping("/findFenceByCarVin/{carVin}")
|
@PostMapping("/findFenceCarVin/{carVin}")
|
||||||
@Operation(summary = "根据车辆的VIN码查询该车的故障记录",description = "根据车辆的VIN码查询该车的故障记录")
|
@Operation(summary = "根据车辆的VIN码查询该车的故障记录",description = "根据车辆的VIN码查询该车的故障记录")
|
||||||
public Result<List<SysCarFaultLogVo>> findFenceByCarVin(@PathVariable("carVin") String carVin){
|
public Result<List<SysCarFaultLogVo>> findFenceByCarVin(@PathVariable("carVin") String carVin){
|
||||||
return Result.success(sysCarService.findFenceByCarVin(carVin));
|
return Result.success(sysCarService.findFenceByCarVin(carVin));
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package com.muyu.server.controller;
|
package com.muyu.server.controller;
|
||||||
|
|
||||||
|
import com.muyu.cache.TemplateCacheService;
|
||||||
import com.muyu.common.core.domain.Result;
|
import com.muyu.common.core.domain.Result;
|
||||||
import com.muyu.common.domain.Template;
|
import com.muyu.common.domain.Template;
|
||||||
import com.muyu.server.service.TemplateService;
|
import com.muyu.server.service.TemplateService;
|
||||||
|
@ -33,6 +34,8 @@ public class TemplateController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private TemplateService templateService;
|
private TemplateService templateService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private TemplateCacheService templateCacheService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 报文模版列表
|
* 报文模版列表
|
||||||
|
@ -41,7 +44,14 @@ public class TemplateController {
|
||||||
@PostMapping("/templateList")
|
@PostMapping("/templateList")
|
||||||
@Operation(summary = "报文模版列表",description = "报文模版列表")
|
@Operation(summary = "报文模版列表",description = "报文模版列表")
|
||||||
public Result<List<Template>> templateList() {
|
public Result<List<Template>> templateList() {
|
||||||
return Result.success(templateService.list());
|
|
||||||
|
List<Template> list = templateService.list();
|
||||||
|
|
||||||
|
list.forEach(template -> {
|
||||||
|
templateCacheService.put(template.getTemplateId().toString(),template);
|
||||||
|
});
|
||||||
|
|
||||||
|
return Result.success(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@ package com.muyu.server.mapper;
|
||||||
|
|
||||||
import com.muyu.common.domain.Enterprise;
|
import com.muyu.common.domain.Enterprise;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
@ -33,5 +34,5 @@ public interface EnterpriseDao {
|
||||||
|
|
||||||
|
|
||||||
//删除企业信息
|
//删除企业信息
|
||||||
public int deleteByIds(Integer[] ids);
|
public int deleteByIds(@Param("ids") Integer[] ids);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ package com.muyu.server.service.impl;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.muyu.cache.CarTypeCacheService;
|
||||||
import com.muyu.common.domain.CarType;
|
import com.muyu.common.domain.CarType;
|
||||||
import com.muyu.common.domain.resp.CarTypeResp;
|
import com.muyu.common.domain.resp.CarTypeResp;
|
||||||
import com.muyu.server.mapper.CarTypeMapper;
|
import com.muyu.server.mapper.CarTypeMapper;
|
||||||
|
@ -20,17 +21,33 @@ import java.util.List;
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class CarTypeServiceImpl extends ServiceImpl<CarTypeMapper, CarType> implements CarTypeService{
|
public class CarTypeServiceImpl extends ServiceImpl<CarTypeMapper, CarType> implements CarTypeService{
|
||||||
@Autowired
|
|
||||||
private CarTypeMapper carTypeMapper;
|
@Autowired
|
||||||
|
private CarTypeMapper carTypeMapper;
|
||||||
|
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CarTypeCacheService carTypeCacheService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<CarType> selectCarTypeList() {
|
public List<CarType> selectCarTypeList() {
|
||||||
QueryWrapper<CarType> carTypeQueryWrapper = new QueryWrapper<>();
|
QueryWrapper<CarType> carTypeQueryWrapper = new QueryWrapper<>();
|
||||||
return carTypeMapper.selectList(carTypeQueryWrapper);
|
List<CarType> list = carTypeMapper.selectList(carTypeQueryWrapper);
|
||||||
|
|
||||||
|
for (CarType carType : list) {
|
||||||
|
carTypeCacheService.put(carTypeCacheService.keyPre() + carType.getId(), carType);
|
||||||
|
}
|
||||||
|
|
||||||
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CarTypeResp selectCarTypeRespList(Long id) {
|
public CarTypeResp selectCarTypeRespList(Long id) {
|
||||||
return carTypeMapper.selectCarTypeRespList(id);
|
CarTypeResp carTypeResp = carTypeMapper.selectCarTypeRespList(id);
|
||||||
|
|
||||||
|
carTypeCacheService.put(carTypeCacheService.keyPre() + id, carTypeResp);
|
||||||
|
|
||||||
|
return carTypeResp;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -38,11 +55,21 @@ private CarTypeMapper carTypeMapper;
|
||||||
QueryWrapper<CarType> carTypeQueryWrapper = new QueryWrapper<>();
|
QueryWrapper<CarType> carTypeQueryWrapper = new QueryWrapper<>();
|
||||||
carTypeQueryWrapper.eq("car_type_id", carTypeId);
|
carTypeQueryWrapper.eq("car_type_id", carTypeId);
|
||||||
CarType carType = carTypeMapper.selectOne(carTypeQueryWrapper);
|
CarType carType = carTypeMapper.selectOne(carTypeQueryWrapper);
|
||||||
|
|
||||||
|
carTypeCacheService.put(carTypeCacheService.keyPre() + carTypeId, carType);
|
||||||
|
|
||||||
return carType;
|
return carType;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<CarTypeResp> findAllCars() {
|
public List<CarTypeResp> findAllCars() {
|
||||||
return carTypeMapper.findAllCars();
|
|
||||||
|
List<CarTypeResp> allCars = carTypeMapper.findAllCars();
|
||||||
|
|
||||||
|
for (CarTypeResp carTypeResp : allCars) {
|
||||||
|
carTypeCacheService.put(carTypeCacheService.keyPre() + carTypeResp.getId(), carTypeResp);
|
||||||
|
}
|
||||||
|
|
||||||
|
return allCars;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@ import lombok.extern.log4j.Log4j2;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -54,9 +55,12 @@ public class ElectronicFenceServiceImpl extends ServiceImpl<ElectronicFenceMappe
|
||||||
List<ElectronicFence> list = this.list(queryWrapper);
|
List<ElectronicFence> list = this.list(queryWrapper);
|
||||||
|
|
||||||
list.forEach(electronicFence -> {
|
list.forEach(electronicFence -> {
|
||||||
electronicFenceCacheService.put(electronicFence.getId().toString(),electronicFence);
|
electronicFenceCacheService.put(electronicFence.getId().toString(), electronicFence);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
ElectronicFence electronicFence = electronicFenceCacheService.get("electronicFence");
|
||||||
|
log.info("electronicFenceCacheService.get(electronicFence) = {}",electronicFence);
|
||||||
|
|
||||||
return list.stream().map(ElectronicFence::bullerResp).toList();
|
return list.stream().map(ElectronicFence::bullerResp).toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package com.muyu.server.service.impl;
|
package com.muyu.server.service.impl;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.muyu.cache.MessageTemplateTypeCacheService;
|
||||||
import com.muyu.common.domain.MessageTemplateType;
|
import com.muyu.common.domain.MessageTemplateType;
|
||||||
import com.muyu.server.mapper.MessageTemplateTypeMapper;
|
import com.muyu.server.mapper.MessageTemplateTypeMapper;
|
||||||
import com.muyu.server.service.MessageTemplateTypeService;
|
import com.muyu.server.service.MessageTemplateTypeService;
|
||||||
|
@ -20,9 +21,15 @@ public class MessageTemplateTypeServiceImpl extends ServiceImpl<MessageTemplate
|
||||||
@Autowired
|
@Autowired
|
||||||
private MessageTemplateTypeMapper messageTemplateTypeMapper;
|
private MessageTemplateTypeMapper messageTemplateTypeMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private MessageTemplateTypeCacheService messageTemplateTypeCacheService;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Integer addMessageType(MessageTemplateType messageTemplateType) {
|
public Integer addMessageType(MessageTemplateType messageTemplateType) {
|
||||||
|
|
||||||
|
messageTemplateTypeCacheService.put(messageTemplateType.getMessageTemplateTypeId(),messageTemplateType);
|
||||||
|
|
||||||
return messageTemplateTypeMapper.insert(messageTemplateType);
|
return messageTemplateTypeMapper.insert(messageTemplateType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,6 +40,11 @@ public class MessageTemplateTypeServiceImpl extends ServiceImpl<MessageTemplate
|
||||||
messageTemplateTypeQueryWrapper.eq("template_id",templatedId);
|
messageTemplateTypeQueryWrapper.eq("template_id",templatedId);
|
||||||
messageTemplateTypeQueryWrapper.eq("message_class",code);
|
messageTemplateTypeQueryWrapper.eq("message_class",code);
|
||||||
List<MessageTemplateType> messageTemplateTypes = messageTemplateTypeMapper.selectList(messageTemplateTypeQueryWrapper);
|
List<MessageTemplateType> messageTemplateTypes = messageTemplateTypeMapper.selectList(messageTemplateTypeQueryWrapper);
|
||||||
|
|
||||||
|
messageTemplateTypes.forEach(messageTemplateType -> {
|
||||||
|
messageTemplateTypeCacheService.put(messageTemplateType.getMessageTemplateTypeId(),messageTemplateType);
|
||||||
|
});
|
||||||
|
|
||||||
return messageTemplateTypes;
|
return messageTemplateTypes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,6 +54,11 @@ public class MessageTemplateTypeServiceImpl extends ServiceImpl<MessageTemplate
|
||||||
messageTemplateTypeQueryWrapper.eq("template_id",templatedId);
|
messageTemplateTypeQueryWrapper.eq("template_id",templatedId);
|
||||||
messageTemplateTypeQueryWrapper.eq("message_class",code);
|
messageTemplateTypeQueryWrapper.eq("message_class",code);
|
||||||
List<MessageTemplateType> messageTemplateTypes = messageTemplateTypeMapper.selectList(messageTemplateTypeQueryWrapper);
|
List<MessageTemplateType> messageTemplateTypes = messageTemplateTypeMapper.selectList(messageTemplateTypeQueryWrapper);
|
||||||
|
|
||||||
|
messageTemplateTypes.forEach(messageTemplateType -> {
|
||||||
|
messageTemplateTypeCacheService.put(messageTemplateType.getMessageTemplateTypeId(),messageTemplateType);
|
||||||
|
});
|
||||||
|
|
||||||
return messageTemplateTypes;
|
return messageTemplateTypes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,6 +68,11 @@ public class MessageTemplateTypeServiceImpl extends ServiceImpl<MessageTemplate
|
||||||
messageTemplateTypeQueryWrapper.eq("template_id",templatedId);
|
messageTemplateTypeQueryWrapper.eq("template_id",templatedId);
|
||||||
messageTemplateTypeQueryWrapper.eq("message_class",code);
|
messageTemplateTypeQueryWrapper.eq("message_class",code);
|
||||||
List<MessageTemplateType> messageTemplateTypes = messageTemplateTypeMapper.selectList(messageTemplateTypeQueryWrapper);
|
List<MessageTemplateType> messageTemplateTypes = messageTemplateTypeMapper.selectList(messageTemplateTypeQueryWrapper);
|
||||||
|
|
||||||
|
messageTemplateTypes.forEach(messageTemplateType -> {
|
||||||
|
messageTemplateTypeCacheService.put(messageTemplateType.getMessageTemplateTypeId(),messageTemplateType);
|
||||||
|
});
|
||||||
|
|
||||||
return messageTemplateTypes;
|
return messageTemplateTypes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,6 +82,11 @@ public class MessageTemplateTypeServiceImpl extends ServiceImpl<MessageTemplate
|
||||||
QueryWrapper<MessageTemplateType> messageTemplateTypeQueryWrapper = new QueryWrapper<>();
|
QueryWrapper<MessageTemplateType> messageTemplateTypeQueryWrapper = new QueryWrapper<>();
|
||||||
messageTemplateTypeQueryWrapper.eq("template_id",templatedId);
|
messageTemplateTypeQueryWrapper.eq("template_id",templatedId);
|
||||||
List<MessageTemplateType> messageTemplateTypes = messageTemplateTypeMapper.selectList(messageTemplateTypeQueryWrapper);
|
List<MessageTemplateType> messageTemplateTypes = messageTemplateTypeMapper.selectList(messageTemplateTypeQueryWrapper);
|
||||||
|
|
||||||
|
messageTemplateTypes.forEach(messageTemplateType -> {
|
||||||
|
messageTemplateTypeCacheService.put(messageTemplateType.getMessageTemplateTypeId(),messageTemplateType);
|
||||||
|
});
|
||||||
|
|
||||||
return messageTemplateTypes;
|
return messageTemplateTypes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,6 +95,11 @@ public class MessageTemplateTypeServiceImpl extends ServiceImpl<MessageTemplate
|
||||||
QueryWrapper<MessageTemplateType> messageTemplateTypeQueryWrapper = new QueryWrapper<>();
|
QueryWrapper<MessageTemplateType> messageTemplateTypeQueryWrapper = new QueryWrapper<>();
|
||||||
messageTemplateTypeQueryWrapper.eq("template_id",templateId);
|
messageTemplateTypeQueryWrapper.eq("template_id",templateId);
|
||||||
List<MessageTemplateType> messageTemplateTypes = messageTemplateTypeMapper.selectList(messageTemplateTypeQueryWrapper);
|
List<MessageTemplateType> messageTemplateTypes = messageTemplateTypeMapper.selectList(messageTemplateTypeQueryWrapper);
|
||||||
|
|
||||||
|
messageTemplateTypes.forEach(messageTemplateType -> {
|
||||||
|
messageTemplateTypeCacheService.put(messageTemplateType.getMessageTemplateTypeId(),messageTemplateType);
|
||||||
|
});
|
||||||
|
|
||||||
return messageTemplateTypes;
|
return messageTemplateTypes;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
package com.muyu.server.service.impl;
|
package com.muyu.server.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.muyu.cache.SysCarCacheService;
|
||||||
import com.muyu.common.domain.SysCar;
|
import com.muyu.common.domain.SysCar;
|
||||||
import com.muyu.common.domain.req.SysCarReq;
|
import com.muyu.common.domain.req.SysCarReq;
|
||||||
import com.muyu.common.domain.resp.SysCarFaultLogVo;
|
import com.muyu.common.domain.resp.SysCarFaultLogVo;
|
||||||
|
@ -12,40 +14,70 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
/**
|
|
||||||
* 车辆管理 服务层处理
|
@DS("lizzDB")
|
||||||
* @author sx
|
|
||||||
* @package com.muyu.server.service.impl
|
|
||||||
* @name SysCarServiceImpl
|
|
||||||
* @date 2024/9/22 14:36
|
|
||||||
*/
|
|
||||||
@Service
|
@Service
|
||||||
public class SysCarServiceImpl extends ServiceImpl<SysCarMapper, SysCar> implements SysCarService {
|
public class SysCarServiceImpl extends ServiceImpl<SysCarMapper, SysCar> implements SysCarService {
|
||||||
@Autowired
|
@Autowired
|
||||||
private SysCarMapper sysCarMapper;
|
private SysCarMapper sysCarMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SysCarCacheService sysCarCacheService;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<SysCarVo> selectSysCarVoList(SysCarReq sysCarReq) {
|
public List<SysCarVo> selectSysCarVoList(SysCarReq sysCarReq) {
|
||||||
return sysCarMapper.selectSysCarVoList(sysCarReq);
|
|
||||||
|
List<SysCarVo> sysCarVos = sysCarMapper.selectSysCarVoList(sysCarReq);
|
||||||
|
|
||||||
|
sysCarVos.forEach(sysCarVo -> {
|
||||||
|
sysCarCacheService.put(String.valueOf(sysCarVo.getId()), sysCarVo);
|
||||||
|
});
|
||||||
|
|
||||||
|
return sysCarVos;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SysCarVo selectSysCarVoById(Long id) {
|
public SysCarVo selectSysCarVoById(Long id) {
|
||||||
return sysCarMapper.selectSysCarVoById(id);
|
SysCarVo sysCarVo = sysCarMapper.selectSysCarVoById(id);
|
||||||
|
|
||||||
|
if (sysCarVo!=null){
|
||||||
|
sysCarCacheService.put(String.valueOf(sysCarVo.getId()), sysCarVo);
|
||||||
|
}
|
||||||
|
|
||||||
|
return sysCarVo;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int addSysCar(SysCar sysCar) {
|
public int addSysCar(SysCar sysCar) {
|
||||||
return sysCarMapper.insert(sysCar);
|
|
||||||
|
int rows = sysCarMapper.insert(sysCar);
|
||||||
|
|
||||||
|
if (rows>0){
|
||||||
|
sysCarCacheService.put(String.valueOf(sysCar.getId()), sysCar);
|
||||||
|
}
|
||||||
|
|
||||||
|
return rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int deleteSysCarById(Long id) {
|
public int deleteSysCarById(Long id) {
|
||||||
return sysCarMapper.deleteById(id);
|
|
||||||
|
int rows = sysCarMapper.deleteById(id);
|
||||||
|
|
||||||
|
sysCarCacheService.remove(String.valueOf(id));
|
||||||
|
|
||||||
|
return rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int updateSysCar(SysCar sysCar) {
|
public int updateSysCar(SysCar sysCar) {
|
||||||
return sysCarMapper.updateById(sysCar);
|
|
||||||
|
int rows = sysCarMapper.updateById(sysCar);
|
||||||
|
|
||||||
|
sysCarCacheService.put(String.valueOf(sysCar.getId()), sysCar);
|
||||||
|
|
||||||
|
return rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -57,7 +89,13 @@ public class SysCarServiceImpl extends ServiceImpl<SysCarMapper, SysCar> impleme
|
||||||
public SysCar findCarByVin(String carVin) {
|
public SysCar findCarByVin(String carVin) {
|
||||||
QueryWrapper<SysCar> sysCarQueryWrapper = new QueryWrapper<>();
|
QueryWrapper<SysCar> sysCarQueryWrapper = new QueryWrapper<>();
|
||||||
sysCarQueryWrapper.eq("car_vin", carVin);
|
sysCarQueryWrapper.eq("car_vin", carVin);
|
||||||
SysCar sysCar = sysCarMapper.selectOne(sysCarQueryWrapper);
|
List<SysCar> sysCars = sysCarMapper.selectList(sysCarQueryWrapper);
|
||||||
return sysCar;
|
|
||||||
|
sysCars.forEach(sysCar -> {
|
||||||
|
sysCarCacheService.put(String.valueOf(sysCar.getId()), sysCar);
|
||||||
|
});
|
||||||
|
|
||||||
|
return sysCars.isEmpty() ? null : sysCars.get(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package com.muyu.server.service.impl;
|
package com.muyu.server.service.impl;
|
||||||
|
|
||||||
|
import com.muyu.cache.MessageTemplateCacheService;
|
||||||
|
import com.muyu.cache.MessageTemplateTypeCacheService;
|
||||||
import com.muyu.common.domain.MessageTemplateType;
|
import com.muyu.common.domain.MessageTemplateType;
|
||||||
import com.muyu.server.mapper.TemplateNeedMapper;
|
import com.muyu.server.mapper.TemplateNeedMapper;
|
||||||
import com.muyu.server.service.TemplateNeedService;
|
import com.muyu.server.service.TemplateNeedService;
|
||||||
|
@ -21,9 +23,19 @@ public class TemplateNeedServiceImpl implements TemplateNeedService {
|
||||||
@Autowired
|
@Autowired
|
||||||
private TemplateNeedMapper templateNeedMapper;
|
private TemplateNeedMapper templateNeedMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private MessageTemplateTypeCacheService messageTemplateTypeCacheService;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<MessageTemplateType> selectByTemplateId(Long templateId) {
|
public List<MessageTemplateType> selectByTemplateId(Long templateId) {
|
||||||
return templateNeedMapper.selectByTemplateId(templateId);
|
|
||||||
|
List<MessageTemplateType> messageTemplateTypes = templateNeedMapper.selectByTemplateId(templateId);
|
||||||
|
|
||||||
|
messageTemplateTypes.forEach(messageTemplateType -> {
|
||||||
|
messageTemplateTypeCacheService.put(messageTemplateType.getMessageTemplateTypeId(),messageTemplateType);
|
||||||
|
});
|
||||||
|
|
||||||
|
return messageTemplateTypes;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,8 @@ package com.muyu.server.service.impl;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.alibaba.fastjson2.JSON;
|
import com.alibaba.fastjson2.JSON;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.muyu.cache.SysCarCacheService;
|
||||||
|
import com.muyu.cache.TemplateCacheService;
|
||||||
import com.muyu.common.domain.MessageTemplateType;
|
import com.muyu.common.domain.MessageTemplateType;
|
||||||
import com.muyu.common.domain.SysCar;
|
import com.muyu.common.domain.SysCar;
|
||||||
import com.muyu.common.domain.Template;
|
import com.muyu.common.domain.Template;
|
||||||
|
@ -35,7 +37,89 @@ public class TemplateServiceImpl extends ServiceImpl<TemplateMapper, Template> i
|
||||||
@Autowired
|
@Autowired
|
||||||
private static TemplateMapper templateMapper;
|
private static TemplateMapper templateMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SysCarService sysCarService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private MessageTemplateTypeService messageTemplateTypeService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private RedisTemplate redisTemplate;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SysCarCacheService sysCarCacheService;
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void messageParsing(String templateMessage) throws SQLException, IoTDBConnectionException, ClassNotFoundException, StatementExecutionException, ExecutionException, InterruptedException {
|
||||||
|
|
||||||
|
//给一个JSON对象
|
||||||
|
JSONObject jsonObject = new JSONObject();
|
||||||
|
//先截取出VIN码 然后根据VIN码查询这个车属于什么类型
|
||||||
|
if (templateMessage.length() < 18) {
|
||||||
|
throw new RuntimeException("The vehicle message is incorrect");
|
||||||
|
}
|
||||||
|
//将报文进行切割
|
||||||
|
String[] hexArray = templateMessage.split(" ");
|
||||||
|
StringBuilder result = new StringBuilder();
|
||||||
|
for (String hex : hexArray) {
|
||||||
|
int decimal = Integer.parseInt(hex, 16);
|
||||||
|
result.append((char) decimal);
|
||||||
|
}
|
||||||
|
//取出VIN码
|
||||||
|
String carVin = result.substring(0, 18 - 1);
|
||||||
|
log.info("carVin码为:" + carVin);
|
||||||
|
//根据VIN码获取车辆信息
|
||||||
|
SysCar carByVin = sysCarService.findCarByVin(carVin);
|
||||||
|
log.info("车辆信息为:" + carByVin);
|
||||||
|
|
||||||
|
|
||||||
|
sysCarCacheService.put(carVin,carByVin);
|
||||||
|
|
||||||
|
|
||||||
|
//对应车辆所对应的报文模版
|
||||||
|
Integer templateId = carByVin.getTemplateId();
|
||||||
|
List<MessageTemplateType> templateTypeList;
|
||||||
|
//key
|
||||||
|
String redisKey = "messageTemplateType" + templateId;
|
||||||
|
log.info("key为:" + redisKey);
|
||||||
|
//key存在
|
||||||
|
if (redisTemplate.hasKey(redisKey)) {
|
||||||
|
|
||||||
|
List list = redisTemplate.opsForList().range(redisKey, 0, -1);
|
||||||
|
templateTypeList = list.stream().map(o -> JSON.parseObject(o.toString(), MessageTemplateType.class))
|
||||||
|
.toList();
|
||||||
|
} else {
|
||||||
|
List<MessageTemplateType> templateTypeList1 = messageTemplateTypeService.findTemplateById(templateId);
|
||||||
|
log.info("redis存入成功");
|
||||||
|
templateTypeList = templateTypeList1;
|
||||||
|
templateTypeList1.forEach(
|
||||||
|
templateType ->
|
||||||
|
redisTemplate.opsForList().rightPush(
|
||||||
|
redisKey, com.alibaba.fastjson.JSON.toJSONString(templateType)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
log.info("哈哈哈哈哈哈哈"+templateTypeList);
|
||||||
|
//将模版里面有的配置进行循环
|
||||||
|
for (MessageTemplateType messageTemplateType : templateTypeList) {
|
||||||
|
//开始位置
|
||||||
|
Integer startIndex = messageTemplateType.getStartIndex() - 1;
|
||||||
|
//结束位置
|
||||||
|
Integer endIndex = messageTemplateType.getEndIndex();
|
||||||
|
String substring = result.substring(startIndex, endIndex);
|
||||||
|
log.info("截取后的字符1:" + substring);
|
||||||
|
//将每个解析后的字段都存入到JSON对象中
|
||||||
|
jsonObject.put(messageTemplateType.getMessageField(),substring );
|
||||||
|
}
|
||||||
|
|
||||||
|
System.out.println("哈哈哈红红火火恍恍惚惚");
|
||||||
|
log.info("解析后的报文是:" + jsonObject);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package com.muyu.server.service.impl;
|
package com.muyu.server.service.impl;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.muyu.cache.WarnRuleCacheService;
|
||||||
import com.muyu.common.domain.WarnRule;
|
import com.muyu.common.domain.WarnRule;
|
||||||
import com.muyu.common.domain.resp.WarnRuleResp;
|
import com.muyu.common.domain.resp.WarnRuleResp;
|
||||||
import com.muyu.server.mapper.WarnRuleMapper;
|
import com.muyu.server.mapper.WarnRuleMapper;
|
||||||
|
@ -24,6 +25,11 @@ public class WarnRuleServiceImpl
|
||||||
@Autowired
|
@Autowired
|
||||||
private WarnRuleMapper warnRuleMapper;
|
private WarnRuleMapper warnRuleMapper;
|
||||||
|
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private WarnRuleCacheService warnRuleCacheService;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 精确查询预警规则
|
* 精确查询预警规则
|
||||||
*
|
*
|
||||||
|
@ -33,7 +39,11 @@ public class WarnRuleServiceImpl
|
||||||
@Override
|
@Override
|
||||||
public WarnRule selectWarnRuleById(Long id)
|
public WarnRule selectWarnRuleById(Long id)
|
||||||
{
|
{
|
||||||
return warnRuleMapper.selectById(id);
|
WarnRule warnRule = warnRuleMapper.selectById(id);
|
||||||
|
|
||||||
|
warnRuleCacheService.put(String.valueOf(warnRule.getId()), warnRule);
|
||||||
|
|
||||||
|
return warnRule;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -46,23 +56,46 @@ public class WarnRuleServiceImpl
|
||||||
@Override
|
@Override
|
||||||
public List<WarnRuleResp> selectWarnRuleRespList()
|
public List<WarnRuleResp> selectWarnRuleRespList()
|
||||||
{
|
{
|
||||||
return warnRuleMapper.selectWarnRuleRespList();
|
List<WarnRuleResp> warnRuleResps = warnRuleMapper.selectWarnRuleRespList();
|
||||||
|
warnRuleResps.forEach(warnRuleResp -> {
|
||||||
|
warnRuleCacheService.put(warnRuleCacheService.keyPre() + warnRuleResp.getId(), warnRuleResp);
|
||||||
|
});
|
||||||
|
return warnRuleResps;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Integer addWarnRule(WarnRule warnRule) {
|
public Integer addWarnRule(WarnRule warnRule) {
|
||||||
return warnRuleMapper.insert(warnRule);
|
|
||||||
|
int rows = warnRuleMapper.insert(warnRule);
|
||||||
|
|
||||||
|
if (rows>0){
|
||||||
|
warnRuleCacheService.put(String.valueOf(warnRule.getId()), warnRule);
|
||||||
|
}
|
||||||
|
|
||||||
|
return rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Integer updWarnRule(WarnRule warnRule) {
|
public Integer updWarnRule(WarnRule warnRule) {
|
||||||
LambdaQueryWrapper<WarnRule> queryWrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<WarnRule> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
return warnRuleMapper.update(queryWrapper);
|
|
||||||
|
Integer update = warnRuleMapper.update(queryWrapper);
|
||||||
|
|
||||||
|
warnRuleCacheService.put(String.valueOf(warnRule.getId()), warnRule);
|
||||||
|
|
||||||
|
return update;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<WarnRuleResp> selectListByStrategyId(Long strategyId) {
|
public List<WarnRuleResp> selectListByStrategyId(Long strategyId) {
|
||||||
return warnRuleMapper.selectListByStrategyId(strategyId);
|
|
||||||
|
List<WarnRuleResp> warnRuleResps = warnRuleMapper.selectListByStrategyId(strategyId);
|
||||||
|
|
||||||
|
warnRuleResps.forEach(warnRuleResp -> {
|
||||||
|
warnRuleCacheService.put(warnRuleCacheService.keyPre() + warnRuleResp.getId(), warnRuleResp);
|
||||||
|
});
|
||||||
|
|
||||||
|
return warnRuleResps;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@ package com.muyu.server.service.impl;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.muyu.cache.WarnStrategyCacheService;
|
||||||
import com.muyu.common.domain.WarnStrategy;
|
import com.muyu.common.domain.WarnStrategy;
|
||||||
import com.muyu.common.domain.req.WarnStrategyReq;
|
import com.muyu.common.domain.req.WarnStrategyReq;
|
||||||
import com.muyu.common.domain.resp.WarnStrategyResp;
|
import com.muyu.common.domain.resp.WarnStrategyResp;
|
||||||
|
@ -25,6 +26,9 @@ public class WarnStrategyServiceImpl
|
||||||
@Autowired
|
@Autowired
|
||||||
private WarnStrategyMapper warnStrategyMapper;
|
private WarnStrategyMapper warnStrategyMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private WarnStrategyCacheService warnStrategyCacheService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 精确查询预警策略
|
* 精确查询预警策略
|
||||||
*
|
*
|
||||||
|
@ -34,7 +38,11 @@ public class WarnStrategyServiceImpl
|
||||||
@Override
|
@Override
|
||||||
public WarnStrategy selectWarnStrategyById(Long id)
|
public WarnStrategy selectWarnStrategyById(Long id)
|
||||||
{
|
{
|
||||||
return warnStrategyMapper.selectById(id);
|
WarnStrategy warnStrategy = warnStrategyMapper.selectById(id);
|
||||||
|
|
||||||
|
warnStrategyCacheService.put(String.valueOf(warnStrategy.getId()), warnStrategy);
|
||||||
|
|
||||||
|
return warnStrategy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -47,12 +55,23 @@ public class WarnStrategyServiceImpl
|
||||||
@Override
|
@Override
|
||||||
public List<WarnStrategyResp> selectWarnStrategyList(WarnStrategyReq warnStrategyReq)
|
public List<WarnStrategyResp> selectWarnStrategyList(WarnStrategyReq warnStrategyReq)
|
||||||
{
|
{
|
||||||
return warnStrategyMapper.selectWarnStrategyList(warnStrategyReq);
|
List<WarnStrategyResp> warnStrategyResps = warnStrategyMapper.selectWarnStrategyList(warnStrategyReq);
|
||||||
|
|
||||||
|
warnStrategyResps.forEach(warnStrategyResp -> {
|
||||||
|
warnStrategyCacheService.put(warnStrategyCacheService.keyPre() + warnStrategyResp.getId(), warnStrategyResp);
|
||||||
|
});
|
||||||
|
|
||||||
|
return warnStrategyResps;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Integer deleteWarnStrategy(Long id) {
|
public Integer deleteWarnStrategy(Long id) {
|
||||||
return warnStrategyMapper.deleteById(id);
|
|
||||||
|
int rows = warnStrategyMapper.deleteById(id);
|
||||||
|
|
||||||
|
warnStrategyCacheService.remove(String.valueOf(id));
|
||||||
|
|
||||||
|
return rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -62,7 +81,12 @@ public class WarnStrategyServiceImpl
|
||||||
@Override
|
@Override
|
||||||
public Integer updWarnStrategy(WarnStrategy warnStrategy){
|
public Integer updWarnStrategy(WarnStrategy warnStrategy){
|
||||||
QueryWrapper<WarnStrategy> wrapper = new QueryWrapper<>(warnStrategy);
|
QueryWrapper<WarnStrategy> wrapper = new QueryWrapper<>(warnStrategy);
|
||||||
return warnStrategyMapper.update(wrapper);
|
|
||||||
|
Integer update = warnStrategyMapper.update(wrapper);
|
||||||
|
|
||||||
|
warnStrategyCacheService.remove(String.valueOf(warnStrategy.getId()));
|
||||||
|
|
||||||
|
return update;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -70,7 +94,12 @@ public class WarnStrategyServiceImpl
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Integer addWarnStrategy(WarnStrategy warnStrategy){
|
public Integer addWarnStrategy(WarnStrategy warnStrategy){
|
||||||
return warnStrategyMapper.insert(warnStrategy);
|
|
||||||
|
int rows = warnStrategyMapper.insert(warnStrategy);
|
||||||
|
|
||||||
|
warnStrategyCacheService.put(String.valueOf(warnStrategy.getId()), warnStrategy);
|
||||||
|
|
||||||
|
return rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -80,7 +109,14 @@ public class WarnStrategyServiceImpl
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<WarnStrategyResp> selectListByCarType(Long carTypeId) {
|
public List<WarnStrategyResp> selectListByCarType(Long carTypeId) {
|
||||||
return warnStrategyMapper.selectListByCarType(carTypeId);
|
|
||||||
|
List<WarnStrategyResp> warnStrategyResps = warnStrategyMapper.selectListByCarType(carTypeId);
|
||||||
|
|
||||||
|
warnStrategyResps.forEach(warnStrategyResp -> {
|
||||||
|
warnStrategyCacheService.put(warnStrategyCacheService.keyPre() + warnStrategyResp.getId(), warnStrategyResp);
|
||||||
|
});
|
||||||
|
|
||||||
|
return warnStrategyResps;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue