自动化立体仓库 - WCS系统
Junjie
4 天以前 8a0442fe48ef5a8d314fd8426475ae44de81a047
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
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>提升机监控管理</title>
    <link rel="stylesheet" type="text/css" href="../static/css/normalize.css">
    <link rel="stylesheet" type="text/css" href="../static/css/common_wcs.css">
    <link rel="stylesheet" type="text/css" href="../static/layui/css/layui.css">
    <link rel="stylesheet" href="../static/css/lift.css">
    <script type="text/javascript" src="../static/js/jquery/jquery-3.3.1.min.js"></script>
    <script type="text/javascript" src="../static/js/layer/layer.js"></script>
    <script type="text/javascript" src="../static/layui/layui.js"></script>
    <script type="text/javascript" src="../static/js/common.js"></script>
</head>
<body>
<div style="padding: 10px;height: 100%;float: left;width: 6%">
    <div class="button-window"></div>
</div>
<div style="height: 100%;padding-left: 6%">
    <div style="padding: 10px;height: 100%">
        <!-- 日志监控板 -->
        <div class="log-board">
            <div class="command-log" id="commandLogId" style="width: 10%;">
            </div>
            <div class="lift-state" style="width: 90%;">
                <table id="lift-state-table">
                    <thead>
                    <tr>
                        <th>提升机</th>
                        <th>工作号</th>
                        <th>PLC任务号</th>
                        <th>模式</th>
                        <th>任务状态</th>
                        <th>任务模式</th>
                        <th>取货数据</th>
                        <th>放货数据</th>
                        <th>出入库模式</th>
                        <th>故障码</th>
                    </tr>
                    </thead>
                    <tbody>
                    </tbody>
                </table>
            </div>
        </div>
        <!-- 提升机状态 -->
        <div class="lift-msg">
            <table id="lift-msg-table">
                <thead>
                <tr>
                    <th>提升机</th>
                    <th>工作号</th>
                    <th>站点信息</th>
                </tr>
                </thead>
                <tbody>
                </tbody>
            </table>
        </div>
        <!-- 手动操作 -->
        <div class="lift-operation">
            <!-- 遮罩层 -->
            <div class="lift-operation-shade">
                    <span class="lift-operation-shade-span">
                        WCS 系统运行中,请停止后操作
                    </span>
            </div>
            <!-- 设备任务选择 -->
            <div class="task-select">
                <!-- 选择 -->
                <div id="lift-select" class="operator-item">
                    <span class="select-title">提升机号</span>
                    <div class="select-container" id="liftRadioBoxId">
                        <!--                            <label><input type="radio" name="liftSelect" value="1" checked>&nbsp;1号提升机</label>-->
                    </div>
                </div>
            </div>
 
            <!-- 设备任务操作 -->
            <div class="task-operator">
                <fieldset>
                    <legend>手动操作</legend>
                    <div class="button-group">
                        <div class="select-container-item">
                            <span>源站</span>
                            <label><input id="sourceStaNo" type="text" name="sourceStaNo" /></label>
                        </div>
                        <div class="select-container-item">
                            <span>目标站</span>
                            <label><input id="staNo" type="text" name="staNo" /></label>
                        </div>
                        <button class="item" onclick="liftOperator(1)">小车换层</button>
                        <button class="item" onclick="liftOperator(2)">移动托盘</button>
                        <button class="item" onclick="liftOperator(3)">移动</button>
                        <button class="item" onclick="liftOperator(4)">任务确认</button>
                        <button class="item" onclick="liftOperator(0)">复位</button>
                    </div>
                </fieldset>
            </div>
 
        </div>
        <!-- 提升机日志输出 -->
        <div class="lift-output-board">
            <textarea id="lift-output"></textarea>
        </div>
 
        <div id="lift-detl" style="display: none">
            <div>
                <div class="form-item">
                    <label class="form-label">站号:</label>
                    <div class="form-input">
                        <input id="liftNo" name="liftNo" class="layui-input" lay-verify="required|number" autocomplete="off" disabled="disabled">
                    </div>
                </div>
                <div class="form-item">
                    <label class="form-label">工作号:</label>
                    <div class="form-input">
                        <input id="workNo" name="workNo" type="number" class="layui-input" lay-verify="number" autocomplete="off">
                    </div>
                </div>
                <div class="form-item form-button-container">
                    <button class="form-button" id="save">保存</button>
                    <button class="form-button" id="cancel" style="background-color: #D0D0D0">取消</button>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
