Преглед изворни кода

提交:未及时处理预计处理

唐渝林 пре 10 месеци
родитељ
комит
20a8428299

+ 4 - 0
PMS.WebUI/Controllers/CloudMonitorController.cs

@@ -116,6 +116,10 @@ namespace PMS.WebUI.Controllers
         /// <returns></returns>
         public ActionResult UnprocessedEarlyWarningManagementIndex()
         {
+            var cloudMonitorConfig = _cloudMonitor.GetCloudMonitorConfig();
+            var config = cloudMonitorConfig?.AlertConfig;
+            if (config == null) config = new AlertConfig();
+            ViewBag.Model = config;
             return View();
         }
 

+ 10 - 1
PMS.WebUI/ViewModels/EarlyWarningManagementIndex.js

@@ -99,7 +99,16 @@
 
         //未及时处理预警
         $("#notTimely").bind("click", function () {
-            InitTable(true);
+            top.ZLPMS.OpenWindowSuccess({
+                title: '未及时处理预警查看',
+                url: '/CloudMonitor/UnprocessedEarlyWarningManagementIndex',
+                area: ['90vw', '90vh'],
+                success: function (layero) {
+                    var iframeWin = ZLPMS.GetChildFrame(layero);//得到iframe页的窗口对象,执行iframe页的方法:
+                },
+                yes: function (index, layero) {
+                }
+            });
         })
 
         //渠道

+ 73 - 202
PMS.WebUI/ViewModels/UnprocessedEarlyWarningManagementIndex.js

@@ -1,195 +1,87 @@
 function viewModel() {
     this.ID = "";
     this.init = function () {
+        InitTable();
+    }
+};
 
-        //预警处理
-        $('#Handle').click(function () {
-            var row = $('#treegrid').datagrid('getSelected');
-            if (row != null) {
-                if (row.预警状态显示 === "已处理") {
-                    top.ZLPMS.Msg("当前预警已经处理完成", 0);
-                    return;
-                }
-                top.ZLPMS.OpenWindowSuccess({
-                    title: '预警处理',
-                    url: '/CloudMonitor/WarningProcessing',
-                    area: ['1000px', '570px'],
-                    success: function (layero) {
-                        var iframeWin = ZLPMS.GetChildFrame(layero);//得到iframe页的窗口对象,执行iframe页的方法:
-                        iframeWin.InitPage(row);
-                    },
-                    yes: function (index, layero) {
-                        //提交表单
-                        Forms.Submit(index, layero);
-                    }
-                });
-            }
-            else {
-                top.ZLPMS.Msg("请选择一行记录后执行操作", 0);
-            }
-        });
-
-        //批量预警处理
-        $('#HandleAll').click(function () {
-            top.ZLPMS.OpenWindowSuccess({
-                title: '批量处理',
-                url: '/CloudMonitor/BatchWarningProcessing?ProId=' + (window.proId||""),
-                area: ['1000px', '570px'],
-                success: function (layero) {
-                    var iframeWin = ZLPMS.GetChildFrame(layero);//得到iframe页的窗口对象,执行iframe页的方法:
-                    iframeWin.InitPage();
-                },
-                yes: function (index, layero) {
-                    //提交表单
-                    Forms.Submit(index, layero);
-                }
-            });
-        });
-
-        /**查看服务器 */
-        $('#ViewServer').click(function () {
-            var row = $('#treegrid').datagrid('getSelected');
-            if (row != null) {
-                if (row.服务器ID == null) {
-                    return;
-                }
-                top.ZLPMS.OpenWindowSuccess({
-                    title: '预警处理',
-                    url: '/CloudMonitor/ServerInfo?serverId='+row.服务器ID,
-                    area: ['1500px', '650px'],
-                    success: function (layero) {
-                       
-                    },
-                    yes: function (index, layero) {
-                    }
-                });
-            }
-            else {
-                top.ZLPMS.Msg("请选择一行记录后执行操作", 0);
-            }
-        });
+function InitTable() {
+    var params = {};
+    params.WCLZT = "红色,橙色";
+    params.ZT = 1;
+
+    //提交表单信息到具体得页面
+    var url = '/CloudMonitor/GetServerAlertBySearch';
+    $.post(url, params, function (data) {
+        const result = separateByWorkHours(data);
+        LoadTable($("#treegrid1"), result.workHoursData.sort((a, b) => {
+            // 将时间字符串转换为 Date 对象
+            const dateA = new Date(a["创建时间"]);
+            const dateB = new Date(b["创建时间"]);
+
+            // 进行倒序排序
+            return dateB - dateA;
+        }));
+        LoadTable($("#treegrid2"), result.offWorkHoursData.sort((a, b) => {
+            // 将时间字符串转换为 Date 对象
+            const dateA = new Date(a["创建时间"]);
+            const dateB = new Date(b["创建时间"]);
+
+            // 进行倒序排序
+            return dateB - dateA;
+        }));
+    });
+    
+    
+}
 
