15928045575 2 lat temu
rodzic
commit
885dd83e75
24 zmienionych plików z 998 dodań i 113 usunięć
  1. 6 0
      pom.xml
  2. 7 4
      slope-common/slope-common-core/src/main/java/com/sckw/core/model/constant/StringConstant.java
  3. 5 0
      slope-common/slope-common-log/pom.xml
  4. 74 0
      slope-common/slope-common-log/src/main/java/com/sckw/log/TraceLog/MdcTaskExecutor.java
  5. 23 0
      slope-common/slope-common-log/src/main/java/com/sckw/log/TraceLog/TraceLog.java
  6. 48 0
      slope-common/slope-common-log/src/main/java/com/sckw/log/TraceLog/aop/TraceIdAspect.java
  7. 52 0
      slope-common/slope-common-log/src/main/java/com/sckw/log/TraceLog/interceptor/MDCInterceptor.java
  8. 45 0
      slope-common/slope-common-log/src/main/java/com/sckw/log/TraceLog/interceptor/RestTemplateTraceIdInterceptor.java
  9. 29 0
      slope-common/slope-common-log/src/main/java/com/sckw/log/TraceLog/interceptor/WebMvcConfig.java
  10. 4 1
      slope-common/slope-common-log/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
  11. 5 0
      slope-modules/slope-detection/pom.xml
  12. 2 0
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/controller/MysqlDemoController.java
  13. 12 0
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/controller/ThresholdController.java
  14. 5 0
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/dto/BaseItemDTO.java
  15. 3 0
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/dto/DeviceElementDTO.java
  16. 29 0
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/param/ProjectThresholdSettingParam.java
  17. 48 0
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/vo/ProjectThresholdSettingVO.java
  18. 31 23
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/service/DeviceService.java
  19. 5 4
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/service/MysqlDemoService.java
  20. 398 72
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/service/ThresholdService.java
  21. 154 0
      slope-modules/slope-detection/src/main/resources/log4j2-bak.xml
  22. 5 1
      slope-modules/slope-detection/src/main/resources/mapper/mysql/KwsDeviceMapper.xml
  23. 2 2
      slope-modules/slope-detection/src/main/resources/mapper/mysql/KwsProjectDeviceMapper.xml
  24. 6 6
      slope-modules/slope-detection/src/main/resources/mapper/tdengine/InsTables.xml

+ 6 - 0
pom.xml

@@ -331,6 +331,12 @@
                 <artifactId>bcprov-jdk18on</artifactId>
                 <artifactId>bcprov-jdk18on</artifactId>
                 <version>1.74</version>
                 <version>1.74</version>
             </dependency>
             </dependency>
+            <!--日志链路-->
+            <dependency>
+                <groupId>com.yomahub</groupId>
+                <artifactId>tlog-all-spring-boot-starter</artifactId>
+                <version>1.5.1</version>
+            </dependency>
         </dependencies>
         </dependencies>
     </dependencyManagement>
     </dependencyManagement>
 
 

+ 7 - 4
slope-common/slope-common-core/src/main/java/com/sckw/core/model/constant/StringConstant.java

@@ -9,6 +9,13 @@ import java.time.format.DateTimeFormatter;
  * @create: 2022-01-27 16:02
  * @create: 2022-01-27 16:02
  **/
  **/
 public final class StringConstant {
 public final class StringConstant {
+
+    public static final String TRACE_ID = "traceId";
+    public static final String RUNG = "-";
+    public static final String UNDERLINE = "_";
+    public static final String SUB_THREAD = "subThread";
+    public final static String DATA_SOURCE = "dataSource";
+
     public static final String LEFT_SEPARATOR = "/";
     public static final String LEFT_SEPARATOR = "/";
     public static final String LEFT_SEPARATORS = "//";
     public static final String LEFT_SEPARATORS = "//";
     public static final String RIGHT_SEPARATOR = "\\";
     public static final String RIGHT_SEPARATOR = "\\";
@@ -23,10 +30,6 @@ public final class StringConstant {
      */
      */
     public static final String HYPHEN = "-";
     public static final String HYPHEN = "-";
 
 
-    /**
-     * 下划线
-     */
-    public static final String UNDERLINE = "_";
     public static final String HTTP_STRING = "http";
     public static final String HTTP_STRING = "http";
     public static final String HTTPS_STRING = "https";
     public static final String HTTPS_STRING = "https";
     public static final String B = "B";
     public static final String B = "B";

+ 5 - 0
slope-common/slope-common-log/pom.xml

@@ -50,6 +50,11 @@
             <groupId>com.alibaba</groupId>
             <groupId>com.alibaba</groupId>
             <artifactId>fastjson</artifactId>
             <artifactId>fastjson</artifactId>
         </dependency>
         </dependency>
+        <dependency>
+            <groupId>com.sckw</groupId>
+            <artifactId>slope-common-core</artifactId>
+            <version>1.0.0</version>
+        </dependency>
 
 
     </dependencies>
     </dependencies>
 
 

+ 74 - 0
slope-common/slope-common-log/src/main/java/com/sckw/log/TraceLog/MdcTaskExecutor.java

@@ -0,0 +1,74 @@
+package com.sckw.log.TraceLog;
+
+import com.sckw.core.model.constant.StringConstant;
+import com.sckw.core.utils.UUIDUtils;
+import lombok.extern.slf4j.Slf4j;
+import org.slf4j.MDC;
+import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
+
+import java.util.Map;
+import java.util.concurrent.Callable;
+import java.util.concurrent.Future;
+
+/**
+ * @author lfdc
+ * @description
+ * @date 2023-11-21 16:11:05
+ */
+@Slf4j
+public class MdcTaskExecutor extends ThreadPoolTaskExecutor {
+
+    private static final long serialVersionUID = 832576625683993818L;
+
+    @Override
+    public <T> Future<T> submit(Callable<T> task) {
+        log.info("mdc thread pool task executor submit");
+        Map<String, String> context = MDC.getCopyOfContextMap();
+        return super.submit(() -> {
+            T result;
+            if (context != null) {
+                //将父线程的MDC内容传给子线程
+                MDC.setContextMap(context);
+            } else {
+                //直接给子线程设置MDC
+                MDC.put(StringConstant.TRACE_ID, UUIDUtils.get32UUID() + StringConstant.RUNG + StringConstant.SUB_THREAD);
+            }
+            try {
+                //执行任务
+                result = task.call();
+            } finally {
+                try {
+                    MDC.clear();
+                } catch (Exception e) {
+                    log.warn("MDC clear exception", e);
+                }
+            }
+            return result;
+        });
+    }
+
+    @Override
+    public void execute(Runnable task) {
+        log.info("mdc thread pool task executor execute");
+        Map<String, String> context = MDC.getCopyOfContextMap();
+        super.execute(() -> {
+            if (context != null) {
+                //将父线程的MDC内容传给子线程
+                MDC.setContextMap(context);
+            } else {
+                //直接给子线程设置MDC
+                MDC.put(StringConstant.TRACE_ID, UUIDUtils.get32UUID() + StringConstant.RUNG + StringConstant.SUB_THREAD);
+            }
+            try {
+                //执行任务
+                task.run();
+            } finally {
+                try {
+                    MDC.clear();
+                } catch (Exception e) {
+                    log.warn("MDC clear exception", e);
+                }
+            }
+        });
+    }
+}

+ 23 - 0
slope-common/slope-common-log/src/main/java/com/sckw/log/TraceLog/TraceLog.java

@@ -0,0 +1,23 @@
+package com.sckw.log.TraceLog;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * @author lfdc
+ * @version 1.0.0
+ * @AnnotationName MDC.java
+ * @Description mdc注解
+ * @createTime 2021年09月09日 12:00:00
+ */
+@Target({ElementType.METHOD, ElementType.TYPE})
+@Retention(RetentionPolicy.RUNTIME)
+public @interface TraceLog {
+    /**
+     * 日志描述
+     * @return
+     */
+    String description() default "";
+}

+ 48 - 0
slope-common/slope-common-log/src/main/java/com/sckw/log/TraceLog/aop/TraceIdAspect.java

@@ -0,0 +1,48 @@
+package com.sckw.log.TraceLog.aop;
+
+import com.sckw.core.model.constant.StringConstant;
+import com.sckw.core.utils.UUIDUtils;
+import com.sckw.log.TraceLog.TraceLog;
+import lombok.extern.slf4j.Slf4j;
+import org.aspectj.lang.ProceedingJoinPoint;
+import org.aspectj.lang.annotation.Around;
+import org.aspectj.lang.annotation.Aspect;
+import org.aspectj.lang.annotation.Pointcut;
+import org.slf4j.MDC;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
+
+/**
+ * @author lfdc
+ * @description
+ * @date 2023-11-21 15:11:54
+ */
+@Slf4j
+@Aspect
+@Component
+public class TraceIdAspect {
+
+    @Value("${spring.application.name}")
+    private String shortName;
+
+    //    @Pointcut("@annotation(com.sckw.slope.detection.common.config.log.TraceId)")
+    @Pointcut("@annotation(l)")
+    public void traceId(TraceLog l) {
+    }
+
+    @Around("traceId(l)")
+    public Object arround(ProceedingJoinPoint joinPoint, TraceLog l) {
+        MDC.put(StringConstant.TRACE_ID, UUIDUtils.get32UUID() + StringConstant.RUNG + l.description() /*+ shortName*/);
+        try {
+            long start = System.currentTimeMillis();
+            Object o = joinPoint.proceed();
+            long end = System.currentTimeMillis();
+            log.info("方法耗时:{} ms", end - start);
+            return o;
+        } catch (Throwable e) {
+            return null;
+        } finally {
+            MDC.clear();
+        }
+    }
+}

+ 52 - 0
slope-common/slope-common-log/src/main/java/com/sckw/log/TraceLog/interceptor/MDCInterceptor.java

@@ -0,0 +1,52 @@
+package com.sckw.log.TraceLog.interceptor;
+
+import com.sckw.core.model.constant.StringConstant;
+import com.sckw.core.utils.StringUtils;
+import com.sckw.core.utils.UUIDUtils;
+import jakarta.servlet.http.HttpServletRequest;
+import jakarta.servlet.http.HttpServletResponse;
+import lombok.extern.slf4j.Slf4j;
+import org.slf4j.MDC;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
+import org.springframework.web.servlet.HandlerInterceptor;
+import org.springframework.web.servlet.ModelAndView;
+
+/**
+ * @author JiangPan
+ * @version 1.0.0
+ * @ClassName MDCInterceptor.java
+ * @Description MDC拦截器
+ * @createTime 2021年09月09日 09:25:00
+ */
+@Slf4j
+@Component
+public class MDCInterceptor implements HandlerInterceptor {
+
+    @Value("${spring.application.name}")
+    private String shortName;
+
+    @Override
+    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
+        String traceId = request.getHeader(StringConstant.TRACE_ID);
+        if (StringUtils.isNotBlank(traceId)) {
+            //添加MDC值
+            MDC.put(StringConstant.TRACE_ID, traceId);
+        } else {
+            //添加MDC值
+            MDC.put(StringConstant.TRACE_ID, UUIDUtils.get32UUID() + StringConstant.RUNG + shortName);
+        }
+        return true;
+    }
+
+    @Override
+    public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
+
+    }
+
+    @Override
+    public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
+        //删除MDC值
+        MDC.remove(StringConstant.TRACE_ID);
+    }
+}

