| | |
| | | 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); |
| | | } |
| | | |
| | | /** |
| | | * 获取地图数据 |
| | | */ |
| | |
| | | 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(); |
| | | } |
| | |
| | | // e.printStackTrace(); |
| | | connect(); |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
New file |
| | |
| | | <!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> |