自动化立体仓库 - WCS系统
#
Junjie
2023-10-12 45387d35f22ad15d6920eaa5c8fc27c8296f0a03
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
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
<!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.css">
    <link rel="stylesheet" type="text/css" href="../static/layui/css/layui.css">
    <link rel="stylesheet" href="../static/css/shuttle.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: 5%;">-->
<!--&lt;!&ndash;                    <div data-shuttleNo="1" class="shuttle-command-item">&ndash;&gt;-->
<!--&lt;!&ndash;                        <label>1#</label>&ndash;&gt;-->
<!--&lt;!&ndash;                        <button class="demoBtn pos-btn">数据维护</button>&ndash;&gt;-->
<!--&lt;!&ndash;                        <button id="mode-1" class="demoBtn mode-btn" >设备信息</button>&ndash;&gt;-->
<!--&lt;!&ndash;                    </div>&ndash;&gt;-->
<!--                </div>-->
                <!-- 堆垛机状态位信息 -->
                <div class="shuttle-state" style="width: 100%;">
                    <table id="shuttle-state-table">
                        <thead>
                            <tr>
                                <th>四向穿梭车</th>
                                <th>任务状态</th>
                                <th>小车状态</th>
                                <th>工作模式</th>
                                <th>实际库位</th>
                                <th>实际坐标</th>
                                <th>电量</th>
                                <th>当前速度</th>
                                <th>负载状态</th>
                                <th>顶升位置</th>
                                <th>运行方向</th>
                                <th>运行方向2</th>
                                <th>充电状态</th>
                                <th>故障状态</th>
                                <th>故障码</th>
                                <th>管制状态</th>
                            </tr>
                        </thead>
                        <tbody>
                        </tbody>
                    </table>
                </div>
            </div>
            <!-- 穿梭车状态 -->
            <div class="shuttle-msg">
                <table id="shuttle-msg-table">
                    <thead>
                        <tr>
                            <th>四向穿梭车</th>
                            <th>工作号</th>
                            <th>源库位</th>
                            <th>目标库位</th>
                            <th>最高电芯电压</th>
                            <th>最低电芯电压</th>
                            <th>电池电压</th>
                            <th>充放电循环次数</th>
                            <th>剩余电量</th>
                            <th>总电量</th>
                            <th>总里程数</th>
                            <th>作业标记</th>
                            <th>当前库位</th>
                            <th>令牌</th>
                        </tr>
                    </thead>
                    <tbody>
                    </tbody>
                </table>
            </div>
            <!-- 手动操作 -->
            <div class="shuttle-operation">
                <!-- 遮罩层 -->
                <div class="shuttle-operation-shade">
                    <span class="shuttle-operation-shade-span">
                        WCS 系统运行中,请停止后操作
                    </span>
                </div>
                <!-- 设备任务选择 -->
                <div class="task-select">
                    <!-- 选择 -->
                    <div id="shuttle-select" class="operator-item" style="width: 100%;">
                        <span class="select-title">四向穿梭车号</span>
                        <div class="select-container" id="shuttleRadioBoxId" style="display: flex;flex-wrap: wrap;justify-content: center;align-items: center;">
<!--                            <label><input type="radio" name="shuttleSelect" value="1" checked>&nbsp;1号穿梭车</label>-->
                        </div>
                    </div>
                </div>
 
                <!-- 设备任务操作 -->
                <div class="task-operator">
                    <fieldset style="height: auto;padding-bottom: 20px;">
                        <legend>手动操作</legend>
                        <div style="display: flex;">
                            <div style="width: 30%;">
                                <div class="operator-item" style="height: auto;width: 100%;">
                                    <span class="select-title">源库位/目标库位</span>
                                    <div class="select-container" style="height: auto;padding: 30px 10px 20px 10px;">
                                        <div class="select-container-item">
                                            <span>源库位</span>
                                            <label><input id="sourceLocNo" type="text" name="sourceLocNo" /></label>
                                        </div>
                                        <div class="select-container-item">
                                            <span>目标库位</span>
                                            <label><input id="distLocNo" type="text" name="distLocNo" /></label>
                                        </div>
 
                                        <div style="margin-top: 10px;">
                                            <button class="item" onclick="shuttleOperator(18)">搬运货物</button>
                                            <button class="item" onclick="shuttleOperator(14)">移动到目标库位</button>
                                            <button class="item" onclick="shuttleOperator(23)">移动到目标库位(任务)</button>
