CZT
2023-11-27 c206acfaedc69c390fb67daa81bc686f58a212ef
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
<!DOCTYPE html>
<html lang="zh-cn" xmlns:th=http://www.thymeleaf.org>
<head>
<meta charset="utf-8">
<title>Layui</title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport"
    content="width=device-width, initial-scale=1, maximum-scale=1">
<link rel="stylesheet"
    th:href="@{../../static/plugins/layui/css/layui.css}">
 
 
<style>
body {
    font-family: "微软雅黑", Arial, sans-serif;
    font-size: 14px;
    background: #f3f5f8;
}
 
table {
    overflow-x: hidden;
}
 
.progress {
    padding: 15px;
}
 
.progress-r {
    padding-left: 15px;
}
 
.progress-r span {
    font-size: 16px;
    font-weight: bold;
}
 
.layui-progress {
    background-color: #666;
}
 
.layui-table {
    color: #0C0C0C;
}
 
.layui-table thead tr {
    border-bottom: 3px solid #53adce;
}
 
.layui-table thead th {
    font-weight: bold;
}
 
.remark {
    padding: 0px 15px 0px 15px;
    height: 22px;
    line-height: 22px;
    color: #FF5722;
    font-size: 12px;
    font-weight: bold;
    float: left;
}
 
.btn-clean {
    background-color: #FF5722;
    color: #FFF;
}
 
.s-error {
    font-weight: bold;
    color: #FF5722;
}
 
.s-complete {
    font-weight: bold;
    color: #5FB878;
}
 
.s-none {
    font-weight: bold;
}
</style>
</head>
 
<body>
    <div class="layui-clear">
 
        <div class="layui-row progress">
 
            <div class="layui-col-md6">
                <div class="layui-progress layui-progress-big"
                    lay-filter="filter-progress" lay-showpercent="yes">
                    <div class="layui-progress-bar" lay-percent="0%"
                        id="filter-progress"></div>
                </div>
            </div>
 
            <div class="layui-col-md6">
                <div class="progress-r">
                    共执行命令:<span id="check_sumNum">0</span>个 &nbsp;&nbsp;&nbsp;&nbsp;
                    已执行:<span id="check_completeNum">0</span>个 &nbsp;&nbsp;&nbsp;&nbsp;
                    失败:<span id="check_errorNum">0</span>个
                </div>
            </div>
 
        </div>
 
        <div class="layui-row">
            <table class="layui-hide" id="tableOrder"
                lay-data="{id: 'tableOrder'}"></table>
        </div>
 
        <div class="layui-row">
            <span class="remark">注:数据为当前库区近8个小时内执行记录和统计,可以清除,不影响执行日志</span>
            <button type="button"
                class="layui-btn layui-btn-primary btn-clean layui-btn-xs"
                onclick="clean()">点击清除</button>
 
            <button type="button"
                class="layui-btn layui-btn-primary btn-clean layui-btn-xs"
                id="btn-auto" onclick="autoFlush()">自动刷新中</button>
        </div>
 
    </div>
 
    <script th:src="@{../../static/plugins/layui/layui.js}"></script>
    <script th:src="@{../../static/js/jquery.min.js}"></script>
    <script th:inline="javascript">
    //业务类型
    var bizType = [[${bizType}]];
    //userId
    var userId = [[${loginUser.username}]];
    var companyId = [[${loginUser.companyId}]];
    var deptId = [[${deptId}]];//当前人所在部门ID
 
    var orderList;
    
    var autoTag = true;
 
    var table;
    var element;
 
    layui.use(['table', 'element'], function () {
        table = layui.table;
        element = layui.element;
        table.render({
            elem: '#tableOrder',
            url: '../../basic/grain/query-order-list?deptId=' + deptId,
            width: 980,
            height: 460,
            cols: [[
                {field: 'exeTime', width: 150, title: '执行时间', sort: true, align: 'center'},
                {field: 'depotName', width: 150, title: '所属仓库', sort: true, align: 'center'},
                {field: 'exeUser', width: 130, title: '检测人', align: 'center'},
                {
                    field: 'status', width: 120, title: '执行状态', align: 'center', templet: function (d) {
                        if ('IN_PROGRESS' == d.status) {
                            return "<span class='s-none'>执行中</span>";
                        } else if ('SEND_ERROR' == d.status) {
                            return "<span class='s-error'>发送失败</span>";
                        } else if ('ANALYSIS_ERROR' == d.status) {
                            return "<span class='s-error'>解析失败</span>";
                        } else if ("TIMEOUT_ERROR" == d.status) {
                            return "<span class='s-error'>处理超时</span>";
                        } else {
                            return "<span class='s-complete'>成功完成</span>";
                        }
                    }
                },
                {field: 'msg', title: '执行说明', align: 'center'}
            ]],
            page: false,
            done: function (res, cuur, count) {
                orderList = res.data;
                exeProgress();
            }
        });
    });
 
    function exeProgress() {
        //console.log("--------------exeProgress----------------");
        //console.log(orderList);
        var sumNum = 0, completeNum = 0, errorNum = 0, per = 0;
        if (orderList) {
            $.each(orderList, function (index, data) {
                sumNum = orderList.length;
                if ("SEND_ERROR" == data.status || "ANALYSIS_ERROR" == data.status || "TIMEOUT_ERROR" == data.status) {
                    completeNum++;
                    errorNum++;
                }
                if ("COMPLETE" == data.status) {
                    completeNum++;
                }
            });
        }
 
        if (sumNum > 0) {
            per = (completeNum / sumNum * 100).toFixed(1);
        }
        // console.log("-------per------"+per);
        element.progress('filter-progress', per + "%");
        //赋值
        $("#check_sumNum").text(sumNum);
        $("#check_completeNum").text(completeNum);
        $("#check_errorNum").text(errorNum);
    }
 
    /**
     *清除日志
     */
    function clean() {
        var data = {
            deptId: deptId,
            companyId: companyId,
            bizType: bizType
        };
        $.ajax({
            type: "POST",
            url: "../../basic/grain/clean-order-list",
            dataType: "json",
            contentType: "application/json;charset=UTF-8",
            data: JSON.stringify(data),
            success: function (result) {
                if (result.code != "0000") {
                    layer.alert(result.data);
                } else {
                    layer.msg("日志清除完成!");
                }
            },
            error: function () {
                layer.alert("系统后台执行失败,请刷新重试!");
            }
        });
    }
 
 
   
 
    function autoFlush() {
        if (autoTag) {
            autoTag = false;
            $("#btn-auto").text("已停止刷新");
        } else {
            autoTag = true;
            $("#btn-auto").text("自动刷新中");
        }
    }
 
 
    //设置自动刷新
    var iframeTimer;
    window.onload = function () {
        if (iframeTimer) {
            clearInterval(iframeTimer);
        }
        iframeTimer = setInterval(function () {
            if (autoTag) {
                table.reload("tableOrder", {
                    url: '../../basic/grain/query-order-list?deptId=' + deptId
                });
            }
        }, 6000);
    };
</script>
</body>
</html>