From 184980deb3f854a98eb112e7998875113ebbba9a Mon Sep 17 00:00:00 2001
From: lsh <lsh@163.com>
Date: 星期一, 28 四月 2025 17:10:39 +0800
Subject: [PATCH] *

---
 src/main/java/com/zy/common/model/MatDto.java               |   23 ++++++-
 src/main/java/com/zy/core/model/protocol/StaProtocol.java   |    1 
 src/main/java/com/zy/core/Slave.java                        |    5 +
 src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java |   13 +++
 src/main/java/com/zy/asrs/entity/ToWmsDTO.java              |    8 ++
 src/main/resources/application-prod.yml                     |    7 ++
 src/main/java/com/zy/core/DevpThread.java                   |    1 
 src/main/java/com/zy/core/thread/ScaleThread.java           |   56 +++++++++++++-----
 src/main/java/com/zy/core/thread/SiemensDevpThread.java     |   11 +++
 9 files changed, 103 insertions(+), 22 deletions(-)

diff --git a/src/main/java/com/zy/asrs/entity/ToWmsDTO.java b/src/main/java/com/zy/asrs/entity/ToWmsDTO.java
index 15d9b12..418f3a3 100644
--- a/src/main/java/com/zy/asrs/entity/ToWmsDTO.java
+++ b/src/main/java/com/zy/asrs/entity/ToWmsDTO.java
@@ -24,6 +24,7 @@
     //搴撲綅绫诲瀷
     private Integer locType;
     private Integer status;//绌烘弧鐗�
+    private Double grossWt;
 
 //    public ToWmsDTO(String barcode, Integer stationCode, Integer locType){
 //        this.barcode = barcode;
@@ -37,6 +38,13 @@
         this.status = status;
     }
 
+    public ToWmsDTO(Integer stationCode, Double grossWt, String barcode, Integer status) {
+        this.stationCode = stationCode;
+        this.grossWt = grossWt;
+        this.barcode = barcode;
+        this.status = status;
+    }
+
     public ToWmsDTO(){
 
     }
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 69a505a..775d5fc 100644
--- a/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
+++ b/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
@@ -194,7 +194,7 @@
                         String barcode = barcodeThread.getBarcode();
                         if (!Cools.isEmpty(barcode) && !barcode.equals("99999999")) {
                             // 璇锋眰wms鎺ュ彛锛岃幏鍙栧伐浣滃彿鍜岀洰鏍囧簱浣�
-                            ToWmsDTO toWmsDTO = new ToWmsDTO(barcode, staProtocol.getSiteId(), 0);
+                            ToWmsDTO toWmsDTO = new ToWmsDTO(staProtocol.getSiteId(),staProtocol.getGrossWt(),barcode, 0);
                             TaskWrk taskWrk1 = taskWrkService.selectOne(new EntityWrapper<TaskWrk>().eq("barcode", barcode));
                             if (!Cools.isEmpty(taskWrk1)) {
                                 log.info("鎵樼洏鐮侊細" + barcode + "浠诲姟妗e瓨鍦�");
@@ -1665,8 +1665,17 @@
                 }
                 // 鑾峰彇宸ヤ綔妗f暟鎹�
                 LedCommand ledCommand = new LedCommand();
-                //璇锋眰wms
 
+//
+//                ledCommand.setWorkNo(wrkMast.getWrkNo());
+//                ledCommand.setIoType(wrkMast.getIoType());
+//                ledCommand.setTitle("绌烘澘鍑哄簱");
+//                ledCommand.setEmptyMk(true);
+//                ledCommand.setSourceLocNo(wrkMast.getSourceLocNo());
+//                ledCommand.setLocNo(wrkMast.getLocNo());
+//                ledCommand.setStaNo(wrkMast.getStaNo());
+                MatDto matDto = new MatDto();
+                ledCommand.getMatDtos().add(matDto);
                 commands.add(ledCommand);
             }
             Set<Integer> workNos = wrkMasts.stream().map(WrkMast::getWrkNo).collect(Collectors.toSet());
