| package com.zy.core; | 
|   | 
| import com.zy.asrs.service.impl.MainServiceImpl; | 
| import com.zy.core.properties.SystemProperties; | 
| import lombok.Data; | 
| import lombok.extern.slf4j.Slf4j; | 
| import org.springframework.beans.factory.annotation.Autowired; | 
| import org.springframework.stereotype.Component; | 
|   | 
| import javax.annotation.PreDestroy; | 
|   | 
| /** | 
|  * WCS主流程 | 
|  * Created by vincent on 2020/8/6 | 
|  */ | 
| @Data | 
| @Slf4j | 
| @Component | 
| public class MainProcess { | 
|   | 
|     @Autowired | 
|     private MainServiceImpl mainService; | 
|     // 所属线程 | 
|     private Thread thread; | 
|     // 频率 | 
|     private int i = 0; | 
|   | 
|     /** | 
|      * =====>>  开始工作 | 
|      */ | 
|     public void start() { | 
|         thread = new Thread(() -> { | 
|             while (!Thread.currentThread().isInterrupted()) { | 
|                 try { | 
|                     // 间隔 | 
|                     Thread.sleep(1000); | 
|   | 
|                     // 系统运行状态判断 | 
|                     if (!SystemProperties.WCS_RUNNING_STATUS.get()) { | 
|                         continue; | 
|                     } | 
|                     // 跑库程序.未调试测试 | 
|                     //mainService.debug("F"); | 
|                     //独立输送线任务.未调试测试 | 
|                     //mainService.transferTaskStart(); | 
|                     //mainService.transferTaskEnd(); | 
|   | 
|   | 
|                     // 入库  ===>> 入库站到堆垛机站,根据条码扫描生成入库工作档 | 
|                     mainService.generateStoreWrkFile(); // 组托 | 
|                     // 出库  ===>>  堆垛机出库站到出库站 | 
|                     mainService.crnStnToOutStn(); | 
|                     // 入出库  ===>>  堆垛机入出库作业下发 | 
|                     mainService.crnIoExecute(); | 
|                     // 执行对工作档的完成操作 | 
|                     mainService.storeFinished(); | 
|   | 
|                     // 堆垛机异常信息记录 | 
|                     mainService.recCrnErr(); | 
|   | 
|                     // 其他  ===>> // 入出库模式切换函数 | 
|                     i++; | 
|                     if (i > 1) { | 
|                         mainService.ioConvert(); | 
|                         i = 0; | 
|                     } | 
|   | 
|   | 
|                 } catch (Exception e) { | 
|                     e.printStackTrace(); | 
|                 } | 
|             } | 
|         }); | 
|         thread.start(); | 
|     } | 
|   | 
|     @PreDestroy | 
|     public void shutDown() { | 
|         if (thread != null) thread.interrupt(); | 
|     } | 
|   | 
| } |