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.beans.factory.annotation.Value;
|
import org.springframework.stereotype.Component;
|
|
import javax.annotation.PreDestroy;
|
import java.util.ArrayList;
|
|
/**
|
* WCS主流程
|
* Created by vincent on 2020/8/6
|
*/
|
@Data
|
@Slf4j
|
@Component
|
public class MainProcess {
|
|
@Autowired
|
private MainServiceImpl mainService;
|
// 所属线程
|
private Thread thread;
|
private Thread rgvThread;
|
private Thread licenseThread;
|
// 频率
|
private int i = 0;
|
private int k = 0;
|
private boolean rgcWrk = true;
|
|
/**
|
* =====>> 开始工作
|
*/
|
public void start(){
|
thread = new Thread(this::crnAndDevRun);
|
thread.start();
|
rgvThread = new Thread(this::rgvRun);
|
rgvThread.start();
|
licenseThread = new Thread(this::licenseThreadRun);
|
licenseThread.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.storeEmptyPlt();
|
// mainService.generateStoreWrkFileWalk(); // wms入库任务下发
|
// 出库 ===>> 堆垛机出库站到出库站
|
mainService.crnStnToOutStn();
|
// 入出库 ===>> 堆垛机入出库作业下发
|
mainService.crnIoExecute();
|
// 入库 ===>> 执行对工作档的完成操作
|
mainService.storeFinished();
|
// 出库 ===>> 堆垛机10分钟无任务则回到源点
|
mainService.crnStnToOutStnSou();
|
|
|
} catch (Exception e) {
|
e.printStackTrace();
|
}
|
}
|
}
|
private void rgvRun() {
|
while (!Thread.currentThread().isInterrupted()) {
|
try {
|
|
// 间隔
|
Thread.sleep(1000);
|
|
// 系统运行状态判断
|
if (!SystemProperties.WCS_RUNNING_STATUS.get()) {
|
continue;
|
}
|
// 任务下发
|
mainService.taskStart();
|
|
} catch (Exception e) {
|
e.printStackTrace();
|
}
|
}
|
}
|
|
private void licenseThreadRun(){
|
int i = 0;
|
while (true) {
|
try{
|
Thread.sleep(60*60*1000L);
|
|
// 系统运行状态判断
|
if (!SystemProperties.WCS_RUNNING_STATUS.get()) {
|
continue;
|
}
|
|
log.info("++++++++ 开始验证许可证 ++++++++");
|
if (!mainService.licenseVerify()){
|
if (i>6){
|
SystemProperties.WCS_RUNNING_STATUS.set(Boolean.FALSE);
|
log.info("++++++++ 验证许可证失败 ++++++++");
|
i = 0;
|
} else {
|
i++;
|
}
|
} else {
|
// SystemProperties.WCS_RUNNING_STATUS.set(Boolean.TRUE);
|
log.info("++++++++ 验证许可证成功 ++++++++");
|
}
|
} catch (Exception e) {}
|
}
|
}
|
|
@PreDestroy
|
public void shutDown(){
|
if (thread != null) thread.interrupt();
|
if (rgvThread != null) rgvThread.interrupt();
|
if (licenseThread != null) licenseThread.interrupt();
|
}
|
|
}
|