diff --git a/src/main/java/com/zy/common/model/MatDto.java b/src/main/java/com/zy/common/model/MatDto.java
index e5b625b..8f28bdd 100644
--- a/src/main/java/com/zy/common/model/MatDto.java
+++ b/src/main/java/com/zy/common/model/MatDto.java
@@ -8,21 +8,34 @@
 @Data
 public class MatDto {
 
+
     // 鐗╂枡缂栧彿
-    private String matNo;
+    private String matnr;
 
     // 鐗╂枡鍚嶇О
-    private String maknx;
+    private String maktx;
+
+    // 搴撲綅瑙勬牸
+    private String specs;
 
     // 鐗╂枡鏁伴噺
     private Double count;
 
+    // 搴撲綅鏁伴噺
+    private Double total;
+
+    //宸ュ簭
+    private String sku;
+
     public MatDto() {
     }
 
-    public MatDto(String matNo, String maknx, Double count) {
-        this.matNo = matNo;
-        this.maknx = maknx;
+    public MatDto(String matnr, String maktx, String specs, Double count, Double total, String sku) {
+        this.matnr = matnr;
+        this.maktx = maktx;
+        this.specs = specs;
         this.count = count;
+        this.total = total;
+        this.sku = sku;
     }
 }
diff --git a/src/main/java/com/zy/core/DevpThread.java b/src/main/java/com/zy/core/DevpThread.java
index 2a8239e..ecdfafc 100644
--- a/src/main/java/com/zy/core/DevpThread.java
+++ b/src/main/java/com/zy/core/DevpThread.java
@@ -10,5 +10,6 @@
 
     void setPakMk(Integer siteId, boolean pakMk);
     void setPakMkWalk(Integer siteId, boolean pakMkWalk);
+    void setGrossWt(Integer siteId, Double grossWt);
 
 }
diff --git a/src/main/java/com/zy/core/Slave.java b/src/main/java/com/zy/core/Slave.java
index 5d38e9d..fbddf55 100644
--- a/src/main/java/com/zy/core/Slave.java
+++ b/src/main/java/com/zy/core/Slave.java
@@ -14,4 +14,9 @@
 
     private Integer port;
 
+    private Integer staNo;
+
+    // 杈撻�佺嚎plc缂栧彿
+    private Integer devpPlcId;
+
 }
diff --git a/src/main/java/com/zy/core/model/protocol/StaProtocol.java b/src/main/java/com/zy/core/model/protocol/StaProtocol.java
index cfaf3d8..3bf92ad 100644
--- a/src/main/java/com/zy/core/model/protocol/StaProtocol.java
+++ b/src/main/java/com/zy/core/model/protocol/StaProtocol.java
@@ -84,6 +84,7 @@
 
     //鎸囦护ID
     private Integer commandId;