<!--                                            <button class="item" onclick="shuttleOperator(16)">移动到提升机</button>-->
                                        </div>
                                    </div>
                                </div>
                            </div>
 
                            <div style="width: 40%;">
                                <div class="operator-item" style="height: auto;width: 100%;">
                                    <span class="select-title">相关指令</span>
                                    <div class="select-container" style="height: auto;padding: 30px 10px 10px 10px;">
                                        <div class="button-group">
                                            <button class="item" onclick="shuttleOperator(3)">托盘顶升</button>
                                            <button class="item" onclick="shuttleOperator(4)">托盘下降</button>
                                            <button class="item" onclick="shuttleOperator(15)">充电开关</button>
                                            <button class="item" onclick="shuttleOperator(9)">复位</button>
                                            <button class="item" onclick="shuttleOperator(21)">管制</button>
                                            <button class="item" onclick="shuttleOperator(22)">取消管制</button>
                                        </div>
                                    </div>
                                </div>
                            </div>
 
                        </div>
                    </fieldset>
                </div>
 
            </div>
            <!-- 穿梭车日志输出 -->
            <div class="shuttle-output-board">
                <textarea id="shuttle-output"></textarea>
            </div>
        </div>
    </div>
 
    <div id="shuttle-detl" style="display: none">
        <div>
            <div class="form-item">
                <label class="form-label">穿梭车号:</label>
                <div class="form-input">
                    <input id="shuttleNo" name="shuttleNo" 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">
                <label class="form-label">作业标记:</label>
                <div class="form-input">
                    <input id="pakMk" name="pakMk" type="text" class="layui-input" autocomplete="off">
                </div>
            </div>
            <div class="form-item">
                <label class="form-label">令牌:</label>
                <div class="form-input">
                    <input id="token" name="token" type="text" class="layui-input" 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>
