wcs项目初始化
This commit is contained in:
161
ruoyi-admin/src/main/java/com/ruoyi/schedule/ScheduleThread.java
Normal file
161
ruoyi-admin/src/main/java/com/ruoyi/schedule/ScheduleThread.java
Normal file
@@ -0,0 +1,161 @@
|
||||
package com.ruoyi.schedule;
|
||||
|
||||
import com.ruoyi.device.ssj.domain.DeviceSsj;
|
||||
import com.ruoyi.device.ssj.service.IDeviceSsjService;
|
||||
import com.ruoyi.schedule.plcRead.ssj.domain.PlcConnectInfo;
|
||||
import com.ruoyi.schedule.plcRead.ssj.PlcRead;
|
||||
import com.ruoyi.schedule.plcRead.ssj.domain.CustomThread;
|
||||
import com.ruoyi.schedule.scheduleTask.ssj.bs.BsInSsjThread;
|
||||
import com.ruoyi.schedule.scheduleTask.ssj.bs.BsOutSsjThread;
|
||||
import com.ruoyi.schedule.scheduleTask.ssj.bs.BsPickSsjTread;
|
||||
import com.ruoyi.schedule.scheduleTask.ssj.js.JsInSsjThread;
|
||||
import com.ruoyi.schedule.scheduleTask.ssj.js.JsOutSsjThread;
|
||||
import com.ruoyi.schedule.scheduleTask.ssj.js.JsPickSsjTread;
|
||||
import com.ruoyi.schedule.scheduleTask.ssj.monitor.SsjMonitorThread;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
public class ScheduleThread {
|
||||
|
||||
public CustomThread<PlcRead> customThread;
|
||||
@Autowired
|
||||
private IDeviceSsjService deviceSsjService;
|
||||
|
||||
public CustomThread<BsInSsjThread> bsInSsjThread;
|
||||
public CustomThread<JsInSsjThread> jsInSsjThread;
|
||||
public CustomThread<BsOutSsjThread> bsOutSsjThread;
|
||||
public CustomThread<JsOutSsjThread> jsOutSsjThread;
|
||||
public CustomThread<BsPickSsjTread> bsPickSsjThread;
|
||||
public CustomThread<JsPickSsjTread> jsPickSsjThread;
|
||||
public CustomThread<SsjMonitorThread> ssjMonitorThread;
|
||||
|
||||
|
||||
private boolean isRun = false;
|
||||
private boolean isRun2 = false;
|
||||
|
||||
/**
|
||||
* 项目初始化启动
|
||||
*/
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
log.info("初始化调度服务");
|
||||
//读取信息初始化
|
||||
plcReadInit();
|
||||
//调度初始化
|
||||
scheduleInit();
|
||||
log.info("调度服务执行成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 调度初始化
|
||||
*/
|
||||
private void scheduleInit() {
|
||||
BsInSsjThread bsInSsjThread1 = new BsInSsjThread();
|
||||
bsInSsjThread = new CustomThread<BsInSsjThread>(new Thread(bsInSsjThread1), bsInSsjThread1);
|
||||
JsInSsjThread jsInSsjThread1 = new JsInSsjThread();
|
||||
jsInSsjThread = new CustomThread<JsInSsjThread>(new Thread(jsInSsjThread1), jsInSsjThread1);
|
||||
BsOutSsjThread bsOutSsjThread1 = new BsOutSsjThread();
|
||||
bsOutSsjThread = new CustomThread<BsOutSsjThread>(new Thread(bsOutSsjThread1), bsOutSsjThread1);
|
||||
JsOutSsjThread jsOutSsjThread1 = new JsOutSsjThread();
|
||||
jsOutSsjThread = new CustomThread<JsOutSsjThread>(new Thread(jsOutSsjThread1), jsOutSsjThread1);
|
||||
BsPickSsjTread bsPickSsjTread1 = new BsPickSsjTread();
|
||||
bsPickSsjThread = new CustomThread<BsPickSsjTread>(new Thread(bsPickSsjTread1), bsPickSsjTread1);
|
||||
JsPickSsjTread jsPickSsjTread1 = new JsPickSsjTread();
|
||||
jsPickSsjThread = new CustomThread<JsPickSsjTread>(new Thread(jsPickSsjTread1), jsPickSsjTread1);
|
||||
|
||||
SsjMonitorThread ssjMonitorThread1 = new SsjMonitorThread();
|
||||
ssjMonitorThread = new CustomThread<SsjMonitorThread>(new Thread(ssjMonitorThread1), ssjMonitorThread1);
|
||||
}
|
||||
|
||||
/**
|
||||
* plc读取初始化
|
||||
*/
|
||||
private void plcReadInit() {
|
||||
String ip = "127.0.0.1";
|
||||
int port = 102;
|
||||
PlcConnectInfo ssjPlcConnectInfo = new PlcConnectInfo(ip, port);
|
||||
ConcurrentHashMap<String, DeviceSsj> list = new ConcurrentHashMap<>();
|
||||
//获取要去取的输送机
|
||||
List<DeviceSsj> deviceSsjs = deviceSsjService.selectDeviceSsjList(new DeviceSsj());
|
||||
for (DeviceSsj deviceSsj : deviceSsjs) {
|
||||
list.put(deviceSsj.getDeviceCode(), deviceSsj);
|
||||
}
|
||||
|
||||
//plc读取线程
|
||||
PlcRead plcRead = new PlcRead(list, ssjPlcConnectInfo);
|
||||
Thread plcReadThread = new Thread(plcRead);
|
||||
customThread = new CustomThread<PlcRead>(plcReadThread, plcRead);
|
||||
}
|
||||
|
||||
/**
|
||||
* 开始线程
|
||||
*/
|
||||
public void startAllThread() {
|
||||
customThread.getThread().start();
|
||||
isRun = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 开启线程2
|
||||
*/
|
||||
public void startAllThread2() {
|
||||
//臂式入库线程调度
|
||||
bsInSsjThread.getThread().start();
|
||||
//臂式出库线程调度
|
||||
bsOutSsjThread.getThread().start();
|
||||
//臂式出库到位线程调度-wms电子屏交互
|
||||
bsPickSsjThread.getThread().start();
|
||||
//剪式入库线程调度
|
||||
jsInSsjThread.getThread().start();
|
||||
//剪式出库线程调度
|
||||
//jsOutSsjThread.getThread().start();
|
||||
|
||||
//剪上出库到位线程调度-wms电子屏交互
|
||||
//jsPickSsjThread.getThread().start();
|
||||
//监控输送机
|
||||
//ssjMonitorThread.getThread().start();
|
||||
|
||||
isRun2 = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 停止线程
|
||||
*/
|
||||
public void stopAllThread() {
|
||||
customThread.runnable.isRun = false;
|
||||
plcReadInit();
|
||||
isRun = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 停止线程2
|
||||
*/
|
||||
public void stopAllThread2() {
|
||||
bsInSsjThread.runnable.isRun = false;
|
||||
jsInSsjThread.runnable.isRun = false;
|
||||
bsOutSsjThread.runnable.isRun = false;
|
||||
jsOutSsjThread.runnable.isRun = false;
|
||||
bsPickSsjThread.runnable.isRun = false;
|
||||
jsPickSsjThread.runnable.isRun = false;
|
||||
scheduleInit();
|
||||
isRun2 = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取调度状态
|
||||
*/
|
||||
public HashMap<String,Boolean> getScheduleStatus() {
|
||||
HashMap<String,Boolean> map = new HashMap<>();
|
||||
map.put("isRun",isRun);
|
||||
map.put("isRun2",isRun2);
|
||||
return map;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user