测试 +修改

This commit is contained in:
zgw
2025-12-18 10:40:00 +08:00
parent 0feecacfdf
commit d8412ac3cc
14 changed files with 701 additions and 587 deletions

View File

@@ -1,5 +1,6 @@
package com.ruoyi.schedule;
import HslCommunication.Core.Types.OperateResultExOne;
import com.ruoyi.common.domain.CustomThread;
import com.ruoyi.common.domain.PlcConnectInfo;
import com.ruoyi.device.ddj.domain.MsgDdj;
@@ -8,9 +9,12 @@ 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.device.tsj.domain.DeviceTsj;
import com.ruoyi.device.tsj.service.impl.DeviceTsjServiceImpl;
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.plcRead.tsj.PlcTsjRead;
import com.ruoyi.schedule.scheduleTask.cdz.CdzThread;
import com.ruoyi.schedule.scheduleTask.ddj.impl.Ddj1Thread;
import com.ruoyi.schedule.scheduleTask.monit.MonitoringThread;
@@ -31,6 +35,7 @@ import java.util.concurrent.ConcurrentHashMap;
public class ScheduleThread {
public CustomThread<PlcSsjRead> plcSsjReadCustomThread;
public CustomThread<PlcTsjRead> plcTsjReadCustomThread;
public CustomThread<PlcSrgvRead> plcSrgvReadCustomThread1;
public CustomThread<PlcSrgvRead> plcSrgvReadCustomThread2;
public CustomThread<PlcSrgvRead> plcSrgvReadCustomThread3;
@@ -53,6 +58,8 @@ public class ScheduleThread {
private boolean isRun = false;
private boolean isRun2 = false;
@Autowired
private DeviceTsjServiceImpl deviceTsjServiceImpl;
/**
* 项目初始化启动
@@ -66,51 +73,50 @@ public class ScheduleThread {
scheduleInit();
log.info("调度服务执行成功");
}
/**
* 调度初始化
*/
private void scheduleInit() {
MonitoringThread monitoringThread = new MonitoringThread();
monitoringCustomThread = new CustomThread<MonitoringThread>(new Thread(monitoringThread), monitoringThread);
//输送机线程
SsjThread ssjThread=new SsjThread();
ssjThreadCustomThread=new CustomThread<SsjThread>(new Thread(ssjThread),ssjThread);
// //四向车线程
SRgv1Thread srgvThread=new SRgv1Thread();
sRgvThreadCustomThread=new CustomThread<>(new Thread(srgvThread),srgvThread);
//提升机线程
TsjThread tsjThread=new TsjThread();
tsjThreadCustomThread=new CustomThread<>(new Thread(tsjThread),tsjThread);
CdzThread cdzThread = new CdzThread();
cdzThreadCustomThread=new CustomThread<>(new Thread(cdzThread),cdzThread);
// Ddj1Thread ddj1Thread = new Ddj1Thread();
// ddj1CustomThread = new CustomThread<>(new Thread(ddj1Thread), ddj1Thread);
/*Ddj2Thread ddj2Thread = new Ddj2Thread();
ddj2CustomThread = new CustomThread<>(new Thread(ddj2Thread), ddj2Thread);
Ddj3Thread ddj3Thread = new Ddj3Thread();
ddj3CustomThread = new CustomThread<>(new Thread(ddj3Thread), ddj3Thread);
Ddj4Thread ddj4Thread = new Ddj4Thread();
ddj4CustomThread = new CustomThread<>(new Thread(ddj4Thread), ddj4Thread);
Ddj5Thread ddj5Thread = new Ddj5Thread();
ddj5CustomThread = new CustomThread<>(new Thread(ddj5Thread), ddj5Thread);
Ddj6Thread ddj6Thread = new Ddj6Thread();
ddj6CustomThread = new CustomThread<>(new Thread(ddj6Thread), ddj6Thread);*/
// //充电线程
// CdzThread cdzThread = new CdzThread();
// cdzThreadCustomThread=new CustomThread<>(new Thread(cdzThread),cdzThread);
}
/**
* plc读取初始化
*/
private void plcReadInit() {
ConcurrentHashMap<String, DeviceSsj> ssjList = new ConcurrentHashMap<>();
//获取要去取的输送机
//获取要取的输送机
List<DeviceSsj> deviceSsjs = deviceSsjService.selectDeviceSsjList(new DeviceSsj());
for (DeviceSsj deviceSsj : deviceSsjs) {
ssjList.put(deviceSsj.getDeviceCode(), deviceSsj);
}
//plc输送机读取线程
PlcSsjRead plcSsjRead = new PlcSsjRead(ssjList, new PlcConnectInfo("127.0.0.1", 102));
PlcSsjRead plcSsjRead = new PlcSsjRead(ssjList, new PlcConnectInfo("127.0.0.1", 1502));
Thread plcSsjReadThread = new Thread(plcSsjRead);
plcSsjReadCustomThread = new CustomThread<PlcSsjRead>(plcSsjReadThread, plcSsjRead);
ConcurrentHashMap<String, DeviceTsj> tsjList = new ConcurrentHashMap<>();
//获取要取的提升机
List<DeviceTsj> tsjLists = deviceTsjServiceImpl.selectDeviceTsjList(new DeviceTsj());
for (DeviceTsj t : tsjLists) {
tsjList.put(t.getName(), t);
}
//plc提升机读取线程
PlcTsjRead plcTsjRead = new PlcTsjRead(tsjList, new PlcConnectInfo("127.0.0.1", 1502));
Thread plcTsjReadThread = new Thread(plcTsjRead);
plcTsjReadCustomThread = new CustomThread<PlcTsjRead>(plcTsjReadThread, plcTsjRead);
ConcurrentHashMap<String, DeviceSrgv> srgvList = new ConcurrentHashMap<>();
List<DeviceSrgv> srgvs=deviceSrgvService.selectDeviceSrgvList(new DeviceSrgv());
for(DeviceSrgv srgv:srgvs){
@@ -126,17 +132,12 @@ public class ScheduleThread {
Thread plcSrgvReadThread2 = new Thread((plcSrgvRead2));
plcSrgvReadCustomThread2=new CustomThread<PlcSrgvRead>(plcSrgvReadThread2,plcSrgvRead2);
break;
/*case 3:
PlcSrgvRead plcSrgvRead3=new PlcSrgvRead(srgv,new PlcConnectInfo(srgv.getIp(),srgv.getPort()));
Thread plcSrgvReadThread3 = new Thread((plcSrgvRead3));
plcSrgvReadCustomThread3=new CustomThread<PlcSrgvRead>(plcSrgvReadThread3,plcSrgvRead3);
break;*/
}
}
PlcSrgvRead.deviceSrgvMap=srgvList;
//监控线程
MonitoringThread monitoringThread = new MonitoringThread();
monitoringCustomThread = new CustomThread<MonitoringThread>(new Thread(monitoringThread), monitoringThread);
}
/**
@@ -145,10 +146,9 @@ public class ScheduleThread {
public void startAllThread() {
plcSsjReadCustomThread.getThread().start();
plcSrgvReadCustomThread1.getThread().start();
//plcSrgvReadCustomThread2.getThread().start();
//plcSrgvReadCustomThread3.getThread().start();
// plcSrgvReadCustomThread2.getThread().start();
plcTsjReadCustomThread.getThread().start();
monitoringCustomThread.getThread().start();
isRun = true;
}
@@ -156,17 +156,10 @@ public class ScheduleThread {
* 开启线程2
*/
public void startAllThread2() {
monitoringCustomThread.thread.start();
ssjThreadCustomThread.thread.start();
//tsjThreadCustomThread.thread.start();
tsjThreadCustomThread.thread.start();
sRgvThreadCustomThread.thread.start();
//cdzThreadCustomThread.thread.start();
// ddj1CustomThread.thread.start();
/*ddj2CustomThread.thread.start();
ddj3CustomThread.thread.start();
ddj4CustomThread.thread.start();
ddj5CustomThread.thread.start();
ddj6CustomThread.thread.start();*/
isRun2 = true;
}
@@ -175,7 +168,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;
@@ -209,4 +202,5 @@ public class ScheduleThread {
map.put("isRun2",isRun2);
return map;
}
}