From d0a82572324e161d140f17321bcb716233e885ea Mon Sep 17 00:00:00 2001 From: zwl <1051256694@qq.com> Date: 星期一, 07 七月 2025 08:37:02 +0800 Subject: [PATCH] 新增称重功能 --- src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java | 6 + src/main/java/com/zy/asrs/entity/param/StorageEscalationParam.java | 3 src/main/resources/application-prod.yml | 162 ++++++---------------------------------- src/main/java/com/zy/core/thread/ScaleThread.java | 7 - src/main/java/com/zy/core/ServerBootstrap.java | 14 +- 5 files changed, 42 insertions(+), 150 deletions(-) diff --git a/src/main/java/com/zy/asrs/entity/param/StorageEscalationParam.java b/src/main/java/com/zy/asrs/entity/param/StorageEscalationParam.java index ab62548..d74120a 100644 --- a/src/main/java/com/zy/asrs/entity/param/StorageEscalationParam.java +++ b/src/main/java/com/zy/asrs/entity/param/StorageEscalationParam.java @@ -16,4 +16,7 @@ private int LocType = 0; //绔欑偣 private int TerminalNo = 0; + + //閲嶉噺 + private double weight = 0.0; } 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 5ced3e9..8684907 100644 --- a/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java +++ b/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java @@ -38,6 +38,7 @@ import com.zy.core.properties.SlaveProperties; import com.zy.core.thread.BarcodeThread; import com.zy.core.thread.LedThread; +import com.zy.core.thread.ScaleThread; import com.zy.core.thread.SiemensDevpThread; import com.zy.system.entity.Config; import com.zy.system.service.ConfigService; @@ -340,6 +341,7 @@ errMsg = "鎵爜澶辫触"; back = true; } + // 鍒ゆ柇鏄惁婊¤冻鍏ュ簱鏉′欢 if (staProtocol.isAutoing() && staProtocol.isLoading() && staProtocol.isInEnable() @@ -374,6 +376,10 @@ } } + ScaleThread scaleThread = (ScaleThread) SlaveConnection.get(SlaveType.Scale, inSta.getBarcode()); + if(scaleThread != null) { + storageEscalationParam.setWeight(scaleThread.getScale()); + } storageEscalationParam.setBoxNo(BoxNo); //鏄惁婊℃澘 1婊℃澘 0绌烘澘 diff --git a/src/main/java/com/zy/core/ServerBootstrap.java b/src/main/java/com/zy/core/ServerBootstrap.java index c840a5b..e06e776 100644 --- a/src/main/java/com/zy/core/ServerBootstrap.java +++ b/src/main/java/com/zy/core/ServerBootstrap.java @@ -102,13 +102,13 @@ new Thread(ledThread).start(); SlaveConnection.put(SlaveType.Led, led.getId(), ledThread); } -// // 鍒濆鍖栫绉ょ嚎绋� -// log.info("鍒濆鍖栫绉ょ嚎绋�..................................................."); -// for (Slave scale : slaveProperties.getScale()) { -// ScaleThread scaleThread = new ScaleThread(scale); -// new Thread(scaleThread).start(); -// SlaveConnection.put(SlaveType.Scale, scale.getId(), scaleThread); -// } + // 鍒濆鍖栫绉ょ嚎绋� + log.info("鍒濆鍖栫绉ょ嚎绋�..................................................."); + for (Slave scale : slaveProperties.getScale()) { + ScaleThread scaleThread = new ScaleThread(scale); + new Thread(scaleThread).start(); + SlaveConnection.put(SlaveType.Scale, scale.getId(), scaleThread); + } } diff --git a/src/main/java/com/zy/core/thread/ScaleThread.java b/src/main/java/com/zy/core/thread/ScaleThread.java index 0dcae31..b8e0dd2 100644 --- a/src/main/java/com/zy/core/thread/ScaleThread.java +++ b/src/main/java/com/zy/core/thread/ScaleThread.java @@ -49,7 +49,8 @@ byte[] read = read(8, 100); if (null != read) { String s = new String(read); - if (!Cools.isEmpty(s) && s.startsWith("=")) { + s=s.substring(1); + if (!Cools.isEmpty(s) && s.startsWith("+")) { scale = Double.parseDouble(s.substring(1)); //灏嗙О閲嶉噸閲忓啓鍏ヨ澶囧熀纭�鏁版嵁涓殑gross_wt瀛楁 @@ -94,13 +95,9 @@ dataOutputStream = new DataOutputStream(socket.getOutputStream()); dataInputStream = new DataInputStream(socket.getInputStream()); // log.info("鏉$爜鎵弿浠繛鎺ユ垚鍔� ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort()); - DeviceErrorService deviceErrorService = SpringUtils.getBean(DeviceErrorService.class); - deviceErrorService.deleteDeviceError("scale", slave.getId()); } catch (Exception e) { socket = null; log.error("纾呯Г杩炴帴澶辫触锛侊紒锛� ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort()); - DeviceErrorService deviceErrorService = SpringUtils.getBean(DeviceErrorService.class); - deviceErrorService.addDeviceError("scale", slave.getId(), "纾呯Г杩炴帴澶辫触"); return false; } return true; diff --git a/src/main/resources/application-prod.yml b/src/main/resources/application-prod.yml index 84dff2e..393a917 100644 --- a/src/main/resources/application-prod.yml +++ b/src/main/resources/application-prod.yml @@ -169,6 +169,7 @@ backSta: 1015 barcode: ${wcs-slave.barcode[0].id} led: ${wcs-slave.led[2].id} + scale: ${wcs-slave.scale[0].id} outSta[0]: #鍑哄簱鍙�1 staNo: 1019 outSta[1]: #鍑哄簱鍙�2 @@ -188,6 +189,7 @@ backSta: 2006 barcode: ${wcs-slave.barcode[1].id} led: ${wcs-slave.led[8].id} + scale: ${wcs-slave.scale[1].id} outSta[0]: #鍑哄簱鍙�1 staNo: 2001 outSta[1]: #鍑哄簱鍙�2 @@ -203,6 +205,7 @@ backSta: 1051 barcode: ${wcs-slave.barcode[2].id} led: ${wcs-slave.led[0].id} + scale: ${wcs-slave.scale[2].id} inSta[1]: #绌烘澘鍏ュ簱鍙�0 staNo: 1058 outSta[0]: #鍑哄簱鍙�1 @@ -221,6 +224,7 @@ backSta: 2055 barcode: ${wcs-slave.barcode[3].id} led: ${wcs-slave.led[4].id} + scale: ${wcs-slave.scale[3].id} outSta[0]: #鍑哄簱鍙�1 staNo: 1053 outSta[1]: #鍑哄簱鍙�1 @@ -331,143 +335,25 @@ port: 5005 devpPlcId: ${wcs-slave.devp[1].id} staArr: 2018 -# crn[0]: #鍫嗗灈鏈�1 -# rack: 0 -# offset: 2 #鍋忕Щ閲忥紝褰撳爢鍨涙満绔欑偣鍒楀彿=1鏃讹紝鍋忕Щ閲�=2 -# port: 102 -# crnOutStn[0]: #鍫嗗灈鏈哄嚭搴撶珯鐐� -# staNo: 101 -# row: 2 -# bay: 1 -# lev: 1 -# devpPlcId: ${wcs-slave.devp[0].id} -# ip: 192.168.1.100 -# crnInStn[0]: #鍫嗗灈鏈哄叆搴撶珯鐐�1 -# staNo: 100 -# row: 1 -# bay: 1 -# lev: 1 -# devpPlcId: ${wcs-slave.devp[0].id} -# id: 1 -# slot: 0 -# demo: false -# crn[1]: #鍫嗗灈鏈�2 -# rack: 0 -# offset: 2 #鍋忕Щ閲忥紝褰撳爢鍨涙満绔欑偣鍒楀彿=1鏃讹紝鍋忕Щ閲�=2 -# port: 102 -# crnOutStn[0]: #鍫嗗灈鏈哄嚭搴撶珯鐐� -# staNo: 103 -# row: 5 -# bay: 1 -# lev: 1 -# devpPlcId: ${wcs-slave.devp[0].id} -# ip: 192.168.1.110 -# crnInStn[0]: #鍫嗗灈鏈哄叆搴撶珯鐐�1 -# staNo: 102 -# row: 4 -# bay: 1 -# lev: 1 -# devpPlcId: ${wcs-slave.devp[0].id} -# id: 2 -# slot: 0 -# demo: false -# barcode[3]: #鏉$爜鎵弿浠�4 -# port: 51236 -# ip: 10.10.10.52 -# id: 4 -# barcode[2]: #鏉$爜鎵弿浠�3 -# port: 51236 -# ip: 10.10.10.52 -# id: 3 -# -# barcode[1]: #鏉$爜鎵弿浠�2 -# port: 51236 -# ip: 10.10.10.52 -# id: 2 -# -# devp[0]: #杈撻�佺嚎 -# emptyInSta[2]: #绌烘澘鍏ュ簱鍙�3 -# staNo: 104 -# emptyInSta[1]: #绌烘澘鍏ュ簱鍙�2 -# staNo: 102 -# rack: 0 -# emptyInSta[0]: #绌烘澘鍏ュ簱鍙�1 -# staNo: 100 -# ip: 192.168.1.140 -# outSta[4]: #鍑哄簱鍙�5 -# staNo: 104 -# outSta[3]: #鍑哄簱鍙�4 -# staNo: 103 -# outSta[6]: #鍑哄簱鍙�7 -# staNo: 106 -# slot: 0 -# outSta[5]: #鍑哄簱鍙�6 -# staNo: 105 -# outSta[0]: #鍑哄簱鍙�1 -# staNo: 100 -# outSta[2]: #鍑哄簱鍙�3 -# staNo: 102 -# emptyInSta[3]: #绌烘澘鍏ュ簱鍙�4 -# staNo: 106 -# outSta[1]: #鍑哄簱鍙�2 -# staNo: 101 -# inSta[2]: -# staNo: 104 -# barcode: ${wcs-slave.barcode[2].id} -# inSta[3]: -# staNo: 106 -# barcode: ${wcs-slave.barcode[3].id} -# port: 102 -# outSta[7]: #鍑哄簱鍙�8 -# staNo: 107 -# inSta[0]: #鍏ュ簱鍙�1 -# staNo: 100 -# barcode: ${wcs-slave.barcode[0].id} -# inSta[1]: #鍏ュ簱鍙�2 -# staNo: 102 -# barcode: ${wcs-slave.barcode[1].id} -# id: 1 -# -# -# crn[2]: #鍫嗗灈鏈�3 -# rack: 0 -# offset: 2 #鍋忕Щ閲忥紝褰撳爢鍨涙満绔欑偣鍒楀彿=1鏃讹紝鍋忕Щ閲�=2 -# port: 102 -# crnOutStn[0]: #鍫嗗灈鏈哄嚭搴撶珯鐐� -# staNo: 105 -# row: 9 -# bay: 1 -# lev: 1 -# devpPlcId: ${wcs-slave.devp[0].id} -# ip: 192.168.1.120 -# crnInStn[0]: #鍫嗗灈鏈哄叆搴撶珯鐐�1 -# staNo: 104 -# row: 8 -# bay: 1 -# lev: 1 -# devpPlcId: ${wcs-slave.devp[0].id} -# id: 3 -# slot: 0 -# demo: false -# crn[3]: #鍫嗗灈鏈�4 -# rack: 0 -# offset: 2 #鍋忕Щ閲忥紝褰撳爢鍨涙満绔欑偣鍒楀彿=1鏃讹紝鍋忕Щ閲�=2 -# port: 102 -# crnOutStn[0]: #鍫嗗灈鏈哄嚭搴撶珯鐐� -# staNo: 107 -# row: 12 -# bay: 1 -# lev: 1 -# devpPlcId: ${wcs-slave.devp[0].id} -# ip: 192.168.1.130 -# crnInStn[0]: #鍫嗗灈鏈哄叆搴撶珯鐐�1 -# staNo: 106 -# row: 11 -# bay: 1 -# lev: 1 -# devpPlcId: ${wcs-slave.devp[0].id} -# id: 4 -# slot: 0 -# demo: false + # 纾呯Г 鍗婃垚鍝佷竴妤� 192.168.110.24 + scale[0]: + id: 1 + ip: 192.168.110.24 + port: 5005 + # 纾呯Г 鍗婃垚鍝�2妤� 192.168.110.23 + scale[1]: + id: 2 + ip: 192.168.110.23 + port: 5005 + # 纾呯Г 鎴愬搧搴撲竴妤�192.168.110.21 + scale[2]: + id: 3 + ip: 192.168.110.21 + port: 5005 + # 纾呯Г 鎴愬搧搴�2妤� 192.168.110.22 + scale[3]: + id: 4 + ip: 192.168.110.22 + port: 5005 -- Gitblit v1.9.1