hangzhoumesParent/common/servicebase/src/main/java/com/mes/engineering/service/impl/EngineeringServiceImpl.java
@@ -32,7 +32,12 @@ //开始/暂停任务 @Override public boolean changeTask(String projectId, Integer state) { //使用projectId作为条件修改state字段 //暂停正在进行工程 LambdaUpdateChainWrapper<Engineering> pauseWrapper = new LambdaUpdateChainWrapper<>(this.getBaseMapper()); pauseWrapper.set(Engineering::getState,0); pauseWrapper.eq(Engineering::getState,1); pauseWrapper.update(); //使用projectId作为条件开始工程 LambdaUpdateChainWrapper<Engineering> wrapper = new LambdaUpdateChainWrapper<>(this.getBaseMapper()); wrapper.set(Engineering::getState,state); wrapper.eq(Engineering::getEngineerId,projectId); hangzhoumesParent/moduleService/LoadGlassModule/src/main/java/com/mes/common/S7object.java
@@ -1,36 +1,62 @@ package com.mes.common; import com.github.xingshuangs.iot.protocol.s7.enums.EPlcType; import com.mes.device.PlcParameterObject; import com.mes.tools.InitUtil; import com.mes.tools.S7control; /** * @Author : zhoush * @Date: 2024/4/9 15:13 * @Description: */ //public class S7object { // public S7control plccontrol; // PLC通讯类实例 // private EPlcType plcType = EPlcType.S1500; // 西门子PLC类型 // private String ip = "192.168.10.1"; // plc ip地址 // private int port = 102; // plc 端口号 // // private static volatile S7object instance = null; // // private S7object() { // if (plccontrol == null) { // plccontrol = new S7control(plcType, ip, port, 0, 0); // } // } // // // 单例模式 获取类的唯一实例 // public static S7object getinstance() { // if (instance == null) { // synchronized (S7object.class) { // if (instance == null) { // instance = new S7object(); // } // } // } // return instance; // } //} public class S7object extends Thread { public S7control plccontrol; // PLC通讯类实例 private EPlcType plcType = EPlcType.S1200; // 西门子PLC类型 private String ip = "192.168.10.1"; // plc ip地址 private int port = 102; // plc 端口号 public PlcParameterObject PlcMesObject; private static volatile S7object instance = null; private S7object() { if (plccontrol == null) { plccontrol = new S7control(plcType, ip, port, 0, 0); String PlcLoadGlass=S7object.class.getResource("/JsonFile/PlcLoadGlass.json").getPath(); //log.info(PLCAutoMes.class.getResource("").getPath()); PlcMesObject = InitUtil.initword(PlcLoadGlass); } } // 单例模式 获取类的唯一实例 public static S7object getinstance() { if (instance == null) { synchronized (S7object.class) { if (instance == null) { instance = new S7object(); } } } return instance; } @Override public void run() { while (this != null) { try { Thread.sleep(100); } catch (InterruptedException e) { e.printStackTrace(); } byte[] getplcvlues= plccontrol.ReadByte(PlcMesObject.getPlcAddressBegin(),PlcMesObject.getPlcAddressLength()); PlcMesObject.setPlcParameterList(getplcvlues); } } } hangzhoumesParent/moduleService/LoadGlassModule/src/main/java/com/mes/job/PlcLoadGlassTask.java
@@ -34,7 +34,7 @@ * fixedDelay : 上一个调用结束后再次调用的延时 */ @Scheduled(fixedDelay = 300) @Scheduled(fixedDelay = 3000000) public void plcLoadGlassTask() throws InterruptedException { try { //获取是否有上片请求 @@ -77,7 +77,7 @@ } else if("0".equals(loadStatus)){ log.info("收到汇报清0状态"); //减少工位数量,完成任务状态 overTask(loadStatus,1); overTask(loadStatus,100); } } //执行后休眠300毫秒 @@ -93,7 +93,7 @@ //减少工位数量 upWorkstationService.reduceWorkstationNumber(upPattenUsage.getState()); //完成上片表状态 upPattenUsageService.updateUpPattenUsageState(upPattenUsage, 100); upPattenUsageService.updateUpPattenUsageState(upPattenUsage, state); S7object.getinstance().plccontrol.writetime(plcParameterObject.getPlcParameter("MesToPlcStatus").getAddress(), 0); } } hangzhoumesParent/moduleService/LoadGlassModule/src/main/java/com/mes/workstation/mapper/UpWorkstationMapper.java
@@ -3,7 +3,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.mes.workstation.entity.UpWorkSequence; import com.mes.workstation.entity.UpWorkstation; import io.lettuce.core.dynamic.annotation.Param; import org.apache.ibatis.annotations.Param; import java.util.List;