From 15325511c434cfa97e94b5221cdc74bba166765c Mon Sep 17 00:00:00 2001 From: wenjy Date: Sun, 27 Mar 2022 10:04:35 +0800 Subject: [PATCH] =?UTF-8?q?change=20-=20=E6=99=BA=E6=85=A7=E5=A0=B4?= =?UTF-8?q?=E6=99=AF=E5=91=8A=E8=AD=A6=E5=96=AE=E5=85=83=E7=B5=B1=E8=A8=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../base/BaseAlarmModuleController.java | 23 +++++++++++ .../iot/WisdomScenarioContorller.java | 39 ++++++++++++++++--- .../templates/section/substation.html | 38 +++++++++++++++--- .../ruoyi/system/domain/BaseAlarmModule.java | 7 ++++ .../system/domain/dto/BaseAlarmModuleDto.java | 2 + .../system/mapper/BaseAlarmModuleMapper.java | 10 +++++ .../service/IBaseAlarmModuleService.java | 10 +++++ .../impl/BaseAlarmModuleServiceImpl.java | 12 ++++++ .../mapper/system/BaseAlarmModuleMapper.xml | 11 ++++++ 9 files changed, 141 insertions(+), 11 deletions(-) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/base/BaseAlarmModuleController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/base/BaseAlarmModuleController.java index 510141c..535e5e4 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/base/BaseAlarmModuleController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/base/BaseAlarmModuleController.java @@ -5,7 +5,9 @@ import java.util.List; import java.util.UUID; import com.ruoyi.common.utils.ShiroUtils; +import com.ruoyi.system.domain.BaseMonitorunitInfo; import com.ruoyi.system.domain.dto.BaseAlarmModuleDto; +import com.ruoyi.system.service.IBaseMonitorunitInfoService; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; @@ -39,6 +41,9 @@ public class BaseAlarmModuleController extends BaseController @Autowired private IBaseAlarmModuleService baseAlarmModuleService; + @Autowired + private IBaseMonitorunitInfoService baseMonitorunitInfoService; + @RequiresPermissions("base:alarmModule:view") @GetMapping() public String alarmModule() @@ -91,6 +96,16 @@ public class BaseAlarmModuleController extends BaseController @ResponseBody public AjaxResult addSave(BaseAlarmModule baseAlarmModule) { + + if(!baseAlarmModule.getMonitorunitId().isEmpty()){ + BaseMonitorunitInfo baseMonitorunitInfo = new BaseMonitorunitInfo(); + baseMonitorunitInfo.setMonitorunitType(baseAlarmModule.getMonitorunitId()); + List baseMonitorunitInfos = baseMonitorunitInfoService.selectBaseMonitorunitInfoList(baseMonitorunitInfo); + if(baseMonitorunitInfos.size() > 0){ + baseAlarmModule.setMonitorunitId(baseMonitorunitInfos.get(0).getMonitorunitType()); + } + } + baseAlarmModule.setAlarmmoduleId(UUID.randomUUID().toString()); baseAlarmModule.setCreatedBy(ShiroUtils.getLoginName()); baseAlarmModule.setCreatedTime(new Date()); @@ -117,6 +132,14 @@ public class BaseAlarmModuleController extends BaseController @ResponseBody public AjaxResult editSave(BaseAlarmModule baseAlarmModule) { + if(!baseAlarmModule.getMonitorunitId().isEmpty()){ + BaseMonitorunitInfo baseMonitorunitInfo = new BaseMonitorunitInfo(); + baseMonitorunitInfo.setMonitorunitId(baseAlarmModule.getMonitorunitId()); + List baseMonitorunitInfos = baseMonitorunitInfoService.selectBaseMonitorunitInfoList(baseMonitorunitInfo); + if(baseMonitorunitInfos.size() > 0){ + baseAlarmModule.setMonitorunitId(baseMonitorunitInfos.get(0).getMonitorunitType()); + } + } baseAlarmModule.setUpdatedBy(ShiroUtils.getLoginName()); baseAlarmModule.setUpdatedTime(new Date()); return toAjax(baseAlarmModuleService.updateBaseAlarmModule(baseAlarmModule)); 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 5a5ad1f..7daf68f 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 @@ -1,19 +1,20 @@ package com.ruoyi.web.controller.iot; import com.alibaba.fastjson.JSONArray; +import com.ruoyi.system.domain.BaseAlarmModule; import com.ruoyi.system.domain.BaseMonitorunitInfo; import com.ruoyi.system.domain.BaseSensorInfo; +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.service.IBaseAlarmModuleService; import com.ruoyi.system.service.IBaseMonitorunitInfoService; import com.ruoyi.system.service.IBaseSensorInfoService; +import com.ruoyi.system.service.IRecordAlarmService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.ui.ModelMap; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.*; import java.util.ArrayList; import java.util.List; @@ -33,6 +34,12 @@ public class WisdomScenarioContorller { @Autowired private IBaseSensorInfoService baseSensorInfoService; + @Autowired + private IBaseAlarmModuleService baseAlarmModuleService; + + @Autowired + private IRecordAlarmService recordAlarmService; + /** * 数量统计:传感器数量、监控单元数量 * @@ -102,7 +109,29 @@ public class WisdomScenarioContorller { return JSONArray.toJSONString(collect); } + /** + * 获取告警单元 + * @author WenJY + * @date 2022/3/26 20:51 + * @param monitorUnitId + * @return java.lang.String + */ + @GetMapping("/getAlarmModule") + @ResponseBody public String getAlarmModule(String monitorUnitId){ - return null; + + List baseAlarmModuleDtos = baseAlarmModuleService.selectAlarmModuleAmountList(new BaseAlarmModule(monitorUnitId)); + + if(baseAlarmModuleDtos.size() < 6){ + List info = new ArrayList<>(); + for (int i = 0;i<6-baseAlarmModuleDtos.size();i++){ + info.add(new BaseAlarmModuleDto()); + } + baseAlarmModuleDtos.addAll(baseAlarmModuleDtos.size()-1,info); + } + + String result = JSONArray.toJSONString(baseAlarmModuleDtos); + + return result; } } diff --git a/ruoyi-admin/src/main/resources/templates/section/substation.html b/ruoyi-admin/src/main/resources/templates/section/substation.html index e13f5e9..7a6c354 100644 --- a/ruoyi-admin/src/main/resources/templates/section/substation.html +++ b/ruoyi-admin/src/main/resources/templates/section/substation.html @@ -235,10 +235,6 @@