</body>
</html>
<script>
    // 空白行数
    var shuttleStateTableBlankRows = 0;
    var shuttleMsgTableBlankRows = 0;
    // 实际行数
    var shuttleStateTableFullRows = 0;
    var shuttleMsgTableFullRows = 0;
    // 初始化
    var shuttleOutputDom = document.getElementById("shuttle-output");
    $(document).ready(function() {
        initShuttleStateTable();
        getShuttleStateInfo();
        initShuttleMsgTable();
        getShuttleMsgInfo();
        operatorBlockShow();
        setShuttleRadio();
    });
 
    setInterval(function () {
        getShuttleStateInfo()
        getShuttleMsgInfo();
    },1000)
    setInterval(function () {
        getShuttleOutput();
        operatorBlockShow();
    },500);
 
    // 判断手动操作模块是否可用
    function operatorBlockShow() {
        if (parent.systemRunning) {
            $('.shuttle-operation').css("opacity", "0.5");
            $('.shuttle-operation-shade').show();
            $('.shuttle-operation-shade-span').show();
        }  else {
            $('.shuttle-operation').css("opacity", "1");
            $('.shuttle-operation-shade').hide();
            $('.shuttle-operation-shade-span').hide();
        }
    }
 
    function getColor(res,e){
        $(e).val(res?"✔":"—");
        if (res){
            $(e).attr("style", "color: #FD482C;");
        }else {
            $(e).attr("style", "color: #00FF00;");
        }
    }
 
    $(document).on('click ','#save', function () {
        http.post(baseUrl+ "/shuttle/detl/update", {
            shuttleNo: $('#shuttleNo').val(),
            workNo: $('#workNo').val(),
            pakMk: $('#pakMk').val(),
            token: $('#token').val(),
        }, function (res) {
            layer.msg("修改成功", {icon: 1,});
            layer.close(layerDetl);
        })
    })
 
    function setShuttleRadio() {
        $.ajax({
            url: baseUrl+ "/shuttle/table/shuttle/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 shuttleRadioBox = '<label><input type="radio" name="shuttleSelect" ';
                        if (i === 1) {
                            shuttleRadioBox += 'checked '
                        }
                        shuttleRadioBox += 'value="' + table[i - 1].shuttleNo + '">&nbsp;' + table[i - 1].shuttleNo + '号穿梭车</label>'
                        $("#shuttleRadioBoxId").append(shuttleRadioBox)
 
 
                        //渲染四向穿梭车数据维护和设备信息html
                        let shuttleCommandLogBox = '<div class="shuttle-command-item" data-shuttleNo="' + table[i - 1].shuttleNo + '">\n' +
                            '<label>' + table[i - 1].shuttleNo + '#</label>\n' +
                            // '<button class="demoBtn pos-btn">数据维护</button>\n' +
                            // '<button class="demoBtn mode-btn" id="mode-' + table[i - 1].shuttleNo + '">设备信息</button>\n' +
                            '</div>'
                        $("#commandLogId").append(shuttleCommandLogBox);
                    }
                } else if (res.code === 403){
                    window.location.href = baseUrl+"/login";
                }  else {
                    console.log(res.msg);
                }
            }
        });
    }
 
    // 四向穿梭车信息表获取 ---- 表一
    function getShuttleStateInfo() {
        let tableEl = $('#shuttle-state-table');
        $.ajax({
            url: baseUrl+ "/shuttle/table/shuttle/state",
            headers: {'token': localStorage.getItem('token')},
            method: 'POST',
            success: function (res) {
                if (res.code === 200){
                    let table = res.data;
                    if (table.length > shuttleStateTableBlankRows && table.length !== shuttleStateTableFullRows) {
                        initShuttleStateTable(table.length-shuttleStateTableBlankRows);
                        shuttleStateTableFullRows = table.length;
                    }
                    for (let i=1;i<=table.length;i++){
                        // $("#mode-"+table[i-1].shuttleNo).html(table[i-1].statusVal===0?'联机':'脱机');
                        let tr = tableEl.find("tr").eq(i);
                        setVal(tr.children("td").eq(0), table[i-1].shuttleNo);
                        setVal(tr.children("td").eq(1), table[i-1].protocolStatus$);
                        setVal(tr.children("td").eq(2), table[i-1].free$);
                        setVal(tr.children("td").eq(3), table[i-1].workingMode$);
                        setVal(tr.children("td").eq(4), table[i-1].point$);
                        setVal(tr.children("td").eq(5), table[i-1].point$$);
                        setVal(tr.children("td").eq(6), table[i-1].powerPercent$);
                        setVal(tr.children("td").eq(7), table[i-1].speed);
                        setVal(tr.children("td").eq(8), table[i-1].loadState$);
                        setVal(tr.children("td").eq(9), table[i-1].liftPosition$);
                        setVal(tr.children("td").eq(10), table[i-1].runDir$);
                        setVal(tr.children("td").eq(11), table[i-1].runDir2$);
                        setVal(tr.children("td").eq(12), table[i-1].chargState$);
                        setVal(tr.children("td").eq(13), table[i-1].errState$);
                        setVal(tr.children("td").eq(14), table[i-1].errCode$);
                        setVal(tr.children("td").eq(15), table[i-1].suspendState$);
                    }
                } else if (res.code === 403){
                    window.location.href = baseUrl+"/login";
                }  else {
                    console.log(res.msg);
                }
            }
        });
    }
 
    // 四向穿梭车数据表获取 ---- 表二
    function getShuttleMsgInfo() {
        let tableEl = $('#shuttle-msg-table');
        $.ajax({
            url: baseUrl+ "/shuttle/table/shuttle/state",
            headers: {'token': localStorage.getItem('token')},
            method: 'POST',
            success: function (res) {
                if (res.code === 200){
                    var table = res.data;
                    if (table.length > shuttleMsgTableBlankRows && table.length !== shuttleMsgTableFullRows) {
                        initShuttleMsgTable(table.length-shuttleMsgTableBlankRows);
                        shuttleMsgTableFullRows = table.length;
                    }
                    for (var i=1;i<=table.length;i++){
                        var tr = tableEl.find("tr").eq(i);
                        setVal(tr.children("td").eq(0), table[i-1].shuttleNo);
                        setVal(tr.children("td").eq(1), table[i-1].taskNo);
                        setVal(tr.children("td").eq(2), table[i-1].sourceLocNo);
                        setVal(tr.children("td").eq(3), table[i-1].locNo);
                        setVal(tr.children("td").eq(4), table[i-1].maxCellVoltage$);
                        setVal(tr.children("td").eq(5), table[i-1].minCellVoltage$);
                        setVal(tr.children("td").eq(6), table[i-1].voltage$);
                        setVal(tr.children("td").eq(7), table[i-1].chargeCycleTimes);
                        setVal(tr.children("td").eq(8), table[i-1].surplusQuantity);
                        setVal(tr.children("td").eq(9), table[i-1].countQuantity);
                        setVal(tr.children("td").eq(10), table[i-1].statusSum ? table[i - 1].statusSum.mileage : '');
                        setVal(tr.children("td").eq(11), table[i-1].pakMk$);
                        setVal(tr.children("td").eq(12), table[i-1].currentLocNo);
                        setVal(tr.children("td").eq(13), table[i-1].token);
                        if (table[i-1].shuttleNo == parseInt($('input[name="shuttleSelect"]:checked').val())) {
                            $("#runSpeedText").text(table[i-1].runSpeed)
                            $("#chargeLineText").text(table[i-1].chargeLine + "%")
                        }
                    }
                } else if (res.code === 403){
                    window.location.href = baseUrl+"/login";
                }  else {
                    console.log(res.msg);
                }
            }
        });
    }
 
    // 穿梭车日志输出 -----------------------------------------------------------------------
    function getShuttleOutput() {
        $.ajax({
            url: baseUrl + "/shuttle/output/shuttle",
            headers: {'token': localStorage.getItem('token')},
            method: 'POST',
            success: function (res) {
                if (res.code === 200) {
                    shuttleOutput(res.data);
                } else if (res.code === 403) {
                    window.location.href = baseUrl + "/login";
                } else {
                    console.log(res.msg);
                }
            }
        })
    }
 
    // 任务指令下发
    function shuttleOperator(shuttleTaskMode) {
        http.post(baseUrl+"/shuttle/operator/shuttle", {
            shuttleNo: $('input[name="shuttleSelect"]:checked').val(),
            shuttleTaskMode: shuttleTaskMode,
            sourceLocNo: $("#sourceLocNo").val(),
            distLocNo: $("#distLocNo").val()
        }, function (res) {
            layer.msg(res.msg, {icon: 1});
        });
    }
 
 
    // ------------------------------------------------------------------------------------------------
 
    // 四向穿梭车信息表获取  ----- 表一
    function initShuttleStateTable(row) {
        let line;
        if (row === undefined){
            let one = $('#shuttle-state-table thead').height();
            let total = $('.shuttle-state').height();
            let count = total / one;
            count = parseInt(count) - 1;
            shuttleStateTableBlankRows = 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" +
                "       <td></td>\n" +
                "     </tr>\n";
        }
        $('#shuttle-state-table tbody').after(html);
    }
 
    // 穿梭车数据表获取  ----- 表二
    function initShuttleMsgTable(row) {
        let line;
        if (row === undefined){
            let one = $('#shuttle-msg-table thead').height();
            let total = $('.shuttle-msg').height();
            let count = total / one;
            count = parseInt(count) - 1;
            shuttleMsgTableBlankRows = 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";
        }
        $('#shuttle-msg-table tbody').after(html);
    }
 
    // 日志输出框
    function shuttleOutput(content){
        shuttleOutputDom.value += content;
        shuttleOutputDom.scrollTop = shuttleOutputDom.scrollHeight;
    }
 
    //四向穿梭车配置参数保存
    function shuttleParamSave() {
        $.ajax({
            url: baseUrl+ "/shuttle/runSpeed/" + $('input[name="shuttleSelect"]:checked').val(),
            headers: {'token': localStorage.getItem('token')},
            method: 'POST',
            data: {
                runSpeed: $("#runSpeed").val(),
                chargeLine: $("#chargeLine").val(),
            },
            success: function (res) {
                if (res.code === 200){
                    layer.msg("配置已保存", {icon: 1,});
                } else if (res.code === 403){
                    window.location.href = baseUrl+"/login";
                }  else {
                    console.log(res.msg);
                }
            }
        });
    }
 
    // 详情操作 -------------------------------------------------------------------------
    var layerDetl;
    $(document).on('dblclick ','#shuttle-msg-table tr', function () {
        var shuttleNo = $(this).children("td").eq(0).html();
        if (shuttleNo !== null && shuttleNo !== "") {
            layerDetl = layer.open({
                type: 1,
                title: false,
                shadeClose: true,
                offset: 'rt',
                anim: 5,
                shade: [0],
                area: ['340px', '255px'],
                closeBtn: 0,
                content: $("#shuttle-detl"),
                success: function(layero, index){
                    $.ajax({
                        url: baseUrl+ "/shuttle/table/shuttle/state",
                        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 (shuttleNo == table[i-1].shuttleNo) {
                                        $('#shuttleNo').val(shuttleNo);
                                        $('#workNo').val(table[i-1].taskNo);
                                        $('#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 () {
                    $('#shuttleNo').val("");
                    $('#workNo').val("");
                    $('#pakMk').val("");
                    $('#token').val("");
                }
            })
        }
    });
 
    $(document).on('click ','#cancel', function () {
        $('#shuttleNo').val("");
        $('#workNo').val("");
        $('#pakMk').val("");
        $('#token').val("");
        layer.close(layerDetl);
    })
 
 
</script>