From ae07cd92f46b88bf034c7d9d0b96b3a5e83fdc98 Mon Sep 17 00:00:00 2001
From: ZengTao <2773468879@qq.com>
Date: 星期二, 20 五月 2025 16:29:00 +0800
Subject: [PATCH] 仓储,上片,卧理修改OPC为S7通讯

---
 hangzhoumesParent/moduleService/CacheGlassModule/src/main/java/com/mes/config/S7Config.java          |   34 +++
 hangzhoumesParent/moduleService/CacheGlassModule/src/main/java/com/mes/s7/entity/S7DataWLTwo.java    |   55 +++++
 hangzhoumesParent/moduleService/LoadGlassModule/src/main/java/com/mes/config/S7Config.java           |   28 ++
 hangzhoumesParent/moduleService/LoadGlassModule/src/main/java/com/mes/s7/entity/S7DataSP.java        |   44 ++++
 hangzhoumesParent/moduleService/CacheGlassModule/src/main/java/com/mes/s7/entity/S7DataMBOne.java    |   37 +++
 hangzhoumesParent/moduleService/CacheGlassModule/src/main/java/com/mes/s7/entity/S7DataWLOne.java    |   52 +++++
 hangzhoumesParent/moduleService/CacheGlassModule/src/main/java/com/mes/job/OpcCacheGlassNewTask.java |   89 ++++++--
 hangzhoumesParent/moduleService/GlassStorageModule/src/main/java/com/mes/config/S7Config.java        |   21 ++
 hangzhoumesParent/moduleService/GlassStorageModule/src/main/java/com/mes/job/RawGlassTask.java       |   87 ++++----
 hangzhoumesParent/moduleService/LoadGlassModule/src/main/java/com/mes/job/OpcLoadGlassTask.java      |   43 +++
 hangzhoumesParent/moduleService/GlassStorageModule/src/main/java/com/mes/s7/entity/S7Data.java       |   89 ++++++++
 11 files changed, 509 insertions(+), 70 deletions(-)

diff --git a/hangzhoumesParent/moduleService/CacheGlassModule/src/main/java/com/mes/config/S7Config.java b/hangzhoumesParent/moduleService/CacheGlassModule/src/main/java/com/mes/config/S7Config.java
new file mode 100644
index 0000000..c6caf02
--- /dev/null
+++ b/hangzhoumesParent/moduleService/CacheGlassModule/src/main/java/com/mes/config/S7Config.java
@@ -0,0 +1,34 @@
+package com.mes.config;
+
+import com.github.xingshuangs.iot.protocol.s7.enums.EPlcType;
+import com.github.xingshuangs.iot.protocol.s7.serializer.S7Serializer;
+import com.github.xingshuangs.iot.protocol.s7.service.S7PLC;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * @Author : zhoush
+ * @Date: 2025/4/30 13:50
+ * @Description:
+ */
+@Configuration
+public class S7Config {
+    @Bean(name = "s7SerializerWLOne")
+    public S7Serializer s7SerializerWLOne() {
+        S7PLC s7PLC = new S7PLC(EPlcType.S1200, "192.168.10.15");
+        return S7Serializer.newInstance(s7PLC);
+    }
+
+    @Bean(name = "s7SerializerWLTwo")
+    public S7Serializer s7SerializerWLTwo() {
+        S7PLC s7PLC = new S7PLC(EPlcType.S1200, "192.168.10.21");
+        return S7Serializer.newInstance(s7PLC);
+    }
+
+    @Bean(name = "s7SerializerMBOne")
+    public S7Serializer s7SerializerMBOne() {
+        S7PLC s7PLC = new S7PLC(EPlcType.S1200, "192.168.10.58");
+        return S7Serializer.newInstance(s7PLC);
+    }
+
+}
diff --git a/hangzhoumesParent/moduleService/CacheGlassModule/src/main/java/com/mes/job/OpcCacheGlassNewTask.java b/hangzhoumesParent/moduleService/CacheGlassModule/src/main/java/com/mes/job/OpcCacheGlassNewTask.java
index 6189fd2..1a09f85 100644
--- a/hangzhoumesParent/moduleService/CacheGlassModule/src/main/java/com/mes/job/OpcCacheGlassNewTask.java
+++ b/hangzhoumesParent/moduleService/CacheGlassModule/src/main/java/com/mes/job/OpcCacheGlassNewTask.java
@@ -5,6 +5,7 @@
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
+import com.github.xingshuangs.iot.protocol.s7.serializer.S7Serializer;
 import com.kangaroohy.milo.model.ReadWriteEntity;
 import com.kangaroohy.milo.service.MiloService;
 import com.mes.common.config.Const;
@@ -22,11 +23,15 @@
 import com.mes.opctask.entity.EdgStorageDeviceTaskHistory;
 import com.mes.opctask.service.EdgStorageDeviceTaskHistoryService;
 import com.mes.opctask.service.EdgStorageDeviceTaskService;
+import com.mes.s7.entity.S7DataMBOne;
+import com.mes.s7.entity.S7DataWLOne;
+import com.mes.s7.entity.S7DataWLTwo;
 import com.mes.sysconfig.service.SysConfigService;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang.StringUtils;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Component;
 
@@ -68,6 +73,18 @@
     @Resource
     SysConfigService sysConfigService;
 
