From ff5657888cbdc0066a82706725f3a23e053d4e70 Mon Sep 17 00:00:00 2001 From: wenjy Date: Thu, 7 Apr 2022 15:21:16 +0800 Subject: [PATCH] =?UTF-8?q?change=20-=20=E5=85=A8=E5=B1=80=E5=91=8A?= =?UTF-8?q?=E8=AD=A6=E5=BC=B9=E7=AA=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../iot/WisdomScenarioContorller.java | 86 ++-- .../src/main/resources/templates/index.html | 403 ++++++++++++------ .../templates/section/substation.html | 5 - .../mapper/system/RecordAlarmMapper.xml | 3 +- 4 files changed, 334 insertions(+), 163 deletions(-) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/iot/WisdomScenarioContorller.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/iot/WisdomScenarioContorller.java index 008b88b..51393ca 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/iot/WisdomScenarioContorller.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/iot/WisdomScenarioContorller.java @@ -3,18 +3,12 @@ package com.ruoyi.web.controller.iot; import com.alibaba.fastjson.JSONArray; import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.domain.AjaxResult; -import com.ruoyi.system.domain.BaseAlarmModule; -import com.ruoyi.system.domain.BaseMonitorunitInfo; -import com.ruoyi.system.domain.BaseSensorInfo; -import com.ruoyi.system.domain.RecordAlarm; +import com.ruoyi.system.domain.*; import com.ruoyi.system.domain.dto.BaseAlarmModuleDto; import com.ruoyi.system.domain.dto.BaseMonitorunitInfoDto; import com.ruoyi.system.domain.dto.BaseSensorInfoDto; import com.ruoyi.system.domain.dto.RecordAlarmDto; -import com.ruoyi.system.service.IBaseAlarmModuleService; -import com.ruoyi.system.service.IBaseMonitorunitInfoService; -import com.ruoyi.system.service.IBaseSensorInfoService; -import com.ruoyi.system.service.IRecordAlarmService; +import com.ruoyi.system.service.*; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.ui.ModelMap; @@ -37,15 +31,15 @@ import java.util.stream.Stream; @RequestMapping("/iot/wisdomScenario") public class WisdomScenarioContorller extends BaseController { + @Autowired private IBaseMonitorunitTypeService baseMonitorunitTypeService; + @Autowired private IBaseMonitorunitInfoService baseMonitorunitInfoService; @Autowired private IBaseSensorInfoService baseSensorInfoService; - @Autowired - private IBaseAlarmModuleService baseAlarmModuleService; + @Autowired private IBaseAlarmModuleService baseAlarmModuleService; - @Autowired - private IRecordAlarmService recordAlarmService; + @Autowired private IRecordAlarmService recordAlarmService; /** * 数量统计:传感器数量、监控单元数量 @@ -109,39 +103,45 @@ public class WisdomScenarioContorller extends BaseController { && x.getEnableFlag() == 0L && x.getMonitorunitType().equals(monitorUnitType)) .collect(Collectors.toList()); - collect.forEach(x->{ - x.setUnitUrl("/sections/transformer-detail?id="+x.getMonitorunitId()); - }); + collect.forEach( + x -> { + x.setUnitUrl("/sections/transformer-detail?id=" + x.getMonitorunitId()); + }); return JSONArray.toJSONString(collect); } /** * 获取告警单元 + * * @author WenJY * @date 2022/3/26 20:51 - * @param monitorUnitId + * @param monitorUnitId * @return java.lang.String */ @GetMapping("/getAlarmModule") @ResponseBody - public String getAlarmModule(String monitorUnitId){ + public String getAlarmModule(String monitorUnitId) { - List baseAlarmModuleDtos = baseAlarmModuleService.selectAlarmModuleAmountList(new BaseAlarmModule(monitorUnitId)); + List baseAlarmModuleDtos = + baseAlarmModuleService.selectAlarmModuleAmountList(new BaseAlarmModule(monitorUnitId)); - if(baseAlarmModuleDtos.size() < 6){ + if (baseAlarmModuleDtos.size() < 6) { List info = new ArrayList<>(); - for (int i = 0;i<6-baseAlarmModuleDtos.size();i++){ + for (int i = 0; i < 6 - baseAlarmModuleDtos.size(); i++) { BaseAlarmModuleDto baseAlarmModuleDto = new BaseAlarmModuleDto(); baseAlarmModuleDto.setAlarmmoduleText("----"); baseAlarmModuleDto.setAlarmModuleAmount("-"); - baseAlarmModuleDto.setOrderFlag(new Long((baseAlarmModuleDtos.size())+i+1)); + baseAlarmModuleDto.setOrderFlag(new Long((baseAlarmModuleDtos.size()) + i + 1)); info.add(baseAlarmModuleDto); } - baseAlarmModuleDtos.addAll(baseAlarmModuleDtos.size(),info); + baseAlarmModuleDtos.addAll(baseAlarmModuleDtos.size(), info); } - List collect = baseAlarmModuleDtos.stream().sorted(Comparator.comparing(BaseAlarmModuleDto::getOrderFlag)).collect(Collectors.toList()); + List collect = + baseAlarmModuleDtos.stream() + .sorted(Comparator.comparing(BaseAlarmModuleDto::getOrderFlag)) + .collect(Collectors.toList()); String result = JSONArray.toJSONString(collect); @@ -150,6 +150,7 @@ public class WisdomScenarioContorller extends BaseController { /** * 获取告警信息 + * * @author WenJY * @date 2022/3/27 11:36 * @param monitorUnitId @@ -157,15 +158,14 @@ public class WisdomScenarioContorller extends BaseController { */ @GetMapping("/getAlarmInfo") @ResponseBody - public String getAlarmInfo(String monitorUnitId){ + public String getAlarmInfo(String monitorUnitId) { - if(!monitorUnitId.isEmpty()){ + if (!monitorUnitId.isEmpty()) { List recordAlarmDtos = recordAlarmService.selectAlarmInfoList(monitorUnitId); String s = JSONArray.toJSONString(recordAlarmDtos); return s; - } return null; @@ -173,16 +173,46 @@ public class WisdomScenarioContorller extends BaseController { @GetMapping("/getAlarmByUid") @ResponseBody - public String getAlarmByUid(String alarmuid){ + public String getAlarmByUid(String alarmuid) { RecordAlarm recordAlarm = recordAlarmService.selectRecordAlarmBySensorId(alarmuid); return JSONArray.toJSONString(recordAlarm); } @PostMapping("/disposeAlarm") @ResponseBody - public AjaxResult disposeAlarm(RecordAlarm recordAlarm){ + public AjaxResult disposeAlarm(RecordAlarm recordAlarm) { recordAlarm.setDisposeFlag(1L); return toAjax(recordAlarmService.updateRecordAlarm(recordAlarm)); } + /** + * 全局告警弹窗获取告警信息 + * @author WenJY + * @date 2022/4/7 15:20 + * @return java.lang.String + */ + @GetMapping("/getAlarmWindow") + @ResponseBody + public String getAlarmWindow() { + + List result = new ArrayList(); + + List baseMonitorunitTypes = + baseMonitorunitTypeService.selectBaseMonitorunitTypeList(new BaseMonitorunitType()); + + baseMonitorunitTypes.forEach( + x -> { + List recordAlarmDtos = + recordAlarmService.selectAlarmInfoList(x.getMonitorunittypeId()); + result.addAll( + result.size(), + recordAlarmDtos.stream() + .filter(f -> f.getDisposeFlag() == 0L) + .collect(Collectors.toList())); + }); + + String s = JSONArray.toJSONString(result); + + return s; + } } diff --git a/ruoyi-admin/src/main/resources/templates/index.html b/ruoyi-admin/src/main/resources/templates/index.html index 2b1fd24..9a42fcb 100644 --- a/ruoyi-admin/src/main/resources/templates/index.html +++ b/ruoyi-admin/src/main/resources/templates/index.html @@ -1,19 +1,40 @@ - + 智慧物联监控平台 - + - + + + + + + -
-
- -
-
智慧物联监控平台
-
+
+
智慧物联监控平台
+
-
- User Image -
-
- -
+
+ User Image +
+
+ +
+
+
+ + + + +
+ +
+ + + + - - - - +
- - - - - - - - - - + + + + + + + + + + + - + + diff --git a/ruoyi-admin/src/main/resources/templates/section/substation.html b/ruoyi-admin/src/main/resources/templates/section/substation.html index d90a2ba..a14362a 100644 --- a/ruoyi-admin/src/main/resources/templates/section/substation.html +++ b/ruoyi-admin/src/main/resources/templates/section/substation.html @@ -396,11 +396,6 @@ content: html, ok: { callback: function () { - let formData = new FormData(); - formData.append("alarmuid", res.alarmuid); - formData.append("disposeMode", $("#disposeMode").val()); - formData.append("alarmReason", $("#alarmReason").val()); - $.post("/iot/wisdomScenario/disposeAlarm", { alarmuid: res.alarmuid, diff --git a/ruoyi-system/src/main/resources/mapper/system/RecordAlarmMapper.xml b/ruoyi-system/src/main/resources/mapper/system/RecordAlarmMapper.xml index 260f07e..6a1000e 100644 --- a/ruoyi-system/src/main/resources/mapper/system/RecordAlarmMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/RecordAlarmMapper.xml @@ -122,7 +122,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" left join base_monitorunit_info t2 on t2.MonitorUnit_Type = t1.MonitorUnit_Id left join base_sensor_info t3 on t2.MonitorUnit_Id = t3.MonitorUnit_Id left join record_alarm t4 on t3.Sensor_Id = t4.Sensor_Id and t1.AlarmType_Id = t4.AlarmType_Id - where t1.MonitorUnit_Id = #{monitorUnitTypeId} and t4.Collect_Time is not null + where t1.MonitorUnit_Id = #{monitorUnitTypeId} and t4.Collect_Time between DATE_FORMAT(DATE_SUB(CURDATE(), INTERVAL 30 DAY), '%Y-%m-%d 00:00:00') and DATE_FORMAT(now(), '%Y-%m-%d 23:59:59') + and t4.Collect_Time is not null