From 2988d2670cf03ef1ab074b0c6cd54301570c8ba4 Mon Sep 17 00:00:00 2001
From: ‘liusuyi’ <1951119284@qq.com>
Date: 星期四, 24 八月 2023 12:01:26 +0800
Subject: [PATCH] 修复引导过程中修改相机导致引导队列中止出队的问题 增加一键派警描述字段
---
ruoyi-common/src/main/java/com/ruoyi/common/utils/file/MimeTypeUtils.java | 2
ard-work/src/main/java/com/ruoyi/device/hiksdk/util/hikSdkUtil/LoginResultCallBack.java | 10 ++-
ruoyi-framework/src/main/java/com/ruoyi/framework/web/domain/Server.java | 1
ard-work/src/main/java/com/ruoyi/alarm/global/service/impl/GlobalAlarmServiceImpl.java | 55 ++++++++++-------
ard-work/src/main/java/com/ruoyi/test/ReadAccessDatabase.java | 3 +
ard-work/src/main/java/com/ruoyi/device/hiksdk/service/impl/HikClientServiceImpl.java | 13 +--
ard-work/src/main/resources/mapper/dispatch/ArdDispatchPoliceMapper.xml | 6 ++
ard-work/src/main/java/com/ruoyi/alarm/global/service/impl/QueueManager.java | 20 ++++--
ard-work/src/main/java/com/ruoyi/dispatch/domain/ArdDispatchPolice.java | 12 ++++
9 files changed, 81 insertions(+), 41 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 0529d64..4817868 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
@@ -49,6 +49,7 @@
import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.*;
+import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
@@ -679,7 +680,6 @@
log.info("鐩告満:" + cameraId + "鏈紑鍚姤璀﹀紩瀵煎姛鑳�");
return;
}
-
SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
GuideTask guideTask = new GuideTask();
//鐩告満ID
@@ -737,31 +737,40 @@
*/
private String getNearbyCamera(double[] targetPosition) {
String minDistanceCameraId = "";
- //鑾峰彇鎵�鏈夊ぇ鍏夌數
- List<ArdCameras> ardCamerasList = ardCamerasMapper.selectArdCamerasList(new ArdCameras("1"));
- //缁熻鎵�鏈夊ぇ鍏夌數鍙鑼冨洿鍐呬笌鎶ヨ鐐圭殑璺濈
- Map<String, Double> distanceMap = new HashMap<>();
- Map<String, Integer> guideMap = new HashMap<>();
- for (ArdCameras camera : ardCamerasList) {
- double[] camPosition = new double[]{camera.getLongitude(), camera.getLatitude()};
- double distance = GisTool.getDistance(targetPosition, camPosition);
- if (distance != 0.0 && distance <= camera.getCamMaxVisibleDistance()) {
- distanceMap.put(camera.getId(), distance);
- if (StringUtils.isNull(camera.getCamAlarmGuideEnable())) {
- camera.setCamAlarmGuideEnable(0);
+ try {
+ //鑾峰彇鎵�鏈夊ぇ鍏夌數
+ List<ArdCameras> ardCamerasList = ardCamerasMapper.selectArdCamerasList(new ArdCameras("1"));
+ //缁熻鎵�鏈夊ぇ鍏夌數鍙鑼冨洿鍐呬笌鎶ヨ鐐圭殑璺濈
+ Map<String, Double> distanceMap = new HashMap<>();
+ Map<String, Integer> guideMap = new HashMap<>();
+ for (ArdCameras camera : ardCamerasList) {
+ if (camera.getCamMaxVisibleDistance() == null) {
+ continue;
}
- guideMap.put(camera.getId(), camera.getCamAlarmGuideEnable());
+ double[] camPosition = new double[]{camera.getLongitude(), camera.getLatitude()};
+ double distance = GisTool.getDistance(targetPosition, camPosition);
+ if (distance != 0.0 && distance <= camera.getCamMaxVisibleDistance()) {
+ distanceMap.put(camera.getId(), distance);
+ if (StringUtils.isNull(camera.getCamAlarmGuideEnable())) {
+ camera.setCamAlarmGuideEnable(0);
+ }
+ guideMap.put(camera.getId(), camera.getCamAlarmGuideEnable());
+ }
+ }
+ if (distanceMap.size() > 0) {
+ log.debug("灏濊瘯鏌ユ壘鏈�杩戝厜鐢�");
+ //鑾峰彇璺濈瀛楀吀涓渶杩戠殑涓�涓浉鏈篒D
+ minDistanceCameraId = ArdTool.getKeyByMinValue(distanceMap);
+ log.debug("鏌ユ壘鍒版渶杩戝厜鐢�:" + minDistanceCameraId);
+ if (guideMap.get(minDistanceCameraId).equals(0)) {
+ log.debug("璇ュ厜鐢垫湭寮�鍚姤璀﹀紩瀵�");
+ return " ";
+ }
}
}
- if (distanceMap.size() > 0) {
- log.debug("灏濊瘯鏌ユ壘鏈�杩戝厜鐢�");
- //鑾峰彇璺濈瀛楀吀涓渶杩戠殑涓�涓浉鏈篒D
- minDistanceCameraId = ArdTool.getKeyByMinValue(distanceMap);
- log.debug("鏌ユ壘鍒版渶杩戝厜鐢�:" + minDistanceCameraId);
- if (guideMap.get(minDistanceCameraId).equals(0)) {
- log.debug("璇ュ厜鐢垫湭寮�鍚姤璀﹀紩瀵�");
- return " ";
- }
+ catch (Exception ex)
+ {
+ log.error("鑾峰彇闄勮繎寮�鍚姤璀﹀紩瀵煎姛鑳藉厜鐢靛紓甯�:"+ex.getMessage());
}
return minDistanceCameraId;
}
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);
diff --git a/ard-work/src/main/java/com/ruoyi/device/hiksdk/service/impl/HikClientServiceImpl.java b/ard-work/src/main/java/com/ruoyi/device/hiksdk/service/impl/HikClientServiceImpl.java
index 771c21f..4ed6415 100644
--- a/ard-work/src/main/java/com/ruoyi/device/hiksdk/service/impl/HikClientServiceImpl.java
+++ b/ard-work/src/main/java/com/ruoyi/device/hiksdk/service/impl/HikClientServiceImpl.java
@@ -2,6 +2,7 @@
import com.ruoyi.common.annotation.SdkOperate;
import com.ruoyi.common.utils.file.FileUtils;
+import com.ruoyi.common.utils.file.MimeTypeUtils;
import com.ruoyi.common.utils.uuid.IdUtils;
import com.ruoyi.device.camera.domain.CameraCmd;
import com.ruoyi.device.camera.service.IArdCamerasService;
@@ -1151,11 +1152,10 @@
//瀛樺偍鍒癿inio
String BucketName = "pic";
String ObjectName = "capture/" + IdUtils.simpleUUID() + ".jpeg";
- String ContentType = "image/JPEG";
InputStream input = new ByteArrayInputStream(array);
String url = "";
try {
- boolean b = minioUtil.uploadObject(BucketName, ObjectName, input, input.available(), ContentType);
+ boolean b = minioUtil.uploadObject(BucketName, ObjectName, input, input.available(), MimeTypeUtils.IMAGE_JPEG);
if (b) {
url = minioUtil.getBucketObjectUrl(BucketName, ObjectName);
log.debug("涓婁紶鏂囦欢鎴愬姛!" + url);
@@ -1336,14 +1336,11 @@
log.debug("褰曞儚鍋滄");
//瀛樺叆minio
String BucketName = cmd.getRecordBucketName();
- String ObjectName = cmd.getRecordObjectName();
- String ContentType = "video/MP4";
+ String ObjectName = cmd.getRecordObjectName()+".mp4";
FileInputStream stream = new FileInputStream(path);
- String time = new SimpleDateFormat("yyyyMMdd").format(new Date());
- String recordName = cameraId + "/" + time + "/" + ObjectName + ".mp4";
- boolean b = minioUtil.uploadObject(BucketName, recordName, stream, stream.available(), ContentType);
+ boolean b = minioUtil.uploadObject(BucketName, ObjectName, stream, stream.available(), "video/MP4");
if (b) {
- url = endpoint + "/" + BucketName + "/" + recordName;
+ url = minioUtil.getBucketObjectUrl(BucketName, ObjectName);
log.debug("涓婁紶鏂囦欢鎴愬姛!" + url);
}
return url;
diff --git a/ard-work/src/main/java/com/ruoyi/device/hiksdk/util/hikSdkUtil/LoginResultCallBack.java b/ard-work/src/main/java/com/ruoyi/device/hiksdk/util/hikSdkUtil/LoginResultCallBack.java
index bbe9c52..d879397 100644
--- a/ard-work/src/main/java/com/ruoyi/device/hiksdk/util/hikSdkUtil/LoginResultCallBack.java
+++ b/ard-work/src/main/java/com/ruoyi/device/hiksdk/util/hikSdkUtil/LoginResultCallBack.java
@@ -59,9 +59,13 @@
}
}
//鍒涘缓寮曞闃熷垪
- Comparator<GuideTask> comparator = GuidePriorityQueue.getComparator();
- PriorityBlockingQueue<GuideTask> priorityQueue = new PriorityBlockingQueue<>(1000, comparator);
- GuidePriorityQueue.cameraQueueMap.put(camera.getId(), priorityQueue);
+ if(!GuidePriorityQueue.cameraQueueMap.containsKey(camera.getId()))
+ {
+ Comparator<GuideTask> comparator = GuidePriorityQueue.getComparator();
+ PriorityBlockingQueue<GuideTask> priorityQueue = new PriorityBlockingQueue<>(1000, comparator);
+ GuidePriorityQueue.cameraQueueMap.put(camera.getId(), priorityQueue);
+ }
+
} else {
log.debug(camera.getIp() + ":" + camera.getPort() + "鐧诲綍澶辫触");
camera.setChanNum(0);
diff --git a/ard-work/src/main/java/com/ruoyi/dispatch/domain/ArdDispatchPolice.java b/ard-work/src/main/java/com/ruoyi/dispatch/domain/ArdDispatchPolice.java
index 64d3dab..f6cdfce 100644
--- a/ard-work/src/main/java/com/ruoyi/dispatch/domain/ArdDispatchPolice.java
+++ b/ard-work/src/main/java/com/ruoyi/dispatch/domain/ArdDispatchPolice.java
@@ -25,6 +25,10 @@
@Excel(name = "娲捐鍚嶇О")
private String name;
+ /** 鎻忚堪 */
+ @Excel(name = "鎻忚堪")
+ private String text;
+
/** 缁忓害 */
@Excel(name = "缁忓害")
private Double longitude;
@@ -106,4 +110,12 @@
public void setArdDispatchPoliceUserList(List<String> ardDispatchPoliceUserList) {
this.ardDispatchPoliceUserList = ardDispatchPoliceUserList;
}
+
+ public String getText() {
+ return text;
+ }
+
+ public void setText(String text) {
+ this.text = text;
+ }
}
diff --git a/ard-work/src/main/java/com/ruoyi/test/ReadAccessDatabase.java b/ard-work/src/main/java/com/ruoyi/test/ReadAccessDatabase.java
index 2d48af9..4a93637 100644
--- a/ard-work/src/main/java/com/ruoyi/test/ReadAccessDatabase.java
+++ b/ard-work/src/main/java/com/ruoyi/test/ReadAccessDatabase.java
@@ -10,6 +10,8 @@
import com.ruoyi.common.utils.ConfigUtils;
import com.ruoyi.common.utils.DictUtils;
+import com.ruoyi.common.utils.file.ImageUtils;
+import com.sun.imageio.plugins.common.ImageUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
@@ -25,6 +27,7 @@
public class ReadAccessDatabase {
public static void main(String[] args) {
+
// 澶氫釜鏁版嵁搴撴枃浠惰矾寰�
String[] dbPaths = {
"D:\\Workspaces\\ard\\瀹夌憺杈惧伐浣滆祫鏂橽\mdb\\閬撹矾涓績绾�.mdb"
diff --git a/ard-work/src/main/resources/mapper/dispatch/ArdDispatchPoliceMapper.xml b/ard-work/src/main/resources/mapper/dispatch/ArdDispatchPoliceMapper.xml
index 7056376..6b0882c 100644
--- a/ard-work/src/main/resources/mapper/dispatch/ArdDispatchPoliceMapper.xml
+++ b/ard-work/src/main/resources/mapper/dispatch/ArdDispatchPoliceMapper.xml
@@ -7,6 +7,7 @@
<resultMap type="ArdDispatchPolice" id="ArdDispatchPoliceResult">
<result property="id" column="id"/>
<result property="name" column="name"/>
+ <result property="text" column="text"/>
<result property="longitude" column="longitude"/>
<result property="latitude" column="latitude"/>
<result property="deptId" column="dept_id"/>
@@ -38,6 +39,7 @@
<sql id="selectArdDispatchPoliceVo">
SELECT ID,
NAME,
+ text,
longitude,
latitude,
dept_id,
@@ -64,6 +66,7 @@
resultMap="ArdDispatchPoliceArdDispatchPoliceUserResult">
select a.id,
a.name,
+ a.text,
a.longitude,
a.latitude,
a.dept_id,
@@ -84,6 +87,7 @@
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if>
<if test="name != null">name,</if>
+ <if test="text != null">text,</if>
<if test="longitude != null">longitude,</if>
<if test="latitude != null">latitude,</if>
<if test="deptId != null">dept_id,</if>
@@ -96,6 +100,7 @@
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if>
<if test="name != null">#{name},</if>
+ <if test="text != null">#{text},</if>
<if test="longitude != null">#{longitude},</if>
<if test="latitude != null">#{latitude},</if>
<if test="deptId != null">#{deptId},</if>
@@ -111,6 +116,7 @@
update ard_dispatch_police
<trim prefix="SET" suffixOverrides=",">
<if test="name != null">name = #{name},</if>
+ <if test="text != null">text = #{text},</if>
<if test="longitude != null">longitude = #{longitude},</if>
<if test="latitude != null">latitude = #{latitude},</if>
<if test="deptId != null">dept_id = #{deptId},</if>
diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/file/MimeTypeUtils.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/file/MimeTypeUtils.java
index f968f1a..7b654af 100644
--- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/file/MimeTypeUtils.java
+++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/file/MimeTypeUtils.java
@@ -16,6 +16,8 @@
public static final String IMAGE_BMP = "image/bmp";
public static final String IMAGE_GIF = "image/gif";
+
+ public static final String Video_MP4 = "video/mp4";
public static final String[] IMAGE_EXTENSION = { "bmp", "gif", "jpg", "jpeg", "png" };
diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/web/domain/Server.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/web/domain/Server.java
index 63b03da..6529aa8 100644
--- a/ruoyi-framework/src/main/java/com/ruoyi/framework/web/domain/Server.java
+++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/web/domain/Server.java
@@ -5,6 +5,7 @@
import java.util.List;
import java.util.Properties;
import com.ruoyi.common.utils.Arith;
+import com.ruoyi.common.utils.file.ImageUtils;
import com.ruoyi.common.utils.ip.IpUtils;
import com.ruoyi.framework.web.domain.server.Cpu;
import com.ruoyi.framework.web.domain.server.Jvm;
--
Gitblit v1.9.3