Compare commits
3 Commits
master
...
dev.protoc
Author | SHA1 | Date |
---|---|---|
|
d1440fb706 | |
|
3ed255fe1e | |
|
1d91e51199 |
|
@ -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,26 @@
|
|||
package com.muyu.enterprise.cache;
|
||||
|
||||
import com.muyu.common.cache.CacheAbsBacis;
|
||||
import com.muyu.domain.MessageTemplate;
|
||||
|
||||
/**
|
||||
* 报文模版缓存
|
||||
*/
|
||||
public class MessageTemplateCacheService extends CacheAbsBacis<String, MessageTemplate> {
|
||||
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String keyPre() {
|
||||
return "messageTemplate:info:";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String decode(String key) {
|
||||
return key.replace("messageTemplate: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:", "");
|
||||
}
|
||||
}
|
|
@ -14,11 +14,11 @@ public class WarnRuleCacheService extends CacheAbsBacis<String, WarnRule> {
|
|||
|
||||
@Override
|
||||
public String keyPre() {
|
||||
return "warn:info:";
|
||||
return "warnRule:info:";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String decode(String key) {
|
||||
return key.replace("warn:info:", "");
|
||||
return key.replace("warnRule:info:", "");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ import com.muyu.domain.WarnRule;
|
|||
import com.muyu.domain.WarnStrategy;
|
||||
|
||||
/**
|
||||
* 预警规则缓存服务
|
||||
* 预警策略缓存服务
|
||||
*/
|
||||
public class WarnStrategyCacheService extends CacheAbsBacis<String, WarnStrategy> {
|
||||
@Override
|
||||
|
@ -15,11 +15,11 @@ public class WarnStrategyCacheService extends CacheAbsBacis<String, WarnStrategy
|
|||
|
||||
@Override
|
||||
public String keyPre() {
|
||||
return "warn:info:";
|
||||
return "warnStrategy:info:";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String decode(String key) {
|
||||
return key.replace("warn:info:", "");
|
||||
return key.replace("warnStrategy:info:", "");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,3 +3,5 @@ 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
|
||||
com.muyu.enterprise.cache.VehicleTypeCacheService
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
package com.muyu.domain.req;
|
||||
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 绑定围栏组请求参数
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Tag(name = "绑定围栏组参数")
|
||||
public class BoundFenceGroupReq {
|
||||
|
||||
/**
|
||||
* 车辆Id
|
||||
*/
|
||||
private Long vehicleId;
|
||||
|
||||
/**
|
||||
* 围栏组Ids
|
||||
*/
|
||||
private List<Long> fenceGroupIds;
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -155,5 +155,4 @@ public class ElectController extends BaseController {
|
|||
return Result.success(fences);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
package com.muyu.enterprise.controller;
|
||||
|
||||
import com.muyu.common.security.utils.SecurityUtils;
|
||||
import com.muyu.common.system.domain.LoginUser;
|
||||
import com.muyu.domain.MessageTemplate;
|
||||
import com.muyu.domain.req.MessageTemplateAddReq;
|
||||
import com.muyu.domain.resp.MessageTemplateListResp;
|
||||
import com.muyu.enterprise.cache.MessageTemplateCacheService;
|
||||
import com.muyu.enterprise.service.MessageTemplateService;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
|
@ -30,6 +33,10 @@ public class MessageTemplateController {
|
|||
@Autowired
|
||||
private MessageTemplateService messageTemplateService;
|
||||
|
||||
//缓存
|
||||
@Autowired
|
||||
private MessageTemplateCacheService templateCacheService;
|
||||
|
||||
/**
|
||||
* 报文模版列表查询
|
||||
*1
|
||||
|
@ -55,8 +62,14 @@ public class MessageTemplateController {
|
|||
*/
|
||||
@PostMapping("/")
|
||||
public Result<String> save(@RequestBody MessageTemplateAddReq messageTemplateAddReq) {
|
||||
messageTemplateService.save(MessageTemplate.addBuild(messageTemplateAddReq));
|
||||
return Result.success("添加成功");
|
||||
boolean save = messageTemplateService.save(MessageTemplate.addBuild(messageTemplateAddReq));
|
||||
//获取用户信息
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
//获取租户唯一标识
|
||||
String databaseName = loginUser.getSysUser().getDatabaseName();
|
||||
//添加到缓存
|
||||
templateCacheService.put(databaseName+messageTemplateAddReq.getMessageTemplateName(), MessageTemplate.addBuild(messageTemplateAddReq));
|
||||
return Result.success(save? "新增成功" : "新增失败");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.muyu.enterprise.controller;
|
|||
|
||||
import com.muyu.common.security.utils.SecurityUtils;
|
||||
import com.muyu.common.system.domain.LoginUser;
|
||||
import com.muyu.domain.req.BoundFenceGroupReq;
|
||||
import com.muyu.enterprise.cache.VehicleCacheService;
|
||||
import com.muyu.enterprise.service.VehicleService;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
|
@ -144,9 +145,10 @@ public class VehicleController extends BaseController {
|
|||
*/
|
||||
@GetMapping("/addBoundFenceGroup")
|
||||
@Operation(description = "车辆绑定围栏组")
|
||||
public Result<String> boundFenceGroup(
|
||||
@Validated @RequestBody BoundMiddle boundMiddle){
|
||||
return null;
|
||||
public Result boundFenceGroup(
|
||||
@Validated @RequestBody BoundFenceGroupReq boundFenceGroupReq){
|
||||
vehicleService.boundFenceGroup(boundFenceGroupReq);
|
||||
return Result.success("绑定成功");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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? "添加成功" : "添加失败");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,11 +30,6 @@ public interface ElectMapper extends MPJBaseMapper<Fence> {
|
|||
@Select("select * from fence where fence_id=#{fenceId}")
|
||||
List<Fence> mapShow(@Param("fenceId") Long fenceId);
|
||||
|
||||
// /**
|
||||
// * 根据id查询车辆
|
||||
// */
|
||||
// Fence boundFence(@Param("fenceId") Long fenceId);
|
||||
|
||||
/**
|
||||
* 查询电子围栏(终版)
|
||||
*/
|
||||
|
|
|
@ -28,7 +28,16 @@ public interface FencegroupMapper extends MPJBaseMapper<FenceGroup> {
|
|||
@Select("SELECT g.fence_group_id,g.group_type,g.priority,g.`status`,f.fence_id, group_CONCAT( f.fence_name ) AS fence_name FROM fence_group g LEFT JOIN middle m ON m.fence_group_id = g.fence_group_id LEFT JOIN fence f ON m.fence_id = f.fence_id GROUP BY g.fence_group_id")
|
||||
List<FenceGroup> showGroupList(FenceGroupReq req);
|
||||
|
||||
@Insert("INSERT INTO `vehicle-basic`.`middle` (`fence_id`, `fence_group_id`) VALUES <foreach collection=\"fenceIds\" item=\"id\" separator=\",\"> (#{id},#{fenceGroupId}) </foreach>")
|
||||
// @Insert("INSERT INTO `vehicle-basic`.`middle` (`fence_id`, `fence_group_id`) VALUES <foreach collection='fenceIds' item='id' separator=','> (#{id},#{fenceGroupId}) </foreach>")
|
||||
// @Insert({ "<script>", "INSERT INTO user_role (user_id, role_id) VALUES ", "<foreach collection='roleIds' item='roleId' separator=','>", "(#{userId}, #{roleId})", "</foreach>", "</script>" })
|
||||
@Insert({
|
||||
"<script>",
|
||||
"INSERT INTO `vehicle-basic`.`middle` (fence_id, fence_group_id) VALUES ",
|
||||
"<foreach collection='fenceIds' item='id' separator=','>",
|
||||
"(#{id}, #{fenceGroupId})",
|
||||
"</foreach>",
|
||||
"</script>"
|
||||
})
|
||||
void addMiddle(@Param("fenceIds") Integer[] fenceIds,@Param("fenceGroupId") Long fenceGroupId);
|
||||
|
||||
}
|
||||
|
|
|
@ -2,8 +2,10 @@ package com.muyu.enterprise.mapper;
|
|||
|
||||
import com.github.yulichang.base.MPJBaseMapper;
|
||||
import com.muyu.domain.Vehicle;
|
||||
import com.muyu.domain.req.BoundFenceGroupReq;
|
||||
import com.muyu.domain.req.VehicleManageReq;
|
||||
import com.muyu.domain.resp.VehicleManageResp;
|
||||
import org.apache.ibatis.annotations.Insert;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
@ -28,11 +30,6 @@ public interface VehicleMapper extends MPJBaseMapper<Vehicle> {
|
|||
*/
|
||||
List<VehicleManageResp> findAll(VehicleManageReq vehicleManageReq);
|
||||
|
||||
/**
|
||||
* 车辆绑定围栏组
|
||||
*/
|
||||
void bindFenceGroup(@Param("fenceGroupIds") Integer[] fenceGroupIds, @Param("vehicleId") Long vehicleId);
|
||||
|
||||
/**
|
||||
* 根据车辆vin查询模版id
|
||||
* @param vehicleVin
|
||||
|
@ -40,4 +37,20 @@ 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);
|
||||
|
||||
/**
|
||||
* 车辆绑定围栏组
|
||||
* @param boundFenceGroupReq
|
||||
*/
|
||||
// @Insert("INSERT INTO `vehicle-basic`.`bound_middle` (`fence_group_id`,`vehicle_id`) VALUES <foreach collection=\"fenceGroupIds\" item=\"id\" separator=\",\"> (#{id},#{vehicleId}) </foreach>")
|
||||
@Insert({
|
||||
"<script>",
|
||||
"INSERT INTO `vehicle-basic`.`bound_middle` (fence_group_id,vehicle_id) VALUES ",
|
||||
"<foreach collection='fenceGroupIds' item='id' separator=','>",
|
||||
"(#{id}, #{vehicleId})",
|
||||
"</foreach>",
|
||||
"</script>"
|
||||
})
|
||||
void boundFenceGroup(BoundFenceGroupReq boundFenceGroupReq);
|
||||
|
||||
}
|
||||
|
|
|
@ -19,7 +19,5 @@ public interface IFencegroupService extends IService<FenceGroup> {
|
|||
|
||||
void addGroup(FenceGroupAddReq addReq);
|
||||
|
||||
// List<FenceGroup> haveFence(HaveFence haveFence);
|
||||
//
|
||||
|
||||
}
|
||||
|
|
|
@ -2,8 +2,10 @@ package com.muyu.enterprise.service;
|
|||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.muyu.domain.Vehicle;
|
||||
import com.muyu.domain.req.BoundFenceGroupReq;
|
||||
import com.muyu.domain.req.VehicleManageReq;
|
||||
import com.muyu.domain.resp.VehicleManageResp;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -31,4 +33,9 @@ public interface VehicleService extends IService<Vehicle> {
|
|||
* @return
|
||||
*/
|
||||
Long findByVehicleVin(String vehicleVin);
|
||||
|
||||
/**
|
||||
* 绑定围栏组
|
||||
*/
|
||||
void boundFenceGroup(BoundFenceGroupReq boundFenceGroupReq);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
// }
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
|||
import com.muyu.common.core.utils.StringUtils;
|
||||
import com.muyu.domain.Vehicle;
|
||||
import com.muyu.domain.VehicleType;
|
||||
import com.muyu.domain.req.BoundFenceGroupReq;
|
||||
import com.muyu.domain.req.VehicleManageReq;
|
||||
import com.muyu.domain.resp.VehicleManageResp;
|
||||
import com.muyu.enterprise.mapper.VehicleMapper;
|
||||
|
@ -69,4 +70,11 @@ public class VehicleServiceImpl
|
|||
return templateId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void boundFenceGroup(BoundFenceGroupReq boundFenceGroupReq) {
|
||||
|
||||
vehicleMapper.boundFenceGroup(boundFenceGroupReq);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -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