From 7603004d9eed2904a823861e7cd6f5c2f0016500 Mon Sep 17 00:00:00 2001 From: Junjie <xjj@123> Date: 星期一, 04 三月 2024 16:19:03 +0800 Subject: [PATCH] #条码显示 --- src/main/java/com/zy/core/thread/BarcodeThread.java | 2 + src/main/java/com/zy/asrs/controller/ConsoleController.java | 12 ++++++ src/main/webapp/views/barcode.html | 81 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 95 insertions(+), 0 deletions(-) diff --git a/src/main/java/com/zy/asrs/controller/ConsoleController.java b/src/main/java/com/zy/asrs/controller/ConsoleController.java index f450cd2..e56629c 100644 --- a/src/main/java/com/zy/asrs/controller/ConsoleController.java +++ b/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); + } + /** * 鑾峰彇鍦板浘鏁版嵁 */ diff --git a/src/main/java/com/zy/core/thread/BarcodeThread.java b/src/main/java/com/zy/core/thread/BarcodeThread.java index b9b451e..2a8a648 100644 --- a/src/main/java/com/zy/core/thread/BarcodeThread.java +++ b/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(); } + } } diff --git a/src/main/webapp/views/barcode.html b/src/main/webapp/views/barcode.html new file mode 100644 index 0000000..8817623 --- /dev/null +++ b/src/main/webapp/views/barcode.html @@ -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> \ No newline at end of file -- Gitblit v1.9.1