堆垛机线程调度 输送线线程调度 监控线程调度

This commit is contained in:
liuhanqing
2025-09-25 14:15:35 +08:00
parent 9640507cfd
commit 0322611d7b
7 changed files with 140 additions and 238 deletions

View File

@@ -1,12 +1,21 @@
package com.ruoyi.schedule;
import com.ruoyi.device.ddj.domain.MsgDdj;
import com.ruoyi.device.ddj.service.IMsgDdjService;
import com.ruoyi.device.ssj.domain.DeviceSsj;
import com.ruoyi.device.ssj.service.IDeviceSsjService;
import com.ruoyi.common.domain.PlcConnectInfo;
import com.ruoyi.schedule.plcRead.ddj.PlcDdjRead;
import com.ruoyi.schedule.plcRead.ssj.PlcSsjRead;
import com.ruoyi.common.domain.CustomThread;
import com.ruoyi.schedule.scheduleTask.ddj.Ddj1Thread;
import com.ruoyi.schedule.scheduleTask.monit.MonitoringThread;
import com.ruoyi.schedule.scheduleTask.ssj.floor1.Floor1BothWayInSsjThread;
import com.ruoyi.schedule.scheduleTask.ssj.floor1.Floor1BothWayOutSsjThread;
import com.ruoyi.schedule.scheduleTask.ssj.floor1.Floor1SingleSsjThread;
import com.ruoyi.schedule.scheduleTask.ssj.floor2.Floor2InSsjThread;
import com.ruoyi.schedule.scheduleTask.ssj.floor2.Floor2OutSsjThread;
import com.ruoyi.schedule.scheduleTask.ssj.floor2.LineSsjThread;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@@ -20,10 +29,21 @@ import java.util.concurrent.ConcurrentHashMap;
@Slf4j
public class ScheduleThread {
public CustomThread<PlcSsjRead> customSsjThread;
public CustomThread<PlcDdjRead> customDdjThread;
public CustomThread<PlcSsjRead> plcSsjReadCustomThread;
public CustomThread<PlcDdjRead> plcDdjReadCustomThread;
public CustomThread<Floor1BothWayInSsjThread> floor1BothWayInSsjCustomThread;
public CustomThread<Floor1BothWayOutSsjThread> floor1BothWayOutSsjCustomThread;
public CustomThread<Floor1SingleSsjThread> floor1SingleSsjCustomThread;
public CustomThread<Floor2InSsjThread> floor2InSsjCustomThread;
public CustomThread<Floor2OutSsjThread> floor2OutSsjCustomThread;
public CustomThread<LineSsjThread> lineSsjCustomThread;
public CustomThread<MonitoringThread> monitoringCustomThread;
public CustomThread<Ddj1Thread> ddj1CustomThread;
@Autowired
private IDeviceSsjService deviceSsjService;
@Autowired
private IMsgDdjService msgDdjService;
private boolean isRun = false;
private boolean isRun2 = false;
@@ -45,47 +65,57 @@ public class ScheduleThread {
* 调度初始化
*/
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);
MonitoringThread monitoringThread = new MonitoringThread();
monitoringCustomThread = new CustomThread<MonitoringThread>(new Thread(monitoringThread), monitoringThread);
SsjMonitorThread ssjMonitorThread1 = new SsjMonitorThread();
ssjMonitorThread = new CustomThread<SsjMonitorThread>(new Thread(ssjMonitorThread1), ssjMonitorThread1);*/
Floor1BothWayInSsjThread floor1BothWayInSsjThread = new Floor1BothWayInSsjThread();
floor1BothWayInSsjCustomThread = new CustomThread<Floor1BothWayInSsjThread>(new Thread(floor1BothWayInSsjThread), floor1BothWayInSsjThread);
Floor1BothWayOutSsjThread floor1BothWayOutSsjThread = new Floor1BothWayOutSsjThread();
floor1BothWayOutSsjCustomThread = new CustomThread<Floor1BothWayOutSsjThread>(new Thread(floor1BothWayOutSsjThread), floor1BothWayOutSsjThread);
Floor1SingleSsjThread floor1SingleSsjThread = new Floor1SingleSsjThread();
floor1SingleSsjCustomThread = new CustomThread<Floor1SingleSsjThread>(new Thread(floor1SingleSsjThread), floor1SingleSsjThread);
Floor2InSsjThread floor2InSsjThread = new Floor2InSsjThread();
floor2InSsjCustomThread = new CustomThread<Floor2InSsjThread>(new Thread(floor2InSsjThread), floor2InSsjThread);
LineSsjThread lineSsjThread = new LineSsjThread();
lineSsjCustomThread = new CustomThread<LineSsjThread>(new Thread(lineSsjThread), lineSsjThread);
Floor2OutSsjThread floor2OutSsjThread = new Floor2OutSsjThread();
floor2OutSsjCustomThread = new CustomThread<Floor2OutSsjThread>(new Thread(floor2OutSsjThread), floor2OutSsjThread);
Ddj1Thread ddj1Thread = new Ddj1Thread();
ddj1CustomThread = new CustomThread<Ddj1Thread>(new Thread(ddj1Thread), ddj1Thread);
}
/**
* 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<>();
ConcurrentHashMap<String, DeviceSsj> ssjList = new ConcurrentHashMap<>();
//获取要去取的输送机
List<DeviceSsj> deviceSsjs = deviceSsjService.selectDeviceSsjList(new DeviceSsj());
for (DeviceSsj deviceSsj : deviceSsjs) {
list.put(deviceSsj.getDeviceCode(), deviceSsj);
ssjList.put(deviceSsj.getDeviceCode(), deviceSsj);
}
//plc输送机读取线程
PlcSsjRead plcSsjRead = new PlcSsjRead(list, ssjPlcConnectInfo);
PlcSsjRead plcSsjRead = new PlcSsjRead(ssjList, new PlcConnectInfo("127.0.0.1", 102));
Thread plcSsjReadThread = new Thread(plcSsjRead);
customSsjThread = new CustomThread<PlcSsjRead>(plcSsjReadThread, plcSsjRead);
plcSsjReadCustomThread = new CustomThread<PlcSsjRead>(plcSsjReadThread, plcSsjRead);
//plc堆垛机读取现场
ConcurrentHashMap<String, MsgDdj> list2 = new ConcurrentHashMap<>();
PlcDdjRead plcDdjRead = new PlcDdjRead(list2, ssjPlcConnectInfo);
ConcurrentHashMap<String, MsgDdj> ddjList = new ConcurrentHashMap<>();
List<MsgDdj> msgDdjs = msgDdjService.selectMsgDdjList(new MsgDdj());
for (MsgDdj msgDdj : msgDdjs) {
ddjList.put("ddj"+msgDdj.getId(), msgDdj);
}
PlcDdjRead plcDdjRead = new PlcDdjRead(ddjList, new PlcConnectInfo("127.0.0.1", 102));
Thread plcDdjReadThread = new Thread(plcDdjRead);
customDdjThread = new CustomThread<PlcDdjRead>(plcDdjReadThread, plcDdjRead);
plcDdjReadCustomThread = new CustomThread<PlcDdjRead>(plcDdjReadThread, plcDdjRead);
}
@@ -93,8 +123,8 @@ public class ScheduleThread {
* 开始线程
*/
public void startAllThread() {
customSsjThread.getThread().start();
customDdjThread.getThread().start();
plcSsjReadCustomThread.getThread().start();
plcDdjReadCustomThread.getThread().start();
isRun = true;
}
@@ -102,22 +132,14 @@ public class ScheduleThread {
* 开启线程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();*/
monitoringCustomThread.thread.start();
floor1BothWayInSsjCustomThread.thread.start();
floor1BothWayOutSsjCustomThread.thread.start();
floor1SingleSsjCustomThread.thread.start();
floor2InSsjCustomThread.thread.start();
lineSsjCustomThread.thread.start();
floor2OutSsjCustomThread.thread.start();
ddj1CustomThread.thread.start();
isRun2 = true;
}
@@ -125,8 +147,8 @@ public class ScheduleThread {
* 停止线程
*/
public void stopAllThread() {
customDdjThread.runnable.isRun = false;
customSsjThread.runnable.isRun = false;
plcSsjReadCustomThread.runnable.isRun = false;
plcDdjReadCustomThread.runnable.isRun = false;
plcReadInit();
isRun = false;
}
@@ -135,12 +157,14 @@ public class ScheduleThread {
* 停止线程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;*/
monitoringCustomThread.runnable.isRun = false;
floor1BothWayInSsjCustomThread.runnable.isRun = false;
floor1BothWayOutSsjCustomThread.runnable.isRun = false;
floor1SingleSsjCustomThread.runnable.isRun = false;
floor2InSsjCustomThread.runnable.isRun = false;
lineSsjCustomThread.runnable.isRun = false;
floor2OutSsjCustomThread.runnable.isRun = false;
ddj1CustomThread.runnable.isRun = false;
scheduleInit();
isRun2 = false;
}