*
lsh
1 天以前 f5c0365702be7d445420a9961b1f2e64b621213b
src/main/java/com/zy/core/MainProcess.java
@@ -5,7 +5,6 @@
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;
@@ -23,71 +22,164 @@
    private MainServiceImpl mainService;
    // 所属线程
    private Thread thread;
    @Value("${crnBackHp.enable}")
    private boolean crnBackHp;
    private boolean look = true;
    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.ioConvert();
                    // 入库  ===>> 入库站到堆垛机站,根据条码扫描生成入库工作档
                    mainService.generateStoreWrkFile(); // 组托
                    mainService.generateStoreWrkFile0(); // WMS入库
                    // 拣料、并板、盘点再入库
                    mainService.stnToCrnStnPick();
                    // 出库  ===>>  堆垛机出库站到出库站
                    mainService.crnStnToOutStn();
                    // 入出库  ===>>  堆垛机入出库作业下发
                    mainService.crnIoExecute();
                    // 入出库增强 ===>> 堆垛机命令下发后,异步修改工作档状态
//                    mainService.crnIoWrkMast();
                    // 入库  ===>> 执行对工作档的完成操作
                    mainService.storeFinished();
                    // 堆垛机异常信息记录
                    mainService.recCrnErr();
                    // 入库  ===>> 空栈板初始化入库,叉车入库站放货
//                    mainService.storeEmptyPlt();
                    // 出库  ===>> 工作档信息写入led显示器
                    mainService.ledExecute();
                    // 其他  ===>> LED显示器复位,显示默认信息
                    mainService.ledReset();
//                    if (crnBackHp) {
//                        if (look) {
//                            //堆垛机没有执行中任务,设备存在入库任务时叫回原点
//                            mainService.crnRebackHp();
//                        }
//                    }
//                    look  = !look;
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
    public void start() {
        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.crnStnToOutStnDemo();
                // 入出库  ===>>  堆垛机入出库作业下发
                mainService.crnIoExecuteDemo();
                // 入库  ===>> 执行对工作档的完成操作
                mainService.storeFinishedDemo();
                // 任务下发
                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(){
    public void shutDown() {
        if (thread != null) thread.interrupt();
        if (thread2 != null) thread2.interrupt();
        if (thread3 != null) thread3.interrupt();
        if (thread4 != null) thread4.interrupt();
    }
}