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,8 +103,9 @@ 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);
@ -118,6 +113,7 @@ public class WisdomScenarioContorller extends BaseController {
/**
*
*
* @author WenJY
* @date 2022/3/26 20:51
* @param monitorUnitId
@ -125,23 +121,27 @@ public class WisdomScenarioContorller extends BaseController {
*/
@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;
}
}

@ -13,7 +13,28 @@
<link th:href="@{/css/fontawesome/all.min.css}" rel="stylesheet"/>
<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,14 +49,32 @@
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>
<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;
@ -45,33 +84,57 @@
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;">
<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>
</header>
<div class="nav nav-tabs tab-group" id="tab-group">
<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>
</div>
<iframe id="main-display-frame"></iframe>
<!-- 全局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">
</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:src="@{/js/Iot-ui/MiniDialog-es5.min.js}"></script>
<script th:inline="javascript">
const pages = [[${menuInfo.url}]];
@ -82,6 +145,7 @@
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') {
@ -108,7 +172,7 @@
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>`
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)) {
@ -153,6 +217,7 @@
$(() => {
queuingMenu.select(0, -1)
// queuingMenu.select(1, 1)
})
function resize() {
@ -163,29 +228,109 @@
$(() => {
resize()
})
</script>
</script>
<script type="text/javascript">
<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);
function userInfoOnclick() {
location.href = '/indexInfo/index';
}
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);
}*/
const getAlarmWindow = function () {
$.ajax({
url: "/iot/wisdomScenario/getAlarmWindow",
type: "get",
dataType: 'JSON',
async: false,
success: (res) => {
if (res.length > 0) {
$("#alarmWindow").html("");
function userInfoOnclick() {
location.href = '/indexInfo/index';
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 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);
})
}
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 () {
$.post("/iot/wisdomScenario/disposeAlarm",
{
alarmuid: res.alarmuid,
disposeMode: $("#disposeMode").val(),
alarmReason: $("#alarmReason").val()
},
function (data, status) {
// alert(+status.includes("succ") ? "告警处理成功" : "告警处理失败");
});
}
}
</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