-        //更多条件
-        $("#btn-more").bind("click", function () {
-            var that = this;
-            //多窗口模式,层叠置顶
-            index = layer.open({
-                type: 1
-                , id: "one"
-                , title: '条件'
-                , area: ['800px', '250px']
-                , shade: 0
-                , anim: 1
-                , shadeClose: true
-                , maxmin: true
-                , shade: 0.3
-                , offset: '50px'
-                , content: $("#inteform")
-                , btn: ['确认', '关闭']
-                , yes: function () {
-                    InitTable();
-                    layer.close(index);
-                }
-                , btn2: function () {
-                    layer.close(index);
-                }
-                , zIndex: 1 //重点1
-            });
-        })
+function gethours(dateStr) {
+    // 以 "HH:MM:SS" 格式处理时间字符串
+    const [hours, minutes, seconds] = dateStr.split(':').map(Number);
+    return hours;
+}
 
-        //未及时处理预警
-        $("#notTimely").bind("click", function () {
-            InitTable(true);
-        })
+function isWithinWorkHours(dateStr, workStartHour, workEndHour) {
+    const date = new Date(dateStr);
+    const hours = date.getHours();
+    // 判断时间是否在工作时间内
+    return (hours > workStartHour && hours < workEndHour);
+}
 
-        //渠道
-        $("#QDID").combobox({
-            url: '/Problem/GetChannelByAuth',
-            valueField: 'ID',
-            textField: '名称',
-            limitToList: true,
-            onChange: function (value) {
-                $("#XMID").combobox({
-                    url: '/PersonManager/GetProject?id=' + value,
-                    valueField: 'ID',
-                    textField: '名称',
-                    limitToList: true,
-                })
+function separateByWorkHours(data) {
+    const workHoursData = [];
+    const offWorkHoursData = [];
+    try {
+        // 定义工作时间的开始和结束时间
+        const workStartHour = gethours(window.starTime);
+        const workEndHour = gethours(window.endTime);
+        data.forEach(item => {
+            if (isWithinWorkHours(item["创建时间"], workStartHour, workEndHour)) {
+                workHoursData.push(item);
+            } else {
+                offWorkHoursData.push(item);
             }
-        })
-
-        //项目
-        $("#XMID").combobox({
-            url: '/Problem/GetProjectByInfo',
-            valueField: 'ID',
-            textField: '名称',
-            limitToList: true,
-        })
-
-        //预警类型
-        $("#YJLXID").combobox({
-            url: '/ProManager/GetEarlyWarningType',
-            valueField: 'ID',
-            textField: '显示名',
-            limitToList: true
-        })
-
-        //状态
-        $("#ZT").combobox({
-            url: '/ProManager/GetWarningProcessingStatu',
-            valueField: 'ID',
-            textField: '显示名',
-            limitToList: true,
-            value:1
-        })
-
-        //处理详情点击
-        $("#timeline").on("click", ".timelineDetail", function () {
-            let Id = $(this).attr("data-Id");
-            var row = $('#treegrid').datagrid('getSelected');
-            let timelineRow = timeline.find(o => o.ID == Id);
-            top.ZLPMS.OpenWindowSuccess({
-                title: '预警处理情况',
-                url: '/CloudMonitor/WarningProcessing',
-                area: ['1000px', '570px'],
-                success: function (layero) {
-                    var iframeWin = ZLPMS.GetChildFrame(layero);//得到iframe页的窗口对象,执行iframe页的方法:
-                    iframeWin.InitPage(row, timelineRow);
-                },
-                yes: function (index, layero) {
-                    top.ZLPMS.CloseWindow(index);
-                }
-            });
-        })
-
+        });
 
-        InitTable();
+        return {
+            workHoursData,
+            offWorkHoursData
+        };
+    } catch (e) {
+        top.ZLPMS.Msg("当前工作时间定义获取失败");
+        return {
+            workHoursData:[],
+            offWorkHoursData: []
+        };
     }
-};
+}
 
-let timeline = [];
 