+ 45 - 0
slope-common/slope-common-log/src/main/java/com/sckw/log/TraceLog/interceptor/RestTemplateTraceIdInterceptor.java

@@ -0,0 +1,45 @@
+package com.sckw.log.TraceLog.interceptor;
+
+
+import com.sckw.core.model.constant.StringConstant;
+import com.sckw.core.utils.UUIDUtils;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+import org.slf4j.MDC;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.http.HttpRequest;
+import org.springframework.http.client.ClientHttpRequestExecution;
+import org.springframework.http.client.ClientHttpRequestInterceptor;
+import org.springframework.http.client.ClientHttpResponse;
+import org.springframework.stereotype.Component;
+
+import java.io.IOException;
+
+/**
+ * @author JiangPan
+ * @version 1.0.0
+ * @ClassName RestTemplateTraceIdInterceptor.java
+ * @Description RestTemplate拦截器
+ * @createTime 2021年09月09日 12:29:00
+ */
+@Slf4j
+@Component
+public class RestTemplateTraceIdInterceptor implements ClientHttpRequestInterceptor {
+
+    @Value("${spring.application.name}")
+    private String shortName;
+
+    @Override
+    public ClientHttpResponse intercept(HttpRequest httpRequest, byte[] bytes, ClientHttpRequestExecution clientHttpRequestExecution) throws IOException {
+        String traceId = MDC.get(StringConstant.TRACE_ID);
+        if (StringUtils.isNotBlank(traceId)) {
+            httpRequest.getHeaders().add(StringConstant.TRACE_ID, traceId + StringConstant.RUNG + UUIDUtils.get32UUID().substring(10));
+        } else {
+            //添加MDC值
+            String traceId1 = UUIDUtils.get32UUID() + StringConstant.RUNG + shortName + StringConstant.RUNG + UUIDUtils.get32UUID().substring(10);
+            MDC.put(StringConstant.TRACE_ID, traceId1);
+            httpRequest.getHeaders().add(StringConstant.TRACE_ID, traceId1);
+        }
+        return clientHttpRequestExecution.execute(httpRequest, bytes);
+    }
+}

+ 29 - 0
slope-common/slope-common-log/src/main/java/com/sckw/log/TraceLog/interceptor/WebMvcConfig.java

@@ -0,0 +1,29 @@
+package com.sckw.log.TraceLog.interceptor;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
+
+/**
+ * @author JiangPan
+ * @version 1.0.0
+ * @ClassName WebMvcConfig.java
+ * @Description MDC注册
+ * @createTime 2021年09月09日 09:31:00
+ */
+@Configuration
+public class WebMvcConfig extends WebMvcConfigurationSupport {
+
+    @Autowired
+    private MDCInterceptor mdcInterceptor;
+
+
+    /**
+     * 拦截器注册
+     */
+    @Override
+    public void addInterceptors(InterceptorRegistry registry) {
+        registry.addInterceptor(mdcInterceptor);
+    }
+}

+ 4 - 1
slope-common/slope-common-log/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports

@@ -1,3 +1,6 @@
 com.sckw.log.aspect.LogInfoAspect
 com.sckw.log.aspect.LogInfoAspect
 com.sckw.log.interceptor.LogInterceptor
 com.sckw.log.interceptor.LogInterceptor
-com.sckw.log.config.WebConfig
+com.sckw.log.config.WebConfig
+com.sckw.log.TraceLog.interceptor.MDCInterceptor
+com.sckw.log.TraceLog.interceptor.WebMvcConfig
+com.sckw.log.TraceLog.aop.TraceIdAspect

+ 5 - 0
slope-modules/slope-detection/pom.xml

@@ -68,6 +68,11 @@
             <version>1.0.0</version>
             <version>1.0.0</version>
         </dependency>
         </dependency>
 
 
+        <dependency>
+            <groupId>com.sckw</groupId>
+            <artifactId>slope-common-log</artifactId>
+            <version>1.0.0</version>
+        </dependency>
         <dependency>
         <dependency>
             <groupId>org.springframework</groupId>
             <groupId>org.springframework</groupId>
             <artifactId>spring-web</artifactId>
             <artifactId>spring-web</artifactId>

+ 2 - 0
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/controller/MysqlDemoController.java

@@ -1,5 +1,6 @@
 package com.sckw.slope.detection.controller;
 package com.sckw.slope.detection.controller;
 
 
+import com.sckw.core.annotation.Log;
 import com.sckw.slope.detection.service.MysqlDemoService;
 import com.sckw.slope.detection.service.MysqlDemoService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -18,6 +19,7 @@ public class MysqlDemoController {
     @Autowired
     @Autowired
     MysqlDemoService mysqlDemoService;
     MysqlDemoService mysqlDemoService;
 
 
+    @Log(description = "mysqlDemo")
     @RequestMapping(value = "/mysqlDemo",method = RequestMethod.GET)
     @RequestMapping(value = "/mysqlDemo",method = RequestMethod.GET)
     public void mysqlDemo(){
     public void mysqlDemo(){
         mysqlDemoService.mysqlDemo();
         mysqlDemoService.mysqlDemo();

+ 12 - 0
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/controller/ThresholdController.java

@@ -3,9 +3,11 @@ package com.sckw.slope.detection.controller;
 import com.alibaba.fastjson2.JSONObject;
 import com.alibaba.fastjson2.JSONObject;
 import com.sckw.core.annotation.Log;
 import com.sckw.core.annotation.Log;
 import com.sckw.core.web.response.HttpResult;
 import com.sckw.core.web.response.HttpResult;
+import com.sckw.log.TraceLog.TraceLog;
 import com.sckw.slope.detection.model.dto.DeleteThresholdDTO;
 import com.sckw.slope.detection.model.dto.DeleteThresholdDTO;
 import com.sckw.slope.detection.model.dto.ThresholdConfigurationDTO;
 import com.sckw.slope.detection.model.dto.ThresholdConfigurationDTO;
 import com.sckw.slope.detection.model.param.ProjectAndDeviceParam;
 import com.sckw.slope.detection.model.param.ProjectAndDeviceParam;
+import com.sckw.slope.detection.model.param.ProjectThresholdSettingParam;
 import com.sckw.slope.detection.model.param.ThresholdDetailQuery;
 import com.sckw.slope.detection.model.param.ThresholdDetailQuery;
 import com.sckw.slope.detection.model.param.ThresholdQuery;
 import com.sckw.slope.detection.model.param.ThresholdQuery;
 import com.sckw.slope.detection.service.ThresholdService;
 import com.sckw.slope.detection.service.ThresholdService;
@@ -73,4 +75,14 @@ public class ThresholdController {
         return thresholdService.dels(deleteThreshold, request);
         return thresholdService.dels(deleteThreshold, request);
     }
     }
 
 
+
+    @Log(description = "阈值设置查询-app")
+    @TraceLog(description = "阈值设置查询-app")
+    //@RepeatSubmit(interval = 3000, message = "两次请求间隔未超过3秒")
+    @RequestMapping(name = "阈值设置查询-app", value = "/selectSetting", method = RequestMethod.POST)
+    public HttpResult selectSetting(@Valid @RequestBody ProjectThresholdSettingParam param, HttpServletRequest request) {
+        log.info("阈值设置查询-app selectSetting param:{}", JSONObject.toJSONString(param));
+        return thresholdService.selectSetting(param, request);
+    }
+
 }
 }

+ 5 - 0
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/dto/BaseItemDTO.java

@@ -21,4 +21,9 @@ public class BaseItemDTO implements Serializable {
      * 要素名
      * 要素名
      */
      */
     private String partName;
     private String partName;
+
+    /**
+     * 要素名
+     */
+    private String partNameLabel;
 }
 }

+ 3 - 0
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/dto/DeviceElementDTO.java

