change - 添加温度音频报警逻辑

master
yinq 4 months ago
parent 4f3221f5e0
commit 5265a43ea8

@ -308,6 +308,22 @@ function tankuan(){
$(".tipfloat").animate({height:"show"},800);
}
document.getElementById('alarmPrompt').addEventListener('click', function() {
var alarmAudio = document.getElementById('alarmAudio');
alarmAudio.play(); // 播放音频
});
// 报警音频播放函数
function playAlarmSound() {
var alarmAudio = document.getElementById('alarmAudio');
if (alarmAudio) {
alarmAudio.play();
} else {
// 如果audio元素不存在则动态创建
alarmAudio = new Audio('/file/alarmAudio.mp3');
alarmAudio.play();
}
}
function deleteValue(){
/*alert(123)
console.log("时间:"+myDate.toLocaleTimeString())*/
@ -325,8 +341,9 @@ function deleteValue(){
/*$("#myModalButton").click();*/
getAlarmPormat();
tankuan();
setTimeout("document.getElementById('closeIconButton').onclick()",1000*8);
// 添加报警音频播放逻辑
playAlarmSound();
setTimeout("document.getElementById('closeIconButton').onclick()",1000 * 8);
}
},
error: function (data) {

@ -2,14 +2,19 @@ package com.ruoyi.quartz.task;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.system.domain.TArraytemperaturedata;
import com.ruoyi.system.domain.TSetmonitorthresholdvalue;
import com.ruoyi.system.domain.T_Alarm_Data;
import com.ruoyi.system.domain.T_W_Temperturedata;
import com.ruoyi.system.domain.dto.T_Alarm_DataDTO;
import com.ruoyi.system.mapper.TArraytemperaturedataMapper;
import com.ruoyi.system.mapper.TSetmonitorthresholdvalueMapper;
import com.ruoyi.system.mapper.T_Alarm_DataMapper;
import com.ruoyi.system.mapper.T_W_TemperturedataMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.ruoyi.common.utils.StringUtils;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.HashMap;
@ -27,6 +32,12 @@ public class RyTask {
@Autowired
private TArraytemperaturedataMapper tArraytemperaturedataMapper;
@Autowired
private T_W_TemperturedataMapper tWTemperturedataMapper;
@Autowired
private TSetmonitorthresholdvalueMapper setmonitorthresholdvalueMapper;
@Autowired
private T_Alarm_DataMapper tAlarmDataMapper;
@ -55,7 +66,7 @@ public class RyTask {
}
/**
*
*
*/
public void ArrayTemperatureSensorAlarm() {
String nowTime = DateUtils.getTime();
@ -91,4 +102,65 @@ public class RyTask {
}
}
/**
*
*/
public void temperatureAlarm() {
String nowTime = DateUtils.getTime();
String beginTime = LocalDateTime
.parse(nowTime, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))
.plusMinutes(-2) // 加一分钟
.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
T_W_Temperturedata selectData = new T_W_Temperturedata();
HashMap<String, Object> selectMap = new HashMap<>();
selectMap.put("beginTime", beginTime);
selectMap.put("endTime", nowTime);
selectData.setParams(selectMap);
List<T_W_Temperturedata> dataList = tWTemperturedataMapper.selectT_W_illdataList(selectData);
T_Alarm_Data alarmData = new T_Alarm_Data();
alarmData.setAlarmStatus(1); //0-已处理 1-未处理
List<T_Alarm_DataDTO> dataDTOList = tAlarmDataMapper.selectT_Alarm_DataList(alarmData);
List<String> alarmList = dataDTOList.stream().map(T_Alarm_DataDTO::getMonitorId).collect(Collectors.toList());
TSetmonitorthresholdvalue selectValue = new TSetmonitorthresholdvalue();
selectValue.setMonitorType(16);
List<TSetmonitorthresholdvalue> thresholdlist = setmonitorthresholdvalueMapper.selectTSetmonitorthresholdvalueList(selectValue);
for (T_W_Temperturedata data : dataList) {
String monitorId = data.getMonitorId();
if (alarmList.contains(monitorId)){
continue;
}
for (TSetmonitorthresholdvalue value : thresholdlist) {
if (value.getMonitorId().equals(monitorId)){
BigDecimal temperatureMax = value.getTemperatureMax();
BigDecimal temperatureMin = value.getTemperatureMin();
if (StringUtils.isNotNull(temperatureMax) && data.getTempreture().compareTo(temperatureMax) > 0){
T_Alarm_Data insertData = new T_Alarm_Data();
insertData.setMonitorId(data.getMonitorId());
insertData.setCollectTime(DateUtils.getNowDate());
insertData.setAlarmType(0);//0-过高报警 1-过低报警
insertData.setMonitorType(16);
insertData.setAlarmStatus(1);
insertData.setAlarmData(data.getTempreture());
insertData.setCause(value.gettMaxIdea() != null ? value.gettMaxIdea() : "温度过高");
tAlarmDataMapper.insertT_Alarm_Data(insertData);
}
if (StringUtils.isNotNull(temperatureMin) && temperatureMin.compareTo(data.getTempreture()) > 0){
T_Alarm_Data insertData = new T_Alarm_Data();
insertData.setMonitorId(data.getMonitorId());
insertData.setCollectTime(DateUtils.getNowDate());
insertData.setAlarmType(0);//0-过高报警 1-过低报警
insertData.setMonitorType(16);
insertData.setAlarmStatus(1);
insertData.setAlarmData(data.getTempreture());
insertData.setCause(value.gettMinIdea() != null ? value.gettMinIdea() : "温度过底");
tAlarmDataMapper.insertT_Alarm_Data(insertData);
}
break;
}
}
}
}
}

@ -126,6 +126,7 @@
<include refid="selectTSetmonitorthresholdvalueVo"/>
<where>
<if test="monitorId != null and monitorId != ''">and stv.monitorId = #{monitorId}</if>
<if test="monitorType != null and monitorType != ''">and t1.monitorType = #{monitorType}</if>
</where>
</select>

@ -121,7 +121,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="monitorId != null and monitorId != ''"> and t1.monitorId = #{monitorId}</if>
<if test="params.beginCollectTime != null and params.beginCollectTime != '' and params.endCollectTime != null and params.endCollectTime != ''"> and t1.collectTime between #{params.beginCollectTime} and #{params.endCollectTime}</if>
<if test="startTime != null and startTime != '' and endTime != null and endTime != ''"> and t1.collectTime between #{startTime} and #{endTime}</if>
and t2.secondType=1 and (t1.illuminance>1)
</where>
</select>

Loading…
Cancel
Save