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 index 764f0e0..fbd7fdc 100644 --- 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 @@ -22,4 +22,21 @@ public class HwOfflineRuleController extends BaseController { List hwOfflineRules = hwOfflineRuleService.selectRuleList(hwOfflineRule); return getDataTable(hwOfflineRules); } + @GetMapping("/{offlineRuleId}") + public HwOfflineRule selectOfflineRuleById(@PathVariable("offlineRuleId") Long offlineRuleId){ + HwOfflineRule hwOfflineRule = hwOfflineRuleService.selectOfflineRuleById(offlineRuleId); + return hwOfflineRule; + } + + @DeleteMapping("/{offlineRuleId}") + public int deleteOfflineRuleById(@PathVariable("offlineRuleId") Long offlineRuleId){ + return hwOfflineRuleService.deleteOfflineRuleById(offlineRuleId); + + } + + @PostMapping + public int addOfflineRule(@RequestBody HwOfflineRule hwOfflineRule){ + return hwOfflineRuleService.addOfflineRule(hwOfflineRule); + + } } diff --git a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/domain/BeaconDevice.java b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/domain/BeaconDevice.java index b637b8c..f3db390 100644 --- a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/domain/BeaconDevice.java +++ b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/domain/BeaconDevice.java @@ -26,6 +26,14 @@ public class BeaconDevice { private String ifAlarm; private String monitorUnitName; + private Boolean alarmElectronFence; + public Boolean getAlarmElectronFence() { + return alarmElectronFence; + } + + public void setAlarmElectronFence(Boolean alarmElectronFence) { + this.alarmElectronFence = alarmElectronFence; + } public String getIfAlarm() { return ifAlarm; diff --git a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/mapper/HwAlarmRuleMapper.java b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/mapper/HwAlarmRuleMapper.java index 57a73b2..bca3ebc 100644 --- a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/mapper/HwAlarmRuleMapper.java +++ b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/mapper/HwAlarmRuleMapper.java @@ -3,6 +3,8 @@ package com.ruoyi.business.mapper; import java.util.List; import com.ruoyi.business.domain.HwAlarmRule; import com.ruoyi.business.domain.HwAlarmRuleLink; +import com.ruoyi.business.domain.HwDevice; +import com.ruoyi.business.domain.HwDeviceMode; /** * 报警规则Mapper接口 @@ -18,7 +20,7 @@ public interface HwAlarmRuleMapper * @param alarmRuleId 报警规则主键 * @return 报警规则 */ - public HwAlarmRule selectHwAlarmRuleByAlarmRuleId(Long alarmRuleId); + public List selectHwAlarmRuleByAlarmRuleId(Long alarmRuleId); /** * 查询报警规则列表 @@ -92,4 +94,6 @@ public interface HwAlarmRuleMapper * @return 结果 */ public int deleteHwAlarmRuleLinkByAlarmRuleId(Long alarmRuleId); + + HwDeviceMode selectModeByDeviceId(Long deviceId); } 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 322daa7..ea5a5bd 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 @@ -172,4 +172,6 @@ public interface HwDeviceMapper Long selectDeviceIfAlarm(Long deviceId); List getDeviceByModel(Long modelId); + + Long selectDeviceIfAlarmElectronFence(Long deviceId); } 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 index 819ade1..6b2d89b 100644 --- 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 @@ -9,4 +9,9 @@ public interface HwOfflineRuleMapper { List selectHwOfflineRuleJoinList(HwOfflineRule hwOfflineRule); + HwOfflineRule selectOfflineRuleById(Long offlineRuleId); + + int deleteOfflineRuleById(Long offlineRuleId); + + int addOfflineRule(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 index 617e237..5cffd21 100644 --- 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 @@ -6,4 +6,10 @@ import java.util.List; public interface HwOfflineRuleService { List selectRuleList(HwOfflineRule hwOfflineRule); + + HwOfflineRule selectOfflineRuleById(Long offlineRuleId); + + int deleteOfflineRuleById(Long offlineRuleId); + + int addOfflineRule(HwOfflineRule hwOfflineRule); } 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 bf75ffc..0dba94a 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 @@ -3,6 +3,7 @@ package com.ruoyi.business.service.impl; import com.ruoyi.business.domain.HwAlarmInfo; import com.ruoyi.business.domain.HwAlarmRule; import com.ruoyi.business.domain.HwAlarmRuleLink; +import com.ruoyi.business.domain.HwDeviceMode; import com.ruoyi.business.mapper.HwAlarmInfoMapper; import com.ruoyi.business.mapper.HwAlarmRuleMapper; import com.ruoyi.business.service.IHwAlarmRuleService; @@ -40,7 +41,17 @@ public class HwAlarmRuleServiceImpl implements IHwAlarmRuleService { */ @Override public HwAlarmRule selectHwAlarmRuleByAlarmRuleId(Long alarmRuleId) { - HwAlarmRule alarmRule = hwAlarmRuleMapper.selectHwAlarmRuleByAlarmRuleId(alarmRuleId); + List alarmRules = hwAlarmRuleMapper.selectHwAlarmRuleByAlarmRuleId(alarmRuleId); + ArrayList ruleDeviceIds = new ArrayList<>(); + for (HwAlarmRule rule : alarmRules) { + ruleDeviceIds.add(rule.getRuleDeviceId()); + } + HwDeviceMode hwDeviceMode = hwAlarmRuleMapper.selectModeByDeviceId(ruleDeviceIds.get(0)); + HwAlarmRule alarmRule = alarmRules.get(0); + alarmRule.setRuleDeviceIds(ruleDeviceIds); + alarmRule.setDeviceModeId(hwDeviceMode.getDeviceModeId()); + alarmRule.setDeviceModeName(alarmRule.getDeviceModeName()); +// HwAlarmRule alarmRule = hwAlarmRuleMapper.selectHwAlarmRuleByAlarmRuleId(alarmRuleId); String triggerExpression = alarmRule.getTriggerExpression(); String triggerCondition = ""; if (triggerExpression.indexOf("and") > 0) { @@ -106,6 +117,7 @@ public class HwAlarmRuleServiceImpl implements IHwAlarmRuleService { public List selectHwAlarmRuleJoinList(HwAlarmRule hwAlarmRule) { hwAlarmRule.setRuleType(HwDictConstants.ALARM_RULE_RULE_TYPE_DEVICE); return hwAlarmRuleMapper.selectHwAlarmRuleJoinList(hwAlarmRule); + } /** @@ -145,25 +157,32 @@ public class HwAlarmRuleServiceImpl implements IHwAlarmRuleService { @Transactional @Override public int updateHwAlarmRule(HwAlarmRule hwAlarmRule) { - hwAlarmRule.setUpdateTime(DateUtils.getNowDate()); - hwAlarmRule.setUpdateBy(SecurityUtils.getUsername()); - - HwAlarmInfo queryAlarmInfo = new HwAlarmInfo(); - queryAlarmInfo.setAlarmInfoType(HwDictConstants.ALARM_INFO_TYPE_DEVICE); - queryAlarmInfo.setAlarmReleatedId(hwAlarmRule.getAlarmRuleId()); - List alarmInfos = hwAlarmInfoMapper.selectHwAlarmInfoList(queryAlarmInfo); - if (alarmInfos == null || alarmInfos.isEmpty()) {//没有关联报警信息,才能修改表达式 - String triggerExpression = this.getTriggerExpression(hwAlarmRule); - hwAlarmRule.setTriggerExpression(triggerExpression); - } else { - hwAlarmRule.setTriggerExpression(null); - } + List ruleDeviceIds = hwAlarmRule.getRuleDeviceIds(); + int updateRows = 0; + for (Long ruleDeviceId : ruleDeviceIds) { + hwAlarmRule.setRuleDeviceId(ruleDeviceId); + hwAlarmRule.setUpdateTime(DateUtils.getNowDate()); + hwAlarmRule.setUpdateBy(SecurityUtils.getUsername()); + HwAlarmInfo queryAlarmInfo = new HwAlarmInfo(); + queryAlarmInfo.setAlarmInfoType(HwDictConstants.ALARM_INFO_TYPE_DEVICE); + queryAlarmInfo.setAlarmReleatedId(hwAlarmRule.getAlarmRuleId()); + List alarmInfos = hwAlarmInfoMapper.selectHwAlarmInfoList(queryAlarmInfo); + if (alarmInfos == null || alarmInfos.isEmpty()) {//没有关联报警信息,才能修改表达式 + String triggerExpression = this.getTriggerExpression(hwAlarmRule); + hwAlarmRule.setTriggerExpression(triggerExpression); + } else { + hwAlarmRule.setTriggerExpression(null); + } - hwAlarmRuleMapper.deleteHwAlarmRuleLinkByAlarmRuleId(hwAlarmRule.getAlarmRuleId()); - if (hwAlarmRule.getLinkFlag().equals(HwDictConstants.ALARM_RULE_LINK_FLAG_YES)) { - insertHwAlarmRuleLink(hwAlarmRule); + hwAlarmRuleMapper.deleteHwAlarmRuleLinkByAlarmRuleId(hwAlarmRule.getAlarmRuleId()); + if (hwAlarmRule.getLinkFlag().equals(HwDictConstants.ALARM_RULE_LINK_FLAG_YES)) { + insertHwAlarmRuleLink(hwAlarmRule); + } + int row = hwAlarmRuleMapper.updateHwAlarmRule(hwAlarmRule); + updateRows += row; } - return hwAlarmRuleMapper.updateHwAlarmRule(hwAlarmRule); + + return updateRows; } /** diff --git a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwDeviceServiceImpl.java b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwDeviceServiceImpl.java index f90b045..675070d 100644 --- a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwDeviceServiceImpl.java +++ b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwDeviceServiceImpl.java @@ -1183,6 +1183,8 @@ public class HwDeviceServiceImpl implements IHwDeviceService { beaconDevice.setMonitorUnitName(hwDevices.get(i).getMonitorUnitName()); //查询是否报警 Long integer = hwDeviceMapper.selectDeviceIfAlarm(hwDevices.get(i).getDeviceId()); + Long integer1 = hwDeviceMapper.selectDeviceIfAlarmElectronFence(hwDevices.get(i).getDeviceId()); + Boolean alarmElectronFence = false; String ifAlarm = new String(); if (integer>0){ //正常 @@ -1191,7 +1193,11 @@ public class HwDeviceServiceImpl implements IHwDeviceService { else { ifAlarm="0"; } + if (integer1>0){ + alarmElectronFence = true; + } beaconDevice.setIfAlarm(ifAlarm); + beaconDevice.setAlarmElectronFence(alarmElectronFence); lists.add(beaconDevice); } } 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 index f9ffec5..e856116 100644 --- 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 @@ -16,4 +16,19 @@ public class HwOfflineRuleServiceImpl implements HwOfflineRuleService { List hwOfflineRules = hwOfflineRuleMapper.selectHwOfflineRuleJoinList(hwOfflineRule); return hwOfflineRules; } + + @Override + public HwOfflineRule selectOfflineRuleById(Long offlineRuleId) { + return hwOfflineRuleMapper.selectOfflineRuleById(offlineRuleId); + } + + @Override + public int deleteOfflineRuleById(Long offlineRuleId) { + return hwOfflineRuleMapper.deleteOfflineRuleById(offlineRuleId); + } + + @Override + public int addOfflineRule(HwOfflineRule hwOfflineRule) { + return hwOfflineRuleMapper.addOfflineRule(hwOfflineRule); + } } 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 9ccf398..34933d5 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 @@ -129,7 +129,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" left join hw_device_mode_function hdmf on b.link_device_function_id=hdmf.mode_function_id where a.alarm_rule_id = #{alarmRuleId} - + + + insert into hw_alarm_rule 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 8f421f9..fa38cd3 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 @@ -62,10 +62,29 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + 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 fab7db8..3dcd17f 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 @@ -195,6 +195,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" delete from hw_alarm_rule_link where alarm_rule_id = #{alarmRuleId} + + update hw_offline_rule set deleted_flag = 1 + insert into hw_alarm_rule_link( rule_link_id, alarm_rule_type, alarm_rule_id, link_type, link_device_id, link_device_function_id, link_device_function_identifier, link_device_function_data) values @@ -202,7 +205,59 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ( #{item.ruleLinkId}, #{item.alarmRuleType}, #{item.alarmRuleId}, #{item.linkType}, #{item.linkDeviceId}, #{item.linkDeviceFunctionId}, #{item.linkDeviceFunctionIdentifier}, #{item.linkDeviceFunctionData}) - + + insert into hw_offline_rule + + offline_rule_name, + tenant_id, + scene_id, + alarm_level_id, + rule_type, + offline_time, + offline_number_time, + offline_number, + trigger_time_frame, + consume_traffic, + battery_level, + power_down_flag, + link_flag, + alarm_rule_status, + alarm_push_flag, + alarm_push_content, + alarm_recover_content, + remark, + create_by, + create_time, + update_by, + update_time, + offline_rule_field, + + + #{offlineRuleName}, + #{tenantId}, + #{sceneId}, + #{alarmLevelId}, + #{ruleType}, + #{offlineTime}, + #{offlineNumberTime}, + #{offlineNumber}, + #{triggerTimeFrame}, + #{consumeTraffic}, + #{batteryLevel}, + #{powerDownFlag}, + #{linkFlag}, + #{alarmRuleStatus}, + #{alarmPushFlag}, + #{alarmPushContent}, + #{alarmRecoverContent}, + #{remark}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{offlineRuleField}, + + + \ No newline at end of file