二次更改
parent
f4cd9174e2
commit
9d0cbb6b8d
|
@ -3,7 +3,9 @@ package com.muyu.warning.domain;
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import com.muyu.common.core.annotation.Excel;
|
import com.muyu.common.core.annotation.Excel;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ClassName WarnRule
|
* @ClassName WarnRule
|
||||||
|
@ -12,6 +14,8 @@ import lombok.Data;
|
||||||
* @Date 2024/9/22 11:53
|
* @Date 2024/9/22 11:53
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
public class WarnRuleDTO {
|
public class WarnRuleDTO {
|
||||||
/** 规则id */
|
/** 规则id */
|
||||||
@TableId( type = IdType.AUTO)
|
@TableId( type = IdType.AUTO)
|
||||||
|
|
|
@ -6,6 +6,7 @@ import java.util.List;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.github.yulichang.query.MPJLambdaQueryWrapper;
|
import com.github.yulichang.query.MPJLambdaQueryWrapper;
|
||||||
import com.muyu.warning.domain.WarnRule;
|
import com.muyu.warning.domain.WarnRule;
|
||||||
|
import com.muyu.warning.domain.WarnRuleDTO;
|
||||||
import com.muyu.warning.domain.WarnStrategy;
|
import com.muyu.warning.domain.WarnStrategy;
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
|
@ -45,9 +46,9 @@ public class WarnRuleController extends BaseController {
|
||||||
*/
|
*/
|
||||||
@RequiresPermissions("warning:list")
|
@RequiresPermissions("warning:list")
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
public Result<TableDataInfo<WarnRule>> list(WarnRule warnRule) {
|
public Result<TableDataInfo<WarnRuleDTO>> list(WarnRuleDTO warnRuleDTO) {
|
||||||
startPage();
|
startPage();
|
||||||
List<WarnRule> list = warnRuleService.selectWarnRuleList(warnRule);
|
List<WarnRuleDTO> list = warnRuleService.selectWarnRuleList(warnRuleDTO);
|
||||||
// MPJLambdaQueryWrapper<WarnRule> objectMPJLambdaQueryWrapper = new MPJLambdaQueryWrapper<>()
|
// MPJLambdaQueryWrapper<WarnRule> objectMPJLambdaQueryWrapper = new MPJLambdaQueryWrapper<>()
|
||||||
// .selectAll(WarnRule.class)
|
// .selectAll(WarnRule.class)
|
||||||
// .select(WarnStrategy::getStrategyName)
|
// .select(WarnStrategy::getStrategyName)
|
||||||
|
@ -61,9 +62,9 @@ public class WarnRuleController extends BaseController {
|
||||||
*/
|
*/
|
||||||
@RequiresPermissions("warning:export")
|
@RequiresPermissions("warning:export")
|
||||||
@PostMapping("/export")
|
@PostMapping("/export")
|
||||||
public void export(HttpServletResponse response, WarnRule warnRule) {
|
public void export(HttpServletResponse response, WarnRuleDTO warnRuleDTO) {
|
||||||
List<WarnRule> list = warnRuleService.selectWarnRuleList(warnRule);
|
List<WarnRuleDTO> list = warnRuleService.selectWarnRuleList(warnRuleDTO);
|
||||||
ExcelUtil<WarnRule> util = new ExcelUtil<WarnRule>(WarnRule.class);
|
ExcelUtil<WarnRuleDTO> util = new ExcelUtil<WarnRuleDTO>(WarnRuleDTO.class);
|
||||||
util.exportExcel(response, list, "预警规则数据");
|
util.exportExcel(response, list, "预警规则数据");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,11 +83,11 @@ public class WarnRuleController extends BaseController {
|
||||||
@RequiresPermissions("warning:add")
|
@RequiresPermissions("warning:add")
|
||||||
@PostMapping
|
@PostMapping
|
||||||
public Result<Integer> add(
|
public Result<Integer> add(
|
||||||
@Validated @RequestBody WarnRule warnRule) {
|
@Validated @RequestBody WarnRuleDTO warnRuleDTO) {
|
||||||
if (warnRuleService.checkIdUnique(warnRule)) {
|
if (warnRuleService.checkIdUnique(warnRuleDTO)) {
|
||||||
return error("新增 预警规则 '" + warnRule + "'失败,预警规则已存在");
|
return error("新增 预警规则 '" + warnRuleDTO + "'失败,预警规则已存在");
|
||||||
}
|
}
|
||||||
return toAjax(warnRuleService.save(warnRule));
|
return toAjax(warnRuleService.save(warnRuleDTO));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -95,11 +96,11 @@ public class WarnRuleController extends BaseController {
|
||||||
@RequiresPermissions("warning:edit")
|
@RequiresPermissions("warning:edit")
|
||||||
@PutMapping
|
@PutMapping
|
||||||
public Result<Integer> edit(
|
public Result<Integer> edit(
|
||||||
@Validated @RequestBody WarnRule warnRule) {
|
@Validated @RequestBody WarnRuleDTO warnRuleDTO) {
|
||||||
if (!warnRuleService.checkIdUnique(warnRule)) {
|
if (!warnRuleService.checkIdUnique(warnRuleDTO)) {
|
||||||
return error("修改 预警规则 '" + warnRule + "'失败,预警规则不存在");
|
return error("修改 预警规则 '" + warnRuleDTO + "'失败,预警规则不存在");
|
||||||
}
|
}
|
||||||
return toAjax(warnRuleService.updateById(warnRule));
|
return toAjax(warnRuleService.updateById(warnRuleDTO));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -35,6 +35,12 @@ public class WarnRulesController {
|
||||||
return Result.success(list);
|
return Result.success(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 联查
|
||||||
|
*
|
||||||
|
* @param warnRuleDTO
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
@PostMapping("/listAll")
|
@PostMapping("/listAll")
|
||||||
public Result<List<WarnRuleDTO>> listAll(WarnRuleDTO warnRuleDTO) {
|
public Result<List<WarnRuleDTO>> listAll(WarnRuleDTO warnRuleDTO) {
|
||||||
List<WarnRuleDTO> list = warnRulesService.selectWarnRulesListAll(warnRuleDTO);
|
List<WarnRuleDTO> list = warnRulesService.selectWarnRulesListAll(warnRuleDTO);
|
||||||
|
|
|
@ -4,6 +4,7 @@ import com.github.yulichang.base.MPJBaseMapper;
|
||||||
import com.muyu.warning.domain.WarnRule;
|
import com.muyu.warning.domain.WarnRule;
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import com.muyu.warning.domain.WarnRule;
|
import com.muyu.warning.domain.WarnRule;
|
||||||
|
import com.muyu.warning.domain.WarnRuleDTO;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -13,6 +14,6 @@ import org.apache.ibatis.annotations.Mapper;
|
||||||
* @date 2024-09-20
|
* @date 2024-09-20
|
||||||
*/
|
*/
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface WarnRuleMapper extends MPJBaseMapper<WarnRule> {
|
public interface WarnRuleMapper extends BaseMapper<WarnRuleDTO> {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@ import java.util.List;
|
||||||
*/
|
*/
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface WarnRulesMapper extends BaseMapper<WarnRuleDTO> {
|
public interface WarnRulesMapper extends BaseMapper<WarnRuleDTO> {
|
||||||
@Select("select r.*,s.strategy_name FROM warn_rule r left join warn_strategy s on r.strategy_id=s.id")
|
@Select("select r.*,s.id,s.strategy_name FROM warn_rule r left join warn_strategy s on r.strategy_id=s.id where r.strategy_id = #{s.id}")
|
||||||
List<WarnRuleDTO> selectWarnRulesListAll(WarnRuleDTO warnRuleDTO);
|
List<WarnRuleDTO> selectWarnRulesListAll(WarnRuleDTO warnRuleDTO);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ import java.util.List;
|
||||||
|
|
||||||
public interface IWarRulesService extends IService<WarnRuleDTO> {
|
public interface IWarRulesService extends IService<WarnRuleDTO> {
|
||||||
List<WarnRuleDTO> selectWarnRulesList();
|
List<WarnRuleDTO> selectWarnRulesList();
|
||||||
|
//联查
|
||||||
List<WarnRuleDTO> selectWarnRulesListAll(WarnRuleDTO warnRuleDTO);
|
List<WarnRuleDTO> selectWarnRulesListAll(WarnRuleDTO warnRuleDTO);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
package com.muyu.warning.service;
|
package com.muyu.warning.service;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import com.github.yulichang.base.MPJBaseService;
|
|
||||||
import com.muyu.warning.domain.WarnRule;
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import com.muyu.warning.domain.WarnRule;
|
import com.github.yulichang.base.MPJBaseService;
|
||||||
|
import com.muyu.warning.domain.WarnRuleDTO;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 预警规则Service接口
|
* 预警规则Service接口
|
||||||
|
@ -13,28 +12,28 @@ import com.muyu.warning.domain.WarnRule;
|
||||||
* @author muyu
|
* @author muyu
|
||||||
* @date 2024-09-20
|
* @date 2024-09-20
|
||||||
*/
|
*/
|
||||||
public interface IWarnRuleService extends MPJBaseService<WarnRule> {
|
public interface IWarnRuleService extends IService<WarnRuleDTO> {
|
||||||
/**
|
/**
|
||||||
* 精确查询预警规则
|
* 精确查询预警规则
|
||||||
*
|
*
|
||||||
* @param id 预警规则主键
|
* @param id 预警规则主键
|
||||||
* @return 预警规则
|
* @return 预警规则
|
||||||
*/
|
*/
|
||||||
public WarnRule selectWarnRuleById(Long id);
|
public WarnRuleDTO selectWarnRuleById(Long id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询预警规则列表
|
* 查询预警规则列表
|
||||||
*
|
*
|
||||||
* @param warnRule 预警规则
|
* @param warnRuleDTO 预警规则
|
||||||
* @return 预警规则集合
|
* @return 预警规则集合
|
||||||
*/
|
*/
|
||||||
public List<WarnRule> selectWarnRuleList(WarnRule warnRule);
|
public List<WarnRuleDTO> selectWarnRuleList(WarnRuleDTO warnRuleDTO);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 判断 预警规则 id是否唯一
|
* 判断 预警规则 id是否唯一
|
||||||
* @param warnRule 预警规则
|
* @param warnRuleDTO 预警规则
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
Boolean checkIdUnique(WarnRule warnRule);
|
Boolean checkIdUnique(WarnRuleDTO warnRuleDTO);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,25 +1,18 @@
|
||||||
package com.muyu.warning.service.impl;
|
package com.muyu.warning.service.impl;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import com.github.yulichang.base.MPJBaseServiceImpl;
|
|
||||||
import com.github.yulichang.query.MPJLambdaQueryWrapper;
|
|
||||||
import com.github.yulichang.query.MPJQueryWrapper;
|
|
||||||
import com.github.yulichang.toolkit.JoinWrappers;
|
|
||||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
|
||||||
import com.muyu.warning.domain.WarnLogs;
|
|
||||||
import com.muyu.warning.domain.WarnRule;
|
|
||||||
import com.muyu.warning.domain.WarnStrategy;
|
|
||||||
import com.muyu.warning.mapper.WarnRuleMapper;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
import com.muyu.warning.domain.WarnRule;
|
|
||||||
import com.muyu.warning.service.IWarnRuleService;
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.github.yulichang.base.MPJBaseServiceImpl;
|
||||||
import com.muyu.common.core.utils.StringUtils;
|
import com.muyu.common.core.utils.StringUtils;
|
||||||
|
import com.muyu.warning.domain.WarnRuleDTO;
|
||||||
|
import com.muyu.warning.mapper.WarnRuleMapper;
|
||||||
|
import com.muyu.warning.service.IWarnRuleService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 预警规则Service业务层处理
|
* 预警规则Service业务层处理
|
||||||
*
|
*
|
||||||
|
@ -28,10 +21,9 @@ import org.springframework.util.Assert;
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class WarnRuleServiceImpl
|
public class WarnRuleServiceImpl
|
||||||
extends MPJBaseServiceImpl<WarnRuleMapper, WarnRule>
|
extends ServiceImpl<WarnRuleMapper, WarnRuleDTO>
|
||||||
implements IWarnRuleService {
|
implements IWarnRuleService {
|
||||||
@Autowired
|
|
||||||
private WarnRuleMapper warnRuleMapper;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 精确查询预警规则
|
* 精确查询预警规则
|
||||||
|
@ -40,10 +32,10 @@ public class WarnRuleServiceImpl
|
||||||
* @return 预警规则
|
* @return 预警规则
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public WarnRule selectWarnRuleById(Long id) {
|
public WarnRuleDTO selectWarnRuleById(Long id) {
|
||||||
LambdaQueryWrapper<WarnRule> queryWrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<WarnRuleDTO> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
Assert.notNull(id, "id不可为空");
|
Assert.notNull(id, "id不可为空");
|
||||||
queryWrapper.eq(WarnRule::getId, id);
|
queryWrapper.eq(WarnRuleDTO::getId, id);
|
||||||
return this.getOne(queryWrapper);
|
return this.getOne(queryWrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,11 +43,11 @@ public class WarnRuleServiceImpl
|
||||||
/**
|
/**
|
||||||
* 查询预警规则列表
|
* 查询预警规则列表
|
||||||
*
|
*
|
||||||
* @param warnRule 预警规则
|
* @param warnRuleDTO 预警规则
|
||||||
* @return 预警规则
|
* @return 预警规则
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<WarnRule> selectWarnRuleList(WarnRule warnRule) {
|
public List<WarnRuleDTO> selectWarnRuleList(WarnRuleDTO warnRuleDTO) {
|
||||||
|
|
||||||
// MPJLambdaWrapper<WarnRule> queryWrapper = new MPJLambdaWrapper<WarnRule>()
|
// MPJLambdaWrapper<WarnRule> queryWrapper = new MPJLambdaWrapper<WarnRule>()
|
||||||
// .selectAll(WarnRule.class)
|
// .selectAll(WarnRule.class)
|
||||||
|
@ -75,25 +67,25 @@ public class WarnRuleServiceImpl
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
|
|
||||||
LambdaQueryWrapper<WarnRule> queryWrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<WarnRuleDTO> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
if (StringUtils.isNotNull(warnRule.getStrategyId())) {
|
if (StringUtils.isNotNull(warnRuleDTO.getStrategyId())) {
|
||||||
queryWrapper.eq(WarnRule::getStrategyId, warnRule.getStrategyId());
|
queryWrapper.eq(WarnRuleDTO::getStrategyId, warnRuleDTO.getStrategyId());
|
||||||
// queryWrapper.eq("strategy_id", warnRule.getStrategyId());
|
// queryWrapper.eq("strategy_id", warnRule.getStrategyId());
|
||||||
}
|
}
|
||||||
if (StringUtils.isNotNull(warnRule.getMsgTypeId())) {
|
if (StringUtils.isNotNull(warnRuleDTO.getMsgTypeId())) {
|
||||||
queryWrapper.eq(WarnRule::getMsgTypeId, warnRule.getMsgTypeId());
|
queryWrapper.eq(WarnRuleDTO::getMsgTypeId, warnRuleDTO.getMsgTypeId());
|
||||||
}
|
}
|
||||||
if (StringUtils.isNotNull(warnRule.getSlideTime())) {
|
if (StringUtils.isNotNull(warnRuleDTO.getSlideTime())) {
|
||||||
queryWrapper.eq(WarnRule::getSlideTime, warnRule.getSlideTime());
|
queryWrapper.eq(WarnRuleDTO::getSlideTime, warnRuleDTO.getSlideTime());
|
||||||
}
|
}
|
||||||
if (StringUtils.isNotNull(warnRule.getSlideFrequency())) {
|
if (StringUtils.isNotNull(warnRuleDTO.getSlideFrequency())) {
|
||||||
queryWrapper.eq(WarnRule::getSlideFrequency, warnRule.getSlideFrequency());
|
queryWrapper.eq(WarnRuleDTO::getSlideFrequency, warnRuleDTO.getSlideFrequency());
|
||||||
}
|
}
|
||||||
if (StringUtils.isNotNull(warnRule.getMaxValue())) {
|
if (StringUtils.isNotNull(warnRuleDTO.getMaxValue())) {
|
||||||
queryWrapper.eq(WarnRule::getMaxValue, warnRule.getMaxValue());
|
queryWrapper.eq(WarnRuleDTO::getMaxValue, warnRuleDTO.getMaxValue());
|
||||||
}
|
}
|
||||||
if (StringUtils.isNotNull(warnRule.getMinValue())) {
|
if (StringUtils.isNotNull(warnRuleDTO.getMinValue())) {
|
||||||
queryWrapper.eq(WarnRule::getMinValue, warnRule.getMinValue());
|
queryWrapper.eq(WarnRuleDTO::getMinValue, warnRuleDTO.getMinValue());
|
||||||
}
|
}
|
||||||
return this.list(queryWrapper);
|
return this.list(queryWrapper);
|
||||||
|
|
||||||
|
@ -103,13 +95,13 @@ public class WarnRuleServiceImpl
|
||||||
/**
|
/**
|
||||||
* 唯一 判断
|
* 唯一 判断
|
||||||
*
|
*
|
||||||
* @param warnRule 预警规则
|
* @param warnRuleDTO 预警规则
|
||||||
* @return 预警规则
|
* @return 预警规则
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Boolean checkIdUnique(WarnRule warnRule) {
|
public Boolean checkIdUnique(WarnRuleDTO warnRuleDTO) {
|
||||||
LambdaQueryWrapper<WarnRule> queryWrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<WarnRuleDTO> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
queryWrapper.eq(WarnRule::getId, warnRule.getId());
|
queryWrapper.eq(WarnRuleDTO::getId, warnRuleDTO.getId());
|
||||||
return this.count(queryWrapper) > 0;
|
return this.count(queryWrapper) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,6 @@ public class WarnRulesServiceImpl
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<WarnRuleDTO> selectWarnRulesListAll(WarnRuleDTO warnRuleDTO) {
|
public List<WarnRuleDTO> selectWarnRulesListAll(WarnRuleDTO warnRuleDTO) {
|
||||||
warnRuleDTO.setStrategyId(warnRuleDTO.getId());
|
|
||||||
List<WarnRuleDTO> list = warnRulesMapper.selectWarnRulesListAll(warnRuleDTO);
|
List<WarnRuleDTO> list = warnRulesMapper.selectWarnRulesListAll(warnRuleDTO);
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue