cpT
2025-06-30 5aa831dffdfb0ca524362e8d649c28babc681ece
src/main/java/com/zy/core/MainProcess.java
@@ -5,11 +5,9 @@
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import javax.annotation.PreDestroy;
import java.util.ArrayList;
/**
 * WCS主流程
@@ -24,8 +22,7 @@
    private MainServiceImpl mainService;
    // 所属线程
    private Thread thread;
    // 频率
    private int i = 0;
    private Thread thread2;
    /**
     * =====>>  开始工作
@@ -34,51 +31,62 @@
        thread = new Thread(() -> {
            while (!Thread.currentThread().isInterrupted()) {
                try {
                    // 间隔
                    Thread.sleep(1000);
                    Thread.sleep(400);
                    // 系统运行状态判断
                    if (!SystemProperties.WCS_RUNNING_STATUS.get()) {
                        continue;
                    }
                    // 演示
//                    mainService.crnDemoOfLocMove1();
                    // 入库  ===>> 入库站到堆垛机站,根据条码扫描生成入库工作档
                    mainService.generateStoreWrkFile(); // 组托
                    // 出库  ===>>  堆垛机出库站到出库站
                    mainService.crnStnToOutStn();
//                    mainService.generateStoreWrkFileIsEmptyMk(); // 组托  空托
                    mainService.generateStoreWrkFileWalk(); // 任务下发
                    // 入出库  ===>>  堆垛机入出库作业下发
                    mainService.crnIoExecute();
                    // 入库  ===>> 执行对工作档的完成操作
                    mainService.storeFinished();
                    // 堆垛机异常信息记录
                    mainService.recCrnErr();
                    // 入库  ===>> 空栈板初始化入库,叉车入库站放货
//                    mainService.storeEmptyPlt();
//                    mainService.outOfDevp();
                    // 其他  ===>> // 入出库模式切换函数
                    i++;
                    if (i > 1) {
//                        mainService.ioConvert();
                        i = 0;
                    }
                    // 任务下发
                    mainService.taskStart();
                    // 出库  ===>>  堆垛机10分钟无任务则回到源点
//                    mainService.crnStnToOutStnSou();
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
        thread.start();
        thread2 = new Thread(() -> {
            while (!Thread.currentThread().isInterrupted()) {
                try {
                    // 间隔
                    Thread.sleep(200);
                    // 系统运行状态判断
                    if (!SystemProperties.WCS_RUNNING_STATUS.get()) {
                        continue;
                    }
                    // 出库  ===>>  堆垛机出库站到出库站
                    mainService.crnStnToOutStn();
                    // 堆垛机异常信息记录
                    mainService.recCrnErr();
                    // 输送线异常信息记录
//                    mainService.recDevErr();
                    // 出库  ===>> 工作档信息写入led显示器
//                    mainService.ledExecute(9);
                    // 其他  ===>> LED显示器复位,显示默认信息
//                    mainService.ledReset(10);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
        thread2.start();
    }
    @PreDestroy
    public void shutDown(){
        if (thread != null) thread.interrupt();
        if (thread2 != null) thread2.interrupt();
    }
}