@@ -15,6 +15,9 @@ public class DeviceElementDTO {
     private String deviceId;
     private String deviceId;
     private String name;
     private String name;
     private String deviceModelId;
     private String deviceModelId;
+    /**
+     * 要素名
+     */
     private String element;
     private String element;
     private String phones;
     private String phones;
     private String integrationElement;
     private String integrationElement;

+ 29 - 0
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/param/ProjectThresholdSettingParam.java

@@ -0,0 +1,29 @@
+package com.sckw.slope.detection.model.param;
+
+import jakarta.validation.constraints.NotBlank;
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * @author lfdc
+ * @description
+ * @date 2023-11-21 13:11:59
+ */
+@Data
+public class ProjectThresholdSettingParam implements Serializable {
+
+    @NotBlank(message = "项目id不能为为空")
+    private String projectId;
+
+    private int page;
+
+    private int pageSize;
+
+    /**
+     * 100 全部  0未设置 1 部分设置 2 已设置
+     */
+    @NotBlank(message = "类型不能为空")
+    private String type;
+
+}

+ 48 - 0
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/vo/ProjectThresholdSettingVO.java

@@ -0,0 +1,48 @@
+package com.sckw.slope.detection.model.vo;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.time.LocalDateTime;
+
+/**
+ * @author lfdc
+ * @description 阈值设置分组查询-app
+ * @date 2023-11-21 15:11:14
+ */
+@Data
+public class ProjectThresholdSettingVO implements Serializable {
+
+    /**
+     * 项目id
+     */
+    private String projectId;
+    /**
+     * 项目名称
+     */
+    private String projectName;
+    /**
+     * 设备id
+     */
+    private String deviceId;
+
+    /**
+     * 设备名称
+     */
+    private String itemNames;
+
+    /**
+     * 设备名称
+     */
+    private String deviceName;
+    /**
+     * 阈值联系人
+     */
+    private String phones;
+    /**
+     * 变更时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private LocalDateTime updateTime;
+}

+ 31 - 23
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/service/DeviceService.java

@@ -93,13 +93,11 @@ public class DeviceService {
     KwsDeviceReferenceMapper deviceReferenceMapper;
     KwsDeviceReferenceMapper deviceReferenceMapper;
 
 
 
 
-
-
     @Transactional
     @Transactional
     public HttpResult dels(String ids, HttpServletRequest response) {
     public HttpResult dels(String ids, HttpServletRequest response) {
         KwsDevice device = deviceMapper.selectOne(new LambdaQueryWrapper<KwsDevice>()
         KwsDevice device = deviceMapper.selectOne(new LambdaQueryWrapper<KwsDevice>()
                 .eq(KwsDevice::getId, ids));
                 .eq(KwsDevice::getId, ids));
-        if(Objects.isNull(device)){
+        if (Objects.isNull(device)) {
             throw new SystemException(HttpStatus.QUERY_FAIL_CODE, HttpStatus.DEVICE_NOT_EXISTS);
             throw new SystemException(HttpStatus.QUERY_FAIL_CODE, HttpStatus.DEVICE_NOT_EXISTS);
         }
         }
         //List<Long> list = StringUtils.splitStrToList(ids, Long.class);
         //List<Long> list = StringUtils.splitStrToList(ids, Long.class);
@@ -276,7 +274,7 @@ public class DeviceService {
         //获取基础要数
         //获取基础要数
         List<DevicePartModelVo> partData = new ArrayList<>();
         List<DevicePartModelVo> partData = new ArrayList<>();
         partData = deviceModelPartMapper.selectByModelId(deviceModel.getId());
         partData = deviceModelPartMapper.selectByModelId(deviceModel.getId());
-        if(!Objects.isNull(partData)){//首先在kws_device_model_part获取数据,然后到字典中查询
+        if (!Objects.isNull(partData)) {//首先在kws_device_model_part获取数据,然后到字典中查询
             for (DevicePartModelVo part : partData) {
             for (DevicePartModelVo part : partData) {
                 for (SystemDict value : dictList.values()) {
                 for (SystemDict value : dictList.values()) {
                     if (part.getPartName().equals(value.getValue())) {
                     if (part.getPartName().equals(value.getValue())) {
@@ -320,13 +318,13 @@ public class DeviceService {
         //获取集成要素
         //获取集成要素
         List<DeviceIntegrationVo> intergData = new ArrayList<>();
         List<DeviceIntegrationVo> intergData = new ArrayList<>();
         intergData = deviceIntegrationMapper.selectListByParmsAndInterName(vo);
         intergData = deviceIntegrationMapper.selectListByParmsAndInterName(vo);
-        if(!Objects.isNull(intergData)){
+        if (!Objects.isNull(intergData)) {
             for (DeviceIntegrationVo inter : intergData) {
             for (DeviceIntegrationVo inter : intergData) {
                 references.forEach(re -> {
                 references.forEach(re -> {
                     if (inter.getIntegrationName().equals(re.getItem())) {
                     if (inter.getIntegrationName().equals(re.getItem())) {
                         SlopeData slopeData = slopeDataMapper.selectListByLine(snCode, re.getItem());//获取到当前测量值
                         SlopeData slopeData = slopeDataMapper.selectListByLine(snCode, re.getItem());//获取到当前测量值
                         inter.setIntegrationBaseData(re.getOriginalValue().toString());
                         inter.setIntegrationBaseData(re.getOriginalValue().toString());
-                        if(!Objects.isNull(slopeData)){
+                        if (!Objects.isNull(slopeData)) {
                             inter.setCurrentData(slopeData.getVal());
                             inter.setCurrentData(slopeData.getVal());
                         }
                         }
                         inter.setIntegrationCurrentBaseData(re.getCurrentValue().toString());
                         inter.setIntegrationCurrentBaseData(re.getCurrentValue().toString());
@@ -340,8 +338,6 @@ public class DeviceService {
         }
         }
 
 
 
 
-
-
         return HttpResult.ok(vo);
         return HttpResult.ok(vo);
     }
     }
 
 
@@ -405,20 +401,20 @@ public class DeviceService {
         device.setUpdateBy(Long.parseLong(headerData.getUpdateBy()));
         device.setUpdateBy(Long.parseLong(headerData.getUpdateBy()));
         device.setUpdateTime(now);
         device.setUpdateTime(now);
         Integer updateStatus = deviceMapper.updateById(device);
         Integer updateStatus = deviceMapper.updateById(device);
-        if(updateStatus == 1){
+        if (updateStatus == 1) {
             int update = deviceIntegrationMapper.update(null, new LambdaUpdateWrapper<KwsDeviceIntegration>()
             int update = deviceIntegrationMapper.update(null, new LambdaUpdateWrapper<KwsDeviceIntegration>()
                     .eq(KwsDeviceIntegration::getDeviceId, deviceAdd.getId())
                     .eq(KwsDeviceIntegration::getDeviceId, deviceAdd.getId())
                     .set(KwsDeviceIntegration::getDelFlag, NumberConstant.ONE)
                     .set(KwsDeviceIntegration::getDelFlag, NumberConstant.ONE)
-                    .set(KwsDeviceIntegration::getUpdateBy,Long.parseLong(headerData.getUpdateBy()) )
+                    .set(KwsDeviceIntegration::getUpdateBy, Long.parseLong(headerData.getUpdateBy()))
                     .set(KwsDeviceIntegration::getUpdateTime, now));
                     .set(KwsDeviceIntegration::getUpdateTime, now));
             //if (update < 1) {
             //if (update < 1) {
-                //throw new BusinessException("删除设备集成要素异常");
+            //throw new BusinessException("删除设备集成要素异常");
             //}
             //}
 
 
             //新增到数据表kws_device_Integration
             //新增到数据表kws_device_Integration
             KwsDeviceIntegration deIntergration = new KwsDeviceIntegration();
             KwsDeviceIntegration deIntergration = new KwsDeviceIntegration();
             String[] temp;//接收分割后的数组
             String[] temp;//接收分割后的数组
-            if(!deviceAdd.getIntegrationId().isEmpty()){
+            if (!deviceAdd.getIntegrationId().isEmpty()) {
                 temp = deviceAdd.getIntegrationId().split(Global.COMMA);
                 temp = deviceAdd.getIntegrationId().split(Global.COMMA);
 
 
                 for (int i = 0; i < temp.length; i++) {
                 for (int i = 0; i < temp.length; i++) {
@@ -471,7 +467,7 @@ public class DeviceService {
                 headerData.getMountainId(), status, Long.parseLong(deviceId));
                 headerData.getMountainId(), status, Long.parseLong(deviceId));
 
 
 
 
-        List<ProjectDeviceVO> projectDeviceList = projectMapper.selectDeviceByProjectId(headerData.getMountainId(), Long.parseLong(projectId), Long.parseLong(deviceId),null);
+        List<ProjectDeviceVO> projectDeviceList = projectMapper.selectDeviceByProjectId(headerData.getMountainId(), Long.parseLong(projectId), Long.parseLong(deviceId), null);
         List<String> deviceIds = new ArrayList<>();
         List<String> deviceIds = new ArrayList<>();
         if (!CollectionUtils.isEmpty(projectDeviceList)) {
         if (!CollectionUtils.isEmpty(projectDeviceList)) {
             deviceIds = projectDeviceList.stream().map(ProjectDeviceVO::getId).distinct().collect(Collectors.toList());
             deviceIds = projectDeviceList.stream().map(ProjectDeviceVO::getId).distinct().collect(Collectors.toList());
@@ -493,7 +489,7 @@ public class DeviceService {
                     put("code", DictEnum.MODEL_PART.getCodeType());
                     put("code", DictEnum.MODEL_PART.getCodeType());
                     put("type", "1");
                     put("type", "1");
                 }});
                 }});
-                String itemName = dictList == null ? item : dictList.get(item).getLabel();
+                String itemName = dictList == null ? item : (dictList.get(item)==null?item:dictList.get(item).getLabel());
                 BigDecimal originalValue = re.getOriginalValue();
                 BigDecimal originalValue = re.getOriginalValue();
                 BigDecimal currentValue = re.getCurrentValue();
                 BigDecimal currentValue = re.getCurrentValue();
                 BigDecimal offset = re.getOffset();
                 BigDecimal offset = re.getOffset();
@@ -551,7 +547,7 @@ public class DeviceService {
                 if (itemList.contains(re.getItem())) {
                 if (itemList.contains(re.getItem())) {
                     BigDecimal offsetValue = new BigDecimal("0.00");
                     BigDecimal offsetValue = new BigDecimal("0.00");
                     if (org.apache.commons.lang3.StringUtils.isNotBlank(val)) {
                     if (org.apache.commons.lang3.StringUtils.isNotBlank(val)) {
-                        offsetValue = new BigDecimal(val).divide(new BigDecimal(1000),12,BigDecimal.ROUND_HALF_UP);
+                        offsetValue = new BigDecimal(val).divide(new BigDecimal(1000), 12, BigDecimal.ROUND_HALF_UP);
                     }
                     }
 //                    currentMeasurement.put(itemName, offsetValue);
 //                    currentMeasurement.put(itemName, offsetValue);
                     vo.setCurrentMeasurementValue(offsetValue == null ? null : offsetValue.toString());
                     vo.setCurrentMeasurementValue(offsetValue == null ? null : offsetValue.toString());
@@ -600,10 +596,13 @@ public class DeviceService {
                     if (!CollectionUtils.isEmpty(stringList)) {
                     if (!CollectionUtils.isEmpty(stringList)) {
                         for (int i = 0; i < stringList.size(); i++) {
                         for (int i = 0; i < stringList.size(); i++) {
                             String snCode = kwsDevice.getSnCode();
                             String snCode = kwsDevice.getSnCode();
-                            InsTables insTables = insTablesMapper.selectTableIsExit("devicesv2" + snCode);
+                            InsTables insTables = insTablesMapper.selectTableIsExit("devices" + snCode);
                             if (insTables == null) {
                             if (insTables == null) {
-                                insTablesMapper.createTable("devicesv2" + snCode);
+                                continue;
                             }
                             }
+//                            if (insTables == null) {
+//                                insTablesMapper.createTable("devices_" + snCode);
+//                            }
                             List<SlopeData> selected = slopeDataMapper.selectListByLineOrderByCreateTime(snCode, stringList.get(i));
                             List<SlopeData> selected = slopeDataMapper.selectListByLineOrderByCreateTime(snCode, stringList.get(i));
                             if (!CollectionUtils.isEmpty(selected)) {
                             if (!CollectionUtils.isEmpty(selected)) {
                                 if (selected.size() == 2) {
                                 if (selected.size() == 2) {
@@ -621,7 +620,7 @@ public class DeviceService {
 //                                    long epochMilli1 = date1.toInstant(ZoneOffset.of("+8")).toEpochMilli();
 //                                    long epochMilli1 = date1.toInstant(ZoneOffset.of("+8")).toEpochMilli();
                                     long t = (epochMilli - epochMilli1) / (60 * 60 * 1000);
                                     long t = (epochMilli - epochMilli1) / (60 * 60 * 1000);
                                     long val = Long.parseLong(currSlopeData.getVal()) - Long.parseLong(lastSlopeData.getVal());
                                     long val = Long.parseLong(currSlopeData.getVal()) - Long.parseLong(lastSlopeData.getVal());
-                                    decimal = BigDecimal.valueOf(val).divide((new BigDecimal(t).multiply(new BigDecimal(t))),12,BigDecimal.ROUND_HALF_UP);
+                                    decimal = BigDecimal.valueOf(val).divide((new BigDecimal(t).multiply(new BigDecimal(t))), 12, BigDecimal.ROUND_HALF_UP);
                                 }
                                 }
                             }
                             }
                         }
                         }
@@ -647,8 +646,8 @@ public class DeviceService {
         JSONArray array = JSON.parseArray(listData);
         JSONArray array = JSON.parseArray(listData);
         LocalDateTime now = LocalDateTime.now();
         LocalDateTime now = LocalDateTime.now();
         BigDecimal zero = new BigDecimal("0");
         BigDecimal zero = new BigDecimal("0");
-        for(Object object : array){
-            JSONObject obj = (JSONObject)object;
+        for (Object object : array) {
+            JSONObject obj = (JSONObject) object;
             KwsDeviceReference reference = deviceReferenceMapper.selectOne(new LambdaQueryWrapper<KwsDeviceReference>()
             KwsDeviceReference reference = deviceReferenceMapper.selectOne(new LambdaQueryWrapper<KwsDeviceReference>()
                     .eq(KwsDeviceReference::getMountainId, headerData.getMountainId())
                     .eq(KwsDeviceReference::getMountainId, headerData.getMountainId())
                     .eq(KwsDeviceReference::getDeviceId, deviceId)
                     .eq(KwsDeviceReference::getDeviceId, deviceId)
@@ -657,13 +656,13 @@ public class DeviceService {
             );
             );
             long interId = new IdWorker(NumberConstant.ONE).nextId();
             long interId = new IdWorker(NumberConstant.ONE).nextId();
             KwsDeviceReference kwsDeviceReference = new KwsDeviceReference();
             KwsDeviceReference kwsDeviceReference = new KwsDeviceReference();
-            BigDecimal value  = new BigDecimal(obj.get("value").toString());
+            BigDecimal value = new BigDecimal(obj.get("value").toString());
 
 
-            if(Objects.isNull(reference)){
+            if (Objects.isNull(reference)) {
                 kwsDeviceReference.setOffset(zero);
                 kwsDeviceReference.setOffset(zero);
                 kwsDeviceReference.setOriginalValue(zero);
                 kwsDeviceReference.setOriginalValue(zero);
                 kwsDeviceReference.setCurrentValue(value);
                 kwsDeviceReference.setCurrentValue(value);
-            }else{
+            } else {
                 //如果有数据,则先删除原有数据。
                 //如果有数据,则先删除原有数据。
                 deviceReferenceMapper.update(null, new LambdaUpdateWrapper<KwsDeviceReference>()
                 deviceReferenceMapper.update(null, new LambdaUpdateWrapper<KwsDeviceReference>()
                         .eq(KwsDeviceReference::getMountainId, headerData.getMountainId())
                         .eq(KwsDeviceReference::getMountainId, headerData.getMountainId())
@@ -713,6 +712,15 @@ public class DeviceService {
         String companyId = commonService.getHeaderData(request).getCompanyId();
         String companyId = commonService.getHeaderData(request).getCompanyId();
         //查询基本要素
         //查询基本要素
         List<BaseItemDTO> baseItem = projectDeviceMapper.selectDataByDeviceId(Long.parseLong(id));
         List<BaseItemDTO> baseItem = projectDeviceMapper.selectDataByDeviceId(Long.parseLong(id));
+        Map<String, SystemDict> dictByDictCode = commonService.getDictByDictCode(DictEnum.MODEL_PART);
+        if (!CollectionUtils.isEmpty(baseItem)) {
+            for (BaseItemDTO baseItemDTO : baseItem) {
+                baseItemDTO.setPartNameLabel(baseItemDTO.getPartName() == null ? null :
+                        (dictByDictCode == null ? baseItemDTO.getPartName() :
+                                (dictByDictCode.get(baseItemDTO.getPartName()) == null ?
+                                        (baseItemDTO.getPartName()) : dictByDictCode.get(baseItemDTO.getPartName()).getLabel())));
+            }
+        }
         List<IntegrationItemVO> integrationItem = projectDeviceMapper.selectIntegrationItemByDeviceId(Long.parseLong(id));
         List<IntegrationItemVO> integrationItem = projectDeviceMapper.selectIntegrationItemByDeviceId(Long.parseLong(id));
         com.alibaba.fastjson2.JSONObject jsonObject = new com.alibaba.fastjson2.JSONObject();
         com.alibaba.fastjson2.JSONObject jsonObject = new com.alibaba.fastjson2.JSONObject();
         jsonObject.put("baseItem", baseItem);
         jsonObject.put("baseItem", baseItem);

+ 5 - 4
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/service/MysqlDemoService.java

@@ -2,8 +2,8 @@ package com.sckw.slope.detection.service;
 
 
 
 
 import com.alibaba.fastjson2.JSONObject;
 import com.alibaba.fastjson2.JSONObject;
-import com.sckw.slope.detection.dao.mysql.KwtLogisticsOrderMapper;
-import com.sckw.slope.detection.model.dos.mysql.KwtLogisticsOrder;
+import com.sckw.slope.detection.dao.mysql.KwsProjectMapper;
+import com.sckw.slope.detection.model.dos.mysql.KwsProject;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
 
 
@@ -18,9 +18,10 @@ import java.util.List;
 public class MysqlDemoService {
 public class MysqlDemoService {
 
 
     @Autowired
     @Autowired
-    KwtLogisticsOrderMapper logisticsOrderMapper;
+    KwsProjectMapper projectMapper;
     public void mysqlDemo() {
     public void mysqlDemo() {
-        List<KwtLogisticsOrder> kwtLogisticsOrders = logisticsOrderMapper.selectList(null);
+
+        List<KwsProject> kwtLogisticsOrders = projectMapper.selectList(null);
         System.out.println(JSONObject.toJSONString(kwtLogisticsOrders));
         System.out.println(JSONObject.toJSONString(kwtLogisticsOrders));
     }
     }
 }
 }

+ 398 - 72
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/service/ThresholdService.java

@@ -19,9 +19,11 @@ import com.sckw.slope.detection.model.dos.mysql.*;
 import com.sckw.slope.detection.model.dos.tdengine.Devices;
 import com.sckw.slope.detection.model.dos.tdengine.Devices;
 import com.sckw.slope.detection.model.dto.*;
 import com.sckw.slope.detection.model.dto.*;
 import com.sckw.slope.detection.model.param.ProjectAndDeviceParam;
 import com.sckw.slope.detection.model.param.ProjectAndDeviceParam;
+import com.sckw.slope.detection.model.param.ProjectThresholdSettingParam;
 import com.sckw.slope.detection.model.param.ThresholdDetailQuery;
 import com.sckw.slope.detection.model.param.ThresholdDetailQuery;
 import com.sckw.slope.detection.model.param.ThresholdQuery;
 import com.sckw.slope.detection.model.param.ThresholdQuery;
 import com.sckw.slope.detection.model.vo.ProjectAndDeviceVo;
 import com.sckw.slope.detection.model.vo.ProjectAndDeviceVo;
+import com.sckw.slope.detection.model.vo.ProjectThresholdSettingVO;
 import com.sckw.slope.detection.model.vo.ThresholdDetailVO;
 import com.sckw.slope.detection.model.vo.ThresholdDetailVO;
 import com.sckw.slope.detection.service.repository.KwsThresholdRepository;
 import com.sckw.slope.detection.service.repository.KwsThresholdRepository;
 import jakarta.servlet.http.HttpServletRequest;
 import jakarta.servlet.http.HttpServletRequest;
@@ -61,6 +63,9 @@ public class ThresholdService {
     @Autowired
     @Autowired
     DevicesMapper devicesMapper;
     DevicesMapper devicesMapper;
 
 
+    @Autowired
+    KwsProjectDeviceMapper projectDeviceMapper;
+
     @Autowired
     @Autowired
     KwsDeviceIntegrationMapper deviceIntegrationMapper;
     KwsDeviceIntegrationMapper deviceIntegrationMapper;
 
 
@@ -326,88 +331,168 @@ public class ThresholdService {
             if (twoKwsThreshold != null) {
             if (twoKwsThreshold != null) {
                 String min = twoKwsThreshold.getMin();
                 String min = twoKwsThreshold.getMin();
                 if (min.contains("-")) {
                 if (min.contains("-")) {
-                    min = StringUtils.deleteCharString(min, "-");
+//                    min = StringUtils.deleteCharString(min, "-");
+                    if (Long.parseLong(min) < Long.parseLong(thresholdBean.getMin())) {
+                        log.error("当前等级:{},当前设置阈值:{},存在二级阈值:{}", level, thresholdBean.getMin(), min);
+                        throw new BusinessException("一级最小值阈值设置数据填写错误");
+                    }
+                } else {
+                    if (Long.parseLong(min) > Long.parseLong(thresholdBean.getMin())) {
+                        log.error("当前等级:{},当前设置阈值:{},存在二级阈值:{}", level, thresholdBean.getMin(), min);
+                        throw new BusinessException("一级最小值阈值设置数据填写错误");
+                    }
                 }
                 }
                 String max = twoKwsThreshold.getMax();
                 String max = twoKwsThreshold.getMax();
-                if (Long.parseLong(thresholdBean.getMax()) > Long.parseLong(max)) {
-                    throw new BusinessException("阈值设置数据填写错误");
-                }
-                if (Long.parseLong(thresholdBean.getMin()) > Long.parseLong(min)) {
-                    throw new BusinessException("阈值设置数据填写错误");
+                if (max.contains("-")) {
+                    if (Long.parseLong(max) > Long.parseLong(thresholdBean.getMax())) {
+                        log.error("当前等级:{},当前设置阈值:{},存在二级阈值:{}", level, thresholdBean.getMax(), max);
+                        throw new BusinessException("一级最大值阈值设置数据填写错误");
+                    }
+                } else {
+                    if (Long.parseLong(max) > Long.parseLong(thresholdBean.getMax())) {
+                        log.error("当前等级:{},当前设置阈值:{},存在二级阈值:{}", level, thresholdBean.getMax(), max);
+                        throw new BusinessException("一级最大值阈值设置数据填写错误");
+                    }
                 }
                 }
             }
             }
             if (threeKwsThreshold != null) {
             if (threeKwsThreshold != null) {
                 String min = threeKwsThreshold.getMin();
                 String min = threeKwsThreshold.getMin();
                 if (min.contains("-")) {
                 if (min.contains("-")) {
-                    min = StringUtils.deleteCharString(min, "-");
+                    if (Long.parseLong(min) < Long.parseLong(thresholdBean.getMin())) {
+                        log.error("当前等级:{},当前设置阈值:{},存在三级阈值:{}", level, thresholdBean.getMin(), min);
+                        throw new BusinessException("一级最小值阈值设置数据填写错误");
+                    }
+                } else {
+                    if (Long.parseLong(min) < Long.parseLong(thresholdBean.getMin())) {
+                        log.error("当前等级:{},当前设置阈值:{},存在三级阈值:{}", level, thresholdBean.getMin(), min);
+                        throw new BusinessException("一级最小值阈值设置数据填写错误");
+                    }
                 }
                 }
                 String max = threeKwsThreshold.getMax();
                 String max = threeKwsThreshold.getMax();
-                if (Long.parseLong(thresholdBean.getMax()) > Long.parseLong(max)) {
-                    throw new BusinessException("阈值设置数据填写错误");
-                }
-                if (Long.parseLong(thresholdBean.getMin()) > Long.parseLong(min)) {
-                    throw new BusinessException("阈值设置数据填写错误");
+                if (max.contains("-")) {
+                    if (Long.parseLong(max) > Long.parseLong(thresholdBean.getMax())) {
+                        log.error("当前等级:{},当前设置阈值:{},存在三级阈值:{}", level, thresholdBean.getMax(), max);
+                        throw new BusinessException("一级最大值阈值设置数据填写错误");
+                    }
+                } else {
+                    if (Long.parseLong(max) > Long.parseLong(thresholdBean.getMax())) {
+                        log.error("当前等级:{},当前设置阈值:{},存在三级阈值:{}", level, thresholdBean.getMax(), max);
+                        throw new BusinessException("一级最大值阈值设置数据填写错误");
+                    }
                 }
                 }
             }
             }
         } else if (2 == level) {
         } else if (2 == level) {
             KwsThreshold oneKwsThreshold = thresholdSelect(1, headerData, deviceId, itemName);
             KwsThreshold oneKwsThreshold = thresholdSelect(1, headerData, deviceId, itemName);
             KwsThreshold threeKwsThreshold = thresholdSelect(3, headerData, deviceId, itemName);
             KwsThreshold threeKwsThreshold = thresholdSelect(3, headerData, deviceId, itemName);
             if (oneKwsThreshold != null) {
             if (oneKwsThreshold != null) {
-                String max = oneKwsThreshold.getMax();
                 String min = oneKwsThreshold.getMin();
                 String min = oneKwsThreshold.getMin();
                 if (min.contains("-")) {
                 if (min.contains("-")) {
-                    min = StringUtils.deleteCharString(min, "-");
-                }
-                if (Long.parseLong(thresholdBean.getMax()) < Long.parseLong(max)) {
-                    throw new BusinessException("阈值设置数据填写错误");
+//                    min = StringUtils.deleteCharString(min, "-");
+                    if (Long.parseLong(min) > Long.parseLong(thresholdBean.getMin())) {
+                        log.error("当前等级:{},当前设置阈值:{},存在一级阈值:{}", level, thresholdBean.getMin(), min);
+                        throw new BusinessException("二级最小值阈值设置数据填写错误");
+                    }
+                } else {
+                    if (Long.parseLong(min) > Long.parseLong(thresholdBean.getMin())) {
+                        log.error("当前等级:{},当前设置阈值:{},存在一级阈值:{}", level, thresholdBean.getMin(), min);
+                        throw new BusinessException("阈值设置数据填写错误");
+                    }
                 }
                 }
-                if (Long.parseLong(thresholdBean.getMin()) < Long.parseLong(min)) {
-                    throw new BusinessException("阈值设置数据填写错误");
+                String max = oneKwsThreshold.getMax();
+                if (max.contains("-")) {
+//                    min = StringUtils.deleteCharString(min, "-");
+                    if (Long.parseLong(max) > Long.parseLong(thresholdBean.getMax())) {
+                        log.error("当前等级:{},当前设置阈值:{},存在一级阈值:{}", level, thresholdBean.getMax(), max);
+                        throw new BusinessException("阈值设置数据填写错误");
+                    }
+                } else {
+                    if (Long.parseLong(max) < Long.parseLong(thresholdBean.getMax())) {
+                        log.error("当前等级:{},当前设置阈值:{},存在一级阈值:{}", level, thresholdBean.getMax(), max);
+                        throw new BusinessException("阈值设置数据填写错误");
+                    }
                 }
                 }
             }
             }
             if (threeKwsThreshold != null) {
             if (threeKwsThreshold != null) {
-                String max = threeKwsThreshold.getMax();
                 String min = threeKwsThreshold.getMin();
                 String min = threeKwsThreshold.getMin();
                 if (min.contains("-")) {
                 if (min.contains("-")) {
-                    min = StringUtils.deleteCharString(min, "-");
-                }
-                if (Long.parseLong(thresholdBean.getMax()) > Long.parseLong(max)) {
-                    throw new BusinessException("阈值设置数据填写错误");
+                    if (Long.parseLong(min) < Long.parseLong(thresholdBean.getMin())) {
+                        log.error("当前等级:{},当前设置阈值:{},存在三级阈值:{}", level, thresholdBean.getMin(), min);
+                        throw new BusinessException("二级最小级阈值设置数据填写错误");
+                    }
+                } else {
+                    if (Long.parseLong(min) < Long.parseLong(thresholdBean.getMin())) {
+                        log.error("当前等级:{},当前设置阈值:{},存在三级阈值:{}", level, thresholdBean.getMin(), min);
+                        throw new BusinessException("二级最小级阈值设置数据填写错误");
+                    }
                 }
                 }
-                if (Long.parseLong(thresholdBean.getMin()) > Long.parseLong(min)) {
-                    throw new BusinessException("阈值设置数据填写错误");
+                String max = threeKwsThreshold.getMax();
+                if (max.contains("-")) {
+                    if (Long.parseLong(max) > Long.parseLong(thresholdBean.getMax())) {
+                        log.error("当前等级:{},当前设置阈值:{},存在三级阈值:{}", level, thresholdBean.getMax(), max);
+                        throw new BusinessException("二级最大值阈值设置数据填写错误");
+                    }
+                } else {
+                    if (Long.parseLong(max) > Long.parseLong(thresholdBean.getMax())) {
+                        log.error("当前等级:{},当前设置阈值:{},存在三级阈值:{}", level, thresholdBean.getMax(), max);
+                        throw new BusinessException("二级最大值阈值设置数据填写错误");
+                    }
                 }
                 }
             }
             }
         } else if (3 == level) {
         } else if (3 == level) {
             KwsThreshold oneKwsThreshold = thresholdSelect(1, headerData, deviceId, itemName);
             KwsThreshold oneKwsThreshold = thresholdSelect(1, headerData, deviceId, itemName);
             KwsThreshold twoKwsThreshold = thresholdSelect(2, headerData, deviceId, itemName);
             KwsThreshold twoKwsThreshold = thresholdSelect(2, headerData, deviceId, itemName);
             if (oneKwsThreshold != null) {
             if (oneKwsThreshold != null) {
-                String max = oneKwsThreshold.getMax();
                 String min = oneKwsThreshold.getMin();
                 String min = oneKwsThreshold.getMin();
                 if (min.contains("-")) {
                 if (min.contains("-")) {
-                    min = StringUtils.deleteCharString(min, "-");
-                }
-                if (Long.parseLong(thresholdBean.getMax()) < Long.parseLong(max)) {
-                    throw new BusinessException("阈值设置数据填写错误");
+                    if (Long.parseLong(min) > Long.parseLong(thresholdBean.getMin())) {
+                        log.error("当前等级:{},当前设置阈值:{},存在一级阈值:{}", level, thresholdBean.getMin(), min);
+                        throw new BusinessException("三级最小值阈值设置数据填写错误");
+                    }
+                } else {
+                    if (Long.parseLong(min) < Long.parseLong(thresholdBean.getMin())) {
+                        log.error("当前等级:{},当前设置阈值:{},存在一级阈值:{}", level, thresholdBean.getMin(), min);
+                        throw new BusinessException("三级最小值阈值设置数据填写错误");
+                    }
                 }
                 }
-                if (Long.parseLong(thresholdBean.getMin()) < Long.parseLong(min)) {
-                    throw new BusinessException("阈值设置数据填写错误");
+                String max = oneKwsThreshold.getMax();
+                if (max.contains("-")) {
+                    if (Long.parseLong(max) < Long.parseLong(thresholdBean.getMax())) {
+                        log.error("当前等级:{},当前设置阈值:{},存在一级阈值:{}", level, thresholdBean.getMax(), max);
+                        throw new BusinessException("三级最大值阈值设置数据填写错误");
+                    }
+                } else {
+                    if (Long.parseLong(max) < Long.parseLong(thresholdBean.getMax())) {
+                        log.error("当前等级:{},当前设置阈值:{},存在一级阈值:{}", level, thresholdBean.getMax(), max);
+                        throw new BusinessException("三级最大值阈值设置数据填写错误");
+                    }
                 }
                 }
             }
             }
             if (twoKwsThreshold != null) {
             if (twoKwsThreshold != null) {
-                String max = twoKwsThreshold.getMax();
                 String min = twoKwsThreshold.getMin();
                 String min = twoKwsThreshold.getMin();
                 if (min.contains("-")) {
                 if (min.contains("-")) {
-                    min = StringUtils.deleteCharString(min, "-");
-                }
-                if (Long.parseLong(thresholdBean.getMax()) < Long.parseLong(max)) {
-                    throw new BusinessException("阈值设置数据填写错误");
+                    if (Long.parseLong(min) > Long.parseLong(thresholdBean.getMin())) {
+                        log.error("当前等级:{},当前设置阈值:{},存在二级阈值:{}", level, thresholdBean.getMin(), min);
+                        throw new BusinessException("三级最小值阈值设置数据填写错误");
+                    }
+                } else {
+                    if (Long.parseLong(min) > Long.parseLong(thresholdBean.getMin())) {
+                        log.error("当前等级:{},当前设置阈值:{},存在二级阈值:{}", level, thresholdBean.getMin(), min);
+                        throw new BusinessException("三级最小值阈值设置数据填写错误");
+                    }
                 }
                 }
-                if (Long.parseLong(thresholdBean.getMin()) < Long.parseLong(min)) {
-                    throw new BusinessException("阈值设置数据填写错误");
+                String max = twoKwsThreshold.getMax();
+                if (max.contains("-")) {
+                    if (Long.parseLong(thresholdBean.getMax()) > Long.parseLong(max)) {
+                        log.error("当前等级:{},当前设置阈值:{},存在二级阈值:{}", level, thresholdBean.getMax(), max);
+                        throw new BusinessException("三级最大值阈值设置数据填写错误");
+                    }
+                } else {
+                    if (Long.parseLong(max) < Long.parseLong(thresholdBean.getMax())) {
+                        log.error("当前等级:{},当前设置阈值:{},存在二级阈值:{}", level, thresholdBean.getMax(), max);
+                        throw new BusinessException("三级最大值阈值设置数据填写错误");
+                    }
                 }
                 }
             }
             }
-
         }
         }
     }
     }
 
 
@@ -416,7 +501,7 @@ public class ThresholdService {
                 .eq(KwsThreshold::getMountainId, headerData.getMountainId())
                 .eq(KwsThreshold::getMountainId, headerData.getMountainId())
                 .eq(KwsThreshold::getDeviceId, deviceId)
                 .eq(KwsThreshold::getDeviceId, deviceId)
                 .eq(KwsThreshold::getItemName, itemName)
                 .eq(KwsThreshold::getItemName, itemName)
-                .eq(KwsThreshold::getLevel, 2)
+                .eq(KwsThreshold::getLevel, level)
                 .eq(KwsThreshold::getDelFlag, NumberConstant.ZERO)
                 .eq(KwsThreshold::getDelFlag, NumberConstant.ZERO)
         );
         );
         return threshold;
         return threshold;
@@ -429,53 +514,87 @@ public class ThresholdService {
         ThresholdBean thresholdBeanTwo = maps.get(2);
         ThresholdBean thresholdBeanTwo = maps.get(2);
         ThresholdBean thresholdBeanThree = maps.get(3);
         ThresholdBean thresholdBeanThree = maps.get(3);
         if (thresholdBeanTwo != null) {
         if (thresholdBeanTwo != null) {
-            String min = thresholdBeanTwo.getMin();
-            if (min.contains("-")) {
-                min = com.sckw.core.utils.StringUtils.deleteCharString(min, "-");
-            }
-            String max = thresholdBeanTwo.getMax();
+            String min = thresholdBeanTwo.getMin();//10
+            String max = thresholdBeanTwo.getMax();//90
             if (thresholdBeanThree != null) {
             if (thresholdBeanThree != null) {
-                String minThree = thresholdBeanThree.getMin();
-                if (minThree.contains("-")) {
-                    minThree = com.sckw.core.utils.StringUtils.deleteCharString(minThree, "-");
-                }
-                String maxThree = thresholdBeanThree.getMax();
-                if (BigDecimal.valueOf(Long.parseLong(max)).compareTo(BigDecimal.valueOf(Long.parseLong(maxThree))) > 0) {
+                String minThree = thresholdBeanThree.getMin();//8
+//                if (minThree.contains("-")) {
+//                    minThree = com.sckw.core.utils.StringUtils.deleteCharString(minThree, "-");//-8
+//                }
+                String maxThree = thresholdBeanThree.getMax();//80
+                if (BigDecimal.valueOf(Long.parseLong(max)).compareTo(BigDecimal.valueOf(Long.parseLong(maxThree))) < 0) {
                     throw new BusinessException("阈值填写错误");
                     throw new BusinessException("阈值填写错误");
                 }
                 }
-                if (BigDecimal.valueOf(Long.parseLong(min)).compareTo(BigDecimal.valueOf(Long.parseLong(minThree))) < 0) {
-                    throw new BusinessException("阈值填写错误");
+                if (min.contains("-")) {
+//                min = com.sckw.core.utils.StringUtils.deleteCharString(min, "-");//-10
+                    if (BigDecimal.valueOf(Long.parseLong(min)).compareTo(BigDecimal.valueOf(Long.parseLong(minThree))) > 0) {
+                        throw new BusinessException("阈值填写错误");
+                    }
+                } else {
+                    if (BigDecimal.valueOf(Long.parseLong(min)).compareTo(BigDecimal.valueOf(Long.parseLong(minThree))) > 0) {
+                        throw new BusinessException("阈值填写错误");
+                    }
                 }
                 }
+
             }
             }
             if (thresholdBeanOne != null) {
             if (thresholdBeanOne != null) {
-                String minOne = thresholdBeanOne.getMin();
-                if (minOne.contains("-")) {
-                    minOne = com.sckw.core.utils.StringUtils.deleteCharString(minOne, "-");
-                }
-                String maxThree = thresholdBeanOne.getMax();
-                if (BigDecimal.valueOf(Long.parseLong(max)).compareTo(BigDecimal.valueOf(Long.parseLong(maxThree))) < 0) {
+                String minOne = thresholdBeanOne.getMin(); //15
+                String maxThree = thresholdBeanOne.getMax();//100
+                if (BigDecimal.valueOf(Long.parseLong(max)).compareTo(BigDecimal.valueOf(Long.parseLong(maxThree))) > 0) {
                     throw new BusinessException("阈值填写错误");
                     throw new BusinessException("阈值填写错误");
                 }
                 }
-                if (BigDecimal.valueOf(Long.parseLong(min)).compareTo(BigDecimal.valueOf(Long.parseLong(minOne))) > 0) {
-                    throw new BusinessException("阈值填写错误");
+                if (minOne.contains("-")) {
+//                    minOne = com.sckw.core.utils.StringUtils.deleteCharString(minOne, "-");//-15
+                    if (BigDecimal.valueOf(Long.parseLong(min)).compareTo(BigDecimal.valueOf(Long.parseLong(minOne))) < 0) {
+                        throw new BusinessException("阈值填写错误");
+                    }
+                } else {
+                    if (BigDecimal.valueOf(Long.parseLong(min)).compareTo(BigDecimal.valueOf(Long.parseLong(minOne))) < 0) {
+                        throw new BusinessException("阈值填写错误");
+                    }
                 }
                 }
             }
             }
         }
         }
         if (thresholdBeanThree != null) {
         if (thresholdBeanThree != null) {
-            String minThree = thresholdBeanThree.getMin();
-            if (minThree.contains("-")) {
-                minThree = com.sckw.core.utils.StringUtils.deleteCharString(minThree, "-");
-            }
-            String maxThree = thresholdBeanThree.getMax();
+            String minThree = thresholdBeanThree.getMin();//8
+            String maxThree = thresholdBeanThree.getMax();//80
             if (thresholdBeanTwo != null) {
             if (thresholdBeanTwo != null) {
-                String twoMax = thresholdBeanTwo.getMax();
-                String twoMin = thresholdBeanTwo.getMin();
-                if (BigDecimal.valueOf(Long.parseLong(twoMax)).compareTo(BigDecimal.valueOf(Long.parseLong(maxThree))) > 0) {
+                String twoMax = thresholdBeanTwo.getMax();//90
+                String twoMin = thresholdBeanTwo.getMin();//-10
+                if (BigDecimal.valueOf(Long.parseLong(twoMax)).compareTo(BigDecimal.valueOf(Long.parseLong(maxThree))) < 0) {
                     throw new BusinessException("阈值填写错误");
                     throw new BusinessException("阈值填写错误");
                 }
                 }
-                if (BigDecimal.valueOf(Long.parseLong(twoMin)).compareTo(BigDecimal.valueOf(Long.parseLong(minThree))) > 0) {
+                if (minThree.contains("-")) {
+//                    minThree = com.sckw.core.utils.StringUtils.deleteCharString(minThree, "-");//-8
+                    if (BigDecimal.valueOf(Long.parseLong(twoMin)).compareTo(BigDecimal.valueOf(Long.parseLong(minThree))) > 0) {
+                        throw new BusinessException("阈值填写错误");
+                    }
+                } else {
+                    if (BigDecimal.valueOf(Long.parseLong(twoMin)).compareTo(BigDecimal.valueOf(Long.parseLong(minThree))) > 0) {
+                        throw new BusinessException("阈值填写错误");
+                    }
+                }
+//                if (twoMin.contains("-")) {
+//                    twoMin = com.sckw.core.utils.StringUtils.deleteCharString(twoMin, "-");//-8
+//                }
+
+            }
+            if (thresholdBeanOne != null) {
+                String oneMax = thresholdBeanOne.getMax();//100
+                String oneMin = thresholdBeanOne.getMin();//-15
+                if (BigDecimal.valueOf(Long.parseLong(oneMax)).compareTo(BigDecimal.valueOf(Long.parseLong(maxThree))) < 0) {
                     throw new BusinessException("阈值填写错误");
                     throw new BusinessException("阈值填写错误");
                 }
                 }
+                if (oneMin.contains("-")) {
+//                    oneMin = com.sckw.core.utils.StringUtils.deleteCharString(oneMin, "-");//-8
+                    if (BigDecimal.valueOf(Long.parseLong(oneMin)).compareTo(BigDecimal.valueOf(Long.parseLong(minThree))) > 0) {
+                        throw new BusinessException("阈值填写错误");
+                    }
+                } else {
+                    if (BigDecimal.valueOf(Long.parseLong(oneMin)).compareTo(BigDecimal.valueOf(Long.parseLong(minThree))) > 0) {
+                        throw new BusinessException("阈值填写错误");
+                    }
+                }
             }
             }
         }
         }
     }
     }
@@ -708,4 +827,211 @@ public class ThresholdService {
         }
         }
         return HttpResult.ok(vo);
         return HttpResult.ok(vo);
     }
     }
+
+    public HttpResult selectSetting(ProjectThresholdSettingParam param, HttpServletRequest request) {
+        HeaderData headerData = commonService.getHeaderData(request);
+        String projectId = param.getProjectId();
+        //100 全部  0未设置 1 部分设置 2 已设置
+        String type = param.getType();
+        if ("100".equals(type)) {
+            return getDeviceAll(projectId, headerData,param);
+        } else {
+            List<ProjectThresholdSettingVO> returnList = new ArrayList<>();
+            List<KwsProjectDevice> selectList = projectDeviceMapper.selectList(new LambdaQueryWrapper<KwsProjectDevice>()
+                    .eq(KwsProjectDevice::getDelFlag, 0)
+                    .eq(KwsProjectDevice::getProjectId, Long.parseLong(projectId))
+            );
+            if (CollectionUtils.isEmpty(selectList)) {
+                return HttpResult.ok();
+            }
+            List<Long> deviceIds = selectList.stream().map(KwsProjectDevice::getDeviceId).distinct().collect(Collectors.toList());
+            if (CollectionUtils.isEmpty(deviceIds)) {
+                return HttpResult.ok();
+            }
+            List<String> typeSetting = new ArrayList<>();
+            typeSetting.add("0");
+            typeSetting.add("1");
+            typeSetting.add("2");
+            LambdaQueryWrapper<KwsThreshold> wrapper = new LambdaQueryWrapper<>();
+            wrapper.eq(KwsThreshold::getDelFlag, NumberConstant.ZERO)
+                    .eq(KwsThreshold::getStatus, NumberConstant.ZERO)
+                    .eq(KwsThreshold::getMountainId, headerData.getMountainId())
+                    .in(KwsThreshold::getDeviceId, deviceIds)
+            ;
+            KwsProject project = projectMapper.selectById(Long.parseLong(projectId));
+            if (typeSetting.contains(type)) {
+                wrapper.eq(KwsThreshold::getSetting, type);
+                List<KwsThreshold> kwsThresholds = thresholdMapper.selectList(wrapper);
+                if (CollectionUtils.isEmpty(kwsThresholds)) {
+                    return HttpResult.ok();
+                }
+                deviceIds = kwsThresholds.stream().map(KwsThreshold::getDeviceId).distinct().collect(Collectors.toList());
+                for (Long deviceId : deviceIds) {
+                    ProjectThresholdSettingVO vo = new ProjectThresholdSettingVO();
+                    vo.setProjectId(projectId);
+                    vo.setProjectName(project == null ? null : project.getName());
+                    vo.setDeviceId(deviceId.toString());
+                    KwsDevice kwsDevice = deviceMapper.selectById(deviceId);
+                    vo.setDeviceName(kwsDevice == null ? null : kwsDevice.getName());
+                    List<Integer> status = new ArrayList<>();
+                    status.add(DeviceEnum.ALREADY_REFERRED_TO.getCode());
+                    //基本要素
+                    List<DeviceElementDTO> basiclElementList = deviceModelPartMapper.selectElementList(projectId,
+                            headerData.getMountainId(), status, deviceId);
+                    Map<String, SystemDict> dictByDictCode = commonService.getDictByDictCode(DictEnum.MODEL_PART);
+                    StringBuilder itemNames = new StringBuilder();
+                    List<String> itemNameList = new ArrayList<>();
+                    if (!CollectionUtils.isEmpty(basiclElementList)) {
+                        for (DeviceElementDTO deviceElementDTO : basiclElementList) {
+                            String itemNameLabel = deviceElementDTO.getElement() == null ? null : (
+                                    dictByDictCode == null ? deviceElementDTO.getElement() : (dictByDictCode.get(deviceElementDTO.getElement()) == null ? deviceElementDTO.getElement() :
+                                            (dictByDictCode.get(deviceElementDTO.getElement()).getLabel())
+                                    )
+                            );
+                            if (Objects.nonNull(itemNameLabel)) {
+                                itemNameList.add(itemNameLabel);
+                            }
+                        }
+                    }
+                    //集成要素
+                    List<DeviceElementDTO> integratedElementList = deviceIntegrationMapper.selectIntegratedElement(projectId,
+                            headerData.getMountainId(), status, deviceId);
+                    if (!CollectionUtils.isEmpty(integratedElementList)) {
+                        List<String> integratedItemName = integratedElementList.stream().map(DeviceElementDTO::getIntegrationElement).distinct().collect(Collectors.toList());
+                        if (!CollectionUtils.isEmpty(integratedItemName)) {
+                            itemNameList.addAll(integratedItemName);
+                        }
+                    }
+                    if (!CollectionUtils.isEmpty(itemNameList)) {
+                        for (int i = 0; i < itemNameList.size(); i++) {
+                            if (i != (itemNameList.size() - 1)) {
+                                itemNames.append(itemNameList.get(i)).append(",");
+                            } else {
+                                itemNames.append(itemNameList.get(i));
+                            }
+                        }
+                    }
+
+                    vo.setItemNames(itemNames == null ? null : itemNames.toString());
+                    //阈值联系人
+                    List<KwsThreshold> thresholdList = thresholdMapper.selectList(new LambdaQueryWrapper<KwsThreshold>()
+                            .eq(KwsThreshold::getStatus, NumberConstant.ZERO)
+                            .eq(KwsThreshold::getDelFlag, 0)
+                            .eq(KwsThreshold::getMountainId, headerData.getMountainId())
+                            .orderByDesc(KwsThreshold::getCreateTime)
+                    );
+                    StringBuilder phoneList = new StringBuilder();
+                    if (!CollectionUtils.isEmpty(thresholdList)) {
+                        List<String> phones = thresholdList.stream().map(KwsThreshold::getPhones).distinct().collect(Collectors.toList());
+                        if (!CollectionUtils.isEmpty(phones)) {
+                            for (int i = 0; i < phones.size(); i++) {
+                                if (i != (phones.size() - 1)) {
+                                    phoneList.append(phones.get(i)).append(",");
+                                } else {
+                                    phoneList.append(phones.get(i));
+                                }
+                            }
+                        }
+                        vo.setPhones(phoneList == null ? null : phoneList.toString());
+                        vo.setUpdateTime(thresholdList.get(0).getCreateTime());
+                    }
+                    returnList.add(vo);
+                }
+            }
+            if (!CollectionUtils.isEmpty(returnList)){
+                returnList = returnList.stream().skip((param.getPage() - 1) * param.getPageSize()).limit(param.getPageSize()).collect(Collectors.toList());
+            }
+            return HttpResult.ok(returnList);
+        }
+    }
+
+    private HttpResult getDeviceAll(String projectId, HeaderData headerData,ProjectThresholdSettingParam param) {
+        List<ProjectThresholdSettingVO> returnList = new ArrayList<>();
+        List<KwsProjectDevice> selectList = projectDeviceMapper.selectList(new LambdaQueryWrapper<KwsProjectDevice>()
+                .eq(KwsProjectDevice::getDelFlag, 0)
+                .eq(KwsProjectDevice::getProjectId, Long.parseLong(projectId))
+        );
+        if (CollectionUtils.isEmpty(selectList)) {
+            return HttpResult.ok();
+        }
+        List<Long> deviceIds = selectList.stream().map(KwsProjectDevice::getDeviceId).distinct().collect(Collectors.toList());
+        if (CollectionUtils.isEmpty(deviceIds)) {
+            return HttpResult.ok();
+        }
+        ProjectThresholdSettingVO returnData = new ProjectThresholdSettingVO();
+        KwsProject project = projectMapper.selectById(Long.parseLong(projectId));
+        for (Long deviceId : deviceIds) {
+            returnData.setProjectId(projectId);
+            returnData.setProjectName(project == null ? null : project.getName());
+            returnData.setDeviceId(deviceId.toString());
+            KwsDevice kwsDevice = deviceMapper.selectById(deviceId);
+            returnData.setDeviceName(kwsDevice == null ? null : kwsDevice.getName());
+            List<Integer> status = new ArrayList<>();
+            status.add(DeviceEnum.ALREADY_REFERRED_TO.getCode());
+            //基本要素
+            List<DeviceElementDTO> basiclElementList = deviceModelPartMapper.selectElementList(projectId,
+                    headerData.getMountainId(), status, deviceId);
+            Map<String, SystemDict> dictByDictCode = commonService.getDictByDictCode(DictEnum.MODEL_PART);
+            StringBuilder itemNames = new StringBuilder();
+            List<String> itemNameList = new ArrayList<>();
+            if (!CollectionUtils.isEmpty(basiclElementList)) {
+                for (DeviceElementDTO deviceElementDTO : basiclElementList) {
+                    String itemNameLabel = deviceElementDTO.getElement() == null ? null : (
+                            dictByDictCode == null ? deviceElementDTO.getElement() : (dictByDictCode.get(deviceElementDTO.getElement()) == null ? deviceElementDTO.getElement() :
+                                    (dictByDictCode.get(deviceElementDTO.getElement()).getLabel())
+                            )
+                    );
+                    if (Objects.nonNull(itemNameLabel)) {
+                        itemNameList.add(itemNameLabel);
+                    }
+                }
+            }
+            //集成要素
+            List<DeviceElementDTO> integratedElementList = deviceIntegrationMapper.selectIntegratedElement(projectId,
+                    headerData.getMountainId(), status, deviceId);
+            if (!CollectionUtils.isEmpty(integratedElementList)) {
+                List<String> integratedItemName = integratedElementList.stream().map(DeviceElementDTO::getIntegrationElement).distinct().collect(Collectors.toList());
+                if (!CollectionUtils.isEmpty(integratedItemName)) {
+                    itemNameList.addAll(integratedItemName);
+                }
+            }
+            if (!CollectionUtils.isEmpty(itemNameList)) {
+                for (int i = 0; i < itemNameList.size(); i++) {
+                    if (i != (itemNameList.size() - 1)) {
+                        itemNames.append(itemNameList.get(i)).append(",");
+                    } else {
+                        itemNames.append(itemNameList.get(i));
+                    }
+                }
+            }
+            returnData.setItemNames(itemNames == null ? null : itemNames.toString());
+            //阈值联系人
+            List<KwsThreshold> thresholdList = thresholdMapper.selectList(new LambdaQueryWrapper<KwsThreshold>()
+                    .eq(KwsThreshold::getStatus, NumberConstant.ZERO)
+                    .eq(KwsThreshold::getDelFlag, 0)
+                    .eq(KwsThreshold::getMountainId, headerData.getMountainId())
+                    .orderByDesc(KwsThreshold::getCreateTime)
+            );
+            StringBuilder phoneList = new StringBuilder();
+            if (!CollectionUtils.isEmpty(thresholdList)) {
+                List<String> phones = thresholdList.stream().map(KwsThreshold::getPhones).distinct().collect(Collectors.toList());
+                if (!CollectionUtils.isEmpty(phones)) {
+                    for (int i = 0; i < phones.size(); i++) {
+                        if (i != (phones.size() - 1)) {
+                            phoneList.append(phones.get(i)).append(",");
+                        } else {
+                            phoneList.append(phones.get(i));
+                        }
+                    }
+                }
+                returnData.setUpdateTime(thresholdList.get(0).getCreateTime());
+            }
+            returnData.setPhones(phoneList == null ? null : phoneList.toString());
+            returnList.add(returnData);
+        }
+        if (!CollectionUtils.isEmpty(returnList)){
+            returnList = returnList.stream().skip((param.getPage() - 1) * param.getPageSize()).limit(param.getPageSize()).collect(Collectors.toList());
+        }
+        return HttpResult.ok(returnList);
+    }
 }
 }

+ 154 - 0
slope-modules/slope-detection/src/main/resources/log4j2-bak.xml

@@ -0,0 +1,154 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<configuration status="info" monitorInterval="30">
+    <properties>
+        <!-- 格式化输出:%date表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度 %msg:日志消息,%n是换行符 -->
+        <!-- %logger{36} 表示 Logger 名字最长36个字符 -->
+        <property name="LOG_PATTERN"
+                  value="%clr{%d{yyyy-MM-dd HH:mm:ss.SSS}}{faint} %X{traceId} %clr{%5p} %clr{${sys:PID}}{magenta} %clr{---}{faint} %clr{[%t]}{faint} %clr{%c{1.}}{cyan} %clr{:}{faint} %m%n%xwEx"/>
+        <property name="LOG_WITHOUT_COLOR_PATTERN"
+                  value="%d{yyyy-MM-dd HH:mm:ss.SSS} %5p %X{traceId} ${sys:PID}--- [%t] %c{1.} : %m%n%xwEx"/>
+        <property name="LOG_PATH" value="logs/slope-detection"/>
+    </properties>
+    <!--DEBUG<INFO<WARNING<ERROR<CRITICAL-->
+    <!-- 先定义所有的appender(附加器)-->
+    <appenders>
+        <!-- 输出控制台的配置 -->
+        <Console name="Console" target="SYSTEM_OUT">
+            <!-- 输出日志的格式 -->
+            <PatternLayout pattern="${LOG_PATTERN}"/>
+        </Console>
+
+        <!--all级别日志-->
+        <RollingFile name="allFileAppender"
+                     fileName="${LOG_PATH}/all.log"
+                     filePattern="${LOG_PATH}/$${date:yyyy-MM}/all-%d{yyyy-MM-dd}-%i.log.gz">
+            <PatternLayout pattern="${LOG_WITHOUT_COLOR_PATTERN}"/>
+
+            <Policies>
+                <!-- 设置日志文件切分参数 -->
+                <!--<OnStartupTriggeringPolicy/>-->
+                <!--设置日志基础文件大小,超过该大小就触发日志文件滚动更新-->
+                <SizeBasedTriggeringPolicy size="100MB"/>
+                <!--设置日志文件滚动更新的时间,依赖于文件命名filePattern的设置-->
+                <TimeBasedTriggeringPolicy/>
+            </Policies>
+            <!--设置日志的文件个数上限,不设置默认为7个,超过大小后会被覆盖;依赖于filePattern中的%i-->
+            <DefaultRolloverStrategy max="100"/>
+        </RollingFile>
+
+        <!--debug级别日志-->
+        <RollingFile name="debugFileAppender"
+                     fileName="${LOG_PATH}/debug.log"
+                     filePattern="${LOG_PATH}/$${date:yyyy-MM}/debug-%d{yyyy-MM-dd}-%i.log.gz">
+            <Filters>
+                <!--过滤掉info及更高级别日志-->
+                <ThresholdFilter level="info" onMatch="DENY" onMismatch="NEUTRAL"/>
+            </Filters>
+            <!--设置日志格式-->
+            <PatternLayout pattern="${LOG_WITHOUT_COLOR_PATTERN}"/>
+
+            <Policies>
+                <!-- 设置日志文件切分参数 -->
+                <!--<OnStartupTriggeringPolicy/>-->
+                <!--设置日志基础文件大小,超过该大小就触发日志文件滚动更新-->
+                <SizeBasedTriggeringPolicy size="100MB"/>
+                <!--设置日志文件滚动更新的时间,依赖于文件命名filePattern的设置-->
+                <TimeBasedTriggeringPolicy/>
+            </Policies>
+            <!--设置日志的文件个数上限,不设置默认为7个,超过大小后会被覆盖;依赖于filePattern中的%i-->
+            <DefaultRolloverStrategy max="100"/>
+        </RollingFile>
+
+        <!--info级别日志-->
+        <RollingFile name="infoFileAppender"
+                     fileName="${LOG_PATH}/info.log"
+                     filePattern="${LOG_PATH}/$${date:yyyy-MM}/info-%d{yyyy-MM-dd}-%i.log.gz">
+            <Filters>
+                <!--过滤掉warn及更高级别日志-->
+                <ThresholdFilter level="warn" onMatch="DENY" onMismatch="NEUTRAL"/>
+            </Filters>
+            <!--设置日志格式-->
+            <PatternLayout pattern="${LOG_WITHOUT_COLOR_PATTERN}"/>
+
+            <Policies>
+                <!-- 设置日志文件切分参数 -->
+                <!--<OnStartupTriggeringPolicy/>-->
+                <!--设置日志基础文件大小,超过该大小就触发日志文件滚动更新-->
+                <SizeBasedTriggeringPolicy size="100MB"/>
+                <!--设置日志文件滚动更新的时间,依赖于文件命名filePattern的设置-->
+                <TimeBasedTriggeringPolicy interval="1" modulate="true"/>
+            </Policies>
+            <!--设置日志的文件个数上限,不设置默认为7个,超过大小后会被覆盖;依赖于filePattern中的%i-->
+            <!--<DefaultRolloverStrategy max="100"/>-->
+        </RollingFile>
+
+        <!--warn级别日志-->
+        <RollingFile name="warnFileAppender"
+                     fileName="${LOG_PATH}/warn.log"
+                     filePattern="${LOG_PATH}/$${date:yyyy-MM}/warn-%d{yyyy-MM-dd}-%i.log.gz">
+            <Filters>
+                <!--过滤掉error及更高级别日志-->
+                <ThresholdFilter level="error" onMatch="DENY" onMismatch="NEUTRAL"/>
+            </Filters>
+            <!--设置日志格式-->
+            <PatternLayout pattern="${LOG_WITHOUT_COLOR_PATTERN}"/>
+
+            <Policies>
+                <!-- 设置日志文件切分参数 -->
+                <!--<OnStartupTriggeringPolicy/>-->
+                <!--设置日志基础文件大小,超过该大小就触发日志文件滚动更新-->
+                <SizeBasedTriggeringPolicy size="100MB"/>
+                <!--设置日志文件滚动更新的时间,依赖于文件命名filePattern的设置-->
+                <TimeBasedTriggeringPolicy/>
+            </Policies>
+            <!--设置日志的文件个数上限,不设置默认为7个,超过大小后会被覆盖;依赖于filePattern中的%i-->
+            <DefaultRolloverStrategy max="100"/>
+        </RollingFile>
+
+        <!--error及更高级别日志-->
+        <RollingFile name="errorFileAppender"
+                     fileName="${LOG_PATH}/error.log"
+                     filePattern="${LOG_PATH}/$${date:yyyy-MM}/error-%d{yyyy-MM-dd}-%i.log.gz">
+            <!--设置日志格式-->
+            <PatternLayout pattern="${LOG_WITHOUT_COLOR_PATTERN}"/>
+            <Policies>
+                <!-- 设置日志文件切分参数 -->
+                <!--<OnStartupTriggeringPolicy/>-->
+                <!--设置日志基础文件大小,超过该大小就触发日志文件滚动更新-->
+                <SizeBasedTriggeringPolicy size="100MB"/>
+                <!--设置日志文件滚动更新的时间,依赖于文件命名filePattern的设置-->
+                <TimeBasedTriggeringPolicy/>
+            </Policies>
+            <!--设置日志的文件个数上限,不设置默认为7个,超过大小后会被覆盖;依赖于filePattern中的%i-->
+            <DefaultRolloverStrategy max="100"/>
+        </RollingFile>
+
+        <!--json格式error级别日志-->
+        <RollingFile name="errorJsonAppender"
+                     fileName="${LOG_PATH}/error-json.log"
+                     filePattern="${LOG_PATH}/$${date:yyyy-MM}/error-json-%d{yyyy-MM-dd}-%i.log.gz">
+            <JSONLayout compact="true" eventEol="true" locationInfo="true"/>
+            <Policies>
+                <SizeBasedTriggeringPolicy size="100 MB"/>
+                <TimeBasedTriggeringPolicy interval="1" modulate="true"/>
+            </Policies>
+        </RollingFile>
+
+    </appenders>
+
+    <loggers>
+        <root level="debug">
+            <AppenderRef ref="allFileAppender" level="all"/>
+            <AppenderRef ref="debugFileAppender" level="debug"/>
+            <AppenderRef ref="infoFileAppender" level="info"/>
+            <AppenderRef ref="warnFileAppender" level="warn"/>
+            <AppenderRef ref="errorFileAppender" level="error"/>
+            <AppenderRef ref="errorJsonAppender" level="error"/>
+            <appender-ref ref="Console" level="info"/>
+        </root>
+        <Logger name="org.springframework" level="info"/>
+        <Logger name="com.alibaba" level="info"/>
+        <Logger name="com.baomidou" level="info"/>
+    </loggers>
+
+</configuration>

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

@@ -294,7 +294,11 @@
         FROM kws_device a
         FROM kws_device a
                  LEFT JOIN kws_project_device b ON a.id = b.device_id
                  LEFT JOIN kws_project_device b ON a.id = b.device_id
                  LEFT JOIN kws_project c ON b.project_id = c.id
                  LEFT JOIN kws_project c ON b.project_id = c.id
-        WHERE c.id = #{projectId}
+        WHERE
+         a.del_flag=0
+        and b.del_flag=0
+        and c.del_flag=0
+        and c.id = #{projectId}
     </select>
     </select>
 
 
     <select id="selectDeviceAllByProjectAndMountainId" resultType="com.sckw.slope.detection.model.dto.ThresholdSelectDTO">
     <select id="selectDeviceAllByProjectAndMountainId" resultType="com.sckw.slope.detection.model.dto.ThresholdSelectDTO">

+ 2 - 2
slope-modules/slope-detection/src/main/resources/mapper/mysql/KwsProjectDeviceMapper.xml

@@ -186,12 +186,12 @@ WHERE
              d.integration_name AS integrationName
              d.integration_name AS integrationName
       FROM kws_project_device a
       FROM kws_project_device a
                LEFT JOIN kws_device b ON a.device_id = b.id
                LEFT JOIN kws_device b ON a.device_id = b.id
-               LEFT JOIN kws_device_integration c ON b.id = c.integration_id
+               LEFT JOIN kws_device_integration c ON b.id = c.device_id
                LEFT JOIN kws_integration d ON c.integration_id = d.id
                LEFT JOIN kws_integration d ON c.integration_id = d.id
       WHERE a.del_flag = 0
       WHERE a.del_flag = 0
         AND b.del_flag = 0
         AND b.del_flag = 0
         and c.del_flag = 0
         and c.del_flag = 0
-        and d.del_flag
+        and d.del_flag = 0
         and b.id = #{id}
         and b.id = #{id}
   </select>
   </select>
 
 

+ 6 - 6
slope-modules/slope-detection/src/main/resources/mapper/tdengine/InsTables.xml

@@ -33,7 +33,7 @@
         <include refid="Base_List">
         <include refid="Base_List">
         </include>
         </include>
         from information_schema.ins_tables a
         from information_schema.ins_tables a
-        where a.db_name = 'devices'
+        where a.db_name = 'devicesv2'
           and a.table_name = #{tableName}
           and a.table_name = #{tableName}
     </select>
     </select>
 
 
@@ -41,12 +41,12 @@
         CREATE TABLE #{tableName}
         CREATE TABLE #{tableName}
         (
         (
             ts          TIMESTAMP,
             ts          TIMESTAMP,
-            raw_id      TIMESTAMP,
-            tslver_id   INT ,
+            tslver_id   INT,
+            line        VARCHAR(64),
+            val         VARCHAR(64),
+            msg_id      VARCHAR(64),
             guid        VARCHAR(64),
             guid        VARCHAR(64),
-            line        VARCHAR(16),
-            val         VARCHAR(16),
-            create_time TIMESTAMP
+            raw_ts      TIMESTAMP
         )
         )
     </insert>
     </insert>
 </mapper>
 </mapper>