自动化立体仓库 - WCS系统
#
Junjie
2025-04-26 544f7c2314a46cd39d55fdce2dc0247499905b1d
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
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>首页</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" href="../../static/wms/layui/css/layui.css" media="all">
    <script type="text/javascript" src="../../static/wms/js/common.js"></script>
    <script type="text/javascript" src="../../static/wms/layui/layui.js"></script>
    <script type="text/javascript" src="../../static/wms/js/jquery/jquery-3.3.1.min.js"></script>
    <script type="text/javascript" src="../../static/wms/js/echarts/echarts.min.js"></script>
    <script type="text/javascript" src="../../static/wms/js/echarts/highcharts.js"></script>
    <style>
        body {
            background-color: #f1f1f1;
        }
        .home-elem {
            background-color: #fff;
            height: 30%;
            margin: 15px 15px 45px 15px;
            border-radius: 5px;
            box-shadow: 0 0 3px rgba(0,0,0,.3);
        }
        .home-elem:first-child{
            margin-bottom: 0;
        }
        .chart-elem {
            box-sizing: border-box;
            display: inline-block;
            width: 49%;
        }
        .chart-elem div {
            padding-top: 15px;
            padding-bottom: 5px;
        }
        .chart-elem:first-child {
            padding: 0 50px;
        }
        .chart-elem:last-child {
            padding: 0 50px;
            border-left: 1px solid rgba(0,0,0,.1);
        }
        /*表格工具栏*/
        .layui-table-tool {
            display: none;
        }
        /*表格*/
        .layui-table thead th {
            font-weight: bold;
            text-align: center;
        }
        div .layui-table-tool .layui-table-tool-self .layui-inline[title='导出']{
            display: none;
        }
        .layui-form.layui-border-box.layui-table-view{
            margin: 15px 0 35px 0;
            width: 100%;
            border-width: 0;
        }
        .layui-table-box{
            padding-bottom: 10px;
        }
        .layui-table-body.layui-table-main{
            overflow: hidden;
        }
        .layui-table-page{
            border-width: 0;
        }
        .layui-table tbody tr:hover, .layui-table thead tr, .layui-table-click, .layui-table-header, .layui-table-hover, .layui-table-mend, .layui-table-patch, .layui-table-tool, .layui-table-total, .layui-table-total tr, .layui-table[lay-even] tr:nth-child(even) {
            background-color: #f9f9f9;
        }
        .layui-table thead tr {
            background-color: #fff;
        }
        #form-header {
            font-size: 18px;
            color: #377bb5;
            font-weight: bold;
            height: 30px;
            box-sizing: border-box;
            padding: 10px 0 10px 20px;
        }
        .layui-form.layui-border-box.layui-table-view {
            border-top: 1px solid rgba(0,0,0,.1);
        }
        #search-box {
            margin-left: 10px;
            z-index: 999;
            position: relative;
            padding: 0 30px 10px 30px;
        }
    </style>
</head>
<body>
 
<!--报表数据-->
<div class="home-elem charts-contain">
    <div class="chart-elem">
        <div id="pie"></div>
    </div>
    <div class="chart-elem">
        <div id="line"></div>
    </div>
</div>
 
