From 2989aae797ee82e202396e3c8ce353d6de9a3360 Mon Sep 17 00:00:00 2001
From: chen.llin <1442464845@qq.comm>
Date: 星期二, 30 十二月 2025 15:17:22 +0800
Subject: [PATCH] 宜和WCS配置初始化

---
 src/main/java/com/zy/core/model/protocol/StaProtocol.java |    2 
 src/main/resources/application-dev.yml                    |   20 +++---
 src/main/resources/application-prod.yml                   |   24 ++++----
 src/main/webapp/static/js/common.js                       |    2 
 pom.xml                                                   |    2 
 src/main/java/com/zy/core/thread/SiemensDevpThread.java   |   81 +++++++++++++++------------
 6 files changed, 70 insertions(+), 61 deletions(-)

diff --git a/pom.xml b/pom.xml
index 28247dc..c427b83 100644
--- a/pom.xml
+++ b/pom.xml
@@ -185,7 +185,7 @@
     </dependencies>
 
     <build>
-        <finalName>yhfzwcs</finalName>
+        <finalName>wcs</finalName>
         <plugins>
             <plugin>
                 <groupId>org.springframework.boot</groupId>
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 dfd1a4e..8644d80 100644
--- a/src/main/java/com/zy/core/model/protocol/StaProtocol.java
+++ b/src/main/java/com/zy/core/model/protocol/StaProtocol.java
@@ -88,7 +88,7 @@
     private boolean barcodeErr = false;
 
     // 璐х墿楂樺害 1.浣� 2.涓� 3.楂�
-    private short goodsHeight;
+    private short goodsHeight = 0;
 
     //鏁呴殰-----------------------------------------------------------------------
     private Boolean breakerErr = false; //鏂矾鍣ㄦ晠闅�
diff --git a/src/main/java/com/zy/core/thread/SiemensDevpThread.java b/src/main/java/com/zy/core/thread/SiemensDevpThread.java
index fffae0f..e36f719 100644
--- a/src/main/java/com/zy/core/thread/SiemensDevpThread.java
+++ b/src/main/java/com/zy/core/thread/SiemensDevpThread.java
@@ -41,32 +41,27 @@
     private Map<Integer, StaProtocol> station = new ConcurrentHashMap<>();
     private short heartBeatVal = 1;
     private StaError1 staError1;
-    public static final ArrayList<Integer> staNos;
 
-    static {
-        ArrayList<Integer> list = new ArrayList<>();
-        for (int i = 1; i <= 48; i++) {
-            list.add(1000 + i);
-        }
-        for (int i = 9; i <= 40; i++) {
-            list.add(1100 + i);
-        }
-        list.add(1701);
-        list.add(1702);
-        staNos = list; // 涓嶅彲淇敼锛屽畨鍏�
-    }
 
