From 03bdf8738729b6055b0c5594628b261a3ebaaced Mon Sep 17 00:00:00 2001
From: aijinhui <aijinhui>
Date: 星期四, 21 九月 2023 16:50:20 +0800
Subject: [PATCH] 设备健康
---
ard-work/src/main/java/com/ruoyi/alarm/global/service/impl/QueueManager.java | 20 +++++++++++++-------
1 files changed, 13 insertions(+), 7 deletions(-)
diff --git a/ard-work/src/main/java/com/ruoyi/alarm/global/service/impl/QueueManager.java b/ard-work/src/main/java/com/ruoyi/alarm/global/service/impl/QueueManager.java
index 21c8772..0497e66 100644
--- a/ard-work/src/main/java/com/ruoyi/alarm/global/service/impl/QueueManager.java
+++ b/ard-work/src/main/java/com/ruoyi/alarm/global/service/impl/QueueManager.java
@@ -58,21 +58,27 @@
public void addTaskToQueue(String cameraId, GuideTask task) {
/*閫氳繃鐩告満ID鑾峰彇寮曞闃熷垪锛屽苟灏嗗紩瀵间换鍔″姞鍏ラ槦鍒�*/
PriorityBlockingQueue<GuideTask> guideTaskQueue = GuidePriorityQueue.cameraQueueMap.get(cameraId);
- if(StringUtils.isNull(guideTaskQueue))
- {
+ if (StringUtils.isNull(guideTaskQueue)) {
log.info("鐩告満鏈櫥褰�,娌℃湁闃熷垪,鏃犳硶鍏ラ槦寮曞");
return;
}
- log.debug("鏂颁换鍔″叆闃�:"+task.getAlarmId());
+ log.debug("鏂颁换鍔″叆闃�:" + task.getAlarmId());
guideTaskQueue.add(task);
/*鑾峰彇璇ョ浉鏈虹殑褰撳墠鎵ц绾跨▼*/
TaskThread currentTaskThread = threadMap.get(cameraId);
//濡傛灉闃熷垪褰撳墠绾跨▼姝e湪杩愯锛岃嫢鍏ラ槦浠诲姟浼樺厛绾уぇ浜庡綋鍓嶄换鍔′紭鍏堢骇锛屽垯缁堟褰撳墠绾跨▼
- if (currentTaskThread != null && task.getPriority() > currentTaskThread.getCurrentTask().getPriority()) {
- currentTaskThread.getThread().interrupt();
+ if (currentTaskThread != null){
+ if (task.getPriority() > currentTaskThread.getCurrentTask().getPriority()) {
+ currentTaskThread.getThread().interrupt();
+ }
+ if (!currentTaskThread.getThread().isAlive()) {
+ Thread newThread = createThread(cameraId, guideTaskQueue);
+ threadMap.put(cameraId, new TaskThread(newThread, task));
+ newThread.start();
+ }
}
//濡傛灉闃熷垪褰撳墠娌℃湁绾跨▼姝e湪杩愯锛屽垯鍚姩鏂扮嚎绋�
- if (currentTaskThread == null || !currentTaskThread.getThread().isAlive()) {
+ else {
Thread newThread = createThread(cameraId, guideTaskQueue);
threadMap.put(cameraId, new TaskThread(newThread, task));
newThread.start();
@@ -90,7 +96,7 @@
while (!Thread.currentThread().isInterrupted()) {
try {
GuideTask task = queue.take();
- log.debug("鍙栧嚭闃熷垪鏁版嵁:"+task.getAlarmId());
+ log.debug("鍙栧嚭闃熷垪鏁版嵁:" + task.getAlarmId());
taskExecutor.processTask(task);
// 鏇存柊绾跨▼鐨勫綋鍓嶄换鍔�
TaskThread currentTaskThread = threadMap.get(queueName);
--
Gitblit v1.9.3