From 441b3902104cb5b501e0b85a5cb7bb4be28c133b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A9=AC=E9=9B=AA=E4=BC=9F?= Date: Thu, 29 Aug 2024 09:26:35 +0800 Subject: [PATCH] =?UTF-8?q?=E7=9B=91=E6=B5=8B=E5=B9=B3=E5=8F=B0=E7=B3=BB?= =?UTF-8?q?=E7=BB=9Fbug=E4=BC=98=E5=8C=96=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/HwAlarmRuleController.java | 11 ++++--- .../controller/HwDeviceController.java | 4 +++ .../controller/HwDeviceModeController.java | 2 ++ .../controller/HwOfflineRuleController.java | 25 +++++++++++++++ .../ruoyi/business/mapper/HwDeviceMapper.java | 4 +++ .../business/mapper/HwDeviceModeMapper.java | 2 ++ .../business/mapper/HwOfflineRuleMapper.java | 12 +++++++ .../service/HwOfflineRuleService.java | 9 ++++++ .../service/IHwDeviceModeService.java | 4 +++ .../service/impl/HwAlarmRuleServiceImpl.java | 23 +++++++++----- .../service/impl/HwDeviceModeServiceImpl.java | 10 ++++++ .../impl/HwMonitorUnitServiceImpl.java | 2 +- .../impl/HwOfflineRuleServiceImpl.java | 19 ++++++++++++ .../mapper/business/HwAlarmRuleMapper.xml | 5 ++- .../mapper/business/HwDeviceMapper.xml | 31 +++++++++++++++++-- .../mapper/business/HwDeviceModeMapper.xml | 3 ++ .../mapper/business/HwOfflineRuleMapper.xml | 2 ++ .../mapper/business/HwSceneMapper.xml | 1 + 18 files changed, 152 insertions(+), 17 deletions(-) create mode 100644 ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/controller/HwOfflineRuleController.java create mode 100644 ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/mapper/HwOfflineRuleMapper.java create mode 100644 ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/HwOfflineRuleService.java create mode 100644 ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwOfflineRuleServiceImpl.java diff --git a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/controller/HwAlarmRuleController.java b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/controller/HwAlarmRuleController.java index 754900d..814c97f 100644 --- a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/controller/HwAlarmRuleController.java +++ b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/controller/HwAlarmRuleController.java @@ -138,14 +138,17 @@ public class HwAlarmRuleController extends BaseController { alarmLevel.setSceneId(sceneId); List alarmLevels = hwAlarmLevelService.selectHwAlarmLevelList(alarmLevel); - HwDevice device = new HwDevice(); - device.setSceneId(sceneId); - List devices = hwDeviceService.selectHwDeviceListWithDeviceMode(device); +// HwDevice device = new HwDevice(); +// device.setSceneId(sceneId); +// List devices = hwDeviceService.selectHwDeviceListWithDeviceMode(device); + + List models = hwDeviceModeService.selectModel(sceneId); JSONObject result = new JSONObject(); result.put("alarmTypes", alarmTypes); result.put("alarmLevels",alarmLevels); - result.put("devices",devices); +// result.put("devices",devices); + result.put("models",models); return success(result); } diff --git a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/controller/HwDeviceController.java b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/controller/HwDeviceController.java index 273a192..6a4cd40 100644 --- a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/controller/HwDeviceController.java +++ b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/controller/HwDeviceController.java @@ -246,5 +246,9 @@ public class HwDeviceController extends BaseController { public void computeOnlineDevicecCount(@PathVariable("days") int days) { hwDeviceService.computeOnlineDevicecCount(days); } + @GetMapping("/getDeviceByModel") + public AjaxResult getDeviceByModel(Long modelId){ + return AjaxResult.success(hwDeviceModeService.getDeviceByModel(modelId)); + } } diff --git a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/controller/HwDeviceModeController.java b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/controller/HwDeviceModeController.java index 4a7360c..552d4f3 100644 --- a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/controller/HwDeviceModeController.java +++ b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/controller/HwDeviceModeController.java @@ -147,4 +147,6 @@ public class HwDeviceModeController extends BaseController { public void rebuildTdSuperTables() { hwDeviceModeService.rebuildTdSuperTables(); } + + } diff --git a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/controller/HwOfflineRuleController.java b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/controller/HwOfflineRuleController.java new file mode 100644 index 0000000..764f0e0 --- /dev/null +++ b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/controller/HwOfflineRuleController.java @@ -0,0 +1,25 @@ +package com.ruoyi.business.controller; + +import com.ruoyi.business.domain.HwOfflineRule; +import com.ruoyi.business.service.HwOfflineRuleService; +import com.ruoyi.common.core.web.controller.BaseController; +import com.ruoyi.common.core.web.page.TableDataInfo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +@RestController +@RequestMapping("/offlineRule") +public class HwOfflineRuleController extends BaseController { + + @Autowired + private HwOfflineRuleService hwOfflineRuleService; + + @GetMapping("list") + public TableDataInfo list(HwOfflineRule hwOfflineRule){ + startPage(); + List hwOfflineRules = hwOfflineRuleService.selectRuleList(hwOfflineRule); + return getDataTable(hwOfflineRules); + } +} diff --git a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/mapper/HwDeviceMapper.java b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/mapper/HwDeviceMapper.java index ce781f0..678c813 100644 --- a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/mapper/HwDeviceMapper.java +++ b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/mapper/HwDeviceMapper.java @@ -134,4 +134,8 @@ public interface HwDeviceMapper * @return List */ public List selectUnallocatedList(HwDevice hwDevice); + + int getOnlineDeviceNum1(Long sceneId); + + List getDeviceByModel(Long modelId); } diff --git a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/mapper/HwDeviceModeMapper.java b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/mapper/HwDeviceModeMapper.java index d4297c2..ae1e860 100644 --- a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/mapper/HwDeviceModeMapper.java +++ b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/mapper/HwDeviceModeMapper.java @@ -143,4 +143,6 @@ public interface HwDeviceModeMapper * @return 设备模型集合 */ public List selectHwDeviceModeJoinList(HwDeviceMode hwDeviceMode); + + List selectModel(Long sceneId); } diff --git a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/mapper/HwOfflineRuleMapper.java b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/mapper/HwOfflineRuleMapper.java new file mode 100644 index 0000000..819ade1 --- /dev/null +++ b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/mapper/HwOfflineRuleMapper.java @@ -0,0 +1,12 @@ +package com.ruoyi.business.mapper; + +import com.ruoyi.business.domain.HwOfflineRule; + +import java.util.List; + +public interface HwOfflineRuleMapper { + + List selectHwOfflineRuleJoinList(HwOfflineRule hwOfflineRule); + + +} diff --git a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/HwOfflineRuleService.java b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/HwOfflineRuleService.java new file mode 100644 index 0000000..617e237 --- /dev/null +++ b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/HwOfflineRuleService.java @@ -0,0 +1,9 @@ +package com.ruoyi.business.service; + +import com.ruoyi.business.domain.HwOfflineRule; + +import java.util.List; + +public interface HwOfflineRuleService { + List selectRuleList(HwOfflineRule hwOfflineRule); +} diff --git a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/IHwDeviceModeService.java b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/IHwDeviceModeService.java index d0ba61f..0523311 100644 --- a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/IHwDeviceModeService.java +++ b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/IHwDeviceModeService.java @@ -3,6 +3,7 @@ package com.ruoyi.business.service; import java.util.List; import java.util.Map; +import com.ruoyi.business.domain.HwDevice; import com.ruoyi.business.domain.HwDeviceMode; import com.ruoyi.business.domain.HwDeviceModeFunction; import com.ruoyi.business.domain.HwDeviceModeParameter; @@ -134,4 +135,7 @@ public interface IHwDeviceModeService */ public HwDeviceMode selectHwDeviceModeByDeviceId(Long deviceId); + List selectModel(Long sceneId); + + List getDeviceByModel(Long modelId); } diff --git a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwAlarmRuleServiceImpl.java b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwAlarmRuleServiceImpl.java index 30be5cc..bf75ffc 100644 --- a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwAlarmRuleServiceImpl.java +++ b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwAlarmRuleServiceImpl.java @@ -117,14 +117,21 @@ public class HwAlarmRuleServiceImpl implements IHwAlarmRuleService { @Transactional @Override public int insertHwAlarmRule(HwAlarmRule hwAlarmRule) { - String triggerExpression = this.getTriggerExpression(hwAlarmRule); - hwAlarmRule.setTriggerExpression(triggerExpression); - hwAlarmRule.setAlarmPushFlag(HwDictConstants.ALARM_PUSH_FLAG_NO); - hwAlarmRule.setCreateTime(DateUtils.getNowDate()); - hwAlarmRule.setTenantId(SecurityUtils.getTenantId()); - hwAlarmRule.setCreateBy(SecurityUtils.getUsername()); - int rows = hwAlarmRuleMapper.insertHwAlarmRule(hwAlarmRule); - insertHwAlarmRuleLink(hwAlarmRule); + List ruleDeviceIds = hwAlarmRule.getRuleDeviceIds(); + int rows = 0; + for (Long ruleDeviceId : ruleDeviceIds) { + hwAlarmRule.setRuleDeviceId(ruleDeviceId); + String triggerExpression = this.getTriggerExpression(hwAlarmRule); + hwAlarmRule.setTriggerExpression(triggerExpression); + hwAlarmRule.setAlarmPushFlag(HwDictConstants.ALARM_PUSH_FLAG_NO); + hwAlarmRule.setCreateTime(DateUtils.getNowDate()); + hwAlarmRule.setTenantId(SecurityUtils.getTenantId()); + hwAlarmRule.setCreateBy(SecurityUtils.getUsername()); + int rowsAdd = hwAlarmRuleMapper.insertHwAlarmRule(hwAlarmRule); + insertHwAlarmRuleLink(hwAlarmRule); + rows += rowsAdd; + } + return rows; } diff --git a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwDeviceModeServiceImpl.java b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwDeviceModeServiceImpl.java index 61187a2..06849ed 100644 --- a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwDeviceModeServiceImpl.java +++ b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwDeviceModeServiceImpl.java @@ -433,6 +433,16 @@ public class HwDeviceModeServiceImpl implements IHwDeviceModeService { return deviceMode; } + @Override + public List selectModel(Long sceneId) { + return hwDeviceModeMapper.selectModel(sceneId); + } + + @Override + public List getDeviceByModel(Long modelId) { + return hwDeviceMapper.getDeviceByModel(modelId); + } + /** * @param: hwDeviceModeFunction diff --git a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwMonitorUnitServiceImpl.java b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwMonitorUnitServiceImpl.java index ed28dc4..2f5647e 100644 --- a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwMonitorUnitServiceImpl.java +++ b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwMonitorUnitServiceImpl.java @@ -174,7 +174,7 @@ public class HwMonitorUnitServiceImpl implements IHwMonitorUnitService { public SubDeviceSumVo selectSubDeviceSum(Long sceneId) { AllNumsVo numsVo = selectAllNums(sceneId); //获取在线设备数量,获取已发布状态子设备并且关联网关为在线的数量以及在线状态发布状态的直连设备数量之和 - int onlineDeviceNum = hwDeviceMapper.getOnlineDeviceNum(sceneId); + int onlineDeviceNum = hwDeviceMapper.getOnlineDeviceNum1(sceneId); SubDeviceSumVo subDeviceSumVo = new SubDeviceSumVo(); subDeviceSumVo.setSubSum(numsVo.getSubSum());//监控单元数量 diff --git a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwOfflineRuleServiceImpl.java b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwOfflineRuleServiceImpl.java new file mode 100644 index 0000000..f9ffec5 --- /dev/null +++ b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwOfflineRuleServiceImpl.java @@ -0,0 +1,19 @@ +package com.ruoyi.business.service.impl; + +import com.ruoyi.business.domain.HwOfflineRule; +import com.ruoyi.business.mapper.HwOfflineRuleMapper; +import com.ruoyi.business.service.HwOfflineRuleService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; +@Service +public class HwOfflineRuleServiceImpl implements HwOfflineRuleService { + @Autowired + private HwOfflineRuleMapper hwOfflineRuleMapper; + @Override + public List selectRuleList(HwOfflineRule hwOfflineRule) { + List hwOfflineRules = hwOfflineRuleMapper.selectHwOfflineRuleJoinList(hwOfflineRule); + return hwOfflineRules; + } +} diff --git a/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwAlarmRuleMapper.xml b/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwAlarmRuleMapper.xml index 66c43e1..00f7350 100644 --- a/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwAlarmRuleMapper.xml +++ b/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwAlarmRuleMapper.xml @@ -118,13 +118,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" order by har.alarm_rule_id desc - select a.alarm_rule_id, a.alarm_rule_name, a.tenant_id, a.scene_id, a.language_code, a.alarm_level_id, a.alarm_type_id, a.rule_type, a.rule_device_id, a.rule_function_total, a.trigger_expression, a.link_flag, a.alarm_rule_status, a.alarm_push_flag, a.alarm_push_content, a.alarm_recover_content, a.remark, a.create_by, a.create_time, a.update_by, a.update_time, a.alarm_rule_field, b.rule_link_id as sub_rule_link_id, b.alarm_rule_type as sub_alarm_rule_type, b.alarm_rule_id as sub_alarm_rule_id, b.link_type as sub_link_type, b.link_device_id as sub_link_device_id, b.link_device_function_id as sub_link_device_function_id, b.link_device_function_identifier as sub_link_device_function_identifier, b.link_device_function_data as sub_link_device_function_data, hd.device_name as sub_link_device_name,hdmf.function_name as sub_link_device_mode_function_name + ,d.device_mode_id as device_mode_id,d.device_mode_name as device_mode_name from hw_alarm_rule a left join hw_alarm_rule_link b on b.alarm_rule_id = a.alarm_rule_id and b.alarm_rule_type=1 left join hw_device hd on b.link_device_id = hd.device_id left join hw_device_mode_function hdmf on b.link_device_function_id=hdmf.mode_function_id + left join hw_device c on a.rule_device_id = c.device_id + left join hw_device_mode d on d.device_mode_id = c.device_mode_id where a.alarm_rule_id = #{alarmRuleId} diff --git a/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwDeviceMapper.xml b/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwDeviceMapper.xml index c981a02..2ee2514 100644 --- a/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwDeviceMapper.xml +++ b/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwDeviceMapper.xml @@ -40,7 +40,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - @@ -48,9 +47,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + + diff --git a/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwDeviceModeMapper.xml b/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwDeviceModeMapper.xml index d128d86..a777014 100644 --- a/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwDeviceModeMapper.xml +++ b/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwDeviceModeMapper.xml @@ -321,6 +321,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" order by hdm.device_mode_id desc + diff --git a/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwOfflineRuleMapper.xml b/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwOfflineRuleMapper.xml index fcb25bb..fab7db8 100644 --- a/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwOfflineRuleMapper.xml +++ b/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwOfflineRuleMapper.xml @@ -236,5 +236,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" order by hor.offline_rule_id desc + \ No newline at end of file diff --git a/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwSceneMapper.xml b/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwSceneMapper.xml index bb40a02..e4a57cf 100644 --- a/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwSceneMapper.xml +++ b/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwSceneMapper.xml @@ -75,6 +75,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"