lengfaqiang 2 лет назад
Родитель
Сommit
193f8b3336

+ 36 - 0
slope-common/slope-common-core/src/main/java/com/sckw/core/model/enums/ThresholdEnum.java

@@ -0,0 +1,36 @@
+package com.sckw.core.model.enums;
+
+import lombok.Getter;
+/**
+ * @author lfdc
+ * @description 预警表setting字段枚举
+ * @date 2023-07-07 14:07:23
+ */
+@Getter
+public enum ThresholdEnum {
+    IS_NOT_SET(0, "0", "未设置"),
+    PARTIAL_SETTING(1, "1", "部分设置"),
+    HAVE_SET(2, "2", "已设置"),
+    ;
+    private final Integer code;
+    private final String status;
+    private final String destination;
+
+    public Integer getCode() {
+        return code;
+    }
+
+    public String getStatus() {
+        return status;
+    }
+
+    public String getDestination() {
+        return destination;
+    }
+
+    ThresholdEnum(Integer code, String status, String destination) {
+        this.code = code;
+        this.status = status;
+        this.destination = destination;
+    }
+}

+ 0 - 5
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/dos/mysql/KwsDeviceReference.java

@@ -24,11 +24,6 @@ public class KwsDeviceReference implements Serializable {
     */
     private Long deviceId;
 
-    /**
-     * 企业id
-     */
-    private String companyId;
-
     /**
     * 基准项
     */

+ 11 - 9
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/service/ThresholdService.java

@@ -6,6 +6,7 @@ import com.github.pagehelper.PageInfo;
 import com.sckw.core.exception.BusinessException;
 import com.sckw.core.model.constant.NumberConstant;
 import com.sckw.core.model.enums.DeviceEnum;
+import com.sckw.core.model.enums.ThresholdEnum;
 import com.sckw.core.model.page.PageRes;
 import com.sckw.core.utils.IdWorker;
 import com.sckw.core.utils.RegularUtils;
@@ -89,15 +90,15 @@ public class ThresholdService {
                     .eq(KwsThreshold::getDelFlag, NumberConstant.ZERO)
                     .orderByDesc(KwsThreshold::getCreateTime)
             );
-            String setting = "0";
-            String statusName = "未设置";
+            String setting = ThresholdEnum.IS_NOT_SET.getStatus();
+            String statusName = ThresholdEnum.IS_NOT_SET.getDestination();
             if (!CollectionUtils.isEmpty(kwsThresholds)) {
                 setting = kwsThresholds.get(0).getSetting();
-                if ("1".equals(setting)) {
-                    statusName = "部分设置";
+                if (ThresholdEnum.PARTIAL_SETTING.getStatus().equals(setting)) {
+                    statusName = ThresholdEnum.PARTIAL_SETTING.getDestination();
                 } else {
-                    setting = "2";
-                    statusName = "已设置";
+                    setting = ThresholdEnum.HAVE_SET.getStatus();
+                    statusName = ThresholdEnum.HAVE_SET.getDestination();
                 }
             }
             dto.setId(thresholdQuery.getProjectId());
@@ -241,11 +242,12 @@ public class ThresholdService {
 
     /**
      * 比较数据库中存在的阈值与页面填写的阈值范围
-     * @param level 阈值等级
+     *
+     * @param level         阈值等级
      * @param thresholdBean 页面填写数据
      * @param headerData    请求头信息
-     * @param deviceId  设备id
-     * @param itemName  要素项
+     * @param deviceId      设备id
+     * @param itemName      要素项
      */
     private void checkDatabaseThresholdLevel(int level, ThresholdBean thresholdBean, HeaderData headerData, String deviceId, String itemName) {
         if (1 == level) {

+ 1 - 1
slope-modules/slope-detection/src/main/resources/mapper/mysql/KwsDeviceIntegrationMapper.xml

@@ -178,7 +178,7 @@
             </foreach>
         </if>
         <if test="projectId != null and projectId != ''">
-            and a.project_id = #{projectId}
+            and a.id = #{projectId}
         </if>
         <if test="mountainId != null and mountainId != ''">
             and a.mountain_id = #{mountainId}

+ 1 - 3
slope-modules/slope-detection/src/main/resources/mapper/mysql/KwsDeviceReferenceMapper.xml

@@ -10,7 +10,6 @@
         <result column="value" jdbcType="DECIMAL" property="value"/>
         <result column="offset" jdbcType="DECIMAL" property="offset"/>
         <result column="status" jdbcType="TINYINT" property="status"/>
-        <result column="company_id" jdbcType="VARCHAR" property="companyId"/>
         <result column="mountain_id" jdbcType="VARCHAR" property="mountainId"/>
         <result column="create_by" jdbcType="BIGINT" property="createBy"/>
         <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
@@ -31,8 +30,7 @@
         create_time,
         update_by,
         update_time,
-        del_flag,
-        company_id
+        del_flag
     </sql>
     <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
         <!--@mbg.generated-->