严智鑫
2024-05-07 b365a0879edc787655b908b0dbb65b5e966bb23b
hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/java/com/mes/common/Plcdownglass.java
@@ -2,24 +2,21 @@
import cn.hutool.json.JSONObject;
import com.mes.device.PlcParameterObject;
import com.mes.downglassinfo.entity.DownGlassTask;
import com.mes.downglassinfo.service.DownGlassTaskService;
import com.mes.downstorage.entity.DownStorageCageDetails;
import com.mes.downstorage.mapper.DownStorageCageDetailsMapper;
import com.mes.downstorage.service.DownStorageCageService;
import com.mes.downworkstation.service.DownWorkstationService;
import com.mes.glassinfo.entity.GlassInfo;
import com.mes.glassinfo.service.GlassInfoService;
import com.mes.tools.WebSocketServer;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.util.List;
import java.util.function.Supplier;
@Component
@Slf4j
public class Plcdownglass extends Thread {
public class Plcdownglass {
    public static final String RESULT_IN = "1";
    public static final String RESULT_OUT = "2";
@@ -30,25 +27,17 @@
    @Autowired
  private DownWorkstationService downWorkstationService;
//     private final Supplier<DownWorkstationService> plcServiceSupplier;
//
//    public Plcdownglass() {
//        this.plcServiceSupplier = () -> WebSocketServer.applicationContext.getBean(DownWorkstationService.class);
//    }
    @Override
    public void run() {
        while (this != null) {
    @Scheduled(fixedDelay = 300)
    public void PlcdownglassTask() throws InterruptedException {
            JSONObject jsonObject = new JSONObject();
            try {
                Thread.sleep(100);
                downWorkstationService = WebSocketServer.applicationContext.getBean(DownWorkstationService.class);
                downStorageCageService = WebSocketServer.applicationContext.getBean(DownStorageCageService.class);
            Thread.sleep(300);
                //                String result = S7control.getinstance().ReadWord("DB14.0", 1).get(0) + "";
//                String number = S7control.getinstance().ReadWord("DB14.2", 1).get(0) + "";
                String result ="1";
            String result = "2";
                String number ="1";
                // 进片请求
                if (RESULT_IN.equals(result)) {
@@ -66,16 +55,11 @@
                    }
                }
            //下片更新
                downWorkstationService.insertdownglassinfo();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
}