From c1dafc830993fcedb99a4f2b62178691e1e92e64 Mon Sep 17 00:00:00 2001
From: Administrator <1144154118@qq.com>
Date: 星期一, 07 八月 2023 14:07:46 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'
---
ard-work/src/main/java/com/ruoyi/storage/minio/service/impl/StorageMinioEventServiceImpl.java | 52 +++++++-----
ard-work/src/main/java/com/ruoyi/alarm/global/service/impl/GlobalAlarmServiceImpl.java | 140 ++++++++++++++---------------------
ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/SysUserOnlineController.java | 9 +-
3 files changed, 90 insertions(+), 111 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 6d761a0..fec6e6f 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
@@ -52,6 +52,7 @@
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.PriorityBlockingQueue;
+import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
/**
@@ -96,6 +97,8 @@
@Resource
private QueueManager queueManager;
//endregion
+ //姣忎釜鐐逛綅鏈紩瀵兼鏁�
+ private Map<String, Integer> unGuideCountMap = new HashMap<>();
/**
* @鎻忚堪 鏌ヨ鎵�鏈夋姤璀︾殑褰撳墠鏁伴噺
@@ -542,68 +545,45 @@
}
double[] coordinate = new double[]{ardAlarmRadar.getLongitude(), ardAlarmRadar.getLatitude()};//鎶ヨ鍧愭爣
- //鍒ゆ柇褰撳墠鎶ヨ鐐�5鍒嗛挓鍐呮槸鍚﹀凡寮曞
- ardAlarmRadar.setGuideFlag(1);
- // ArdAlarmRadar AlarmRadar = ardAlarmRadarMapper.getArdAlarmRadarWithGuide(ardAlarmRadar);
- ArdAlarmRadar AlarmRadar = redisCache.getCacheObject("global_alarm:guideNew");//浠巖edis涓彇鍑烘渶鏂板紩瀵肩殑鎶ヨ鏁版嵁
- if (StringUtils.isNull(AlarmRadar)) {
- //5鍒嗛挓鍐呮湭寮曞鐩存帴鍏ュ簱
- ardAlarmRadarMapper.insertArdAlarmRadar(ardAlarmRadar);
- redisCache.setCacheObject("global_alarm:guideNew",ardAlarmRadar);//寮曞鏁版嵁鍐欏叆redis
- //鑾峰彇闆疯揪鎵�鍦ㄥ涓婄殑澶у厜鐢�
- String cameraIdWithTower = ardAlarmRadarMapper.getCameraByRadar(radarAlarmData.getRadarId());
- if (StringUtils.isNotNull(cameraIdWithTower) && StringUtils.isNotEmpty(cameraIdWithTower)) {
- log.info("鑾峰彇鍒伴浄杈惧涓婄殑鍏夌數:" + cameraIdWithTower);
- //濡傛灉闆疯揪濉斾笂鏈夊厜鐢�
- messagesEnqueued(cameraIdWithTower, uuid, alarmType, ardAlarmRadar.getCreateTime(), 1, 1, coordinate);
- }
- //鑾峰彇鎶ヨ鐐瑰叧鑱旂殑澶у厜鐢�
- ArdAlarmpointsWell ardAlarmpointsWell = ardAlarmpointsWellMapper.selectArdAlarmpointsWellByWellId(alarmpointName);
- if (StringUtils.isNotNull(ardAlarmpointsWell) && StringUtils.isNotEmpty(ardAlarmpointsWell.getCameraId())) {
- String cameraId = ardAlarmpointsWell.getCameraId();
- if (cameraId.equals(cameraIdWithTower)) {
- return;
- }
- log.info("鑾峰彇鍒版姤璀︾偣鍏宠仈鐨勫厜鐢�:" + cameraId);
- //濡傛灉鎶ヨ鐐瑰叧鑱斾簡鍏夌數
- messagesEnqueued(cameraId, uuid, alarmType, ardAlarmRadar.getCreateTime(), 1, 2, coordinate);
- }
+ //浠巖edis涓彇鍑哄綋鍓嶆姤璀︾偣鐨�5鍒嗛挓鍐呮槸鍚︽湁寮曞
+ ArdAlarmRadar AlarmRadar = redisCache.getCacheObject("global_alarm:" + ardAlarmRadar.getName());//浠巖edis涓彇鍑烘渶鏂板紩瀵肩殑鎶ヨ鏁版嵁
+ if (AlarmRadar == null) {
+ //5鍒嗛挓鍐卹edis涓病鏈夋暟鎹紝璇存槑5鍒嗛挓鍐呮病鏈夊紩瀵兼暟鎹�
+ ardAlarmRadar.setGuideFlag(1);
+ //灏嗗紩瀵兼暟鎹啓鍏edis 璁剧疆5鍒嗛挓杩囨湡
+ redisCache.setCacheObject("global_alarm:" + ardAlarmRadar.getName(), ardAlarmRadar, 5, TimeUnit.MINUTES);//寮曞鏁版嵁鍐欏叆redis
+ unGuideCountMap.put(ardAlarmRadar.getName(), 0);
+ //寮曞鍏ラ槦
+ radarGuide(radarAlarmData.getRadarId(), alarmpointName, alarmType, ardAlarmRadar.getCreateTime(), coordinate);
+
} else {
- //5鍒嗛挓鍐呮湁寮曞
- ardAlarmRadar.setGuideFlag(0);
- int count = ardAlarmRadarMapper.getArdAlarmRadarWithNotGuide(ardAlarmRadar, AlarmRadar.getCreateTime());
- //鏈紩瀵艰秴杩�3娆★紝鐩存帴鍏ュ簱鍏ラ槦
- if (count >= 3) {
- ardAlarmRadar.setGuideFlag(1);
- ardAlarmRadarMapper.insertArdAlarmRadar(ardAlarmRadar);
- redisCache.setCacheObject("global_alarm:guideNew",ardAlarmRadar);//寮曞鏁版嵁鍐欏叆redis
- //鑾峰彇闆疯揪鎵�鍦ㄥ涓婄殑澶у厜鐢�
- String cameraIdWithTower = ardAlarmRadarMapper.getCameraByRadar(radarAlarmData.getRadarId());
- if (StringUtils.isNotNull(cameraIdWithTower) && StringUtils.isNotEmpty(cameraIdWithTower)) {
- log.info("鑾峰彇鍒伴浄杈惧涓婄殑鍏夌數:" + cameraIdWithTower);
- //濡傛灉闆疯揪濉斾笂鏈夊厜鐢�
- messagesEnqueued(cameraIdWithTower, uuid, alarmType, ardAlarmRadar.getCreateTime(), count, 1, coordinate);
- }
- //鑾峰彇鎶ヨ鐐瑰叧鑱旂殑澶у厜鐢�
- ArdAlarmpointsWell ardAlarmpointsWell = ardAlarmpointsWellMapper.selectArdAlarmpointsWellByWellId(alarmpointName);
- if (StringUtils.isNotNull(ardAlarmpointsWell) && StringUtils.isNotEmpty(ardAlarmpointsWell.getCameraId())) {
- String cameraId = ardAlarmpointsWell.getCameraId();
- if (cameraId.equals(cameraIdWithTower)) {
- return;
- }
- log.info("鑾峰彇鍒版姤璀︾偣鍏宠仈鐨勫厜鐢�:" + cameraId);
- //濡傛灉鎶ヨ鐐瑰叧鑱斾簡鍏夌數
- messagesEnqueued(cameraId, uuid, alarmType, ardAlarmRadar.getCreateTime(), count, 2, coordinate);
+ //5鍒嗛挓鍐卹edis涓湁鏁版嵁锛岃鏄�5鍒嗛挓鍐呮湁寮曞鏁版嵁,鑾峰彇褰撳墠鎶ヨ鐐圭殑鏈紩瀵兼鏁�
+ Integer count = unGuideCountMap.get(ardAlarmRadar.getName());
+ if (count != null) {
+ if (count > 2) {
+ //鏈紩瀵兼鏁�3娆″悗杩涜寮曞
+ ardAlarmRadar.setGuideFlag(1);
+ //灏嗗紩瀵兼暟鎹啓鍏edis 璁剧疆5鍒嗛挓杩囨湡
+ redisCache.setCacheObject("global_alarm:" + ardAlarmRadar.getName(), ardAlarmRadar, 5, TimeUnit.MINUTES);
+ count = 0;
+ //寮曞鍏ラ槦
+ radarGuide(radarAlarmData.getRadarId(), alarmpointName, alarmType, ardAlarmRadar.getCreateTime(), coordinate);
+ } else {
+ ardAlarmRadar.setGuideFlag(0);
+ count++;
}
} else {
- //鏈紩瀵兼湭瓒呰繃3娆★紝鐩存帴鍏ュ簱
- ardAlarmRadarMapper.insertArdAlarmRadar(ardAlarmRadar);
+ ardAlarmRadar.setGuideFlag(0);
+ count = 0;
}
+ unGuideCountMap.put(ardAlarmRadar.getName(), count);
}
+ //鍏ュ簱
+ ardAlarmRadarMapper.insertArdAlarmRadar(ardAlarmRadar);
// 缁撴潫鏃堕棿
long etime = System.currentTimeMillis();
// 璁$畻鎵ц鏃堕棿
- log.info("鏌ヨAPI鎵ц鏃堕暱锛�"+(etime-stime)+"姣");
+ log.info("闆疯揪鎶ヨ澶勭悊鏃堕暱锛�" + (etime - stime) + "姣");
}
//endregion
@@ -739,7 +719,7 @@
private Boolean IsEnableGuide(String cameraId) {
boolean enabled = false;
ArdCameras ardCameras = redisCache.getCacheObject(CacheConstants.CAMERA_LIST_KEY + cameraId);
- if(ardCameras!=null) {
+ if (ardCameras != null) {
if (ardCameras.getCamAlarmGuideEnable().equals(1)) {
enabled = true;
}
@@ -781,37 +761,29 @@
return minDistanceCameraId;
}
- public static void main(String[] args) {
- Comparator<Obj> PriorityDescCom = Comparator.comparingInt(Obj::getPriority).reversed();
- Comparator<Obj> NumDescCom = Comparator.comparingInt(Obj::getNum).reversed();
- Comparator<Obj> receiveTimeAscCom = Comparator.comparing(Obj::getAlarmTime);
- Comparator<Obj> comparator = PriorityDescCom.thenComparing(NumDescCom).thenComparing(receiveTimeAscCom);
-
- PriorityBlockingQueue<Obj> priorityQueue = new PriorityBlockingQueue<>(1000, comparator);
-
- priorityQueue.add(new Obj(999, 1, "2023-07-01 16:00:01"));
- priorityQueue.add(new Obj(999, 2, "2023-07-01 16:00:01"));
- priorityQueue.add(new Obj(999, 3, "2023-07-01 16:00:01"));
-
- List<Obj> elements = new ArrayList<>(priorityQueue);
- elements.sort(priorityQueue.comparator()); // 浣跨敤闃熷垪鐨勬瘮杈冨櫒杩涜鎺掑簭
- for (Obj task : elements) {
- log.info("姝e湪鎺掗槦銆恜riority銆�" + task.getPriority() + "銆恘um銆�" + task.getNum() + "銆恆larmTime銆�" + task.getAlarmTime());
+ /**
+ * 闆疯揪寮曞鍏ラ槦
+ */
+ private void radarGuide(String radarId, String alarmpointName, String alarmType, Date createTime, double[] coordinate) {
+ String uuid = IdUtils.simpleUUID();
+ //鑾峰彇闆疯揪鎵�鍦ㄥ涓婄殑澶у厜鐢�
+ String cameraIdWithTower = ardAlarmRadarMapper.getCameraByRadar(radarId);
+ if (StringUtils.isNotNull(cameraIdWithTower) && StringUtils.isNotEmpty(cameraIdWithTower)) {
+ log.info("鑾峰彇鍒伴浄杈惧涓婄殑鍏夌數:" + cameraIdWithTower);
+ //濡傛灉闆疯揪濉斾笂鏈夊厜鐢�
+ messagesEnqueued(cameraIdWithTower, uuid, alarmType, createTime, 1, 1, coordinate);
}
- log.info("===================================================================");
- priorityQueue.add(new Obj(999, 5, "2023-07-01 16:00:01"));
- PriorityBlockingQueue queue = new PriorityBlockingQueue<>(priorityQueue);
- while (queue.size() > 0) {
- Obj task = (Obj) queue.poll();
- log.info("姝e湪鎺掗槦銆恜riority銆�" + task.getPriority() + "銆恘um銆�" + task.getNum() + "銆恆larmTime銆�" + task.getAlarmTime());
+ //鑾峰彇鎶ヨ鐐瑰叧鑱旂殑澶у厜鐢�
+ ArdAlarmpointsWell ardAlarmpointsWell = ardAlarmpointsWellMapper.selectArdAlarmpointsWellByWellId(alarmpointName);
+ if (StringUtils.isNotNull(ardAlarmpointsWell) && StringUtils.isNotEmpty(ardAlarmpointsWell.getCameraId())) {
+ String cameraId = ardAlarmpointsWell.getCameraId();
+ if (cameraId.equals(cameraIdWithTower)) {
+ return;
+ }
+ log.info("鑾峰彇鍒版姤璀︾偣鍏宠仈鐨勫厜鐢�:" + cameraId);
+ //濡傛灉鎶ヨ鐐瑰叧鑱斾簡鍏夌數
+ messagesEnqueued(cameraId, uuid, alarmType, createTime, 1, 2, coordinate);
}
}
- @Data
- @AllArgsConstructor
- static class Obj {
- Integer priority;
- Integer num;
- String alarmTime;
- }
}
diff --git a/ard-work/src/main/java/com/ruoyi/storage/minio/service/impl/StorageMinioEventServiceImpl.java b/ard-work/src/main/java/com/ruoyi/storage/minio/service/impl/StorageMinioEventServiceImpl.java
index ce70fdf..5e16aca 100644
--- a/ard-work/src/main/java/com/ruoyi/storage/minio/service/impl/StorageMinioEventServiceImpl.java
+++ b/ard-work/src/main/java/com/ruoyi/storage/minio/service/impl/StorageMinioEventServiceImpl.java
@@ -106,31 +106,37 @@
@Async
@Override
public void parseStorageMinioEvent(String message) {
- JsonsRootBean jsonsRootBean = JSONObject.parseObject(message, JsonsRootBean.class);
- if (jsonsRootBean != null) {
- Records records = jsonsRootBean.getRecords().get(0);
- StorageMinioEvent storageMinioEvent = new StorageMinioEvent();
- storageMinioEvent.setEventTime(records.getEventTime());
- storageMinioEvent.setEventType(records.getEventName());
- storageMinioEvent.setBucketName(records.getS3().getBucket().getName());
- String encode = null;
- try {
- encode = URLDecoder.decode(records.getS3().getMObject().getKey(), "UTF-8");
- } catch (UnsupportedEncodingException e) {
- e.printStackTrace();
- }
- storageMinioEvent.setObjectName(encode);
- storageMinioEvent.setObjectSize(records.getS3().getMObject().getSize());
- storageMinioEvent.setObjectType(records.getS3().getMObject().getContentType());
- storageMinioEvent.setHost(records.getSource().getHost());
- storageMinioEvent.setEndpoint(records.getResponseElements().getXMinioOriginEndpoint());
- storageMinioEvent.setUserName(records.getRequestParameters().getPrincipalid());
+ try {
+ JsonsRootBean jsonsRootBean = JSONObject.parseObject(message, JsonsRootBean.class);
+ if (jsonsRootBean != null) {
+ Records records = jsonsRootBean.getRecords().get(0);
+ StorageMinioEvent storageMinioEvent = new StorageMinioEvent();
+ storageMinioEvent.setEventTime(records.getEventTime());
+ String eventType = records.getEventName().substring(0, records.getEventName().indexOf(":", records.getEventName().indexOf(":") + 1));//涓嶅寘鍚湰韬綅缃�
+ storageMinioEvent.setEventType(eventType);
+ storageMinioEvent.setBucketName(records.getS3().getBucket().getName());
+ String encode = null;
+ try {
+ encode = URLDecoder.decode(records.getS3().getMObject().getKey(), "UTF-8");
+ } catch (UnsupportedEncodingException e) {
+ e.printStackTrace();
+ }
+ storageMinioEvent.setObjectName(encode);
+ storageMinioEvent.setObjectSize(records.getS3().getMObject().getSize());
+ storageMinioEvent.setObjectType(records.getS3().getMObject().getContentType());
+ storageMinioEvent.setHost(records.getSource().getHost());
+ storageMinioEvent.setEndpoint(records.getResponseElements().getXMinioOriginEndpoint());
+ storageMinioEvent.setUserName(records.getRequestParameters().getPrincipalid());
- int i = insertStorageMinioEvent(storageMinioEvent);
- if(i>0)
- {
- log.debug("minio鎿嶄綔鏃ュ織鍏ュ簱鎴愬姛!銆�"+storageMinioEvent.getEventType()+"銆�");
+ int i = insertStorageMinioEvent(storageMinioEvent);
+ if (i > 0) {
+ log.debug("minio鎿嶄綔鏃ュ織鍏ュ簱鎴愬姛!銆�" + storageMinioEvent.getEventType() + "銆�");
+ }
}
}
+ catch (Exception ex)
+ {
+ log.error("minio浜嬩欢鏍煎紡鍖栧紓甯�:"+ex.getMessage());
+ }
}
}
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/SysUserOnlineController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/SysUserOnlineController.java
index f539fce..e3fed44 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/SysUserOnlineController.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/SysUserOnlineController.java
@@ -1,9 +1,7 @@
package com.ruoyi.web.controller.monitor;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
+import java.util.*;
+
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.DeleteMapping;
@@ -75,6 +73,9 @@
}
Collections.reverse(userOnlineList);
userOnlineList.removeAll(Collections.singleton(null));
+ //鍦ㄧ嚎鐢ㄦ埛鎸夌櫥褰曟椂闂撮�嗗簭鎺掑簭
+ Comparator<SysUserOnline> comparator = Comparator.comparingLong(sysUserOnline -> sysUserOnline.getLoginTime()); // 浣跨敤Collections.sort鏂规硶杩涜鎺掑簭 Collections.sort(personList, comparator);
+ Collections.sort(userOnlineList, comparator.reversed());
return getDataTable(userOnlineList);
}
--
Gitblit v1.9.3