+    private Double grossWt;
 
     public BasDevp toSqlModel(){
         BasDevp basDevp = new BasDevp();
diff --git a/src/main/java/com/zy/core/thread/ScaleThread.java b/src/main/java/com/zy/core/thread/ScaleThread.java
index 0dcae31..2b7e65d 100644
--- a/src/main/java/com/zy/core/thread/ScaleThread.java
+++ b/src/main/java/com/zy/core/thread/ScaleThread.java
@@ -7,9 +7,13 @@
 import com.zy.asrs.entity.BasDevp;
 import com.zy.asrs.service.BasDevpService;
 import com.zy.asrs.service.DeviceErrorService;
+import com.zy.core.DevpThread;
 import com.zy.core.Slave;
 import com.zy.core.ThreadHandler;
 import com.zy.core.cache.OutputQueue;
+import com.zy.core.cache.SlaveConnection;
+import com.zy.core.enums.SlaveType;
+import com.zy.core.model.protocol.StaProtocol;
 import lombok.Data;
 import lombok.extern.slf4j.Slf4j;
 
@@ -52,25 +56,47 @@
                     if (!Cools.isEmpty(s) && s.startsWith("=")) {
                         scale = Double.parseDouble(s.substring(1));
 
+//                        String substring = s.substring(1);
+//                        String s1 = new StringBuilder(substring).reverse().toString();//閫嗗簭
+//                        scale = Double.parseDouble(s1);
                         //灏嗙О閲嶉噸閲忓啓鍏ヨ澶囧熀纭�鏁版嵁涓殑gross_wt瀛楁
                         if(scale > 20) {
-                            BasDevpService basDevpService = SpringUtils.getBean(BasDevpService.class);
-                            Integer staNo = slave.getId() == 1 ? 101 : 201;
-                            BasDevp basDevp = basDevpService.selectById(staNo);
-                            if(!Cools.isEmpty(basDevp)) {
-                                basDevp.setGrossWt(scale);
-                                if (null != basDevpService && !basDevpService.updateById(basDevp)) {
-                                    throw new Exception("鏇存柊鏁版嵁搴撴暟鎹け璐�");
+                            try{
+                                // 鑾峰彇绔欎俊鎭�
+                                DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, slave.getDevpPlcId());
+                                StaProtocol staProtocol = devpThread.getStation().get(slave.getStaNo());
+                                if (staProtocol != null) {
+                                    devpThread.setGrossWt(staProtocol.getSiteId(), scale);
+
+                                    JSONObject jsonObject = new JSONObject();
+                                    jsonObject.put("time", DateUtils.convert(new Date(), DateUtils.yyyyMMddHHmmss_F));
+                                    jsonObject.put("id", slave.getStaNo());
+                                    jsonObject.put("scale", scale);
+                                    if (OutputQueue.SCALE.size() >= 32) {
+                                        OutputQueue.SCALE.poll();
+                                    }
+                                    OutputQueue.SCALE.offer(jsonObject);
                                 }
-                                JSONObject jsonObject = new JSONObject();
-                                jsonObject.put("time", DateUtils.convert(new Date(), DateUtils.yyyyMMddHHmmss_F));
-                                jsonObject.put("id", staNo);
-                                jsonObject.put("scale", scale);
-                                if (OutputQueue.SCALE.size() >= 32) {
-                                    OutputQueue.SCALE.poll();
-                                }
-                                OutputQueue.SCALE.offer(jsonObject);
+                            } catch (Exception e){
+                                log.error("绉伴噸妯″潡寮傚父"+e.getMessage());
                             }
+//                            BasDevpService basDevpService = SpringUtils.getBean(BasDevpService.class);
+//                            BasDevp basDevp = basDevpService.selectById(slave.getStaNo());
+//                            if(!Cools.isEmpty(basDevp)) {
+//                                basDevp.setGrossWt(scale);
+//                                if (null != basDevpService && !basDevpService.updateById(basDevp)) {
+//                                    throw new Exception("鏇存柊鏁版嵁搴撴暟鎹け璐�");
+//                                }
+//                                JSONObject jsonObject = new JSONObject();
+//                                jsonObject.put("time", DateUtils.convert(new Date(), DateUtils.yyyyMMddHHmmss_F));
+//                                jsonObject.put("id", slave.getStaNo());
+//                                jsonObject.put("scale", scale);
+//                                if (OutputQueue.SCALE.size() >= 32) {
+//                                    OutputQueue.SCALE.poll();
+//                                }
+//                                OutputQueue.SCALE.offer(jsonObject);
+//
+//                            }
                         }
                     }
                 }
diff --git a/src/main/java/com/zy/core/thread/SiemensDevpThread.java b/src/main/java/com/zy/core/thread/SiemensDevpThread.java
index a7ddb53..6972c16 100644
--- a/src/main/java/com/zy/core/thread/SiemensDevpThread.java
+++ b/src/main/java/com/zy/core/thread/SiemensDevpThread.java
@@ -412,6 +412,17 @@
         }
     }
 
+    /**
+     * 璁剧疆鍏ュ簱鏍囪
+     */
+    @Override
+    public void setGrossWt(Integer siteId, Double grossWt) {
+        StaProtocol staProtocol = station.get(siteId);
+        if (null != staProtocol) {
+            staProtocol.setGrossWt(grossWt);
+        }
+    }
+
     @Override
     public void close() {
         siemensS7Net.ConnectClose();
diff --git a/src/main/resources/application-prod.yml b/src/main/resources/application-prod.yml
index 76025a1..7bc5054 100644
--- a/src/main/resources/application-prod.yml
+++ b/src/main/resources/application-prod.yml
@@ -120,6 +120,13 @@
     port: 51236
     ip: 10.10.10.52
     id: 3
+    # 纾呯Г
+  scale[0]:
+    id: 1
+    ip: 10.10.10.207
+    port: 5005
+    staNo: 281
+    devpPlcId: 1
   crn[0]: #鍫嗗灈鏈�1
     ip: 192.168.4.250
     id: 1

--
Gitblit v1.9.1