118 lines
4.0 KiB
Java
118 lines
4.0 KiB
Java
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 org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Component;
|
|
|
|
import javax.annotation.PostConstruct;
|
|
import java.util.List;
|
|
import java.util.concurrent.ConcurrentHashMap;
|
|
|
|
@Component
|
|
public class ScheduleThread {
|
|
|
|
public CustomThread customThread;
|
|
@Autowired
|
|
private IDeviceSsjService deviceSsjService;
|
|
|
|
public CustomThread bsInSsjThread;
|
|
public CustomThread jsInSsjThread;
|
|
public CustomThread bsOutSsjThread;
|
|
public CustomThread jsOutSsjThread;
|
|
public CustomThread bsPickSsjThread;
|
|
public CustomThread jsPickSsjThread;
|
|
|
|
/**
|
|
* 项目初始化启动
|
|
*/
|
|
@PostConstruct
|
|
public void init() {
|
|
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(plcReadThread, plcRead);
|
|
|
|
//调度初始化
|
|
BsInSsjThread bsInSsjThread1 = new BsInSsjThread();
|
|
bsInSsjThread = new CustomThread(new Thread(bsInSsjThread1),bsInSsjThread1);
|
|
JsInSsjThread jsInSsjThread1 = new JsInSsjThread();
|
|
jsInSsjThread = new CustomThread(new Thread(jsInSsjThread1),bsInSsjThread1);
|
|
BsOutSsjThread bsOutSsjThread1 = new BsOutSsjThread();
|
|
bsOutSsjThread = new CustomThread(new Thread(bsOutSsjThread1),bsOutSsjThread1);
|
|
JsOutSsjThread jsOutSsjThread1 = new JsOutSsjThread();
|
|
jsOutSsjThread = new CustomThread(new Thread(jsOutSsjThread1),jsOutSsjThread1);
|
|
BsPickSsjTread bsPickSsjTread1 = new BsPickSsjTread();
|
|
bsPickSsjThread = new CustomThread(new Thread(bsPickSsjTread1),bsPickSsjTread1);
|
|
JsPickSsjTread jsPickSsjTread1 = new JsPickSsjTread();
|
|
jsPickSsjThread = new CustomThread(new Thread(jsPickSsjTread1),jsPickSsjTread1);
|
|
}
|
|
|
|
/**
|
|
* 开始线程
|
|
*/
|
|
public void startAllThread() {
|
|
customThread.getThread().start();
|
|
}
|
|
|
|
public void startAllThread2() {
|
|
//臂式入库线程调度
|
|
bsInSsjThread.getThread().start();
|
|
//臂式出库线程调度
|
|
bsOutSsjThread.getThread().start();
|
|
//臂式出库到位线程调度-wms电子屏交互
|
|
bsPickSsjThread.getThread().start();
|
|
//剪式入库线程调度
|
|
//jsInSsjThread.getThread().start();
|
|
//剪式出库线程调度
|
|
//jsOutSsjThread.getThread().start();
|
|
|
|
//剪上出库到位线程调度-wms电子屏交互
|
|
//jsPickSsjThread.getThread().start();
|
|
}
|
|
|
|
/**
|
|
* 停止线程
|
|
*/
|
|
public void stopAllThread() {
|
|
stopThread(customThread);
|
|
}
|
|
|
|
public void stopAllThread2() {
|
|
stopThread(bsInSsjThread);
|
|
stopThread(jsInSsjThread);
|
|
stopThread(bsOutSsjThread);
|
|
stopThread(jsOutSsjThread);
|
|
stopThread(bsPickSsjThread);
|
|
stopThread(jsPickSsjThread);
|
|
}
|
|
|
|
/**
|
|
* 停止线程
|
|
*/
|
|
private void stopThread(CustomThread customThread) {
|
|
|
|
}
|
|
|
|
|
|
}
|