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 @@