-    public static final ArrayList<Integer> BarcodeList = new ArrayList<Integer>() {{
-        add(1); add(2);add(3); add(4);add(5); add(6);add(7); add(8);
+
+    public static final ArrayList<Integer> staNos1= new ArrayList<Integer>() {{
+        add(1001);add(1002);add(1003);add(1004);add(1005);add(1006);add(1007);add(1008);add(1009);add(1010);
+        add(1011);add(1012);add(1013);add(1014);add(1015);add(1016);add(1017);add(1018);add(1019);
+        add(1020);add(1021);add(1022);add(1023);add(1024);add(1071);
     }};
-    public static final ArrayList<Integer> staNosErrList = new ArrayList<Integer>() {{
-        add(104); add(106);
+    public static final ArrayList<Integer> staNos2= new ArrayList<Integer>() {{
+        add(1025);add(1026);add(1027);add(1028);add(1029);add(1030);add(1031);add(1032);add(1033);
+        add(1034);add(1035);add(1036);add(1037);add(1039);add(1040);add(1041);add(1042);add(1043);
+        add(1044);add(1045);add(1046);add(1047);add(1048);
     }};
 
-    /**
-     * 鏉$爜鏁伴噺
-     */
-    private int barcodeSize = 2;
+
+    public static final ArrayList<Integer> BarcodeList1 = new ArrayList<Integer>() {{
+        add(1002); add(1004);add(1006); add(1008);
+    }};
+    public static final ArrayList<Integer> BarcodeList2 = new ArrayList<Integer>() {{
+        add(1041); add(1043);add(1045); add(1047);
+    }};
 
     /**
      * 鍏ュ嚭搴撴ā寮�
@@ -83,7 +78,20 @@
     }
 
     private ArrayList<Integer> getStaNo() {
-        return staNos;
+        if (slave.getId() == 1){
+            return staNos2;
+        }else {
+            return staNos1;
+        }
+
+    }
+    private ArrayList<Integer> getBarcodeList() {
+        if (slave.getId() == 1){
+            return BarcodeList2;
+        }else {
+            return BarcodeList1;
+        }
+
     }
 
     @Override
@@ -189,9 +197,9 @@
      * 璇诲彇鐘舵�� ====> 鏁村潡plc
      */
     private void read() {
-
+        ArrayList<Integer> staNos = getStaNo();
         // 绔欑偣淇℃伅
-        OperateResultExOne<byte[]> result = siemensS7Net.Read("DB101.0", (short) (8*8));
+        OperateResultExOne<byte[]> result = siemensS7Net.Read("DB101.0", (short) (staNos.size()*8));
         if (result.IsSuccess) {
             for (int i = 0; i < staNos.size(); i++) {
                 Integer siteId = staNos.get(i); // 绔欑偣缂栧彿
@@ -226,13 +234,13 @@
             News.error("SiemensCrn"+" - 4"+" - 璇诲彇杈撻�佺嚎plc鐘舵�佷俊鎭け璐� ===>> [id:{}] [ip:{}] [port:{}] [rack:{}] [slot:{}]", slave.getId(), slave.getIp(), slave.getPort(), slave.getRack(), slave.getSlot());
             return;
         }
-
+        ArrayList<Integer> barcodeList = getBarcodeList();
         // 鏉$爜鎵弿鍣�
-        OperateResultExOne<byte[]> barcodeResult = siemensS7Net.Read("DB101.400", (short) (BarcodeList.size() * 10));
+        OperateResultExOne<byte[]> barcodeResult = siemensS7Net.Read("DB101.860", (short) (barcodeList.size() * 8));
         if (barcodeResult.IsSuccess) {
-            for (int i = 0; i < BarcodeList.size(); i++) {
-                String barcode = siemensS7Net.getByteTransform().TransString(barcodeResult.Content,i*10 + 2,8, "UTF-8");
-                BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, BarcodeList.get(i));
+            for (int i = 0; i < barcodeList.size(); i++) {
+                String barcode = siemensS7Net.getByteTransform().TransString(barcodeResult.Content,i*8 ,8, "UTF-8");
+                BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, barcodeList.get(i));
                 if(!Cools.isEmpty(barcodeThread) && !barcodeThread.getBarcode().equals(barcode)) {
                     barcodeThread.setBarcode(barcode);
                 }
@@ -240,11 +248,13 @@
         }
 
         // 澶栧舰妫�娴�
-        OperateResultExOne<byte[]> resultErr = siemensS7Net.Read("DB101.430", (short) (staNosErrList.size() *4)); // 涓嶈繛缁紝澶氳涓棿涓�涓�
+        OperateResultExOne<byte[]> resultErr = siemensS7Net.Read("DB101.800", (short) (barcodeList.size() *6)); // 涓嶈繛缁紝澶氳涓棿涓�涓�
         if (resultErr.IsSuccess){
-            for (int i = 0;i<staNosErrList.size();i++){
-                boolean[] status = siemensS7Net.getByteTransform().TransBool(resultErr.Content, i*4, 1);
-                StaProtocol staProtocol = station.get(staNosErrList.get(i));
+            for (int i = 0;i<barcodeList.size();i++){
+                StaProtocol staProtocol = station.get(barcodeList.get(i));
+                short goodsHeight = siemensS7Net.getByteTransform().TransInt16(resultErr.Content, i * 4);
+                staProtocol.setGoodsHeight(goodsHeight);
+                boolean[] status = siemensS7Net.getByteTransform().TransBool(resultErr.Content, i*4+2, 1);
                 staProtocol.setFrontErr(status[0]);
                 staProtocol.setBackErr(status[1]);
                 staProtocol.setHighErr(status[2]);
@@ -253,8 +263,7 @@
                 staProtocol.setGroupSupportErr(status[5]);
                 staProtocol.setBarcodeErr(status[6]);
                 staProtocol.setWeightErr(status[7]);
-                short goodsHeight = siemensS7Net.getByteTransform().TransInt16(resultErr.Content, i * 4 + 2);
-                staProtocol.setGoodsHeight(goodsHeight);
+
             }
         }
 
@@ -312,7 +321,7 @@
         if (null == staProtocol) {
             return;
         }
-
+        ArrayList<Integer> staNos = getStaNo();
         int address = staNos.indexOf(staProtocol.getSiteId()) * 4;
 
         OperateResult write;
diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml
index e44e0cf..3100558 100644
--- a/src/main/resources/application-dev.yml
+++ b/src/main/resources/application-dev.yml
@@ -34,7 +34,7 @@
   enable: false
 
 wms:
-  url: 127.0.0.1:8080/yhfzwms
+  url: 127.0.0.1:8080/wms
 
 # 涓嬩綅鏈洪厤缃�
 wcs-slave:
@@ -351,50 +351,50 @@
   # 杈撻�佺嚎2 鍙嶅師鐐逛晶杈撻�佺嚎
   #涓滈潰
   devp[1]:
-    id: 1
+    id: 2
     ip: 10.10.10.140
     port: 102
     rack: 0
     slot: 0
     #涓滈潰
     # 鍏ュ簱鍙�5
-    inSta[4]:
+    inSta[0]:
       staNo: 1015
       barcode: ${wcs-slave.barcode[1].id}
       backSta: 1002
       led: ${wcs-slave.led[5].id}
     # 鍑哄簱鍙�5
-    outSta[4]:
+    outSta[0]:
       staNo: 1001
       led: ${wcs-slave.led[5].id}
     # 鍏ュ簱鍙�6
-    inSta[5]:
+    inSta[1]:
       staNo: 1017
       barcode: ${wcs-slave.barcode[1].id}
       backSta: 1004
       led: ${wcs-slave.led[5].id}
     # 鍑哄簱鍙�6
-    outSta[5]:
+    outSta[1]:
       staNo: 1003
       led: ${wcs-slave.led[5].id}
     # 鍏ュ簱鍙�7
-    inSta[6]:
+    inSta[2]:
       staNo: 1019
       barcode: ${wcs-slave.barcode[1].id}
       backSta: 1006
       led: ${wcs-slave.led[4].id}
     # 鍑哄簱鍙�7
-    outSta[6]:
+    outSta[2]:
       staNo: 1005
       led: ${wcs-slave.led[4].id}
     # 鍏ュ簱鍙�8
-    inSta[7]:
+    inSta[3]:
       staNo: 1021
       barcode: ${wcs-slave.barcode[1].id}
       backSta: 1008
       led: ${wcs-slave.led[3].id}
     # 鍑哄簱鍙�8
-    outSta[7]:
+    outSta[3]:
       staNo: 1007
       led: ${wcs-slave.led[3].id}
     # 绌烘澘鍏ュ簱鍙�1
diff --git a/src/main/resources/application-prod.yml b/src/main/resources/application-prod.yml
index deb7ec5..3100558 100644
--- a/src/main/resources/application-prod.yml
+++ b/src/main/resources/application-prod.yml
@@ -8,9 +8,9 @@
     name: @pom.build.finalName@
   datasource:
     driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver
-    url: jdbc:sqlserver://192.168.4.15:1433;databasename=yhfzasrs
+    url: jdbc:sqlserver://127.0.0.1:1433;databasename=yhfzasrs
     username: sa
-    password: sa@123
+    password: sa@12345
   mvc:
     static-path-pattern: /**
   redis:
@@ -34,7 +34,7 @@
   enable: false
 
 wms:
-  url: 127.0.0.1:8080/yhfzwms
+  url: 127.0.0.1:8080/wms
 
 # 涓嬩綅鏈洪厤缃�
 wcs-slave:
@@ -351,50 +351,50 @@
   # 杈撻�佺嚎2 鍙嶅師鐐逛晶杈撻�佺嚎
   #涓滈潰
   devp[1]:
-    id: 1
+    id: 2
     ip: 10.10.10.140
     port: 102
     rack: 0
     slot: 0
     #涓滈潰
     # 鍏ュ簱鍙�5
-    inSta[4]:
+    inSta[0]:
       staNo: 1015
       barcode: ${wcs-slave.barcode[1].id}
       backSta: 1002
       led: ${wcs-slave.led[5].id}
     # 鍑哄簱鍙�5
-    outSta[4]:
+    outSta[0]:
       staNo: 1001
       led: ${wcs-slave.led[5].id}
     # 鍏ュ簱鍙�6
-    inSta[5]:
+    inSta[1]:
       staNo: 1017
       barcode: ${wcs-slave.barcode[1].id}
       backSta: 1004
       led: ${wcs-slave.led[5].id}
     # 鍑哄簱鍙�6
-    outSta[5]:
+    outSta[1]:
       staNo: 1003
       led: ${wcs-slave.led[5].id}
     # 鍏ュ簱鍙�7
-    inSta[6]:
+    inSta[2]:
       staNo: 1019
       barcode: ${wcs-slave.barcode[1].id}
       backSta: 1006
       led: ${wcs-slave.led[4].id}
     # 鍑哄簱鍙�7
-    outSta[6]:
+    outSta[2]:
       staNo: 1005
       led: ${wcs-slave.led[4].id}
     # 鍏ュ簱鍙�8
-    inSta[7]:
+    inSta[3]:
       staNo: 1021
       barcode: ${wcs-slave.barcode[1].id}
       backSta: 1008
       led: ${wcs-slave.led[3].id}
     # 鍑哄簱鍙�8
-    outSta[7]:
+    outSta[3]:
       staNo: 1007
       led: ${wcs-slave.led[3].id}
     # 绌烘澘鍏ュ簱鍙�1
diff --git a/src/main/webapp/static/js/common.js b/src/main/webapp/static/js/common.js
index 37e6cea..2a45d7e 100644
--- a/src/main/webapp/static/js/common.js
+++ b/src/main/webapp/static/js/common.js
@@ -1,4 +1,4 @@
-var baseUrl = "/yhfzwcs";
+var baseUrl = "/wcs";
 
 // 璧嬪��
 function setVal(el, val) {

--
Gitblit v1.9.1