+    @Autowired
+    @Qualifier("s7SerializerWLOne")
+    private S7Serializer s7SerializerWLOne;
+
+    @Autowired
+    @Qualifier("s7SerializerWLTwo")
+    private S7Serializer s7SerializerWLTwo;
+
+    @Autowired
+    @Qualifier("s7SerializerMBOne")
+    private S7Serializer s7SerializerMBOne;
+
     //    @Value("${mes.threshold}")
     private int threshold;
     //    @Value("${mes.cellLength}")
@@ -103,12 +120,15 @@
 
     @Scheduled(fixedDelay = 1000)
     public void startOneOpcTask() throws Exception {
+        S7DataWLTwo s7DataWLTwo = s7SerializerWLTwo.read(S7DataWLTwo.class);
         //鑾峰彇绗簩鏉$嚎璺殑鍗у紡鐞嗙墖绗肩姸鎬�
-        ReadWriteEntity twoInkageEntity = miloService.readFromOpcUa("WL2.WL2.deviceState");
+//        ReadWriteEntity twoInkageEntity = miloService.readFromOpcUa("WL2.WL2.deviceState");
+        Boolean twoInkageEntity = s7DataWLTwo.getDeviceState();
         //榛樿鍙窇涓�鍙板崸寮忕悊鐗�,涓ゆ潯绾胯矾閮藉彲浠ヨ蛋
         int cellFlag = 1;
         //濡傛灉涓ゆ潯绾块兘鍚姩鍒欏彧鑳借窇涓�鏉$嚎
-        if (twoInkageEntity != null && !Boolean.parseBoolean(twoInkageEntity.getValue() + "")) {
+//        if (twoInkageEntity != null && !Boolean.parseBoolean(twoInkageEntity.getValue() + "")) {
+        if (twoInkageEntity != null && !twoInkageEntity) {
             cellFlag = 2;
         }
         startOneOpcTaskChild(EDG_STORAGE_DEVICE_ONE_TASK, 1, cellFlag);
@@ -116,9 +136,12 @@
 
     @Scheduled(fixedDelay = 1000)
     public void startTwoOpcTask() throws Exception {
-        ReadWriteEntity oneInkageEntity = miloService.readFromOpcUa("WL1.WL1.deviceState");
+        S7DataWLOne s7DataWLOne = s7SerializerWLOne.read(S7DataWLOne.class);
+//        ReadWriteEntity oneInkageEntity = miloService.readFromOpcUa("WL1.WL1.deviceState");
+        Boolean oneInkageEntity = s7DataWLOne.getDeviceState();
         int cellFlag = 1;
-        if (oneInkageEntity != null && !Boolean.parseBoolean(oneInkageEntity.getValue() + "")) {
+//        if (oneInkageEntity != null && !Boolean.parseBoolean(oneInkageEntity.getValue() + "")) {
+        if (oneInkageEntity != null && !oneInkageEntity) {
             cellFlag = 2;
         }
         startOneOpcTaskChild(EDG_STORAGE_DEVICE_TWO_TASK, 2, cellFlag);
@@ -219,15 +242,25 @@
             return;
         }
         String toEndingId = glassInfo.getTemperingLayoutId() + "" + glassInfo.getTemperingFeedSequence();
-        List<ReadWriteEntity> list = new ArrayList<>();
-//        list.add(generateReadWriteEntity("MB" + cell + ".MB" + cell + ".mesControl", true));
-        list.add(generateReadWriteEntity("MB" + cell + ".MB" + cell + ".glassId", Integer.parseInt(toEndingId)));
-        list.add(generateReadWriteEntity("MB" + cell + ".MB" + cell + ".toEdingId", Integer.parseInt(toEndingId)));
-        list.add(generateReadWriteEntity("MB" + cell + ".MB" + cell + ".width", (int) Math.max(glassInfo.getWidth() * ratio, glassInfo.getHeight() * ratio)));
-        list.add(generateReadWriteEntity("MB" + cell + ".MB" + cell + ".height", (int) Math.min(glassInfo.getWidth() * ratio, glassInfo.getHeight() * ratio)));
+//        List<ReadWriteEntity> list = new ArrayList<>();
+////        list.add(generateReadWriteEntity("MB" + cell + ".MB" + cell + ".mesControl", true));
+//        list.add(generateReadWriteEntity("MB" + cell + ".MB" + cell + ".glassId", Integer.parseInt(toEndingId)));
+//        list.add(generateReadWriteEntity("MB" + cell + ".MB" + cell + ".toEdingId", Integer.parseInt(toEndingId)));
+//        list.add(generateReadWriteEntity("MB" + cell + ".MB" + cell + ".width", (int) Math.max(glassInfo.getWidth() * ratio, glassInfo.getHeight() * ratio)));
+//        list.add(generateReadWriteEntity("MB" + cell + ".MB" + cell + ".height", (int) Math.min(glassInfo.getWidth() * ratio, glassInfo.getHeight() * ratio)));
+//
+//        miloService.writeToOpcUa(list);
+//        miloService.writeToOpcWord(generateReadWriteEntity("MB" + cell + ".MB" + cell + ".thickness", (int) glassInfo.getThickness() * ratio));
+        S7DataMBOne s7DataMBOne =new S7DataMBOne();
+        s7DataMBOne.setToEdingId(Integer.parseInt(toEndingId));
+        s7DataMBOne.setGlassId(Integer.parseInt(toEndingId));
+        s7DataMBOne.setWidth((int) Math.max(glassInfo.getWidth() * ratio, glassInfo.getHeight() * ratio));
+        s7DataMBOne.setHeight((int) Math.min(glassInfo.getWidth() * ratio, glassInfo.getHeight() * ratio));
+        s7SerializerMBOne.write(s7DataMBOne);
 
-        miloService.writeToOpcUa(list);
-        miloService.writeToOpcWord(generateReadWriteEntity("MB" + cell + ".MB" + cell + ".thickness", (int) glassInfo.getThickness() * ratio));
+        s7DataMBOne =new S7DataMBOne();
+        s7DataMBOne.setThickness((short) (glassInfo.getThickness() * ratio));
+        s7SerializerMBOne.write(s7DataMBOne);
         //淇敼纾ㄨ竟瀵瑰垪涓殑纾ㄨ竟绾胯矾鍙婄姸鎬�
         edgGlassTaskInfoService.update(new LambdaUpdateWrapper<EdgGlassTaskInfo>()
                 .set(EdgGlassTaskInfo::getLine, cell)
@@ -300,26 +333,40 @@
     private boolean outTask(EdgStorageDeviceTask task, String tableName, int deviceId, int cellFlag) throws Exception {
         Date startDate = new Date();
         //鑾峰彇瀵瑰簲鐨勮澶囩姸鎬佷俊鎭�
-        ReadWriteEntity oneOutStateEntity = miloService.readFromOpcUa("WL1.WL1.slotState");
-        ReadWriteEntity twoOutStateEntity = miloService.readFromOpcUa("WL2.WL2.slotState");
-        ReadWriteEntity d06OutStateEntity = miloService.readFromOpcUa("WL2.WL2.d06SlotState");
+//        ReadWriteEntity oneOutStateEntity = miloService.readFromOpcUa("WL1.WL1.slotState");
+//        ReadWriteEntity twoOutStateEntity = miloService.readFromOpcUa("WL2.WL2.slotState");
+//        ReadWriteEntity d06OutStateEntity = miloService.readFromOpcUa("WL2.WL2.d06SlotState");
+        S7DataWLOne s7DataWLOne = s7SerializerWLOne.read(S7DataWLOne.class);
+        S7DataWLTwo s7DataWLTwo = s7SerializerWLTwo.read(S7DataWLTwo.class);
+        Short oneOutStateEntity = s7DataWLOne.getSlotState();
+        Short twoOutStateEntity = s7DataWLTwo.getSlotState();
+        Short d06OutStateEntity = s7DataWLTwo.getD06SlotState();
         //鐘舵�佹湁3涓儏鍐碉細0绌洪棽 1蹇欑 2绂佺敤
         String oneOutState = Const.OUT_DISABLE;
         String twoOutState = Const.OUT_DISABLE;
         String d06OutState = Const.OUT_DISABLE;
-        if (null != oneOutStateEntity && null != oneOutStateEntity.getValue()) {
-            oneOutState = oneOutStateEntity.getValue().toString();
+//        if (null != oneOutStateEntity && null != oneOutStateEntity.getValue()) {
+//            oneOutState = oneOutStateEntity.getValue().toString();
+//        }
+        if (null != oneOutStateEntity ) {
+            oneOutState = oneOutStateEntity.toString();
         }
-        if (null != twoOutStateEntity && null != twoOutStateEntity.getValue()) {
-            twoOutState = twoOutStateEntity.getValue().toString();
+//        if (null != twoOutStateEntity && null != twoOutStateEntity.getValue()) {
+//            twoOutState = twoOutStateEntity.getValue().toString();
+//        }
+        if (null != twoOutStateEntity ) {
+            twoOutState = twoOutStateEntity.toString();
         }
         //涓ゆ潯绾块兘涓虹鐢ㄥ垯涓嶅嚭鐜荤拑
         if (Const.OUT_DISABLE.equals(oneOutState) && Const.OUT_DISABLE.equals(twoOutState)) {
             log.info("A09銆丄10涓簕},{}闈炶嚜鍔ㄧ姸鎬侊紝鏃犳硶鍑虹墖", oneOutState, oneOutState);
             return Boolean.FALSE;
         }
-        if (null != d06OutStateEntity && null != d06OutStateEntity.getValue()) {
-            d06OutState = d06OutStateEntity.getValue().toString();
+//        if (null != d06OutStateEntity && null != d06OutStateEntity.getValue()) {
+//            d06OutState = d06OutStateEntity.getValue().toString();
+//        }
+        if (null != d06OutStateEntity ) {
+            d06OutState = d06OutStateEntity.toString();
         }
         //鑾峰彇d06鐗囧彴鐘舵��
         // 1:涓�瀵逛竴鐨勬儏鍐典笅涓嶉渶瑕佸垽鏂璬06鐘舵��
diff --git a/hangzhoumesParent/moduleService/CacheGlassModule/src/main/java/com/mes/s7/entity/S7DataMBOne.java b/hangzhoumesParent/moduleService/CacheGlassModule/src/main/java/com/mes/s7/entity/S7DataMBOne.java
new file mode 100644
index 0000000..261efdb
--- /dev/null
+++ b/hangzhoumesParent/moduleService/CacheGlassModule/src/main/java/com/mes/s7/entity/S7DataMBOne.java
@@ -0,0 +1,37 @@
+package com.mes.s7.entity;
+
+import com.github.xingshuangs.iot.protocol.common.enums.EDataType;
+import com.github.xingshuangs.iot.protocol.s7.serializer.S7Variable;
+import lombok.Data;
+
+/**
+ * @Author : zhoush
+ * @Date: 2025/4/30 14:19
+ * @Description:
+ */
+@Data
+public class S7DataMBOne {
+
+
+    @S7Variable(address = "DB19.0", type = EDataType.FLOAT32)
+    private Integer speed;
+
+    @S7Variable(address = "DB49.46", type = EDataType.INT32)
+    private Integer width;
+
+    @S7Variable(address = "DB49.48", type = EDataType.INT32)
+    private Integer toEdingId;
+
+    @S7Variable(address = "DB49.50", type = EDataType.INT32)
+    private Integer glassId;
+
+    @S7Variable(address = "DB49.52", type = EDataType.INT32)
+    private Integer height;
+
+    @S7Variable(address = "DB49.116", type = EDataType.INT16)
+    private Short thickness;
+
+    @S7Variable(address = "DB49.124", type = EDataType.BOOL)
+    private Boolean mesControl;
+
+}
diff --git a/hangzhoumesParent/moduleService/CacheGlassModule/src/main/java/com/mes/s7/entity/S7DataWLOne.java b/hangzhoumesParent/moduleService/CacheGlassModule/src/main/java/com/mes/s7/entity/S7DataWLOne.java
new file mode 100644
index 0000000..bf21d1f
--- /dev/null
+++ b/hangzhoumesParent/moduleService/CacheGlassModule/src/main/java/com/mes/s7/entity/S7DataWLOne.java
@@ -0,0 +1,52 @@
+package com.mes.s7.entity;
+
+import com.github.xingshuangs.iot.protocol.common.enums.EDataType;
+import com.github.xingshuangs.iot.protocol.s7.serializer.S7Variable;
+import lombok.Data;
+
+/**
+ * @Author : zhoush
+ * @Date: 2025/4/30 14:19
+ * @Description:
+ */
+@Data
+public class S7DataWLOne {
+
+
+    @S7Variable(address = "DB19.0", type = EDataType.INT16)
+    private Short taskRunning;
+
+    @S7Variable(address = "DB49.46", type = EDataType.INT16)
+    private Short slot;
+
+    @S7Variable(address = "DB49.48", type = EDataType.INT16)
+    private Short startCell;
+
+    @S7Variable(address = "DB49.50", type = EDataType.INT16)
+    private Short endCell;
+
+    @S7Variable(address = "DB49.52", type = EDataType.INT16)
+    private Short plcTaskState;
+
+    @S7Variable(address = "DB49.116", type = EDataType.INT16)
+    private Short inPlace;
+
+    @S7Variable(address = "DB49.124", type = EDataType.INT16)
+    private Short slotState;
+
+    @S7Variable(address = "DB49.118", type = EDataType.FLOAT32)
+    private Short speed;
+
+    @S7Variable(address = "DB49.2", type = EDataType.STRING)
+    private String glassIdIn;
+
+    @S7Variable(address = "DB49.24", type = EDataType.STRING)
+    private String glassIdOut;
+
+    @S7Variable(address = "DB49.94", type = EDataType.STRING)
+    private String glassId;
+
+    @S7Variable(address = "DB49.112", type = EDataType.BOOL)
+    private Boolean deviceState;
+
+}
diff --git a/hangzhoumesParent/moduleService/CacheGlassModule/src/main/java/com/mes/s7/entity/S7DataWLTwo.java b/hangzhoumesParent/moduleService/CacheGlassModule/src/main/java/com/mes/s7/entity/S7DataWLTwo.java
new file mode 100644
index 0000000..c9b0534
--- /dev/null
+++ b/hangzhoumesParent/moduleService/CacheGlassModule/src/main/java/com/mes/s7/entity/S7DataWLTwo.java
@@ -0,0 +1,55 @@
+package com.mes.s7.entity;
+
+import com.github.xingshuangs.iot.protocol.common.enums.EDataType;
+import com.github.xingshuangs.iot.protocol.s7.serializer.S7Variable;
+import lombok.Data;
+
+/**
+ * @Author : zhoush
+ * @Date: 2025/4/30 14:19
+ * @Description:
+ */
+@Data
+public class S7DataWLTwo {
+
+
+    @S7Variable(address = "DB19.0", type = EDataType.INT16)
+    private Short taskRunning;
+
+    @S7Variable(address = "DB49.46", type = EDataType.INT16)
+    private Short slot;
+
+    @S7Variable(address = "DB49.48", type = EDataType.INT16)
+    private Short startCell;
+
+    @S7Variable(address = "DB49.50", type = EDataType.INT16)
+    private Short endCell;
+
+    @S7Variable(address = "DB49.52", type = EDataType.INT16)
+    private Short plcTaskState;
+
+    @S7Variable(address = "DB49.116", type = EDataType.INT16)
+    private Short inPlace;
+
+    @S7Variable(address = "DB49.124", type = EDataType.INT16)
+    private Short slotState;
+
+    @S7Variable(address = "DB49.118", type = EDataType.FLOAT32)
+    private Short d06SlotState;
+
+    @S7Variable(address = "DB49.118", type = EDataType.FLOAT32)
+    private Short speed;
+
+    @S7Variable(address = "DB49.2", type = EDataType.STRING)
+    private String glassIdIn;
+
+    @S7Variable(address = "DB49.24", type = EDataType.STRING)
+    private String glassIdOut;
+
+    @S7Variable(address = "DB49.94", type = EDataType.STRING)
+    private String glassId;
+
+    @S7Variable(address = "DB49.112", type = EDataType.BOOL)
+    private Boolean deviceState;
+
+}
diff --git a/hangzhoumesParent/moduleService/GlassStorageModule/src/main/java/com/mes/config/S7Config.java b/hangzhoumesParent/moduleService/GlassStorageModule/src/main/java/com/mes/config/S7Config.java
new file mode 100644
index 0000000..889333c
--- /dev/null
+++ b/hangzhoumesParent/moduleService/GlassStorageModule/src/main/java/com/mes/config/S7Config.java
@@ -0,0 +1,21 @@
+package com.mes.config;
+
+import com.github.xingshuangs.iot.protocol.s7.enums.EPlcType;
+import com.github.xingshuangs.iot.protocol.s7.serializer.S7Serializer;
+import com.github.xingshuangs.iot.protocol.s7.service.S7PLC;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * @Author : zhoush
+ * @Date: 2025/4/30 13:50
+ * @Description:
+ */
+@Configuration
+public class S7Config {
+    @Bean
+    public S7Serializer s7Serializer() {
+        S7PLC s7PLC = new S7PLC(EPlcType.S1200, "192.168.10.80");
+        return S7Serializer.newInstance(s7PLC);
+    }
+}
diff --git a/hangzhoumesParent/moduleService/GlassStorageModule/src/main/java/com/mes/job/RawGlassTask.java b/hangzhoumesParent/moduleService/GlassStorageModule/src/main/java/com/mes/job/RawGlassTask.java
index fc39593..8de01c4 100644
--- a/hangzhoumesParent/moduleService/GlassStorageModule/src/main/java/com/mes/job/RawGlassTask.java
+++ b/hangzhoumesParent/moduleService/GlassStorageModule/src/main/java/com/mes/job/RawGlassTask.java
@@ -17,6 +17,7 @@
 import com.mes.rawglassstation.service.RawGlassStorageStationService;
 import com.mes.rawglasstask.entity.RawGlassStorageTask;
 import com.mes.rawglasstask.service.RawGlassStorageTaskService;
+import com.mes.s7.entity.S7Data;
 import com.mes.uppattenusage.entity.UpPattenUsage;
 import com.mes.uppattenusage.entity.vo.UpPattenUsageVO;
 import com.mes.uppattenusage.mapper.UpPattenUsageMapper;
@@ -76,39 +77,39 @@
 
     @Scheduled(fixedDelay = 1000)
     public void rawStorageTask() throws Exception {
-//        S7Data S7DataWL1 = s7Serializer.read(S7Data.class);
-//        String requestWord = S7DataWL1.getRequest().toString();
-//        String confireWord = S7DataWL1.getConfirmation().toString();
-//        String reportWord = S7DataWL1.getReportWord().toString();
-//        String taskWord = S7DataWL1.getTaskWord().toString();
-//        String requestValue = requestWord;
-        ReadWriteEntity requestWord = miloService.readFromOpcUa("CC.CC.request");
-        ReadWriteEntity confireWord = miloService.readFromOpcUa("CC.CC.confirmation");
-        ReadWriteEntity reportWord = miloService.readFromOpcUa("CC.CC.reportWord");
-        ReadWriteEntity taskWord = miloService.readFromOpcUa("CC.CC.taskWord");
-        String requestValue = requestWord.getValue() + "";
+        S7Data S7DataCCOne = s7Serializer.read(S7Data.class);
+        String requestWord = S7DataCCOne.getRequest().toString();
+        String confireWord = S7DataCCOne.getConfirmation().toString();
+        String reportWord = S7DataCCOne.getReportWord().toString();
+        String taskWord = S7DataCCOne.getTaskWord().toString();
+        String requestValue = requestWord;
+//        ReadWriteEntity requestWord = miloService.readFromOpcUa("CC.CC.request");
+//        ReadWriteEntity confireWord = miloService.readFromOpcUa("CC.CC.confirmation");
+//        ReadWriteEntity reportWord = miloService.readFromOpcUa("CC.CC.reportWord");
+//        ReadWriteEntity taskWord = miloService.readFromOpcUa("CC.CC.taskWord");
+//        String requestValue = requestWord.getValue() + "";
         if ("0".equals(requestValue)) {
             if ("1".equals(confireWord) && "0".equals(reportWord)) {
 //            if ("1".equals(confireWord.getValue() + "") && "0".equals(reportWord.getValue() + "")) {
-//                S7Data s7Data = new S7Data();
-//                s7Data.setConfirmation((short) 0);
-//                s7Serializer.write(s7Data);
-                List<ReadWriteEntity> list = new ArrayList<>();
-                list.add(generateReadWriteEntity("CC.CC.confirmation", 0));
-                miloService.writeToOpcWord(list);
+                S7Data s7Data = new S7Data();
+                s7Data.setConfirmation((short) 0);
+                s7Serializer.write(s7Data);
+//                List<ReadWriteEntity> list = new ArrayList<>();
+//                list.add(generateReadWriteEntity("CC.CC.confirmation", 0));
+//                miloService.writeToOpcWord(list);
             }
-//            if ("1".equals(taskWord)) {
-          if ("1".equals(taskWord.getValue() + "")) {
-//                S7Data s7Data = new S7Data();
-//                s7Data.setTaskWord((short) 0);
-//                s7Data.setStartSlot((short) 0);
-//                s7Data.setEndSlot((short) 0);
-//                s7Serializer.write(s7Data);
-                List<ReadWriteEntity> list = new ArrayList<>();
-                list.add(generateReadWriteEntity("CC.CC.taskWord", 0));
-                list.add(generateReadWriteEntity("CC.CC.startSlot", 0));
-                list.add(generateReadWriteEntity("CC.CC.endSlot", 0));
-                miloService.writeToOpcWord(list);
+            if ("1".equals(taskWord)) {
+//          if ("1".equals(taskWord.getValue() + "")) {
+                S7Data s7Data = new S7Data();
+                s7Data.setTaskWord((short) 0);
+                s7Data.setStartSlot((short) 0);
+                s7Data.setEndSlot((short) 0);
+                s7Serializer.write(s7Data);
+//                List<ReadWriteEntity> list = new ArrayList<>();
+//                list.add(generateReadWriteEntity("CC.CC.taskWord", 0));
+//                list.add(generateReadWriteEntity("CC.CC.startSlot", 0));
+//                list.add(generateReadWriteEntity("CC.CC.endSlot", 0));
+//                miloService.writeToOpcWord(list);
             }
             return;
         }
@@ -148,10 +149,10 @@
 
     @Scheduled(fixedDelay = 1000)
     public void rawStorageInCar() throws Exception {
-//        S7Data S7DataWL1 = s7Serializer.read(S7Data.class);
-//        String value = S7DataWL1.getInCar().toString();
-        ReadWriteEntity entity = miloService.readFromOpcUa("CC.CC.inCar");
-        String value = entity.getValue() + "";
+        S7Data S7DataCCOne = s7Serializer.read(S7Data.class);
+        String value = S7DataCCOne.getInCar().toString();
+//        ReadWriteEntity entity = miloService.readFromOpcUa("CC.CC.inCar");
+//        String value = entity.getValue() + "";
         if (!"1".equals(value)) {
             log.info("澶ц溅涓婃病鏈夋灦瀛�");
             return;
@@ -169,10 +170,10 @@
 
     @Scheduled(fixedDelay = 1000)
     public void rawStorageFinish() throws Exception {
-//        S7Data S7DataWL1 = s7Serializer.read(S7Data.class);
-//        String value = S7DataWL1.getReportWord().toString();
-        ReadWriteEntity entity = miloService.readFromOpcUa("CC.CC.reportWord");
-        String value = entity.getValue() + "";
+        S7Data S7DataCCOne = s7Serializer.read(S7Data.class);
+        String value = S7DataCCOne.getReportWord().toString();
+//        ReadWriteEntity entity = miloService.readFromOpcUa("CC.CC.reportWord");
+//        String value = entity.getValue() + "";
         if ("0".equals(value)) {
             log.info("褰撳墠浠诲姟鏈眹鎶ワ紝缁撴潫鏈浠诲姟");
             return;
@@ -235,12 +236,12 @@
                     .set(RawGlassStorageTask::getTaskState, Const.RAW_GLASS_TASK_FAILURE));
 
         }
-//        S7Data s7Data = new S7Data();
-//        s7Data.setConfirmation((short) 1);
-//        s7Serializer.write(s7Data);
-        List<ReadWriteEntity> list = new ArrayList<>();
-        list.add(generateReadWriteEntity("CC.CC.confirmation", 1));
-        miloService.writeToOpcWord(list);
+        S7Data s7Data = new S7Data();
+        s7Data.setConfirmation((short) 1);
+        s7Serializer.write(s7Data);
+//        List<ReadWriteEntity> list = new ArrayList<>();
+//        list.add(generateReadWriteEntity("CC.CC.confirmation", 1));
+//        miloService.writeToOpcWord(list);
     }
 
     private boolean isHasRunningTask() {
diff --git a/hangzhoumesParent/moduleService/GlassStorageModule/src/main/java/com/mes/s7/entity/S7Data.java b/hangzhoumesParent/moduleService/GlassStorageModule/src/main/java/com/mes/s7/entity/S7Data.java
new file mode 100644
index 0000000..2050c51
--- /dev/null
+++ b/hangzhoumesParent/moduleService/GlassStorageModule/src/main/java/com/mes/s7/entity/S7Data.java
@@ -0,0 +1,89 @@
+package com.mes.s7.entity;
+
+import com.github.xingshuangs.iot.protocol.common.enums.EDataType;
+import com.github.xingshuangs.iot.protocol.s7.serializer.S7Variable;
+import lombok.Data;
+
+/**
+ * @Author : zhoush
+ * @Date: 2025/4/30 14:19
+ * @Description:
+ */
+@Data
+public class S7Data {
+
+
+//    @S7Variable(address = "DB1.0", type = EDataType.INT16)
+//    private Short request;
+//
+//    @S7Variable(address = "DB1.2", type = EDataType.INT16)
+//    private Short requestId;
+//
+//    @S7Variable(address = "DB1.4", type = EDataType.INT16)
+//    private Short reportWord;
+//
+//    @S7Variable(address = "DB1.6", type = EDataType.INT16)
+//    private Short reportId;
+//
+//    @S7Variable(address = "DB1.8", type = EDataType.INT16)
+//    private Short inCar;
+//
+//    @S7Variable(address = "DB1.10", type = EDataType.INT16)
+//    private Short taskWord;
+//
+//    @S7Variable(address = "DB1.12", type = EDataType.INT16)
+//    private Short taskId;
+//
+//    @S7Variable(address = "DB1.14", type = EDataType.INT16)
+//    private Short startSlot;
+//
+//    @S7Variable(address = "DB1.16", type = EDataType.INT16)
+//    private Short endSlot;
+//
+//    @S7Variable(address = "DB1.18", type = EDataType.INT16)
+//    private Short taskSending;
+//
+//    @S7Variable(address = "DB1.20", type = EDataType.INT16)
+//    private Short confirmation;
+//
+//    @S7Variable(address = "DB1.22", type = EDataType.INT16)
+//    private Short confirmationId;
+
+    @S7Variable(address = "DB38.0", type = EDataType.INT16)
+    private Short request;
+
+    @S7Variable(address = "DB38.2", type = EDataType.INT16)
+    private Short requestId;
+
+    @S7Variable(address = "DB38.10", type = EDataType.INT16)
+    private Short reportWord;
+
+    @S7Variable(address = "DB38.12", type = EDataType.INT16)
+    private Short reportId;
+
+    @S7Variable(address = "DB38.18", type = EDataType.INT16)
+    private Short inCar;
+
+    @S7Variable(address = "DB38.20", type = EDataType.INT16)
+    private Short taskWord;
+
+    @S7Variable(address = "DB38.22", type = EDataType.INT16)
+    private Short taskId;
+
+    @S7Variable(address = "DB38.24", type = EDataType.INT16)
+    private Short startSlot;
+
+    @S7Variable(address = "DB38.26", type = EDataType.INT16)
+    private Short endSlot;
+
+    @S7Variable(address = "DB38.28", type = EDataType.INT16)
+    private Short taskSending;
+
+    @S7Variable(address = "DB38.40", type = EDataType.INT16)
+    private Short confirmation;
+
+    @S7Variable(address = "DB38.42", type = EDataType.INT16)
+    private Short confirmationId;
+
+
+}
diff --git a/hangzhoumesParent/moduleService/LoadGlassModule/src/main/java/com/mes/config/S7Config.java b/hangzhoumesParent/moduleService/LoadGlassModule/src/main/java/com/mes/config/S7Config.java
new file mode 100644
index 0000000..e7bb075
--- /dev/null
+++ b/hangzhoumesParent/moduleService/LoadGlassModule/src/main/java/com/mes/config/S7Config.java
@@ -0,0 +1,28 @@
+package com.mes.config;
+
+import com.github.xingshuangs.iot.protocol.s7.enums.EPlcType;
+import com.github.xingshuangs.iot.protocol.s7.serializer.S7Serializer;
+import com.github.xingshuangs.iot.protocol.s7.service.S7PLC;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * @Author : zhoush
+ * @Date: 2025/4/30 13:50
+ * @Description:
+ */
+@Configuration
+public class S7Config {
+    @Bean(name = "s7SerializerSPOne")
+    public S7Serializer s7SerializerSPOne() {
+        S7PLC s7PLC = new S7PLC(EPlcType.S1200, "192.168.10.15");
+        return S7Serializer.newInstance(s7PLC);
+    }
+
+    @Bean(name = "s7SerializerSPTwo")
+    public S7Serializer s7SerializerSPTwo() {
+        S7PLC s7PLC = new S7PLC(EPlcType.S1200, "192.168.10.21");
+        return S7Serializer.newInstance(s7PLC);
+    }
+
+}
diff --git a/hangzhoumesParent/moduleService/LoadGlassModule/src/main/java/com/mes/job/OpcLoadGlassTask.java b/hangzhoumesParent/moduleService/LoadGlassModule/src/main/java/com/mes/job/OpcLoadGlassTask.java
index a18183a..be0007a 100644
--- a/hangzhoumesParent/moduleService/LoadGlassModule/src/main/java/com/mes/job/OpcLoadGlassTask.java
+++ b/hangzhoumesParent/moduleService/LoadGlassModule/src/main/java/com/mes/job/OpcLoadGlassTask.java
@@ -3,6 +3,7 @@
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
+import com.github.xingshuangs.iot.protocol.s7.serializer.S7Serializer;
 import com.mes.common.config.Const;
 import com.mes.engineering.entity.Engineering;
 import com.mes.engineering.mapper.EngineeringMapper;
@@ -14,11 +15,14 @@
 import com.mes.pp.service.OptimizeProjectService;
 import com.mes.rawglassdetails.entity.RawGlassStorageDetails;
 import com.mes.rawglassdetails.service.RawGlassStorageDetailsService;
+import com.mes.s7.entity.S7DataSP;
 import com.mes.uppattenusage.entity.UpPattenUsage;
 import com.mes.uppattenusage.entity.vo.UpPattenUsageVO;
 import com.mes.uppattenusage.mapper.UpPattenUsageMapper;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Component;
 import org.springframework.util.CollectionUtils;
@@ -52,6 +56,14 @@
     private UpPattenUsageMapper upPattenUsageMapper;
     @Resource
     private OptimizeProjectService optimizeProjectService;
+
+    @Autowired
+    @Qualifier("s7SerializerSPOne")
+    private S7Serializer s7SerializerSPOne;
+
+    @Autowired
+    @Qualifier("s7SerializerSPTwo")
+    private S7Serializer s7SerializerSPTwo;
 
     private static final List<Integer> LOAD_STATION_01 = Arrays.asList(101, 102);
     private static final List<Integer> LOAD_STATION_02 = Arrays.asList(103, 104);
@@ -109,6 +121,12 @@
     }
 
     private void opcLoadGlassChild(String tableName, Integer deviceId) {
+        S7DataSP s7DataSP = new S7DataSP();
+        if(tableName.equals(LOAD_GLASS_DEVICE_ONE_TASK)){
+            s7DataSP = s7SerializerSPOne.read(S7DataSP.class);
+        }else{
+            s7DataSP = s7SerializerSPTwo.read(S7DataSP.class);
+        }
         Engineering engineering = engineeringMapper.selectOne(new LambdaQueryWrapper<Engineering>()
                 .eq(Engineering::getState, Const.ENGINEERING_RUNNING).eq(Engineering::getStationCell, deviceId));
         if (null == engineering) {
@@ -117,11 +135,14 @@
         }
         //浠诲姟鏆傚仠
         LoadGlassDeviceTask task = loadGlassDeviceTaskService.queryTaskMessage(tableName);
-        if (0 == task.getInkageState()) {
+        ;
+        if ("0".equals(s7DataSP.getInkageState().toString())) {
+//        if (0 == task.getInkageState()) {
             log.info("{}涓婄墖绾匡紝澶勪簬绂荤嚎鐘舵�侊細{}锛岀粨鏉熸湰鍦颁笂鐗囪姹�", deviceId, task.getInkageState());
             return;
         }
-        if (task.getTaskRunning().equals(Const.ENGINEERING_RUNNING)) {
+        if (s7DataSP.getTaskRunning().toString().equals(Const.ENGINEERING_RUNNING)) {
+//        if (task.getTaskRunning().equals(Const.ENGINEERING_RUNNING)) {
             log.info("{}涓婄墖绾匡紝鏈夋鍦ㄦ墽琛岀殑浠诲姟锛岀粨鏉熸湰鍦颁笂鐗囪姹�", deviceId);
             return;
         }
@@ -181,19 +202,29 @@
     }
 
     private void opcLoadGlassFinishChid(String tableName, Integer deviceId) {
+        S7DataSP s7DataSP = new S7DataSP();
+        if(tableName.equals(LOAD_GLASS_DEVICE_ONE_TASK)){
+            s7DataSP = s7SerializerSPOne.read(S7DataSP.class);
+        }else{
+            s7DataSP = s7SerializerSPTwo.read(S7DataSP.class);
+        }
         LoadGlassDeviceTask task = loadGlassDeviceTaskService.queryTaskMessage(tableName);
-        if (task.getTaskRunning().equals(Const.ENGINEERING_NEW)) {
+        if (s7DataSP.getTaskRunning().toString().equals(Const.ENGINEERING_NEW)) {
+//        if (task.getTaskRunning().equals(Const.ENGINEERING_NEW)) {
             log.info("鏃犱换鍔�,缁撴潫");
             return;
         }
-        if (task.getTaskState() <= 1) {
+        if (Integer.parseInt(s7DataSP.getTaskState().toString()) <= 1) {
+//        if (task.getTaskState() <= 1) {
             log.info("浠诲姟姝e湪鎵ц,缁撴潫");
             return;
         }
         //鑾峰彇浠诲姟瀹屾垚鎯呭喌
 //         宸插畬鎴愭暟閲�  鐮存崯鏁伴噺
-        Integer finishCount = task.getFinishCount();
-        Integer damageCount = task.getDamageCount();
+        Integer finishCount = Integer.parseInt(s7DataSP.getFinishCount().toString());
+        Integer damageCount = Integer.parseInt(s7DataSP.getDamageCount().toString());
+//        Integer finishCount = task.getFinishCount();
+//        Integer damageCount = task.getDamageCount();
 
         //鏇存柊褰撳墠鏋跺瓙涓婄殑鍘熺墖鍓╀綑鎯呭喌
         rawGlassStorageDetailsService.update(new UpdateWrapper<RawGlassStorageDetails>()
diff --git a/hangzhoumesParent/moduleService/LoadGlassModule/src/main/java/com/mes/s7/entity/S7DataSP.java b/hangzhoumesParent/moduleService/LoadGlassModule/src/main/java/com/mes/s7/entity/S7DataSP.java
new file mode 100644
index 0000000..4bde154
--- /dev/null
+++ b/hangzhoumesParent/moduleService/LoadGlassModule/src/main/java/com/mes/s7/entity/S7DataSP.java
@@ -0,0 +1,44 @@
+package com.mes.s7.entity;
+
+import com.github.xingshuangs.iot.protocol.common.enums.EDataType;
+import com.github.xingshuangs.iot.protocol.s7.serializer.S7Variable;
+import lombok.Data;
+
+/**
+ * @Author : zhoush
+ * @Date: 2025/4/30 14:19
+ * @Description:
+ */
+@Data
+public class S7DataSP {
+
+
+    @S7Variable(address = "DB19.14", type = EDataType.INT16)
+    private Integer taskState;
+
+    @S7Variable(address = "DB19.18", type = EDataType.INT16)
+    private Integer damageCount;
+
+    @S7Variable(address = "DB19.20", type = EDataType.INT16)
+    private Integer rawGlassWidth;
+
+    @S7Variable(address = "DB19.22", type = EDataType.INT16)
+    private Integer rawGlassHeight;
+
+    @S7Variable(address = "DB19.24", type = EDataType.INT16)
+    private Integer slot;
+
+    @S7Variable(address = "DB19.26", type = EDataType.INT16)
+    private Integer totalCount;
+
+    @S7Variable(address = "DB19.28", type = EDataType.INT16)
+    private Integer finishCount;
+
+    @S7Variable(address = "DB19.x16.0", type = EDataType.BOOL)
+    private Integer taskRunning;
+
+    @S7Variable(address = "DB19.30", type = EDataType.INT16)
+    private Integer inkageState;
+
+
+}

--
Gitblit v1.8.0