输送线

This commit is contained in:
张怡蓉
2025-11-21 10:47:10 +08:00
parent 9a24fb4be8
commit c3156725d5
2 changed files with 81 additions and 96 deletions

View File

@@ -4,9 +4,12 @@ import com.ruoyi.common.domain.CustomThread;
import com.ruoyi.common.domain.PlcConnectInfo;
import com.ruoyi.device.ddj.domain.MsgDdj;
import com.ruoyi.device.ddj.service.IMsgDdjService;
import com.ruoyi.device.srgv.domain.DeviceSrgv;
import com.ruoyi.device.srgv.service.IDeviceSrgvService;
import com.ruoyi.device.ssj.domain.DeviceSsj;
import com.ruoyi.device.ssj.service.IDeviceSsjService;
import com.ruoyi.schedule.plcRead.ddj.PlcDdjRead;
import com.ruoyi.schedule.plcRead.srgv.PlcSrgvRead;
import com.ruoyi.schedule.plcRead.ssj.PlcSsjRead;
import com.ruoyi.schedule.scheduleTask.ddj.impl.Ddj1Thread;
import com.ruoyi.schedule.scheduleTask.monit.MonitoringThread;
@@ -25,12 +28,9 @@ import java.util.concurrent.ConcurrentHashMap;
public class ScheduleThread {
public CustomThread<PlcSsjRead> plcSsjReadCustomThread;
public CustomThread<PlcDdjRead> plcDdj1ReadCustomThread;
public CustomThread<PlcDdjRead> plcDdj2ReadCustomThread;
public CustomThread<PlcDdjRead> plcDdj3ReadCustomThread;
public CustomThread<PlcDdjRead> plcDdj4ReadCustomThread;
public CustomThread<PlcDdjRead> plcDdj5ReadCustomThread;
public CustomThread<PlcDdjRead> plcDdj6ReadCustomThread;
public CustomThread<PlcSrgvRead> plcSrgvReadCustomThread1;
public CustomThread<PlcSrgvRead> plcSrgvReadCustomThread2;
public CustomThread<PlcSrgvRead> plcSrgvReadCustomThread3;
public CustomThread<MonitoringThread> monitoringCustomThread;
public CustomThread<SsjThread> ssjThreadCustomThread;
@@ -44,6 +44,8 @@ public class ScheduleThread {
private IDeviceSsjService deviceSsjService;
@Autowired
private IMsgDdjService msgDdjService;
@Autowired
private IDeviceSrgvService deviceSrgvService;
private boolean isRun = false;
private boolean isRun2 = false;
@@ -94,56 +96,37 @@ public class ScheduleThread {
ssjList.put(deviceSsj.getDeviceCode(), deviceSsj);
}
//plc输送机读取线程
PlcSsjRead plcSsjRead = new PlcSsjRead(ssjList, new PlcConnectInfo("127.0.0.1", 102));
Thread plcSsjReadThread = new Thread(plcSsjRead);
plcSsjReadCustomThread = new CustomThread<PlcSsjRead>(plcSsjReadThread, plcSsjRead);
//plc堆垛机读取现场
ConcurrentHashMap<String, MsgDdj> ddjList = new ConcurrentHashMap<>();
List<MsgDdj> msgDdjs = msgDdjService.selectMsgDdjList(new MsgDdj());
for (MsgDdj msgDdj : msgDdjs) {
switch (msgDdj.getId()){
ConcurrentHashMap<String, DeviceSrgv> srgvList = new ConcurrentHashMap<>();
List<DeviceSrgv> srgvs=deviceSrgvService.selectDeviceSrgvList(new DeviceSrgv());
for(DeviceSrgv srgv:srgvs){
srgvList.put(srgv.getDeviceId().toString(),srgv);
switch (srgv.getDeviceId()){
case 1:
msgDdj.setPlcDbReadAddress("DB41.0");
PlcDdjRead plcDdjRead1 = new PlcDdjRead(ddjList, new PlcConnectInfo("127.0.0.1", 102));
Thread plcDdjReadThread1 = new Thread(plcDdjRead1);
plcDdj1ReadCustomThread = new CustomThread<PlcDdjRead>(plcDdjReadThread1, plcDdjRead1);
PlcSrgvRead plcSrgvRead1=new PlcSrgvRead(srgv,new PlcConnectInfo(srgv.getIp(),srgv.getPort()));
Thread plcSrgvReadThread1 = new Thread((plcSrgvRead1));
plcSrgvReadCustomThread1=new CustomThread<PlcSrgvRead>(plcSrgvReadThread1,plcSrgvRead1);
break;
case 2:
msgDdj.setPlcDbReadAddress("DB42.0");
PlcDdjRead plcDdjRead2 = new PlcDdjRead(ddjList, new PlcConnectInfo("127.0.0.2", 102));
Thread plcDdjReadThread2 = new Thread(plcDdjRead2);
plcDdj2ReadCustomThread = new CustomThread<PlcDdjRead>(plcDdjReadThread2, plcDdjRead2);
PlcSrgvRead plcSrgvRead2=new PlcSrgvRead(srgv,new PlcConnectInfo(srgv.getIp(),srgv.getPort()));
Thread plcSrgvReadThread2 = new Thread((plcSrgvRead2));
plcSrgvReadCustomThread2=new CustomThread<PlcSrgvRead>(plcSrgvReadThread2,plcSrgvRead2);
break;
case 3:
msgDdj.setPlcDbReadAddress("DB42.0");
PlcDdjRead plcDdjRead3 = new PlcDdjRead(ddjList, new PlcConnectInfo("127.0.0.3", 102));
Thread plcDdjReadThread3 = new Thread(plcDdjRead3);
plcDdj3ReadCustomThread = new CustomThread<PlcDdjRead>(plcDdjReadThread3, plcDdjRead3);
break;
case 4:
msgDdj.setPlcDbReadAddress("DB42.0");
PlcDdjRead plcDdjRead4 = new PlcDdjRead(ddjList, new PlcConnectInfo("127.0.0.4", 102));
Thread plcDdjReadThread4 = new Thread(plcDdjRead4);
plcDdj4ReadCustomThread = new CustomThread<PlcDdjRead>(plcDdjReadThread4, plcDdjRead4);
break;
case 5:
msgDdj.setPlcDbReadAddress("DB42.0");
PlcDdjRead plcDdjRead5 = new PlcDdjRead(ddjList, new PlcConnectInfo("127.0.0.5", 102));
Thread plcDdjReadThread5 = new Thread(plcDdjRead5);
plcDdj5ReadCustomThread = new CustomThread<PlcDdjRead>(plcDdjReadThread5, plcDdjRead5);
break;
case 6:
msgDdj.setPlcDbReadAddress("DB42.0");
PlcDdjRead plcDdjRead6 = new PlcDdjRead(ddjList, new PlcConnectInfo("127.0.0.6", 102));
Thread plcDdjReadThread6 = new Thread(plcDdjRead6);
plcDdj6ReadCustomThread = new CustomThread<PlcDdjRead>(plcDdjReadThread6, plcDdjRead6);
PlcSrgvRead plcSrgvRead3=new PlcSrgvRead(srgv,new PlcConnectInfo(srgv.getIp(),srgv.getPort()));
Thread plcSrgvReadThread3 = new Thread((plcSrgvRead3));
plcSrgvReadCustomThread3=new CustomThread<PlcSrgvRead>(plcSrgvReadThread3,plcSrgvRead3);
break;
}
ddjList.put("ddj" + msgDdj.getId(), msgDdj);
}
PlcSrgvRead.deviceSrgvMap=srgvList;
}
/**
@@ -151,12 +134,10 @@ public class ScheduleThread {
*/
public void startAllThread() {
plcSsjReadCustomThread.getThread().start();
plcDdj1ReadCustomThread.getThread().start();
plcDdj2ReadCustomThread.getThread().start();
plcDdj3ReadCustomThread.getThread().start();
plcDdj4ReadCustomThread.getThread().start();
plcDdj5ReadCustomThread.getThread().start();
plcDdj6ReadCustomThread.getThread().start();
plcSrgvReadCustomThread1.getThread().start();
plcSrgvReadCustomThread2.getThread().start();
plcSrgvReadCustomThread3.getThread().start();
isRun = true;
}
@@ -180,7 +161,7 @@ public class ScheduleThread {
*/
public void stopAllThread() {
plcSsjReadCustomThread.runnable.isRun = false;
plcDdj1ReadCustomThread.runnable.isRun = false;
// plcDdj1ReadCustomThread.runnable.isRun = false;
/* plcDdj2ReadCustomThread.runnable.isRun = false;
plcDdj3ReadCustomThread.runnable.isRun = false;
plcDdj4ReadCustomThread.runnable.isRun = false;