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