From f5fa6fa5e5d14fb3d8703434b30648be76b6e7e6 Mon Sep 17 00:00:00 2001
From: ‘liusuyi’ <1951119284@qq.com>
Date: 星期二, 12 十二月 2023 17:08:47 +0800
Subject: [PATCH] 重构引导队列逻辑
---
ard-work/src/main/java/com/ruoyi/alarm/global/service/impl/QueueTaskExecutor.java | 6
ard-work/src/main/java/com/ruoyi/utils/sdk/hiksdk/service/impl/HikvisionSDK.java | 16 +
ard-work/src/main/java/com/ruoyi/alarm/global/service/impl/GlobalAlarmServiceImpl.java | 4
ard-work/src/main/java/com/ruoyi/alarm/global/service/impl/QueueHandler.java | 216 ++++++++++++++++++++++++++++++
ard-work/src/main/java/com/ruoyi/alarm/global/service/impl/QueueManager.java | 134 +++++++++---------
ard-work/src/main/java/com/ruoyi/utils/sdk/dhsdk/service/impl/DahuaSDK.java | 34 +++-
6 files changed, 323 insertions(+), 87 deletions(-)
diff --git a/ard-work/src/main/java/com/ruoyi/alarm/global/service/impl/GlobalAlarmServiceImpl.java b/ard-work/src/main/java/com/ruoyi/alarm/global/service/impl/GlobalAlarmServiceImpl.java
index 588c3f5..28d68cd 100644
--- a/ard-work/src/main/java/com/ruoyi/alarm/global/service/impl/GlobalAlarmServiceImpl.java
+++ b/ard-work/src/main/java/com/ruoyi/alarm/global/service/impl/GlobalAlarmServiceImpl.java
@@ -110,7 +110,7 @@
@Resource
private RedisCache redisCache;
@Resource
- private QueueManager queueManager;
+ private QueueHandler queueHandler;
@Resource
private ArdEquipRadarMapper ardEquipRadarMapper;
//endregion
@@ -1427,7 +1427,7 @@
guideTask.setGuidePTZ(guideDataDto.getGuidePTZ());
}
//娑堟伅鍏ラ槦
- queueManager.addTaskToQueue(cameraId, guideTask);
+ queueHandler.addTaskToQueue(cameraId, guideTask);
//鎵撳嵃闃熷垪
GuidePriorityQueue.printPriorityQueue();
} catch (Exception ex) {
diff --git a/ard-work/src/main/java/com/ruoyi/alarm/global/service/impl/QueueHandler.java b/ard-work/src/main/java/com/ruoyi/alarm/global/service/impl/QueueHandler.java
new file mode 100644
index 0000000..b883dc7
--- /dev/null
+++ b/ard-work/src/main/java/com/ruoyi/alarm/global/service/impl/QueueHandler.java
@@ -0,0 +1,216 @@
+package com.ruoyi.alarm.global.service.impl;
+
+import com.ruoyi.alarm.access.domain.ArdAlarmAccess;
+import com.ruoyi.alarm.access.service.IArdAlarmAccessService;
+import com.ruoyi.alarm.external.domain.ArdAlarmExternal;
+import com.ruoyi.alarm.external.service.IArdAlarmExternalService;
+import com.ruoyi.alarm.global.domain.GuidePriorityQueue;
+import com.ruoyi.alarm.global.domain.GuideTask;
+import com.ruoyi.alarm.radar.domain.ArdAlarmRadarFire;
+import com.ruoyi.alarm.radar.domain.ArdAlarmRadarMove;
+import com.ruoyi.alarm.radar.domain.ArdAlarmRadarPump;
+import com.ruoyi.alarm.radar.service.IArdAlarmRadarFireService;
+import com.ruoyi.alarm.radar.service.IArdAlarmRadarMoveService;
+import com.ruoyi.alarm.radar.service.IArdAlarmRadarPumpService;
+import com.ruoyi.alarm.tube.domain.ArdAlarmTube;
+import com.ruoyi.alarm.tube.service.IArdAlarmTubeService;
+import com.ruoyi.common.utils.StringUtils;
+import com.ruoyi.common.utils.spring.SpringUtils;
+import com.ruoyi.device.camera.domain.CameraCmd;
+import com.ruoyi.device.camera.service.ICameraSdkService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.scheduling.annotation.Async;
+import org.springframework.stereotype.Component;
+
+import java.time.Duration;
+import java.time.Instant;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.*;
+
+/**
+ * @Description: 闃熷垪澶勭悊鍣�
+ * @ClassName: QueueHandler
+ * @Author: 鍒樿嫃涔�
+ * @Date: 2023骞�12鏈�12鏃�13:40:13
+ **/
+@Slf4j(topic = "guideQueue")
+@Component
+public class QueueHandler {
+ /**
+ * 寮曞浠诲姟鍏ラ槦
+ * 鍒樿嫃涔�
+ * 2023/6/30 8:57
+ */
+ public void addTaskToQueue(String cameraId, GuideTask task) {
+ /*閫氳繃鐩告満ID鑾峰彇寮曞闃熷垪锛屽苟灏嗗紩瀵间换鍔″姞鍏ラ槦鍒�*/
+ PriorityBlockingQueue<GuideTask> guideTaskQueue = GuidePriorityQueue.cameraQueueMap.get(cameraId);
+ if (StringUtils.isNull(guideTaskQueue)) {
+ log.info("鐩告満鏈櫥褰�,娌℃湁闃熷垪,鏃犳硶鍏ラ槦寮曞");
+ return;
+ }
+ log.debug("鏂颁换鍔″叆闃�:" + task.getAlarmId());
+ guideTaskQueue.add(task);
+ /*鑾峰彇璇ョ浉鏈虹殑褰撳墠鎵ц绾跨▼-----寮冪敤*/
+ //TaskThread currentTaskThread = threadMap.get(cameraId);
+ ////濡傛灉闃熷垪褰撳墠绾跨▼姝e湪杩愯锛岃嫢鍏ラ槦浠诲姟浼樺厛绾уぇ浜庡綋鍓嶄换鍔′紭鍏堢骇锛屽垯缁堟褰撳墠绾跨▼
+ //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湪杩愯锛屽垯鍚姩鏂扮嚎绋�
+ //else {
+ // Thread newThread = createThread(cameraId, guideTaskQueue);
+ // threadMap.put(cameraId, new TaskThread(newThread, task));
+ // newThread.start();
+ //}
+ }
+ @Async
+ public void process(String cameraId) {
+ log.debug("CameraId:銆�" + cameraId + "銆戦槦鍒楀鐞嗗櫒鍚姩");
+ PriorityBlockingQueue<GuideTask> guideTasks = GuidePriorityQueue.cameraQueueMap.get(cameraId);
+ while (true) {
+ if (guideTasks.size() > 0) {
+ //鍙栧嚭闃熷垪涓殑寮曞浠诲姟
+ GuideTask newTask = null;
+ try {
+ newTask = guideTasks.take();
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ log.debug("鎵ц鏂颁换鍔�:銆�" + newTask.getAlarmId() + "銆�");
+ log.debug("鍓╀綑浠诲姟鏁�:銆�" + guideTasks.size() + "銆�");
+ // 寮傛澶勭悊浠诲姟锛屽苟鑾峰彇Future
+ processTask(newTask);
+ }
+ try {
+ Thread.sleep(100);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ public void processTask(GuideTask guideTask) {
+ try {
+ String url="";
+ CameraCmd cmd = new CameraCmd();
+ cmd.setCameraId(guideTask.getCameraId());
+ cmd.setChanNo(guideTask.getChanNum());
+ cmd.setTargetPosition(guideTask.getTargetPosition());
+ cmd.setOperator(guideTask.getAlarmType());
+ cmd.setExpired(30);
+ cmd.setRecordBucketName("record");
+ Map<String, Double> ptzMap = new HashMap<>();
+ ptzMap.put("p", guideTask.getGuidePTZ().getP());
+ ptzMap.put("t", guideTask.getGuidePTZ().getT());
+ ptzMap.put("z", guideTask.getGuidePTZ().getZ());
+ cmd.setPtzMap(ptzMap);
+ if (guideTask.getRecordSn().equals(1)) {
+ cmd.setRecordObjectName("alarm_" + guideTask.getAlarmId() + "_1");
+ } else {
+ cmd.setRecordObjectName("alarm_" + guideTask.getAlarmId() + "_2");
+ }
+ ICameraSdkService cameraSdkService = SpringUtils.getBean(ICameraSdkService.class);
+ log.debug("寮�濮嬪紩瀵�");
+ boolean guideRes = false;
+ boolean recordFlag = false;
+ if (cmd.getPtzMap().get("p") != null) {
+ //p鍊煎瓨鍦� 浼樺厛寮曞ptz
+ guideRes = cameraSdkService.setPtz(cmd);
+ } else {
+ guideRes = cameraSdkService.guideTargetPosition(cmd);
+ }
+ if (guideRes) {
+ log.debug("寮曞鎴愬姛");
+ cameraSdkService.controlLock(cmd);//涓婇攣
+ cameraSdkService.recordStart(cmd);//寮�濮嬪綍鍍�
+ recordFlag = true;
+ Instant startTime = Instant.now();
+ while (recordFlag) {
+ //鍒ゆ柇鏃堕棿
+ Instant currentTime = Instant.now();
+ long elapsedSeconds = Duration.between(startTime, currentTime).getSeconds();
+ if (elapsedSeconds >= 30) {
+ recordFlag = false;
+ url = cameraSdkService.recordStopToMinio(cmd);//鍋滄褰曞儚杩斿洖url
+ }
+ //鍒ゆ柇闃熷垪涓涓�鏉℃暟鎹殑浼樺厛绾ф槸鍚﹀ぇ浜庡綋鍓嶆暟鎹殑浼樺厛绾�
+ PriorityBlockingQueue<GuideTask> guideTasks = GuidePriorityQueue.cameraQueueMap.get(guideTask.getCameraId());
+ if (guideTasks.size() > 0) {
+ GuideTask firstTask = guideTasks.peek();
+ if (firstTask.getPriority() > guideTask.getPriority()) {
+ recordFlag = false;//褰曞儚鍋滄
+ break;
+ }
+ }
+ }
+ if (StringUtils.isNotEmpty(url)) {
+ switch (guideTask.getAlarmType()) {
+ case "sys_tube_leak":
+ ArdAlarmTube ardAlarmTube = new ArdAlarmTube();
+ ardAlarmTube.setId(guideTask.getAlarmId());
+ ardAlarmTube.setRecordUrl(url);
+ IArdAlarmTubeService ardAlarmTubeService = SpringUtils.getBean(IArdAlarmTubeService.class);
+ ardAlarmTubeService.updateArdAlarmTube(ardAlarmTube);
+ break;
+ case "sys_radar_move":
+ ArdAlarmRadarMove ardAlarmRadarMove = new ArdAlarmRadarMove();
+ ardAlarmRadarMove.setId(guideTask.getAlarmId());
+ if (guideTask.getRecordSn().equals(1)) {
+ ardAlarmRadarMove.setRecordUrl1(url);
+ } else {
+ ardAlarmRadarMove.setRecordUrl2(url);
+ }
+ IArdAlarmRadarMoveService ardAlarmRadarMoveService = SpringUtils.getBean(IArdAlarmRadarMoveService.class);
+ ardAlarmRadarMoveService.updateArdAlarmRadarMove(ardAlarmRadarMove);
+ break;
+ case "sys_radar_fire":
+ ArdAlarmRadarFire ardAlarmRadarFire = new ArdAlarmRadarFire();
+ ardAlarmRadarFire.setId(guideTask.getAlarmId());
+ if (guideTask.getRecordSn().equals(1)) {
+ ardAlarmRadarFire.setRecordUrl1(url);
+ } else {
+ ardAlarmRadarFire.setRecordUrl2(url);
+ }
+ IArdAlarmRadarFireService ardAlarmRadarFireService = SpringUtils.getBean(IArdAlarmRadarFireService.class);
+ ardAlarmRadarFireService.updateArdAlarmRadarFire(ardAlarmRadarFire);
+ break;
+ case "sys_radar_pump":
+ ArdAlarmRadarPump ardAlarmRadarPump = new ArdAlarmRadarPump();
+ ardAlarmRadarPump.setId(guideTask.getAlarmId());
+ if (guideTask.getRecordSn().equals(1)) {
+ ardAlarmRadarPump.setRecordUrl1(url);
+ } else {
+ ardAlarmRadarPump.setRecordUrl2(url);
+ }
+ IArdAlarmRadarPumpService ardAlarmRadarPumpService = SpringUtils.getBean(IArdAlarmRadarPumpService.class);
+ ardAlarmRadarPumpService.updateArdAlarmRadarPump(ardAlarmRadarPump);
+ break;
+ case "sys_external":
+ ArdAlarmExternal ardAlarmExternal = new ArdAlarmExternal();
+ ardAlarmExternal.setId(guideTask.getAlarmId());
+ ardAlarmExternal.setRecordUrl(url);
+ IArdAlarmExternalService ardAlarmExternalService = SpringUtils.getBean(IArdAlarmExternalService.class);
+ ardAlarmExternalService.updateArdAlarmExternal(ardAlarmExternal);
+ break;
+ case "sys_access_control":
+ ArdAlarmAccess ardAlarmAccess = new ArdAlarmAccess();
+ ardAlarmAccess.setId(guideTask.getAlarmId());
+ ardAlarmAccess.setRecordUrl(url);
+ IArdAlarmAccessService ardAlarmAccessService = SpringUtils.getBean(IArdAlarmAccessService.class);
+ ardAlarmAccessService.updateArdAlarmAccess(ardAlarmAccess);
+ break;
+ }
+ }
+ }
+ } catch (Exception ex) {
+ log.info("绾跨▼浠诲姟寮傚父:" + ex.getMessage());
+ }
+ }
+}
\ No newline at end of file
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 0497e66..9d53cc8 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
@@ -13,7 +13,7 @@
/**
* @ClassName QueueManager
- * @Description: 闃熷垪绠$悊
+ * @Description: 闃熷垪绠$悊-----寮冪敤
* @Author 鍒樿嫃涔�
* @Date 2023/6/29 21:09
* @Version 1.0
@@ -23,32 +23,32 @@
@Slf4j(topic = "guideQueue")
public class QueueManager {
- @Autowired
- private QueueTaskExecutor taskExecutor;
- private Map<String, TaskThread> threadMap = new ConcurrentHashMap<>();
+ // @Autowired
+ // private QueueTaskExecutor taskExecutor;-----寮冪敤
+ // private Map<String, TaskThread> threadMap = new ConcurrentHashMap<>();
- /*鍐呴儴闈欐�佺被*/
- private static class TaskThread {
- private Thread thread;
- private GuideTask currentTask;
-
- public TaskThread(Thread thread, GuideTask currentTask) {
- this.thread = thread;
- this.currentTask = currentTask;
- }
-
- public Thread getThread() {
- return thread;
- }
-
- public GuideTask getCurrentTask() {
- return currentTask;
- }
-
- public void setCurrentTask(GuideTask task) {
- this.currentTask = task;
- }
- }
+ ///*鍐呴儴闈欐�佺被*/
+ //private static class TaskThread {
+ // private Thread thread;
+ // private GuideTask currentTask;
+ //
+ // public TaskThread(Thread thread, GuideTask currentTask) {
+ // this.thread = thread;
+ // this.currentTask = currentTask;
+ // }
+ //
+ // public Thread getThread() {
+ // return thread;
+ // }
+ //
+ // public GuideTask getCurrentTask() {
+ // return currentTask;
+ // }
+ //
+ // public void setCurrentTask(GuideTask task) {
+ // this.currentTask = task;
+ // }
+ //}
/**
* 寮曞浠诲姟鍏ラ槦
@@ -64,51 +64,51 @@
}
log.debug("鏂颁换鍔″叆闃�:" + task.getAlarmId());
guideTaskQueue.add(task);
- /*鑾峰彇璇ョ浉鏈虹殑褰撳墠鎵ц绾跨▼*/
- TaskThread currentTaskThread = threadMap.get(cameraId);
- //濡傛灉闃熷垪褰撳墠绾跨▼姝e湪杩愯锛岃嫢鍏ラ槦浠诲姟浼樺厛绾уぇ浜庡綋鍓嶄换鍔′紭鍏堢骇锛屽垯缁堟褰撳墠绾跨▼
- 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湪杩愯锛屽垯鍚姩鏂扮嚎绋�
- else {
- Thread newThread = createThread(cameraId, guideTaskQueue);
- threadMap.put(cameraId, new TaskThread(newThread, task));
- newThread.start();
- }
+ /*鑾峰彇璇ョ浉鏈虹殑褰撳墠鎵ц绾跨▼-----寮冪敤*/
+ //TaskThread currentTaskThread = threadMap.get(cameraId);
+ ////濡傛灉闃熷垪褰撳墠绾跨▼姝e湪杩愯锛岃嫢鍏ラ槦浠诲姟浼樺厛绾уぇ浜庡綋鍓嶄换鍔′紭鍏堢骇锛屽垯缁堟褰撳墠绾跨▼
+ //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湪杩愯锛屽垯鍚姩鏂扮嚎绋�
+ //else {
+ // Thread newThread = createThread(cameraId, guideTaskQueue);
+ // threadMap.put(cameraId, new TaskThread(newThread, task));
+ // newThread.start();
+ //}
}
/**
- * 鍒涘缓绾跨▼
+ * 鍒涘缓绾跨▼ -----寮冪敤
* 鍒樿嫃涔�
* 2023/6/30 9:04
*/
- private Thread createThread(String queueName, PriorityBlockingQueue<GuideTask> queue) {
-
- return new Thread(() -> {
- while (!Thread.currentThread().isInterrupted()) {
- try {
- GuideTask task = queue.take();
- log.debug("鍙栧嚭闃熷垪鏁版嵁:" + task.getAlarmId());
- taskExecutor.processTask(task);
- // 鏇存柊绾跨▼鐨勫綋鍓嶄换鍔�
- TaskThread currentTaskThread = threadMap.get(queueName);
- if (currentTaskThread != null) {
- currentTaskThread.setCurrentTask(task);
- }
- } catch (InterruptedException e) {
- log.info("涓柇褰撳墠绾跨▼");
- //绾跨▼涓柇锛岄��鍑哄惊鐜�
- Thread.currentThread().interrupt();
- }
- }
- }, queueName);
- }
+ //private Thread createThread(String queueName, PriorityBlockingQueue<GuideTask> queue) {
+ //
+ // return new Thread(() -> {
+ // while (!Thread.currentThread().isInterrupted()) {
+ // try {
+ // GuideTask task = queue.take();
+ // log.debug("鍙栧嚭闃熷垪鏁版嵁:" + task.getAlarmId());
+ // taskExecutor.processTask(task);
+ // // 鏇存柊绾跨▼鐨勫綋鍓嶄换鍔�
+ // TaskThread currentTaskThread = threadMap.get(queueName);
+ // if (currentTaskThread != null) {
+ // currentTaskThread.setCurrentTask(task);
+ // }
+ // } catch (InterruptedException e) {
+ // log.info("涓柇褰撳墠绾跨▼");
+ // //绾跨▼涓柇锛岄��鍑哄惊鐜�
+ // Thread.currentThread().interrupt();
+ // }
+ // }
+ // }, queueName);
+ //}
}
diff --git a/ard-work/src/main/java/com/ruoyi/alarm/global/service/impl/QueueTaskExecutor.java b/ard-work/src/main/java/com/ruoyi/alarm/global/service/impl/QueueTaskExecutor.java
index 9b45bf5..ff9980c 100644
--- a/ard-work/src/main/java/com/ruoyi/alarm/global/service/impl/QueueTaskExecutor.java
+++ b/ard-work/src/main/java/com/ruoyi/alarm/global/service/impl/QueueTaskExecutor.java
@@ -25,13 +25,12 @@
/**
* @ClassName QueueTaskExecutor
- * @Description: 闃熷垪浠诲姟鎵ц鍣�
+ * @Description: 闃熷垪浠诲姟鎵ц鍣�-----寮冪敤
* @Author 鍒樿嫃涔�
* @Date 2023/6/29 21:10
* @Version 1.0
*/
-@Component
@Slf4j(topic = "guideQueue")
public class QueueTaskExecutor {
@Resource
@@ -44,7 +43,6 @@
ICameraSdkService cameraSdkService;
@Resource
IArdAlarmTubeService ardAlarmTubeService;
-
@Resource
IArdAlarmExternalService ardAlarmExternalService;
@Resource
@@ -145,4 +143,4 @@
log.info("绾跨▼浠诲姟寮傚父:" + ex.getMessage());
}
}
-}
+}
\ No newline at end of file
diff --git a/ard-work/src/main/java/com/ruoyi/utils/sdk/dhsdk/service/impl/DahuaSDK.java b/ard-work/src/main/java/com/ruoyi/utils/sdk/dhsdk/service/impl/DahuaSDK.java
index a2e632f..306fb1c 100644
--- a/ard-work/src/main/java/com/ruoyi/utils/sdk/dhsdk/service/impl/DahuaSDK.java
+++ b/ard-work/src/main/java/com/ruoyi/utils/sdk/dhsdk/service/impl/DahuaSDK.java
@@ -2,8 +2,10 @@
import com.ruoyi.alarm.global.domain.GuidePriorityQueue;
import com.ruoyi.alarm.global.domain.GuideTask;
+import com.ruoyi.alarm.global.service.impl.QueueHandler;
import com.ruoyi.common.utils.file.FileUtils;
import com.ruoyi.common.utils.file.MimeTypeUtils;
+import com.ruoyi.common.utils.spring.SpringUtils;
import com.ruoyi.common.utils.uuid.IdUtils;
import com.ruoyi.device.camera.factory.CameraSDK;
import com.ruoyi.device.camera.domain.ArdCameras;
@@ -62,7 +64,8 @@
private IVtduService vtduService;
@Value("${minio.endpoint}")
private String minioEndPoint;
-
+ @Resource
+ private QueueHandler queueHandler;
// 璁惧鏂嚎閫氱煡鍥炶皟
private static DisConnect disConnect = new DisConnect();
@@ -74,6 +77,7 @@
* 鐧诲綍
* 鍒樿嫃涔�
* 2023/10/17 8:28:13
+ *
* @return
*/
@Override
@@ -152,17 +156,22 @@
}
//鍒涘缓寮曞闃熷垪
- if (!GuidePriorityQueue.cameraQueueMap.containsKey(camera.getId())) {
- Comparator<GuideTask> comparator = GuidePriorityQueue.getComparator();
- PriorityBlockingQueue<GuideTask> priorityQueue = new PriorityBlockingQueue<>(1000, comparator);
- GuidePriorityQueue.cameraQueueMap.put(camera.getId(), priorityQueue);
+ //鍒涘缓寮曞闃熷垪
+ if (camera.getCamAlarmGuideEnable() == 1) {
+ if (!GuidePriorityQueue.cameraQueueMap.containsKey(camera.getId())) {
+ Comparator<GuideTask> comparator = GuidePriorityQueue.getComparator();
+ PriorityBlockingQueue<GuideTask> priorityQueue = new PriorityBlockingQueue<>(1000, comparator);
+ GuidePriorityQueue.cameraQueueMap.put(camera.getId(), priorityQueue);
+ }
+ //鍚姩闃熷垪澶勭悊鍣�
+ queueHandler.process(camera.getId());
}
return true;
}
@Override
@Async("loginExecutor")
- public void asyncLogin(ArdCameras camera){
+ public void asyncLogin(ArdCameras camera) {
LoginModule.init(disConnect, haveReConnect);
NetSDKLib.NET_DEVICEINFO_Ex m_stDeviceInfo = new NetSDKLib.NET_DEVICEINFO_Ex();
NetSDKLib.LLong loginId = LoginModule.login(camera.getIp(), camera.getPort(), camera.getUsername(), camera.getPassword(), m_stDeviceInfo);
@@ -236,10 +245,14 @@
}
//鍒涘缓寮曞闃熷垪
- if (!GuidePriorityQueue.cameraQueueMap.containsKey(camera.getId())) {
- Comparator<GuideTask> comparator = GuidePriorityQueue.getComparator();
- PriorityBlockingQueue<GuideTask> priorityQueue = new PriorityBlockingQueue<>(1000, comparator);
- GuidePriorityQueue.cameraQueueMap.put(camera.getId(), priorityQueue);
+ if (camera.getCamAlarmGuideEnable() == 1) {
+ if (!GuidePriorityQueue.cameraQueueMap.containsKey(camera.getId())) {
+ Comparator<GuideTask> comparator = GuidePriorityQueue.getComparator();
+ PriorityBlockingQueue<GuideTask> priorityQueue = new PriorityBlockingQueue<>(1000, comparator);
+ GuidePriorityQueue.cameraQueueMap.put(camera.getId(), priorityQueue);
+ }
+ //鍚姩闃熷垪澶勭悊鍣�
+ queueHandler.process(camera.getId());
}
}
@@ -247,6 +260,7 @@
* 娉ㄩ攢
* 鍒樿嫃涔�
* 2023/10/17 8:28:13
+ *
* @return
*/
@Override
diff --git a/ard-work/src/main/java/com/ruoyi/utils/sdk/hiksdk/service/impl/HikvisionSDK.java b/ard-work/src/main/java/com/ruoyi/utils/sdk/hiksdk/service/impl/HikvisionSDK.java
index 8c89a46..ac1388b 100644
--- a/ard-work/src/main/java/com/ruoyi/utils/sdk/hiksdk/service/impl/HikvisionSDK.java
+++ b/ard-work/src/main/java/com/ruoyi/utils/sdk/hiksdk/service/impl/HikvisionSDK.java
@@ -2,8 +2,10 @@
import com.ruoyi.alarm.global.domain.GuidePriorityQueue;
import com.ruoyi.alarm.global.domain.GuideTask;
+import com.ruoyi.alarm.global.service.impl.QueueHandler;
import com.ruoyi.common.utils.file.FileUtils;
import com.ruoyi.common.utils.file.MimeTypeUtils;
+import com.ruoyi.common.utils.spring.SpringUtils;
import com.ruoyi.common.utils.uuid.IdUtils;
import com.ruoyi.device.camera.service.IArdCamerasService;
import com.ruoyi.device.camera.factory.CameraSDK;
@@ -52,6 +54,8 @@
private IArdChannelService ardChannelService;
@Resource
private IVtduService vtduService;
+ @Resource
+ private QueueHandler queueHandler;
public static HCNetSDK hCNetSDK = HCNetSDK.hCNetSDK;
private static HCNetSDK.FExceptionCallBack fExceptionCallBack;//寮傚父鍥炶皟
@@ -265,10 +269,14 @@
//娣诲姞鍒版祦濯掍綋
addVtdu(camera);
//鍒涘缓寮曞闃熷垪
- if (!GuidePriorityQueue.cameraQueueMap.containsKey(camera.getId())) {
- Comparator<GuideTask> comparator = GuidePriorityQueue.getComparator();
- PriorityBlockingQueue<GuideTask> priorityQueue = new PriorityBlockingQueue<>(1000, comparator);
- GuidePriorityQueue.cameraQueueMap.put(camera.getId(), priorityQueue);
+ if(camera.getCamAlarmGuideEnable()==1) {
+ if (!GuidePriorityQueue.cameraQueueMap.containsKey(camera.getId())) {
+ Comparator<GuideTask> comparator = GuidePriorityQueue.getComparator();
+ PriorityBlockingQueue<GuideTask> priorityQueue = new PriorityBlockingQueue<>(1000, comparator);
+ GuidePriorityQueue.cameraQueueMap.put(camera.getId(), priorityQueue);
+ //鍚姩闃熷垪澶勭悊鍣�
+ queueHandler.process(camera.getId());
+ }
}
} catch (Exception ex) {
log.error("娉ㄥ唽璁惧寮傚父", ex);
--
Gitblit v1.9.3