lengfaqiang 2 tahun lalu
induk
melakukan
626f2b9d3f

+ 4 - 4
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/consumer/MqttCallbackHandler.java

@@ -697,10 +697,10 @@ public class MqttCallbackHandler extends AbstractHandler {
                 .eq(KwsAlarm::getDelFlag, 0)
                 .orderByDesc(KwsAlarm::getCreateTime);
         if (projectDevice != null) {
-            wrapper.eq(KwsAlarm::getProjectId, projectDevice.getProjectId())
-                    .eq(KwsAlarm::getMountainId, projectDevice.getMountainId());
+            wrapper.eq(Objects.nonNull(projectDevice.getProjectId()), KwsAlarm::getProjectId, projectDevice.getProjectId())
+                    .eq(StringUtils.isNotBlank(device.getMountainId()),KwsAlarm::getMountainId, projectDevice.getMountainId());
             if (projectDevice.getProjectId() != null) {
-                wrapper.eq(KwsAlarm::getCompanyId, projectDevice.getCompanyId());
+                wrapper.eq(StringUtils.isNotBlank(projectDevice.getCompanyId()),KwsAlarm::getCompanyId, projectDevice.getCompanyId());
             }
         }
         long alarmId = new IdWorker(NumberConstant.ONE).nextId();
@@ -833,7 +833,7 @@ public class MqttCallbackHandler extends AbstractHandler {
                 wrapper.eq(StringUtils.isNotBlank(projectDevice.getCompanyId()), KwsAlarm::getCompanyId, projectDevice.getCompanyId());
             }
         }
-        KwsAlarm kwsAlarm = new KwsAlarm();
+        KwsAlarm kwsAlarm = null;
         List<KwsAlarm> alarms = alarmMapper.selectList(wrapper);
         if (alarms.size() > 0) {
             kwsAlarm = alarms.get(0);

+ 7 - 5
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/service/ProjectService.java

@@ -1,6 +1,5 @@
 package com.sckw.slope.detection.service;
 
-import cn.hutool.core.date.DateTime;
 import com.alibaba.fastjson2.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
@@ -46,7 +45,6 @@ import java.math.RoundingMode;
 import java.text.SimpleDateFormat;
 import java.time.LocalDate;
 import java.time.LocalDateTime;
-import java.time.format.DateTimeFormatter;
 import java.util.*;
 import java.util.stream.Collectors;
 
@@ -1443,6 +1441,7 @@ public class ProjectService {
     private Map<String, String> getAlarmStatus(String deviceId) {
         String alarmStatus = "0";
         String thresholdId = null;
+        Map<String, String> returnMap = new HashMap<>();
         List<KwsThreshold> kwsThresholds = thresholdMapper.selectList(new LambdaQueryWrapper<KwsThreshold>()
                 .eq(KwsThreshold::getDeviceId, Long.parseLong(deviceId))
                 .eq(KwsThreshold::getDelFlag, NumberConstant.ZERO)
@@ -1453,8 +1452,12 @@ public class ProjectService {
                         .eq(KwsAlarmDetail::getDelFlag, NumberConstant.ZERO)
                         .eq(KwsAlarmDetail::getStatus, NumberConstant.ZERO)
         );
-        if (!CollectionUtils.isEmpty(deviceDetails)) {
+        if (!CollectionUtils.isEmpty(deviceDetails) && deviceDetails.size() > 0) {
             alarmStatus = "1";
+            thresholdId = deviceDetails.get(0).getAlarmId().toString();
+            returnMap.put("alarmStatus", alarmStatus);
+            returnMap.put("thresholdId", thresholdId);
+            return returnMap;
         }
         if (!CollectionUtils.isEmpty(kwsThresholds)) {
             List<Long> longList = kwsThresholds.stream().map(KwsThreshold::getId).distinct().collect(Collectors.toList());
@@ -1489,7 +1492,7 @@ public class ProjectService {
                                         List<KwsAlarmDetail> alarmDetails = alarmDetailMapper.selectList(new LambdaQueryWrapper<KwsAlarmDetail>()
                                                 .eq(KwsAlarmDetail::getPid, threshold.getId()));
                                         if (!CollectionUtils.isEmpty(alarmDetails) && alarmDetails.size() > 0) {
-                                            thresholdId = alarmDetails.get(0).getPid().toString();
+                                            thresholdId = alarmDetails.get(0).getAlarmId().toString();
                                         }
                                     }
                                 }
@@ -1499,7 +1502,6 @@ public class ProjectService {
                 }
             }
         }
-        Map<String, String> returnMap = new HashMap<>();
         returnMap.put("alarmStatus", alarmStatus);
         returnMap.put("thresholdId", thresholdId);
         return returnMap;

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

@@ -282,7 +282,7 @@
         WHERE a.del_flag = 0
           AND c.del_flag = 0
           AND d.del_flag = 0
-          AND c.relevance_level = 0
+          AND c.relevance_level in ('1','0')
           AND c.id NOT in (SELECT DISTINCT a.relate_device_id
                            FROM kws_device_relation a
                                     LEFT JOIN kws_project b ON a.mountain_id = b.mountain_id where a.del_flag = 0)

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

@@ -252,7 +252,7 @@ WHERE
       SELECT b.*
       FROM kws_project a
                LEFT JOIN kws_project_device b ON a.id = b.project_id
-      WHERE b.id = #{deviceId}
+      WHERE b.device_id = #{deviceId}
       order by b.create_time desc limit 1
   </select>
 </mapper>