测试过程问题修改
This commit is contained in:
@@ -37,7 +37,6 @@ public class DeviceCarController extends BaseController
|
|||||||
/**
|
/**
|
||||||
* 查询设备信息列表
|
* 查询设备信息列表
|
||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('device:DeviceCar:list')")
|
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
public TableDataInfo list(DeviceCar deviceCar)
|
public TableDataInfo list(DeviceCar deviceCar)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -37,7 +37,6 @@ public class DeviceSrgvController extends BaseController
|
|||||||
/**
|
/**
|
||||||
* 查询四向小车设备表列表
|
* 查询四向小车设备表列表
|
||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('device:srgv:list')")
|
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
public TableDataInfo list(DeviceSrgv deviceSrgv)
|
public TableDataInfo list(DeviceSrgv deviceSrgv)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -37,7 +37,6 @@ public class DeviceSsjController extends BaseController
|
|||||||
/**
|
/**
|
||||||
* 查询输送机列表
|
* 查询输送机列表
|
||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('device:ssj:list')")
|
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
public TableDataInfo list(DeviceSsj deviceSsj)
|
public TableDataInfo list(DeviceSsj deviceSsj)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -37,7 +37,6 @@ public class DeviceTsjController extends BaseController
|
|||||||
/**
|
/**
|
||||||
* 查询提升机设备列表
|
* 查询提升机设备列表
|
||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('device:tsj:list')")
|
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
public TableDataInfo list(DeviceTsj deviceTsj)
|
public TableDataInfo list(DeviceTsj deviceTsj)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -250,7 +250,6 @@ public class IndexController extends BaseController {
|
|||||||
statusCount.put("SRGV", new HashMap<>());
|
statusCount.put("SRGV", new HashMap<>());
|
||||||
statusCount.put("TSJ", new HashMap<>());
|
statusCount.put("TSJ", new HashMap<>());
|
||||||
statusCount.put("SSJ", new HashMap<>());
|
statusCount.put("SSJ", new HashMap<>());
|
||||||
|
|
||||||
// 查询DeviceCar数据(AGV)
|
// 查询DeviceCar数据(AGV)
|
||||||
DeviceSrgv deviceSrgv = new DeviceSrgv();
|
DeviceSrgv deviceSrgv = new DeviceSrgv();
|
||||||
List<DeviceSrgv> deviceSrgvs = deviceSrgvService.selectDeviceSrgvList(deviceSrgv);
|
List<DeviceSrgv> deviceSrgvs = deviceSrgvService.selectDeviceSrgvList(deviceSrgv);
|
||||||
@@ -274,19 +273,15 @@ public class IndexController extends BaseController {
|
|||||||
for (DeviceSsj ssj : ssjList) {
|
for (DeviceSsj ssj : ssjList) {
|
||||||
int taskNo = ssj.getTaskNo();
|
int taskNo = ssj.getTaskNo();
|
||||||
String status = "其他";
|
String status = "其他";
|
||||||
|
|
||||||
// 根据taskNo判断状态:不等于空或0时为运行状态
|
// 根据taskNo判断状态:不等于空或0时为运行状态
|
||||||
if (taskNo != 0) {
|
if (taskNo != 0) {
|
||||||
status = "运行";
|
status = "运行";
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<String, Integer> typeStatusCount = statusCount.get("SSJ");
|
Map<String, Integer> typeStatusCount = statusCount.get("SSJ");
|
||||||
typeStatusCount.put(status, typeStatusCount.getOrDefault(status, 0) + 1);
|
typeStatusCount.put(status, typeStatusCount.getOrDefault(status, 0) + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
DeviceTsj deviceTsj = new DeviceTsj();
|
DeviceTsj deviceTsj = new DeviceTsj();
|
||||||
List<DeviceTsj> TsjList = deviceTsjService.selectDeviceTsjList(deviceTsj);
|
List<DeviceTsj> TsjList = deviceTsjService.selectDeviceTsjList(deviceTsj);
|
||||||
|
|
||||||
for (DeviceTsj tsj : TsjList){
|
for (DeviceTsj tsj : TsjList){
|
||||||
Long taskNo = tsj.getRwh();
|
Long taskNo = tsj.getRwh();
|
||||||
String status = "其他";
|
String status = "其他";
|
||||||
@@ -296,7 +291,6 @@ public class IndexController extends BaseController {
|
|||||||
Map<String,Integer> typeStatusCount = statusCount.get("TSJ");
|
Map<String,Integer> typeStatusCount = statusCount.get("TSJ");
|
||||||
typeStatusCount.put(status,typeStatusCount.getOrDefault(status,0) + 1);
|
typeStatusCount.put(status,typeStatusCount.getOrDefault(status,0) + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
return AjaxResult.success(statusCount);
|
return AjaxResult.success(statusCount);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
return AjaxResult.error("获取设备状态分布数据失败");
|
return AjaxResult.error("获取设备状态分布数据失败");
|
||||||
|
|||||||
@@ -29,14 +29,22 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import javax.annotation.PostConstruct;
|
import javax.annotation.PostConstruct;
|
||||||
|
import javax.annotation.PreDestroy;
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class ScheduleThread {
|
public class ScheduleThread {
|
||||||
|
|
||||||
|
public Map<String, CustomThread<?>> threadMap = new ConcurrentHashMap<>();
|
||||||
|
public Map<String, String> threadDescMap = new ConcurrentHashMap<>();
|
||||||
|
public Map<String, String> threadTypeMap = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
public CustomThread<PlcSsjRead> plcSsjReadCustomThread;
|
public CustomThread<PlcSsjRead> plcSsjReadCustomThread;
|
||||||
public CustomThread<PlcCdzRead> plcCdzjReadCustomThread;
|
public CustomThread<PlcCdzRead> plcCdzjReadCustomThread;
|
||||||
public CustomThread<PlcTsjRead> plcTsjReadCustomThread;
|
public CustomThread<PlcTsjRead> plcTsjReadCustomThread;
|
||||||
@@ -49,12 +57,7 @@ public class ScheduleThread {
|
|||||||
public CustomThread<SRgv1Thread> sRgvThreadCustomThread;
|
public CustomThread<SRgv1Thread> sRgvThreadCustomThread;
|
||||||
public CustomThread<TsjThread> tsjThreadCustomThread;
|
public CustomThread<TsjThread> tsjThreadCustomThread;
|
||||||
public CustomThread<CdzThread> cdzThreadCustomThread;
|
public CustomThread<CdzThread> cdzThreadCustomThread;
|
||||||
// public CustomThread<Ddj1Thread> ddj1CustomThread;
|
|
||||||
/*public CustomThread<Ddj2Thread> ddj2CustomThread;
|
|
||||||
public CustomThread<Ddj3Thread> ddj3CustomThread;
|
|
||||||
public CustomThread<Ddj4Thread> ddj4CustomThread;
|
|
||||||
public CustomThread<Ddj5Thread> ddj5CustomThread;
|
|
||||||
public CustomThread<Ddj6Thread> ddj6CustomThread;*/
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private IDeviceSsjService deviceSsjService;
|
private IDeviceSsjService deviceSsjService;
|
||||||
@Autowired
|
@Autowired
|
||||||
@@ -85,23 +88,27 @@ public class ScheduleThread {
|
|||||||
|
|
||||||
log.info("调度服务执行成功");
|
log.info("调度服务执行成功");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 调度初始化
|
* 调度初始化
|
||||||
*/
|
*/
|
||||||
private void scheduleInit() {
|
private void scheduleInit() {
|
||||||
//输送机线程
|
//输送机线程
|
||||||
SsjThread ssjThread=new SsjThread();
|
SsjThread ssjThread = new SsjThread();
|
||||||
ssjThreadCustomThread=new CustomThread<SsjThread>(new Thread(ssjThread),ssjThread);
|
ssjThreadCustomThread = new CustomThread<SsjThread>(new Thread(ssjThread, "ssjThreadCustomThread"), ssjThread);
|
||||||
// //四向车线程
|
//四向车线程
|
||||||
SRgv1Thread srgvThread=new SRgv1Thread();
|
SRgv1Thread srgvThread = new SRgv1Thread();
|
||||||
sRgvThreadCustomThread=new CustomThread<>(new Thread(srgvThread),srgvThread);
|
sRgvThreadCustomThread = new CustomThread<>(new Thread(srgvThread, "sRgvThreadCustomThread"), srgvThread);
|
||||||
//提升机线程
|
//提升机线程
|
||||||
TsjThread tsjThread=new TsjThread();
|
TsjThread tsjThread = new TsjThread();
|
||||||
tsjThreadCustomThread=new CustomThread<>(new Thread(tsjThread),tsjThread);
|
tsjThreadCustomThread = new CustomThread<>(new Thread(tsjThread, "tsjThreadCustomThread"), tsjThread);
|
||||||
//充电线程
|
//充电线程
|
||||||
CdzThread cdzThread = new CdzThread();
|
CdzThread cdzThread = new CdzThread();
|
||||||
cdzThreadCustomThread=new CustomThread<>(new Thread(cdzThread),cdzThread);
|
cdzThreadCustomThread = new CustomThread<>(new Thread(cdzThread, "cdzThreadCustomThread"), cdzThread);
|
||||||
|
|
||||||
|
refreshThreadMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* plc读取初始化
|
* plc读取初始化
|
||||||
*/
|
*/
|
||||||
@@ -114,17 +121,17 @@ public class ScheduleThread {
|
|||||||
ssjList.put(deviceSsj.getDeviceCode(), deviceSsj);
|
ssjList.put(deviceSsj.getDeviceCode(), deviceSsj);
|
||||||
}
|
}
|
||||||
PlcSsjRead plcSsjRead = new PlcSsjRead(ssjList, new PlcConnectInfo("127.0.0.1", 1502));
|
PlcSsjRead plcSsjRead = new PlcSsjRead(ssjList, new PlcConnectInfo("127.0.0.1", 1502));
|
||||||
Thread plcSsjReadThread = new Thread(plcSsjRead);
|
Thread plcSsjReadThread = new Thread(plcSsjRead, "plcSsjReadCustomThread");
|
||||||
plcSsjReadCustomThread = new CustomThread<PlcSsjRead>(plcSsjReadThread, plcSsjRead);
|
plcSsjReadCustomThread = new CustomThread<PlcSsjRead>(plcSsjReadThread, plcSsjRead);
|
||||||
|
|
||||||
//plc充电桩读取线程
|
//plc充电桩读取线程
|
||||||
ConcurrentHashMap<String, DeviceCdz> cdzList = new ConcurrentHashMap<>();
|
ConcurrentHashMap<String, DeviceCdz> cdzList = new ConcurrentHashMap<>();
|
||||||
List<DeviceCdz> deviceCdzList =deviceCdzService.selectDeviceCdzList(new DeviceCdz());
|
List<DeviceCdz> deviceCdzList = deviceCdzService.selectDeviceCdzList(new DeviceCdz());
|
||||||
for (DeviceCdz deviceCdz : deviceCdzList) {
|
for (DeviceCdz deviceCdz : deviceCdzList) {
|
||||||
cdzList.put(String.valueOf(deviceCdz.getId()),deviceCdz);
|
cdzList.put(String.valueOf(deviceCdz.getId()), deviceCdz);
|
||||||
}
|
}
|
||||||
PlcCdzRead plcCdzRead = new PlcCdzRead(cdzList, new PlcConnectInfo("127.0.0.1", 1502));
|
PlcCdzRead plcCdzRead = new PlcCdzRead(cdzList, new PlcConnectInfo("127.0.0.1", 1502));
|
||||||
Thread plcCdzReadThread = new Thread(plcCdzRead);
|
Thread plcCdzReadThread = new Thread(plcCdzRead, "plcCdzjReadCustomThread");
|
||||||
plcCdzjReadCustomThread = new CustomThread<PlcCdzRead>(plcCdzReadThread, plcCdzRead);
|
plcCdzjReadCustomThread = new CustomThread<PlcCdzRead>(plcCdzReadThread, plcCdzRead);
|
||||||
|
|
||||||
|
|
||||||
@@ -136,83 +143,100 @@ public class ScheduleThread {
|
|||||||
}
|
}
|
||||||
//plc提升机读取线程
|
//plc提升机读取线程
|
||||||
PlcTsjRead plcTsjRead = new PlcTsjRead(tsjList, new PlcConnectInfo("127.0.0.1", 1502));
|
PlcTsjRead plcTsjRead = new PlcTsjRead(tsjList, new PlcConnectInfo("127.0.0.1", 1502));
|
||||||
Thread plcTsjReadThread = new Thread(plcTsjRead);
|
Thread plcTsjReadThread = new Thread(plcTsjRead, "plcTsjReadCustomThread");
|
||||||
plcTsjReadCustomThread = new CustomThread<PlcTsjRead>(plcTsjReadThread, plcTsjRead);
|
plcTsjReadCustomThread = new CustomThread<PlcTsjRead>(plcTsjReadThread, plcTsjRead);
|
||||||
|
|
||||||
ConcurrentHashMap<String, DeviceSrgv> srgvList = new ConcurrentHashMap<>();
|
ConcurrentHashMap<String, DeviceSrgv> srgvList = new ConcurrentHashMap<>();
|
||||||
List<DeviceSrgv> srgvs=deviceSrgvService.selectDeviceSrgvList(new DeviceSrgv());
|
List<DeviceSrgv> srgvs = deviceSrgvService.selectDeviceSrgvList(new DeviceSrgv());
|
||||||
for(DeviceSrgv srgv:srgvs){
|
for (DeviceSrgv srgv : srgvs) {
|
||||||
srgvList.put(srgv.getDeviceId().toString(),srgv);
|
srgvList.put(srgv.getDeviceId().toString(), srgv);
|
||||||
switch (srgv.getDeviceId()){
|
switch (srgv.getDeviceId()) {
|
||||||
case 1:
|
case 1:
|
||||||
PlcSrgvRead plcSrgvRead1=new PlcSrgvRead(srgv,new PlcConnectInfo(srgv.getIp(),srgv.getPort()));
|
PlcSrgvRead plcSrgvRead1 = new PlcSrgvRead(srgv, new PlcConnectInfo(srgv.getIp(), srgv.getPort()));
|
||||||
Thread plcSrgvReadThread1 = new Thread((plcSrgvRead1));
|
Thread plcSrgvReadThread1 = new Thread(plcSrgvRead1, "plcSrgvReadCustomThread1");
|
||||||
plcSrgvReadCustomThread1=new CustomThread<PlcSrgvRead>(plcSrgvReadThread1,plcSrgvRead1);
|
plcSrgvReadCustomThread1 = new CustomThread<PlcSrgvRead>(plcSrgvReadThread1, plcSrgvRead1);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
PlcSrgvRead plcSrgvRead2=new PlcSrgvRead(srgv,new PlcConnectInfo(srgv.getIp(),srgv.getPort()));
|
PlcSrgvRead plcSrgvRead2 = new PlcSrgvRead(srgv, new PlcConnectInfo(srgv.getIp(), srgv.getPort()));
|
||||||
Thread plcSrgvReadThread2 = new Thread((plcSrgvRead2));
|
Thread plcSrgvReadThread2 = new Thread(plcSrgvRead2, "plcSrgvReadCustomThread2");
|
||||||
plcSrgvReadCustomThread2=new CustomThread<PlcSrgvRead>(plcSrgvReadThread2,plcSrgvRead2);
|
plcSrgvReadCustomThread2 = new CustomThread<PlcSrgvRead>(plcSrgvReadThread2, plcSrgvRead2);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PlcSrgvRead.deviceSrgvMap=srgvList;
|
PlcSrgvRead.deviceSrgvMap = srgvList;
|
||||||
//监控线程
|
//监控线程
|
||||||
MonitoringThread monitoringThread = new MonitoringThread();
|
MonitoringThread monitoringThread = new MonitoringThread();
|
||||||
monitoringCustomThread = new CustomThread<MonitoringThread>(new Thread(monitoringThread), monitoringThread);
|
monitoringCustomThread = new CustomThread<MonitoringThread>(new Thread(monitoringThread, "monitoringCustomThread"), monitoringThread);
|
||||||
|
|
||||||
|
refreshThreadMap();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void refreshThreadMap() {
|
||||||
|
registerThread("plcSsjReadCustomThread", plcSsjReadCustomThread, "PLC输送机读取线程", "read");
|
||||||
|
registerThread("plcCdzjReadCustomThread", plcCdzjReadCustomThread, "PLC充电桩读取线程", "read");
|
||||||
|
registerThread("plcTsjReadCustomThread", plcTsjReadCustomThread, "PLC提升机读取线程", "read");
|
||||||
|
registerThread("plcSrgvReadCustomThread1", plcSrgvReadCustomThread1, "PLC四向车1读取线程", "read");
|
||||||
|
registerThread("plcSrgvReadCustomThread2", plcSrgvReadCustomThread2, "PLC四向车2读取线程", "read");
|
||||||
|
registerThread("monitoringCustomThread", monitoringCustomThread, "监控线程", "monitor");
|
||||||
|
registerThread("ssjThreadCustomThread", ssjThreadCustomThread, "输送机调度线程", "schedule");
|
||||||
|
registerThread("sRgvThreadCustomThread", sRgvThreadCustomThread, "四向车调度线程", "schedule");
|
||||||
|
registerThread("tsjThreadCustomThread", tsjThreadCustomThread, "提升机调度线程", "schedule");
|
||||||
|
registerThread("cdzThreadCustomThread", cdzThreadCustomThread, "充电调度线程", "schedule");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void registerThread(String key, CustomThread<?> thread, String desc, String type) {
|
||||||
|
if (thread != null) {
|
||||||
|
threadMap.put(key, thread);
|
||||||
|
threadDescMap.put(key, desc);
|
||||||
|
threadTypeMap.put(key, type);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 开始线程
|
* 开始线程 读取
|
||||||
*/
|
*/
|
||||||
public void startAllThread() {
|
public void startAllThread() {
|
||||||
plcSsjReadCustomThread.getThread().start();
|
plcSsjReadCustomThread.getThread().start();
|
||||||
plcSrgvReadCustomThread1.getThread().start();
|
plcSrgvReadCustomThread1.getThread().start();
|
||||||
// plcSrgvReadCustomThread2.getThread().start();
|
plcSrgvReadCustomThread2.getThread().start();
|
||||||
plcTsjReadCustomThread.getThread().start();
|
plcTsjReadCustomThread.getThread().start();
|
||||||
monitoringCustomThread.getThread().start();
|
monitoringCustomThread.getThread().start();
|
||||||
//充电桩读取线程
|
//充电桩读取线程
|
||||||
// plcCdzjReadCustomThread.getThread().start();
|
plcCdzjReadCustomThread.getThread().start();
|
||||||
isRun = true;
|
isRun = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 开启线程2
|
* 开启线程2 调度
|
||||||
*/
|
*/
|
||||||
public void startAllThread2() {
|
public void startAllThread2() {
|
||||||
ssjThreadCustomThread.thread.start();
|
ssjThreadCustomThread.thread.start();
|
||||||
tsjThreadCustomThread.thread.start();
|
tsjThreadCustomThread.thread.start();
|
||||||
sRgvThreadCustomThread.thread.start();
|
sRgvThreadCustomThread.thread.start();
|
||||||
// cdzThreadCustomThread.thread.start();
|
cdzThreadCustomThread.thread.start();
|
||||||
isRun2 = true;
|
isRun2 = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 停止线程
|
* 停止线程读取
|
||||||
*/
|
*/
|
||||||
public void stopAllThread() {
|
public void stopAllThread() {
|
||||||
plcSsjReadCustomThread.runnable.isRun = false;
|
plcSsjReadCustomThread.runnable.isRun = false;
|
||||||
// plcDdj1ReadCustomThread.runnable.isRun = false;
|
plcSrgvReadCustomThread1.runnable.isRun = false;
|
||||||
/* plcDdj2ReadCustomThread.runnable.isRun = false;
|
plcSrgvReadCustomThread2.runnable.isRun = false;
|
||||||
plcDdj3ReadCustomThread.runnable.isRun = false;
|
plcTsjReadCustomThread.runnable.isRun = false;
|
||||||
plcDdj4ReadCustomThread.runnable.isRun = false;
|
monitoringCustomThread.runnable.isRun = false;
|
||||||
plcDdj5ReadCustomThread.runnable.isRun = false;
|
|
||||||
plcDdj6ReadCustomThread.runnable.isRun = false;*/
|
|
||||||
plcReadInit();
|
plcReadInit();
|
||||||
isRun = false;
|
isRun = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 停止线程2
|
* 停止线程调度
|
||||||
*/
|
*/
|
||||||
public void stopAllThread2() {
|
public void stopAllThread2() {
|
||||||
monitoringCustomThread.runnable.isRun = false;
|
ssjThreadCustomThread.runnable.isRun = false;
|
||||||
// ddj1CustomThread.runnable.isRun = false;
|
tsjThreadCustomThread.runnable.isRun = false;
|
||||||
/*ddj2CustomThread.runnable.isRun = false;
|
sRgvThreadCustomThread.runnable.isRun = false;
|
||||||
ddj3CustomThread.runnable.isRun = false;
|
|
||||||
ddj4CustomThread.runnable.isRun = false;
|
|
||||||
ddj5CustomThread.runnable.isRun = false;
|
|
||||||
ddj6CustomThread.runnable.isRun = false;*/
|
|
||||||
scheduleInit();
|
scheduleInit();
|
||||||
isRun2 = false;
|
isRun2 = false;
|
||||||
}
|
}
|
||||||
@@ -220,11 +244,91 @@ public class ScheduleThread {
|
|||||||
/**
|
/**
|
||||||
* 获取调度状态
|
* 获取调度状态
|
||||||
*/
|
*/
|
||||||
public HashMap<String,Boolean> getScheduleStatus() {
|
public HashMap<String, Boolean> getScheduleStatus() {
|
||||||
HashMap<String,Boolean> map = new HashMap<>();
|
HashMap<String, Boolean> map = new HashMap<>();
|
||||||
map.put("isRun",isRun);
|
map.put("isRun", isRun);
|
||||||
map.put("isRun2",isRun2);
|
map.put("isRun2", isRun2);
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取所有受管线程状态
|
||||||
|
*/
|
||||||
|
public List<Map<String, Object>> getAllThreadStatus() {
|
||||||
|
List<Map<String, Object>> list = new ArrayList<>();
|
||||||
|
for (String key : threadDescMap.keySet()) {
|
||||||
|
CustomThread<?> ct = threadMap.get(key);
|
||||||
|
Map<String, Object> info = new HashMap<>();
|
||||||
|
info.put("key", key);
|
||||||
|
info.put("name", threadDescMap.get(key));
|
||||||
|
info.put("type", threadTypeMap.get(key));
|
||||||
|
boolean alive = false;
|
||||||
|
boolean isRun = false;
|
||||||
|
if (ct != null && ct.getRunnable() != null) {
|
||||||
|
try {
|
||||||
|
Field field = ct.getRunnable().getClass().getField("isRun");
|
||||||
|
isRun = field.getBoolean(ct.getRunnable());
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("获取线程[{}]isRun状态异常", key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
info.put("isRun", isRun);
|
||||||
|
if (ct != null && ct.getThread() != null) {
|
||||||
|
alive = ct.getThread().isAlive();
|
||||||
|
}
|
||||||
|
info.put("alive", alive);
|
||||||
|
list.add(info);
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 启动指定线程
|
||||||
|
*/
|
||||||
|
public synchronized void startThread(String key) {
|
||||||
|
CustomThread<?> ct = threadMap.get(key);
|
||||||
|
if (ct == null) {
|
||||||
|
throw new RuntimeException("未知线程: " + key);
|
||||||
|
}
|
||||||
|
if (ct.getThread() != null && ct.getThread().isAlive()) {
|
||||||
|
log.info("线程 {} 已经在运行中", key);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 设置Runnable isRun = true
|
||||||
|
setRunnableIsRun(ct.getRunnable(), true);
|
||||||
|
|
||||||
|
// 创建新线程
|
||||||
|
Thread newThread = new Thread((Runnable) ct.getRunnable(), key);
|
||||||
|
ct.setThread(newThread);
|
||||||
|
newThread.start();
|
||||||
|
log.info("线程 {} 已启动", key);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 停止指定线程
|
||||||
|
*/
|
||||||
|
public synchronized void stopThread(String key) {
|
||||||
|
CustomThread<?> ct = threadMap.get(key);
|
||||||
|
if (ct == null) {
|
||||||
|
throw new RuntimeException("未知线程: " + key);
|
||||||
|
}
|
||||||
|
// 设置Runnable isRun = false
|
||||||
|
setRunnableIsRun(ct.getRunnable(), false);
|
||||||
|
log.info("线程 {} 停止指令已下发", key);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setRunnableIsRun(Object runnable, boolean isRun) {
|
||||||
|
try {
|
||||||
|
Field field = runnable.getClass().getField("isRun"); // 使用getField获取public字段
|
||||||
|
field.setBoolean(runnable, isRun);
|
||||||
|
} catch (NoSuchFieldException e) {
|
||||||
|
// 尝试查找父类或非public字段? 目前都是public
|
||||||
|
log.error("无法找到isRun字段: {}", runnable.getClass().getName());
|
||||||
|
} catch (IllegalAccessException e) {
|
||||||
|
log.error("无法访问isRun字段: {}", runnable.getClass().getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ public class BaseSRgvThread implements Runnable, SRgvThreadInterface {
|
|||||||
for (String code : sRgvCodeList.get("srgv")) {
|
for (String code : sRgvCodeList.get("srgv")) {
|
||||||
if (PlcSrgvRead.deviceSrgvMap.containsKey(code)) {
|
if (PlcSrgvRead.deviceSrgvMap.containsKey(code)) {
|
||||||
if (ObjUtil.isNotNull(PlcSrgvRead.deviceSrgvMap.get(code))) {
|
if (ObjUtil.isNotNull(PlcSrgvRead.deviceSrgvMap.get(code))) {
|
||||||
|
log.info("小车处理开始");
|
||||||
DeviceSrgv deviceSrgv = PlcSrgvRead.deviceSrgvMap.get(code);
|
DeviceSrgv deviceSrgv = PlcSrgvRead.deviceSrgvMap.get(code);
|
||||||
|
|
||||||
sRgvTask(deviceSrgv);
|
sRgvTask(deviceSrgv);
|
||||||
@@ -109,6 +109,7 @@ public class BaseSRgvThread implements Runnable, SRgvThreadInterface {
|
|||||||
inCharging(deviceSrgv);
|
inCharging(deviceSrgv);
|
||||||
|
|
||||||
outCharging(deviceSrgv);
|
outCharging(deviceSrgv);
|
||||||
|
log.info("小车处理结束");
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
log.error("小车设备为空");
|
log.error("小车设备为空");
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ spring:
|
|||||||
devtools:
|
devtools:
|
||||||
restart:
|
restart:
|
||||||
# 热部署开关
|
# 热部署开关
|
||||||
enabled: true
|
enabled: false
|
||||||
# redis 配置
|
# redis 配置
|
||||||
redis:
|
redis:
|
||||||
# 地址
|
# 地址
|
||||||
|
|||||||
@@ -7,18 +7,6 @@
|
|||||||
|
|
||||||
<div class="right-menu">
|
<div class="right-menu">
|
||||||
<template v-if="device!=='mobile'">
|
<template v-if="device!=='mobile'">
|
||||||
<el-tooltip :content="$t('top.read')" effect="dark" placement="bottom">
|
|
||||||
<el-button class="right-menu-item hover-effect" :type="plcReadStatus ? 'success' : 'info'" size="mini" @click="togglePlcRead">
|
|
||||||
{{ plcReadStatus ? $t('top.stopRead') : $t('top.startRead') }}
|
|
||||||
</el-button>
|
|
||||||
</el-tooltip>
|
|
||||||
|
|
||||||
<el-tooltip :content="$t('top.task')" effect="dark" placement="bottom">
|
|
||||||
<el-button class="right-menu-item hover-effect" :type="plcScheduleStatus ? 'success' : 'info'" size="mini" @click="togglePlcSchedule">
|
|
||||||
{{ plcScheduleStatus ? $t('top.stopTask') : $t('top.startTask') }}
|
|
||||||
</el-button>
|
|
||||||
</el-tooltip>
|
|
||||||
|
|
||||||
|
|
||||||
<search id="header-search" class="right-menu-item" />
|
<search id="header-search" class="right-menu-item" />
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="app-container">
|
<div class="app-container">
|
||||||
<!-- 统计卡片 -->
|
<!-- 统计卡片 -->
|
||||||
<el-row :gutter="20" class="stats-row">
|
<el-row :gutter="40" class="stats-row">
|
||||||
|
|
||||||
<el-col :span="4">
|
<el-col :span="8">
|
||||||
<el-card class="stats-card">
|
<el-card class="stats-card">
|
||||||
<div class="stats-content">
|
<div class="stats-content">
|
||||||
<div class="stats-icon ddj-icon">
|
<div class="stats-icon ddj-icon">
|
||||||
@@ -16,7 +16,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</el-card>
|
</el-card>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="4">
|
<el-col :span="8">
|
||||||
<el-card class="stats-card">
|
<el-card class="stats-card">
|
||||||
<div class="stats-content">
|
<div class="stats-content">
|
||||||
<div class="stats-icon ctu-icon">
|
<div class="stats-icon ctu-icon">
|
||||||
@@ -29,7 +29,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</el-card>
|
</el-card>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="4">
|
<el-col :span="8">
|
||||||
<el-card class="stats-card">
|
<el-card class="stats-card">
|
||||||
<div class="stats-content">
|
<div class="stats-content">
|
||||||
<div class="stats-icon tsj-icon">
|
<div class="stats-icon tsj-icon">
|
||||||
@@ -42,7 +42,9 @@
|
|||||||
</div>
|
</div>
|
||||||
</el-card>
|
</el-card>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="4">
|
</el-row>
|
||||||
|
<el-row :gutter="40" class="stats-row">
|
||||||
|
<el-col :span="8">
|
||||||
<el-card class="stats-card">
|
<el-card class="stats-card">
|
||||||
<div class="stats-content">
|
<div class="stats-content">
|
||||||
<div class="stats-icon queue-icon">
|
<div class="stats-icon queue-icon">
|
||||||
@@ -55,7 +57,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</el-card>
|
</el-card>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="4">
|
<el-col :span="8">
|
||||||
<el-card class="stats-card">
|
<el-card class="stats-card">
|
||||||
<div class="stats-content">
|
<div class="stats-content">
|
||||||
<div class="stats-icon running-icon">
|
<div class="stats-icon running-icon">
|
||||||
@@ -68,7 +70,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</el-card>
|
</el-card>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="4">
|
<el-col :span="8">
|
||||||
<el-card class="stats-card">
|
<el-card class="stats-card">
|
||||||
<div class="stats-content">
|
<div class="stats-content">
|
||||||
<div class="stats-icon finish-icon">
|
<div class="stats-icon finish-icon">
|
||||||
@@ -379,9 +381,7 @@ export default {
|
|||||||
} else {
|
} else {
|
||||||
// 默认数据
|
// 默认数据
|
||||||
chartData = [
|
chartData = [
|
||||||
{ value: 45, name: this.$t('index.inboundTask') }, // 入库任务
|
|
||||||
{ value: 35, name: this.$t('index.outboundTask') }, // 出库任务
|
|
||||||
{ value: 20, name: this.$t('index.transferTask') } // 移库任务
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user