Explorar el Código

feat(alarm): 新增预警编码枚举和预警阈值管理功能

- 添加 WarningCodeEnum 枚举类定义预警编码类型
- 创建 WarningThreshold 实体类映射预警阈值数据表
- 实现预警阈值的分页查询和列表查询接口
- 将预警阈值相关服务从 api 模块迁移到 system 模块
- 在 controller 中添加匿名访问注解支持公开查询
- 实现根据设备编码和预警编码查询单个预警值的功能
- 完善预警阈值的数据访问层和业务逻辑层实现
林仔 hace 2 meses
padre
commit
9360529274

+ 7 - 4
zk-api-service/src/main/java/com/zksy/api/controller/WarningThresholdController.java → pipe-network-service/zksy-admin/src/main/java/com/zksy/web/controller/base/alarm/WarningThresholdController.java

@@ -1,8 +1,9 @@
-package com.zksy.api.controller;
+package com.zksy.web.controller.base.alarm;
 
-import com.zksy.api.domain.WarningThreshold;
-import com.zksy.api.service.WarningThresholdService;
-import com.zksy.common.utils.AjaxResult;
+import com.zksy.base.alarm.domain.WarningThreshold;
+import com.zksy.base.alarm.service.WarningThresholdService;
+import com.zksy.common.annotation.Anonymous;
+import com.zksy.common.core.domain.AjaxResult;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiParam;
@@ -27,6 +28,7 @@ public class WarningThresholdController {
     private WarningThresholdService service;
     @GetMapping("/findByPage")
     @ApiOperation(value = "预警阈值信息查询分页")
+    @Anonymous
     public AjaxResult findByPage(@ApiParam(value = "页码", required = true)long pageNum,
                                  @ApiParam(value = "页数", required = true)long pageSize, @ApiParam(value = "设备名称", example = "反应釜A", required = false)String deviceName,
                                  @ApiParam(value = "设备编码", required = false)String deviceCode,
@@ -36,6 +38,7 @@ public class WarningThresholdController {
     }
     @GetMapping("/getWarningThresholdList")
     @ApiOperation(value = "预警阈值信息查询")
+    @Anonymous
     public AjaxResult getWarningThresholdList(@ApiParam(value = "设备名称", required = false)String deviceName,
                                               @ApiParam(value = "设备编码",  required = false)String deviceCode,
                                               @ApiParam(value = "预警类型",  allowableValues = "温度预警,压力预警,湿度预警", required = false) String warningType,

+ 21 - 0
pipe-network-service/zksy-system/src/main/java/com/zksy/base/alarm/domain/Enum/WarningCodeEnum.java

@@ -0,0 +1,21 @@
+package com.zksy.base.alarm.domain.Enum;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+/**
+ * 预警编码枚举(替代原WarningTypeEnum)
+ */
+@Getter
+@AllArgsConstructor
+public enum WarningCodeEnum {
+    SUSPENDED_SOLIDS("WARN-SUSPENDED-SOLIDS", "悬浮物预警", 40.0),
+    COD("WARN-COD", "COD预警", 30.0),
+    AMMONIA_NITROGEN("WARN-AMMONIA-NITROGEN", "氨氮预警", 20.0),
+    CONDUCTIVITY("WARN-CONDUCTIVITY", "电导率预警", 20.0),
+    PH("WARN-PH", "PH预警", 20.0);
+
+    private final String code;       // 预警编码(对应数据库)
+    private final String name;       // 预警名称
+    private final double defaultVal; // 默认阈值(数据库未配置时使用)
+}

+ 92 - 0
pipe-network-service/zksy-system/src/main/java/com/zksy/base/alarm/domain/WarningThreshold.java

@@ -0,0 +1,92 @@
+package com.zksy.base.alarm.domain;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.time.LocalDateTime;
+
+/**
+ * 预警阈值
+ * @TableName warning_threshold
+ */
+@TableName(value ="warning_threshold")
+@Data
+public class WarningThreshold implements Serializable {
+    /**
+     * 主键
+     */
+    @TableId(value = "id", type = IdType.ASSIGN_UUID)
+    @ApiModelProperty(value = "主键")
+    private String id;
+
+    /**
+     * 设备名称
+     */
+    @TableField(value = "device_name")
+    @ApiModelProperty(value = "设备名称")
+    private String deviceName;
+
+    /**
+     * 设备编码
+     */
+    @TableField(value = "device_code")
+    @ApiModelProperty(value = "设备编码")
+    private String deviceCode;
+
+    /**
+     * 设备类型
+     */
+    @TableField(value = "device_type")
+    @ApiModelProperty(value = "设备类型")
+    private String deviceType;
+
+    /**
+     * 预警类型
+     */
+    @TableField(value = "warning_type")
+    @ApiModelProperty(value = "预警类型")
+    private String warningType;
+
+    /**
+     * 预警编码
+     */
+    @TableField(value = "warning_code")
+    @ApiModelProperty(value = "预警编码")
+    private String warningCode;
+
+    /**
+     * 预警值
+     */
+    @TableField(value = "warning_value")
+    @ApiModelProperty(value = "预警值")
+    private Double warningValue;
+
+    /**
+     * 备注
+     */
+    @TableField(value = "remark")
+    @ApiModelProperty(value = "备注")
+    private String remark;
+
+    /**
+     * 创建时间
+     */
+    @TableField(value = "create_time")
+    @ApiModelProperty(value = "创建时间")
+    private LocalDateTime createTime;
+
+    /**
+     * 修改时间
+     */
+    @TableField(value = "update_time")
+    @ApiModelProperty(value = "修改时间")
+    private LocalDateTime updateTime;
+
+    @TableField(exist = false)
+    private static final long serialVersionUID = 1L;
+}

+ 20 - 0
pipe-network-service/zksy-system/src/main/java/com/zksy/base/alarm/mapper/WarningThresholdMapper.java

@@ -0,0 +1,20 @@
+package com.zksy.base.alarm.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.zksy.base.alarm.domain.WarningThreshold;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+* @author Administrator
+* @description 针对表【warning_threshold(预警阈值)】的数据库操作Mapper
+* @createDate 2025-09-01 09:59:43
+* @Entity com.zksy.common.domain.WarningThreshold
+*/
+@Mapper
+public interface WarningThresholdMapper extends BaseMapper<WarningThreshold> {
+
+}
+
+
+
+

+ 22 - 0
pipe-network-service/zksy-system/src/main/java/com/zksy/base/alarm/service/WarningThresholdService.java

@@ -0,0 +1,22 @@
+package com.zksy.base.alarm.service;
+
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.zksy.base.alarm.domain.WarningThreshold;
+
+import java.util.List;
+
+/**
+* @author Administrator
+* @description 针对表【warning_threshold(预警阈值)】的数据库操作Service
+* @createDate 2025-09-01 09:59:43
+*/
+public interface WarningThresholdService extends IService<WarningThreshold> {
+    Page<WarningThreshold> findByPage(long pageNum, long pageSize, String deviceName,String deviceCode,String warningType,String warningCode);
+    List<WarningThreshold> getWarningThresholdList(String deviceName,String deviceCode,String warningType,String warningCode);
+
+    /**
+     * 根据设备编号查询该设备所有预警值
+     */
+    WarningThreshold getWarningThresholdByDeviceAndCode(String deviceCode, String warningCode);
+}

+ 61 - 0
pipe-network-service/zksy-system/src/main/java/com/zksy/base/alarm/service/impl/WarningThresholdServiceImpl.java

@@ -0,0 +1,61 @@
+package com.zksy.base.alarm.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.zksy.base.alarm.domain.WarningThreshold;
+import com.zksy.base.alarm.mapper.WarningThresholdMapper;
+import com.zksy.base.alarm.service.WarningThresholdService;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+* @author Administrator
+* @description 针对表【warning_threshold(预警阈值)】的数据库操作Service实现
+* @createDate 2025-09-01 09:59:43
+*/
+@Service
+public class WarningThresholdServiceImpl extends ServiceImpl<WarningThresholdMapper, WarningThreshold>
+    implements WarningThresholdService {
+
+    @Override
+    public Page<WarningThreshold> findByPage(long pageNum, long pageSize, String deviceName, String deviceCode, String warningType, String warningCode) {
+        Page<WarningThreshold> page = new Page<>(pageNum, pageSize);
+        LambdaQueryWrapper<WarningThreshold> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.like(WarningThreshold::getDeviceName,deviceName)
+                .like(WarningThreshold::getDeviceCode,deviceCode)
+                .like(WarningThreshold::getWarningType,warningType)
+                .like(WarningThreshold::getWarningCode,warningCode);
+        queryWrapper.orderByDesc(WarningThreshold::getUpdateTime);
+        return this.page(page, queryWrapper);
+    }
+
+    @Override
+    public List<WarningThreshold> getWarningThresholdList(String deviceName, String deviceCode, String warningType, String warningCode) {
+        LambdaQueryWrapper<WarningThreshold> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.like(WarningThreshold::getDeviceName,deviceName)
+                .like(WarningThreshold::getDeviceCode,deviceCode)
+                .like(WarningThreshold::getWarningType,warningType)
+                .like(WarningThreshold::getWarningCode,warningCode);
+        queryWrapper.orderByDesc(WarningThreshold::getUpdateTime);
+        return this.list(queryWrapper);
+    }
+
+    /**
+     * 根据设备编号查询该设备所有预警值
+     */
+    @Override
+    public WarningThreshold getWarningThresholdByDeviceAndCode(String deviceCode, String warningCodes) {
+        LambdaQueryWrapper<WarningThreshold> lambdaQueryWrapper = Wrappers.lambdaQuery(WarningThreshold.class)
+                .eq(WarningThreshold::getDeviceCode, deviceCode)
+                .eq(WarningThreshold::getWarningCode,warningCodes);
+
+        return baseMapper.selectOne(lambdaQueryWrapper);
+    }
+}
+
+
+
+

+ 0 - 3
zk-api-service/src/main/java/com/zksy/api/service/WarningThresholdService.java

@@ -13,9 +13,6 @@ import java.util.List;
 * @createDate 2025-09-01 09:59:43
 */
 public interface WarningThresholdService extends IService<WarningThreshold> {
-    Page<WarningThreshold> findByPage(long pageNum, long pageSize, String deviceName,String deviceCode,String warningType,String warningCode);
-    List<WarningThreshold> getWarningThresholdList(String deviceName,String deviceCode,String warningType,String warningCode);
-
     /**
      * 根据设备编号查询该设备所有预警值
      */

+ 0 - 24
zk-api-service/src/main/java/com/zksy/api/service/impl/WarningThresholdServiceImpl.java

@@ -19,30 +19,6 @@ import java.util.List;
 @Service
 public class WarningThresholdServiceImpl extends ServiceImpl<WarningThresholdMapper, WarningThreshold>
     implements WarningThresholdService{
-
-    @Override
-    public Page<WarningThreshold> findByPage(long pageNum, long pageSize, String deviceName, String deviceCode, String warningType, String warningCode) {
-        Page<WarningThreshold> page = new Page<>(pageNum, pageSize);
-        LambdaQueryWrapper<WarningThreshold> queryWrapper = new LambdaQueryWrapper<>();
-        queryWrapper.like(WarningThreshold::getDeviceName,deviceName)
-                .like(WarningThreshold::getDeviceCode,deviceCode)
-                .like(WarningThreshold::getWarningType,warningType)
-                .like(WarningThreshold::getWarningCode,warningCode);
-        queryWrapper.orderByDesc(WarningThreshold::getUpdateTime);
-        return this.page(page, queryWrapper);
-    }
-
-    @Override
-    public List<WarningThreshold> getWarningThresholdList(String deviceName, String deviceCode, String warningType, String warningCode) {
-        LambdaQueryWrapper<WarningThreshold> queryWrapper = new LambdaQueryWrapper<>();
-        queryWrapper.like(WarningThreshold::getDeviceName,deviceName)
-                .like(WarningThreshold::getDeviceCode,deviceCode)
-                .like(WarningThreshold::getWarningType,warningType)
-                .like(WarningThreshold::getWarningCode,warningCode);
-        queryWrapper.orderByDesc(WarningThreshold::getUpdateTime);
-        return this.list(queryWrapper);
-    }
-
     /**
      * 根据设备编号查询该设备所有预警值
      */