*
lsh
2 天以前 cc53aa90eaf44db5f474af473285187486da8370
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,61 +22,161 @@
    private MainServiceImpl mainService;
    // 所属线程
    private Thread thread;
    // 频率
    private int i = 0;
    private Thread thread2;
    private Thread thread3;
    private Thread thread4;
    /**
     * =====>>  开始工作
     */
    public void start(){
        thread = new Thread(() -> {
            while (!Thread.currentThread().isInterrupted()) {
                try {
                    // 间隔
                    Thread.sleep(1000);
                    // 系统运行状态判断
                    if (!SystemProperties.WCS_RUNNING_STATUS.get()) {
                        continue;
                    }
                    // 演示
//                    mainService.crnDemoOfLocMove1();
                    // 入库  ===>> 入库站到堆垛机站,根据条码扫描生成入库工作档
                    mainService.generateStoreWrkFile(); // 组托
                    // 出库  ===>>  堆垛机出库站到出库站
                    mainService.crnStnToOutStn();
                    // 入出库  ===>>  堆垛机入出库作业下发
                    mainService.crnIoExecute();
                    // 入库  ===>> 执行对工作档的完成操作
                    mainService.storeFinished();
                    // 堆垛机异常信息记录
                    mainService.recCrnErr();
                    // 入库  ===>> 空栈板初始化入库,叉车入库站放货
//                    mainService.storeEmptyPlt();
//                    mainService.outOfDevp();
                    // 其他  ===>> // 入出库模式切换函数
                    i++;
                    if (i > 1) {
//                        mainService.ioConvert();
                        i = 0;
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
        thread = new Thread(this::crnAndDevRun);
        thread.start();
        thread2 = new Thread(this::crnAndDevOtherRun);
        thread2.start();
        thread3 = new Thread(this::demoRun);
        thread3.start();
        thread4 = new Thread(this::demoOpenRun);
        thread4.start();
    }
    private void crnAndDevRun() {
        while (!Thread.currentThread().isInterrupted()) {
            try {
                // 间隔
                Thread.sleep(1000);
                // 系统运行状态判断
                if (!SystemProperties.WCS_RUNNING_STATUS.get()) {
                    continue;
                }
                // 系统演示模式运行状态判断
                if (SystemProperties.WCS_RUNNING_STATUS_DEMO.get()) {
                    continue;
                }
                // 入库  ===>> 入库站到堆垛机站,根据条码扫描生成入库工作档
                mainService.generateStoreWrkFile(); // 组托
//                    mainService.generateStoreWrkFileIsEmptyMk(); // 组托  空托
                mainService.generateStoreWrkFileWalk(); // wms入库任务下发
                // 入出库  ===>>  堆垛机入出库作业下发
                mainService.crnIoExecute();
                // 入库  ===>> 执行对工作档的完成操作
                mainService.storeFinished();
                // 任务下发
                mainService.taskStart();
                // 出库  ===>>  堆垛机10分钟无任务则回到源点
                mainService.crnStnToOutStnSou();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
    private void crnAndDevOtherRun() {
        while (!Thread.currentThread().isInterrupted()) {
            try {
                // 间隔
                Thread.sleep(400);
                // 系统运行状态判断
                if (!SystemProperties.WCS_RUNNING_STATUS.get()) {
                    continue;
                }
                // 系统演示模式运行状态判断
                if (SystemProperties.WCS_RUNNING_STATUS_DEMO.get()) {
                    continue;
                }
                // 出库  ===>>  堆垛机出库站到出库站
                mainService.crnStnToOutStn();
                // 堆垛机异常信息记录
                mainService.recCrnErr();
                // 输送线异常信息记录
//                    mainService.recDevErr();
                // 出库  ===>> 工作档信息写入led显示器
//                    mainService.ledExecute(9);
                // 其他  ===>> LED显示器复位,显示默认信息
//                    mainService.ledReset(10);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
    private void demoRun() {
        while (!Thread.currentThread().isInterrupted()) {
            try {
                // 间隔
                Thread.sleep(1000);
                // 系统运行状态判断
                if (!SystemProperties.WCS_RUNNING_STATUS.get()) {
                    continue;
                }
                // 系统演示模式运行状态判断
                if (!SystemProperties.WCS_RUNNING_STATUS_DEMO.get()) {
                    continue;
                }
                // 入出库  ===>>  堆垛机入出库作业下发
                mainService.crnIoExecuteDemo();
                // 出库  ===>>  堆垛机出库站到出库站
                mainService.crnStnToOutStnDemo();
                // 任务下发
                mainService.taskStartDemo();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
    private void demoOpenRun() {
        while (!Thread.currentThread().isInterrupted()) {
            try {
                // 间隔
                Thread.sleep(1000);
                // 系统演示模式运行状态变化
                if (SystemProperties.WCS_RUNNING_STATUS_DEMO.get()) {
                    if (SystemProperties.WCS_RUNNING_STATUS_DEMO_VALUE == 2){
                        boolean signHpMk = mainService.crnStnDEMOStop2();
                        if (signHpMk){
                            SystemProperties.WCS_RUNNING_STATUS_DEMO_VALUE = 3;
                        }
                    } else if (SystemProperties.WCS_RUNNING_STATUS_DEMO_VALUE == 3){
                        boolean signHpMk = mainService.crnStnDEMOStop3();
                        if (signHpMk){
                            SystemProperties.WCS_RUNNING_STATUS_DEMO.set(false);
                            SystemProperties.WCS_RUNNING_STATUS_DEMO_VALUE = 0;
                        }
                    }
                } else {
                     if (SystemProperties.WCS_RUNNING_STATUS_DEMO_VALUE == 1){
                        boolean signHpMk = mainService.crnStnDEMOOpen1();
                        if (signHpMk){
                            SystemProperties.WCS_RUNNING_STATUS_DEMO.set(true);
                            SystemProperties.WCS_RUNNING_STATUS_DEMO_VALUE = 2;
                        } else {
                            SystemProperties.WCS_RUNNING_STATUS_DEMO_VALUE = 0;
                        }
                    } else {
                         boolean signHpMk = mainService.crnStnDEMOOpen0();
                         if (signHpMk){
                             SystemProperties.WCS_RUNNING_STATUS_DEMO_VALUE = 1;
                         } else {
                             SystemProperties.WCS_RUNNING_STATUS_DEMO_VALUE = 0;
                         }
                     }
                }
                // 其他  ===>> LED显示器显示时间
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
    @PreDestroy
    public void shutDown(){
        if (thread != null) thread.interrupt();
        if (thread2 != null) thread2.interrupt();
        if (thread3 != null) thread3.interrupt();
        if (thread4 != null) thread4.interrupt();
    }
}