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 535e5e4..61192e6 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 @@ -97,7 +97,7 @@ public class BaseAlarmModuleController extends BaseController public AjaxResult addSave(BaseAlarmModule baseAlarmModule) { - if(!baseAlarmModule.getMonitorunitId().isEmpty()){ + /*if(!baseAlarmModule.getMonitorunitId().isEmpty()){ BaseMonitorunitInfo baseMonitorunitInfo = new BaseMonitorunitInfo(); baseMonitorunitInfo.setMonitorunitType(baseAlarmModule.getMonitorunitId()); List baseMonitorunitInfos = baseMonitorunitInfoService.selectBaseMonitorunitInfoList(baseMonitorunitInfo); @@ -105,7 +105,7 @@ public class BaseAlarmModuleController extends BaseController baseAlarmModule.setMonitorunitId(baseMonitorunitInfos.get(0).getMonitorunitType()); } } - +*/ baseAlarmModule.setAlarmmoduleId(UUID.randomUUID().toString()); baseAlarmModule.setCreatedBy(ShiroUtils.getLoginName()); baseAlarmModule.setCreatedTime(new Date()); @@ -132,14 +132,14 @@ public class BaseAlarmModuleController extends BaseController @ResponseBody public AjaxResult editSave(BaseAlarmModule baseAlarmModule) { - if(!baseAlarmModule.getMonitorunitId().isEmpty()){ + /*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/base/BaseMonitorunitTypeController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/base/BaseMonitorunitTypeController.java index 687a577..ba8ca46 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/base/BaseMonitorunitTypeController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/base/BaseMonitorunitTypeController.java @@ -1,9 +1,14 @@ package com.ruoyi.web.controller.base; +import java.util.ArrayList; import java.util.Date; import java.util.List; +import com.ruoyi.common.core.domain.Ztree; import com.ruoyi.common.utils.ShiroUtils; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.system.domain.BaseMonitorunitInfo; +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; @@ -36,6 +41,9 @@ public class BaseMonitorunitTypeController extends BaseController { @Autowired private IBaseMonitorunitTypeService baseMonitorunitTypeService; + @Autowired + private IBaseMonitorunitInfoService baseMonitorunitInfoService; + @RequiresPermissions("base:monitorUnitType:view") @GetMapping() public String monitorUnitType() { @@ -144,4 +152,34 @@ public class BaseMonitorunitTypeController extends BaseController { public AjaxResult remove(String ids) { return toAjax(baseMonitorunitTypeService.deleteBaseMonitorunitTypeByObjIds(ids)); } + + /** 选择智慧場景信息树 */ + @GetMapping(value = {"/selectMonitorUnitInfoTree/{ObjId}", "/selectMonitorUnitInfoTree/"}) + public String selectMonitorUnitInfoTree( + @PathVariable(value = "ObjId", required = false) String ObjId, ModelMap mmap) { + if (StringUtils.isNotNull(ObjId)) { + + mmap.put( + "baseMonitorUnitType", + baseMonitorunitTypeService.selectBaseMonitorunitTypeList(new BaseMonitorunitType(ObjId)).get(0)); + } + return prefix + "/tree"; + } + + /** 加载智慧場景信息树列表 */ + @GetMapping("/treeData") + @ResponseBody + public List treeData() { + List baseMonitorunitTypes = baseMonitorunitTypeService.selectBaseMonitorunitTypeList(new BaseMonitorunitType()); + List ztrees = new ArrayList(); + for (BaseMonitorunitType baseMonitorunitType : baseMonitorunitTypes) { + Ztree ztree = new Ztree(); + ztree.setId(baseMonitorunitType.getMonitorunittypeId()); + ztree.setpId(baseMonitorunitType.getMonitorunittypeId()); + ztree.setName(baseMonitorunitType.getMonitorunittypeName()); + ztree.setTitle(baseMonitorunitType.getMonitorunittypeName()); + ztrees.add(ztree); + } + return ztrees; + } } 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 7daf68f..7b7c43f 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 @@ -17,8 +17,10 @@ import org.springframework.ui.ModelMap; import org.springframework.web.bind.annotation.*; import java.util.ArrayList; +import java.util.Comparator; import java.util.List; import java.util.stream.Collectors; +import java.util.stream.Stream; /** * 智慧场景Controller @@ -125,12 +127,18 @@ public class WisdomScenarioContorller { if(baseAlarmModuleDtos.size() < 6){ List info = new ArrayList<>(); for (int i = 0;i<6-baseAlarmModuleDtos.size();i++){ - info.add(new BaseAlarmModuleDto()); + BaseAlarmModuleDto baseAlarmModuleDto = new BaseAlarmModuleDto(); + baseAlarmModuleDto.setAlarmmoduleText("----"); + baseAlarmModuleDto.setAlarmModuleAmount("-"); + baseAlarmModuleDto.setOrderFlag(new Long((baseAlarmModuleDtos.size())+i+1)); + info.add(baseAlarmModuleDto); } - baseAlarmModuleDtos.addAll(baseAlarmModuleDtos.size()-1,info); + baseAlarmModuleDtos.addAll(baseAlarmModuleDtos.size(),info); } - String result = JSONArray.toJSONString(baseAlarmModuleDtos); + List collect = baseAlarmModuleDtos.stream().sorted(Comparator.comparing(BaseAlarmModuleDto::getOrderFlag)).collect(Collectors.toList()); + + String result = JSONArray.toJSONString(collect); return result; } diff --git a/ruoyi-admin/src/main/resources/templates/base/alarmModule/add.html b/ruoyi-admin/src/main/resources/templates/base/alarmModule/add.html index 024b55f..adc18ad 100644 --- a/ruoyi-admin/src/main/resources/templates/base/alarmModule/add.html +++ b/ruoyi-admin/src/main/resources/templates/base/alarmModule/add.html @@ -21,7 +21,7 @@ -->
- +
@@ -38,6 +38,12 @@
+
+ +
+ +
+
@@ -78,9 +84,9 @@ /* 选择监控单元树 */ function selectMonitorTree() { var deptId = $.common.isEmpty($("#treeId").val()) ? "" : $("#treeId").val(); - var url = ctx + "base/monitorUnitInfo/selectMonitorUnitInfoTree/" + deptId; + var url = ctx + "base/monitorUnitType/selectMonitorUnitInfoTree/" + deptId; var options = { - title: '选择部门', + title: '选择智慧场景', width: "380", url: url, callBack: doSubmit diff --git a/ruoyi-admin/src/main/resources/templates/base/alarmModule/alarmModule.html b/ruoyi-admin/src/main/resources/templates/base/alarmModule/alarmModule.html index ea5924e..3e4b93a 100644 --- a/ruoyi-admin/src/main/resources/templates/base/alarmModule/alarmModule.html +++ b/ruoyi-admin/src/main/resources/templates/base/alarmModule/alarmModule.html @@ -10,10 +10,10 @@
- 监控单元 + 智慧场景
- @@ -133,13 +133,17 @@ }, { field: 'monitorunitName', - title: '监控单元' + title: '智慧场景' }, { field: 'alarmTypeName', title: '报警类型' }, - { + { + field: 'orderFlag', + title: '排序标识', + }, + { field: 'enableFlag', title: '是否启用', formatter: function(value, row, index) { @@ -177,7 +181,7 @@ } function queryMonitorTree() { - let url = ctx + "base/monitorUnitInfo/treeData"; + let url = ctx + "base/monitorUnitType/treeData"; let options = { url: url, expandLevel: 2, @@ -214,8 +218,8 @@ }); function monitorUnitInfo() { - var url = ctx + "base/monitorUnitInfo"; - $.modal.openTab("监控单元", url); + var url = ctx + "base/monitorUnitType"; + $.modal.openTab("智慧场景", url); } diff --git a/ruoyi-admin/src/main/resources/templates/base/alarmModule/edit.html b/ruoyi-admin/src/main/resources/templates/base/alarmModule/edit.html index e4f1b75..29044a9 100644 --- a/ruoyi-admin/src/main/resources/templates/base/alarmModule/edit.html +++ b/ruoyi-admin/src/main/resources/templates/base/alarmModule/edit.html @@ -18,7 +18,7 @@
- +
@@ -35,6 +35,12 @@
+
+ +
+ +
+
@@ -71,12 +77,12 @@ autoclose: true }); - /* 选择监控单元树 */ + /* 选择智慧场景树 */ function selectMonitorTree() { var deptId = $.common.isEmpty($("#treeId").val()) ? "" : $("#treeId").val(); - var url = ctx + "base/monitorUnitInfo/selectMonitorUnitInfoTree/" + deptId; + var url = ctx + "base/monitorUnitType/selectMonitorUnitInfoTree/" + deptId; var options = { - title: '选择部门', + title: '选择智慧场景', width: "380", url: url, callBack: doSubmit diff --git a/ruoyi-admin/src/main/resources/templates/base/monitorUnitType/tree.html b/ruoyi-admin/src/main/resources/templates/base/monitorUnitType/tree.html new file mode 100644 index 0000000..200ce98 --- /dev/null +++ b/ruoyi-admin/src/main/resources/templates/base/monitorUnitType/tree.html @@ -0,0 +1,49 @@ + + + + + + + + + + +
+ + +
+ +
+ 展开 / + 折叠 +
+
+
+ + + + + \ No newline at end of file diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain/BaseAlarmModule.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain/BaseAlarmModule.java index 780ba83..32afed2 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/domain/BaseAlarmModule.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain/BaseAlarmModule.java @@ -46,6 +46,9 @@ public class BaseAlarmModule extends BaseEntity @Excel(name = "是否启用") private Long enableFlag; + /** 排序字段 */ + private Long orderFlag; + /** 创建人 */ @Excel(name = "创建人") private String createdBy; @@ -153,6 +156,14 @@ public class BaseAlarmModule extends BaseEntity this.alarmTypeId = alarmTypeId; } + public Long getOrderFlag() { + return orderFlag; + } + + public void setOrderFlag(Long orderFlag) { + this.orderFlag = orderFlag; + } + @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) diff --git a/ruoyi-system/src/main/resources/mapper/system/BaseAlarmModuleMapper.xml b/ruoyi-system/src/main/resources/mapper/system/BaseAlarmModuleMapper.xml index 7b5cd86..3e4292d 100644 --- a/ruoyi-system/src/main/resources/mapper/system/BaseAlarmModuleMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/BaseAlarmModuleMapper.xml @@ -11,6 +11,7 @@ + @@ -26,6 +27,7 @@ + @@ -39,16 +41,17 @@ t1.AlarmModule_Id, t1.AlarmModule_Text, t1.MonitorUnit_Id, - t2.MonitorUnit_Name, + t2.MonitorUnitType_Name as MonitorUnit_Name, t1.AlarmType_Id, t3.AlarmType_Name, t1.Enable_Flag, t1.CREATED_BY, t1.CREATED_TIME, t1.UPDATED_BY, - t1.UPDATED_TIME + t1.UPDATED_TIME, + t1.Order_Flag from base_alarm_module t1 - left join base_monitorunit_info t2 on t1.MonitorUnit_Id = t2.MonitorUnit_Id + left join base_monitorunit_type t2 on t1.MonitorUnit_Id = t2.MonitorUnitType_Id left join base_alarm_type t3 on t1.AlarmType_Id = t3.alarmType_Id @@ -62,6 +65,7 @@ and t1.AlarmType_Id = #{alarmTypeId} and t1.Enable_Flag = #{enableFlag} + order by t1.order_Flag - select t1.AlarmModule_Text,count(t4.Alarm_Value) as alarmModuleAmount from base_alarm_module t1 + select t1.AlarmModule_Text,t1.Order_Flag,count(t4.Alarm_Value) as alarmModuleAmount from base_alarm_module t1 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 and t1.MonitorUnit_Id = #{monitorunitId} - group by t1.AlarmModule_Text + group by t1.AlarmModule_Text,t1.Order_Flag + order by t1.Order_Flag \ No newline at end of file