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 Thread thread2;
|
private Thread thread3;
|
private Thread thread4;
|
|
/**
|
* =====>> 开始工作
|
*/
|
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.crnStnToOutStn();
|
// 入出库 ===>> 堆垛机入出库作业下发
|
mainService.crnIoExecute();
|
// 其他 ===>> LED显示器显示时间
|
} 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();
|
}
|
|
}
|