Explorar el Código

1.增加告警id数据返回
2.增加告警查看明细 项目描边区域

lengfaqiang hace 2 años
padre
commit
338c172aa3

+ 7 - 0
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/dao/mysql/KwsProjectDeviceMapper.java

@@ -35,6 +35,13 @@ public interface KwsProjectDeviceMapper extends BaseMapper<KwsProjectDevice> {
      */
     ProjectVo selectProjectByDeviceId(@Param("deviceId") long id);
 
+    /**
+     * 设备id查项目数据
+     * @param id 设备id
+     * @return
+     */
+    ProjectVo selectNotDeleteProjectByDeviceId(@Param("deviceId") long id);
+
     /**
      * 设备id查项目数据
      * @param id 设备id

+ 5 - 0
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/vo/DeviceListBean.java

@@ -43,4 +43,9 @@ public class DeviceListBean implements Serializable {
      * 告警状态
      */
     private String alarmStatus;
+
+    /**
+     * 阈值id
+     */
+    private String thresholdId;
 }

+ 1 - 0
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/vo/ProjectVo.java

@@ -17,6 +17,7 @@ import java.time.LocalDateTime;
 public class ProjectVo implements Serializable {
     private Long id;
 
+    private Long projectId;
     /**
      * 项目名
      */

+ 3 - 1
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/vo/ThresholdLogDetailVO.java

@@ -25,10 +25,12 @@ public class ThresholdLogDetailVO implements Serializable {
     private String deviceId;
 
     /**
-     * 告警id
+     * 选中区域
      */
     private String alarmId;
 
+    private String fence;
+
     /**
      * 告警id
      */

+ 19 - 13
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/service/KwsAlarmService.java

@@ -23,10 +23,7 @@ import com.sckw.slope.detection.model.dto.SystemDict;
 import com.sckw.slope.detection.model.param.AlarmLogThresholdExport;
 import com.sckw.slope.detection.model.param.AlarmLogThresholdQuery;
 import com.sckw.slope.detection.model.param.AlarmStatisticsQuery;
-import com.sckw.slope.detection.model.vo.AlarmLogThresholdVO;
-import com.sckw.slope.detection.model.vo.KwsAlarmVO;
-import com.sckw.slope.detection.model.vo.ThresholdLogDetailVO;
-import com.sckw.slope.detection.model.vo.ThresholdRecordDetailVO;
+import com.sckw.slope.detection.model.vo.*;
 import com.sckw.slope.detection.model.vo.excel.KwsAlarmExportVO;
 import com.sckw.slope.detection.model.vo.excel.ThresholdRecordDetailExportVO;
 import jakarta.servlet.http.HttpServletRequest;
@@ -182,6 +179,9 @@ public class KwsAlarmService {
     @Autowired
     KwsProjectDeviceMapper projectDeviceMapper;
 
+    @Autowired
+    KwsProjectAreaMapper projectAreaMapper;
+
 
     public HttpResult read1(BaseList baseList, HttpServletRequest request) {
         String ids = baseList.getIds();
@@ -507,6 +507,12 @@ public class KwsAlarmService {
 //                throw new RuntimeException(e);
             }
             vo.setAlarmId(kwsAlarm.getId().toString());
+            Long deviceId1 = device.getId();
+            ProjectVo project = projectDeviceMapper.selectNotDeleteProjectByDeviceId(deviceId1);
+            if (Objects.nonNull(project.getProjectId())) {
+                KwsProjectArea area = projectAreaMapper.selectOne(new LambdaQueryWrapper<KwsProjectArea>().eq(KwsProjectArea::getProjectId, project.getProjectId()));
+                vo.setFence(area == null ? null : area.getFence());
+            }
             vo.setAlarmDetailId(id);
             vo.setDeviceId(deviceId.toString());
             vo.setItemName(itemName);
@@ -557,13 +563,13 @@ public class KwsAlarmService {
             String dateTimeFormat = startTime;
             endTime = weekMondayAndSunday.get(1);
             //按照天纬度统计
-            returnList = getDataAlarmToWeek(startTime, endTime, level, projectId, headerData.getMountainId(),dateTimeFormat, type);
+            returnList = getDataAlarmToWeek(startTime, endTime, level, projectId, headerData.getMountainId(), dateTimeFormat, type);
         } else if (StringUtils.isNotBlank(startTime) && StringUtils.isNotBlank(endTime)) {
             String dateTimeFormat = startTime;
             startTime = startTime + " 00:00:00";
             endTime = endTime + " 23:59:59";
             //统计小时的纬度统计
-            returnList = getDataAlarmToWeek(startTime, endTime, level, projectId, headerData.getMountainId(),dateTimeFormat, type);
+            returnList = getDataAlarmToWeek(startTime, endTime, level, projectId, headerData.getMountainId(), dateTimeFormat, type);
         } else {
             if (latitude != null) {
 
@@ -576,14 +582,14 @@ public class KwsAlarmService {
                     startTime = weekMondayAndSunday.get(0);
                     String dateTimeFormat = startTime;
                     endTime = weekMondayAndSunday.get(1);
-                    returnList = getDataAlarmToWeek(startTime, endTime, level, projectId, headerData.getMountainId(),dateTimeFormat, type);
+                    returnList = getDataAlarmToWeek(startTime, endTime, level, projectId, headerData.getMountainId(), dateTimeFormat, type);
                 } else if ("3".equals(latitude)) {
                     LocalDate firstDayOfMonth = com.sckw.excel.utils.DateUtil.getFirstDayOfMonth();
                     startTime = com.sckw.excel.utils.DateUtil.dateToStr(firstDayOfMonth, "yyyy-MM-dd") /*+ " 00:00:00"*/;
                     String dateTimeFormat = startTime;
                     LocalDate lastDayOfMonth = com.sckw.excel.utils.DateUtil.getLastDayOfMonth();
                     endTime = com.sckw.excel.utils.DateUtil.dateToStr(lastDayOfMonth, "yyyy-MM-dd")/* + " 23:59:59"*/;
-                    returnList = getDataAlarmToWeek(startTime, endTime, level, projectId, headerData.getMountainId(),dateTimeFormat, type);
+                    returnList = getDataAlarmToWeek(startTime, endTime, level, projectId, headerData.getMountainId(), dateTimeFormat, type);
                 } else if ("4".equals(latitude)) {
                     //查询全年每个月份
                     startTime = com.sckw.excel.utils.DateUtil.getYearFirstMonth() + "-01";
@@ -654,8 +660,8 @@ public class KwsAlarmService {
         return list;
     }
 
-    private List<Map<String, Object>> getDataAlarmToWeek(String startTime, String endTime, String level, String projectId, String mountainId,String dateTimeFormat, Integer type) {
-        List<Map<String, Object>> list = alarmMapper.getDataAlarmToWeek(startTime, endTime, level, projectId, mountainId,dateTimeFormat, type);
+    private List<Map<String, Object>> getDataAlarmToWeek(String startTime, String endTime, String level, String projectId, String mountainId, String dateTimeFormat, Integer type) {
+        List<Map<String, Object>> list = alarmMapper.getDataAlarmToWeek(startTime, endTime, level, projectId, mountainId, dateTimeFormat, type);
         return list;
     }
 
@@ -680,7 +686,7 @@ public class KwsAlarmService {
             String dateTimeFormat = startTime;
             endTime = weekMondayAndSunday.get(1);
             //按照天纬度统计
-            returnList = getDataAlarmToWeek(startTime, endTime, level, projectId, headerData.getMountainId(),dateTimeFormat, type);
+            returnList = getDataAlarmToWeek(startTime, endTime, level, projectId, headerData.getMountainId(), dateTimeFormat, type);
         } else if (StringUtils.isNotBlank(startTime) && StringUtils.isNotBlank(endTime)) {
             startTime = startTime + " 00:00:00";
             endTime = endTime + " 23:59:59";
@@ -697,14 +703,14 @@ public class KwsAlarmService {
                     startTime = weekMondayAndSunday.get(0);
                     String dateTimeFormat = startTime;
                     endTime = weekMondayAndSunday.get(1);
-                    returnList = getDataAlarmToWeek(startTime, endTime, level, projectId, headerData.getMountainId(),dateTimeFormat, type);
+                    returnList = getDataAlarmToWeek(startTime, endTime, level, projectId, headerData.getMountainId(), dateTimeFormat, type);
                 } else if ("3".equals(latitude)) {
                     LocalDate firstDayOfMonth = com.sckw.excel.utils.DateUtil.getFirstDayOfMonth();
                     startTime = com.sckw.excel.utils.DateUtil.dateToStr(firstDayOfMonth, "yyyy-MM-dd") /*+ " 00:00:00"*/;
                     LocalDate lastDayOfMonth = com.sckw.excel.utils.DateUtil.getLastDayOfMonth();
                     endTime = com.sckw.excel.utils.DateUtil.dateToStr(lastDayOfMonth, "yyyy-MM-dd")/* + " 23:59:59"*/;
                     String dateTimeFormat = startTime;
-                    returnList = getDataAlarmToWeek(startTime, endTime, level, projectId, headerData.getMountainId(),dateTimeFormat, type);
+                    returnList = getDataAlarmToWeek(startTime, endTime, level, projectId, headerData.getMountainId(), dateTimeFormat, type);
                 } else if ("4".equals(latitude)) {
                     //查询全年每个月份
                     startTime = com.sckw.excel.utils.DateUtil.getYearFirstMonth() + "-01";

+ 20 - 4
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/service/ProjectService.java

@@ -1425,8 +1425,9 @@ public class ProjectService {
                     bean.setAlias(device.getAlias());
                     bean.setDeviceId(device.getDeviceId());
                     String deviceId = device.getDeviceId();
-                    String alarmStatus = getAlarmStatus(deviceId);
-                    bean.setAlarmStatus(alarmStatus);
+                    Map<String, String> map = getAlarmStatus(deviceId);
+                    bean.setAlarmStatus(map.get("alarmStatus"));
+                    bean.setThresholdId(map.get("thresholdId"));
                     beans.add(bean);
                 });
                 vo.setDeviceList(beans);
@@ -1436,8 +1437,9 @@ public class ProjectService {
         return HttpResult.ok(returnList);
     }
 
-    private String getAlarmStatus(String deviceId) {
+    private Map<String, String> getAlarmStatus(String deviceId) {
         String alarmStatus = "0";
+        String thresholdId = null;
         List<KwsThreshold> kwsThresholds = thresholdMapper.selectList(new LambdaQueryWrapper<KwsThreshold>()
                 .eq(KwsThreshold::getDeviceId, Long.parseLong(deviceId))
                 .eq(KwsThreshold::getDelFlag, NumberConstant.ZERO)
@@ -1474,12 +1476,26 @@ public class ProjectService {
                             if (!CollectionUtils.isEmpty(levelList)) {
                                 alarmStatus = String.valueOf(levelList.get(0));
                             }
+                            List<String> objects = new ArrayList<>();
+                            objects.add("1");
+                            objects.add("2");
+                            objects.add("3");
+                            if (objects.contains(alarmStatus)) {
+                                for (KwsThreshold threshold : thresholds) {
+                                    if (alarmStatus.equals(String.valueOf(threshold.getLevel()))) {
+                                        thresholdId = threshold.getId().toString();
+                                    }
+                                }
+                            }
                         }
                     }
                 }
             }
         }
-        return alarmStatus;
+        Map<String, String> returnMap = new HashMap<>();
+        returnMap.put("alarmStatus",alarmStatus);
+        returnMap.put("thresholdId",thresholdId);
+        return returnMap;
     }
 
     /**

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

@@ -238,6 +238,16 @@ WHERE
         order by  b.create_time desc  limit 1
     </select>
 
+    <select id="selectNotDeleteProjectByDeviceId" resultType="com.sckw.slope.detection.model.vo.ProjectVo">
+        SELECT a.id     AS projectId,
+               a.`name` AS projectName
+        FROM kws_project a
+                 LEFT JOIN kws_project_device b ON a.id = b.project_id
+        WHERE b.id = #{deviceId}
+          and a.del_flag = 0
+        order by b.create_time desc limit 1
+    </select>
+
   <select id="selectProjectDeviceByDeviceId" resultMap="BaseResultMap">
       SELECT b.*
       FROM kws_project a