From ba3361da94ac46fc2f35a3bf3adfa76d76a922b6 Mon Sep 17 00:00:00 2001
From: chentaisen <14615430+chentaisen@user.noreply.gitee.com>
Date: Mon, 23 Sep 2024 09:56:19 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BA=8C=E6=AC=A1=E6=9B=B4=E6=94=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../cloud-warn-common/pom.xml | 6 +-
.../com/muyu/warning/domain/WarnRuleDTO.java | 59 +++++++++++++++++
.../cloud-warn-server/pom.xml | 11 +++-
.../controller/WarnRuleController.java | 35 ++++++-----
.../muyu/warning/mapper/WarnRuleMapper.java | 4 +-
.../warning/service/IWarnRuleService.java | 5 +-
.../service/impl/WarnRuleServiceImpl.java | 63 ++++++++++++++-----
7 files changed, 147 insertions(+), 36 deletions(-)
create mode 100644 cloud-modules/cloud-modules-warn/cloud-warn-common/src/main/java/com/muyu/warning/domain/WarnRuleDTO.java
diff --git a/cloud-modules/cloud-modules-warn/cloud-warn-common/pom.xml b/cloud-modules/cloud-modules-warn/cloud-warn-common/pom.xml
index fa7ca2f..809ecc3 100644
--- a/cloud-modules/cloud-modules-warn/cloud-warn-common/pom.xml
+++ b/cloud-modules/cloud-modules-warn/cloud-warn-common/pom.xml
@@ -129,6 +129,10 @@
fastjson2
2.0.43
-
+
+
+
+
+
diff --git a/cloud-modules/cloud-modules-warn/cloud-warn-common/src/main/java/com/muyu/warning/domain/WarnRuleDTO.java b/cloud-modules/cloud-modules-warn/cloud-warn-common/src/main/java/com/muyu/warning/domain/WarnRuleDTO.java
new file mode 100644
index 0000000..e908257
--- /dev/null
+++ b/cloud-modules/cloud-modules-warn/cloud-warn-common/src/main/java/com/muyu/warning/domain/WarnRuleDTO.java
@@ -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;
+}
diff --git a/cloud-modules/cloud-modules-warn/cloud-warn-server/pom.xml b/cloud-modules/cloud-modules-warn/cloud-warn-server/pom.xml
index 13b8bbc..cb5da5d 100644
--- a/cloud-modules/cloud-modules-warn/cloud-warn-server/pom.xml
+++ b/cloud-modules/cloud-modules-warn/cloud-warn-server/pom.xml
@@ -22,7 +22,16 @@
cloud-warn-common
3.6.3
-
+
+
+
+
+
+
+ com.github.yulichang
+ mybatis-plus-join-boot-starter
+ 1.4.11
+
com.squareup.okhttp3
okhttp
diff --git a/cloud-modules/cloud-modules-warn/cloud-warn-server/src/main/java/com/muyu/warning/controller/WarnRuleController.java b/cloud-modules/cloud-modules-warn/cloud-warn-server/src/main/java/com/muyu/warning/controller/WarnRuleController.java
index 35253eb..20e7798 100644
--- a/cloud-modules/cloud-modules-warn/cloud-warn-server/src/main/java/com/muyu/warning/controller/WarnRuleController.java
+++ b/cloud-modules/cloud-modules-warn/cloud-warn-server/src/main/java/com/muyu/warning/controller/WarnRuleController.java
@@ -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> list(WarnRule warnRule)
- {
+ public Result> list(WarnRule warnRule) {
startPage();
List list = warnRuleService.selectWarnRuleList(warnRule);
+// MPJLambdaQueryWrapper 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 list = warnRuleService.selectWarnRuleList(warnRule);
ExcelUtil util = new ExcelUtil(WarnRule.class);
util.exportExcel(response, list, "预警规则数据");
@@ -63,8 +72,7 @@ public class WarnRuleController extends BaseController
*/
@RequiresPermissions("warning:query")
@GetMapping(value = "/{id}")
- public Result> getInfo(@PathVariable("id") Long id)
- {
+ public Result> 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 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 edit(
- @Validated @RequestBody WarnRule warnRule)
- {
+ @Validated @RequestBody WarnRule warnRule) {
if (!warnRuleService.checkIdUnique(warnRule)) {
return error("修改 预警规则 '" + warnRule + "'失败,预警规则不存在");
}
@@ -100,9 +106,8 @@ public class WarnRuleController extends BaseController
* 删除预警规则
*/
@RequiresPermissions("warning:remove")
- @DeleteMapping("/{ids}")
- public Result remove(@PathVariable("ids") Long[] ids)
- {
+ @DeleteMapping("/{ids}")
+ public Result remove(@PathVariable("ids") Long[] ids) {
warnRuleService.removeBatchByIds(Arrays.asList(ids));
return success();
}
diff --git a/cloud-modules/cloud-modules-warn/cloud-warn-server/src/main/java/com/muyu/warning/mapper/WarnRuleMapper.java b/cloud-modules/cloud-modules-warn/cloud-warn-server/src/main/java/com/muyu/warning/mapper/WarnRuleMapper.java
index 58b7caf..e190368 100644
--- a/cloud-modules/cloud-modules-warn/cloud-warn-server/src/main/java/com/muyu/warning/mapper/WarnRuleMapper.java
+++ b/cloud-modules/cloud-modules-warn/cloud-warn-server/src/main/java/com/muyu/warning/mapper/WarnRuleMapper.java
@@ -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{
+public interface WarnRuleMapper extends MPJBaseMapper {
}
diff --git a/cloud-modules/cloud-modules-warn/cloud-warn-server/src/main/java/com/muyu/warning/service/IWarnRuleService.java b/cloud-modules/cloud-modules-warn/cloud-warn-server/src/main/java/com/muyu/warning/service/IWarnRuleService.java
index fa61ff5..08664d6 100644
--- a/cloud-modules/cloud-modules-warn/cloud-warn-server/src/main/java/com/muyu/warning/service/IWarnRuleService.java
+++ b/cloud-modules/cloud-modules-warn/cloud-warn-server/src/main/java/com/muyu/warning/service/IWarnRuleService.java
@@ -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 {
+public interface IWarnRuleService extends MPJBaseService {
/**
* 精确查询预警规则
*
diff --git a/cloud-modules/cloud-modules-warn/cloud-warn-server/src/main/java/com/muyu/warning/service/impl/WarnRuleServiceImpl.java b/cloud-modules/cloud-modules-warn/cloud-warn-server/src/main/java/com/muyu/warning/service/impl/WarnRuleServiceImpl.java
index 1e16c8f..766bdb7 100644
--- a/cloud-modules/cloud-modules-warn/cloud-warn-server/src/main/java/com/muyu/warning/service/impl/WarnRuleServiceImpl.java
+++ b/cloud-modules/cloud-modules-warn/cloud-warn-server/src/main/java/com/muyu/warning/service/impl/WarnRuleServiceImpl.java
@@ -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
+ extends MPJBaseServiceImpl
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 queryWrapper = new LambdaQueryWrapper<>();
Assert.notNull(id, "id不可为空");
queryWrapper.eq(WarnRule::getId, id);
@@ -45,38 +55,57 @@ public class WarnRuleServiceImpl
* @return 预警规则
*/
@Override
- public List selectWarnRuleList(WarnRule warnRule)
- {
+ public List selectWarnRuleList(WarnRule warnRule) {
+
+// MPJLambdaWrapper queryWrapper = new MPJLambdaWrapper()
+// .selectAll(WarnRule.class)
+// .select(WarnStrategy::getStrategyName)
+// .selectAs(WarnStrategy::getStrategyName, WarnRule::getStrategyName);
+// List list = warnRuleMapper.selectJoinList(WarnRule.class, queryWrapper);
+// return list;
+// MPJLambdaWrapper 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 queryWrapper = new MPJQueryWrapper<>();
+// if (StringUtils.isNotEmpty(warnRule.getRuleName())) {
+//// queryWrapper.like(WarnRule::getRuleName, warnRule.getRuleName());
+// queryWrapper.like("rule_name", warnRule.getRuleName());
+// }
+//
+
LambdaQueryWrapper 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 预警规则
+ * 唯一 判断
+ *
+ * @param warnRule 预警规则
* @return 预警规则
- */
+ */
@Override
public Boolean checkIdUnique(WarnRule warnRule) {
LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>();