| | |
| | | <dependency> |
| | | <groupId>com.github.xingshuangs</groupId> |
| | | <artifactId>iot-communication</artifactId> |
| | | <version>1.4.2</version> |
| | | <version>1.5.4</version> |
| | | </dependency> |
| | | |
| | | <!--引入redis,排除lettuce的引用--> |
| | |
| | | public OptimizeHeatLayout selectHeatLayoutInfo(String engineerId, Integer temperingid) { |
| | | |
| | | QueryWrapper<OptimizeHeatLayout> wrapper = new QueryWrapper<>(); |
| | | wrapper.select("Top 1 *").eq("project_no", engineerId) |
| | | wrapper.eq("project_no", engineerId) |
| | | .eq("layout_id", temperingid); |
| | | return baseMapper.selectOne(wrapper); |
| | | } |
| New file |
| | |
| | | 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.100"); |
| | | // S7PLC s7PLC = new S7PLC(EPlcType.S1500, "10.153.19.191"); |
| | | return S7Serializer.newInstance(s7PLC); |
| | | } |
| | | |
| | | @Bean(name = "s7SerializerWLTwo") |
| | | public S7Serializer s7SerializerWLTwo() { |
| | | S7PLC s7PLC = new S7PLC(EPlcType.S1200, "192.168.10.130"); |
| | | // S7PLC s7PLC = new S7PLC(EPlcType.S1500, "10.153.19.191"); |
| | | return S7Serializer.newInstance(s7PLC); |
| | | } |
| | | |
| | | @Bean(name = "s7SerializerMBOne") |
| | | public S7Serializer s7SerializerMBOne() { |
| | | S7PLC s7PLC = new S7PLC(EPlcType.S1200, "192.168.10.58"); |
| | | // S7PLC s7PLC = new S7PLC(EPlcType.S1500, "10.153.19.191"); |
| | | return S7Serializer.newInstance(s7PLC); |
| | | } |
| | | |
| | | @Bean(name = "s7SerializerMBTwo") |
| | | public S7Serializer s7SerializerMBTwo() { |
| | | S7PLC s7PLC = new S7PLC(EPlcType.S1200, "192.168.10.18"); |
| | | // S7PLC s7PLC = new S7PLC(EPlcType.S1500, "10.153.19.191"); |
| | | return S7Serializer.newInstance(s7PLC); |
| | | } |
| | | |
| | | @Bean(name = "s7SerializerMBExtra") |
| | | public S7Serializer s7SerializerMBExtra() { |
| | | S7PLC s7PLC = new S7PLC(EPlcType.S1500, "192.168.20.100"); |
| | | return S7Serializer.newInstance(s7PLC); |
| | | } |
| | | } |
| | |
| | | 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; |
| | |
| | | import com.mes.edgstoragecage.service.EdgStorageCageService; |
| | | import com.mes.glassinfo.entity.GlassInfo; |
| | | import com.mes.glassinfo.service.GlassInfoService; |
| | | import com.mes.opctask.entity.EdgStorageDeviceTask; |
| | | import com.mes.opctask.entity.EdgStorageDeviceTaskHistory; |
| | | import com.mes.opctask.service.EdgStorageDeviceTaskHistoryService; |
| | | import com.mes.opctask.service.EdgStorageDeviceTaskService; |
| | | import com.mes.s7.entity.S7DataMB; |
| | | import com.mes.s7.entity.S7DataWL; |
| | | import com.mes.s7.entity.S7DataWLExtra; |
| | | 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; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | |
| | | @Resource |
| | | SysConfigService sysConfigService; |
| | | |
| | | @Autowired |
| | | @Qualifier("s7SerializerWLOne") |
| | | private S7Serializer s7SerializerWLOne; |
| | | |
| | | @Autowired |
| | | @Qualifier("s7SerializerWLTwo") |
| | | private S7Serializer s7SerializerWLTwo; |
| | | |
| | | @Autowired |
| | | @Qualifier("s7SerializerMBOne") |
| | | private S7Serializer s7SerializerMBOne; |
| | | |
| | | @Autowired |
| | | @Qualifier("s7SerializerMBTwo") |
| | | private S7Serializer s7SerializerMBTwo; |
| | | |
| | | // @Value("${mes.threshold}") |
| | | private int threshold; |
| | | // @Value("${mes.cellLength}") |
| | |
| | | |
| | | @Scheduled(fixedDelay = 1000) |
| | | public void startOneOpcTask() throws Exception { |
| | | S7DataWL s7DataWLTwo = s7SerializerWLTwo.read(S7DataWL.class); |
| | | S7DataWL s7DataWLOne = s7SerializerWLOne.read(S7DataWL.class); |
| | | log.info("一线卧理: {}", s7DataWLOne); |
| | | //获取第二条线路的卧式理片笼状态 |
| | | ReadWriteEntity twoInkageEntity = miloService.readFromOpcUa("WL2.WL2.deviceState"); |
| | | // ReadWriteEntity twoInkageEntity = miloService.readFromOpcUa("WL2.WL2.deviceState"); |
| | | Boolean twoInkageEntity = s7DataWLTwo.getDeviceState(); |
| | | // Boolean twoInkageEntity = Boolean.FALSE; |
| | | //默认只跑一台卧式理片,两条线路都可以走 |
| | | 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); |
| | | startOneOpcTaskChild(s7DataWLOne, 1, cellFlag); |
| | | } |
| | | |
| | | @Scheduled(fixedDelay = 1000) |
| | | public void startTwoOpcTask() throws Exception { |
| | | ReadWriteEntity oneInkageEntity = miloService.readFromOpcUa("WL1.WL1.deviceState"); |
| | | S7DataWL s7DataWLOne = s7SerializerWLOne.read(S7DataWL.class); |
| | | S7DataWL s7DataWLTwo = s7SerializerWLTwo.read(S7DataWL.class); |
| | | log.info("二线卧理: {}", s7DataWLTwo); |
| | | // 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); |
| | | startOneOpcTaskChild(s7DataWLTwo, 2, cellFlag); |
| | | } |
| | | |
| | | private void startOneOpcTaskChild(String tableName, int device, int cellFlag) throws Exception { |
| | | // private void startOneOpcTaskChild(String tableName, int device, int cellFlag) throws Exception { |
| | | private void startOneOpcTaskChild(S7DataWL task, int device, int cellFlag) throws Exception { |
| | | threshold = sysConfigService.queryConfigValue(ConstSysConfig.CACHE_THRESHOLD); |
| | | cellLength = sysConfigService.queryConfigValue(ConstSysConfig.CACHE_CELL_LENGTH); |
| | | ratio = sysConfigService.queryConfigValue(ConstSysConfig.CACHE_RATIO); |
| | |
| | | maxTwoSecondLength = sysConfigService.queryConfigValue(ConstSysConfig.CACHE_MAX_SECOND_LENGTH); |
| | | maxThickness = sysConfigService.queryConfigValue(ConstSysConfig.CACHE_MAX_THICKNESS); |
| | | |
| | | EdgStorageDeviceTask task = edgStorageDeviceTaskService.queryTaskMessage(tableName); |
| | | // EdgStorageDeviceTask task = edgStorageDeviceTaskService.queryTaskMessage(tableName); |
| | | |
| | | if (task == null) { |
| | | log.info("任务表基础数据录入失败,请检查数据是否录入成功"); |
| | | return; |
| | |
| | | //进片任务 |
| | | log.info("设备:{}状态:{}", device, request); |
| | | log.info("进片任务:进片玻璃id为:{}", task.getGlassIdIn()); |
| | | intoTask(task, tableName, device); |
| | | intoTask(task, "", device); |
| | | } else if (request == 2 && taskRunning == 0) { |
| | | //出片任务 |
| | | outTask(task, tableName, device, cellFlag); |
| | | outTask(task, "", device, cellFlag); |
| | | } else if (request == 3 && taskRunning == 0) { |
| | | //直通任务 |
| | | log.info("设备:{}状态:{}", device, request); |
| | | if (!outTask(task, tableName, device, cellFlag)) { |
| | | intoTask(task, tableName, device); |
| | | if (!outTask(task, "", device, cellFlag)) { |
| | | intoTask(task, "", device); |
| | | } |
| | | } else if (request == 4) { |
| | | log.info("设备:{}状态:{}", device, request); |
| | | log.info("将启动子改为4"); |
| | | task.setTaskRunning(Const.GLASS_CACHE_TYPE_RUNNING); |
| | | edgStorageDeviceTaskService.updateTaskMessage(tableName, task); |
| | | // task.setTaskRunning(Const.GLASS_CACHE_TYPE_RUNNING); |
| | | // edgStorageDeviceTaskService.updateTaskMessage(tableName, task); |
| | | if (device == 2) { |
| | | task.setTaskRunning(Const.GLASS_CACHE_TYPE_RUNNING); |
| | | s7SerializerWLTwo.write(S7DataWL.builder().taskRunning(Const.GLASS_CACHE_TYPE_RUNNING).build()); |
| | | } else { |
| | | task.setTaskRunning(Const.GLASS_CACHE_TYPE_RUNNING); |
| | | s7SerializerWLOne.write(S7DataWL.builder().taskRunning(Const.GLASS_CACHE_TYPE_RUNNING).build()); |
| | | } |
| | | |
| | | } else if (request == 5) { |
| | | log.info("设备:{}状态:{}", device, request); |
| | | finishTask(task, tableName, device); |
| | | finishTask(task, "", device); |
| | | } else { |
| | | log.info("玻璃异常处理"); |
| | | damageTask(task, tableName, device); |
| | | damageTask(task, "", device); |
| | | } |
| | | // } catch(Exception e) |
| | | // |
| | |
| | | |
| | | @Scheduled(fixedDelay = 1000) |
| | | public void edgOneOpcTask() throws Exception { |
| | | EdgStorageDeviceTask task = edgStorageDeviceTaskService.queryTaskMessage(EDG_STORAGE_DEVICE_ONE_TASK); |
| | | String glassId = task.getGlassId(); |
| | | // EdgStorageDeviceTask task = edgStorageDeviceTaskService.queryTaskMessage(EDG_STORAGE_DEVICE_ONE_TASK); |
| | | // String glassId = task.getGlassId(); |
| | | S7DataWL s7DataWLOne = s7SerializerWLOne.read(S7DataWL.class); |
| | | String glassId = s7DataWLOne.getGlassId(); |
| | | log.info("1号线玻璃id{},历史id{}", glassId, glassIdOne); |
| | | if (StringUtils.isBlank(glassId) || glassId.equals(glassIdOne)) { |
| | | log.info("{}号线磨边前玻璃未就位,结束本次任务", 1); |
| | | return; |
| | |
| | | |
| | | @Scheduled(fixedDelay = 1000) |
| | | public void edgTwoOpcTask() throws Exception { |
| | | EdgStorageDeviceTask task = edgStorageDeviceTaskService.queryTaskMessage(EDG_STORAGE_DEVICE_TWO_TASK); |
| | | String glassId = task.getGlassId(); |
| | | // EdgStorageDeviceTask task = edgStorageDeviceTaskService.queryTaskMessage(EDG_STORAGE_DEVICE_TWO_TASK); |
| | | // String glassId = task.getGlassId(); |
| | | S7DataWL s7DataWLTwo = s7SerializerWLTwo.read(S7DataWL.class); |
| | | // S7DataMB s7DataMB = s7SerializerMBOne.read(S7DataMB.class); |
| | | // log.info("磨边数据{}", s7DataMB); |
| | | String glassId = s7DataWLTwo.getGlassId(); |
| | | log.info("2号线玻璃id{},历史id{}", glassId, glassIdTwo); |
| | | if (StringUtils.isBlank(glassId) || glassId.equals(glassIdTwo)) { |
| | | log.info("{}号线磨边前玻璃未就位,结束本次任务", 2); |
| | | return; |
| | |
| | | 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)); |
| | | |
| | | miloService.writeToOpcUa(list); |
| | | miloService.writeToOpcWord(generateReadWriteEntity("MB" + cell + ".MB" + cell + ".thickness", (int) glassInfo.getThickness() * ratio)); |
| | | S7DataMB s7DataMB = new S7DataMB(); |
| | | s7DataMB.setToEdingId(Integer.parseInt(toEndingId)); |
| | | s7DataMB.setGlassId(Integer.parseInt(toEndingId)); |
| | | s7DataMB.setWidth((int) Math.max(glassInfo.getWidth() * ratio, glassInfo.getHeight() * ratio)); |
| | | s7DataMB.setHeight((int) Math.min(glassInfo.getWidth() * ratio, glassInfo.getHeight() * ratio)); |
| | | log.info("玻璃id:{},{}线向PLC发送宽高数据{}", glassId, cell, s7DataMB); |
| | | if (cell == 1) { |
| | | s7SerializerMBOne.write(s7DataMB); |
| | | } else { |
| | | s7SerializerMBTwo.write(s7DataMB); |
| | | } |
| | | s7DataMB = new S7DataMB(); |
| | | s7DataMB.setThickness((int) (glassInfo.getThickness() * ratio)); |
| | | log.info("{}线向PLC发送厚度数据{}", cell, s7DataMB); |
| | | if (cell == 1) { |
| | | s7SerializerMBOne.write(s7DataMB); |
| | | } else { |
| | | s7SerializerMBTwo.write(s7DataMB); |
| | | } |
| | | //修改磨边对列中的磨边线路及状态 |
| | | edgGlassTaskInfoService.update(new LambdaUpdateWrapper<EdgGlassTaskInfo>() |
| | | .set(EdgGlassTaskInfo::getLine, cell) |
| | |
| | | } |
| | | } |
| | | |
| | | private boolean intoTask(EdgStorageDeviceTask task, String tableName, int deviceId) { |
| | | private boolean intoTask(S7DataWL task, String tableName, int deviceId) { |
| | | Date startDate = new Date(); |
| | | log.info("开始执行进片任务,任务信息为:{},表名为:{},设备id:{},开始时间:{}", task, tableName, deviceId, startDate); |
| | | //获取玻璃的基本信息 |
| | |
| | | log.info("结束进片任务设备为{},结束时间为:{},共耗时:{}ms", deviceId, endDate, endDate.getTime() - startDate.getTime()); |
| | | return Boolean.FALSE; |
| | | } |
| | | EdgStorageCage edgStorageCage = edgStorageCageService.selectNearestEmpty(task.getCurrentCell(), deviceId, Boolean.FALSE); |
| | | // EdgStorageCage edgStorageCage = edgStorageCageService.selectNearestEmpty(task.getCurrentCell(), deviceId, Boolean.FALSE); |
| | | EdgStorageCage edgStorageCage = edgStorageCageService.selectNearestEmpty(Integer.parseInt(task.getCurrentCell().toString()), deviceId, Boolean.FALSE); |
| | | Assert.isTrue(null != edgStorageCage, "格子已满"); |
| | | log.info("4、将玻璃信息插入卧式理片笼,当前玻璃信息:{}", glassInfo); |
| | | EdgStorageCageDetails details = new EdgStorageCageDetails(); |
| | |
| | | edgStorageCageDetailsService.save(details); |
| | | |
| | | //更新任务信息 |
| | | // task.setStartCell(edgStorageCage.getSlot()); |
| | | // task.setTaskRunning(Const.GLASS_CACHE_TYPE_IN); |
| | | // edgStorageDeviceTaskService.updateTaskMessage(tableName, task); |
| | | task.setStartCell(edgStorageCage.getSlot()); |
| | | task.setTaskRunning(Const.GLASS_CACHE_TYPE_IN); |
| | | edgStorageDeviceTaskService.updateTaskMessage(tableName, task); |
| | | if (deviceId == 1) { |
| | | s7SerializerWLOne.write( |
| | | S7DataWL.builder().startCell(edgStorageCage.getSlot()) |
| | | .taskRunning(Const.GLASS_CACHE_TYPE_IN).build() |
| | | ); |
| | | } else { |
| | | s7SerializerWLTwo.write( |
| | | S7DataWL.builder().startCell(edgStorageCage.getSlot()) |
| | | .taskRunning(Const.GLASS_CACHE_TYPE_IN).build() |
| | | ); |
| | | } |
| | | saveHistoryTask(task, deviceId); |
| | | //记录进片任务的玻璃id用于下次任务的比较,防止同一块玻璃重复执行 |
| | | if (deviceId == 1) { |
| | |
| | | return Boolean.TRUE; |
| | | } |
| | | |
| | | private boolean outTask(EdgStorageDeviceTask task, String tableName, int deviceId, int cellFlag) throws Exception { |
| | | private boolean outTask(S7DataWL 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"); |
| | | S7DataWL s7DataWLOne = s7SerializerWLOne.read(S7DataWL.class); |
| | | S7DataWL s7DataWLTwo = s7SerializerWLTwo.read(S7DataWL.class); |
| | | S7DataWLExtra s7DataWLExtraTwo = s7SerializerWLTwo.read(S7DataWLExtra.class); |
| | | Integer oneOutStateEntity = s7DataWLOne.getSlotState(); |
| | | Integer twoOutStateEntity = s7DataWLTwo.getSlotState(); |
| | | Integer d06OutStateEntity = s7DataWLExtraTwo.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状态 |
| | |
| | | return Boolean.TRUE; |
| | | } |
| | | |
| | | private boolean outChildTask(EdgStorageDeviceTask task, String tableName, int deviceId, int cell, Date startDate) { |
| | | private boolean outChildTask(S7DataWL task, String tableName, int deviceId, int cell, Date startDate) { |
| | | EdgStorageCageDetails edgStorageCageDetails = null; |
| | | |
| | | //笼内是版图相差是否超过阈值 |
| | |
| | | } |
| | | //前面已经尺寸问题处理完毕,开始计算无相同尺寸的新玻璃小片 |
| | | if (null == edgStorageCageDetails) { |
| | | edgStorageCageDetails = edgStorageCageDetailsService.queryEdgStorageDetailsByLimitSize(deviceId, task.getCurrentCell(), 0, 0, |
| | | edgStorageCageDetails = edgStorageCageDetailsService.queryEdgStorageDetailsByLimitSize(deviceId, Integer.parseInt(task.getCurrentCell().toString()), 0, 0, |
| | | cell, minOneFirstLength, minOneSecondLength, maxTwoFirstLength, maxTwoSecondLength, maxThickness); |
| | | } |
| | | if (edgStorageCageDetails == null && StringUtils.isNotBlank(task.getGlassIdIn())) { |
| | |
| | | task.setStartCell(edgStorageCageDetails.getSlot()); |
| | | task.setTaskRunning(taskType); |
| | | task.setEndCell(cell); |
| | | |
| | | edgStorageDeviceTaskService.updateTaskMessage(tableName, task); |
| | | // edgStorageDeviceTaskService.updateTaskMessage(tableName, task); |
| | | if (deviceId == 1) { |
| | | s7SerializerWLOne.write( |
| | | S7DataWL.builder() |
| | | .glassIdOut(edgStorageCageDetails.getGlassId()) |
| | | .startCell(edgStorageCageDetails.getSlot()) |
| | | .taskRunning(taskType) |
| | | .endCell(cell) |
| | | .build() |
| | | ); |
| | | } else { |
| | | s7SerializerWLTwo.write( |
| | | S7DataWL.builder() |
| | | .glassIdOut(edgStorageCageDetails.getGlassId()) |
| | | .startCell(edgStorageCageDetails.getSlot()) |
| | | .taskRunning(taskType) |
| | | .endCell(cell) |
| | | .build() |
| | | ); |
| | | } |
| | | saveHistoryTask(task, deviceId); |
| | | //记录直通任务的玻璃id用于下次任务的比较,防止同一块玻璃重复执行 |
| | | if (3 == task.getTaskState()) { |
| | |
| | | return Boolean.TRUE; |
| | | } |
| | | |
| | | private boolean finishTask(EdgStorageDeviceTask task, String tableName, int device) { |
| | | private boolean finishTask(S7DataWL task, String tableName, int device) { |
| | | if (task.getTaskState() <= 4) { |
| | | log.info("有正在执行的任务或这任务已执行任务状态{},任务启动情况{},结束", task.getTaskState(), task.getTaskRunning()); |
| | | return Boolean.FALSE; |
| | | } |
| | | Date startDate = new Date(); |
| | | log.info("开始执行完成任务后清除动作,任务信息为:{},表名为:{},开始时间:{}", task, tableName, startDate); |
| | | task.setTaskRunning(Const.GLASS_CACHE_TYPE_EMPTY); |
| | | task.setGlassIdOut(""); |
| | | task.setStartCell(0); |
| | | task.setEndCell(0); |
| | | // task.setTaskRunning(Const.GLASS_CACHE_TYPE_EMPTY); |
| | | // task.setGlassIdOut(""); |
| | | // task.setStartCell(0); |
| | | // task.setEndCell(0); |
| | | EdgStorageDeviceTaskHistory taskHistory = edgStorageDeviceTaskHistoryService.getOne(new LambdaQueryWrapper<EdgStorageDeviceTaskHistory>() |
| | | .eq(EdgStorageDeviceTaskHistory::getTaskState, Const.RAW_GLASS_TASK_NEW) |
| | | .eq(EdgStorageDeviceTaskHistory::getDeviceId, device) |
| | |
| | | ); |
| | | } |
| | | //最后更新任务,保证任务前的动作都做完 |
| | | edgStorageDeviceTaskService.updateTaskMessage(tableName, task); |
| | | |
| | | // task.setTaskRunning(Const.GLASS_CACHE_TYPE_EMPTY); |
| | | // task.setGlassIdOut(""); |
| | | // task.setStartCell(0); |
| | | // task.setEndCell(0); |
| | | // edgStorageDeviceTaskService.updateTaskMessage(tableName, task); |
| | | if (device == 1) { |
| | | s7SerializerWLOne.write( |
| | | S7DataWL.builder() |
| | | .taskRunning(Const.GLASS_CACHE_TYPE_EMPTY) |
| | | .glassIdOut("") |
| | | .startCell(0) |
| | | .endCell(0) |
| | | .build() |
| | | ); |
| | | } else { |
| | | s7SerializerWLTwo.write( |
| | | S7DataWL.builder() |
| | | .taskRunning(Const.GLASS_CACHE_TYPE_EMPTY) |
| | | .glassIdOut("") |
| | | .startCell(0) |
| | | .endCell(0) |
| | | .build() |
| | | ); |
| | | } |
| | | Date endDate = new Date(); |
| | | log.info("结束完成任务后清除动作,表名为:{},结束时间为:{},共耗时:{}ms", tableName, endDate, endDate.getTime() - startDate.getTime()); |
| | | return Boolean.TRUE; |
| | | } |
| | | |
| | | private boolean damageTask(EdgStorageDeviceTask task, String tableName, int device) { |
| | | private boolean damageTask(S7DataWL task, String tableName, int device) { |
| | | if (task.getTaskState() <= 5) { |
| | | log.info("任务未发生异常清空,任务结束,电气状态{},mes状态{}", task.getTaskState(), task.getTaskRunning()); |
| | | return Boolean.FALSE; |
| | |
| | | ); |
| | | } |
| | | //最后更新任务,保证任务前的动作都做完 |
| | | task.setTaskRunning(Const.GLASS_CACHE_TYPE_EMPTY); |
| | | task.setGlassIdOut(""); |
| | | task.setStartCell(0); |
| | | task.setEndCell(0); |
| | | edgStorageDeviceTaskService.updateTaskMessage(tableName, task); |
| | | // task.setTaskRunning(Const.GLASS_CACHE_TYPE_EMPTY); |
| | | // task.setGlassIdOut(""); |
| | | // task.setStartCell(0); |
| | | // task.setEndCell(0); |
| | | // edgStorageDeviceTaskService.updateTaskMessage(tableName, task); |
| | | if (device == 1) { |
| | | s7SerializerWLOne.write( |
| | | S7DataWL.builder() |
| | | .taskRunning(Const.GLASS_CACHE_TYPE_EMPTY) |
| | | .glassIdOut("") |
| | | .startCell(0) |
| | | .endCell(0) |
| | | .build() |
| | | ); |
| | | } else { |
| | | s7SerializerWLTwo.write( |
| | | S7DataWL.builder() |
| | | .taskRunning(Const.GLASS_CACHE_TYPE_EMPTY) |
| | | .glassIdOut("") |
| | | .startCell(0) |
| | | .endCell(0) |
| | | .build() |
| | | ); |
| | | } |
| | | Date endDate = new Date(); |
| | | log.info("完成执行异常处理任务后清除动作,表名为:{},结束时间为:{},共耗时:{}ms", tableName, endDate, endDate.getTime() - startDate.getTime()); |
| | | return Boolean.TRUE; |
| | |
| | | } |
| | | } |
| | | |
| | | public boolean saveHistoryTask(EdgStorageDeviceTask task, int deviceId) { |
| | | // public boolean saveHistoryTask(EdgStorageDeviceTask task, int deviceId) { |
| | | public boolean saveHistoryTask(S7DataWL task, int deviceId) { |
| | | EdgStorageDeviceTaskHistory taskHistory = new EdgStorageDeviceTaskHistory(); |
| | | BeanUtils.copyProperties(task, taskHistory); |
| | | // taskHistory.setTaskType(task.getTaskRunning()); |
| | | taskHistory.setTaskType(task.getTaskRunning()); |
| | | taskHistory.setCreateTime(new Date()); |
| | | taskHistory.setTaskState(Const.RAW_GLASS_TASK_NEW); |
| | |
| | | package com.mes.job; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.github.xingshuangs.iot.protocol.s7.serializer.S7Serializer; |
| | | import com.kangaroohy.milo.model.ReadWriteEntity; |
| | | import com.kangaroohy.milo.service.MiloService; |
| | | import com.mes.glassinfo.entity.GlassInfo; |
| | | import com.mes.glassinfo.service.GlassInfoService; |
| | | import com.mes.s7.entity.S7DataMBExtra; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | 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.StringUtils; |
| | |
| | | @Autowired(required = false) |
| | | MiloService miloService; |
| | | |
| | | @Autowired |
| | | @Qualifier("s7SerializerMBExtra") |
| | | private S7Serializer s7SerializerMBExtra; |
| | | |
| | | @Resource |
| | | GlassInfoService glassInfoService; |
| | | |
| | | |
| | | @Scheduled(fixedDelay = 2000) |
| | | public void startOneEdgTask() throws Exception { |
| | |
| | | } |
| | | |
| | | private void startEdgTaskChild(String cell) throws Exception { |
| | | ReadWriteEntity request = miloService.readFromOpcUa("MB04.MB04.request" + cell); |
| | | if (null == request || "0".equals(request.getValue() + "")) { |
| | | S7DataMBExtra s7DataMBExtra = s7SerializerMBExtra.read(S7DataMBExtra.class); |
| | | log.info("MB04读取数据{}", s7DataMBExtra); |
| | | // ReadWriteEntity request = miloService.readFromOpcUa("MB04.MB04.request" + cell); |
| | | // if (null == request || "0".equals(request.getValue() + "")) { |
| | | String request = ""; |
| | | String glassIdEntity = ""; |
| | | if ("01".equals(cell)) { |
| | | request = s7DataMBExtra.getRequestOne().toString(); |
| | | glassIdEntity = s7DataMBExtra.getPlcGlassIdOne(); |
| | | } else { |
| | | request = s7DataMBExtra.getRequestTwo().toString(); |
| | | glassIdEntity = s7DataMBExtra.getPlcGlassIdTwo(); |
| | | } |
| | | if (null == request || "0".equals(request)) { |
| | | log.info("未收到玻璃请求,结束本次任务"); |
| | | return; |
| | | } |
| | | ReadWriteEntity glassIdEntity = miloService.readFromOpcUa("MB04.MB04.plc_glass_id_" + cell); |
| | | |
| | | if (null == glassIdEntity || StringUtils.isEmpty(glassIdEntity.getValue() + "")) { |
| | | // ReadWriteEntity glassIdEntity = miloService.readFromOpcUa("MB04.MB04.plc_glass_id_" + cell); |
| | | // if (null == glassIdEntity || StringUtils.isEmpty(glassIdEntity.getValue() + "")) { |
| | | if (null == glassIdEntity || StringUtils.isEmpty(glassIdEntity)) { |
| | | log.info("有请求但玻璃id为空,结束本次任务"); |
| | | return; |
| | | } |
| | | String glassId = glassIdEntity.getValue() + ""; |
| | | // String glassId = glassIdEntity.getValue() + ""; |
| | | String glassId = glassIdEntity; |
| | | log.info("获取到{}线的玻璃id:{}", cell, glassId); |
| | | GlassInfo glassInfo = glassInfoService.getOne(new LambdaQueryWrapper<GlassInfo>().eq(GlassInfo::getGlassId, glassId).last("limit 1")); |
| | | |
| | | List<ReadWriteEntity> ualist = new ArrayList<>(); |
| | | ualist.add(generateReadWriteEntity("MB04.MB04.width" + cell, (int) Math.max(glassInfo.getWidth() * 10, glassInfo.getHeight() * 10))); |
| | | ualist.add(generateReadWriteEntity("MB04.MB04.height" + cell, (int) Math.min(glassInfo.getWidth() * 10, glassInfo.getHeight() * 10))); |
| | | ualist.add(generateReadWriteEntity("MB04.MB04.thickness" + cell, (int) glassInfo.getThickness() * 10)); |
| | | miloService.writeToOpcWord(ualist); |
| | | miloService.writeToOpcUa(generateReadWriteEntity("MB04.MB04.mes_glass_Id_" + cell, glassId)); |
| | | // List<ReadWriteEntity> ualist = new ArrayList<>(); |
| | | // ualist.add(generateReadWriteEntity("MB04.MB04.width" + cell, (int) Math.max(glassInfo.getWidth() * 10, glassInfo.getHeight() * 10))); |
| | | // ualist.add(generateReadWriteEntity("MB04.MB04.height" + cell, (int) Math.min(glassInfo.getWidth() * 10, glassInfo.getHeight() * 10))); |
| | | // ualist.add(generateReadWriteEntity("MB04.MB04.thickness" + cell, (int) glassInfo.getThickness() * 10)); |
| | | // miloService.writeToOpcWord(ualist); |
| | | // miloService.writeToOpcUa(generateReadWriteEntity("MB04.MB04.mes_glass_Id_" + cell, glassId)); |
| | | log.info("{}线发送尺寸信息宽:{},高:{},厚度:{}", cell, Math.max(glassInfo.getWidth() * 10, glassInfo.getHeight() * 10), Math.min(glassInfo.getWidth() * 10, glassInfo.getHeight() * 10), glassInfo.getThickness() * 10); |
| | | if ("01".equals(cell)) { |
| | | s7SerializerMBExtra.write( |
| | | S7DataMBExtra.builder() |
| | | .widthOne((int) Math.max(glassInfo.getWidth() * 10, glassInfo.getHeight() * 10)) |
| | | .heightOne((int) Math.min(glassInfo.getWidth() * 10, glassInfo.getHeight() * 10)) |
| | | .thicknessOne((int) (glassInfo.getThickness() * 10)) |
| | | .build() |
| | | ); |
| | | s7SerializerMBExtra.write( |
| | | S7DataMBExtra.builder().mesGlassIdOne(glassId).build() |
| | | ); |
| | | } else { |
| | | s7SerializerMBExtra.write( |
| | | S7DataMBExtra.builder() |
| | | .widthTwo((int) Math.max(glassInfo.getWidth() * 10, glassInfo.getHeight() * 10)) |
| | | .heightTwo((int) Math.min(glassInfo.getWidth() * 10, glassInfo.getHeight() * 10)) |
| | | .thicknessTwo((int) (glassInfo.getThickness() * 10)) |
| | | .build() |
| | | ); |
| | | s7SerializerMBExtra.write( |
| | | S7DataMBExtra.builder().mesglassIdTwo(glassId).build() |
| | | ); |
| | | } |
| | | } |
| | | |
| | | private ReadWriteEntity generateReadWriteEntity(String identifier, Object value) { |
| New file |
| | |
| | | package com.mes.s7.entity; |
| | | |
| | | import com.github.xingshuangs.iot.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 S7DataMB { |
| | | |
| | | |
| | | @S7Variable(address = "DB323.6", type = EDataType.FLOAT32) |
| | | private Float speed; |
| | | |
| | | @S7Variable(address = "DB324.2", type = EDataType.INT32) |
| | | private Integer toEdingId; |
| | | |
| | | @S7Variable(address = "DB324.6", type = EDataType.INT32) |
| | | private Integer glassId; |
| | | |
| | | @S7Variable(address = "DB324.10", type = EDataType.INT32) |
| | | private Integer width; |
| | | |
| | | @S7Variable(address = "DB324.14", type = EDataType.INT32) |
| | | private Integer height; |
| | | |
| | | @S7Variable(address = "DB324.18", type = EDataType.UINT16) |
| | | private Integer thickness; |
| | | |
| | | @S7Variable(address = "DB324.0.3", type = EDataType.BOOL) |
| | | private Boolean mesControl; |
| | | |
| | | // @S7Variable(address = "DB49.126", type = EDataType.INT32) |
| | | // private Integer toEdingId; |
| | | // |
| | | // @S7Variable(address = "DB49.130", type = EDataType.INT32) |
| | | // private Integer glassId; |
| | | // |
| | | // @S7Variable(address = "DB49.134", type = EDataType.INT32) |
| | | // private Integer width; |
| | | // |
| | | // @S7Variable(address = "DB49.138", type = EDataType.INT32) |
| | | // private Integer height; |
| | | // |
| | | // @S7Variable(address = "DB49.142", type = EDataType.UINT16) |
| | | // private Short thickness; |
| | | |
| | | } |
| New file |
| | |
| | | package com.mes.s7.entity; |
| | | |
| | | import com.github.xingshuangs.iot.common.enums.EDataType; |
| | | import com.github.xingshuangs.iot.protocol.s7.serializer.S7Variable; |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.Builder; |
| | | import lombok.Data; |
| | | import lombok.NoArgsConstructor; |
| | | |
| | | /** |
| | | * @Author : zhoush |
| | | * @Date: 2025/4/30 14:19 |
| | | * @Description: |
| | | */ |
| | | @Data |
| | | @Builder |
| | | @NoArgsConstructor |
| | | @AllArgsConstructor |
| | | public class S7DataMBExtra { |
| | | |
| | | |
| | | @S7Variable(address = "DB49.0", type = EDataType.UINT16) |
| | | private Integer requestOne; |
| | | |
| | | @S7Variable(address = "DB49.46", type = EDataType.UINT16) |
| | | private Integer widthOne; |
| | | |
| | | @S7Variable(address = "DB49.48", type = EDataType.UINT16) |
| | | private Integer heightOne; |
| | | |
| | | @S7Variable(address = "DB49.50", type = EDataType.UINT16) |
| | | private Integer thicknessOne; |
| | | |
| | | @S7Variable(address = "DB49.52", type = EDataType.UINT16) |
| | | private Integer requestTwo; |
| | | |
| | | @S7Variable(address = "DB49.98", type = EDataType.UINT16) |
| | | private Integer widthTwo; |
| | | |
| | | @S7Variable(address = "DB49.100", type = EDataType.UINT16) |
| | | private Integer heightTwo; |
| | | |
| | | @S7Variable(address = "DB49.102", type = EDataType.UINT16) |
| | | private Integer thicknessTwo; |
| | | |
| | | @S7Variable(address = "DB49.2", type = EDataType.STRING, count = 14) |
| | | private String plcGlassIdOne; |
| | | |
| | | @S7Variable(address = "DB49.24", type = EDataType.STRING, count = 14) |
| | | private String mesGlassIdOne; |
| | | |
| | | @S7Variable(address = "DB49.54", type = EDataType.STRING, count = 14) |
| | | private String plcGlassIdTwo; |
| | | |
| | | @S7Variable(address = "DB49.76", type = EDataType.STRING, count = 14) |
| | | private String mesglassIdTwo; |
| | | |
| | | } |
| New file |
| | |
| | | package com.mes.s7.entity; |
| | | |
| | | import com.github.xingshuangs.iot.common.enums.EDataType; |
| | | import com.github.xingshuangs.iot.protocol.s7.serializer.S7Variable; |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.Builder; |
| | | import lombok.Data; |
| | | import lombok.NoArgsConstructor; |
| | | |
| | | /** |
| | | * @Author : zhoush |
| | | * @Date: 2025/4/30 14:19 |
| | | * @Description: |
| | | */ |
| | | @Data |
| | | @Builder |
| | | @NoArgsConstructor |
| | | @AllArgsConstructor |
| | | public class S7DataWL { |
| | | |
| | | |
| | | @S7Variable(address = "DB49.0", type = EDataType.UINT16) |
| | | private Integer taskRunning; |
| | | |
| | | @S7Variable(address = "DB49.46", type = EDataType.UINT16) |
| | | private Integer currentCell; |
| | | |
| | | @S7Variable(address = "DB49.48", type = EDataType.UINT16) |
| | | private Integer startCell; |
| | | |
| | | @S7Variable(address = "DB49.50", type = EDataType.UINT16) |
| | | private Integer endCell; |
| | | |
| | | @S7Variable(address = "DB49.52", type = EDataType.UINT16) |
| | | private Integer TaskState; |
| | | |
| | | @S7Variable(address = "DB49.116", type = EDataType.UINT16) |
| | | private Integer inPlace; |
| | | |
| | | @S7Variable(address = "DB49.124", type = EDataType.UINT16) |
| | | private Integer slotState; |
| | | |
| | | @S7Variable(address = "DB49.118", type = EDataType.FLOAT32) |
| | | private Float speed; |
| | | |
| | | @S7Variable(address = "DB49.2", type = EDataType.STRING, count = 14) |
| | | private String glassIdIn; |
| | | |
| | | @S7Variable(address = "DB49.24", type = EDataType.STRING, count = 14) |
| | | private String glassIdOut; |
| | | |
| | | @S7Variable(address = "DB49.94", type = EDataType.STRING, count = 14) |
| | | private String glassId; |
| | | |
| | | @S7Variable(address = "DB49.112.0", type = EDataType.BOOL) |
| | | private Boolean deviceState; |
| | | |
| | | } |
| New file |
| | |
| | | package com.mes.s7.entity; |
| | | |
| | | import com.github.xingshuangs.iot.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 S7DataWLExtra { |
| | | |
| | | @S7Variable(address = "DB49.126", type = EDataType.UINT16) |
| | | private Integer d06SlotState; |
| | | |
| | | } |
| | |
| | | |
| | | spring: |
| | | profiles: |
| | | active: dev |
| | | active: yw |
| | | application: |
| | | name: cacheGlass |
| | | liquibase: |
| New file |
| | |
| | | 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 = "s7SerializerDLPOne") |
| | | public S7Serializer s7SerializerDLPOne() { |
| | | S7PLC s7PLC = new S7PLC(EPlcType.S1500, "192.168.20.140"); |
| | | // S7PLC s7PLC = new S7PLC(EPlcType.S1500, "10.153.19.191"); |
| | | return S7Serializer.newInstance(s7PLC); |
| | | } |
| | | |
| | | @Bean(name = "s7SerializerDLPTwo") |
| | | public S7Serializer s7SerializerDLPTwo() { |
| | | S7PLC s7PLC = new S7PLC(EPlcType.S1500, "192.168.20.140"); |
| | | // S7PLC s7PLC = new S7PLC(EPlcType.S1500, "10.153.19.191"); |
| | | return S7Serializer.newInstance(s7PLC); |
| | | } |
| | | |
| | | } |
| | |
| | | |
| | | import cn.hutool.json.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.github.xingshuangs.iot.protocol.s7.serializer.S7Serializer; |
| | | import com.kangaroohy.milo.model.ReadWriteEntity; |
| | | import com.kangaroohy.milo.service.MiloService; |
| | | import com.mes.bigstorage.entity.BigStorageCageDetails; |
| | |
| | | import com.mes.glassinfo.service.GlassInfoService; |
| | | import com.mes.largenscreen.entity.PieChartVO; |
| | | import com.mes.largenscreen.entity.RunTime; |
| | | import com.mes.s7.entity.S7DataDLPOne; |
| | | import com.mes.s7.entity.S7DataDLPTwo; |
| | | import com.mes.temperingglass.entity.TemperingGlassInfo; |
| | | import com.mes.temperingglass.service.TemperingGlassInfoService; |
| | | import com.mes.tools.WebSocketServer; |
| | | import com.mes.utils.RedisUtil; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | 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; |
| | | |
| | |
| | | @Autowired(required = false) |
| | | MiloService miloService; |
| | | |
| | | @Autowired |
| | | @Qualifier("s7SerializerDLPOne") |
| | | private S7Serializer s7SerializerDLPOne; |
| | | |
| | | @Autowired |
| | | @Qualifier("s7SerializerDLPTwo") |
| | | private S7Serializer s7SerializerDLPTwo; |
| | | |
| | | private JSONObject jsonObject = new JSONObject(); |
| | | |
| | | public void queryDataSource1() throws Exception { |
| | | S7DataDLPOne s7DataDLPOne = s7SerializerDLPOne.read(S7DataDLPOne.class); |
| | | S7DataDLPTwo s7DataWLTwo = s7SerializerDLPTwo.read(S7DataDLPTwo.class); |
| | | List<Double> carPostion = new ArrayList<>(); |
| | | carPostion.add(0.25); |
| | | carPostion.add(0.5); |
| | |
| | | try { |
| | | //进片任务数据 |
| | | List<BigStorageTaskVO> inTaskList = new ArrayList(); |
| | | ReadWriteEntity fromOpcUa = miloService.readFromOpcUa("DLP1A.DLP1A.FROM1"); |
| | | // ReadWriteEntity fromOpcUa = miloService.readFromOpcUa("DLP1A.DLP1A.FROM1"); |
| | | String fromOpcUa = s7DataDLPOne.getFrom1().toString(); |
| | | List<Integer> states = s7DataDLPOne.getStates(); |
| | | List<Integer> tos = s7DataDLPOne.getTos(); |
| | | List<String> ids = s7DataDLPOne.getIds(); |
| | | for (int i = 1; i <= 6; i++) { |
| | | ReadWriteEntity requestWord = miloService.readFromOpcUa("DLP1A.DLP1A.DI" + i); |
| | | ReadWriteEntity targetSlotWord = miloService.readFromOpcUa("DLP1A.DLP1A.TO" + i); |
| | | ReadWriteEntity stateWord = miloService.readFromOpcUa("DLP1A.DLP1A.STATE" + i); |
| | | if (null != requestWord.getValue()) { |
| | | // ReadWriteEntity requestWord = miloService.readFromOpcUa("DLP1A.DLP1A.DI" + i); |
| | | // ReadWriteEntity targetSlotWord = miloService.readFromOpcUa("DLP1A.DLP1A.TO" + i); |
| | | // ReadWriteEntity stateWord = miloService.readFromOpcUa("DLP1A.DLP1A.STATE" + i); |
| | | String requestWord = ids.get(i - 1); |
| | | String targetSlotWord = tos.get(i - 1).toString(); |
| | | String stateWord = states.get(i - 1).toString(); |
| | | // if (null != requestWord.getValue()) { |
| | | if (null != requestWord) { |
| | | BigStorageTaskVO task = new BigStorageTaskVO(); |
| | | task.setGlassId(requestWord.getValue() + ""); |
| | | // task.setGlassId(requestWord.getValue() + ""); |
| | | task.setGlassId(requestWord); |
| | | int isExistCount = bigStorageCageDetailsService.count(new LambdaQueryWrapper<BigStorageCageDetails>().in(BigStorageCageDetails::getGlassId, task.getGlassId()) |
| | | .in(BigStorageCageDetails::getState, Const.GLASS_STATE_IN_ALL)); |
| | | if (isExistCount > 0) { |
| | |
| | | } else { |
| | | task.setIsSame(0); |
| | | } |
| | | task.setStartSlot(Integer.parseInt(fromOpcUa.getValue() + "")); |
| | | task.setTargetSlot(Integer.parseInt(targetSlotWord.getValue() + "")); |
| | | task.setTaskState(Integer.parseInt(stateWord.getValue() + "")); |
| | | // task.setStartSlot(Integer.parseInt(fromOpcUa.getValue() + "")); |
| | | // task.setTargetSlot(Integer.parseInt(targetSlotWord.getValue() + "")); |
| | | // task.setTaskState(Integer.parseInt(stateWord.getValue() + "")); |
| | | task.setStartSlot(Integer.parseInt(fromOpcUa)); |
| | | task.setTargetSlot(Integer.parseInt(targetSlotWord)); |
| | | task.setTaskState(Integer.parseInt(stateWord)); |
| | | inTaskList.add(task); |
| | | continue; |
| | | } |
| | |
| | | } |
| | | try { |
| | | //进片联机 |
| | | ReadWriteEntity inkageEntity = miloService.readFromOpcUa("DLP1A.DLP1A.mesControl"); |
| | | jsonObject.append("inkageEntity", inkageEntity.getValue()); |
| | | // ReadWriteEntity inkageEntity = miloService.readFromOpcUa("DLP1A.DLP1A.mesControl"); |
| | | // jsonObject.append("inkageEntity", inkageEntity.getValue()); |
| | | Boolean inkageEntity = s7DataDLPOne.getMesControl(); |
| | | jsonObject.append("inkageEntity", inkageEntity); |
| | | //进片请求 |
| | | ReadWriteEntity requestEntity = miloService.readFromOpcUa("DLP1A.DLP1A.RequestMes"); |
| | | jsonObject.append("requestEntity", requestEntity.getValue()); |
| | | // ReadWriteEntity requestEntity = miloService.readFromOpcUa("DLP1A.DLP1A.RequestMes"); |
| | | // jsonObject.append("requestEntity", requestEntity.getValue()); |
| | | String requestEntity = s7DataDLPOne.getRequestMes().toString(); |
| | | jsonObject.append("requestEntity", requestEntity); |
| | | //启动命令 |
| | | ReadWriteEntity mesReplyEntity = miloService.readFromOpcUa("DLP1A.DLP1A.MesReply"); |
| | | jsonObject.append("mesReplyEntity", mesReplyEntity.getValue()); |
| | | // ReadWriteEntity mesReplyEntity = miloService.readFromOpcUa("DLP1A.DLP1A.MesReply"); |
| | | // jsonObject.append("mesReplyEntity", mesReplyEntity.getValue()); |
| | | String mesReplyEntity = s7DataDLPOne.getMesReply().toString(); |
| | | jsonObject.append("mesReplyEntity", mesReplyEntity); |
| | | //出片联机 |
| | | ReadWriteEntity outInkageEntity = miloService.readFromOpcUa("DLP1B.DLP1B.mesControl"); |
| | | jsonObject.append("outInkageEntity", outInkageEntity.getValue()); |
| | | // ReadWriteEntity outInkageEntity = miloService.readFromOpcUa("DLP1B.DLP1B.mesControl"); |
| | | // jsonObject.append("outInkageEntity", outInkageEntity.getValue()); |
| | | Boolean outInkageEntity = s7DataWLTwo.getMesControl(); |
| | | jsonObject.append("outInkageEntity", outInkageEntity); |
| | | //出片请求 |
| | | ReadWriteEntity outRequestEntity = miloService.readFromOpcUa("DLP1B.DLP1B.RequestMes"); |
| | | jsonObject.append("outRequestEntity", outRequestEntity.getValue()); |
| | | // ReadWriteEntity outRequestEntity = miloService.readFromOpcUa("DLP1B.DLP1B.RequestMes"); |
| | | // jsonObject.append("outRequestEntity", outRequestEntity.getValue()); |
| | | String outRequestEntity = s7DataWLTwo.getRequestMes().toString(); |
| | | jsonObject.append("outRequestEntity", outRequestEntity); |
| | | |
| | | |
| | | //出片任务数据 |
| | | List<BigStorageCageTask> outTaskList = bigStorageCageTaskService.queryTaskMessage("big_storage_cage_out_one_task"); |
| | | // List<BigStorageCageTask> outTaskList = bigStorageCageTaskService.queryTaskMessage("big_storage_cage_out_one_task"); |
| | | List<BigStorageCageTask> outTaskList = new ArrayList<>(); |
| | | for (int i = 0; i < 6; i++) { |
| | | |
| | | BigStorageCageTask bigStorageCageTask = new BigStorageCageTask(); |
| | | String glassId = ""; |
| | | Integer startSlot = 0; |
| | | Integer targetSlot = 0; |
| | | Integer taskState = 0; |
| | | switch (i) { |
| | | case 0: |
| | | glassId = s7DataWLTwo.getId1(); |
| | | startSlot = s7DataWLTwo.getFrom1(); |
| | | targetSlot = s7DataWLTwo.getTo1(); |
| | | taskState = s7DataWLTwo.getState1(); |
| | | ; |
| | | break; |
| | | case 1: |
| | | glassId = s7DataWLTwo.getId2(); |
| | | startSlot = s7DataWLTwo.getFrom2(); |
| | | targetSlot = s7DataWLTwo.getTo2(); |
| | | taskState = s7DataWLTwo.getState2(); |
| | | break; |
| | | case 2: |
| | | glassId = s7DataWLTwo.getId3(); |
| | | startSlot = s7DataWLTwo.getFrom3(); |
| | | targetSlot = s7DataWLTwo.getTo3(); |
| | | taskState = s7DataWLTwo.getState3(); |
| | | break; |
| | | case 3: |
| | | glassId = s7DataWLTwo.getId4(); |
| | | startSlot = s7DataWLTwo.getFrom4(); |
| | | targetSlot = s7DataWLTwo.getTo4(); |
| | | taskState = s7DataWLTwo.getState4(); |
| | | break; |
| | | case 4: |
| | | glassId = s7DataWLTwo.getId5(); |
| | | startSlot = s7DataWLTwo.getFrom5(); |
| | | targetSlot = s7DataWLTwo.getTo5(); |
| | | taskState = s7DataWLTwo.getState5(); |
| | | break; |
| | | case 5: |
| | | glassId = s7DataWLTwo.getId6(); |
| | | startSlot = s7DataWLTwo.getFrom6(); |
| | | targetSlot = s7DataWLTwo.getTo6(); |
| | | taskState = s7DataWLTwo.getState6(); |
| | | break; |
| | | } |
| | | bigStorageCageTask.setGlassId(glassId); |
| | | bigStorageCageTask.setStartSlot(startSlot); |
| | | bigStorageCageTask.setTargetSlot(targetSlot); |
| | | bigStorageCageTask.setTaskState(taskState); |
| | | outTaskList.add(bigStorageCageTask); |
| | | } |
| | | jsonObject.append("bigStorageCageDetailsOutTask", outTaskList); |
| | | } catch (Exception e) { |
| | | //todo:不做任务处理 |
| | |
| | | import cn.hutool.core.lang.Assert; |
| | | 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.github.yulichang.toolkit.JoinWrappers; |
| | | import com.kangaroohy.milo.model.ReadWriteEntity; |
| | | import com.kangaroohy.milo.service.MiloService; |
| | |
| | | import com.mes.edgglasstask.service.EdgGlassTaskInfoService; |
| | | import com.mes.glassinfo.entity.GlassInfo; |
| | | import com.mes.glassinfo.service.GlassInfoService; |
| | | import com.mes.s7.entity.S7DataDLPOne; |
| | | import com.mes.s7.entity.S7DataDLPTwo; |
| | | import com.mes.sysconfig.service.SysConfigService; |
| | | import com.mes.temperingglass.entity.TemperingGlassInfo; |
| | | import com.mes.temperingglass.service.TemperingGlassInfoService; |
| | |
| | | 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; |
| | | |
| | |
| | | @Autowired(required = false) |
| | | MiloService miloService; |
| | | |
| | | @Autowired |
| | | @Qualifier("s7SerializerDLPOne") |
| | | private S7Serializer s7SerializerDLPOne; |
| | | |
| | | @Autowired |
| | | @Qualifier("s7SerializerDLPTwo") |
| | | private S7Serializer s7SerializerDLPTwo; |
| | | |
| | | @Resource |
| | | SysConfigService sysConfigService; |
| | | |
| | |
| | | |
| | | @Scheduled(fixedDelay = 1000) |
| | | public void inBigStorageTask() throws Exception { |
| | | ReadWriteEntity inkageEntity = miloService.readFromOpcUa("DLP1A.DLP1A.mesControl"); |
| | | if (true != Boolean.parseBoolean(inkageEntity.getValue() + "")) { |
| | | S7DataDLPOne s7DataDLPOne = s7SerializerDLPOne.read(S7DataDLPOne.class); |
| | | // ReadWriteEntity inkageEntity = miloService.readFromOpcUa("DLP1A.DLP1A.mesControl"); |
| | | // if (true != Boolean.parseBoolean(inkageEntity.getValue() + "")) { |
| | | Boolean inkageEntity = s7DataDLPOne.getMesControl(); |
| | | if (true != inkageEntity) { |
| | | log.info("当前为非联机状态,结束进片任务"); |
| | | return; |
| | | } |
| | | ReadWriteEntity requestEntity = miloService.readFromOpcUa("DLP1A.DLP1A.RequestMes"); |
| | | if (!"1".equals(requestEntity.getValue() + "")) { |
| | | // ReadWriteEntity requestEntity = miloService.readFromOpcUa("DLP1A.DLP1A.RequestMes"); |
| | | // if (!"1".equals(requestEntity.getValue() + "")) { |
| | | String requestEntity = s7DataDLPOne.getRequestMes().toString(); |
| | | if (!"1".equals(requestEntity)) { |
| | | log.info("当前未收到进片请求,结束进片任务"); |
| | | return; |
| | | } |
| | | ReadWriteEntity mesReplyEntity = miloService.readFromOpcUa("DLP1A.DLP1A.MesReply"); |
| | | if ("1".equals(mesReplyEntity.getValue() + "")) { |
| | | // ReadWriteEntity mesReplyEntity = miloService.readFromOpcUa("DLP1A.DLP1A.MesReply"); |
| | | // if ("1".equals(mesReplyEntity.getValue() + "")) { |
| | | String mesReplyEntity = s7DataDLPOne.getMesReply().toString(); |
| | | if ("1".equals(mesReplyEntity)) { |
| | | log.info("有正在执行的任务,结束进片任务"); |
| | | return; |
| | | } |
| | | //获取进片任务信息 |
| | | List<BigStorageCageTask> inTaskList = new ArrayList(); |
| | | ReadWriteEntity fromOpcUa = miloService.readFromOpcUa("DLP1A.DLP1A.FROM1"); |
| | | // ReadWriteEntity fromOpcUa = miloService.readFromOpcUa("DLP1A.DLP1A.FROM1"); |
| | | String fromOpcUa = s7DataDLPOne.getFrom1().toString(); |
| | | |
| | | List<String> ids = s7DataDLPOne.getIds(); |
| | | List<String> glassIdList = new ArrayList<>(); |
| | | for (int i = 1; i <= 6; i++) { |
| | | ReadWriteEntity requestWord = miloService.readFromOpcUa("DLP1A.DLP1A.DI" + i); |
| | | if (null != requestWord.getValue()) { |
| | | for (int i = 0; i < 6; i++) { |
| | | // ReadWriteEntity requestWord = miloService.readFromOpcUa("DLP1A.DLP1A.DI" + i); |
| | | String requestWord = ids.get(i); |
| | | // if (null != requestWord.getValue()) { |
| | | if (null != requestWord && !requestWord.isEmpty()) { |
| | | BigStorageCageTask task = new BigStorageCageTask(); |
| | | task.setGlassId(requestWord.getValue() + ""); |
| | | task.setStartSlot(Integer.parseInt(fromOpcUa.getValue() + "")); |
| | | // task.setGlassId(requestWord.getValue() + ""); |
| | | task.setGlassId(requestWord); |
| | | // task.setStartSlot(Integer.parseInt(fromOpcUa.getValue() + "")); |
| | | task.setStartSlot(Integer.parseInt(fromOpcUa)); |
| | | inTaskList.add(task); |
| | | glassIdList.add(requestWord.getValue() + ""); |
| | | // glassIdList.add(requestWord.getValue() + ""); |
| | | glassIdList.add(requestWord); |
| | | continue; |
| | | } |
| | | } |
| | |
| | | return; |
| | | } |
| | | log.info("获取任务的玻璃id:{}", glassIdList); |
| | | ReadWriteEntity countEntity = miloService.readFromOpcUa("DLP1A.DLP1A.glassCount"); |
| | | if (null == countEntity.getValue() || Integer.parseInt(countEntity.getValue() + "") != glassIdList.size()) { |
| | | log.info("当前大车进片玻璃数量{}与mes读取到的数量{}不匹配,结束进片任务", countEntity.getValue(), glassIdList.size()); |
| | | // ReadWriteEntity countEntity = miloService.readFromOpcUa("DLP1A.DLP1A.glassCount"); |
| | | String countEntity = s7DataDLPOne.getGlassCount().toString(); |
| | | // if (null == countEntity.getValue() || Integer.parseInt(countEntity.getValue() + "") != glassIdList.size()) { |
| | | if (null == countEntity || Integer.parseInt(countEntity) != glassIdList.size()) { |
| | | log.info("当前大车进片玻璃数量{}与mes读取到的数量{}不匹配,结束进片任务", countEntity, glassIdList.size()); |
| | | //向plc发送报警:当前大车进片玻璃数量与mes读取到的数量不匹配 |
| | | miloService.writeToOpcWord(generateReadWriteEntity("DLP1A.DLP1A.alarmSignal", 1)); |
| | | // miloService.writeToOpcWord(generateReadWriteEntity("DLP1A.DLP1A.alarmSignal", 1)); |
| | | s7DataDLPOne = new S7DataDLPOne(); |
| | | s7DataDLPOne.setAlarmSignal(1); |
| | | s7SerializerDLPOne.write(s7DataDLPOne); |
| | | return; |
| | | } |
| | | Map<String, Long> glassCountMap = glassIdList.stream().collect(Collectors.groupingBy(e -> e, Collectors.counting())); |
| | |
| | | if (entry.getValue() > 1) { |
| | | log.info("进片玻璃{}存在相同,结束本次任务", entry.getKey()); |
| | | //向plc发送报警:同一车进片玻璃存在相同 |
| | | miloService.writeToOpcWord(generateReadWriteEntity("DLP1A.DLP1A.alarmSignal", 2)); |
| | | // miloService.writeToOpcWord(generateReadWriteEntity("DLP1A.DLP1A.alarmSignal", 2)); |
| | | s7DataDLPOne = new S7DataDLPOne(); |
| | | s7DataDLPOne.setAlarmSignal(2); |
| | | s7SerializerDLPOne.write(s7DataDLPOne); |
| | | return; |
| | | } |
| | | } |
| | |
| | | if (CollectionUtil.isNotEmpty(detailsList)) { |
| | | log.info("理片笼存在相同的进片玻璃{},结束本次任务", detailsList); |
| | | //向plc发送报警:理片笼存在相同的进片玻璃 |
| | | miloService.writeToOpcWord(generateReadWriteEntity("DLP1A.DLP1A.alarmSignal", 4)); |
| | | // miloService.writeToOpcWord(generateReadWriteEntity("DLP1A.DLP1A.alarmSignal", 4)); |
| | | s7DataDLPOne = new S7DataDLPOne(); |
| | | s7DataDLPOne.setAlarmSignal(4); |
| | | s7SerializerDLPOne.write(s7DataDLPOne); |
| | | return; |
| | | } |
| | | List<GlassInfo> glassInfoList = glassInfoService.list(new LambdaQueryWrapper<GlassInfo>().in(GlassInfo::getGlassId, glassIdList)); |
| | |
| | | if (glassInfoList.size() != inTaskList.size()) { |
| | | log.info("进片任务数量{}与玻璃数量{}不匹配,结束本次进片", inTaskList.size(), glassInfoList.size()); |
| | | //向plc发送报警:进片任务数量与系统查询到的玻璃数量不匹配 |
| | | miloService.writeToOpcWord(generateReadWriteEntity("DLP1A.DLP1A.alarmSignal", 8)); |
| | | // miloService.writeToOpcWord(generateReadWriteEntity("DLP1A.DLP1A.alarmSignal", 8)); |
| | | s7DataDLPOne = new S7DataDLPOne(); |
| | | s7DataDLPOne.setAlarmSignal(8); |
| | | s7SerializerDLPOne.write(s7DataDLPOne); |
| | | return; |
| | | } |
| | | Integer glassGap = sysConfigService.queryConfigValue(ConstSysConfig.VERTICAL_GLASS_GAP); |
| | |
| | | if (count < entry.getValue()) { |
| | | log.info("笼内格子剩余数量不足,结束本次进片"); |
| | | //向plc发送报警:笼内格子剩余数量不足 |
| | | miloService.writeToOpcWord(generateReadWriteEntity("DLP1A.DLP1A.alarmSignal", 16)); |
| | | // miloService.writeToOpcWord(generateReadWriteEntity("DLP1A.DLP1A.alarmSignal", 16)); |
| | | s7DataDLPOne = new S7DataDLPOne(); |
| | | s7DataDLPOne.setAlarmSignal(16); |
| | | s7SerializerDLPOne.write(s7DataDLPOne); |
| | | return; |
| | | } |
| | | } |
| | |
| | | if (count > 0) { |
| | | log.info("直通片台存在玻璃,结束本次进片"); |
| | | //向plc发送报警:直通片台存在玻璃,无法继续直通 |
| | | miloService.writeToOpcWord(generateReadWriteEntity("DLP1A.DLP1A.alarmSignal", 64)); |
| | | // miloService.writeToOpcWord(generateReadWriteEntity("DLP1A.DLP1A.alarmSignal", 64)); |
| | | s7DataDLPOne = new S7DataDLPOne(); |
| | | s7DataDLPOne.setAlarmSignal(64); |
| | | s7SerializerDLPOne.write(s7DataDLPOne); |
| | | return; |
| | | } |
| | | } |
| | |
| | | .eq(BigStorageCage::getSlot, bigStorageDTO.getSlot())); |
| | | task.setTargetSlot(bigStorageDTO.getSlot()); |
| | | task.setGlassId(info.getGlassId()); |
| | | bigStorageCageTaskService.updateTaskMessage("big_storage_cage_in_one_task", task); |
| | | // bigStorageCageTaskService.updateTaskMessage("big_storage_cage_in_one_task", task); |
| | | //存放历史任务 |
| | | BigStorageCageHistoryTask historyTask = new BigStorageCageHistoryTask(); |
| | | BeanUtils.copyProperties(task, historyTask); |
| | |
| | | } else { |
| | | BigStorageCageTask task = inTaskList.get(0); |
| | | task.setTargetSlot(THROUGH_SLOT); |
| | | bigStorageCageTaskService.updateTaskMessage("big_storage_cage_in_one_task", task); |
| | | // bigStorageCageTaskService.updateTaskMessage("big_storage_cage_in_one_task", task); |
| | | //存放历史任务 |
| | | BigStorageCageHistoryTask historyTask = new BigStorageCageHistoryTask(); |
| | | BeanUtils.copyProperties(task, historyTask); |
| | |
| | | //历史数据入库 |
| | | bigStorageCageHistoryTaskService.saveBatch(historyTasks); |
| | | //向opc发送启动信号 |
| | | List<ReadWriteEntity> list = new ArrayList<>(); |
| | | for (int i = 1; i <= inTaskList.size(); i++) { |
| | | list.add(generateReadWriteEntity("DLP1A.DLP1A.TO" + i, inTaskList.get(i - 1).getTargetSlot())); |
| | | // List<ReadWriteEntity> list = new ArrayList<>(); |
| | | // for (int i = 1; i <= inTaskList.size(); i++) { |
| | | // list.add(generateReadWriteEntity("DLP1A.DLP1A.TO" + i, inTaskList.get(i - 1).getTargetSlot())); |
| | | // } |
| | | // list.add(generateReadWriteEntity("DLP1A.DLP1A.MesReply", 1)); |
| | | // miloService.writeToOpcWord(list); |
| | | s7DataDLPOne = new S7DataDLPOne(); |
| | | for (int i = 0; i < inTaskList.size(); i++) { |
| | | Integer value = Integer.parseInt(inTaskList.get(i).getTargetSlot().toString()); |
| | | switch (i) { |
| | | case 0: |
| | | s7DataDLPOne.setTo1(value); |
| | | break; |
| | | case 1: |
| | | s7DataDLPOne.setTo2(value); |
| | | break; |
| | | case 2: |
| | | s7DataDLPOne.setTo3(value); |
| | | break; |
| | | case 3: |
| | | s7DataDLPOne.setTo4(value); |
| | | break; |
| | | case 4: |
| | | s7DataDLPOne.setTo5(value); |
| | | break; |
| | | case 5: |
| | | s7DataDLPOne.setTo6(value); |
| | | break; |
| | | } |
| | | } |
| | | list.add(generateReadWriteEntity("DLP1A.DLP1A.MesReply", 1)); |
| | | miloService.writeToOpcWord(list); |
| | | s7SerializerDLPOne.write(s7DataDLPOne); |
| | | s7DataDLPOne = new S7DataDLPOne(); |
| | | s7DataDLPOne.setMesReply(1); |
| | | s7SerializerDLPOne.write(s7DataDLPOne); |
| | | } |
| | | |
| | | @Scheduled(fixedDelay = 1000) |
| | | public void outBigStorageTask() throws Exception { |
| | | Date startDate = new Date(); |
| | | ReadWriteEntity inkageEntity = miloService.readFromOpcUa("DLP1B.DLP1B.mesControl"); |
| | | if (true != Boolean.parseBoolean(inkageEntity.getValue() + "")) { |
| | | S7DataDLPTwo s7DataWLTwo = s7SerializerDLPTwo.read(S7DataDLPTwo.class); |
| | | // ReadWriteEntity inkageEntity = miloService.readFromOpcUa("DLP1B.DLP1B.mesControl"); |
| | | // if (true != Boolean.parseBoolean(inkageEntity.getValue() + "")) { |
| | | Boolean inkageEntity = s7DataWLTwo.getMesControl(); |
| | | if (true != inkageEntity) { |
| | | log.info("当前为非联机状态,结束进片任务"); |
| | | return; |
| | | } |
| | | ReadWriteEntity requestEntity = miloService.readFromOpcUa("DLP1B.DLP1B.RequestMes"); |
| | | if (!"1".equals(requestEntity.getValue() + "")) { |
| | | // ReadWriteEntity requestEntity = miloService.readFromOpcUa("DLP1B.DLP1B.RequestMes"); |
| | | // if (!"1".equals(requestEntity.getValue() + "")) { |
| | | String requestEntity = s7DataWLTwo.getRequestMes().toString(); |
| | | if (!"1".equals(requestEntity)) { |
| | | log.info("当前未收到出片请求,结束出片任务"); |
| | | return; |
| | | } |
| | | //获取出片任务表 |
| | | List<BigStorageCageTask> outTaskList = bigStorageCageTaskService.queryTaskMessage("big_storage_cage_out_one_task"); |
| | | List<BigStorageCageTask> outTaskList = getOutTaskList(s7DataWLTwo); |
| | | // List<BigStorageCageTask> outTaskList = bigStorageCageTaskService.queryTaskMessage("big_storage_cage_out_one_task"); |
| | | if (CollectionUtil.isNotEmpty(outTaskList)) { |
| | | log.info("有正在执行的出片任务,结束本次出片任务"); |
| | | return; |
| | |
| | | |
| | | @Scheduled(fixedDelay = 1000) |
| | | public void finishInBigStorageTask() throws Exception { |
| | | ReadWriteEntity inkageEntity = miloService.readFromOpcUa("DLP1A.DLP1A.mesControl"); |
| | | if (true != Boolean.parseBoolean(inkageEntity.getValue() + "")) { |
| | | S7DataDLPOne s7DataDLPOne = s7SerializerDLPOne.read(S7DataDLPOne.class); |
| | | // ReadWriteEntity inkageEntity = miloService.readFromOpcUa("DLP1A.DLP1A.mesControl"); |
| | | // if (true != Boolean.parseBoolean(inkageEntity.getValue() + "")) { |
| | | Boolean inkageEntity = s7DataDLPOne.getMesControl(); |
| | | if (true != inkageEntity) { |
| | | log.info("当前为非联机状态,结束完成进片任务"); |
| | | return; |
| | | } |
| | |
| | | List<BigStorageCageTask> inTaskList = new ArrayList(); |
| | | |
| | | List<String> glassIdList = new ArrayList<>(); |
| | | ReadWriteEntity toWord = miloService.readFromOpcUa("DLP1A.DLP1A.TO1"); |
| | | if ("0".equals(toWord.getValue() + "")) { |
| | | // ReadWriteEntity toWord = miloService.readFromOpcUa("DLP1A.DLP1A.TO1"); |
| | | // if ("0".equals(toWord.getValue() + "")) { |
| | | String toWord = s7DataDLPOne.getTo1().toString(); |
| | | if ("0".equals(toWord)) { |
| | | log.info("完成任务已执行,结束本次完成进片任务"); |
| | | return; |
| | | } |
| | | for (int i = 1; i <= 6; i++) { |
| | | ReadWriteEntity requestWord = miloService.readFromOpcUa("DLP1A.DLP1A.DI" + i); |
| | | ReadWriteEntity statetWord = miloService.readFromOpcUa("DLP1A.DLP1A.STATE" + i); |
| | | ReadWriteEntity toOpcUa = miloService.readFromOpcUa("DLP1A.DLP1A.TO" + i); |
| | | ReadWriteEntity fromOpcUa = miloService.readFromOpcUa("DLP1A.DLP1A.FROM" + i); |
| | | for (int i = 0; i < 6; i++) { |
| | | // ReadWriteEntity requestWord = miloService.readFromOpcUa("DLP1A.DLP1A.DI" + i); |
| | | // ReadWriteEntity statetWord = miloService.readFromOpcUa("DLP1A.DLP1A.STATE" + i); |
| | | // ReadWriteEntity toOpcUa = miloService.readFromOpcUa("DLP1A.DLP1A.TO" + i); |
| | | // ReadWriteEntity fromOpcUa = miloService.readFromOpcUa("DLP1A.DLP1A.FROM" + i); |
| | | String requestWord = ""; |
| | | String statetWord = ""; |
| | | String toOpcUa = ""; |
| | | String fromOpcUa = ""; |
| | | switch (i) { |
| | | case 0: |
| | | requestWord = s7DataDLPOne.getId1(); |
| | | statetWord = s7DataDLPOne.getState1().toString(); |
| | | toOpcUa = s7DataDLPOne.getTo1().toString(); |
| | | fromOpcUa = s7DataDLPOne.getFrom1().toString(); |
| | | break; |
| | | case 1: |
| | | requestWord = s7DataDLPOne.getId2(); |
| | | statetWord = s7DataDLPOne.getState2().toString(); |
| | | toOpcUa = s7DataDLPOne.getTo2().toString(); |
| | | fromOpcUa = s7DataDLPOne.getFrom2().toString(); |
| | | break; |
| | | case 2: |
| | | requestWord = s7DataDLPOne.getId3(); |
| | | statetWord = s7DataDLPOne.getState3().toString(); |
| | | toOpcUa = s7DataDLPOne.getTo3().toString(); |
| | | fromOpcUa = s7DataDLPOne.getFrom3().toString(); |
| | | break; |
| | | case 3: |
| | | requestWord = s7DataDLPOne.getId4(); |
| | | statetWord = s7DataDLPOne.getState4().toString(); |
| | | toOpcUa = s7DataDLPOne.getTo4().toString(); |
| | | fromOpcUa = s7DataDLPOne.getFrom4().toString(); |
| | | break; |
| | | case 4: |
| | | requestWord = s7DataDLPOne.getId5(); |
| | | statetWord = s7DataDLPOne.getState5().toString(); |
| | | toOpcUa = s7DataDLPOne.getTo5().toString(); |
| | | fromOpcUa = s7DataDLPOne.getFrom5().toString(); |
| | | break; |
| | | case 5: |
| | | requestWord = s7DataDLPOne.getId6(); |
| | | statetWord = s7DataDLPOne.getState6().toString(); |
| | | toOpcUa = s7DataDLPOne.getTo6().toString(); |
| | | fromOpcUa = s7DataDLPOne.getFrom6().toString(); |
| | | break; |
| | | } |
| | | |
| | | if (null != requestWord.getValue()) { |
| | | // if (null != requestWord.getValue()) { |
| | | if (!requestWord.isEmpty()) { |
| | | BigStorageCageTask task = new BigStorageCageTask(); |
| | | task.setGlassId(requestWord.getValue() + ""); |
| | | task.setTargetSlot(Integer.parseInt(toOpcUa.getValue() + "")); |
| | | task.setTaskState(Integer.parseInt(statetWord.getValue() + "")); |
| | | task.setStartSlot(Integer.parseInt(fromOpcUa.getValue() + "")); |
| | | // task.setGlassId(requestWord.getValue() + ""); |
| | | // task.setTargetSlot(Integer.parseInt(toOpcUa.getValue() + "")); |
| | | // task.setTaskState(Integer.parseInt(statetWord.getValue() + "")); |
| | | // task.setStartSlot(Integer.parseInt(fromOpcUa.getValue() + "")); |
| | | task.setGlassId(requestWord); |
| | | task.setTargetSlot(Integer.parseInt(toOpcUa)); |
| | | task.setTaskState(Integer.parseInt(statetWord)); |
| | | task.setStartSlot(Integer.parseInt(fromOpcUa)); |
| | | inTaskList.add(task); |
| | | glassIdList.add(requestWord.getValue() + ""); |
| | | // glassIdList.add(requestWord.getValue() + ""); |
| | | glassIdList.add(requestWord); |
| | | continue; |
| | | } |
| | | } |
| | |
| | | .eq(BigStorageCageHistoryTask::getGlassId, item.getGlassId())); |
| | | item.setTargetSlot(0); |
| | | //清空任务表数据 |
| | | bigStorageCageTaskService.updateTaskMessage("big_storage_cage_in_one_task", item); |
| | | // bigStorageCageTaskService.updateTaskMessage("big_storage_cage_in_one_task", item); |
| | | } |
| | | //清空启动状态 |
| | | //向opc发送启动信号 |
| | | //向opc发送启动信号 |
| | | List<ReadWriteEntity> list = new ArrayList<>(); |
| | | for (int i = 1; i <= 6; i++) { |
| | | list.add(generateReadWriteEntity("DLP1A.DLP1A.TO" + i, 0)); |
| | | } |
| | | list.add(generateReadWriteEntity("DLP1A.DLP1A.MesReply", 0)); |
| | | miloService.writeToOpcWord(list); |
| | | // List<ReadWriteEntity> list = new ArrayList<>(); |
| | | // for (int i = 1; i <= 6; i++) { |
| | | // list.add(generateReadWriteEntity("DLP1A.DLP1A.TO" + i, 0)); |
| | | // } |
| | | // list.add(generateReadWriteEntity("DLP1A.DLP1A.MesReply", 0)); |
| | | // miloService.writeToOpcWord(list); |
| | | s7DataDLPOne = new S7DataDLPOne(); |
| | | s7DataDLPOne.setTo1(0); |
| | | s7DataDLPOne.setTo2(0); |
| | | s7DataDLPOne.setTo3(0); |
| | | s7DataDLPOne.setTo4(0); |
| | | s7DataDLPOne.setTo5(0); |
| | | s7DataDLPOne.setTo6(0); |
| | | s7DataDLPOne.setMesReply(0); |
| | | s7SerializerDLPOne.write(s7DataDLPOne); |
| | | } |
| | | |
| | | @Scheduled(fixedDelay = 1000) |
| | | public void finishOutBigStorageTask() throws Exception { |
| | | ReadWriteEntity inkageEntity = miloService.readFromOpcUa("DLP1B.DLP1B.mesControl"); |
| | | if (true != Boolean.parseBoolean(inkageEntity.getValue() + "")) { |
| | | S7DataDLPTwo s7DataWLTwo = s7SerializerDLPTwo.read(S7DataDLPTwo.class); |
| | | // ReadWriteEntity inkageEntity = miloService.readFromOpcUa("DLP1B.DLP1B.mesControl"); |
| | | // if (true != Boolean.parseBoolean(inkageEntity.getValue() + "")) { |
| | | Boolean inkageEntity = s7DataWLTwo.getMesControl(); |
| | | if (true != inkageEntity) { |
| | | log.info("当前为非联机状态,结束完成出片任务"); |
| | | return; |
| | | } |
| | | //获取进片任务表 |
| | | List<BigStorageCageTask> outTaskList = bigStorageCageTaskService.queryTaskMessage("big_storage_cage_out_one_task"); |
| | | //获取出片任务表 |
| | | List<BigStorageCageTask> outTaskList = getOutTaskList(s7DataWLTwo); |
| | | // List<BigStorageCageTask> outTaskList = bigStorageCageTaskService.queryTaskMessage("big_storage_cage_out_one_task"); |
| | | if (CollectionUtil.isEmpty(outTaskList)) { |
| | | log.info("当前大车无出片玻璃,结束完成出片任务"); |
| | | return; |
| | |
| | | } |
| | | } |
| | | // 重置任务表数据 |
| | | bigStorageCageTaskService.updateOutTaskMessage("big_storage_cage_out_one_task"); |
| | | // bigStorageCageTaskService.updateOutTaskMessage("big_storage_cage_out_one_task"); |
| | | resetOutTask(); |
| | | //清空启动状态 |
| | | //向opc发送启动信号 |
| | | miloService.writeToOpcWord(generateReadWriteEntity("DLP1B.DLP1B.MesReply", 0)); |
| | | // miloService.writeToOpcWord(generateReadWriteEntity("DLP1B.DLP1B.MesReply", 0)); |
| | | S7DataDLPTwo s7DataDLPTwo = new S7DataDLPTwo(); |
| | | s7DataDLPTwo.setMesReply(0); |
| | | s7SerializerDLPTwo.write(s7DataDLPTwo); |
| | | } |
| | | |
| | | private void dealDamageInTask(List<BigStorageCageTask> damageTaskList) { |
| | |
| | | List<String> glassIds = bigStorageCageTaskList.stream().map(BigStorageCageTask::getGlassId).collect(Collectors.toList()); |
| | | int glassCount = bigStorageCageTaskList.size(); |
| | | //生成出片任务条数不足6补全 |
| | | while (bigStorageCageTaskList.size() < 6) { |
| | | bigStorageCageTaskList.add(new BigStorageCageTask("", 0, 0, 0)); |
| | | } |
| | | // while (bigStorageCageTaskList.size() < 6) { |
| | | // bigStorageCageTaskList.add(new BigStorageCageTask("", 0, 0, 0)); |
| | | // } |
| | | //清空任务表数据 |
| | | bigStorageCageTaskService.removeAll("big_storage_cage_out_one_task"); |
| | | bigStorageCageTaskService.saveTaskMessage(tableName, bigStorageCageTaskList); |
| | | resetOutTask(); |
| | | S7DataDLPTwo s7DataDLPTwo = new S7DataDLPTwo(); |
| | | for (int i = 0; i < bigStorageCageTaskList.size() && i < 6; i++) { |
| | | String glassId = bigStorageCageTaskList.get(i).getGlassId(); |
| | | Integer startSlot = bigStorageCageTaskList.get(i).getStartSlot(); |
| | | Integer target = bigStorageCageTaskList.get(i).getTargetSlot(); |
| | | if (startSlot > 0) { |
| | | switch (i) { |
| | | case 0: |
| | | s7DataDLPTwo.setId1(glassId); |
| | | s7DataDLPTwo.setFrom1(startSlot); |
| | | s7DataDLPTwo.setTo1(target); |
| | | break; |
| | | case 1: |
| | | s7DataDLPTwo.setId2(glassId); |
| | | s7DataDLPTwo.setFrom2(startSlot); |
| | | s7DataDLPTwo.setTo2(target); |
| | | break; |
| | | case 2: |
| | | s7DataDLPTwo.setId3(glassId); |
| | | s7DataDLPTwo.setFrom3(startSlot); |
| | | s7DataDLPTwo.setTo3(target); |
| | | break; |
| | | case 3: |
| | | s7DataDLPTwo.setId4(glassId); |
| | | s7DataDLPTwo.setFrom4(startSlot); |
| | | s7DataDLPTwo.setTo4(target); |
| | | break; |
| | | case 4: |
| | | s7DataDLPTwo.setId5(glassId); |
| | | s7DataDLPTwo.setFrom5(startSlot); |
| | | s7DataDLPTwo.setTo5(target); |
| | | break; |
| | | case 5: |
| | | s7DataDLPTwo.setId6(glassId); |
| | | s7DataDLPTwo.setFrom6(startSlot); |
| | | s7DataDLPTwo.setTo6(target); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | s7SerializerDLPTwo.write(s7DataDLPTwo); |
| | | // bigStorageCageTaskService.removeAll("big_storage_cage_out_one_task"); |
| | | // bigStorageCageTaskService.saveTaskMessage(tableName, bigStorageCageTaskList); |
| | | List<BigStorageCageHistoryTask> historyList = bigStorageCageTaskList.stream().filter(e -> StringUtils.isNotBlank(e.getGlassId())).map(e -> { |
| | | BigStorageCageHistoryTask history = new BigStorageCageHistoryTask(); |
| | | BeanUtils.copyProperties(e, history); |
| | |
| | | .ne(BigStorageCageDetails::getState, Const.GLASS_STATE_OUT) |
| | | .in(BigStorageCageDetails::getGlassId, glassIds)); |
| | | try { |
| | | miloService.writeToOpcWord(generateReadWriteEntity("DLP1B.DLP1B.MesReply", 1)); |
| | | // miloService.writeToOpcWord(generateReadWriteEntity("DLP1B.DLP1B.MesReply", 1)); |
| | | s7DataDLPTwo = new S7DataDLPTwo(); |
| | | s7DataDLPTwo.setMesReply(1); |
| | | s7SerializerDLPTwo.write(s7DataDLPTwo); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | |
| | | .set(Const.GLASS_STATE_SCHEDULE_ING.equals(state), BigStorageCageBaseInfo::getSlot, targetSlot) |
| | | .in(BigStorageCageDetails::getGlassId, glassIds)); |
| | | try { |
| | | miloService.writeToOpcWord(generateReadWriteEntity("DLP1B.DLP1B.MesReply", 1)); |
| | | // miloService.writeToOpcWord(generateReadWriteEntity("DLP1B.DLP1B.MesReply", 1)); |
| | | S7DataDLPTwo s7DataDLPTwo = new S7DataDLPTwo(); |
| | | s7DataDLPTwo.setMesReply(1); |
| | | s7SerializerDLPTwo.write(s7DataDLPTwo); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | |
| | | .value(value) |
| | | .build(); |
| | | } |
| | | |
| | | //重置任务表 |
| | | private void resetOutTask() { |
| | | S7DataDLPTwo s7DataDLPTwo = new S7DataDLPTwo(); |
| | | s7DataDLPTwo.setId1(""); |
| | | s7DataDLPTwo.setId2(""); |
| | | s7DataDLPTwo.setId3(""); |
| | | s7DataDLPTwo.setId4(""); |
| | | s7DataDLPTwo.setId5(""); |
| | | s7DataDLPTwo.setId6(""); |
| | | s7DataDLPTwo.setFrom1(0); |
| | | s7DataDLPTwo.setFrom2(0); |
| | | s7DataDLPTwo.setFrom3(0); |
| | | s7DataDLPTwo.setFrom4(0); |
| | | s7DataDLPTwo.setFrom5(0); |
| | | s7DataDLPTwo.setFrom6(0); |
| | | s7DataDLPTwo.setTo1(0); |
| | | s7DataDLPTwo.setTo2(0); |
| | | s7DataDLPTwo.setTo3(0); |
| | | s7DataDLPTwo.setTo4(0); |
| | | s7DataDLPTwo.setTo5(0); |
| | | s7DataDLPTwo.setTo6(0); |
| | | s7DataDLPTwo.setState1(0); |
| | | s7DataDLPTwo.setState2(0); |
| | | s7DataDLPTwo.setState3(0); |
| | | s7DataDLPTwo.setState4(0); |
| | | s7DataDLPTwo.setState5(0); |
| | | s7DataDLPTwo.setState6(0); |
| | | s7SerializerDLPTwo.write(s7DataDLPTwo); |
| | | } |
| | | |
| | | //读取出片地址 |
| | | private List<BigStorageCageTask> getOutTaskList(S7DataDLPTwo s7DataDLPTwo) { |
| | | List<BigStorageCageTask> outTaskList = new ArrayList<>(); |
| | | List<String> glassIds = s7DataDLPTwo.getIds(); |
| | | List<Integer> startSlots = s7DataDLPTwo.getFroms(); |
| | | List<Integer> endSlots = s7DataDLPTwo.getTos(); |
| | | List<Integer> states = s7DataDLPTwo.getStates(); |
| | | for (int i = 0; i < 6; i++) { |
| | | if (glassIds.get(i) != null && !glassIds.get(i).isEmpty()) { |
| | | BigStorageCageTask bigStorageCageTask = new BigStorageCageTask(); |
| | | bigStorageCageTask.setGlassId(glassIds.get(i)); |
| | | bigStorageCageTask.setStartSlot(startSlots.get(i)); |
| | | bigStorageCageTask.setTargetSlot(endSlots.get(i)); |
| | | bigStorageCageTask.setTaskState(states.get(i)); |
| | | outTaskList.add(bigStorageCageTask); |
| | | } |
| | | } |
| | | return outTaskList; |
| | | } |
| | | } |
| New file |
| | |
| | | package com.mes.s7.entity; |
| | | |
| | | import com.github.xingshuangs.iot.common.enums.EDataType; |
| | | import com.github.xingshuangs.iot.protocol.s7.serializer.S7Variable; |
| | | import lombok.Data; |
| | | |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @Author : zhoush |
| | | * @Date: 2025/4/30 14:19 |
| | | * @Description: |
| | | */ |
| | | @Data |
| | | public class S7DataDLPOne { |
| | | |
| | | |
| | | @S7Variable(address = "DB3.3118.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 to4; |
| | | |
| | | @S7Variable(address = "DB7.160", type = EDataType.UINT16) |
| | | private Integer to5; |
| | | |
| | | @S7Variable(address = "DB7.162", type = EDataType.UINT16) |
| | | private Integer to6; |
| | | |
| | | @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 = 14) |
| | | private String id1; |
| | | |
| | | @S7Variable(address = "DB7.30", type = EDataType.STRING, count = 14) |
| | | private String id2; |
| | | |
| | | @S7Variable(address = "DB7.52", type = EDataType.STRING, count = 14) |
| | | private String id3; |
| | | |
| | | @S7Variable(address = "DB7.74", type = EDataType.STRING, count = 14) |
| | | private String id4; |
| | | |
| | | @S7Variable(address = "DB7.96", type = EDataType.STRING, count = 14) |
| | | private String id5; |
| | | |
| | | @S7Variable(address = "DB7.118", type = EDataType.STRING, count = 14) |
| | | private String id6; |
| | | |
| | | @S7Variable(address = "MW1002", type = EDataType.UINT16) |
| | | private Integer alarmSignal; |
| | | |
| | | public List<Integer> getStates() { |
| | | return Arrays.asList(state1, state2, state3, state4, state5, state6); |
| | | } |
| | | |
| | | public List<String> getIds() { |
| | | return Arrays.asList(id1, id2, id3, id4, id5, id6); |
| | | } |
| | | |
| | | public List<Integer> getTos() { |
| | | return Arrays.asList(to1, to2, to3, to4, to5, to6); |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | package com.mes.s7.entity; |
| | | |
| | | import com.github.xingshuangs.iot.common.enums.EDataType; |
| | | import com.github.xingshuangs.iot.protocol.s7.serializer.S7Variable; |
| | | import io.swagger.models.auth.In; |
| | | import lombok.Data; |
| | | |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @Author : zhoush |
| | | * @Date: 2025/4/30 14:19 |
| | | * @Description: |
| | | */ |
| | | @Data |
| | | public class S7DataDLPTwo { |
| | | |
| | | |
| | | @S7Variable(address = "DB3.3118.0", type = EDataType.BOOL) |
| | | private Boolean mesControl; |
| | | |
| | | @S7Variable(address = "DB7.4", type = EDataType.UINT16) |
| | | private Integer requestMes; |
| | | |
| | | @S7Variable(address = "DB7.6", type = EDataType.UINT16) |
| | | private Integer mesReply; |
| | | |
| | | @S7Variable(address = "DB7.308", type = EDataType.UINT16) |
| | | private Integer from1; |
| | | |
| | | @S7Variable(address = "DB7.310", type = EDataType.UINT16) |
| | | private Integer from2; |
| | | |
| | | @S7Variable(address = "DB7.312", type = EDataType.UINT16) |
| | | private Integer from3; |
| | | |
| | | @S7Variable(address = "DB7.314", type = EDataType.UINT16) |
| | | private Integer from4; |
| | | |
| | | @S7Variable(address = "DB7.316", type = EDataType.UINT16) |
| | | private Integer from5; |
| | | |
| | | @S7Variable(address = "DB7.318", type = EDataType.UINT16) |
| | | private Integer from6; |
| | | |
| | | @S7Variable(address = "DB7.320", type = EDataType.UINT16) |
| | | private Integer to1; |
| | | |
| | | @S7Variable(address = "DB7.322", type = EDataType.UINT16) |
| | | private Integer to2; |
| | | |
| | | @S7Variable(address = "DB7.324", type = EDataType.UINT16) |
| | | private Integer to3; |
| | | |
| | | @S7Variable(address = "DB7.326", type = EDataType.UINT16) |
| | | private Integer to4; |
| | | |
| | | @S7Variable(address = "DB7.328", type = EDataType.UINT16) |
| | | private Integer to5; |
| | | |
| | | @S7Variable(address = "DB7.330", type = EDataType.UINT16) |
| | | private Integer to6; |
| | | |
| | | @S7Variable(address = "DB7.332", type = EDataType.UINT16) |
| | | private Integer state1; |
| | | |
| | | @S7Variable(address = "DB7.334", type = EDataType.UINT16) |
| | | private Integer state2; |
| | | |
| | | @S7Variable(address = "DB7.336", type = EDataType.UINT16) |
| | | private Integer state3; |
| | | |
| | | @S7Variable(address = "DB7.338", type = EDataType.UINT16) |
| | | private Integer state4; |
| | | |
| | | @S7Variable(address = "DB7.340", type = EDataType.UINT16) |
| | | private Integer state5; |
| | | |
| | | @S7Variable(address = "DB7.342", type = EDataType.UINT16) |
| | | private Integer state6; |
| | | |
| | | @S7Variable(address = "DB7.176", type = EDataType.STRING, count = 14) |
| | | private String id1; |
| | | |
| | | @S7Variable(address = "DB7.198", type = EDataType.STRING, count = 14) |
| | | private String id2; |
| | | |
| | | @S7Variable(address = "DB7.220", type = EDataType.STRING, count = 14) |
| | | private String id3; |
| | | |
| | | @S7Variable(address = "DB7.242", type = EDataType.STRING, count = 14) |
| | | private String id4; |
| | | |
| | | @S7Variable(address = "DB7.264", type = EDataType.STRING, count = 14) |
| | | private String id5; |
| | | |
| | | @S7Variable(address = "DB7.286", type = EDataType.STRING, count = 14) |
| | | private String id6; |
| | | |
| | | public List<Integer> getStates() { |
| | | return Arrays.asList(state1, state2, state3, state4, state5, state6); |
| | | } |
| | | |
| | | public List<String> getIds() { |
| | | return Arrays.asList(id1, id2, id3, id4, id5, id6); |
| | | } |
| | | |
| | | public List<Integer> getTos() { |
| | | return Arrays.asList(to1, to2, to3, to4, to5, to6); |
| | | } |
| | | |
| | | public List<Integer> getFroms() { |
| | | return Arrays.asList(from1, from2, from3, from4, from5, from6); |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | 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 = "s7SerializerCC") |
| | | public S7Serializer s7SerializerCC() { |
| | | // S7PLC s7PLC = new S7PLC(EPlcType.S1200, "192.168.10.80"); |
| | | S7PLC s7PLC = new S7PLC(EPlcType.S1500, "10.153.19.191"); |
| | | return S7Serializer.newInstance(s7PLC); |
| | | } |
| | | |
| | | @Bean(name = "s7SerializerSPOne") |
| | | public S7Serializer s7SerializerSPOne() { |
| | | // S7PLC s7PLC = new S7PLC(EPlcType.S1200, "192.168.10.15"); |
| | | S7PLC s7PLC = new S7PLC(EPlcType.S1500, "10.153.19.191"); |
| | | return S7Serializer.newInstance(s7PLC); |
| | | } |
| | | |
| | | @Bean(name = "s7SerializerSPTwo") |
| | | public S7Serializer s7SerializerSPTwo() { |
| | | // S7PLC s7PLC = new S7PLC(EPlcType.S1200, "192.168.10.21"); |
| | | S7PLC s7PLC = new S7PLC(EPlcType.S1500, "10.153.19.191"); |
| | | return S7Serializer.newInstance(s7PLC); |
| | | } |
| | | } |
| | |
| | | import com.mes.rawglassstation.service.RawGlassStorageStationService; |
| | | import com.mes.rawglasstask.entity.RawGlassStorageTask; |
| | | import com.mes.rawglasstask.service.RawGlassStorageTaskService; |
| | | import com.mes.s7.entity.S7DataCC; |
| | | 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.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; |
| | |
| | | @Autowired(required = false) |
| | | private MiloService miloService; |
| | | |
| | | @Autowired(required = false) |
| | | S7Serializer s7Serializer; |
| | | @Autowired |
| | | @Qualifier("s7SerializerCC") |
| | | S7Serializer s7SerializerCC; |
| | | |
| | | @Autowired |
| | | @Qualifier("s7SerializerSPOne") |
| | | private S7Serializer s7SerializerSPOne; |
| | | |
| | | @Autowired |
| | | @Qualifier("s7SerializerSPTwo") |
| | | private S7Serializer s7SerializerSPTwo; |
| | | |
| | | |
| | | private static final String LOAD_GLASS_DEVICE_ONE_TASK = "load_glass_device_one_task"; |
| | |
| | | |
| | | @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() + ""; |
| | | S7DataCC S7DataCCOne = s7SerializerCC.read(S7DataCC.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); |
| | | S7DataCC s7Data = new S7DataCC(); |
| | | s7Data.setConfirmation(0); |
| | | s7SerializerCC.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() + "")) { |
| | | S7DataCC s7Data = new S7DataCC(); |
| | | s7Data.setTaskWord(0); |
| | | s7Data.setStartSlot(0); |
| | | s7Data.setEndSlot(0); |
| | | s7SerializerCC.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; |
| | | } |
| | |
| | | |
| | | @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() + ""; |
| | | S7DataCC S7DataCCOne = s7SerializerCC.read(S7DataCC.class); |
| | | String value = S7DataCCOne.getInCar().toString(); |
| | | // ReadWriteEntity entity = miloService.readFromOpcUa("CC.CC.inCar"); |
| | | // String value = entity.getValue() + ""; |
| | | if (!"1".equals(value)) { |
| | | log.info("大车上没有架子"); |
| | | return; |
| | |
| | | |
| | | @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() + ""; |
| | | S7DataCC S7DataCCOne = s7SerializerCC.read(S7DataCC.class); |
| | | String value = S7DataCCOne.getReportWord().toString(); |
| | | // ReadWriteEntity entity = miloService.readFromOpcUa("CC.CC.reportWord"); |
| | | // String value = entity.getValue() + ""; |
| | | if ("0".equals(value)) { |
| | | log.info("当前任务未汇报,结束本次任务"); |
| | | return; |
| | |
| | | .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); |
| | | S7DataCC s7Data = new S7DataCC(); |
| | | s7Data.setConfirmation(1); |
| | | s7SerializerCC.write(s7Data); |
| | | // List<ReadWriteEntity> list = new ArrayList<>(); |
| | | // list.add(generateReadWriteEntity("CC.CC.confirmation", 1)); |
| | | // miloService.writeToOpcWord(list); |
| | | } |
| | | |
| | | private boolean isHasRunningTask() { |
| | |
| | | if (CollectionUtils.isEmpty(loadStationList)) { |
| | | log.info("1号上片位生成调度任务"); |
| | | RawGlassStorageDetails rawDetails = getRawGlassStorageDetailsBySize(usageVOS.get(0), usageVOS.size()); |
| | | if (CollectionUtils.isEmpty(loadStationList)) { |
| | | if (rawDetails == null) { |
| | | log.info("仓库内无匹配的玻璃"); |
| | | return Boolean.FALSE; |
| | | } |
| | |
| | | RawGlassStorageDetails twoLoadStation = loadStationList.stream().filter(e -> e.getSlot().equals(loadStation.get(1))).findFirst().orElse(null); |
| | | if (null == twoLoadStation) { |
| | | //按照尺寸生成二号位上片任务信息 |
| | | LoadGlassDeviceTask loadTask = loadGlassDeviceTaskService.queryTaskMessage(tableName); |
| | | // LoadGlassDeviceTask loadTask = loadGlassDeviceTaskService.queryTaskMessage(tableName); |
| | | S7DataSP loadTask = new S7DataSP(); |
| | | if (stationCell == 5) { |
| | | loadTask = s7SerializerSPOne.read(S7DataSP.class); |
| | | } else { |
| | | loadTask = s7SerializerSPTwo.read(S7DataSP.class); |
| | | } |
| | | RawGlassStorageDetails rawDetails = null; |
| | | if (oneLoadStation.getRemainQuantity() > (loadTask.getTotalCount() + loadTask.getDamageCount())) { |
| | | usageVOS = upListMap.get("2"); |
| | |
| | | } else { |
| | | //todo:当二号为的尺寸大于0时,是否执行调度任务,更换当前原片的尺寸,等待下一次任务的直接执行;还是继续等待,当尺寸不一样,等待一号工位的进出库调度任务。 |
| | | if (twoLoadStation.getRemainQuantity() > 0) { |
| | | LoadGlassDeviceTask loadTask = loadGlassDeviceTaskService.queryTaskMessage(tableName); |
| | | // LoadGlassDeviceTask loadTask = loadGlassDeviceTaskService.queryTaskMessage(tableName); |
| | | S7DataSP loadTask = new S7DataSP(); |
| | | if (stationCell == 5) { |
| | | loadTask = s7SerializerSPOne.read(S7DataSP.class); |
| | | } else { |
| | | loadTask = s7SerializerSPTwo.read(S7DataSP.class); |
| | | } |
| | | if (oneLoadStation.getRemainQuantity() > (loadTask.getTotalCount() + loadTask.getDamageCount())) { |
| | | usageVOS = upListMap.get("2"); |
| | | if (CollectionUtils.isEmpty(usageVOS)) { |
| New file |
| | |
| | | package com.mes.s7.entity; |
| | | |
| | | import com.github.xingshuangs.iot.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 S7DataCC { |
| | | |
| | | |
| | | // @S7Variable(address = "DB1.0", type = EDataType.UINT16) |
| | | // private Integer request; |
| | | // |
| | | // @S7Variable(address = "DB1.2", type = EDataType.UINT16) |
| | | // private Integer requestId; |
| | | // |
| | | // @S7Variable(address = "DB1.4", type = EDataType.UINT16) |
| | | // private Integer reportWord; |
| | | // |
| | | // @S7Variable(address = "DB1.6", type = EDataType.UINT16) |
| | | // private Integer reportId; |
| | | // |
| | | // @S7Variable(address = "DB1.8", type = EDataType.UINT16) |
| | | // private Integer inCar; |
| | | // |
| | | // @S7Variable(address = "DB1.10", type = EDataType.UINT16) |
| | | // private Integer taskWord; |
| | | // |
| | | // @S7Variable(address = "DB1.12", type = EDataType.UINT16) |
| | | // private Integer taskId; |
| | | // |
| | | // @S7Variable(address = "DB1.14", type = EDataType.UINT16) |
| | | // private Integer startSlot; |
| | | // |
| | | // @S7Variable(address = "DB1.16", type = EDataType.UINT16) |
| | | // private Integer endSlot; |
| | | // |
| | | // @S7Variable(address = "DB1.18", type = EDataType.UINT16) |
| | | // private Integer taskSending; |
| | | // |
| | | // @S7Variable(address = "DB1.20", type = EDataType.UINT16) |
| | | // private Integer confirmation; |
| | | // |
| | | // @S7Variable(address = "DB1.22", type = EDataType.UINT16) |
| | | // private Integer confirmationId; |
| | | |
| | | @S7Variable(address = "DB38.0", type = EDataType.UINT16) |
| | | private Integer request; |
| | | |
| | | @S7Variable(address = "DB38.2", type = EDataType.UINT16) |
| | | private Integer requestId; |
| | | |
| | | @S7Variable(address = "DB38.10", type = EDataType.UINT16) |
| | | private Integer reportWord; |
| | | |
| | | @S7Variable(address = "DB38.12", type = EDataType.UINT16) |
| | | private Integer reportId; |
| | | |
| | | @S7Variable(address = "DB38.18", type = EDataType.UINT16) |
| | | private Integer inCar; |
| | | |
| | | @S7Variable(address = "DB38.20", type = EDataType.UINT16) |
| | | private Integer taskWord; |
| | | |
| | | @S7Variable(address = "DB38.22", type = EDataType.UINT16) |
| | | private Integer taskId; |
| | | |
| | | @S7Variable(address = "DB38.24", type = EDataType.UINT16) |
| | | private Integer startSlot; |
| | | |
| | | @S7Variable(address = "DB38.26", type = EDataType.UINT16) |
| | | private Integer endSlot; |
| | | |
| | | @S7Variable(address = "DB38.28", type = EDataType.UINT16) |
| | | private Integer taskSending; |
| | | |
| | | @S7Variable(address = "DB38.40", type = EDataType.UINT16) |
| | | private Integer confirmation; |
| | | |
| | | @S7Variable(address = "DB38.42", type = EDataType.UINT16) |
| | | private Integer confirmationId; |
| | | |
| | | |
| | | } |
| New file |
| | |
| | | package com.mes.s7.entity; |
| | | |
| | | import com.github.xingshuangs.iot.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.UINT16) |
| | | private Integer taskState; |
| | | |
| | | @S7Variable(address = "DB19.18", type = EDataType.UINT16) |
| | | private Integer damageCount; |
| | | |
| | | @S7Variable(address = "DB19.20", type = EDataType.UINT16) |
| | | private Integer rawGlassWidth; |
| | | |
| | | @S7Variable(address = "DB19.22", type = EDataType.UINT16) |
| | | private Integer rawGlassHeight; |
| | | |
| | | @S7Variable(address = "DB19.24", type = EDataType.UINT16) |
| | | private Integer slot; |
| | | |
| | | @S7Variable(address = "DB19.26", type = EDataType.UINT16) |
| | | private Integer totalCount; |
| | | |
| | | @S7Variable(address = "DB19.28", type = EDataType.UINT16) |
| | | private Integer finishCount; |
| | | |
| | | @S7Variable(address = "DB19.16.0", type = EDataType.BOOL) |
| | | private Boolean taskRunning; |
| | | |
| | | @S7Variable(address = "DB19.30", type = EDataType.UINT16) |
| | | private Integer inkageState; |
| | | |
| | | |
| | | } |
| | |
| | | strict: false #设置严格模式,默认false不启动. 启动后在未匹配到指定数据源时候回抛出异常,不启动会使用默认数据源. |
| | | datasource: |
| | | northGlassMes: |
| | | url: jdbc:mysql://10.153.19.150:3306/north_glass_mes?serverTimezone=GMT%2b8 |
| | | url: jdbc:mysql://10.153.19.150:3306/north_glass_mes?serverTimezone=GMT%2b8&allowMultiQueries=true |
| | | username: root |
| | | password: beibo.123/ |
| | | driver-class-name: com.mysql.cj.jdbc.Driver |
| New file |
| | |
| | | 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"); |
| | | S7PLC s7PLC = new S7PLC(EPlcType.S1500, "10.153.19.191"); |
| | | return S7Serializer.newInstance(s7PLC); |
| | | } |
| | | |
| | | @Bean(name = "s7SerializerSPTwo") |
| | | public S7Serializer s7SerializerSPTwo() { |
| | | // S7PLC s7PLC = new S7PLC(EPlcType.S1200, "192.168.10.21"); |
| | | S7PLC s7PLC = new S7PLC(EPlcType.S1500, "10.153.19.191"); |
| | | return S7Serializer.newInstance(s7PLC); |
| | | } |
| | | |
| | | } |
| | |
| | | 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; |
| | |
| | | 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; |
| | |
| | | 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); |
| | |
| | | } |
| | | |
| | | 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) { |
| | |
| | | return; |
| | | } |
| | | //任务暂停 |
| | | LoadGlassDeviceTask task = loadGlassDeviceTaskService.queryTaskMessage(tableName); |
| | | if (0 == task.getInkageState()) { |
| | | log.info("{}上片线,处于离线状态:{},结束本地上片请求", deviceId, task.getInkageState()); |
| | | S7DataSP task = new S7DataSP(); |
| | | if (LOAD_GLASS_ONE_DEVICE.equals(deviceId)) { |
| | | s7SerializerSPOne.read(S7DataSP.class); |
| | | } else { |
| | | s7SerializerSPTwo.read(S7DataSP.class); |
| | | } |
| | | // LoadGlassDeviceTask task = loadGlassDeviceTaskService.queryTaskMessage(tableName); |
| | | ; |
| | | if ("0".equals(s7DataSP.getInkageState().toString())) { |
| | | log.info("{}上片线,处于离线状态:{},结束本地上片请求", deviceId, s7DataSP.getInkageState().toString()); |
| | | // if (0 == task.getInkageState()) { |
| | | // log.info("{}上片线,处于离线状态:{},结束本地上片请求", deviceId, task.getInkageState()); |
| | | return; |
| | | } |
| | | if (task.getTaskRunning().equals(Const.ENGINEERING_RUNNING)) { |
| | | if (s7DataSP.getTaskRunning()) { |
| | | // if (task.getTaskRunning().equals(Const.ENGINEERING_RUNNING)) { |
| | | log.info("{}上片线,有正在执行的任务,结束本地上片请求", deviceId); |
| | | return; |
| | | } |
| | |
| | | int number = Math.min(twoLoadStation.getRemainQuantity(), usageVOS.size()); |
| | | //生成上片任务 |
| | | task.setTotalCount(number); |
| | | task.setTaskRunning(Const.ENGINEERING_RUNNING); |
| | | task.setTaskRunning(Boolean.TRUE); |
| | | task.setRawGlassWidth((int) usageVOS.get(0).getWidth()); |
| | | task.setRawGlassHeight((int) usageVOS.get(0).getHeight()); |
| | | task.setSlot(loadStation.get(1)); |
| | | loadGlassDeviceTaskService.updateTaskMessage(tableName, task); |
| | | // loadGlassDeviceTaskService.updateTaskMessage(tableName, task); |
| | | S7DataSP s7DataSPWrite = new S7DataSP(); |
| | | s7DataSPWrite.setTotalCount(number); |
| | | s7DataSPWrite.setTaskRunning(Boolean.TRUE); |
| | | s7DataSPWrite.setRawGlassWidth((int) usageVOS.get(0).getWidth()); |
| | | s7DataSPWrite.setRawGlassHeight((int) usageVOS.get(0).getHeight()); |
| | | s7DataSPWrite.setSlot(loadStation.get(1)); |
| | | if (LOAD_GLASS_ONE_DEVICE.equals(deviceId)) { |
| | | s7SerializerSPOne.write(s7DataSPWrite); |
| | | } else { |
| | | s7SerializerSPTwo.write(s7DataSPWrite); |
| | | } |
| | | saveHistoryTask(task, deviceId); |
| | | return; |
| | | } |
| | |
| | | //生成上片任务 |
| | | int number = Math.min(oneLoadStation.getRemainQuantity(), usageVOS.size()); |
| | | task.setTotalCount(number); |
| | | task.setTaskRunning(Const.ENGINEERING_RUNNING); |
| | | task.setTaskRunning(Boolean.TRUE); |
| | | task.setRawGlassWidth((int) usageVOS.get(0).getWidth()); |
| | | task.setRawGlassHeight((int) usageVOS.get(0).getHeight()); |
| | | task.setSlot(loadStation.get(0)); |
| | | loadGlassDeviceTaskService.updateTaskMessage(tableName, task); |
| | | // loadGlassDeviceTaskService.updateTaskMessage(tableName, task); |
| | | S7DataSP s7DataSPWrite = new S7DataSP(); |
| | | s7DataSPWrite.setTotalCount(number); |
| | | s7DataSPWrite.setTaskRunning(Boolean.TRUE); |
| | | s7DataSPWrite.setRawGlassWidth((int) usageVOS.get(0).getWidth()); |
| | | s7DataSPWrite.setRawGlassHeight((int) usageVOS.get(0).getHeight()); |
| | | s7DataSPWrite.setSlot(loadStation.get(0)); |
| | | if (LOAD_GLASS_ONE_DEVICE.equals(deviceId)) { |
| | | s7SerializerSPOne.write(s7DataSPWrite); |
| | | } else { |
| | | s7SerializerSPTwo.write(s7DataSPWrite); |
| | | } |
| | | saveHistoryTask(task, deviceId); |
| | | } |
| | | |
| | | private void opcLoadGlassFinishChid(String tableName, Integer deviceId) { |
| | | LoadGlassDeviceTask task = loadGlassDeviceTaskService.queryTaskMessage(tableName); |
| | | if (task.getTaskRunning().equals(Const.ENGINEERING_NEW)) { |
| | | 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 (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 slot = Integer.parseInt(s7DataSP.getSlot().toString()); |
| | | // Integer finishCount = task.getFinishCount(); |
| | | // Integer damageCount = task.getDamageCount(); |
| | | |
| | | //更新当前架子上的原片剩余情况 |
| | | rawGlassStorageDetailsService.update(new UpdateWrapper<RawGlassStorageDetails>() |
| | | .inSql("slot", "select slot from raw_glass_storage_station where enable_state = 1") |
| | | .eq("slot", task.getSlot()) |
| | | // .eq("slot", task.getSlot()) |
| | | .eq("slot", slot) |
| | | .eq("state", Const.RAW_GLASS_STATE_IN) |
| | | .setSql("remain_quantity = remain_quantity - " + (finishCount + damageCount))); |
| | | //更新工程下的原片数量 todo:sql待优化 |
| | |
| | | .set(UpPattenUsage::getState, Const.LOAD_RAW_GLASS_SUCCESS)); |
| | | } |
| | | //任务表数据情况 |
| | | task.setTaskRunning(0); |
| | | task.setTotalCount(0); |
| | | task.setRawGlassWidth(0); |
| | | task.setRawGlassHeight(0); |
| | | task.setSlot(0); |
| | | loadGlassDeviceTaskService.updateTaskMessage(tableName, task); |
| | | // task.setTaskRunning(0); |
| | | // task.setTotalCount(0); |
| | | // task.setRawGlassWidth(0); |
| | | // task.setRawGlassHeight(0); |
| | | // task.setSlot(0); |
| | | // loadGlassDeviceTaskService.updateTaskMessage(tableName, task); |
| | | S7DataSP s7DataSPWrite = new S7DataSP(); |
| | | s7DataSPWrite.setTaskRunning(Boolean.FALSE); |
| | | s7DataSPWrite.setTotalCount(0); |
| | | s7DataSPWrite.setRawGlassWidth(0); |
| | | s7DataSPWrite.setRawGlassHeight(0); |
| | | s7DataSPWrite.setSlot(0); |
| | | if (LOAD_GLASS_ONE_DEVICE.equals(deviceId)) { |
| | | s7SerializerSPOne.write(s7DataSPWrite); |
| | | } else { |
| | | s7SerializerSPTwo.write(s7DataSPWrite); |
| | | } |
| | | loadGlassDeviceTaskHistoryService.update(new LambdaUpdateWrapper<LoadGlassDeviceTaskHistory>() |
| | | .set(LoadGlassDeviceTaskHistory::getTaskState, Const.RAW_GLASS_TASK_SUCCESS) |
| | | .eq(LoadGlassDeviceTaskHistory::getTaskState, Const.RAW_GLASS_TASK_NEW) |
| | |
| | | ); |
| | | } |
| | | |
| | | private boolean saveHistoryTask(LoadGlassDeviceTask task, Integer deviceId) { |
| | | private boolean saveHistoryTask(S7DataSP task, Integer deviceId) { |
| | | LoadGlassDeviceTaskHistory taskHistory = new LoadGlassDeviceTaskHistory(); |
| | | BeanUtils.copyProperties(task, taskHistory); |
| | | taskHistory.setStation(deviceId); |
| New file |
| | |
| | | package com.mes.s7.entity; |
| | | |
| | | import com.github.xingshuangs.iot.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.UINT16) |
| | | private Integer taskState; |
| | | |
| | | @S7Variable(address = "DB19.18", type = EDataType.UINT16) |
| | | private Integer damageCount; |
| | | |
| | | @S7Variable(address = "DB19.20", type = EDataType.UINT16) |
| | | private Integer rawGlassWidth; |
| | | |
| | | @S7Variable(address = "DB19.22", type = EDataType.UINT16) |
| | | private Integer rawGlassHeight; |
| | | |
| | | @S7Variable(address = "DB19.24", type = EDataType.UINT16) |
| | | private Integer slot; |
| | | |
| | | @S7Variable(address = "DB19.26", type = EDataType.UINT16) |
| | | private Integer totalCount; |
| | | |
| | | @S7Variable(address = "DB19.28", type = EDataType.UINT16) |
| | | private Integer finishCount; |
| | | |
| | | @S7Variable(address = "DB19.16.0", type = EDataType.BOOL) |
| | | private Boolean taskRunning; |
| | | |
| | | @S7Variable(address = "DB19.30", type = EDataType.UINT16) |
| | | private Integer inkageState; |
| | | |
| | | |
| | | } |
| | |
| | | strict: false #设置严格模式,默认false不启动. 启动后在未匹配到指定数据源时候回抛出异常,不启动会使用默认数据源. |
| | | datasource: |
| | | northGlassMes: |
| | | url: jdbc:mysql://10.153.19.150:3306/north_glass_mes?serverTimezone=GMT%2b8 |
| | | url: jdbc:mysql://10.153.19.150:3306/north_glass_mes?serverTimezone=GMT%2b8&allowMultiQueries=true |
| | | username: root |
| | | password: beibo.123/ |
| | | driver-class-name: com.mysql.cj.jdbc.Driver |
| New file |
| | |
| | | package com.mes.config; |
| | | |
| | | import com.github.xingshuangs.iot.protocol.modbus.service.ModbusTcp; |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.context.annotation.Configuration; |
| | | |
| | | /** |
| | | * @Author : zhoush |
| | | * @Date: 2025/4/30 13:50 |
| | | * @Description: |
| | | */ |
| | | @Configuration |
| | | public class ModbusConfig { |
| | | @Bean("tempModbusTcp") |
| | | public ModbusTcp modbusTcp() { |
| | | // return new ModbusTcp("127.0.0.1"); |
| | | return new ModbusTcp("192.168.20.80"); |
| | | } |
| | | } |
| New file |
| | |
| | | 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 = "s7SerializerGHOne") |
| | | public S7Serializer s7SerializerGHOne() { |
| | | S7PLC s7PLC = new S7PLC(EPlcType.S1500, "192.168.20.180"); |
| | | // S7PLC s7PLC = new S7PLC(EPlcType.S1500, "10.153.19.191"); |
| | | return S7Serializer.newInstance(s7PLC); |
| | | } |
| | | |
| | | @Bean(name = "s7SerializerGHTwo") |
| | | public S7Serializer s7SerializerGHTwo() { |
| | | S7PLC s7PLC = new S7PLC(EPlcType.S1500, "192.168.20.180"); |
| | | // S7PLC s7PLC = new S7PLC(EPlcType.S1500, "10.153.19.191"); |
| | | return S7Serializer.newInstance(s7PLC); |
| | | } |
| | | |
| | | } |
| | |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.github.xingshuangs.iot.protocol.modbus.service.ModbusTcp; |
| | | 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; |
| | |
| | | import com.mes.pp.entity.OptimizeHeatLayout; |
| | | import com.mes.pp.service.OptimizeHeatDetailService; |
| | | import com.mes.pp.service.OptimizeHeatLayoutService; |
| | | import com.mes.s7.entity.S7DataGHOne; |
| | | import com.mes.temperingglass.entity.TemperingGlassInfo; |
| | | import com.mes.temperingglass.service.TemperingGlassInfoService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang.StringUtils; |
| | | 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; |
| | | |
| | |
| | | @Autowired |
| | | private OptimizeHeatDetailService optimizeHeatDetailService; |
| | | |
| | | @Autowired |
| | | @Qualifier("s7SerializerGHOne") |
| | | private S7Serializer s7SerializerGHOne; |
| | | |
| | | @Autowired |
| | | ModbusTcp tempModbusTcp; |
| | | |
| | | private Integer offset = 40001; |
| | | |
| | | /** |
| | | * 摆片台请求进片逻辑处理 |
| | | * fixedRate : 上一个调用开始后再次调用的延时(不用等待上一次调用完成) |
| | |
| | | */ |
| | | @Scheduled(fixedDelay = 1000) |
| | | public void requestTemperingTask() throws Exception { |
| | | ReadWriteEntity requestInTempering = miloService.readFromOpcUa("GH1S7.GH1S7.requestInTempering");//请求进片 |
| | | ReadWriteEntity requestTemperingId = miloService.readFromOpcUa("GH1S7.GH1S7.requestTemperingId");//请求进片 炉号ID |
| | | Integer request = Integer.parseInt(requestInTempering.getValue().toString()); |
| | | Integer id = Integer.parseInt(requestTemperingId.getValue().toString()); |
| | | S7DataGHOne s7DataGHOne = s7SerializerGHOne.read(S7DataGHOne.class); |
| | | log.info("读取到的GH1S7.GH1S7数据:{}", s7DataGHOne); |
| | | // ReadWriteEntity requestInTempering = miloService.readFromOpcUa("GH1S7.GH1S7.requestInTempering");//请求进片 |
| | | // ReadWriteEntity requestTemperingId = miloService.readFromOpcUa("GH1S7.GH1S7.requestTemperingId");//请求进片 炉号ID |
| | | // Integer request = Integer.parseInt(requestInTempering.getValue().toString()); |
| | | // Integer id = Integer.parseInt(requestTemperingId.getValue().toString()); |
| | | Integer request = (int) s7DataGHOne.getRequestInTempering(); |
| | | Integer id = (int) s7DataGHOne.getRequestTemperingId(); |
| | | if (request == 0) { |
| | | miloService.writeToOpcUa(generateReadWriteEntity("GH1S7.GH1S7.responseInTempering", 0));//允许送片清零 |
| | | // miloService.writeToOpcUa(generateReadWriteEntity("GH1S7.GH1S7.responseInTempering", 0));//允许送片清零 |
| | | s7SerializerGHOne.write( |
| | | S7DataGHOne.builder().responseInTempering(0).build() |
| | | ); |
| | | } else { |
| | | if (id == 0){ |
| | | if (id == 0) { |
| | | log.info("炉号不能为0"); |
| | | return; |
| | | } |
| | | ReadWriteEntity placedNumber = miloService.readFromOpcUa("GH1S7.GH1S7.placedNumber");//已摆片数量 |
| | | // ReadWriteEntity placedNumber = miloService.readFromOpcUa("GH1S7.GH1S7.placedNumber");//已摆片数量 |
| | | String placedNumber = s7DataGHOne.getPlacedNumber().toString();//已摆片数量 |
| | | List<TemperingGlassInfo> glassList = temperingAgoService.selectGlassInfoById(id); |
| | | if (Integer.parseInt(placedNumber.getValue().toString()) == glassList.size()) { |
| | | miloService.writeToOpcUa(generateReadWriteEntity("GH1S7.GH1S7.responseInTempering", 1));//写入允许送片 |
| | | // if (Integer.parseInt(placedNumber.getValue().toString()) == glassList.size()) { |
| | | if (Integer.parseInt(placedNumber) == glassList.size()) { |
| | | // miloService.writeToOpcUa(generateReadWriteEntity("GH1S7.GH1S7.responseInTempering", 1));//写入允许送片 |
| | | s7SerializerGHOne.write( |
| | | S7DataGHOne.builder().responseInTempering(1).build() |
| | | ); |
| | | } else { |
| | | miloService.writeToOpcUa(generateReadWriteEntity("GH1S7.GH1S7.responseInTempering", 2));//不满足进炉条件 |
| | | // miloService.writeToOpcUa(generateReadWriteEntity("GH1S7.GH1S7.responseInTempering", 2));//不满足进炉条件 |
| | | s7SerializerGHOne.write( |
| | | S7DataGHOne.builder().responseInTempering(2).build() |
| | | ); |
| | | } |
| | | } |
| | | } |
| | |
| | | */ |
| | | @Scheduled(fixedDelay = 1000) |
| | | public void loadTemperingTask() throws Exception { |
| | | ReadWriteEntity loadTemperingId = miloService.readFromOpcUa("GH1S7.GH1S7.loadTemperingId");//进片完成 炉号ID |
| | | getNewTemperingID(Integer.parseInt(loadTemperingId.getValue().toString()));//进片完成 下发参数 |
| | | S7DataGHOne s7DataGHOne = s7SerializerGHOne.read(S7DataGHOne.class); |
| | | log.info("读取到的GH1S7.GH1S7数据:{}", s7DataGHOne); |
| | | Integer loadTemperingId = s7DataGHOne.getLoadTemperingId();//进片完成 炉号ID |
| | | getNewTemperingID(loadTemperingId);//进片完成 下发参数 |
| | | // ReadWriteEntity loadTemperingId = miloService.readFromOpcUa("GH1S7.GH1S7.loadTemperingId");//进片完成 炉号ID |
| | | // getNewTemperingID(Integer.parseInt(loadTemperingId.getValue().toString()));//进片完成 下发参数 |
| | | // getNewTemperingID(19); |
| | | } |
| | | |
| | | /** |
| | | * 更新钢化小片表内的玻璃状态 |
| | | * fixedRate : 上一个调用开始后再次调用的延时(不用等待上一次调用完成) |
| | |
| | | */ |
| | | @Scheduled(fixedDelay = 5000) |
| | | public void updateTemperingTask() throws Exception { |
| | | ReadWriteEntity furanchiIdEntity = miloService.readFromOpcUa("GH1.GH1.Furanch1Id");//进片完成 炉号ID |
| | | if (StringUtils.isNotBlank(furanchiIdEntity.getValue()+"")){ |
| | | int temperingid = Integer.parseInt(furanchiIdEntity.getValue().toString()); |
| | | int furanchiIdEntity = tempModbusTcp.readUInt16(40461 - offset); |
| | | if (StringUtils.isNotBlank(furanchiIdEntity + "")) { |
| | | int temperingid = furanchiIdEntity; |
| | | // ReadWriteEntity furanchiIdEntity = miloService.readFromOpcUa("GH1.GH1.Furanch1Id");//进片完成 炉号ID |
| | | // if (StringUtils.isNotBlank(furanchiIdEntity.getValue()+"")){ |
| | | // int temperingid = Integer.parseInt(furanchiIdEntity.getValue().toString()); |
| | | temperingAgoService.update(new LambdaUpdateWrapper<TemperingGlassInfo>().set(TemperingGlassInfo::getState, Const.TEMPERING_START) |
| | | .in(TemperingGlassInfo::getState, Const.TEMPERING_OUT, Const.TEMPERING_DROP).eq(TemperingGlassInfo::getTemperingLayoutId,temperingid)); |
| | | .in(TemperingGlassInfo::getState, Const.TEMPERING_OUT, Const.TEMPERING_DROP).eq(TemperingGlassInfo::getTemperingLayoutId, temperingid)); |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | //获取到炉号id执行参数下发任务 |
| | | private void getNewTemperingID(Integer temperingid) throws Exception { |
| | | ReadWriteEntity autoStatus = miloService.readFromOpcUa("GH1.GH1.AutoStatus"); |
| | | if (1 != Integer.parseInt(autoStatus.getValue().toString())) { |
| | | int autoStatus = tempModbusTcp.readUInt16(40451 - offset); |
| | | if (1 != autoStatus) { |
| | | // ReadWriteEntity autoStatus = miloService.readFromOpcUa("GH1.GH1.AutoStatus"); |
| | | // if (1 != Integer.parseInt(autoStatus.getValue().toString())) { |
| | | log.info("当前为非联机状态,结束钢化下发参数任务"); |
| | | return; |
| | | } |
| | | ReadWriteEntity QandA = miloService.readFromOpcUa("GH1.GH1.QandA"); |
| | | ReadWriteEntity RecipeStatus = miloService.readFromOpcUa("GH1.GH1.RecipeStatus"); |
| | | if (1 == Integer.parseInt(QandA.getValue().toString()) && 2 == Integer.parseInt(RecipeStatus.getValue().toString())) { |
| | | int QandA = tempModbusTcp.readUInt16(40422 - offset); |
| | | int RecipeStatus = tempModbusTcp.readUInt16(40456 - offset); |
| | | if (1 == QandA && 2 == RecipeStatus) { |
| | | // ReadWriteEntity QandA = miloService.readFromOpcUa("GH1.GH1.QandA"); |
| | | // ReadWriteEntity RecipeStatus = miloService.readFromOpcUa("GH1.GH1.RecipeStatus"); |
| | | // if (1 == Integer.parseInt(QandA.getValue().toString()) && 2 == Integer.parseInt(RecipeStatus.getValue().toString())) { |
| | | log.info("版面信息已经下发,并且已经匹配参数,结束钢化下发参数任务"); |
| | | return; |
| | | } |
| | |
| | | shape = shape > 10000 ? 10000 : shape; |
| | | int workmode = 0; //工位数 |
| | | int furmode = 0; //双室/联室 |
| | | tempModbusTcp.writeUInt16(40408 - offset, temperingid); |
| | | tempModbusTcp.writeUInt16(40409 - offset, glasstype); |
| | | tempModbusTcp.writeUInt16(40411 - offset, process); |
| | | tempModbusTcp.writeUInt16(40412 - offset, thiness); |
| | | tempModbusTcp.writeUInt16(40413 - offset, loadingRate); |
| | | tempModbusTcp.writeUInt16(40414 - offset, shape); |
| | | tempModbusTcp.writeUInt16(40415 - offset, workmode); |
| | | tempModbusTcp.writeUInt16(40416 - offset, furmode); |
| | | |
| | | miloService.writeToOpcUa(generateReadWriteEntity("GH1.GH1.TemperingId", temperingid));//写入炉号 |
| | | miloService.writeToOpcUa(generateReadWriteEntity("GH1.GH1.GlassType", glasstype));//写入玻璃类型 |
| | | miloService.writeToOpcUa(generateReadWriteEntity("GH1.GH1.Process", process));//写入钢化类型 全钢 半钢 防火 |
| | | miloService.writeToOpcUa(generateReadWriteEntity("GH1.GH1.Thickness", thiness));//写入厚度 |
| | | miloService.writeToOpcUa(generateReadWriteEntity("GH1.GH1.LoadingRate", loadingRate));//写入装载率 |
| | | miloService.writeToOpcUa(generateReadWriteEntity("GH1.GH1.Shape", shape));//写入大片比例 |
| | | miloService.writeToOpcUa(generateReadWriteEntity("GH1.GH1.WorkMode", workmode));//写入工位数 |
| | | miloService.writeToOpcUa(generateReadWriteEntity("GH1.GH1.FurnaceMode", furmode));//写入炉体工作方式 |
| | | // miloService.writeToOpcUa(generateReadWriteEntity("GH1.GH1.TemperingId", temperingid));//写入炉号 |
| | | // miloService.writeToOpcUa(generateReadWriteEntity("GH1.GH1.GlassType", glasstype));//写入玻璃类型 |
| | | // miloService.writeToOpcUa(generateReadWriteEntity("GH1.GH1.Process", process));//写入钢化类型 全钢 半钢 防火 |
| | | // miloService.writeToOpcUa(generateReadWriteEntity("GH1.GH1.Thickness", thiness));//写入厚度 |
| | | // miloService.writeToOpcUa(generateReadWriteEntity("GH1.GH1.LoadingRate", loadingRate));//写入装载率 |
| | | // miloService.writeToOpcUa(generateReadWriteEntity("GH1.GH1.Shape", shape));//写入大片比例 |
| | | // miloService.writeToOpcUa(generateReadWriteEntity("GH1.GH1.WorkMode", workmode));//写入工位数 |
| | | // miloService.writeToOpcUa(generateReadWriteEntity("GH1.GH1.FurnaceMode", furmode));//写入炉体工作方式 |
| | | log.info("炉号" + temperingid + "版面信息尝试下发"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | 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.mes.common.config.Const; |
| | | import com.mes.damage.service.DamageService; |
| | | import com.mes.largenscreen.entity.PieChartVO; |
| | | import com.mes.s7.entity.S7DataGHTwo; |
| | | import com.mes.temperingglass.entity.TemperingGlassInfo; |
| | | import com.mes.temperingglass.service.TemperingGlassInfoService; |
| | | import com.mes.tools.WebSocketServer; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | 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; |
| | | |
| | |
| | | @Autowired |
| | | private DamageService damageService; |
| | | |
| | | @Autowired |
| | | @Qualifier("s7SerializerGHTwo") |
| | | private S7Serializer s7SerializerGHTwo; |
| | | |
| | | /** |
| | | * fixedRate : 上一个调用开始后再次调用的延时(不用等待上一次调用完成) |
| | | * fixedDelay : 上一个调用结束后再次调用的延时 |
| | | */ |
| | | |
| | | private List<TemperingGlassInfo> selectWaitingGlassByOpc() { |
| | | //获取等待进炉中的玻璃信息 |
| | | try { |
| | | S7DataGHTwo s7DataGHTwo = s7SerializerGHTwo.read(S7DataGHTwo.class); |
| | | String engineerEntity = s7DataGHTwo.getF09EngineerId(); |
| | | Integer temperingLayoutIdEntity = s7DataGHTwo.getF09TemperingLayoutId(); |
| | | // ReadWriteEntity engineerEntity = miloService.readFromOpcUa("GH2S7.GH2S7.F09_ENGINEER_ID"); |
| | | // ReadWriteEntity temperingLayoutIdEntity = miloService.readFromOpcUa("GH2S7.GH2S7.F09_TEMPERING_LAYOUT_ID"); |
| | | |
| | | if (null == engineerEntity || null == temperingLayoutIdEntity) { |
| | | engineerEntity = s7DataGHTwo.getF08EngineerId(); |
| | | temperingLayoutIdEntity = s7DataGHTwo.getF08TemperingLayoutId(); |
| | | // engineerEntity = miloService.readFromOpcUa("GH2S7.GH2S7.F08_ENGINEER_ID"); |
| | | // temperingLayoutIdEntity = miloService.readFromOpcUa("GH2S7.GH2S7.F08_TEMPERING_LAYOUT_ID"); |
| | | if (null == engineerEntity || null == temperingLayoutIdEntity) { |
| | | log.info("获取参数异常,结束本次任务"); |
| | | return new ArrayList<>(); |
| | | } |
| | | } |
| | | return temperingAgoService.list(new LambdaQueryWrapper<TemperingGlassInfo>() |
| | | .eq(TemperingGlassInfo::getEngineerId, engineerEntity) |
| | | .eq(TemperingGlassInfo::getTemperingLayoutId, temperingLayoutIdEntity)); |
| | | } catch (Exception e) { |
| | | log.info("获取钢化参数异常:{}", e); |
| | | return new ArrayList<>(); |
| | | } |
| | | } |
| | | |
| | | @Scheduled(fixedDelay = 1000) |
| | | public void temperingGlassHome() { |
| | | JSONObject jsonObject = new JSONObject(); |
| | | //正在等待进片的玻璃 |
| | | List<TemperingGlassInfo> waitingGlass = temperingAgoService.selectWaitingGlassByOpc(); |
| | | List<TemperingGlassInfo> waitingGlass = selectWaitingGlassByOpc(); |
| | | // List<TemperingGlassInfo> waitingGlass = temperingAgoService.selectWaitingGlassByOpc(); |
| | | if (waitingGlass != null) { |
| | | jsonObject.append("waitingGlass", waitingGlass); |
| | | } |
| | |
| | | //大屏钢化信息 |
| | | List<TemperingGlassInfo> temperingGlassInfoList = temperingAgoService.list( |
| | | new QueryWrapper<TemperingGlassInfo>() |
| | | .select("engineer_id" ,"tempering_layout_id") |
| | | .select("engineer_id", "tempering_layout_id") |
| | | .eq("state", Const.TEMPERING_START) |
| | | .gt("create_time", startOfToday) |
| | | .groupBy("engineer_id" ,"tempering_layout_id") |
| | | .groupBy("engineer_id", "tempering_layout_id") |
| | | ); |
| | | jsonObject.append("temperingGlassInfoList", temperingGlassInfoList.size()); |
| | | //大屏钢化信息 |
| New file |
| | |
| | | package com.mes.s7.entity; |
| | | |
| | | import com.github.xingshuangs.iot.common.enums.EDataType; |
| | | import com.github.xingshuangs.iot.protocol.s7.serializer.S7Variable; |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.Builder; |
| | | import lombok.Data; |
| | | import lombok.NoArgsConstructor; |
| | | |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @Author : zhoush |
| | | * @Date: 2025/4/30 14:19 |
| | | * @Description: |
| | | */ |
| | | @Data |
| | | @Builder |
| | | @NoArgsConstructor |
| | | @AllArgsConstructor |
| | | public class S7DataGHOne { |
| | | |
| | | |
| | | @S7Variable(address = "DB99.0", type = EDataType.UINT16) |
| | | private Integer requestInTempering; |
| | | |
| | | @S7Variable(address = "DB99.2", type = EDataType.UINT16) |
| | | private Integer requestTemperingId; |
| | | |
| | | @S7Variable(address = "DB99.4", type = EDataType.UINT16) |
| | | private Integer placedNumber; |
| | | |
| | | @S7Variable(address = "DB99.6", type = EDataType.UINT16) |
| | | private Integer responseInTempering; |
| | | |
| | | @S7Variable(address = "DB99.8", type = EDataType.UINT16) |
| | | private Integer loadTemperingId; |
| | | |
| | | } |
| New file |
| | |
| | | package com.mes.s7.entity; |
| | | |
| | | import com.github.xingshuangs.iot.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 S7DataGHTwo { |
| | | |
| | | |
| | | @S7Variable(address = "DB110.32", type = EDataType.UINT16) |
| | | private Integer f08TemperingLayoutId; |
| | | |
| | | @S7Variable(address = "DB110.80", type = EDataType.UINT16) |
| | | private Integer f09TemperingLayoutId; |
| | | |
| | | @S7Variable(address = "DB110.34", type = EDataType.STRING,count = 10) |
| | | private String f08EngineerId; |
| | | |
| | | @S7Variable(address = "DB110.82", type = EDataType.STRING,count = 10) |
| | | private String f09EngineerId; |
| | | |
| | | } |
| New file |
| | |
| | | package com.mes.config; |
| | | |
| | | import com.github.xingshuangs.iot.protocol.modbus.service.ModbusTcp; |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.context.annotation.Configuration; |
| | | |
| | | /** |
| | | * @Author : zhoush |
| | | * @Date: 2025/4/30 13:50 |
| | | * @Description: |
| | | */ |
| | | @Configuration |
| | | public class ModbusConfig { |
| | | |
| | | @Bean(name = "CMJ1ModbusTcp") |
| | | public ModbusTcp CMJ1ModbusTcp() { |
| | | // return new ModbusTcp("127.0.0.1"); |
| | | return new ModbusTcp("192.168.30.160"); |
| | | } |
| | | |
| | | @Bean(name = "CMJ2ModbusTcp") |
| | | public ModbusTcp CMJ2ModbusTcp() { |
| | | // return new ModbusTcp("127.0.0.1"); |
| | | return new ModbusTcp("192.168.30.162"); |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | 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 = "s7SerializerZKDLPOne") |
| | | public S7Serializer s7SerializerZKDLPOne() { |
| | | S7PLC s7PLC = new S7PLC(EPlcType.S1500, "192.168.30.100"); |
| | | // S7PLC s7PLC = new S7PLC(EPlcType.S1500, "10.153.19.191"); |
| | | return S7Serializer.newInstance(s7PLC); |
| | | } |
| | | |
| | | @Bean(name = "s7SerializerZKDLPTwo") |
| | | public S7Serializer s7SerializerZKDLPTwo() { |
| | | S7PLC s7PLC = new S7PLC(EPlcType.S1500, "192.168.30.100"); |
| | | // S7PLC s7PLC = new S7PLC(EPlcType.S1500, "10.153.19.191"); |
| | | return S7Serializer.newInstance(s7PLC); |
| | | } |
| | | |
| | | @Bean(name = "s7SerializerZKQ2") |
| | | public S7Serializer s7SerializerZKQ2() { |
| | | S7PLC s7PLC = new S7PLC(EPlcType.S1500, "192.168.30.140"); |
| | | // S7PLC s7PLC = new S7PLC(EPlcType.S1500, "10.153.19.191"); |
| | | return S7Serializer.newInstance(s7PLC); |
| | | } |
| | | |
| | | } |
| | |
| | | import cn.hutool.core.collection.CollectionUtil; |
| | | import cn.hutool.json.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.github.xingshuangs.iot.protocol.modbus.service.ModbusTcp; |
| | | import com.github.xingshuangs.iot.protocol.s7.serializer.S7Serializer; |
| | | import com.kangaroohy.milo.model.ReadWriteEntity; |
| | | import com.kangaroohy.milo.service.MiloService; |
| | | import com.mes.bigstoragecagetask.entity.BigStorageCageTask; |
| | |
| | | import com.mes.hollowtask.service.HollowBigStorageCageHistoryTaskService; |
| | | import com.mes.largenscreen.entity.PieChartVO; |
| | | import com.mes.largenscreen.entity.RunTime; |
| | | import com.mes.s7.entity.S7DataZKDLPOne; |
| | | import com.mes.s7.entity.S7DataZKDLPTwo; |
| | | import com.mes.s7.entity.S7DataZKExtra; |
| | | import com.mes.tools.WebSocketServer; |
| | | import com.mes.utils.RedisUtil; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | 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; |
| | | |
| | |
| | | @Autowired(required = false) |
| | | MiloService miloService; |
| | | |
| | | @Autowired |
| | | @Qualifier("s7SerializerZKDLPOne") |
| | | private S7Serializer s7SerializerZKDLPOne; |
| | | |
| | | @Autowired |
| | | @Qualifier("s7SerializerZKDLPTwo") |
| | | private S7Serializer s7SerializerZKDLPTwo; |
| | | |
| | | @Autowired |
| | | @Qualifier("s7SerializerZKQ2") |
| | | private S7Serializer s7SerializerZKQ2; |
| | | |
| | | @Autowired |
| | | @Qualifier("CMJ1ModbusTcp") |
| | | ModbusTcp CMJ1ModbusTcp; |
| | | |
| | | @Autowired |
| | | @Qualifier("CMJ2ModbusTcp") |
| | | ModbusTcp CMJ2ModbusTcp; |
| | | |
| | | private Integer offset = 40001; |
| | | |
| | | @Resource |
| | | RedisUtil redisUtil; |
| | | |
| | | @Scheduled(fixedDelay = 5000) |
| | | public void hollowGlassTaskOne() { |
| | | hollowGlassTaskChild(930, "CMJ1.CMJ1.isFree", "HollowGlassOne"); |
| | | hollowGlassTaskChild(930, CMJ1ModbusTcp.readUInt16(42027 - offset) + "", "HollowGlassOne"); |
| | | } |
| | | |
| | | @Scheduled(fixedDelay = 5000) |
| | | public void hollowGlassTaskTwo() { |
| | | hollowGlassTaskChild(931, "ZKQ2.ZKQ2.isFree", "HollowGlassTwo"); |
| | | S7DataZKExtra s7DataZKExtra = s7SerializerZKQ2.read(S7DataZKExtra.class); |
| | | hollowGlassTaskChild(931, (s7DataZKExtra.getIsFree() ? 1 : 0) + "", "HollowGlassTwo"); |
| | | } |
| | | |
| | | @Scheduled(fixedDelay = 5000) |
| | | public void hollowGlassTaskThree() { |
| | | S7DataZKExtra s7DataZKExtra = s7SerializerZKQ2.read(S7DataZKExtra.class); |
| | | //todo:暂无三线的空闲状态信号,临时标签空闲状态 |
| | | hollowGlassTaskChild(932, "ZKQ3.ZKQ3.isFree", "HollowGlassThree"); |
| | | hollowGlassTaskChild(932, (s7DataZKExtra.getIsFree03() ? 1 : 0) + "", "HollowGlassThree"); |
| | | } |
| | | |
| | | public void hollowGlassTaskChild(int cell, String isFreeTag, String websocketName) { |
| | |
| | | List<HollowGlassQueueInfo> list = hollowGlassQueueInfoService.list(new LambdaQueryWrapper<HollowGlassQueueInfo>().in(HollowGlassQueueInfo::getRelationId, taskIdList)); |
| | | jsonObject.append("queueInfo", list); |
| | | } |
| | | |
| | | try { |
| | | //930空闲信号 |
| | | ReadWriteEntity freeOneRequestEntity = miloService.readFromOpcUa(isFreeTag); |
| | | jsonObject.append("freeRequest", freeOneRequestEntity.getValue()); |
| | | jsonObject.append("freeRequest", isFreeTag); |
| | | } catch (Exception e) { |
| | | log.error("opc存在异常", e); |
| | | } |
| | |
| | | |
| | | |
| | | public void queryDataSource1(JSONObject jsonObject) throws Exception { |
| | | S7DataZKDLPOne s7DataZKDLPOne = s7SerializerZKDLPOne.read(S7DataZKDLPOne.class); |
| | | S7DataZKDLPTwo s7DataZKDLPTwo = s7SerializerZKDLPTwo.read(S7DataZKDLPTwo.class); |
| | | S7DataZKExtra s7DataZKExtra = s7SerializerZKQ2.read(S7DataZKExtra.class); |
| | | List<Double> carPostion = new ArrayList<>(); |
| | | carPostion.add(0.25); |
| | | carPostion.add(0.5); |
| | |
| | | try { |
| | | //进片任务数据 |
| | | List<BigStorageTaskVO> inTaskList = new ArrayList(); |
| | | ReadWriteEntity fromOpcUa = miloService.readFromOpcUa("DLP2A.DLP2A.FROM1"); |
| | | for (int i = 1; i <= 6; i++) { |
| | | ReadWriteEntity requestWord = miloService.readFromOpcUa("DLP2A.DLP2A.DI" + i); |
| | | ReadWriteEntity targetSlotWord = miloService.readFromOpcUa("DLP2A.DLP2A.TO" + i); |
| | | ReadWriteEntity stateWord = miloService.readFromOpcUa("DLP2A.DLP2A.STATE" + i); |
| | | if (null != requestWord.getValue()) { |
| | | // ReadWriteEntity fromOpcUa = miloService.readFromOpcUa("DLP2A.DLP2A.FROM1"); |
| | | String fromOpcUa = s7DataZKDLPOne.getFrom1().toString(); |
| | | for (int i = 0; i < 6; i++) { |
| | | // ReadWriteEntity requestWord = miloService.readFromOpcUa("DLP2A.DLP2A.DI" + i); |
| | | // ReadWriteEntity targetSlotWord = miloService.readFromOpcUa("DLP2A.DLP2A.TO" + i); |
| | | // ReadWriteEntity stateWord = miloService.readFromOpcUa("DLP2A.DLP2A.STATE" + i); |
| | | String requestWord = ""; |
| | | String stateWord = ""; |
| | | String targetSlotWord = ""; |
| | | switch (i) { |
| | | case 0: |
| | | requestWord = s7DataZKDLPOne.getId1(); |
| | | stateWord = s7DataZKDLPOne.getState1().toString(); |
| | | targetSlotWord = s7DataZKDLPOne.getTo1().toString(); |
| | | break; |
| | | case 1: |
| | | requestWord = s7DataZKDLPOne.getId2(); |
| | | stateWord = s7DataZKDLPOne.getState2().toString(); |
| | | targetSlotWord = s7DataZKDLPOne.getTo2().toString(); |
| | | break; |
| | | case 2: |
| | | requestWord = s7DataZKDLPOne.getId3(); |
| | | stateWord = s7DataZKDLPOne.getState3().toString(); |
| | | targetSlotWord = s7DataZKDLPOne.getTo3().toString(); |
| | | break; |
| | | case 3: |
| | | requestWord = s7DataZKDLPOne.getId4(); |
| | | stateWord = s7DataZKDLPOne.getState4().toString(); |
| | | targetSlotWord = s7DataZKDLPOne.getTo4().toString(); |
| | | break; |
| | | case 4: |
| | | requestWord = s7DataZKDLPOne.getId5(); |
| | | stateWord = s7DataZKDLPOne.getState5().toString(); |
| | | targetSlotWord = s7DataZKDLPOne.getTo5().toString(); |
| | | break; |
| | | case 5: |
| | | requestWord = s7DataZKDLPOne.getId6(); |
| | | stateWord = s7DataZKDLPOne.getState6().toString(); |
| | | targetSlotWord = s7DataZKDLPOne.getTo6().toString(); |
| | | break; |
| | | } |
| | | // if (null != requestWord.getValue()) { |
| | | if (null != requestWord) { |
| | | BigStorageTaskVO task = new BigStorageTaskVO(); |
| | | task.setGlassId(requestWord.getValue() + ""); |
| | | // task.setGlassId(requestWord.getValue() + ""); |
| | | task.setGlassId(requestWord); |
| | | int isExistCount = hollowBigStorageCageDetailsService.count(new LambdaQueryWrapper<HollowBigStorageCageDetails>().in(HollowBigStorageCageDetails::getGlassId, task.getGlassId()) |
| | | .in(HollowBigStorageCageDetails::getState, Const.GLASS_STATE_IN_ALL)); |
| | | if (isExistCount > 0) { |
| | |
| | | } else { |
| | | task.setIsSame(0); |
| | | } |
| | | task.setStartSlot(Integer.parseInt(fromOpcUa.getValue() + "")); |
| | | task.setTargetSlot(Integer.parseInt(targetSlotWord.getValue() + "")); |
| | | task.setTaskState(Integer.parseInt(stateWord.getValue() + "")); |
| | | // task.setStartSlot(Integer.parseInt(fromOpcUa.getValue() + "")); |
| | | // task.setTargetSlot(Integer.parseInt(targetSlotWord.getValue() + "")); |
| | | // task.setTaskState(Integer.parseInt(stateWord.getValue() + "")); |
| | | task.setStartSlot(Integer.parseInt(fromOpcUa)); |
| | | task.setTargetSlot(Integer.parseInt(targetSlotWord)); |
| | | task.setTaskState(Integer.parseInt(stateWord)); |
| | | inTaskList.add(task); |
| | | continue; |
| | | } |
| | |
| | | } |
| | | try { |
| | | //进片联机 |
| | | ReadWriteEntity inkageEntity = miloService.readFromOpcUa("DLP2A.DLP2A.mesControl"); |
| | | jsonObject.append("inkageEntity", inkageEntity.getValue()); |
| | | // ReadWriteEntity inkageEntity = miloService.readFromOpcUa("DLP2A.DLP2A.mesControl"); |
| | | // jsonObject.append("inkageEntity", inkageEntity.getValue()); |
| | | Boolean inkageEntity = s7DataZKDLPOne.getMesControl(); |
| | | jsonObject.append("inkageEntity", inkageEntity); |
| | | //进片请求 |
| | | ReadWriteEntity requestEntity = miloService.readFromOpcUa("DLP2A.DLP2A.RequestMes"); |
| | | jsonObject.append("requestEntity", requestEntity.getValue()); |
| | | // ReadWriteEntity requestEntity = miloService.readFromOpcUa("DLP2A.DLP2A.RequestMes"); |
| | | // jsonObject.append("requestEntity", requestEntity.getValue()); |
| | | String requestEntity = s7DataZKDLPOne.getRequestMes().toString(); |
| | | jsonObject.append("requestEntity", requestEntity); |
| | | //启动命令 |
| | | ReadWriteEntity mesReplyEntity = miloService.readFromOpcUa("DLP2A.DLP2A.MesReply"); |
| | | jsonObject.append("mesReplyEntity", mesReplyEntity.getValue()); |
| | | // ReadWriteEntity mesReplyEntity = miloService.readFromOpcUa("DLP2A.DLP2A.MesReply"); |
| | | // jsonObject.append("mesReplyEntity", mesReplyEntity.getValue()); |
| | | String mesReplyEntity = s7DataZKDLPOne.getMesReply().toString(); |
| | | jsonObject.append("mesReplyEntity", mesReplyEntity); |
| | | //出片联机 |
| | | ReadWriteEntity outInkageEntity = miloService.readFromOpcUa("DLP2B.DLP2B.mesControl"); |
| | | jsonObject.append("outInkageEntity", outInkageEntity.getValue()); |
| | | // ReadWriteEntity outInkageEntity = miloService.readFromOpcUa("DLP2B.DLP2B.mesControl"); |
| | | // jsonObject.append("outInkageEntity", outInkageEntity.getValue()); |
| | | String outInkageEntity = s7DataZKDLPTwo.getMesControl().toString(); |
| | | jsonObject.append("outInkageEntity", outInkageEntity); |
| | | //出片请求 |
| | | ReadWriteEntity outRequestEntity = miloService.readFromOpcUa("DLP2B.DLP2B.RequestMes"); |
| | | jsonObject.append("outRequestEntity", outRequestEntity.getValue()); |
| | | // ReadWriteEntity outRequestEntity = miloService.readFromOpcUa("DLP2B.DLP2B.RequestMes"); |
| | | // jsonObject.append("outRequestEntity", outRequestEntity.getValue()); |
| | | String outRequestEntity = s7DataZKDLPTwo.getRequestMes().toString(); |
| | | jsonObject.append("outInkageEntity", outInkageEntity); |
| | | //930空闲信号 |
| | | ReadWriteEntity freeOneRequestEntity = miloService.readFromOpcUa("CMJ1.CMJ1.isFree"); |
| | | jsonObject.append("freeOneRequestEntity", freeOneRequestEntity.getValue()); |
| | | // ReadWriteEntity freeOneRequestEntity = miloService.readFromOpcUa("CMJ1.CMJ1.isFree"); |
| | | // jsonObject.append("freeOneRequestEntity", freeOneRequestEntity.getValue()); |
| | | jsonObject.append("freeOneRequestEntity", CMJ1ModbusTcp.readUInt16(42027 - offset)); |
| | | //931空闲信号 |
| | | ReadWriteEntity freeTwoRequestEntity = miloService.readFromOpcUa("ZKQ2.ZKQ2.isFree"); |
| | | jsonObject.append("freeTwoRequestEntity", freeTwoRequestEntity.getValue()); |
| | | // ReadWriteEntity freeTwoRequestEntity = miloService.readFromOpcUa("ZKQ2.ZKQ2.isFree"); |
| | | // jsonObject.append("freeTwoRequestEntity", freeTwoRequestEntity.getValue()); |
| | | jsonObject.append("freeTwoRequestEntity", s7DataZKExtra.getIsFree()); |
| | | //932空闲信号 |
| | | ReadWriteEntity freeThreeRequestEntity = miloService.readFromOpcUa("ZKQ3.ZKQ3.isFree"); |
| | | jsonObject.append("freeThreeRequestEntity", freeThreeRequestEntity.getValue()); |
| | | // ReadWriteEntity freeThreeRequestEntity = miloService.readFromOpcUa("ZKQ3.ZKQ3.isFree"); |
| | | // jsonObject.append("freeThreeRequestEntity", freeThreeRequestEntity.getValue()); |
| | | jsonObject.append("freeThreeRequestEntity", s7DataZKExtra.getIsFree()); |
| | | } catch (Exception e) { |
| | | //todo:不做任务处理 |
| | | } |
| | | |
| | | //出片任务数据 |
| | | List<BigStorageCageTask> outTaskList = bigStorageCageTaskService.queryTaskMessage("big_storage_cage_out_two_task"); |
| | | // List<BigStorageCageTask> outTaskList = bigStorageCageTaskService.queryTaskMessage("big_storage_cage_out_two_task"); |
| | | // jsonObject.append("bigStorageCageDetailsOutTask", outTaskList); |
| | | List<BigStorageCageTask> outTaskList = new ArrayList<>(); |
| | | for (int i = 0; i < 6; i++) { |
| | | |
| | | BigStorageCageTask bigStorageCageTask = new BigStorageCageTask(); |
| | | String glassId = ""; |
| | | Integer startSlot = 0; |
| | | Integer targetSlot = 0; |
| | | Integer taskState = 0; |
| | | switch (i) { |
| | | case 0: |
| | | glassId = s7DataZKDLPTwo.getId1(); |
| | | startSlot = s7DataZKDLPTwo.getFrom1(); |
| | | targetSlot = s7DataZKDLPTwo.getTo1(); |
| | | taskState = s7DataZKDLPTwo.getState1(); |
| | | ; |
| | | break; |
| | | case 1: |
| | | glassId = s7DataZKDLPTwo.getId2(); |
| | | startSlot = s7DataZKDLPTwo.getFrom2(); |
| | | targetSlot = s7DataZKDLPTwo.getTo2(); |
| | | taskState = s7DataZKDLPTwo.getState2(); |
| | | break; |
| | | case 2: |
| | | glassId = s7DataZKDLPTwo.getId3(); |
| | | startSlot = s7DataZKDLPTwo.getFrom3(); |
| | | targetSlot = s7DataZKDLPTwo.getTo3(); |
| | | taskState = s7DataZKDLPTwo.getState3(); |
| | | break; |
| | | case 3: |
| | | glassId = s7DataZKDLPTwo.getId4(); |
| | | startSlot = s7DataZKDLPTwo.getFrom4(); |
| | | targetSlot = s7DataZKDLPTwo.getTo4(); |
| | | taskState = s7DataZKDLPTwo.getState4(); |
| | | break; |
| | | case 4: |
| | | glassId = s7DataZKDLPTwo.getId5(); |
| | | startSlot = s7DataZKDLPTwo.getFrom5(); |
| | | targetSlot = s7DataZKDLPTwo.getTo5(); |
| | | taskState = s7DataZKDLPTwo.getState5(); |
| | | break; |
| | | case 5: |
| | | glassId = s7DataZKDLPTwo.getId6(); |
| | | startSlot = s7DataZKDLPTwo.getFrom6(); |
| | | targetSlot = s7DataZKDLPTwo.getTo6(); |
| | | taskState = s7DataZKDLPTwo.getState6(); |
| | | break; |
| | | } |
| | | bigStorageCageTask.setGlassId(glassId); |
| | | bigStorageCageTask.setStartSlot(startSlot); |
| | | bigStorageCageTask.setTargetSlot(targetSlot); |
| | | bigStorageCageTask.setTaskState(taskState); |
| | | outTaskList.add(bigStorageCageTask); |
| | | } |
| | | jsonObject.append("bigStorageCageDetailsOutTask", outTaskList); |
| | | |
| | | //调度开关 |
| New file |
| | |
| | | package com.mes.s7.entity; |
| | | |
| | | import com.github.xingshuangs.iot.common.enums.EDataType; |
| | | import com.github.xingshuangs.iot.protocol.s7.serializer.S7Variable; |
| | | import lombok.Data; |
| | | |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @Author : zhoush |
| | | * @Date: 2025/4/30 14:19 |
| | | * @Description: |
| | | */ |
| | | @Data |
| | | public class S7DataZKDLPOne { |
| | | |
| | | |
| | | @S7Variable(address = "DB3.2992.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 to4; |
| | | |
| | | @S7Variable(address = "DB7.160", type = EDataType.UINT16) |
| | | private Integer to5; |
| | | |
| | | @S7Variable(address = "DB7.162", type = EDataType.UINT16) |
| | | private Integer to6; |
| | | |
| | | @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.8", type = EDataType.STRING, count = 14) |
| | | private String id1; |
| | | |
| | | @S7Variable(address = "DB7.30", type = EDataType.STRING, count = 14) |
| | | private String id2; |
| | | |
| | | @S7Variable(address = "DB7.52", type = EDataType.STRING, count = 14) |
| | | private String id3; |
| | | |
| | | @S7Variable(address = "DB7.74", type = EDataType.STRING, count = 14) |
| | | private String id4; |
| | | |
| | | @S7Variable(address = "DB7.96", type = EDataType.STRING, count = 14) |
| | | private String id5; |
| | | |
| | | @S7Variable(address = "DB7.118", type = EDataType.STRING, count = 14) |
| | | private String id6; |
| | | |
| | | @S7Variable(address = "MW1002", type = EDataType.UINT16) |
| | | private Integer alramSignal; |
| | | |
| | | public List<Integer> getStates() { |
| | | return Arrays.asList(state1, state2, state3, state4, state5, state6); |
| | | } |
| | | |
| | | public List<String> getIds() { |
| | | return Arrays.asList(id1, id2, id3, id4, id5, id6); |
| | | } |
| | | |
| | | public List<Integer> getTos() { |
| | | return Arrays.asList(to1, to2, to3, to4, to5, to6); |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | package com.mes.s7.entity; |
| | | |
| | | import com.github.xingshuangs.iot.common.enums.EDataType; |
| | | import com.github.xingshuangs.iot.protocol.s7.serializer.S7Variable; |
| | | import lombok.Data; |
| | | |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @Author : zhoush |
| | | * @Date: 2025/4/30 14:19 |
| | | * @Description: |
| | | */ |
| | | @Data |
| | | public class S7DataZKDLPTwo { |
| | | |
| | | |
| | | @S7Variable(address = "DB3.2992.0", type = EDataType.BOOL) |
| | | private Boolean mesControl; |
| | | |
| | | @S7Variable(address = "DB7.4", type = EDataType.UINT16) |
| | | private Integer requestMes; |
| | | |
| | | @S7Variable(address = "DB7.6", type = EDataType.UINT16) |
| | | private Integer mesReply; |
| | | |
| | | @S7Variable(address = "DB7.308", type = EDataType.UINT16) |
| | | private Integer from1; |
| | | |
| | | @S7Variable(address = "DB7.310", type = EDataType.UINT16) |
| | | private Integer from2; |
| | | |
| | | @S7Variable(address = "DB7.312", type = EDataType.UINT16) |
| | | private Integer from3; |
| | | |
| | | @S7Variable(address = "DB7.314", type = EDataType.UINT16) |
| | | private Integer from4; |
| | | |
| | | @S7Variable(address = "DB7.316", type = EDataType.UINT16) |
| | | private Integer from5; |
| | | |
| | | @S7Variable(address = "DB7.318", type = EDataType.UINT16) |
| | | private Integer from6; |
| | | |
| | | @S7Variable(address = "DB7.320", type = EDataType.UINT16) |
| | | private Integer to1; |
| | | |
| | | @S7Variable(address = "DB7.322", type = EDataType.UINT16) |
| | | private Integer to2; |
| | | |
| | | @S7Variable(address = "DB7.324", type = EDataType.UINT16) |
| | | private Integer to3; |
| | | |
| | | @S7Variable(address = "DB7.326", type = EDataType.UINT16) |
| | | private Integer to4; |
| | | |
| | | @S7Variable(address = "DB7.328", type = EDataType.UINT16) |
| | | private Integer to5; |
| | | |
| | | @S7Variable(address = "DB7.330", type = EDataType.UINT16) |
| | | private Integer to6; |
| | | |
| | | @S7Variable(address = "DB7.332", type = EDataType.UINT16) |
| | | private Integer state1; |
| | | |
| | | @S7Variable(address = "DB7.334", type = EDataType.UINT16) |
| | | private Integer state2; |
| | | |
| | | @S7Variable(address = "DB7.336", type = EDataType.UINT16) |
| | | private Integer state3; |
| | | |
| | | @S7Variable(address = "DB7.338", type = EDataType.UINT16) |
| | | private Integer state4; |
| | | |
| | | @S7Variable(address = "DB7.340", type = EDataType.UINT16) |
| | | private Integer state5; |
| | | |
| | | @S7Variable(address = "DB7.342", type = EDataType.UINT16) |
| | | private Integer state6; |
| | | |
| | | @S7Variable(address = "DB7.176", type = EDataType.STRING, count = 14) |
| | | private String id1; |
| | | |
| | | @S7Variable(address = "DB7.198", type = EDataType.STRING, count = 14) |
| | | private String id2; |
| | | |
| | | @S7Variable(address = "DB7.220", type = EDataType.STRING, count = 14) |
| | | private String id3; |
| | | |
| | | @S7Variable(address = "DB7.242", type = EDataType.STRING, count = 14) |
| | | private String id4; |
| | | |
| | | @S7Variable(address = "DB7.264", type = EDataType.STRING, count = 14) |
| | | private String id5; |
| | | |
| | | @S7Variable(address = "DB7.286", type = EDataType.STRING, count = 14) |
| | | private String id6; |
| | | |
| | | public List<Integer> getStates() { |
| | | return Arrays.asList(state1, state2, state3, state4, state5, state6); |
| | | } |
| | | |
| | | public List<String> getIds() { |
| | | return Arrays.asList(id1, id2, id3, id4, id5, id6); |
| | | } |
| | | |
| | | public List<Integer> getTos() { |
| | | return Arrays.asList(to1, to2, to3, to4, to5, to6); |
| | | } |
| | | |
| | | public List<Integer> getFroms() { |
| | | return Arrays.asList(from1, from2, from3, from4, from5, from6); |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | 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 S7DataZKExtra { |
| | | |
| | | @S7Variable(address = "DB20.0.0", type = EDataType.BOOL) |
| | | private Boolean isFree; |
| | | |
| | | @S7Variable(address = "DB20.0.1", type = EDataType.BOOL) |
| | | private Boolean isFree03; |
| | | |
| | | } |