feat:()修改代码方法
parent
0be090d11b
commit
a00e5345b4
|
@ -63,4 +63,5 @@ public class LoginUser implements Serializable {
|
||||||
*/
|
*/
|
||||||
private SysUser sysUser;
|
private SysUser sysUser;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,11 +2,12 @@ package com.muyu.enterprise.cache;
|
||||||
|
|
||||||
import com.muyu.common.cache.CacheAbsBacis;
|
import com.muyu.common.cache.CacheAbsBacis;
|
||||||
import com.muyu.domain.WarnStrategy;
|
import com.muyu.domain.WarnStrategy;
|
||||||
|
import com.muyu.domain.resp.WarnVehicleResp;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 预警策略缓存服务
|
* 预警策略缓存服务
|
||||||
*/
|
*/
|
||||||
public class AllWarnStrategyCacheService extends CacheAbsBacis<String, WarnStrategy> {
|
public class AllWarnStrategyCacheService extends CacheAbsBacis<String, WarnVehicleResp> {
|
||||||
@Override
|
@Override
|
||||||
public void clear() {
|
public void clear() {
|
||||||
|
|
||||||
|
|
|
@ -75,6 +75,14 @@ public class WarnRule extends BaseEntity{
|
||||||
@Excel(name = "最小值")
|
@Excel(name = "最小值")
|
||||||
private Integer minValue;
|
private Integer minValue;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 策略外键id
|
||||||
|
*/
|
||||||
|
@Schema(type = "Integer",description = "策略外键id")
|
||||||
|
@Excel(name = "策略外键id")
|
||||||
|
private Integer warnStrategyId;
|
||||||
|
|
||||||
|
|
||||||
public static WarnRule updateBuilder(WarnRule warnRule, Supplier<Long> supplier) {
|
public static WarnRule updateBuilder(WarnRule warnRule, Supplier<Long> supplier) {
|
||||||
return WarnRule.builder()
|
return WarnRule.builder()
|
||||||
.warnRuleId(supplier.get())
|
.warnRuleId(supplier.get())
|
||||||
|
|
|
@ -51,6 +51,7 @@ public class WarnStrategy extends BaseEntity{
|
||||||
private Long vehicleTypeId;
|
private Long vehicleTypeId;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static WarnStrategy updateBuilder(WarnStrategy warnStrategy, Supplier<Long> supplier) {
|
public static WarnStrategy updateBuilder(WarnStrategy warnStrategy, Supplier<Long> supplier) {
|
||||||
return WarnStrategy.builder()
|
return WarnStrategy.builder()
|
||||||
.warnStrategyId(supplier.get())
|
.warnStrategyId(supplier.get())
|
||||||
|
|
|
@ -26,5 +26,5 @@ public class BoundFenceGroupReq {
|
||||||
/**
|
/**
|
||||||
* 围栏组Ids
|
* 围栏组Ids
|
||||||
*/
|
*/
|
||||||
private List<Long> fenceGroupIds;
|
private Long[] fenceGroupIds;
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,4 +23,7 @@ public class WarnVehicleReq {
|
||||||
@Excel(name = "策略名称")
|
@Excel(name = "策略名称")
|
||||||
private String strategyName;
|
private String strategyName;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -175,4 +175,5 @@ public class VehicleController extends BaseController {
|
||||||
Long templateId = vehicleService.findByVehicleVin(vehicleVin);
|
Long templateId = vehicleService.findByVehicleVin(vehicleVin);
|
||||||
return Result.success(templateId);
|
return Result.success(templateId);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,11 +37,19 @@ public class WarnStrategyController {
|
||||||
*/
|
*/
|
||||||
@RequestMapping(path = "/strategyList",method = RequestMethod.POST)
|
@RequestMapping(path = "/strategyList",method = RequestMethod.POST)
|
||||||
@Operation(summary = "策略列表", description = "获取所有策略列表")
|
@Operation(summary = "策略列表", description = "获取所有策略列表")
|
||||||
public Result<List<WarnStrategy>> strategyList() {
|
// public Result<List<WarnStrategy>> strategyList() {
|
||||||
List<WarnStrategy> list = warnStrategyService.list();
|
// List<WarnStrategy> list = warnStrategyService.list();
|
||||||
//存进Redis
|
// //存进Redis
|
||||||
for (WarnStrategy warnStrategy : list) {
|
// for (WarnStrategy warnStrategy : list) {
|
||||||
allWarnStrategyCacheService.put(String.valueOf(warnStrategy.getWarnStrategyId()),warnStrategy);
|
// 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);
|
||||||
}
|
}
|
||||||
return Result.success(list);
|
return Result.success(list);
|
||||||
}
|
}
|
||||||
|
@ -62,11 +70,11 @@ public class WarnStrategyController {
|
||||||
* @param warnVehicleReq
|
* @param warnVehicleReq
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@RequestMapping(path = "ruleStrategyList",method = RequestMethod.POST)
|
// @RequestMapping(path = "ruleStrategyList",method = RequestMethod.POST)
|
||||||
@Operation(summary = "策略规则双表联查", description = "获取所有策略规则双表联查")
|
// @Operation(summary = "策略规则双表联查", description = "获取所有策略规则双表联查")
|
||||||
public Result<List<WarnVehicleResp>> ruleStrategyList(@RequestBody WarnVehicleReq warnVehicleReq){
|
// public Result<List<WarnVehicleResp>> ruleStrategyList(@RequestBody WarnVehicleReq warnVehicleReq){
|
||||||
return Result.success(warnStrategyService.ruleStrategyList(warnVehicleReq));
|
// return Result.success(warnStrategyService.ruleStrategyList(warnVehicleReq));
|
||||||
}
|
// }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 添加策略
|
* 添加策略
|
||||||
|
|
|
@ -44,12 +44,8 @@ public interface VehicleMapper extends MPJBaseMapper<Vehicle> {
|
||||||
*/
|
*/
|
||||||
// @Insert("INSERT INTO `vehicle-basic`.`bound_middle` (`fence_group_id`,`vehicle_id`) VALUES <foreach collection=\"fenceGroupIds\" item=\"id\" separator=\",\"> (#{id},#{vehicleId}) </foreach>")
|
// @Insert("INSERT INTO `vehicle-basic`.`bound_middle` (`fence_group_id`,`vehicle_id`) VALUES <foreach collection=\"fenceGroupIds\" item=\"id\" separator=\",\"> (#{id},#{vehicleId}) </foreach>")
|
||||||
@Insert({
|
@Insert({
|
||||||
"<script>",
|
"<script> INSERT INTO `vehicle-basic`.`bound_middle` (fence_group_id,vehicle_id) VALUES <foreach collection='fenceGroupIds' item='id' separator=','> (#{id}, #{vehicleId}) </foreach> </script>"
|
||||||
"INSERT INTO `vehicle-basic`.`bound_middle` (fence_group_id,vehicle_id) VALUES ",
|
// "INSERT INTO `vehicle-basic`.`bound_middle` (fence_group_id, vehicle_id) VALUES <foreach collection=\"fenceGroupIds\" item=\"id\" separator=\",\"> (#{id}, #{vehicleId}) </foreach> "
|
||||||
"<foreach collection='fenceGroupIds' item='id' separator=','>",
|
|
||||||
"(#{id}, #{vehicleId})",
|
|
||||||
"</foreach>",
|
|
||||||
"</script>"
|
|
||||||
})
|
})
|
||||||
void boundFenceGroup(BoundFenceGroupReq boundFenceGroupReq);
|
void boundFenceGroup(BoundFenceGroupReq boundFenceGroupReq);
|
||||||
|
|
||||||
|
|
|
@ -38,4 +38,5 @@ public interface VehicleService extends IService<Vehicle> {
|
||||||
* 绑定围栏组
|
* 绑定围栏组
|
||||||
*/
|
*/
|
||||||
void boundFenceGroup(BoundFenceGroupReq boundFenceGroupReq);
|
void boundFenceGroup(BoundFenceGroupReq boundFenceGroupReq);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,5 +9,8 @@ import java.util.List;
|
||||||
|
|
||||||
public interface WarnStrategyService extends IService<WarnStrategy> {
|
public interface WarnStrategyService extends IService<WarnStrategy> {
|
||||||
|
|
||||||
List<WarnVehicleResp>ruleStrategyList(WarnVehicleReq warnVehicleReq);
|
// List<WarnVehicleResp>ruleStrategyList(WarnVehicleReq warnVehicleReq);
|
||||||
|
|
||||||
|
List<WarnVehicleResp> selectList(WarnVehicleReq req);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@ import com.muyu.domain.Fence;
|
||||||
import com.muyu.domain.LanType;
|
import com.muyu.domain.LanType;
|
||||||
import com.muyu.domain.req.FenceReq;
|
import com.muyu.domain.req.FenceReq;
|
||||||
import com.muyu.domain.resp.FenceResp;
|
import com.muyu.domain.resp.FenceResp;
|
||||||
|
import com.muyu.enterprise.service.VehicleService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@ -24,7 +25,8 @@ public class ElectServiceImpl
|
||||||
@Autowired
|
@Autowired
|
||||||
private ElectMapper electMapper;
|
private ElectMapper electMapper;
|
||||||
@Autowired
|
@Autowired
|
||||||
private WarnLogsMapper warnLogsMapper;
|
private VehicleService service;
|
||||||
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private FenceCahceService fenceCahceService;
|
private FenceCahceService fenceCahceService;
|
||||||
|
@ -51,13 +53,6 @@ public class ElectServiceImpl
|
||||||
// fenceCahceService.put(String.valueOf(decode),d);
|
// fenceCahceService.put(String.valueOf(decode),d);
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public int addFence(Fence fence) {
|
|
||||||
// int i = electMapper.addFence(fence);
|
|
||||||
// return i;
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateFenceOn(Long fenceId) {
|
public void updateFenceOn(Long fenceId) {
|
||||||
|
|
|
@ -73,7 +73,6 @@ public class VehicleServiceImpl
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void boundFenceGroup(BoundFenceGroupReq boundFenceGroupReq) {
|
public void boundFenceGroup(BoundFenceGroupReq boundFenceGroupReq) {
|
||||||
|
|
||||||
vehicleMapper.boundFenceGroup(boundFenceGroupReq);
|
vehicleMapper.boundFenceGroup(boundFenceGroupReq);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@ package com.muyu.enterprise.service.impl;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||||
|
import com.muyu.domain.MessageTemplate;
|
||||||
import com.muyu.enterprise.mapper.WarnStrategyMapper;
|
import com.muyu.enterprise.mapper.WarnStrategyMapper;
|
||||||
import com.muyu.enterprise.service.WarnStrategyService;
|
import com.muyu.enterprise.service.WarnStrategyService;
|
||||||
import com.muyu.common.core.utils.StringUtils;
|
import com.muyu.common.core.utils.StringUtils;
|
||||||
|
@ -12,6 +13,7 @@ import com.muyu.domain.resp.WarnVehicleResp;
|
||||||
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;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
|
@ -21,15 +23,31 @@ public class WarnStrategyServiceImpl extends ServiceImpl<WarnStrategyMapper, War
|
||||||
@Autowired
|
@Autowired
|
||||||
private WarnStrategyMapper warnStrategyMapper;
|
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
|
@Override
|
||||||
public List<WarnVehicleResp> ruleStrategyList(WarnVehicleReq warnVehicleReq) {
|
public List<WarnVehicleResp> selectList(WarnVehicleReq req) {
|
||||||
MPJLambdaWrapper<WarnStrategy> wrapper = new MPJLambdaWrapper<>();
|
MPJLambdaWrapper<WarnStrategy> wrapper = new MPJLambdaWrapper<>();
|
||||||
wrapper.selectAll(WarnStrategy.class)
|
wrapper.selectAll(WarnStrategy.class)
|
||||||
.selectAs(VehicleType::getVehicleTypeName,WarnVehicleResp::getVehicleTypeName)
|
.selectAs(VehicleType::getVehicleTypeName,WarnVehicleResp::getVehicleTypeName)
|
||||||
|
.selectAs(MessageTemplate::getMessageTemplateName,WarnVehicleResp::getMessageTemplateName)
|
||||||
.leftJoin(VehicleType.class, VehicleType::getVehicleTypeId,WarnStrategy::getVehicleTypeId)
|
.leftJoin(VehicleType.class, VehicleType::getVehicleTypeId,WarnStrategy::getVehicleTypeId)
|
||||||
|
.leftJoin(MessageTemplate.class, MessageTemplate::getMessageTemplateId,WarnStrategy::getMessageTemplateId)
|
||||||
.like(
|
.like(
|
||||||
StringUtils.isNotEmpty(warnVehicleReq.getStrategyName()),
|
StringUtils.isNotEmpty(req.getStrategyName()),
|
||||||
WarnStrategy::getStrategyName,warnVehicleReq.getStrategyName()
|
WarnStrategy::getStrategyName,req.getStrategyName()
|
||||||
);
|
);
|
||||||
List<WarnVehicleResp> list = warnStrategyMapper.selectJoinList(WarnVehicleResp.class, wrapper);
|
List<WarnVehicleResp> list = warnStrategyMapper.selectJoinList(WarnVehicleResp.class, wrapper);
|
||||||
return list;
|
return list;
|
||||||
|
|
Loading…
Reference in New Issue