feat:()修改代码方法

dev.redis
sy200 2024-10-06 21:20:41 +08:00
parent 0be090d11b
commit a00e5345b4
14 changed files with 66 additions and 31 deletions

View File

@ -63,4 +63,5 @@ public class LoginUser implements Serializable {
*/
private SysUser sysUser;
}

View File

@ -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() {

View File

@ -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())

View File

@ -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())

View File

@ -26,5 +26,5 @@ public class BoundFenceGroupReq {
/**
* Ids
*/
private List<Long> fenceGroupIds;
private Long[] fenceGroupIds;
}

View File

@ -23,4 +23,7 @@ public class WarnVehicleReq {
@Excel(name = "策略名称")
private String strategyName;
}

View File

@ -175,4 +175,5 @@ public class VehicleController extends BaseController {
Long templateId = vehicleService.findByVehicleVin(vehicleVin);
return Result.success(templateId);
}
}

View File

@ -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));
// }
/**
*

View File

@ -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);

View File

@ -38,4 +38,5 @@ public interface VehicleService extends IService<Vehicle> {
*
*/
void boundFenceGroup(BoundFenceGroupReq boundFenceGroupReq);
}

View File

@ -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);
}

View File

@ -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) {

View File

@ -73,7 +73,6 @@ public class VehicleServiceImpl
@Override
public void boundFenceGroup(BoundFenceGroupReq boundFenceGroupReq) {
vehicleMapper.boundFenceGroup(boundFenceGroupReq);
}

View File

@ -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;