粉尘,温湿度,噪声报警信息采集任务

master
马雪伟 1 week ago
parent 9c88db4ef7
commit a5f3927e44

@ -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);
}

@ -27,6 +27,11 @@ public class RemoteEmsFallbackFactory implements FallbackFactory<RemoteEmsServic
}
@Override
public R<?> dnthAlarmTask(String source) {
return R.fail("调用失败:" + throwable.getMessage());
}
@Override
public R<?> deviceOfflineTimingTask(String source) {
return R.fail("调用失败:" + throwable.getMessage());

@ -186,4 +186,12 @@ public class RecordAlarmDataController extends BaseController {
return recordAlarmDataService.dailyConsumptionTimingTask();
}
/**
* 湿
*/
@PostMapping("/dnthAlarmTask")
public R<Boolean> dnthAlarmTask(){
return recordAlarmDataService.dnthAlarmTask();
}
}

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

@ -58,4 +58,6 @@ public interface RecordAlarmRuleMapper
* @return
*/
public int deleteRecordAlarmRuleByObjIds(Long[] objIds);
List<RecordAlarmRule> selectEnergyTypes();
}

@ -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<RecordDnbInstant> offlineAlerts(RecordDnbInstant recordDnbInstant);
List<RecordAlarmData> selectNoiseCount(@Param("time") Date time,@Param("maxValue") int maxValue);
List<RecordAlarmData> selectDustCount(@Param("time") Date time,@Param("maxValue") int maxValue);
List<RecordAlarmData> selectTemAndHumCount(@Param("time") Date time,@Param("maxValue") int maxValue);
}

@ -68,4 +68,6 @@ public interface IRecordAlarmDataService {
R<Boolean> dailyConsumptionTimingTask();
R<Boolean> dnthAlarmTask();
}

@ -566,6 +566,74 @@ public class RecordAlarmDataServiceImpl implements IRecordAlarmDataService {
}
}
@Override
public R<Boolean> dnthAlarmTask() {
List<RecordAlarmRule> 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<RecordAlarmData> 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<RecordAlarmData> 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<RecordAlarmData> 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

@ -52,6 +52,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<include refid="selectRecordAlarmRuleVo"/>
where objId = #{objId}
</select>
<select id="selectEnergyTypes" resultType="com.hw.ems.record.domain.RecordAlarmRule">
select objId, rule_id, rule_name,monitor_id monitorId, collect_time, energy_type energyType, trigger_rule triggerRule, trigger_number triggerNumber, time_range timeRange, device_offline_time, notify_user, cause, create_by, create_time, update_by, update_time, dept_id, user_id FROM `hwjy-cloud`.record_alarm_rule where energy_type != 2 and trigger_rule = 0
</select>
<insert id="insertRecordAlarmRule" parameterType="RecordAlarmRule" useGeneratedKeys="true" keyProperty="objId">
insert into record_alarm_rule

@ -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
</select>
<select id="selectNoiseCount" resultType="com.hw.ems.record.domain.RecordAlarmData">
SELECT x.monitorId,count(1) alarmCount FROM `hwjy-cloud`.record_iotenv_instant x where x.noise >#{maxValue} and x.recodeTime >#{time} group by x.monitorId
</select>
<select id="selectDustCount" resultType="com.hw.ems.record.domain.RecordAlarmData">
SELECT x.monitorId,count(1) alarmCount FROM `hwjy-cloud`.record_iotenv_instant x where (x.pm1 >#{maxValue} or x.pm2 >#{maxValue} or x.pm10>#{maxValue}) and x.recodeTime >#{time} group by x.monitorId
</select>
<select id="selectTemAndHumCount" resultType="com.hw.ems.record.domain.RecordAlarmData">
SELECT x.monitorId,count(1) alarmCount FROM `hwjy-cloud`.record_iotenv_instant x where (x.tempreture>#{maxValue} or x.humidity>#{maxValue}) and x.recodeTime >#{time} group by x.monitorId
</select>
<insert id="insertRecordDnbInstant" parameterType="RecordDnbInstant" useGeneratedKeys="true" keyProperty="objid">
insert into record_dnb_instant

@ -102,6 +102,10 @@
<version>3.6.3</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.hw</groupId>
<artifactId>hw-api-mes</artifactId>
</dependency>
</dependencies>

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

Loading…
Cancel
Save