diff --git a/hw-api/hw-api-ems/src/main/java/com/hw/ems/api/RemoteEmsService.java b/hw-api/hw-api-ems/src/main/java/com/hw/ems/api/RemoteEmsService.java index 5839100..90360af 100644 --- a/hw-api/hw-api-ems/src/main/java/com/hw/ems/api/RemoteEmsService.java +++ b/hw-api/hw-api-ems/src/main/java/com/hw/ems/api/RemoteEmsService.java @@ -26,4 +26,7 @@ public interface RemoteEmsService { @PostMapping("/record/alarmData/deviceOfflineTimingTask") R deviceOfflineTimingTask(@RequestHeader(SecurityConstants.FROM_SOURCE) String source); + @PostMapping("/record/alarmData/dnthAlarmTask") + R dnthAlarmTask(@RequestHeader(SecurityConstants.FROM_SOURCE) String source); + } diff --git a/hw-api/hw-api-ems/src/main/java/com/hw/ems/api/factory/RemoteEmsFallbackFactory.java b/hw-api/hw-api-ems/src/main/java/com/hw/ems/api/factory/RemoteEmsFallbackFactory.java index c3415f8..a37196c 100644 --- a/hw-api/hw-api-ems/src/main/java/com/hw/ems/api/factory/RemoteEmsFallbackFactory.java +++ b/hw-api/hw-api-ems/src/main/java/com/hw/ems/api/factory/RemoteEmsFallbackFactory.java @@ -27,6 +27,11 @@ public class RemoteEmsFallbackFactory implements FallbackFactory dnthAlarmTask(String source) { + return R.fail("调用失败:" + throwable.getMessage()); + } + @Override public R deviceOfflineTimingTask(String source) { return R.fail("调用失败:" + throwable.getMessage()); diff --git a/hw-modules/hw-ems/src/main/java/com/hw/ems/record/controller/RecordAlarmDataController.java b/hw-modules/hw-ems/src/main/java/com/hw/ems/record/controller/RecordAlarmDataController.java index 2a9e932..96b0e08 100644 --- a/hw-modules/hw-ems/src/main/java/com/hw/ems/record/controller/RecordAlarmDataController.java +++ b/hw-modules/hw-ems/src/main/java/com/hw/ems/record/controller/RecordAlarmDataController.java @@ -186,4 +186,12 @@ public class RecordAlarmDataController extends BaseController { return recordAlarmDataService.dailyConsumptionTimingTask(); } + /** + * 粉尘、噪声、温湿度报警 + */ + @PostMapping("/dnthAlarmTask") + public R dnthAlarmTask(){ + return recordAlarmDataService.dnthAlarmTask(); + } + } diff --git a/hw-modules/hw-ems/src/main/java/com/hw/ems/record/domain/RecordAlarmData.java b/hw-modules/hw-ems/src/main/java/com/hw/ems/record/domain/RecordAlarmData.java index 8c64853..f35faf4 100644 --- a/hw-modules/hw-ems/src/main/java/com/hw/ems/record/domain/RecordAlarmData.java +++ b/hw-modules/hw-ems/src/main/java/com/hw/ems/record/domain/RecordAlarmData.java @@ -96,7 +96,14 @@ public class RecordAlarmData extends BaseEntity private String alarmStatusName; + private Integer alarmCount; + public Integer getAlarmCount() { + return alarmCount; + } + public void setAlarmCount(Integer alarmCount) { + this.alarmCount = alarmCount; + } public String getAlarmStatusName() { return alarmStatusName; } diff --git a/hw-modules/hw-ems/src/main/java/com/hw/ems/record/mapper/RecordAlarmRuleMapper.java b/hw-modules/hw-ems/src/main/java/com/hw/ems/record/mapper/RecordAlarmRuleMapper.java index c51955a..db3ed51 100644 --- a/hw-modules/hw-ems/src/main/java/com/hw/ems/record/mapper/RecordAlarmRuleMapper.java +++ b/hw-modules/hw-ems/src/main/java/com/hw/ems/record/mapper/RecordAlarmRuleMapper.java @@ -58,4 +58,6 @@ public interface RecordAlarmRuleMapper * @return 结果 */ public int deleteRecordAlarmRuleByObjIds(Long[] objIds); + + List selectEnergyTypes(); } diff --git a/hw-modules/hw-ems/src/main/java/com/hw/ems/record/mapper/RecordDnbInstantMapper.java b/hw-modules/hw-ems/src/main/java/com/hw/ems/record/mapper/RecordDnbInstantMapper.java index 1882d98..add20ba 100644 --- a/hw-modules/hw-ems/src/main/java/com/hw/ems/record/mapper/RecordDnbInstantMapper.java +++ b/hw-modules/hw-ems/src/main/java/com/hw/ems/record/mapper/RecordDnbInstantMapper.java @@ -1,7 +1,10 @@ package com.hw.ems.record.mapper; +import com.hw.ems.record.domain.RecordAlarmData; import com.hw.ems.record.domain.RecordDnbInstant; +import org.apache.ibatis.annotations.Param; +import java.util.Date; import java.util.List; import java.util.Map; @@ -89,4 +92,10 @@ public interface RecordDnbInstantMapper * @return */ List offlineAlerts(RecordDnbInstant recordDnbInstant); + + List selectNoiseCount(@Param("time") Date time,@Param("maxValue") int maxValue); + + List selectDustCount(@Param("time") Date time,@Param("maxValue") int maxValue); + + List selectTemAndHumCount(@Param("time") Date time,@Param("maxValue") int maxValue); } diff --git a/hw-modules/hw-ems/src/main/java/com/hw/ems/record/service/IRecordAlarmDataService.java b/hw-modules/hw-ems/src/main/java/com/hw/ems/record/service/IRecordAlarmDataService.java index d9d24b7..8640ab9 100644 --- a/hw-modules/hw-ems/src/main/java/com/hw/ems/record/service/IRecordAlarmDataService.java +++ b/hw-modules/hw-ems/src/main/java/com/hw/ems/record/service/IRecordAlarmDataService.java @@ -68,4 +68,6 @@ public interface IRecordAlarmDataService { R dailyConsumptionTimingTask(); + R dnthAlarmTask(); + } diff --git a/hw-modules/hw-ems/src/main/java/com/hw/ems/record/service/impl/RecordAlarmDataServiceImpl.java b/hw-modules/hw-ems/src/main/java/com/hw/ems/record/service/impl/RecordAlarmDataServiceImpl.java index 8ec5af8..9d51cab 100644 --- a/hw-modules/hw-ems/src/main/java/com/hw/ems/record/service/impl/RecordAlarmDataServiceImpl.java +++ b/hw-modules/hw-ems/src/main/java/com/hw/ems/record/service/impl/RecordAlarmDataServiceImpl.java @@ -566,6 +566,74 @@ public class RecordAlarmDataServiceImpl implements IRecordAlarmDataService { } } + @Override + public R dnthAlarmTask() { + List types = recordAlarmRuleMapper.selectEnergyTypes(); + for (RecordAlarmRule rule : types) { + System.out.println("kaishile"); + Long timeRange = rule.getTimeRange(); + if (timeRange == 0){ + timeRange = 1L; + } + Calendar instance = Calendar.getInstance(); + instance.add(Calendar.MINUTE,-timeRange.intValue()); + Date time = instance.getTime(); + Long triggerNumber = rule.getTriggerNumber(); + if (triggerNumber == 0){ + triggerNumber = 1L; + } + if (rule.getEnergyType() == 4){ + List records = recordDnbInstantMapper.selectNoiseCount(time,50); + for (RecordAlarmData record : records) { + if (record.getAlarmCount()>triggerNumber){ + RecordAlarmData alarmData = new RecordAlarmData(); + alarmData.setMonitorId(record.getMonitorId()); + alarmData.setCollectTime(new Date()); + alarmData.setAlarmType(3L); + alarmData.setAlarmStatus(1L); + alarmData.setAlarmData("超过噪声阈值"); + recordAlarmDataMapper.insertRecordAlarmData(alarmData); + }else { + continue; + } + } + }else if (rule.getEnergyType() == 6){ + List records = recordDnbInstantMapper.selectDustCount(time,19); + for (RecordAlarmData record : records) { + if (record.getAlarmCount()>triggerNumber){ + RecordAlarmData alarmData = new RecordAlarmData(); + alarmData.setMonitorId(record.getMonitorId()); + alarmData.setCollectTime(new Date()); + alarmData.setAlarmType(3L); + alarmData.setAlarmStatus(1L); + alarmData.setAlarmData("超过粉尘阈值"); + recordAlarmDataMapper.insertRecordAlarmData(alarmData); + }else { + continue; + } + } + }else if (rule.getEnergyType() == 7){ + List records = recordDnbInstantMapper.selectTemAndHumCount(time,30); + for (RecordAlarmData record : records) { + if (record.getAlarmCount()>triggerNumber){ + RecordAlarmData alarmData = new RecordAlarmData(); + alarmData.setMonitorId(record.getMonitorId()); + alarmData.setCollectTime(new Date()); + alarmData.setAlarmType(3L); + alarmData.setAlarmStatus(1L); + alarmData.setAlarmData("超过温湿度阈值"); + recordAlarmDataMapper.insertRecordAlarmData(alarmData); + }else { + continue; + } + } + } + + + } + return null; + } + /** * 日耗量告警 * @return diff --git a/hw-modules/hw-ems/src/main/resources/mapper/record/RecordAlarmRuleMapper.xml b/hw-modules/hw-ems/src/main/resources/mapper/record/RecordAlarmRuleMapper.xml index a195035..a68134b 100644 --- a/hw-modules/hw-ems/src/main/resources/mapper/record/RecordAlarmRuleMapper.xml +++ b/hw-modules/hw-ems/src/main/resources/mapper/record/RecordAlarmRuleMapper.xml @@ -52,6 +52,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" where objId = #{objId} + insert into record_alarm_rule diff --git a/hw-modules/hw-ems/src/main/resources/mapper/record/RecordDnbInstantMapper.xml b/hw-modules/hw-ems/src/main/resources/mapper/record/RecordDnbInstantMapper.xml index 22afc57..c6bc5f9 100644 --- a/hw-modules/hw-ems/src/main/resources/mapper/record/RecordDnbInstantMapper.xml +++ b/hw-modules/hw-ems/src/main/resources/mapper/record/RecordDnbInstantMapper.xml @@ -184,6 +184,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" join base_monitor_info m on m.monitor_id = rdi.monitor_id and m.monitor_status = 0 and m.is_ammeter = 'false' where #{recordTime} > d.record_time + + + insert into record_dnb_instant diff --git a/hw-modules/hw-job/pom.xml b/hw-modules/hw-job/pom.xml index 813427e..a151004 100644 --- a/hw-modules/hw-job/pom.xml +++ b/hw-modules/hw-job/pom.xml @@ -102,6 +102,10 @@ 3.6.3 compile + + com.hw + hw-api-mes + diff --git a/hw-modules/hw-job/src/main/java/com/hw/job/task/RyTask.java b/hw-modules/hw-job/src/main/java/com/hw/job/task/RyTask.java index d8ed013..dd05331 100644 --- a/hw-modules/hw-job/src/main/java/com/hw/job/task/RyTask.java +++ b/hw-modules/hw-job/src/main/java/com/hw/job/task/RyTask.java @@ -58,6 +58,11 @@ public class RyTask remoteEmsService.thresholdTimingTask(SecurityConstants.INNER); } + public void dnthAlarmTask(){ + System.out.println("++能源报警任务+开始++thresholdTimingTask+++++"); + remoteEmsService.dnthAlarmTask(SecurityConstants.INNER); + } + public void getDnbInstantByJob(){ System.out.println("++电整点数据获取+开始++getDnbInstantByJob+++++"); remoteEmsService.getDnbInstantByJob(SecurityConstants.INNER);