change - 告警信息处理

main
wenjy 3 years ago
parent cf2d3b7c26
commit 031a937242

@ -1,9 +1,12 @@
package com.ruoyi.web.controller.iot;
import com.alibaba.fastjson.JSONArray;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.system.domain.BaseAlarmModule;
import com.ruoyi.system.domain.BaseMonitorunitInfo;
import com.ruoyi.system.domain.BaseSensorInfo;
import com.ruoyi.system.domain.RecordAlarm;
import com.ruoyi.system.domain.dto.BaseAlarmModuleDto;
import com.ruoyi.system.domain.dto.BaseMonitorunitInfoDto;
import com.ruoyi.system.domain.dto.BaseSensorInfoDto;
@ -32,7 +35,7 @@ import java.util.stream.Stream;
*/
@Controller
@RequestMapping("/iot/wisdomScenario")
public class WisdomScenarioContorller {
public class WisdomScenarioContorller extends BaseController {
@Autowired private IBaseMonitorunitInfoService baseMonitorunitInfoService;
@ -168,4 +171,18 @@ public class WisdomScenarioContorller {
return null;
}
@GetMapping("/getAlarmByUid")
@ResponseBody
public String getAlarmByUid(String alarmuid){
RecordAlarm recordAlarm = recordAlarmService.selectRecordAlarmBySensorId(alarmuid);
return JSONArray.toJSONString(recordAlarm);
}
@PostMapping("/disposeAlarm")
@ResponseBody
public AjaxResult disposeAlarm(RecordAlarm recordAlarm){
recordAlarm.setDisposeFlag(1L);
return toAjax(recordAlarmService.updateRecordAlarm(recordAlarm));
}
}

@ -1,6 +1,9 @@
package com.ruoyi.web.controller.record;
import java.util.ArrayList;
import java.util.List;
import com.alibaba.fastjson.JSONArray;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
@ -92,10 +95,10 @@ public class RecordAlarmController extends BaseController
/**
*
*/
@GetMapping("/edit/{sensorId}")
public String edit(@PathVariable("sensorId") String sensorId, ModelMap mmap)
@GetMapping("/edit/{alarmuid}")
public String edit(@PathVariable("alarmuid") String alarmuid, ModelMap mmap)
{
RecordAlarm recordAlarm = recordAlarmService.selectRecordAlarmBySensorId(sensorId);
RecordAlarm recordAlarm = recordAlarmService.selectRecordAlarmBySensorId(alarmuid);
mmap.put("recordAlarm", recordAlarm);
return prefix + "/edit";
}

@ -6,12 +6,12 @@ spring:
druid:
# 主库数据源
master:
# url: jdbc:mysql://121.36.58.109:3306/jrm-intelligent-iot?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
# username: root
# password: Haiwei123456
url: jdbc:mysql://localhost:3306/jrm-intelligent-iot?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
url: jdbc:mysql://121.36.58.109:3306/jrm-intelligent-iot?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
username: root
password: root
password: Haiwei123456
# url: jdbc:mysql://localhost:3306/jrm-intelligent-iot?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
# username: root
# password: root
# 从库数据源
slave:
# 从数据源开关/默认关闭

@ -7,7 +7,7 @@ ruoyi:
# 版权年份
copyrightYear: 2021
# 实例演示开关
demoEnabled: false
demoEnabled: true
# 文件路径 示例( Windows配置D:/ruoyi/uploadPathLinux配置 /home/ruoyi/uploadPath
profile: D:/ruoyi/uploadPath
# 获取ip地址开关

File diff suppressed because one or more lines are too long

@ -4,8 +4,7 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="renderer" content="webkit">
<title>智慧场景</title>
<th:block th:include="include :: header('智慧场景')"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link th:href="@{favicon.ico}" rel="shortcut icon"/>
<link th:href="@{/css/bootstrap.min.css}" rel="stylesheet"/>
@ -200,6 +199,16 @@
table td {
padding: 2%
}
.text-success {
background-color: transparent;
border-style: none;
}
.text-danger {
background-color: transparent;
border-style: none;
}
</style>
<script th:src="@{/js/jquery.min.js}"></script>
@ -209,8 +218,8 @@
<script th:src="@{/js/auto-update.js}"></script>
<script th:src="@{/js/font-adjust.js}"></script>
<script th:src="@{/js/MyPage.js}"></script>
<th:block th:include="include :: echarts-js"/>
<script th:inline="javascript"></script>
<script th:src="@{/js/Iot-ui/MiniDialog-es5.min.js}"></script>
</head>
<body class="body-substation-1">
<div class="display-text-1" id="transformer"><span id="unitAmount">78</span></br><span
@ -293,33 +302,32 @@
});
//获取监控单元模块
const alertListColumns = [ '告警编号', '告警单元', '告警位置', '告警信息', '类型', '告警时间', '处理情况']
const alertListColumns = ['告警编号', '告警单元', '告警位置', '告警信息', '类型', '告警时间', '处理情况']
const alertList = new AutoScrollTable(document.getElementById("alert-list"), alertListColumns, {
width: ['10%', '10%', '10%', '30%', '10%', '10%', '10%'],
})
//获取告警信息
$(() => {
const alarmInfo = function () {
$.ajax({
url: "/iot/wisdomScenario/getAlarmInfo?monitorUnitId=" + getParams("id"),
type: "get",
dataType: 'JSON',
success: (res) => {
console.log("告警信息:"+res);
console.log("告警信息:" + res);
alertList.loadData(res.map(value => [value.alarmModuleId.substring(0,2)+"...", value.alarmModuleText,value.sensorLocation,`${"无线检测 相对检测值为:"+value.minValue+"-"+value.maxValue+",其值为:"+value.alarmValue}`, "超限", value.collectTime,`${value.disposeFlag==1?'<a class="text-success">已处理</a>':'<a onclick="alarmDispose('+value+')" class="text-danger">未处理</a>'}`]), Object.keys(alertListColumns))
alertList.loadData(res.map(value => [value.alarmModuleId.substring(0, 2) + "...", value.alarmModuleText, value.sensorLocation, `${"无线检测 相对检测值为:" + value.minValue + "-" + value.maxValue + ",其值为:" + value.alarmValue}`, "超限", value.collectTime, `${value.disposeFlag == 1 ? '<button class="text-success">已处理</button>' : '<button id="' + value.alarmuid + '" onclick="alarmDispose(this.id)" class="text-danger">未处理</button>'}`]), Object.keys(alertListColumns))
},
error: () => {
console.log("失败");
}
})
});
}
function resize() {
fontAdjust()
alertList.resize()
fontAdjust();
alarmInfo();
}
window.onresize = resize
@ -328,8 +336,55 @@
})
const alarmDispose = function (res) {
console.log("ces:"+res);
$.getJSON('/iot/wisdomScenario/getAlarmByUid?alarmuid=' + res, function (result) {
alarmDisposeInfo(result);
})
}
const alarmDisposeInfo = function (res) {
let html = `<div>
<p style="margin-top: 13px;">
<label>告警编号:${res.alarmuid}</label>
</p>
<p style="margin-top: 13px;">
<label>告警信息:${"无线检测相对检测值为:" + res.minValue + "-" + res.maxValue + ",实际值为:" + res.alarmValue}</label>
</p>
<p style="margin-top: 13px;">
<label>告警原因</label>
<input type="text" name="alarmReason" id="alarmReason" style="width: 70%;">
</p>
<p style="margin-top: 13px;">
<label>处理方式</label>
<input type="text" name="disposeMode" id="disposeMode" style="width: 70%;">
</p>
</div>`
Dialog({
title: "告警处理",
width: 600,
content: html,
ok: {
callback: function () {
let formData = new FormData();
formData.append("alarmuid", res.alarmuid);
formData.append("disposeMode", $("#disposeMode").val());
formData.append("alarmReason", $("#alarmReason").val());
$.post("/iot/wisdomScenario/disposeAlarm",
{
alarmuid: res.alarmuid,
disposeMode: $("#disposeMode").val(),
alarmReason: $("#alarmReason").val()
},
function (data, status) {
alert(+status.includes("succ") ? "告警处理成功" : "告警处理失败");
alarmInfo();
});
}
}
});
}
</script>
<script type="text/javascript">
@ -372,7 +427,7 @@
e += '<span style="border:1px solid red;background-color:#2E2F44;border-radius:5px;margin-left: 5%">&nbsp;&nbsp;异常&nbsp;&nbsp;</span>';
break
}
e += '</div><div style="text-align:center;" onclick="window.location = ' + '\'' + datas[j].unitUrl +'\'"><img src="' + datas[j].monitorunitImage + '" display="inline-block" vertical-align="middle" width="70%" ></div></li>';
e += '</div><div style="text-align:center;" onclick="window.location = ' + '\'' + datas[j].unitUrl + '\'"><img src="' + datas[j].monitorunitImage + '" display="inline-block" vertical-align="middle" width="70%" ></div></li>';
ul.append(e);
}
} else { // 当超过一页时
@ -401,12 +456,6 @@
console.log("异常:" + e)
}
})
}
function unitOnclick(e) {
alert(e);
}
//绘制页码
@ -480,5 +529,14 @@
}
}
</script>
<style type="text/css">
.mini-dialog-footer {
text-align: right;
height: 34px;
padding: 1px 0;
border-top: #e6e6e6 solid 1px;
}
</style>
</body>
</html>

