Junjie
2024-03-04 7603004d9eed2904a823861e7cd6f5c2f0016500
#条码显示
2个文件已修改
1个文件已添加
95 ■■■■■ 已修改文件
src/main/java/com/zy/asrs/controller/ConsoleController.java 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/thread/BarcodeThread.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/webapp/views/barcode.html 81 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/controller/ConsoleController.java
@@ -313,6 +313,18 @@
        return R.ok().add(JSON.toJSONString(new ArrayList<>(OutputQueue.BARCODE)));
    }
    @GetMapping("/barcode/list")
    public R barcodeList(){
        ArrayList<HashMap<String, Object>> list = new ArrayList<>();
        for (Slave slave : slaveProperties.getBarcode()) {
            HashMap<String, Object> map = new HashMap<>();
            BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, slave.getId());
            map.put("id", slave.getId());
            map.put("barcode", barcodeThread.getBarcode());
        }
        return R.ok().add(list);
    }
    /**
     * 获取地图数据
     */
src/main/java/com/zy/core/thread/BarcodeThread.java
@@ -50,6 +50,7 @@
            JSONObject jsonObject = new JSONObject();
            jsonObject.put("time", DateUtils.convert(new Date(), DateUtils.yyyyMMddHHmmss_F));
            jsonObject.put("barcode", barcode);
            jsonObject.put("id", slave.getId());
            if (OutputQueue.BARCODE.size() >= 32) {
                OutputQueue.BARCODE.poll();
            }
@@ -113,6 +114,7 @@
//                e.printStackTrace();
                connect();
            }
        }
    }
src/main/webapp/views/barcode.html
New file
@@ -0,0 +1,81 @@
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>条码器</title>
    <script type="text/javascript" src="../static/js/jquery/jquery-3.3.1.min.js"></script>
    <script type="text/javascript" src="../static/js/common.js"></script>
    <script type="text/javascript" src="../static/vue/js/vue.min.js"></script>
    <script type="text/javascript" src="../static/vue/element/element.js"></script>
    <style>
        .barcodeBox {
            display: flex;
            justify-content: flex-start;
        }
        .barcodeItem {
            margin-right: 50px;
        }
        .barcodeItem div{
            margin-top: 10px;
        }
    </style>
</head>
<body>
<div id="app">
    <div class="barcodeBox">
        <div class="barcodeItem" v-for="(item,index) in codeList" :key="index">
            <div>{{item.id}}号扫码器</div>
            <div>{{item.barcode}}</div>
        </div>
    </div>
</div>
<script>
    var app = new Vue({
        el: '#app',
        data: {
            codeList: [],//条码List
        },
        created() {
            this.init()
        },
        watch: {
        },
        methods: {
            init() {
                this.getBarcodeList() //获取条码
                this.consoleInterval = setInterval(() => {
                    this.getBarcodeList() //获取条码
                }, 1000)
            },
            getBarcodeList() {
                // 获取条码
                let that = this
                $.ajax({
                    url: baseUrl + "/console/barcode/list",
                    headers: {
                        'token': localStorage.getItem('token')
                    },
                    method: 'GET',
                    success: function(res) {
                        if (res.code === 200) {
                            that.codeList = res.data;
                        } else if (res.code === 403) {
                            parent.location.href = baseUrl + "/login";
                        } else {
                            that.$message({
                                message: res.msg,
                                type: 'error'
                            });
                        }
                    }
                });
            },
        }
    })
</script>
</body>
</html>