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 int i = 0; private int j = 0; private int k = 0; private int l = 0; private int[] autoZ = new int[]{0,0,0,0,0,0,0}; /** * =====>> 开始工作 */ public void start(){ thread = new Thread(() -> { try{ Thread.sleep(200); log.info("++++++++ 开始验证许可证 ++++++++"); if (!mainService.licenseVerify()){ SystemProperties.WCS_RUNNING_STATUS.set(Boolean.FALSE); log.info("++++++++ 验证许可证失败 ++++++++"); } else { SystemProperties.WCS_RUNNING_STATUS.set(Boolean.TRUE); log.info("++++++++ 验证许可证成功 ++++++++"); } } catch (Exception e) {} while (!Thread.currentThread().isInterrupted()) { try { // 间隔 Thread.sleep(200); // 系统运行状态判断 if (!SystemProperties.WCS_RUNNING_STATUS.get()) { continue; } //更新位置信息 mainService.updateStePositionNearby(); //更新位置信息 mainService.updateStePosition(); // 任务下发 mainService.DevpTaskNoRun(); // 任务完成 mainService.rgvCompleteWrkMastSta(autoZ); //更新位置信息 mainService.updateStePosition(); } catch (Exception e) { e.printStackTrace(); } } }); thread.start(); } @PreDestroy public void shutDown(){ if (thread != null) thread.interrupt(); } }