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