From 429bf2ffe5bf78bb35347a051e45f329ab0e79d5 Mon Sep 17 00:00:00 2001 From: zyx <zyx123456> Date: 星期二, 06 二月 2024 18:58:19 +0800 Subject: [PATCH] #AGV 输送线扫码器扫描 --- src/main/java/com/zy/asrs/controller/AgvController.java | 7 ++ src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java | 79 ++++++++++++++++++++++++-- src/main/java/com/zy/core/MainProcess.java | 2 src/main/resources/application.yml | 80 +++++++++++++------------- 4 files changed, 121 insertions(+), 47 deletions(-) diff --git a/src/main/java/com/zy/asrs/controller/AgvController.java b/src/main/java/com/zy/asrs/controller/AgvController.java index d20a6bc..68995d3 100644 --- a/src/main/java/com/zy/asrs/controller/AgvController.java +++ b/src/main/java/com/zy/asrs/controller/AgvController.java @@ -29,7 +29,12 @@ return r.add(map); - //return R.ok(); + } + + @PostMapping("/container/completed") + public R containerCompleted(@RequestBody JSONObject jsonObject){ + + return R.ok(); } } diff --git a/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java b/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java index d6ad9cb..6eb8c41 100644 --- a/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java +++ b/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java @@ -2739,13 +2739,38 @@ return false; } + //閫氱煡WMS褰撳墠鎷f枡绔欑偣淇℃伅 + private boolean agvCureentCall(String staNo, String barcode) { + try { + HashMap<String, Object> param = new HashMap<>(); + param.put("devNo", staNo); + param.put("containerCode", barcode); + String response = new HttpHandler.Builder() + .setUri(wmsUrl) + .setPath("/rpc/current/containerCode") + .setJson(JSON.toJSONString(param)) + .build() + .doPost(); + JSONObject jsonObject = JSON.parseObject(response); + News.info("鎮寕绾匡紝WMS杩斿洖缁撴灉锛�" + jsonObject); + Integer code = jsonObject.getInteger("code"); + if (code.equals(200)) {//鍛煎彨AGV + return true; + } + } catch (Exception e) { + e.printStackTrace(); + TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); + } + return false; + } + /** * AGV琛ヨ揣(鎮寕绾块�氱煡AGV鍙栬揣) */ public void agvRestockIntoByHangingWire() { try { //妫�娴�350鍜�351鎵爜鍣� - int[] barcodeStaNo = {11, 12};//11 => 350绔欐壂鐮佸櫒,12 => 351绔欐壂鐮佸櫒 + int[] barcodeStaNo = {11, 12,14,16,18,20};//11 => 350绔欐壂鐮佸櫒,12 => 351绔欐壂鐮佸櫒 for (int staNo : barcodeStaNo) { // 鑾峰彇鏉$爜鎵弿浠俊鎭� BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, staNo); @@ -2763,13 +2788,13 @@ agvStaNo = "303-1"; } else if(staNo == 12){ agvStaNo = "304-1"; - } else if(staNo == 13){ - agvStaNo = "311-1"; } else if(staNo == 14){ - agvStaNo = "313-1"; - } else if(staNo == 15){ - agvStaNo = "315-1"; + agvStaNo = "311-1"; } else if(staNo == 16){ + agvStaNo = "313-1"; + } else if(staNo == 18){ + agvStaNo = "315-1"; + } else if(staNo == 20){ agvStaNo = "317-1"; } //閫氱煡AGV鍙栬揣 @@ -2785,6 +2810,48 @@ } } + /** + * AGV鎷f枡绔欑偣淇℃伅 + */ + public void agvCurrentContainerCodeInfoWire() { + try { + //妫�娴�350鍜�351鎵爜鍣� + int[] barcodeStaNo = {13, 15,17,19};//11 => 350绔欐壂鐮佸櫒,12 => 351绔欐壂鐮佸櫒 + for (int staNo : barcodeStaNo) { + // 鑾峰彇鏉$爜鎵弿浠俊鎭� + BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, staNo); + if (barcodeThread == null) { + continue; + } + String barcode = barcodeThread.getBarcode(); + if (!Cools.isEmpty(barcode)) { + if (barcode.contains("NoRead")) { + continue; + } + + String agvStaNo = null; + if (staNo == 13) { + agvStaNo = "310-1"; + } else if(staNo == 15){ + agvStaNo = "312-1"; + } else if(staNo == 17){ + agvStaNo = "314-1"; + } else if(staNo == 19){ + agvStaNo = "316-1"; + } + //閫氱煡AGV鍙栬揣 + boolean result = agvRestockCall(agvStaNo, barcode); + if (result) { + barcodeThread.setBarcode(""); + } + log.info(barcodeThread.getSlave().getId() + "鍙锋壂鐮佸櫒锛岄�氱煡AGV鍙栬揣锛屾潯鐮佸彿锛�" + barcode); + } + } + } catch (Exception e) { + e.printStackTrace(); + } + } + // 300绔欐嫞鏂� public void pick300() { try { diff --git a/src/main/java/com/zy/core/MainProcess.java b/src/main/java/com/zy/core/MainProcess.java index 261ec36..411b4c0 100644 --- a/src/main/java/com/zy/core/MainProcess.java +++ b/src/main/java/com/zy/core/MainProcess.java @@ -82,6 +82,8 @@ mainService.agvRestockInto(); // AGV琛ヨ揣(鎮寕绾块�氱煡AGV鍙栬揣) mainService.agvRestockIntoByHangingWire(); + // AGV淇℃伅鏇存柊 + mainService.agvCurrentContainerCodeInfoWire(); // 300绔欐嫞鏂� mainService.pick300(); // 鍑哄簱 ===>> 宸ヤ綔妗d俊鎭啓鍏ed鏄剧ず鍣� diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 36230aa..7e94169 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -394,46 +394,46 @@ id: 12 ip: 10.10.10.224 port: 2002 -# # 鏉$爜鎵弿浠� -# barcode[12]: -# id: 12 -# ip: 10.10.10.224 -# port: 2002 -# # 鏉$爜鎵弿浠� -# barcode[13]: -# id: 12 -# ip: 10.10.10.224 -# port: 2002 -# # 鏉$爜鎵弿浠� -# barcode[14]: -# id: 12 -# ip: 10.10.10.224 -# port: 2002 -# # 鏉$爜鎵弿浠� -# barcode[15]: -# id: 12 -# ip: 10.10.10.224 -# port: 2002 -# # 鏉$爜鎵弿浠� -# barcode[16]: -# id: 12 -# ip: 10.10.10.224 -# port: 2002 -# # 鏉$爜鎵弿浠� -# barcode[17]: -# id: 12 -# ip: 10.10.10.224 -# port: 2002 -# # 鏉$爜鎵弿浠� -# barcode[18]: -# id: 12 -# ip: 10.10.10.224 -# port: 2002 -# # 鏉$爜鎵弿浠� -# barcode[19]: -# id: 12 -# ip: 10.10.10.224 -# port: 2002 + # 鏉$爜鎵弿浠� + barcode[12]: + id: 13 + ip: 10.10.10.233 + port: 2002 + # 鏉$爜鎵弿浠� + barcode[13]: + id: 14 + ip: 10.10.10.232 + port: 2002 + # 鏉$爜鎵弿浠� + barcode[14]: + id: 15 + ip: 10.10.10.231 + port: 2002 + # 鏉$爜鎵弿浠� + barcode[15]: + id: 16 + ip: 10.10.10.230 + port: 2002 + # 鏉$爜鎵弿浠� + barcode[16]: + id: 17 + ip: 10.10.10.229 + port: 2002 + # 鏉$爜鎵弿浠� + barcode[17]: + id: 18 + ip: 10.10.10.228 + port: 2002 + # 鏉$爜鎵弿浠� + barcode[18]: + id: 19 + ip: 10.10.10.227 + port: 2002 + # 鏉$爜鎵弿浠� + barcode[19]: + id: 20 + ip: 10.10.10.226 + port: 2002 # LED1 led[0]: -- Gitblit v1.9.1