@ -20,6 +20,8 @@ public class RecordAlarm extends BaseEntity
@Excel(name = "传感器")
private String sensorId;
private String alarmuid;
/** 报警类型 */
@Excel(name = "报警类型")
private String alarmtypeId;
@ -128,6 +130,14 @@ public class RecordAlarm extends BaseEntity
this.alarmReason = alarmReason;
}
public String getAlarmuid() {
return alarmuid;
}
public void setAlarmuid(String alarmuid) {
this.alarmuid = alarmuid;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)

@ -7,6 +7,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<resultMap type="RecordAlarm" id="RecordAlarmResult">
<result property="sensorId" column="Sensor_Id" />
<result property="alarmtypeId" column="AlarmType_Id" />
<result property="alarmuid" column="Alarm_Uid" />
<result property="minValue" column="Min_Value" />
<result property="alarmValue" column="Alarm_Value" />
<result property="maxValue" column="Max_Value" />
@ -19,6 +20,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<resultMap type="RecordAlarmDto" id="RecordAlarmDtoResult">
<result property="sensorId" column="Sensor_Id" />
<result property="alarmtypeId" column="AlarmType_Id" />
<result property="alarmuid" column="Alarm_Uid" />
<result property="minValue" column="Min_Value" />
<result property="alarmValue" column="Alarm_Value" />
<result property="maxValue" column="Max_Value" />
@ -35,7 +37,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap>
<sql id="selectRecordAlarmVo">
select Sensor_Id, AlarmType_Id, Min_Value, Alarm_Value, Max_Value,Dispose_Flag, Collect_Time,Dispose_Mode,Alarm_Reason from record_alarm
select Sensor_Id, AlarmType_Id, Min_Value, Alarm_Value,Alarm_Uid, Max_Value,Dispose_Flag, Collect_Time,Dispose_Mode,Alarm_Reason from record_alarm
</sql>
<select id="selectRecordAlarmList" parameterType="RecordAlarm" resultMap="RecordAlarmResult">
@ -52,7 +54,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectRecordAlarmBySensorId" parameterType="String" resultMap="RecordAlarmResult">
<include refid="selectRecordAlarmVo"/>
where Sensor_Id = #{sensorId}
where Alarm_Uid = #{alarmuid}
</select>
<insert id="insertRecordAlarm" parameterType="RecordAlarm">
@ -82,25 +84,26 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<update id="updateRecordAlarm" parameterType="RecordAlarm">
update record_alarm
<trim prefix="SET" suffixOverrides=",">
<if test="alarmtypeId != null">AlarmType_Id = #{alarmtypeId},</if>
<!--<if test="alarmtypeId != null">AlarmType_Id = #{alarmtypeId},</if>
<if test="minValue != null">Min_Value = #{minValue},</if>
<if test="alarmValue != null">Alarm_Value = #{alarmValue},</if>
<if test="maxValue != null">Max_Value = #{maxValue},</if>
<if test="collectTime != null">Collect_Time = #{collectTime},</if>
<if test="collectTime != null">Collect_Time = #{collectTime},</if>-->
<if test="disposeFlag != null">Dispose_Flag = #{disposeFlag},</if>
<if test="disposeMode != null">Dispose_Mode = #{disposeMode},</if>
<if test="alarmReason != null">Alarm_Reason = #{alarmReason},</if>
</trim>
where Sensor_Id = #{sensorId}
where Alarm_Uid = #{alarmuid}
</update>
<delete id="deleteRecordAlarmBySensorId" parameterType="String">
delete from record_alarm where Sensor_Id = #{sensorId}
delete from record_alarm where Alarm_Uid = #{alarmuid}
</delete>
<delete id="deleteRecordAlarmBySensorIds" parameterType="String">
delete from record_alarm where Sensor_Id in
delete from record_alarm where Alarm_Uid in
<foreach item="sensorId" collection="array" open="(" separator="," close=")">
#{sensorId}
#{alarmuid}
</foreach>
</delete>
@ -111,6 +114,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
t3.Sensor_Name,
t4.Min_Value,
t4.Max_Value,
t4.Alarm_Uid,
t4.Alarm_Value,
t4.Collect_Time,
t4.Dispose_Flag

Loading…
Cancel
Save