二次更改
parent
111be4af5f
commit
e8cd683a0b
|
@ -129,6 +129,10 @@
|
|||
<artifactId>fastjson2</artifactId>
|
||||
<version>2.0.43</version>
|
||||
</dependency>
|
||||
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>com.github.yulichang</groupId>-->
|
||||
<!-- <artifactId>mybatis-plus-join-boot-starter</artifactId>-->
|
||||
<!-- <version>1.4.11</version>-->
|
||||
<!-- </dependency>-->
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
|
@ -0,0 +1,59 @@
|
|||
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.Data;
|
||||
|
||||
/**
|
||||
* @ClassName WarnRule
|
||||
* @Description 描述
|
||||
* @Author Chen
|
||||
* @Date 2024/9/22 11:53
|
||||
*/
|
||||
@Data
|
||||
public class WarnRuleDTO {
|
||||
/** 规则id */
|
||||
@TableId( type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/** 规则名称 */
|
||||
@Excel(name = "规则名称")
|
||||
private String ruleName;
|
||||
|
||||
/** 策略id */
|
||||
@Excel(name = "策略id")
|
||||
private Long strategyId;
|
||||
|
||||
/** 报文数据类型id */
|
||||
@Excel(name = "报文数据类型id")
|
||||
private Long msgTypeId;
|
||||
|
||||
/** 滑窗时间 */
|
||||
@Excel(name = "滑窗时间")
|
||||
private Long slideTime;
|
||||
|
||||
/** 滑窗频率 */
|
||||
@Excel(name = "滑窗频率")
|
||||
private Long slideFrequency;
|
||||
|
||||
/** 最大值 */
|
||||
@Excel(name = "最大值")
|
||||
private Long maxValue;
|
||||
|
||||
/** 最小值 */
|
||||
@Excel(name = "最小值")
|
||||
private Long minValue;
|
||||
|
||||
/** 车辆类型id */
|
||||
@Excel(name = "车辆类型id")
|
||||
private Long carTypeId;
|
||||
|
||||
/** 策略名称 */
|
||||
@Excel(name = "策略名称")
|
||||
private String strategyName;
|
||||
|
||||
/** 报文模版id */
|
||||
@Excel(name = "报文模版id")
|
||||
private Long msgId;
|
||||
}
|
|
@ -22,7 +22,16 @@
|
|||
<artifactId>cloud-warn-common</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</dependency>
|
||||
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>com.github.yulichang</groupId>-->
|
||||
<!-- <artifactId>mybatis-plus-join</artifactId>-->
|
||||
<!-- <version>1.2.4</version>-->
|
||||
<!-- </dependency>-->
|
||||
<dependency>
|
||||
<groupId>com.github.yulichang</groupId>
|
||||
<artifactId>mybatis-plus-join-boot-starter</artifactId>
|
||||
<version>1.4.11</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.squareup.okhttp3</groupId>
|
||||
<artifactId>okhttp</artifactId>
|
||||
|
|
|
@ -2,8 +2,15 @@ package com.muyu.warning.controller;
|
|||
|
||||
import java.util.Arrays;
|
||||
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.WarnStrategy;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
|
@ -29,8 +36,7 @@ import com.muyu.common.core.web.page.TableDataInfo;
|
|||
*/
|
||||
@RestController
|
||||
@RequestMapping("/rule")
|
||||
public class WarnRuleController extends BaseController
|
||||
{
|
||||
public class WarnRuleController extends BaseController {
|
||||
@Resource
|
||||
private IWarnRuleService warnRuleService;
|
||||
|
||||
|
@ -39,10 +45,14 @@ public class WarnRuleController extends BaseController
|
|||
*/
|
||||
@RequiresPermissions("warning:list")
|
||||
@GetMapping("/list")
|
||||
public Result<TableDataInfo<WarnRule>> list(WarnRule warnRule)
|
||||
{
|
||||
public Result<TableDataInfo<WarnRule>> list(WarnRule warnRule) {
|
||||
startPage();
|
||||
List<WarnRule> list = warnRuleService.selectWarnRuleList(warnRule);
|
||||
// MPJLambdaQueryWrapper<WarnRule> objectMPJLambdaQueryWrapper = new MPJLambdaQueryWrapper<>()
|
||||
// .selectAll(WarnRule.class)
|
||||
// .select(WarnStrategy::getStrategyName)
|
||||
// .leftJoin(WarnStrategy.class, WarnStrategy::getId, WarnRule::getStrategyId)
|
||||
// .stringQuery();
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
|
@ -51,8 +61,7 @@ public class WarnRuleController extends BaseController
|
|||
*/
|
||||
@RequiresPermissions("warning:export")
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, WarnRule warnRule)
|
||||
{
|
||||
public void export(HttpServletResponse response, WarnRule warnRule) {
|
||||
List<WarnRule> list = warnRuleService.selectWarnRuleList(warnRule);
|
||||
ExcelUtil<WarnRule> util = new ExcelUtil<WarnRule>(WarnRule.class);
|
||||
util.exportExcel(response, list, "预警规则数据");
|
||||
|
@ -63,8 +72,7 @@ public class WarnRuleController extends BaseController
|
|||
*/
|
||||
@RequiresPermissions("warning:query")
|
||||
@GetMapping(value = "/{id}")
|
||||
public Result<List<WarnRule>> getInfo(@PathVariable("id") Long id)
|
||||
{
|
||||
public Result<List<WarnRule>> getInfo(@PathVariable("id") Long id) {
|
||||
return success(warnRuleService.selectWarnRuleById(id));
|
||||
}
|
||||
|
||||
|
@ -74,8 +82,7 @@ public class WarnRuleController extends BaseController
|
|||
@RequiresPermissions("warning:add")
|
||||
@PostMapping
|
||||
public Result<Integer> add(
|
||||
@Validated @RequestBody WarnRule warnRule)
|
||||
{
|
||||
@Validated @RequestBody WarnRule warnRule) {
|
||||
if (warnRuleService.checkIdUnique(warnRule)) {
|
||||
return error("新增 预警规则 '" + warnRule + "'失败,预警规则已存在");
|
||||
}
|
||||
|
@ -88,8 +95,7 @@ public class WarnRuleController extends BaseController
|
|||
@RequiresPermissions("warning:edit")
|
||||
@PutMapping
|
||||
public Result<Integer> edit(
|
||||
@Validated @RequestBody WarnRule warnRule)
|
||||
{
|
||||
@Validated @RequestBody WarnRule warnRule) {
|
||||
if (!warnRuleService.checkIdUnique(warnRule)) {
|
||||
return error("修改 预警规则 '" + warnRule + "'失败,预警规则不存在");
|
||||
}
|
||||
|
@ -101,8 +107,7 @@ public class WarnRuleController extends BaseController
|
|||
*/
|
||||
@RequiresPermissions("warning:remove")
|
||||
@DeleteMapping("/{ids}")
|
||||
public Result<Integer> remove(@PathVariable("ids") Long[] ids)
|
||||
{
|
||||
public Result<Integer> remove(@PathVariable("ids") Long[] ids) {
|
||||
warnRuleService.removeBatchByIds(Arrays.asList(ids));
|
||||
return success();
|
||||
}
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
package com.muyu.warning.mapper;
|
||||
|
||||
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 org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
|
@ -11,6 +13,6 @@ import org.apache.ibatis.annotations.Mapper;
|
|||
* @date 2024-09-20
|
||||
*/
|
||||
@Mapper
|
||||
public interface WarnRuleMapper extends BaseMapper<WarnRule>{
|
||||
public interface WarnRuleMapper extends MPJBaseMapper<WarnRule> {
|
||||
|
||||
}
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
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;
|
||||
|
||||
/**
|
||||
* 预警规则Service接口
|
||||
|
@ -10,7 +13,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
|||
* @author muyu
|
||||
* @date 2024-09-20
|
||||
*/
|
||||
public interface IWarnRuleService extends IService<WarnRule> {
|
||||
public interface IWarnRuleService extends MPJBaseService<WarnRule> {
|
||||
/**
|
||||
* 精确查询预警规则
|
||||
*
|
||||
|
|
|
@ -2,7 +2,16 @@ 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;
|
||||
|
@ -19,8 +28,10 @@ import org.springframework.util.Assert;
|
|||
*/
|
||||
@Service
|
||||
public class WarnRuleServiceImpl
|
||||
extends ServiceImpl<WarnRuleMapper, WarnRule>
|
||||
extends MPJBaseServiceImpl<WarnRuleMapper, WarnRule>
|
||||
implements IWarnRuleService {
|
||||
@Autowired
|
||||
private WarnRuleMapper warnRuleMapper;
|
||||
|
||||
/**
|
||||
* 精确查询预警规则
|
||||
|
@ -29,8 +40,7 @@ public class WarnRuleServiceImpl
|
|||
* @return 预警规则
|
||||
*/
|
||||
@Override
|
||||
public WarnRule selectWarnRuleById(Long id)
|
||||
{
|
||||
public WarnRule selectWarnRuleById(Long id) {
|
||||
LambdaQueryWrapper<WarnRule> queryWrapper = new LambdaQueryWrapper<>();
|
||||
Assert.notNull(id, "id不可为空");
|
||||
queryWrapper.eq(WarnRule::getId, id);
|
||||
|
@ -45,35 +55,54 @@ public class WarnRuleServiceImpl
|
|||
* @return 预警规则
|
||||
*/
|
||||
@Override
|
||||
public List<WarnRule> selectWarnRuleList(WarnRule warnRule)
|
||||
{
|
||||
public List<WarnRule> selectWarnRuleList(WarnRule warnRule) {
|
||||
|
||||
// MPJLambdaWrapper<WarnRule> queryWrapper = new MPJLambdaWrapper<WarnRule>()
|
||||
// .selectAll(WarnRule.class)
|
||||
// .select(WarnStrategy::getStrategyName)
|
||||
// .selectAs(WarnStrategy::getStrategyName, WarnRule::getStrategyName);
|
||||
// List<WarnRule> list = warnRuleMapper.selectJoinList(WarnRule.class, queryWrapper);
|
||||
// return list;
|
||||
// MPJLambdaWrapper<WarnRule> wrapper = JoinWrappers.lambda(WarnRule.class)
|
||||
// .selectAll(WarnRule.class)
|
||||
// .select(WarnStrategy::getStrategyName)
|
||||
// .leftJoin(WarnStrategy.class, WarnStrategy::getId, WarnRule::getId);
|
||||
// return warnRuleMapper.selectJoinList(WarnRule.class, wrapper);
|
||||
// MPJQueryWrapper<WarnRule> queryWrapper = new MPJQueryWrapper<>();
|
||||
// if (StringUtils.isNotEmpty(warnRule.getRuleName())) {
|
||||
//// queryWrapper.like(WarnRule::getRuleName, warnRule.getRuleName());
|
||||
// queryWrapper.like("rule_name", warnRule.getRuleName());
|
||||
// }
|
||||
//
|
||||
|
||||
LambdaQueryWrapper<WarnRule> queryWrapper = new LambdaQueryWrapper<>();
|
||||
if (StringUtils.isNotEmpty(warnRule.getRuleName())){
|
||||
queryWrapper.like(WarnRule::getRuleName, warnRule.getRuleName());
|
||||
}
|
||||
if (StringUtils.isNotNull(warnRule.getStrategyId())){
|
||||
if (StringUtils.isNotNull(warnRule.getStrategyId())) {
|
||||
queryWrapper.eq(WarnRule::getStrategyId, warnRule.getStrategyId());
|
||||
// queryWrapper.eq("strategy_id", warnRule.getStrategyId());
|
||||
}
|
||||
if (StringUtils.isNotNull(warnRule.getMsgTypeId())){
|
||||
if (StringUtils.isNotNull(warnRule.getMsgTypeId())) {
|
||||
queryWrapper.eq(WarnRule::getMsgTypeId, warnRule.getMsgTypeId());
|
||||
}
|
||||
if (StringUtils.isNotNull(warnRule.getSlideTime())){
|
||||
if (StringUtils.isNotNull(warnRule.getSlideTime())) {
|
||||
queryWrapper.eq(WarnRule::getSlideTime, warnRule.getSlideTime());
|
||||
}
|
||||
if (StringUtils.isNotNull(warnRule.getSlideFrequency())){
|
||||
if (StringUtils.isNotNull(warnRule.getSlideFrequency())) {
|
||||
queryWrapper.eq(WarnRule::getSlideFrequency, warnRule.getSlideFrequency());
|
||||
}
|
||||
if (StringUtils.isNotNull(warnRule.getMaxValue())){
|
||||
if (StringUtils.isNotNull(warnRule.getMaxValue())) {
|
||||
queryWrapper.eq(WarnRule::getMaxValue, warnRule.getMaxValue());
|
||||
}
|
||||
if (StringUtils.isNotNull(warnRule.getMinValue())){
|
||||
if (StringUtils.isNotNull(warnRule.getMinValue())) {
|
||||
queryWrapper.eq(WarnRule::getMinValue, warnRule.getMinValue());
|
||||
}
|
||||
return this.list(queryWrapper);
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 唯一 判断
|
||||
*
|
||||
* @param warnRule 预警规则
|
||||
* @return 预警规则
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue