hangzhoumesParent/moduleService/CacheGlassModule/src/main/java/com/mes/config/S7ConfigWL1.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 S7ConfigWL1 { @Bean public S7Serializer s7Serializer() { S7PLC s7PLC = new S7PLC(EPlcType.S1200, "192.169.10.100"); return S7Serializer.newInstance(s7PLC); } } hangzhoumesParent/moduleService/CacheGlassModule/src/main/java/com/mes/s7/entity/S7DataWL1.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 S7DataWL1 { @S7Variable(address = "DB49.0", type = EDataType.INT16) private Integer task_running; @S7Variable(address = "DB49.46", type = EDataType.INT16) private Integer slot; @S7Variable(address = "DB49.48", type = EDataType.INT16) private Integer start_cell; @S7Variable(address = "DB49.50", type = EDataType.INT16) private Integer end_cell; @S7Variable(address = "DB49.52", type = EDataType.INT16) private Integer plc_task_state; @S7Variable(address = "DB49.116", type = EDataType.INT16) private Integer in_place; @S7Variable(address = "DB49.124", type = EDataType.INT16) private Integer slotState; @S7Variable(address = "DB49.R118", type = EDataType.FLOAT32) private Integer speed; @S7Variable(address = "DB49.2", type = EDataType.STRING, count = 22) private String glass_id_in; @S7Variable(address = "DB49.24", type = EDataType.STRING, count = 22) private String glass_id_out; @S7Variable(address = "DB49.94", type = EDataType.STRING, count = 18) private String glass_id; @S7Variable(address = "DB49.X122.0", type = EDataType.BOOL) private Boolean deviceState; } hangzhoumesParent/moduleService/CacheGlassModule/src/main/java/com/mes/s7/job/s7Job.java
New file @@ -0,0 +1,28 @@ package com.mes.s7.job; import com.github.xingshuangs.iot.protocol.s7.serializer.S7Serializer; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; /** * @Author : zhoush * @Date: 2025/4/30 14:20 * @Description: */ @Component @Slf4j public class s7Job { @Autowired(required = false) S7Serializer s7Serializer; @Scheduled(fixedDelay = 1000) public void hollowRemoveTaskOne() { // S7Data read = s7Serializer.read(S7Data.class); // log.info("read data: {}", read); } } hangzhoumesParent/moduleService/CacheVerticalGlassModule/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.20.140"); return S7Serializer.newInstance(s7PLC); } } hangzhoumesParent/moduleService/CacheVerticalGlassModule/src/main/java/com/mes/s7/entity/S7Data.java
New file @@ -0,0 +1,102 @@ 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 = "DB3.X3118.0", type = EDataType.BOOL) private Boolean mesControl; @S7Variable(address = "DB7.0", type = EDataType.UINT16) private Integer RequestMes; @S7Variable(address = "DB7.2", type = EDataType.UINT16) private Integer MesReply; @S7Variable(address = "DB7.140", type = EDataType.UINT16) private Integer FROM1; @S7Variable(address = "DB7.142", type = EDataType.UINT16) private Integer FROM2; @S7Variable(address = "DB7.144", type = EDataType.UINT16) private Integer FROM3; @S7Variable(address = "DB7.146", type = EDataType.UINT16) private Integer FROM4; @S7Variable(address = "DB7.148", type = EDataType.UINT16) private Integer FROM5; @S7Variable(address = "DB7.150", type = EDataType.UINT16) private Integer FROM6; @S7Variable(address = "DB7.152", type = EDataType.UINT16) private Integer TO1; @S7Variable(address = "DB7.154", type = EDataType.UINT16) private Integer TO2; @S7Variable(address = "DB7.156", type = EDataType.UINT16) private Integer TO3; @S7Variable(address = "DB7.158", type = EDataType.UINT16) private Integer T4; @S7Variable(address = "DB7.160", type = EDataType.UINT16) private Integer T5; @S7Variable(address = "DB7.162", type = EDataType.UINT16) private Integer T6; @S7Variable(address = "DB7.164", type = EDataType.UINT16) private Integer STATE1; @S7Variable(address = "DB7.166", type = EDataType.UINT16) private Integer STATE2; @S7Variable(address = "DB7.168", type = EDataType.UINT16) private Integer STATE3; @S7Variable(address = "DB7.170", type = EDataType.UINT16) private Integer STATE4; @S7Variable(address = "DB7.172", type = EDataType.UINT16) private Integer STATE5; @S7Variable(address = "DB7.174", type = EDataType.UINT16) private Integer STATE6; @S7Variable(address = "DB7.1246", type = EDataType.UINT16) private Integer glassCount; @S7Variable(address = "DB7.8", type = EDataType.STRING, count = 22) private Integer DI1; @S7Variable(address = "DB7.30", type = EDataType.STRING, count = 22) private Integer DI2; @S7Variable(address = "DB7.52", type = EDataType.STRING, count = 22) private Integer DI3; @S7Variable(address = "DB7.74", type = EDataType.STRING, count = 22) private Integer DI4; @S7Variable(address = "DB7.96", type = EDataType.STRING, count = 22) private Integer DI5; @S7Variable(address = "DB7.118", type = EDataType.STRING, count = 22) private Integer DI6; @S7Variable(address = "MW1002", type = EDataType.UINT16) private Integer alarmSignal; } hangzhoumesParent/moduleService/CacheVerticalGlassModule/src/main/java/com/mes/s7/job/s7Job.java
New file @@ -0,0 +1,28 @@ package com.mes.s7.job; import com.github.xingshuangs.iot.protocol.s7.serializer.S7Serializer; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; /** * @Author : zhoush * @Date: 2025/4/30 14:20 * @Description: */ @Component @Slf4j public class s7Job { @Autowired(required = false) S7Serializer s7Serializer; @Scheduled(fixedDelay = 1000) public void hollowRemoveTaskOne() { // S7Data read = s7Serializer.read(S7Data.class); // log.info("read data: {}", read); } } 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, "10.153.19.192"); return S7Serializer.newInstance(s7PLC); } } hangzhoumesParent/moduleService/GlassStorageModule/src/main/java/com/mes/job/RawGlassTask.java
@@ -3,6 +3,7 @@ import cn.hutool.core.collection.CollectionUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; 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; @@ -16,6 +17,8 @@ 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.s7.job.S7Job; import com.mes.uppattenusage.entity.UpPattenUsage; import com.mes.uppattenusage.entity.vo.UpPattenUsageVO; import com.mes.uppattenusage.mapper.UpPattenUsageMapper; @@ -57,6 +60,9 @@ @Autowired(required = false) private MiloService miloService; @Autowired(required = false) S7Serializer s7Serializer; private static final String LOAD_GLASS_DEVICE_ONE_TASK = "load_glass_device_one_task"; @@ -64,6 +70,7 @@ private static final List<Integer> LOAD_STATION_01 = Arrays.asList(101, 102); private static final List<Integer> LOAD_STATION_02 = Arrays.asList(103, 104); private static final List<Integer> LOAD_STATION_ALL = Arrays.asList(101, 102, 103, 104); private static final Integer LEFTING_01 = 98; private static final Integer LEFTING_02 = 99; private static final Integer LOAD_GLASS_ONE_DEVICE = 5; @@ -71,23 +78,39 @@ @Scheduled(fixedDelay = 1000) public void rawStorageTask() throws Exception { 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 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() + ""; if ("0".equals(requestValue)) { if ("1".equals(confireWord.getValue() + "") && "0".equals(reportWord.getValue() + "")) { List<ReadWriteEntity> list = new ArrayList<>(); list.add(generateReadWriteEntity("CC.CC.confirmation", 0)); miloService.writeToOpcWord(list); 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); } if ("1".equals(taskWord.getValue() + "")) { 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; } @@ -127,8 +150,10 @@ @Scheduled(fixedDelay = 1000) public void rawStorageInCar() throws Exception { ReadWriteEntity entity = miloService.readFromOpcUa("CC.CC.inCar"); String value = entity.getValue() + ""; S7Data S7DataWL1 = s7Serializer.read(S7Data.class); String value = S7DataWL1.getInCar().toString(); // ReadWriteEntity entity = miloService.readFromOpcUa("CC.CC.inCar"); // String value = entity.getValue() + ""; if (!"1".equals(value)) { log.info("大车上没有架子"); return; @@ -146,8 +171,10 @@ @Scheduled(fixedDelay = 1000) public void rawStorageFinish() throws Exception { ReadWriteEntity entity = miloService.readFromOpcUa("CC.CC.reportWord"); String value = entity.getValue() + ""; S7Data S7DataWL1 = s7Serializer.read(S7Data.class); String value = S7DataWL1.getReportWord().toString(); // ReadWriteEntity entity = miloService.readFromOpcUa("CC.CC.reportWord"); // String value = entity.getValue() + ""; if ("0".equals(value)) { log.info("当前任务未汇报,结束本次任务"); return; @@ -210,9 +237,12 @@ .set(RawGlassStorageTask::getTaskState, Const.RAW_GLASS_TASK_FAILURE)); } 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() { @@ -405,6 +435,10 @@ if (CollectionUtils.isEmpty(loadStationList)) { log.info("1号上片位生成调度任务"); RawGlassStorageDetails rawDetails = getRawGlassStorageDetailsBySize(usageVOS.get(0), usageVOS.size()); if (CollectionUtils.isEmpty(loadStationList)) { log.info("仓库内无匹配的玻璃"); return Boolean.FALSE; } rawGlassStorageDetailsService.generateTask(rawDetails.getSlot(), loadStation.get(0), rawDetails.getShelf(), rawDetails.getRemainQuantity(), Const.RAW_GLASS_TASK_TYPE_DISPATCH); //结束调度任务 修改工位状态(起始位)状态为103 RAW_GLASS_STATE_RUNNING 任务完成后将状态改为101 目标位新增一条数据,架子号为(起始位) rawGlassStorageDetailsService.update(new LambdaUpdateWrapper<RawGlassStorageDetails>() @@ -546,6 +580,7 @@ .eq(RawGlassStorageDetails::getPatternWidth, usageVO.getWidth()) .eq(RawGlassStorageDetails::getPatternHeight, usageVO.getHeight()) .eq(RawGlassStorageDetails::getPatternThickness, usageVO.getThickness()) .notIn(RawGlassStorageDetails::getSlot, LOAD_STATION_ALL) .eq(RawGlassStorageDetails::getState, Const.GLASS_STATE_IN) .orderByAsc(RawGlassStorageDetails::getRemainQuantity) .last("order by abs(t.remain_quantity - " + remainQuantity + ") asc") 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/GlassStorageModule/src/main/java/com/mes/s7/job/S7Job.java
New file @@ -0,0 +1,28 @@ package com.mes.s7.job; import com.github.xingshuangs.iot.protocol.s7.serializer.S7Serializer; import com.mes.s7.entity.S7Data; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; /** * @Author : zhoush * @Date: 2025/4/30 14:20 * @Description: */ @Component @Slf4j public class S7Job { // @Autowired(required = false) // S7Serializer s7Serializer; // // @Scheduled(fixedDelay = 1000) // public void hollowRemoveTaskOne() { // S7Data S7DataWL1 = s7Serializer.read(S7Data.class); // log.info("read data: {}", S7DataWL1); // } } hangzhoumesParent/moduleService/GlassStorageModule/src/main/resources/application-alg.yml
New file @@ -0,0 +1,38 @@ spring: datasource: dynamic: primary: northGlassMes #设置默认的数据源或者数据源组,默认值即为master strict: false #设置严格模式,默认false不启动. 启动后在未匹配到指定数据源时候回抛出异常,不启动会使用默认数据源. datasource: northGlassMes: url: jdbc:mysql://192.168.10.86:3306/north_glass_mes?serverTimezone=GMT%2b8&allowMultiQueries=true username: root password: beibo.123/ driver-class-name: com.mysql.cj.jdbc.Driver salve_northGlassMes: url: jdbc:sqlserver://192.168.10.86:1433;databasename=north_glass_mes username: sa password: beibo.123/ driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver druid: wall: multi-statement-allow: true cloud: nacos: discovery: server-addr: 192.168.10.86:8848 redis: database: 0 host: 192.168.10.86 port: 6379 password: 123456 kangaroohy: milo: enabled: false primary: default config: default: endpoint: opc.tcp://192.168.10.86:49320 security-policy: basic256sha256 username: admin password: 1qaz2wsx3edc4rfv hangzhoumesParent/moduleService/LoadGlassModule/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 s7SerializerSP1() { S7PLC s7PLC = new S7PLC(EPlcType.S1200, "192.168.10.86"); 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.S7Data; import com.mes.s7.job.S7Job; 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.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; import org.springframework.util.CollectionUtils; @@ -53,6 +57,9 @@ @Resource private OptimizeProjectService optimizeProjectService; @Autowired(required = false) S7Serializer s7Serializer; private static final List<Integer> LOAD_STATION_01 = Arrays.asList(101, 102); private static final List<Integer> LOAD_STATION_02 = Arrays.asList(103, 104); @@ -74,7 +81,7 @@ opcLoadGlassChild(LOAD_GLASS_DEVICE_ONE_TASK, LOAD_GLASS_ONE_DEVICE); } @Scheduled(fixedDelay = 5000) // @Scheduled(fixedDelay = 5000) public void opcLoadGlassTwo() { opcLoadGlassChild(LOAD_GLASS_DEVICE_TWO_TASK, LOAD_GLASS_TWO_DEVICE); } @@ -84,7 +91,7 @@ opcLoadGlassFinishChid(LOAD_GLASS_DEVICE_ONE_TASK, LOAD_GLASS_ONE_DEVICE); } @Scheduled(fixedDelay = 5000) // @Scheduled(fixedDelay = 5000) public void opcLoadGlassTwoFinish() { opcLoadGlassFinishChid(LOAD_GLASS_DEVICE_TWO_TASK, LOAD_GLASS_TWO_DEVICE); } @@ -109,6 +116,7 @@ } private void opcLoadGlassChild(String tableName, Integer deviceId) { S7Data S7DataSP1 = s7Serializer.read(S7Data.class); Engineering engineering = engineeringMapper.selectOne(new LambdaQueryWrapper<Engineering>() .eq(Engineering::getState, Const.ENGINEERING_RUNNING).eq(Engineering::getStationCell, deviceId)); if (null == engineering) { @@ -117,11 +125,14 @@ } //任务暂停 LoadGlassDeviceTask task = loadGlassDeviceTaskService.queryTaskMessage(tableName); if (0 == task.getInkageState()) { ; if ("0".equals(S7DataSP1.getInkageState().toString())) { // if (0 == task.getInkageState()) { log.info("{}上片线,处于离线状态:{},结束本地上片请求", deviceId, task.getInkageState()); return; } if (task.getTaskRunning().equals(Const.ENGINEERING_RUNNING)) { if (S7DataSP1.getTaskRunning().toString().equals(Const.ENGINEERING_RUNNING)) { // if (task.getTaskRunning().equals(Const.ENGINEERING_RUNNING)) { log.info("{}上片线,有正在执行的任务,结束本地上片请求", deviceId); return; } @@ -181,19 +192,24 @@ } private void opcLoadGlassFinishChid(String tableName, Integer deviceId) { S7Data S7DataSP1 = s7Serializer.read(S7Data.class); LoadGlassDeviceTask task = loadGlassDeviceTaskService.queryTaskMessage(tableName); if (task.getTaskRunning().equals(Const.ENGINEERING_NEW)) { if (S7DataSP1.getTaskRunning().toString().equals(Const.ENGINEERING_NEW)) { // if (task.getTaskRunning().equals(Const.ENGINEERING_NEW)) { log.info("无任务,结束"); return; } if (task.getTaskState() <= 1) { if (Integer.parseInt(S7DataSP1.getTaskState().toString()) <= 1) { // if (task.getTaskState() <= 1) { log.info("任务正在执行,结束"); return; } //获取任务完成情况 // 已完成数量 破损数量 Integer finishCount = task.getFinishCount(); Integer damageCount = task.getDamageCount(); Integer finishCount = Integer.parseInt(S7DataSP1.getFinishCount().toString()); Integer damageCount = Integer.parseInt(S7DataSP1.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/S7Data.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 S7Data { @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; } hangzhoumesParent/moduleService/LoadGlassModule/src/main/java/com/mes/s7/job/S7Job.java
New file @@ -0,0 +1,34 @@ package com.mes.s7.job; import com.github.xingshuangs.iot.protocol.s7.serializer.S7Serializer; import com.mes.s7.entity.S7Data; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; /** * @Author : zhoush * @Date: 2025/4/30 14:20 * @Description: */ @Component @Slf4j public class S7Job { // @Autowired(required = false) // S7Serializer s7SerializerSP1; // S7Serializer s7SerializerSP2; // // public static S7Data S7DataSP1; // public static S7Data S7DataSP2; // // @Scheduled(fixedDelay = 1000) // public void hollowRemoveTaskOne() { // S7DataSP1 = s7SerializerSP1.read(S7Data.class); // log.info("read data: {}", S7DataSP1); // S7DataSP2 = s7SerializerSP2.read(S7Data.class); // log.info("read data: {}", S7DataSP2); // } } hangzhoumesParent/moduleService/LoadGlassModule/src/main/resources/application-alg.yml
New file @@ -0,0 +1,43 @@ spring: datasource: dynamic: primary: northGlassMes #设置默认的数据源或者数据源组,默认值即为master strict: false #设置严格模式,默认false不启动. 启动后在未匹配到指定数据源时候回抛出异常,不启动会使用默认数据源. datasource: northGlassMes: url: jdbc:mysql://192.168.10.86:3306/north_glass_mes?serverTimezone=GMT%2b8&allowMultiQueries=true username: root password: beibo.123/ driver-class-name: com.mysql.cj.jdbc.Driver pp: url: jdbc:mysql://192.168.10.86:3306/pp?serverTimezone=GMT%2b8 username: root password: beibo.123/ driver-class-name: com.mysql.cj.jdbc.Driver sd: url: jdbc:mysql://192.168.10.86:3306/sd?serverTimezone=GMT%2b8 username: root password: beibo.123/ driver-class-name: com.mysql.cj.jdbc.Driver druid: wall: multi-statement-allow: true cloud: nacos: discovery: server-addr: 192.168.10.86:8848 redis: database: 0 host: 192.168.10.86 port: 6379 password: 123456 kangaroohy: milo: enabled: false primary: default config: default: endpoint: opc.tcp://192.168.10.86:49320 security-policy: basic256sha256 username: admin password: 1qaz2wsx3edc4rfv