<!--&lt;!&ndash;表格数据&ndash;&gt;-->
<!--<div class="home-elem loc-retention">-->
<!--    <div class="layui-form">-->
<!--        <div id="form-header">库龄统计表</div>-->
<!--        <table class="layui-hide" id="stayTime" lay-filter="stayTime"></table>-->
<!--    </div>-->
<!--</div>-->
</body>
<script>
    pieCharts();
    lineCharts();
    // 饼图
    function pieCharts(){
        $.ajax({
            url:baseUrl+'/console/loc/pie/charts',
            headers: {'token': localStorage.getItem('token')},
            dataType: 'json',
            contentType: 'application/json;charset=UTF-8',
            crossDomain: true,
            method: 'POST',
            success:function(res){
                var data = res.data;
                var dataPie=eval(data.rows);
                var chart = {
                    plotBackgroundColor: null,
                    plotBorderWidth: null,
                    plotShadow: false
                };
                var title = {
                    text: '库位使用比例',
                    margin:1,
                    style: {fontSize: '18px',color: '#777',fontWeight: 'bold'},
                    y: 5
                };
                var tooltip = {
                    pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
                };
                var plotOptions = {
                    pie: {
                        allowPointSelect: true,
                        cursor: 'pointer',
                        dataLabels: {
                            enabled: true,
                            format: '<b>{point.name}</b>: {point.percentage:.1f} %',
                            style: {
                                color: (Highcharts.theme && Highcharts.theme.contrastTextColor) || 'black'
                            }
                        }
                    }
                };
                var series= [{
                    type: 'pie',
                    name: '库位占比',
                    data: dataPie
                }];
                var loading = {
                    hideDuration: 3,
                    showDuration: 3
                };
                var json = {};
                json.chart = chart;
                json.title = title;
                json.tooltip = tooltip;
                json.series = series;
                json.plotOptions = plotOptions;
                json.loading = loading;
                json.credits = {enabled: false};
                $('#pie').highcharts(json);
 
            },
            error:function(){
            }
        });
    }
 
    // 折线图
    function lineCharts() {
        $.ajax({
            url: baseUrl+'/console/locIo/line/charts',
            headers: {'token': localStorage.getItem('token')},
            dataType: 'json',
            contentType: 'application/json;charset=UTF-8',
            method: 'POST',
            success: function (res) {
                var data = res.data;
                var dataPie = eval(data.rows);
                var title = {
                    text: '日入出库数量',
                    margin: 1,
                    style: {fontSize: '18px',color: '#777',fontWeight: 'bold'},
                    y: 5
                };
                var xAxis = {
                    categories: [getDate(-11), getDate(-10), getDate(-9), getDate(-8), getDate(-7), getDate(-6),
                        getDate(-5), getDate(-4), getDate(-3), getDate(-2), getDate(-1), getDate(-0)]
                };
                var yAxis = {
                    title: {
                        text: '入/出库数量'
                    },
                    plotLines: [{
                        value: 0,
                        width: 1,
                        color: '#808080'
                    }]
                };
                var tooltip = {};
                var legend = {
                    layout: 'vertical',
                    align: 'right',
                    verticalAlign: 'middle',
                    borderWidth: 0
                };
                var loading = {
                    hideDuration: 3,
                    showDuration: 3
                }
                var series = dataPie;
                var json = {};
                json.title = title;
                json.xAxis = xAxis;
                json.yAxis = yAxis;
                json.tooltip = tooltip;
                json.legend = legend;
                json.loading = loading;
                json.series = series;
                json.credits = {enabled: false};
                $('#line').highcharts(json);
            }
        });
    }
 
    // 表格
    var pageCurr;
    function getCol() {
        var cols = [
            //{field: 'appeTime$', title: '入库时间', align: 'center', width: 165}
            {field: 'stay_time', align: 'center',title: '滞留天数',width: 90}
            ,{field: 'store_max_date', align: 'center',title: '库龄上限',width: 90}
            // ,{field: 'store_min', title: '库存下限', align: 'center'}
            // ,{field: 'sum_qty', title: '库存总数', align: 'center'}
            // ,{field: 'store_max', title: '库存上限', align: 'center'}
            ,{field: 'loc_no', align: 'center',title: '库位号',width: 90}
 
        ];
        cols.push.apply(cols, detlCols);
        //cols.push({field: 'sum_qty', title: '库存总数', align: 'center'})
        return cols;
    }
    layui.use(['table','laydate', 'form'], function() {
        var table = layui.table;
        var $ = layui.jquery;
        var layer = layui.layer;
        var form = layui.form;
 
        // 数据渲染
        tableIns = table.render({
            elem: '#stayTime',
            headers: {token: localStorage.getItem('token')},
            url: baseUrl+'/report/viewStayTimeList.action',
            page: true,
            limit: 10,
            toolbar: '#toolbar',
            even: true,
            cellMinWidth: 50,
            crossDomain: true,
            cols: [getCol()],
            request: {
                pageName: 'curr',
                pageSize: 'limit'
            },
            parseData: function (res) {
                return {
                    'code': res.code,
                    'msg': res.msg,
                    'count': res.data.total,
                    'data': res.data.records
                }
            },
            response: {
                statusCode: 200
            },
            done: function(res, curr, count) {
                var that = this.elem.next();
                res.data.forEach(function (item, index) {
                    var tr = that.find(".layui-table-box tbody tr[data-index='" + index + "']");
                    if (item.store_max_date != null) {
                        if (item.stay_time > item.store_max_date) {
                            tr.css("background-color", "#ff6f00");
                            tr.css("color", "white");
                            tr.children()[1].style.backgroundColor="#ff0000"
                        }
                    }
                    //低于下限
                    if (item.sum_qty < item.store_min) {
                        tr.css("background-color", "#ff6f00");
                        tr.css("color", "white");
                        tr.children()[2].style.backgroundColor="rgb(255,0,0)"
                        tr.children()[2].style.color="white"
                        tr.children()[3].style.backgroundColor="#ff0000"
                        tr.children()[3].style.color="white"
                    }
                    //高于上限
                    if(item.store_max != null) {
                        if (item.sum_qty > item.store_max) {
                            tr.css("background-color", "#ff6f00");
                            tr.css("color", "white");
                            tr.children()[3].style.backgroundColor="#009c04"
                            tr.children()[3].style.color="white"
                            tr.children()[4].style.backgroundColor="#3da83f"
                            tr.children()[4].style.color="white"
                        }
                    }
                });
                if (res.code === 403) {
                    top.location.href = baseUrl+"/";
                }
                pageCurr=curr;
            }
        });
 
        // 监听排序事件
        table.on('sort(stayTime)', function (obj) {
            var searchData = {};
            $.each($('#search-box [name]').serializeArray(), function() {
                searchData[this.name] = this.value;
            });
            searchData['orderByField'] = obj.field;
            searchData['orderByType'] = obj.type;
            tableIns.reload({
                where: searchData,
                page: {
                    curr: 1
                },
                done: function (res, curr, count) {
                    var that = this.elem.next();
                    res.data.forEach(function (item, index) {
                        if (item.store_max_date != null) {
                            if (item.stay_time > item.store_max_date) {
                                var tr = that.find(".layui-table-box tbody tr[data-index='" + index + "']");
                                tr.css("background-color", "#FF5722");
                                tr.css("color", "white");
                            }
                        }
                    });
                    if (res.code === 403) {
                        top.location.href = baseUrl+"/";
                    }
                    pageCurr=curr;
                }
            });
        });
 
        // 搜索栏搜索事件
        form.on('submit(search)', function (data) {
            tableReload();
        });
        // 搜索栏搜索事件
        form.on('submit(reset)', function (data) {
            $(':input', $('#search-box'))
                .val('')
                .removeAttr('checked')
                .removeAttr('selected');
            var searchData = {};
            $.each($('#search-box [name]').serializeArray(), function() {
                searchData[this.name] = this.value;
            });
            tableIns.reload({
                where: searchData
            });
 
        });
 
        function tableReload() {
            var searchData = {};
            $.each($('#search-box [name]').serializeArray(), function() {
                searchData[this.name] = this.value;
            });
            tableIns.reload({
                where: searchData
            });
        }
    });
 
 
    function getDate(value){
        var date = new Date();// 获取当前时间
        date.setDate(date.getDate() + value);// 设置天数 -1 天
        return date.Format("MM-dd");
    }
    /**
     * 日期格式化
     */
    Date.prototype.Format = function (fmt) {
        var o = {
            "M+": this.getMonth() + 1, //月份
            "d+": this.getDate(), //日
            "h+": this.getHours(), //小时
            "m+": this.getMinutes(), //分
            "s+": this.getSeconds(), //秒
            "q+": Math.floor((this.getMonth() + 3) / 3), //季度
            "S": this.getMilliseconds() //毫秒
        };
        if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
        for (var k in o)
            if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length === 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
        return fmt;
    }
</script>
</html>