ZengTao
2025-05-20 ae07cd92f46b88bf034c7d9d0b96b3a5e83fdc98
仓储,上片,卧理修改OPC为S7通讯
3个文件已修改
8个文件已添加
579 ■■■■ 已修改文件
hangzhoumesParent/moduleService/CacheGlassModule/src/main/java/com/mes/config/S7Config.java 34 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
hangzhoumesParent/moduleService/CacheGlassModule/src/main/java/com/mes/job/OpcCacheGlassNewTask.java 89 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
hangzhoumesParent/moduleService/CacheGlassModule/src/main/java/com/mes/s7/entity/S7DataMBOne.java 37 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
hangzhoumesParent/moduleService/CacheGlassModule/src/main/java/com/mes/s7/entity/S7DataWLOne.java 52 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
hangzhoumesParent/moduleService/CacheGlassModule/src/main/java/com/mes/s7/entity/S7DataWLTwo.java 55 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
hangzhoumesParent/moduleService/GlassStorageModule/src/main/java/com/mes/config/S7Config.java 21 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
hangzhoumesParent/moduleService/GlassStorageModule/src/main/java/com/mes/job/RawGlassTask.java 87 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
hangzhoumesParent/moduleService/GlassStorageModule/src/main/java/com/mes/s7/entity/S7Data.java 89 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
hangzhoumesParent/moduleService/LoadGlassModule/src/main/java/com/mes/config/S7Config.java 28 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
hangzhoumesParent/moduleService/LoadGlassModule/src/main/java/com/mes/job/OpcLoadGlassTask.java 43 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
hangzhoumesParent/moduleService/LoadGlassModule/src/main/java/com/mes/s7/entity/S7DataSP.java 44 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
hangzhoumesParent/moduleService/CacheGlassModule/src/main/java/com/mes/config/S7Config.java
New file
@@ -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);
    }
}
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、A10为{},{}非自动状态,无法出片", 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:一对一的情况下不需要判断d06状态
hangzhoumesParent/moduleService/CacheGlassModule/src/main/java/com/mes/s7/entity/S7DataMBOne.java
New file
@@ -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;
}
hangzhoumesParent/moduleService/CacheGlassModule/src/main/java/com/mes/s7/entity/S7DataWLOne.java
New file
@@ -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;
}
hangzhoumesParent/moduleService/CacheGlassModule/src/main/java/com/mes/s7/entity/S7DataWLTwo.java
New file
@@ -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;
}
hangzhoumesParent/moduleService/GlassStorageModule/src/main/java/com/mes/config/S7Config.java
New file
@@ -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);
    }
}
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() {
hangzhoumesParent/moduleService/GlassStorageModule/src/main/java/com/mes/s7/entity/S7Data.java
New file
@@ -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;
}
hangzhoumesParent/moduleService/LoadGlassModule/src/main/java/com/mes/config/S7Config.java
New file
@@ -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);
    }
}
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("任务正在执行,结束");
            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>()
hangzhoumesParent/moduleService/LoadGlassModule/src/main/java/com/mes/s7/entity/S7DataSP.java
New file
@@ -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;
}