</html>
<script>
    // 空白行数
    var liftStateTableBlankRows = 0;
    var liftMsgTableBlankRows = 0;
    // 实际行数
    var liftStateTableFullRows = 0;
    var liftMsgTableFullRows = 0;
    // 初始化
    var liftOutputDom = document.getElementById("lift-output");
    $(document).ready(function() {
        initliftStateTable();
        getliftStateInfo();
        initliftMsgTable();
        getliftMsgInfo();
        operatorBlockShow();
        setliftRadio();
    });
 
    setInterval(function () {
        getliftStateInfo()
        getliftMsgInfo();
    },1000)
    setInterval(function () {
        getliftOutput();
        operatorBlockShow();
    },500);
 
    // 判断手动操作模块是否可用
    function operatorBlockShow() {
        if (parent.systemRunning) {
            $('.lift-operation').css("opacity", "0.5");
            $('.lift-operation-shade').show();
            $('.lift-operation-shade-span').show();
        }  else {
            $('.lift-operation').css("opacity", "1");
            $('.lift-operation-shade').hide();
            $('.lift-operation-shade-span').hide();
        }
    }
 
    $(document).on('click ','#save', function () {
        http.post(baseUrl+ "/forkLift/detl/update", {
            liftNo: $('#liftNo').val(),
            workNo: $('#workNo').val(),
        }, function (res) {
            layer.msg("修改成功", {icon: 1,});
            layer.close(layerDetl);
        })
    })
 
    function setliftRadio() {
        $.ajax({
            url: baseUrl+ "/forkLift/table/lift/state",
            headers: {'token': localStorage.getItem('token')},
            method: 'POST',
            success: function (res) {
                if (res.code === 200){
                    let table = res.data;
                    for (let i=1;i<=table.length;i++){
                        //渲染提升机选项html
                        let liftRadioBox = '<label><input type="radio" name="liftSelect" ';
                        if (i === 1) {
                            liftRadioBox += 'checked '
                        }
                        liftRadioBox += 'value="' + table[i - 1].liftNo + '">&nbsp;' + table[i - 1].liftNo + '号提升机</label>'
                        $("#liftRadioBoxId").append(liftRadioBox)
 
 
                        //渲染提升机数据维护和设备信息html
                        let liftCommandLogBox = '<div class="lift-command-item" data-liftNo="' + table[i - 1].liftNo + '">\n' +
                            '<label>' + table[i - 1].liftNo + '#</label>\n' +
                            '</div>'
                        $("#commandLogId").append(liftCommandLogBox);
                    }
                } else if (res.code === 403){
                    window.location.href = baseUrl+"/login";
                }  else {
                    console.log(res.msg);
                }
            }
        });
    }
 
    // 提升机信息表获取 ---- 表一
    function getliftStateInfo() {
        let tableEl = $('#lift-state-table');
        $.ajax({
            url: baseUrl+ "/forkLift/table/lift/state",
            headers: {'token': localStorage.getItem('token')},
            method: 'POST',
            success: function (res) {
                if (res.code === 200){
                    let table = res.data;
                    if (table.length > liftStateTableBlankRows && table.length !== liftStateTableFullRows) {
                        initliftStateTable(table.length-liftStateTableBlankRows);
                        liftStateTableFullRows = table.length;
                    }
                    for (let i=1;i<=table.length;i++){
                        // $("#mode-"+table[i-1].liftNo).html(table[i-1].statusVal===0?'联机':'脱机');
                        let tr = tableEl.find("tr").eq(i);
                        setVal(tr.children("td").eq(0), table[i-1].liftNo);
                        setVal(tr.children("td").eq(1), table[i-1].taskNo);
                        setVal(tr.children("td").eq(2), table[i-1].wrkNo);
                        setVal(tr.children("td").eq(3), table[i-1].model$);
                        setVal(tr.children("td").eq(4), table[i-1].protocolStatus$);
                        setVal(tr.children("td").eq(5), table[i-1].taskMode$);
                        setVal(tr.children("td").eq(6), table[i-1].pick);
                        setVal(tr.children("td").eq(7), table[i-1].put);
                        setVal(tr.children("td").eq(8), table[i-1].iOMode$);
                        setVal(tr.children("td").eq(9), table[i-1].errorCode$);
                    }
                } else if (res.code === 403){
                    window.location.href = baseUrl+"/login";
                }  else {
                    console.log(res.msg);
                }
            }
        });
    }
 
    // 提升机数据表获取 ---- 表二
    function getliftMsgInfo() {
        let tableEl = $('#lift-msg-table');
        $.ajax({
            url: baseUrl+ "/forkLift/table/lift/msg",
            headers: {'token': localStorage.getItem('token')},
            method: 'POST',
            success: function (res) {
                if (res.code === 200){
                    var table = res.data;
                    if (table.length > liftMsgTableBlankRows && table.length !== liftMsgTableFullRows) {
                        initliftMsgTable(table.length-liftMsgTableBlankRows);
                        liftMsgTableFullRows = table.length;
                    }
                    for (var i=1;i<=table.length;i++){
                        var tr = tableEl.find("tr").eq(i);
                        let staDiv = "";
                        table[i-1].forkLiftStaProtocols.forEach((item) => {
                            let hasTray = item.hasTray ? "Y" : "N";
                            let hasCar = item.hasCar ? "Y" : "N";
                            staDiv += "<div>" + item.lev + "层,托盘:" + hasTray + ",小车:" + hasCar + "</div>"
                        })
 
                        setVal(tr.children("td").eq(0), table[i-1].liftNo);
                        setVal(tr.children("td").eq(1), table[i-1].workNo);
                        setVal(tr.children("td").eq(2), staDiv);
                    }
                } else if (res.code === 403){
                    window.location.href = baseUrl+"/login";
                }  else {
                    console.log(res.msg);
                }
            }
        });
    }
 
    // 提升机日志输出 -----------------------------------------------------------------------
    function getliftOutput() {
        $.ajax({
            url: baseUrl + "/forkLift/output/lift",
            headers: {'token': localStorage.getItem('token')},
            method: 'POST',
            success: function (res) {
                if (res.code === 200) {
                    liftOutput(res.data);
                } else if (res.code === 403) {
                    window.location.href = baseUrl + "/login";
                } else {
                    console.log(res.msg);
                }
            }
        })
    }
 
    // 任务指令下发
    function liftOperator(liftTaskMode) {
        http.post(baseUrl+"/forkLift/operator/lift", {
            liftNo: $('input[name="liftSelect"]:checked').val(),
            liftTaskMode: liftTaskMode,
            lev: $("#liftLev").val(),
            sourceStaNo: $("#sourceStaNo").val(),
            staNo: $("#staNo").val()
        }, function (res) {
            layer.msg(res.msg, {icon: 1});
        });
    }
 
 
    // ------------------------------------------------------------------------------------------------
 
    // 提升机信息表获取  ----- 表一
    function initliftStateTable(row) {
        let line;
        if (row === undefined){
            let one = $('#lift-state-table thead').height();
            let total = $('.lift-state').height();
            let count = total / one;
            count = parseInt(count) - 1;
            liftStateTableBlankRows = count;
            line = count;
        } else {
            line = row;
        }
        let html = "";
        for (let i = 0; i < line; i ++){
            html += " <tr>\n" +
                "       <td></td>\n" +
                "       <td></td>\n" +
                "       <td></td>\n" +
                "       <td></td>\n" +
                "       <td></td>\n" +
                "       <td></td>\n" +
                "       <td></td>\n" +
                "       <td></td>\n" +
                "       <td></td>\n" +
                "       <td></td>\n" +
                "       <td></td>\n" +
                "       <td></td>\n" +
                "       <td></td>\n" +
                "       <td></td>\n" +
                "       <td></td>\n" +
                "       <td></td>\n" +
                "       <td></td>\n" +
                "     </tr>\n";
        }
        $('#lift-state-table tbody').after(html);
    }
 
    // 提升机数据表获取  ----- 表二
    function initliftMsgTable(row) {
        let line;
        if (row === undefined){
            let one = $('#lift-msg-table thead').height();
            let total = $('.lift-msg').height();
            let count = total / one;
            count = parseInt(count) - 1;
            liftMsgTableBlankRows = count;
            line = count;
        } else {
            line = row;
        }
        let html = "";
        for (let i = 0; i < line; i ++){
            html += " <tr>\n" +
                "       <td></td>\n" +
                "       <td></td>\n" +
                "       <td></td>\n" +
                "       <td></td>\n" +
                "       <td></td>\n" +
                "       <td></td>\n" +
                "       <td></td>\n" +
                "       <td></td>\n" +
                "       <td></td>\n" +
                "       <td></td>\n" +
                "       <td></td>\n" +
                "       <td></td>\n" +
                "       <td></td>\n" +
                "       <td></td>\n" +
                "       <td></td>\n" +
                "     </tr>\n";
        }
        $('#lift-msg-table tbody').after(html);
    }
 
    // 日志输出框
    function liftOutput(content){
        liftOutputDom.value += content;
        liftOutputDom.scrollTop = liftOutputDom.scrollHeight;
    }
 
    // 详情操作 -------------------------------------------------------------------------
    var layerDetl;
    $(document).on('dblclick ','#lift-msg-table tr', function () {
        var liftNo = $(this).children("td").eq(0).html();
        if (liftNo !== null && liftNo !== "") {
            layerDetl = layer.open({
                type: 1,
                title: false,
                shadeClose: true,
                offset: 'rt',
                anim: 5,
                shade: [0],
                area: ['340px', '255px'],
                closeBtn: 0,
                content: $("#lift-detl"),
                success: function(layero, index){
                    $.ajax({
                        url: baseUrl+ "/forkLift/table/lift/msg",
                        headers: {'token': localStorage.getItem('token')},
                        method: 'POST',
                        success: function (res) {
                            if (res.code === 200){
                                var table = res.data;
                                for (var i=1;i<=table.length;i++){
                                    if (liftNo == table[i-1].liftNo) {
                                        $('#liftNo').val(liftNo);
                                        $('#workNo').val(table[i-1].workNo);
                                        $('#pakMk').val(table[i-1].pakMk);
                                        $('#token').val(table[i-1].token);
                                    }
                                }
                            } else if (res.code === 403){
                                window.location.href = baseUrl+"/login";
                            }  else {
                                console.log(res.msg);
                            }
                        }
                    });
                },
                end: function () {
                    $('#liftNo').val("");
                    $('#workNo').val("");
                    $('#pakMk').val("");
                    $('#token').val("");
                }
            })
        }
    });
 
    $(document).on('click ','#cancel', function () {
        $('#liftNo').val("");
        $('#workNo').val("");
        $('#pakMk').val("");
        $('#token').val("");
        layer.close(layerDetl);
    })
 
</script>