feat:()添加报文模版缓存
parent
1d91e51199
commit
3ed255fe1e
|
@ -2,6 +2,9 @@ package com.muyu.enterprise.cache;
|
|||
|
||||
import com.muyu.common.cache.CacheAbsBacis;
|
||||
import com.muyu.domain.Fence;
|
||||
import com.muyu.domain.resp.FenceResp;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 电子围栏缓存
|
||||
|
@ -21,4 +24,5 @@ public class FenceCahceService extends CacheAbsBacis<String, Fence> {
|
|||
public String decode(String key) {
|
||||
return key.replace("fence:info:", "");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
package com.muyu.enterprise.cache;
|
||||
|
||||
import com.muyu.common.cache.CacheAbsBacis;
|
||||
import com.muyu.domain.VehicleType;
|
||||
|
||||
/**
|
||||
* 故障缓存服务
|
||||
*/
|
||||
public class VehicleTypeCacheService extends CacheAbsBacis<String, VehicleType> {
|
||||
@Override
|
||||
public void clear() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String keyPre() {
|
||||
return "vehicleType:info:";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String decode(String key) {
|
||||
return key.replace("vehicleType:info:", "");
|
||||
}
|
||||
}
|
|
@ -3,3 +3,4 @@ com.muyu.enterprise.cache.FaultCacheService
|
|||
com.muyu.enterprise.cache.FenceCahceService
|
||||
com.muyu.enterprise.cache.WarnRuleCacheService
|
||||
com.muyu.enterprise.cache.WarnStrategyCacheService
|
||||
com.muyu.enterprise.cache.MessageTemplateCacheService
|
||||
|
|
|
@ -3,9 +3,6 @@ package com.muyu.domain;
|
|||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.muyu.common.core.annotation.Excel;
|
||||
import com.muyu.common.core.annotation.Excel.ColumnType;
|
||||
import com.muyu.common.core.web.domain.BaseEntity;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
|
@ -46,5 +43,14 @@ public class VehicleType extends BaseEntity {
|
|||
@Schema(type = "Integer",description = "报文模版外键")
|
||||
private Integer messageTemplateId;
|
||||
|
||||
/**
|
||||
* 添加车辆类型
|
||||
*/
|
||||
public static VehicleType addBuilder(VehicleType vehicleType) {
|
||||
return VehicleType.builder().
|
||||
vehicleTypeId(vehicleType.getVehicleTypeId()).
|
||||
vehicleTypeName(vehicleType.getVehicleTypeName()).
|
||||
build();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ public class ElectController extends BaseController {
|
|||
public Result<TableDataInfo<FenceResp>> showList(@RequestBody @Validated FenceReq req) {
|
||||
startPage();
|
||||
List<FenceResp> list = electService.selectFenceList(req);
|
||||
fenceCahceService.get(String.valueOf(req));
|
||||
//将列表存到Redis
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,15 +1,20 @@
|
|||
package com.muyu.enterprise.controller;
|
||||
|
||||
import com.muyu.common.security.utils.SecurityUtils;
|
||||
import com.muyu.common.system.domain.LoginUser;
|
||||
import com.muyu.domain.MessageValue;
|
||||
import com.muyu.domain.VehicleType;
|
||||
import com.muyu.domain.req.MessageValueAddReq;
|
||||
import com.muyu.domain.req.VehicleAddReq;
|
||||
import com.muyu.enterprise.cache.VehicleCacheService;
|
||||
import com.muyu.enterprise.cache.VehicleTypeCacheService;
|
||||
import com.muyu.enterprise.service.VehicleTypeService;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -30,6 +35,9 @@ public class VehicleTypeController {
|
|||
@Autowired
|
||||
private VehicleTypeService vehicleTypeService;
|
||||
|
||||
@Autowired
|
||||
private VehicleTypeCacheService vehicleTypeCacheService;
|
||||
|
||||
/**
|
||||
* 查询所有车辆类型
|
||||
* @return
|
||||
|
@ -39,4 +47,22 @@ public class VehicleTypeController {
|
|||
public Result<List<VehicleType>> findAll(){
|
||||
return Result.success(vehicleTypeService.list());
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加车辆类型
|
||||
* @param vehicleType
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/add")
|
||||
@Operation(summary = "添加报文数据", description = "新增报文数据")
|
||||
public Result<String> save(@RequestBody VehicleType vehicleType) {
|
||||
boolean save = vehicleTypeService.save(vehicleType);
|
||||
//获取用户信息
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
//获取租户唯一标识
|
||||
String databaseName = loginUser.getSysUser().getDatabaseName();
|
||||
//存到redis
|
||||
vehicleTypeCacheService.put(databaseName+vehicleType.getVehicleTypeId(),vehicleType);
|
||||
return Result.success(save? "添加成功" : "添加失败");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,4 +40,5 @@ public interface VehicleMapper extends MPJBaseMapper<Vehicle> {
|
|||
*/
|
||||
@Select("SELECT t.message_template_id FROM vehicle v LEFT JOIN vehicle_type t ON v.vehicle_type_id = t.vehicle_type_id WHERE v.vehicle_vin = #{vehicleVin}")
|
||||
Long findByVehicleVin(String vehicleVin);
|
||||
|
||||
}
|
||||
|
|
|
@ -19,7 +19,5 @@ public interface IFencegroupService extends IService<FenceGroup> {
|
|||
|
||||
void addGroup(FenceGroupAddReq addReq);
|
||||
|
||||
// List<FenceGroup> haveFence(HaveFence haveFence);
|
||||
//
|
||||
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
|||
import com.muyu.domain.Vehicle;
|
||||
import com.muyu.domain.req.VehicleManageReq;
|
||||
import com.muyu.domain.resp.VehicleManageResp;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -31,4 +32,10 @@ public interface VehicleService extends IService<Vehicle> {
|
|||
* @return
|
||||
*/
|
||||
Long findByVehicleVin(String vehicleVin);
|
||||
|
||||
/**
|
||||
* 绑定围栏组
|
||||
*/
|
||||
void bindFenceGroup(@Param("fenceGroupIds") Integer[] fenceGroupIds, @Param("vehicleId") Long vehicleId);
|
||||
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.muyu.enterprise.service.impl;
|
|||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
import com.muyu.enterprise.cache.FenceCahceService;
|
||||
import com.muyu.enterprise.mapper.ElectMapper;
|
||||
import com.muyu.enterprise.mapper.WarnLogsMapper;
|
||||
import com.muyu.enterprise.service.ElectService;
|
||||
|
@ -25,6 +26,10 @@ public class ElectServiceImpl
|
|||
@Autowired
|
||||
private WarnLogsMapper warnLogsMapper;
|
||||
|
||||
@Autowired
|
||||
private FenceCahceService fenceCahceService;
|
||||
|
||||
|
||||
@Override
|
||||
public List<FenceResp> selectFenceList(FenceReq req) {
|
||||
|
||||
|
@ -39,6 +44,11 @@ public class ElectServiceImpl
|
|||
req.getFenceName()
|
||||
);
|
||||
List<FenceResp> list = electMapper.selectJoinList(FenceResp.class, wrapper);
|
||||
|
||||
String decode = fenceCahceService.decode(String.valueOf(list));
|
||||
|
||||
//将获取到的数据存到Redis
|
||||
fenceCahceService.put(String.valueOf(decode),d);
|
||||
return list;
|
||||
}
|
||||
//
|
||||
|
|
|
@ -41,10 +41,5 @@ public class FencegroupServiceImpl
|
|||
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public List<FenceGroup> haveFence(HaveFence haveFence) {
|
||||
// return null;
|
||||
// }
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -69,4 +69,9 @@ public class VehicleServiceImpl
|
|||
return templateId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bindFenceGroup(Integer[] fenceGroupIds, Long vehicleId) {
|
||||
vehicleMapper.bindFenceGroup(fenceGroupIds, vehicleId);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -100,6 +100,13 @@
|
|||
<artifactId>cloud-common-kafka</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!--缓存依赖-->
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>cloud-modules-enterprise-cache</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
|
Loading…
Reference in New Issue