change - 全局告警弹窗

main
wenjy 3 years ago
parent 68704a67b6
commit ff5657888c

@ -3,18 +3,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.*;
import com.ruoyi.system.domain.dto.BaseAlarmModuleDto;
import com.ruoyi.system.domain.dto.BaseMonitorunitInfoDto;
import com.ruoyi.system.domain.dto.BaseSensorInfoDto;
import com.ruoyi.system.domain.dto.RecordAlarmDto;
import com.ruoyi.system.service.IBaseAlarmModuleService;
import com.ruoyi.system.service.IBaseMonitorunitInfoService;
import com.ruoyi.system.service.IBaseSensorInfoService;
import com.ruoyi.system.service.IRecordAlarmService;
import com.ruoyi.system.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
@ -37,15 +31,15 @@ import java.util.stream.Stream;
@RequestMapping("/iot/wisdomScenario")
public class WisdomScenarioContorller extends BaseController {
@Autowired private IBaseMonitorunitTypeService baseMonitorunitTypeService;
@Autowired private IBaseMonitorunitInfoService baseMonitorunitInfoService;
@Autowired private IBaseSensorInfoService baseSensorInfoService;
@Autowired
private IBaseAlarmModuleService baseAlarmModuleService;
@Autowired private IBaseAlarmModuleService baseAlarmModuleService;
@Autowired
private IRecordAlarmService recordAlarmService;
@Autowired private IRecordAlarmService recordAlarmService;
/**
* :
@ -109,39 +103,45 @@ public class WisdomScenarioContorller extends BaseController {
&& x.getEnableFlag() == 0L
&& x.getMonitorunitType().equals(monitorUnitType))
.collect(Collectors.toList());
collect.forEach(x->{
x.setUnitUrl("/sections/transformer-detail?id="+x.getMonitorunitId());
});
collect.forEach(
x -> {
x.setUnitUrl("/sections/transformer-detail?id=" + x.getMonitorunitId());
});
return JSONArray.toJSONString(collect);
}
/**
*
*
* @author WenJY
* @date 2022/3/26 20:51
* @param monitorUnitId
* @param monitorUnitId
* @return java.lang.String
*/
@GetMapping("/getAlarmModule")
@ResponseBody
public String getAlarmModule(String monitorUnitId){
public String getAlarmModule(String monitorUnitId) {
List<BaseAlarmModuleDto> baseAlarmModuleDtos = baseAlarmModuleService.selectAlarmModuleAmountList(new BaseAlarmModule(monitorUnitId));
List<BaseAlarmModuleDto> baseAlarmModuleDtos =
baseAlarmModuleService.selectAlarmModuleAmountList(new BaseAlarmModule(monitorUnitId));
if(baseAlarmModuleDtos.size() < 6){
if (baseAlarmModuleDtos.size() < 6) {
List<BaseAlarmModuleDto> info = new ArrayList<>();
for (int i = 0;i<6-baseAlarmModuleDtos.size();i++){
for (int i = 0; i < 6 - baseAlarmModuleDtos.size(); i++) {
BaseAlarmModuleDto baseAlarmModuleDto = new BaseAlarmModuleDto();
baseAlarmModuleDto.setAlarmmoduleText("----");
baseAlarmModuleDto.setAlarmModuleAmount("-");
baseAlarmModuleDto.setOrderFlag(new Long((baseAlarmModuleDtos.size())+i+1));
baseAlarmModuleDto.setOrderFlag(new Long((baseAlarmModuleDtos.size()) + i + 1));
info.add(baseAlarmModuleDto);
}
baseAlarmModuleDtos.addAll(baseAlarmModuleDtos.size(),info);
baseAlarmModuleDtos.addAll(baseAlarmModuleDtos.size(), info);
}
List<BaseAlarmModuleDto> collect = baseAlarmModuleDtos.stream().sorted(Comparator.comparing(BaseAlarmModuleDto::getOrderFlag)).collect(Collectors.toList());
List<BaseAlarmModuleDto> collect =
baseAlarmModuleDtos.stream()
.sorted(Comparator.comparing(BaseAlarmModuleDto::getOrderFlag))
.collect(Collectors.toList());
String result = JSONArray.toJSONString(collect);
@ -150,6 +150,7 @@ public class WisdomScenarioContorller extends BaseController {
/**
*
*
* @author WenJY
* @date 2022/3/27 11:36
* @param monitorUnitId
@ -157,15 +158,14 @@ public class WisdomScenarioContorller extends BaseController {
*/
@GetMapping("/getAlarmInfo")
@ResponseBody
public String getAlarmInfo(String monitorUnitId){
public String getAlarmInfo(String monitorUnitId) {
if(!monitorUnitId.isEmpty()){
if (!monitorUnitId.isEmpty()) {
List<RecordAlarmDto> recordAlarmDtos = recordAlarmService.selectAlarmInfoList(monitorUnitId);
String s = JSONArray.toJSONString(recordAlarmDtos);
return s;
}
return null;
@ -173,16 +173,46 @@ public class WisdomScenarioContorller extends BaseController {
@GetMapping("/getAlarmByUid")
@ResponseBody
public String getAlarmByUid(String alarmuid){
public String getAlarmByUid(String alarmuid) {
RecordAlarm recordAlarm = recordAlarmService.selectRecordAlarmBySensorId(alarmuid);
return JSONArray.toJSONString(recordAlarm);
}
@PostMapping("/disposeAlarm")
@ResponseBody
public AjaxResult disposeAlarm(RecordAlarm recordAlarm){
public AjaxResult disposeAlarm(RecordAlarm recordAlarm) {
recordAlarm.setDisposeFlag(1L);
return toAjax(recordAlarmService.updateRecordAlarm(recordAlarm));
}
/**
*
* @author WenJY
* @date 2022/4/7 15:20
* @return java.lang.String
*/
@GetMapping("/getAlarmWindow")
@ResponseBody
public String getAlarmWindow() {
List<RecordAlarmDto> result = new ArrayList<RecordAlarmDto>();
List<BaseMonitorunitType> baseMonitorunitTypes =
baseMonitorunitTypeService.selectBaseMonitorunitTypeList(new BaseMonitorunitType());
baseMonitorunitTypes.forEach(
x -> {
List<RecordAlarmDto> recordAlarmDtos =
recordAlarmService.selectAlarmInfoList(x.getMonitorunittypeId());
result.addAll(
result.size(),
recordAlarmDtos.stream()
.filter(f -> f.getDisposeFlag() == 0L)
.collect(Collectors.toList()));
});
String s = JSONArray.toJSONString(result);
return s;
}
}

@ -1,19 +1,40 @@
<!DOCTYPE html>
<html lang="zh-cn" xmlns:th="http://www.thymeleaf.org">
<html lang="zh-cn" xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="renderer" content="webkit">
<title>智慧物联监控平台</title>
<!-- 避免IE使用兼容模式 -->
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<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"/>
<link th:href="@{/css/jquery.contextMenu.min.css}" rel="stylesheet"/>
<link th:href="@{/css/fontawesome/all.min.css}" rel="stylesheet"/>
<link rel="stylesheet" th:href="@{/css/main.css}"/>
<link rel="stylesheet" th:href="@{/css/main.css}"/>
<link rel="stylesheet" th:href="@{/css/autoscroll-table.css}"/>
<link th:href="@{/css/animate.css}" rel="stylesheet"/>
<link th:href="@{/css/style.css}" rel="stylesheet"/>
<link th:href="@{/css/skins.css}" rel="stylesheet"/>
<link th:href="@{/ruoyi/css/ry-ui.css?v=4.3.1}" rel="stylesheet"/>
<style type="text/css">
* {
padding: 0px;
margin: 0px;
font-family: "微软雅黑";
}
.tipfloat {
display: none;
z-index: 999;
border: 0px #8e9cde solid;
position: absolute;
bottom: 0px;
right: 17px;
width: 268px;
height: auto;
}
</style>
<style>
#tab-group {
position: absolute;
@ -28,164 +49,288 @@
height: 87%;
}
div::-webkit-scrollbar {
/*滚动条整体样式*/
width: 5px;
/*高宽分别对应横竖滚动条的尺寸*/
height: 1px;
}
div::-webkit-scrollbar-thumb {
/*滚动条里面小方块*/
border-radius: 10px;
-webkit-box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
background: #004EA1;
}
div::-webkit-scrollbar-track {
/*滚动条里面轨道*/
-webkit-box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
border-radius: 10px;
background: white;
}
</style>
</head>
<body class="body-bg-1">
<header>
<div class="btn-group section-button-area" id="section-buttons">
<!--<button class="btn section-button">监控主页</button>
<button class="btn section-button">智慧线路</button>
<button class="btn section-button">分类监测</button>-->
</div>
<div class="main-title">智慧物联监控平台</div>
<div style="position: absolute;
<header>
<div class="btn-group section-button-area" id="section-buttons">
</div>
<div class="main-title">智慧物联监控平台</div>
<div style="position: absolute;
border: 0px solid red;
width: 28%;
height: 5%;
top: 3%;
right: 2.7%;">
<div style="position: absolute;width: 10%;height:100%;right:15%;border: 0px solid yellow;">
<img onclick="userInfoOnclick()" th:src="(${#strings.isEmpty(user.avatar)}) ? @{/img/userInfo.png} : @{${user.avatar}}" th:onerror="this.src='img/userInfo.png'" alt="User Image" title="用户信息" style="height:80%;width:80%;cursor: pointer;">
</div>
<div style="position: absolute;width: 10%;height:100%;right:5%;border: 0px solid yellow;">
<a th:href="@{logout}" style="padding-left:5px;" title="注销"><i class="fa fa-sign-out text-danger"></i> </a>
</div>
<div style="position: absolute;width: 10%;height:100%;right:15%;border: 0px solid yellow;">
<img onclick="userInfoOnclick()"
th:src="(${#strings.isEmpty(user.avatar)}) ? @{/img/userInfo.png} : @{${user.avatar}}"
th:onerror="this.src='img/userInfo.png'" alt="User Image" title="用户信息"
style="height:80%;width:80%;cursor: pointer;">
</div>
<div style="position: absolute;width: 10%;height:100%;right:5%;border: 0px solid yellow;">
<a th:href="@{logout}" style="padding-left:5px;" title="注销"><i class="fa fa-sign-out text-danger"></i> </a>
</div>
</div>
</header>
<div class="nav nav-tabs tab-group" id="tab-group">
<button class="btn tab-group-item">正在加载<i class="fa-solid fa-times close-btn"></i></button>
<button class="btn tab-group-item">正在加载<i class="fa-solid fa-times close-btn"></i></button>
<button class="btn tab-group-item">正在加载<i class="fa-solid fa-times close-btn"></i></button>
<button class="btn tab-group-item">正在加载<i class="fa-solid fa-times close-btn"></i></button>
<button class="btn tab-group-item">正在加载<i class="fa-solid fa-times close-btn"></i></button>
</div>
<iframe id="main-display-frame"></iframe>
<div>
<!--弹出信息 右下角-->
<div class="tipfloat" data-num="3" style="background-color: #083E70;color:white">
<div class="modal-header" style="border-color: #1FACF4">
<h2 class="modal-title">告警提示</h2>
<input type="hidden" id="alarmuid" name="alarmuid">
</div>
<div class="modal-body" id="alarmWindow" style="height:170px;overflow-y:auto;border-color: red"></div>
<div class="modal-footer" style="border-color: #1FACF4">
<button type="button" onclick="closeButton()" data-dismiss="modal"
style="color: black;height: 40px;width: 100px;border-radius: 5px">关闭
</button>
<button type="button" onclick="alarmDispose()"
style="height: 40px;width: 100px;background-color: #1AB394;border-radius: 5px">处理
</button>
</div>
</header>
<div class="nav nav-tabs tab-group" id="tab-group">
<button class="btn tab-group-item">正在加载<i class="fa-solid fa-times close-btn"></i></button>
<button class="btn tab-group-item">正在加载<i class="fa-solid fa-times close-btn"></i></button>
<button class="btn tab-group-item">正在加载<i class="fa-solid fa-times close-btn"></i></button>
<button class="btn tab-group-item">正在加载<i class="fa-solid fa-times close-btn"></i></button>
<button class="btn tab-group-item">正在加载<i class="fa-solid fa-times close-btn"></i></button>
</div>
<iframe id="main-display-frame"></iframe>
</div>
<!-- 全局js -->
<script th:src="@{/js/jquery.min.js}"></script>
<script th:src="@{/js/bootstrap.bundle.min.js}"></script>
<script th:src="@{/js/fontawesome/all.min.js}"></script>
<script th:src="@{/js/autoscroll-table.js}"></script>
<script th:src="@{/js/auto-update.js}"></script>
<script th:src="@{/js/font-adjust.js}"></script>
<th:block th:include="include :: echarts-js" />
<script th:src="@{/js/queuing-menu.js}"></script>
<script th:inline="javascript">
<!-- 全局js -->
<script th:src="@{/js/jquery.min.js}"></script>
<script th:src="@{/js/bootstrap.bundle.min.js}"></script>
<script th:src="@{/js/fontawesome/all.min.js}"></script>
<script th:src="@{/js/autoscroll-table.js}"></script>
<script th:src="@{/js/auto-update.js}"></script>
<script th:src="@{/js/font-adjust.js}"></script>
<th:block th:include="include :: echarts-js"/>
<script th:src="@{/js/queuing-menu.js}"></script>
<script th:src="@{/js/Iot-ui/MiniDialog-es5.min.js}"></script>
<script th:inline="javascript">
const pages = [[${menuInfo.url}]];
const pages = [[${menuInfo.url}]];
const menuStr = [[${menuInfo.menuStr}]];
const menuStr = [[${menuInfo.menuStr}]];
const mainFrame = document.getElementById("main-display-frame")
const mainFrame = document.getElementById("main-display-frame")
function switchPage(index, subIndex) {
mainFrame.setAttribute("src", subIndex === -1 ? pages[index] : pages[index][subIndex])
}
function searchPageByPath(pathName) {
for (let entry1 of Object.entries(pages)) {
if (typeof entry1[1] === 'string') {
if (pathName === entry1[1]) {
return [entry1[0], -1]
}
} else {
for (let entry2 of Object.entries(entry1[1])) {
if (pathName === entry2[0]) {
return [entry1[0], entry2[0]]
}
function switchPage(index, subIndex) {
mainFrame.setAttribute("src", subIndex === -1 ? pages[index] : pages[index][subIndex])
}
function searchPageByPath(pathName) {
for (let entry1 of Object.entries(pages)) {
if (typeof entry1[1] === 'string') {
if (pathName === entry1[1]) {
return [entry1[0], -1]
}
} else {
for (let entry2 of Object.entries(entry1[1])) {
if (pathName === entry2[0]) {
return [entry1[0], entry2[0]]
}
}
}
return [-1, -1]
}
const queuingMenu = new QueuingMenu(
document.getElementById("section-buttons"),
document.getElementById("tab-group"),
menuStr,
{
onRenderMenuItem(parent, index, menuName, submenuNames) {
let html = ''
html += `<button class="btn section-button ${submenuNames.length > 0 ? "dropdown-toggle": ""}" id="section-${index}" data-bs-toggle="dropdown" aria-expanded="false" ${submenuNames.length === 0 ? "onclick=\"queuingMenu.select(" + index + ", " + -1 + ")\"" : ""}>${menuName}</button>`
if (submenuNames.length > 0) {
html += `<ul class="dropdown-menu" aria-labelledby="section-${index}">`
for (let entry of Object.entries(submenuNames)) {
html += `<li><a class="dropdown-item" href="javascript:queuingMenu.select(${index}, ${entry[0]})">${entry[1]}</a></li>`
}
html += `</ul>`
}
return [-1, -1]
}
return html
},
onRenderQueueItem(parent, index, item) {
let info = `<button class="btn tab-group-item ${item.active ? "active" : ""}" id="queue-item-${index}">${item.name}<span class="close-btn"><i class="fa-solid fa-times"></i></span></button>`;
return info;
},
onLinkQueue(parent, queue) {
for (let index in queue) {
const el = parent.children[index]
el.addEventListener("click", evt => {
queuingMenu.switch(index)
})
el.querySelector(".close-btn").addEventListener("click", evt => {
queuingMenu.close(index, true)
})
const queuingMenu = new QueuingMenu(
document.getElementById("section-buttons"),
document.getElementById("tab-group"),
menuStr,
{
onRenderMenuItem(parent, index, menuName, submenuNames) {
let html = ''
html += `<button class="btn section-button ${submenuNames.length > 0 ? "dropdown-toggle" : ""}" id="section-${index}" data-bs-toggle="dropdown" aria-expanded="false" ${submenuNames.length === 0 ? "onclick=\"queuingMenu.select(" + index + ", " + -1 + ")\"" : ""}>${menuName}</button>`
if (submenuNames.length > 0) {
html += `<ul class="dropdown-menu" aria-labelledby="section-${index}">`
for (let entry of Object.entries(submenuNames)) {
html += `<li><a class="dropdown-item" href="javascript:queuingMenu.select(${index}, ${entry[0]})">${entry[1]}</a></li>`
}
},
onSwitch(queueParent, name, oldQueueIndex, queueIndex, menuIndex, menuSubIndex) {
switchPage(menuIndex, menuSubIndex)
},
html += `</ul>`
}
return html
},
)
mainFrame.addEventListener("load", ev => {
const path = mainFrame.contentWindow.location.pathname
const entry = searchPageByPath(path)
queuingMenu.select(entry[0], entry[1], {
defaultPageName: "新标签页",
dirtySwitch: true,
})
onRenderQueueItem(parent, index, item) {
let info = `<button class="btn tab-group-item ${item.active ? "active" : ""}" id="queue-item-${index}">${item.name}<span class="close-btn"><i class="fa-solid fa-times"></i></span></button>`;
return info;
},
onLinkQueue(parent, queue) {
for (let index in queue) {
const el = parent.children[index]
el.addEventListener("click", evt => {
queuingMenu.switch(index)
})
el.querySelector(".close-btn").addEventListener("click", evt => {
queuingMenu.close(index, true)
})
}
},
onSwitch(queueParent, name, oldQueueIndex, queueIndex, menuIndex, menuSubIndex) {
switchPage(menuIndex, menuSubIndex)
},
},
)
mainFrame.addEventListener("load", ev => {
const path = mainFrame.contentWindow.location.pathname
const entry = searchPageByPath(path)
queuingMenu.select(entry[0], entry[1], {
defaultPageName: "新标签页",
dirtySwitch: true,
})
})
$(() => {
queuingMenu.select(0, -1)
// queuingMenu.select(1, 1)
$(() => {
queuingMenu.select(0, -1)
// queuingMenu.select(1, 1)
})
function resize() {
fontAdjust()
}
window.onresize = resize
$(() => {
resize()
})
</script>
<script type="text/javascript">
function userInfoOnclick() {
location.href = '/indexInfo/index';
}
const getAlarmWindow = function () {
$.ajax({
url: "/iot/wisdomScenario/getAlarmWindow",
type: "get",
dataType: 'JSON',
async: false,
success: (res) => {
if (res.length > 0) {
$("#alarmWindow").html("");
let html = `<h3>告警位置: ${res[0].sensorLocation}</h3>
<h3>告警时间: ${res[0].collectTime}</h3>
<h3>告警信息: ${"无线检测 相对检测值为:" + res[0].minValue + "-" + res[0].maxValue + ",其值为:" + res[0].alarmValue}</h3>`
$("#alarmWindow").append(html);
$("#alarmuid").val(res[0].alarmuid);
showToggle();
}
},
error: () => {
console.log("失败");
}
})
}
setInterval(`getAlarmWindow()`, 1000 * 20);
const showToggle = function () {
$(".tipfloat").animate({height: "show"}, 800);
setTimeout(`$(".tipfloat").animate({height: "hide"}, 800)`, 8000);
}
function resize() {
fontAdjust()
}
window.onresize = resize
$(() => {
resize()
function closeButton() {
$(".tipfloat").animate({height: "hide"}, 800);
}
function closeIcon() {
$(".tipfloat").animate({height: "hide"}, 800);
}
const alarmDispose = function () {
$.getJSON('/iot/wisdomScenario/getAlarmByUid?alarmuid=' + $("#alarmuid").val(), function (result) {
alarmDisposeInfo(result);
})
</script>
<script type="text/javascript">
}
/*function myClick(hre) {
let num = new Object;
num.cp_keynum = "wisdmoScenario_Key";
num.cp_num_value = hre;
var str = JSON.stringify(num); // 将对象转换为字符串
localStorage.setItem(num.cp_keynum, str);
}
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>`
function buttonClick(href) {
let num = new Object;
num.cp_keynum = "wisdmoScenario_Key";
num.cp_num_value = href.innerText;
var str = JSON.stringify(num); // 将对象转换为字符串
localStorage.setItem(num.cp_keynum, str);
}*/
Dialog({
title: "告警处理",
width: 600,
content: html,
ok: {
callback: function () {
$.post("/iot/wisdomScenario/disposeAlarm",
{
alarmuid: res.alarmuid,
disposeMode: $("#disposeMode").val(),
alarmReason: $("#alarmReason").val()
},
function (data, status) {
// alert(+status.includes("succ") ? "告警处理成功" : "告警处理失败");
});
}
}
});
}
function userInfoOnclick() {
location.href = '/indexInfo/index';
}
</script>
</script>
</body>
<style type="text/css">
.mini-dialog-footer {
text-align: right;
height: 34px;
padding: 1px 0;
border-top: #e6e6e6 solid 1px;
}
</style>
</html>

@ -396,11 +396,6 @@
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,

@ -122,7 +122,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
left join base_monitorunit_info t2 on t2.MonitorUnit_Type = t1.MonitorUnit_Id
left join base_sensor_info t3 on t2.MonitorUnit_Id = t3.MonitorUnit_Id
left join record_alarm t4 on t3.Sensor_Id = t4.Sensor_Id and t1.AlarmType_Id = t4.AlarmType_Id
where t1.MonitorUnit_Id = #{monitorUnitTypeId} and t4.Collect_Time is not null
where t1.MonitorUnit_Id = #{monitorUnitTypeId} and t4.Collect_Time between DATE_FORMAT(DATE_SUB(CURDATE(), INTERVAL 30 DAY), '%Y-%m-%d 00:00:00') and DATE_FORMAT(now(), '%Y-%m-%d 23:59:59')
and t4.Collect_Time is not null
</select>
<select id="selectAlarmTrendList" parameterType="String" resultMap="RecordAlarmDtoResult">

Loading…
Cancel
Save