-function InitTable(notTimely = false) {
-    var params = ZLPMS.FormToObject('inteform');
-    if (notTimely) {
-        params.WCLZT = "红色,橙色";
-    }
-    if (window.proId != null && window.proId != 'null') {
-        params.XMID = window.proId;
-        //处理界面显示
-        $("#userAccount").remove();
-        $("#btn-more").css("display", "none");
-        $("#notTimely").css("display", "none");
-    } else {
-        params.CONTENT = $("#userAccount").val();
-    }
+function LoadTable(ele, data) {
     //初始化树形表格
-    $("#treegrid").datagrid({
-        url: '/CloudMonitor/GetServerAlertBySearch',
+    ele.datagrid({
         idField: 'ID',
-        queryParams: params,
-        //data: data,
-        method: 'POST',
+        data: data,
         fit: true,
         pageSize: 0,
         toolbar: window.proId != null ? "" : "#Channeltb",
@@ -232,13 +124,13 @@ function InitTable(notTimely = false) {
                         }
                     }
                     return `<div class="${className}">${value}</div>`;
-                } },
+                }
+            },
             { field: '处理时间', title: '处理时间', width: 150, align: 'center', formatter: ZLPMS.formatterData }
         ]],
         singleSelect: true,
         onClickRow: function (index, row) {
-            if (row.预警状态 !=1)
-                Loading(row.ID);
+
         },
         onSelectAll: function (rows) {
         }
@@ -310,27 +202,6 @@ var Doajax = function (data) {
     });
 }
 
-//加载时间轴
-function Loading(alertId) {
-    if (!alertId) {
-        return;
-    }
-    if ($("#processPanel").css("display") !="block")
-        $(".panel-header").click()
-    timeline = ZLPMS.GetAPi(`/CloudMonitor/GetServerAlertProcessByAlertId?alertId=${alertId}`);
-    $("#timeline").html("");
-    let html = "";
-    for (var i = 0; i < timeline.length; i++) {
-        let d = timeline[i];
-        html += "<li class='layui-timeline-item timelineDetail' data-Id='" + d.ID + "'><i class='layui-icon layui-timeline-axis'>&#xe617;</i><div class='layui-timeline-content layui-text'><h3 class='layui-timeline-title'> <span style='margin-right:15px'>"
-            + (d.处理人 == null ? "" : d.处理人) + "</span><span  style='margin-right:15px;color:#00b8ff'>"
-            + d.处理状态显示 + "</span><span style='margin-right:15px;color:#a2a2a2'>"
-            + d.创建时间 + "</span></h3><p style='font-size:15px;width:350px;word-break: break-word;color:#a2a2a2'><br>"
-            + (d.处理说明 == null ? "" : d.处理说明) + "</p></div></li>";
-    }
-    $("#timeline").html(html);
-}
-
 
 //回车提交查询
 function Enter_Submit() {

+ 8 - 2
PMS.WebUI/Views/CloudMonitor/EarlyWarningConfigIndex.cshtml

@@ -245,7 +245,7 @@
                                         <label class="layui-form-label" style="width: auto;">工作开始时间</label>
                                         <div class="layui-input-inline" style="width: 100px;">
                                             <div class="layui-input-wrap">
-                                                <input type="time" name="工作开始时间" value="@config.工作开始时间" placeholder="" autocomplete="off" class="layui-input" min="0" step="1" lay-affix="time">
+                                                <input type="time" name="工作开始时间" id="strTime" value="@config.工作开始时间" placeholder="" autocomplete="off" class="layui-input" min="0" step="1" lay-affix="time">
                                             </div>
                                         </div>
                                     </div>
@@ -253,7 +253,7 @@
                                         <label class="layui-form-label" style="width: auto;">未及时处理预警(红色)</label>
                                         <div class="layui-input-inline" style="width: 100px;">
                                             <div class="layui-input-wrap">
-                                                <input type="time" name="工作结束时间" value="@config.工作结束时间" placeholder="" autocomplete="off" class="layui-input" min="0" step="1" lay-affix="time">
+                                                <input type="time" name="工作结束时间" id="endTime" value="@config.工作结束时间" placeholder="" autocomplete="off" class="layui-input" min="0" step="1" lay-affix="time">
                                             </div>
                                         </div>
                                     </div>
@@ -325,6 +325,12 @@
             // 使用 AJAX 发送表单数据
             var form = 预警;
             var formData = new FormData(form);
+            let strTime = $("#strTime").val();
+            let endTime = $("#endTime").val();
+            if (strTime > endTime) {
+                top.ZLPMS.Msg("工作开始时间不能大于工作结束时间");
+                return;
+            }
 
             var xhr = new XMLHttpRequest();
             xhr.open(form.method, form.action);

+ 18 - 51
PMS.WebUI/Views/CloudMonitor/UnprocessedEarlyWarningManagementIndex.cshtml

@@ -1,7 +1,8 @@
-
+@using PMS.BusinessModels.CloudMonitorManage;
 @{
     ViewBag.Title = "EarlyWarningManagementIndex";
     Layout = "~/Views/Shared/_MainLayoutPage.cshtml";
+    AlertConfig config = ViewBag.Model as AlertConfig;
 }
 <style>
     .datagrid-header-row {
@@ -50,66 +51,32 @@
         background-color: #63b563;
     }
 </style>
-<div id="Channeltb">
-    <button href="#" id="Handle" class="easyui-linkbutton" data-options="iconCls:'fa fa-plus color_blue',plain:true">处理</button>
-    <button href="#" id="HandleAll" class="easyui-linkbutton" data-options="iconCls:'fa fa-plus color_blue',plain:true">批量处理</button>
-    <button href="#" id="ViewServer" class="easyui-linkbutton" data-options="iconCls:'fa fa-plus color_blue',plain:true">查看服务器</button>
-    <input id="userAccount" class="easyui-searchbox" data-options="prompt:'支持渠道,项目,预警类型,负责人,服务器类型',searcher:Enter_Submit" style="width:450px" />
-    <button type="button" id="btn-more" class="layui-btn layui-btn-normal layui-btn-sm">更多条件</button>
-    <button type="button" id="notTimely" class="layui-btn layui-btn-danger layui-btn-sm">未及时处理预警</button>
-</div>
-<div id="mainLayout" style="width:100%;height:900px;">
-    <div data-options="region:'center', title:'预警管理'">
-        <table id="treegrid" data-options="fit:true">
-            <!-- 预警管理表格内容 -->
-        </table>
+<div>
+    <div id="mainLayout1" style="width:100%;height:450px;">
+        <div data-options="region:'center', title:'工作时间内'" style="height:45vh;">
+            <table id="treegrid1" data-options="fit:true">
+                <!-- 预警管理表格内容 -->
+            </table>
+        </div>
     </div>
-    <div id="processPanel" data-options="region:'east', split:true, title:'处理过程', collapsible:true, collapsed:true" style="width:20%;">
-        <div data-options="region:'east',split:true" title="过程" style="width:400px;">
-            <ul class="layui-timeline" id="timeline">
-            </ul>
+    <div id="mainLayout2" style="width:100%;height:450px;">
+        <div data-options="region:'center', title:'工作时间外'" style="height:45vh;">
+            <table id="treegrid2" data-options="fit:true">
+                <!-- 预警管理表格内容 -->
+            </table>
         </div>
     </div>
 </div>
 
-@*更多条件*@
-<form id="inteform" method="post" class="layui-form" style="margin-top:20px;display:none;">
-    <div class="layui-form-item">
-        <div class="layui-inline">
-            <label class="layui-form-label">渠道</label>
-            <div class="layui-input-inline">
-                <input id="QDID" name="QDID" panelheight="200px" class="easyui-combobox xmid" data-options="labelAlign:'right',prompt:'请选择渠道',limitToList:true,tipPosition:'top'" style="height:38px;border-radius:4px;width:200px" />
-            </div>
-        </div>
-        <div class="layui-inline">
-            <label class="layui-form-label">项目</label>
-            <div class="layui-input-inline">
-                <input id="XMID" name="XMID" panelheight="200px" class="easyui-combobox xmid" data-options="labelAlign:'right',prompt:'请选择项目',limitToList:true,tipPosition:'top'" style="height: 38px; border-radius: 4px; width: 200px " />
-            </div>
-        </div>
-    </div>
-    <div class="layui-form-item">
-        <div class="layui-inline">
-            <label class="layui-form-label">预警类型</label>
-            <div class="layui-input-inline">
-                <input id="YJLXID" name="YJLXID" panelheight="200px" class="easyui-combobox xmid" data-options="labelAlign:'right',prompt:'请选择渠道',limitToList:true,tipPosition:'top'" style="height:38px;border-radius:4px;width:200px" />
-            </div>
-        </div>
-        <div class="layui-inline">
-            <label class="layui-form-label">处理状态</label>
-            <div class="layui-input-inline">
-                <input id="ZT" name="ZT" panelheight="200px" class="easyui-combobox xmid" data-options="labelAlign:'right',prompt:'请选择项目',limitToList:true,tipPosition:'top'" style="height: 38px; border-radius: 4px; width: 200px " />
-            </div>
-        </div>
-    </div>
-</form>
 <script src="~/ViewModels/UnprocessedEarlyWarningManagementIndex.js"></script>
 <script type="text/javascript">
+    window.starTime = '@config.工作开始时间';
+    window.endTime = '@config.工作结束时间';
     var model = new viewModel();
-    window.proId = getQueryString("ProId");
     model.init();
     $(function () {
-        $('#mainLayout').layout();
+        $('#mainLayout1').layout();
+        $('#mainLayout2').layout();
     })
 </script>