From aff3af669362fc9b0743e3d3319ac9e20ba822eb Mon Sep 17 00:00:00 2001
From: ‘liusuyi’ <1951119284@qq.com>
Date: 星期日, 08 十月 2023 15:06:31 +0800
Subject: [PATCH] 归纳分类定时任务 任务列表和任务日志按时间逆序排列
---
ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/CleanTask.java | 25 +++++
/dev/null | 43 ----------
ruoyi-quartz/src/main/resources/mapper/quartz/SysJobLogMapper.xml | 1
ruoyi-quartz/src/main/resources/mapper/quartz/SysJobMapper.xml | 1
ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/PushTask.java | 43 ++++++++--
ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/SyncTask.java | 84 +++++++++++++++++++++
6 files changed, 142 insertions(+), 55 deletions(-)
diff --git a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/AlarmTask.java b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/AlarmTask.java
deleted file mode 100644
index 1eea459..0000000
--- a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/AlarmTask.java
+++ /dev/null
@@ -1,62 +0,0 @@
-package com.ruoyi.quartz.task;
-
-import com.ruoyi.alarm.global.domain.GuidePriorityQueue;
-import com.ruoyi.alarm.global.domain.GuideTask;
-import com.ruoyi.alarm.global.service.IGlobalAlarmService;
-import com.ruoyi.common.utils.spring.SpringUtils;
-import com.ruoyi.utils.websocket.util.WebSocketUtils;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.stereotype.Component;
-
-import java.util.*;
-import java.util.concurrent.PriorityBlockingQueue;
-
-import static com.ruoyi.utils.websocket.util.WebSocketUtils.ONLINE_USER_SESSIONS;
-
-/**
- * @ClassName: AlarmTask
- * @Description:
- * @Author: Administrator
- * @Date: 2023骞�03鏈�06鏃� 11:13
- * @Version: 1.0
- **/
-@Component("AlarmTask")
-@Slf4j
-public class AlarmTask {
-
- /**
- * @鎻忚堪 瀹氭椂鎺ㄩ�佹墍鏈夋姤璀︾殑鐐逛綅鏁伴噺
- * @鍙傛暟 []
- * @杩斿洖鍊� void
- * @鍒涘缓浜� 鍒樿嫃涔�
- * @鍒涘缓鏃堕棿 2023/6/15 15:43
- * @淇敼浜哄拰鍏跺畠淇℃伅
- */
- public void globalAlarmCountPush() {
- try {
- IGlobalAlarmService globalAlarmService = SpringUtils.getBean(IGlobalAlarmService.class);
- Map<String, Object> stringIntegerMap = globalAlarmService.selectAlarmLogsCount();
- if (ONLINE_USER_SESSIONS.size() > 0) {
- WebSocketUtils.sendMessageAll(stringIntegerMap);
- }
- } catch (Exception ex) {
- log.error("瀹氭椂鎺ㄩ�佹墍鏈夋姤璀︾殑鐐逛綅鏁伴噺寮傚父:" + ex.getMessage());
- }
- }
-
- /**
- * 瀹氭椂娓呯┖寮曞闃熷垪
- * 鍒樿嫃涔�
- * 2023/7/1 10:41
- */
- public void clearGuideQueue() {
- try {
- log.info("瀹氭椂娓呯悊寮曞闃熷垪");
- for (PriorityBlockingQueue<GuideTask> guideQueue : GuidePriorityQueue.cameraQueueMap.values()) {
- guideQueue.clear();
- }
- } catch (Exception ex) {
- log.error("瀹氭椂娓呯┖寮曞闃熷垪:" + ex.getMessage());
- }
- }
-}
\ No newline at end of file
diff --git a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/MinioTask.java b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/CleanTask.java
similarity index 78%
rename from ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/MinioTask.java
rename to ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/CleanTask.java
index 7a8ef64..1cbb4fe 100644
--- a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/MinioTask.java
+++ b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/CleanTask.java
@@ -1,15 +1,18 @@
package com.ruoyi.quartz.task;
+import com.ruoyi.alarm.global.domain.GuidePriorityQueue;
+import com.ruoyi.alarm.global.domain.GuideTask;
import com.ruoyi.utils.minio.MinioUtil;
import io.minio.Result;
import io.minio.messages.Item;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
-import javax.annotation.Resource;
+
import java.text.SimpleDateFormat;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.*;
+import java.util.concurrent.PriorityBlockingQueue;
/**
* @ClassName: MinioDeleteTask
@@ -19,8 +22,8 @@
* @Version: 1.0
**/
@Component("MinioTask")
-@Slf4j(topic = "minio")
-public class MinioTask {
+@Slf4j
+public class CleanTask {
public void delHistoryTask(Integer saveDays) {
log.debug("鎵ц鍘嗗彶鏁版嵁鍒犻櫎");
@@ -59,4 +62,20 @@
log.error("minio鍘嗗彶鏁版嵁鍒犻櫎寮傚父锛�" + ex.getMessage());
}
}
+
+ /**
+ * 瀹氭椂娓呯┖寮曞闃熷垪
+ * 鍒樿嫃涔�
+ * 2023/7/1 10:41
+ */
+ public void clearGuideQueue() {
+ try {
+ log.info("瀹氭椂娓呯悊寮曞闃熷垪");
+ for (PriorityBlockingQueue<GuideTask> guideQueue : GuidePriorityQueue.cameraQueueMap.values()) {
+ guideQueue.clear();
+ }
+ } catch (Exception ex) {
+ log.error("瀹氭椂娓呯┖寮曞闃熷垪:" + ex.getMessage());
+ }
+ }
}
diff --git a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/SdkTask.java b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/PushTask.java
similarity index 79%
rename from ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/SdkTask.java
rename to ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/PushTask.java
index ad33328..4aa4deb 100644
--- a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/SdkTask.java
+++ b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/PushTask.java
@@ -1,32 +1,58 @@
package com.ruoyi.quartz.task;
+import com.ruoyi.alarm.global.domain.GuidePriorityQueue;
+import com.ruoyi.alarm.global.domain.GuideTask;
+import com.ruoyi.alarm.global.service.IGlobalAlarmService;
import com.ruoyi.common.constant.CacheConstants;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.redis.RedisCache;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.spring.SpringUtils;
-import com.ruoyi.utils.websocket.util.WebSocketUtils;
import com.ruoyi.device.camera.domain.ArdCameras;
import com.ruoyi.device.camera.domain.CameraCmd;
import com.ruoyi.device.hiksdk.common.GlobalVariable;
import com.ruoyi.device.hiksdk.service.IHikClientService;
+import com.ruoyi.utils.websocket.util.WebSocketUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
+
import java.util.*;
+import java.util.concurrent.PriorityBlockingQueue;
import static com.ruoyi.utils.websocket.util.WebSocketUtils.ONLINE_USER_SESSIONS;
/**
+ * @ClassName: AlarmTask
* @Description:
- * @ClassName: SdkTask
- * @Author: 鍒樿嫃涔�
- * @Date: 2023骞�06鏈�24鏃�14:23
+ * @Author: Administrator
+ * @Date: 2023骞�03鏈�06鏃� 11:13
* @Version: 1.0
**/
-@Component("SdkTask")
-@Slf4j(topic = "hikSdk")
-public class SdkTask {
+@Component("PushTask")
+@Slf4j
+public class PushTask {
+
+ /**
+ * @鎻忚堪 瀹氭椂鎺ㄩ�佹墍鏈夋姤璀︾殑鐐逛綅鏁伴噺
+ * @鍙傛暟 []
+ * @杩斿洖鍊� void
+ * @鍒涘缓浜� 鍒樿嫃涔�
+ * @鍒涘缓鏃堕棿 2023/6/15 15:43
+ * @淇敼浜哄拰鍏跺畠淇℃伅
+ */
+ public void globalAlarmCountPush() {
+ try {
+ IGlobalAlarmService globalAlarmService = SpringUtils.getBean(IGlobalAlarmService.class);
+ Map<String, Object> stringIntegerMap = globalAlarmService.selectAlarmLogsCount();
+ if (ONLINE_USER_SESSIONS.size() > 0) {
+ WebSocketUtils.sendMessageAll(stringIntegerMap);
+ }
+ } catch (Exception ex) {
+ log.error("鎺ㄩ�佹姤璀︾殑鐐逛綅鏁伴噺寮傚父:" + ex.getMessage());
+ }
+ }
+
/**
* @鎻忚堪 瀹氭椂鎺ㄩ�乸tz
@@ -105,5 +131,4 @@
log.error("鎺ㄩ�乸tz寮傚父:" + ex.getMessage());
}
}
-
-}
+}
\ No newline at end of file
diff --git a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/RongCloudTask.java b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/RongCloudTask.java
deleted file mode 100644
index 7ec73cc..0000000
--- a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/RongCloudTask.java
+++ /dev/null
@@ -1,58 +0,0 @@
-package com.ruoyi.quartz.task;
-
-import com.ruoyi.app.position.domain.ArdAppPosition;
-import com.ruoyi.common.core.domain.entity.SysUser;
-import com.ruoyi.rongcloud.service.RongCloudService;
-import com.ruoyi.system.service.ISysUserService;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.stereotype.Component;
-
-import javax.annotation.Resource;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * @Description: 铻嶄簯浠诲姟绫�
- * @ClassName: RongCloudTask
- * @Author: 鍒樿嫃涔�
- * @Date: 2023骞�07鏈�28鏃�13:18:22
- * @Version: 1.0
- **/
-@Component("RongCloudTask")
-@Slf4j
-public class RongCloudTask {
-
- @Resource
- ISysUserService sysUserService;
- @Resource
- RongCloudService rongCloudService;
-
- /**
- * 瀹氭椂鑾峰彇app鐢ㄦ埛鍦ㄧ嚎鐘舵��
- * 鍒樿嫃涔�
- * 2023/8/9 9:17:48
- */
- public void getAppUserOnlineStateTask() {
- try {
- List<SysUser> SysUserList = sysUserService.selectAllAppUserList(new SysUser());
- if (SysUserList.size() > 0) {
- for (SysUser sysUser : SysUserList) {
- String state = sysUser.getAppOnlineState();//鑾峰彇褰撳墠鐢ㄦ埛鐨勫湪绾跨姸鎬�
- Boolean online = rongCloudService.checkOnline(sysUser.getUserId());//浠庤瀺浜戣幏鍙栧湪绾跨姸鎬�
- if (state != null) {
- Boolean appOnlineState = state.equals("1");
- if (appOnlineState == online) {
- continue;
- }
- }
- sysUser.setAppOnlineState(online ? "1" : "0");
- sysUserService.updateUserProfile(sysUser);
- }
- }
- } catch (Exception ex) {
- log.error("铻嶄簯鍦ㄧ嚎鎺ュ彛寮傚父锛�" + ex.getMessage());
- }
- }
-}
diff --git a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/SyncTask.java b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/SyncTask.java
new file mode 100644
index 0000000..f2b6b01
--- /dev/null
+++ b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/SyncTask.java
@@ -0,0 +1,84 @@
+package com.ruoyi.quartz.task;
+
+import com.ruoyi.common.core.domain.entity.SysUser;
+import com.ruoyi.device.camera.domain.ArdCameras;
+import com.ruoyi.device.camera.domain.CameraCmd;
+import com.ruoyi.device.camera.service.IArdCamerasService;
+import com.ruoyi.device.hiksdk.service.IHikClientService;
+import com.ruoyi.rongcloud.service.RongCloudService;
+import com.ruoyi.system.service.ISysUserService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Component;
+
+import javax.annotation.Resource;
+import java.util.List;
+
+/**
+ * @Description: 鍚屾浠诲姟
+ * @ClassName: syncDeviceStateTask
+ * @Author: 鍒樿嫃涔�
+ * @Date: 2023骞�10鏈�08鏃�11:06:42
+ **/
+@Component("SyncTask")
+@Slf4j
+public class SyncTask {
+ @Resource
+ ISysUserService sysUserService;
+ @Resource
+ RongCloudService rongCloudService;
+ @Resource
+ IArdCamerasService iArdCamerasService;
+ @Resource
+ IHikClientService iHikClientService;
+
+ /**
+ * 鍚屾鐩告満鍦ㄧ嚎鐘舵��
+ * 鍒樿嫃涔�
+ * 2023/10/8 14:54:41
+ */
+ public void cameraState() {
+ List<ArdCameras> ardCameras = iArdCamerasService.selectArdCamerasListNoDataScope(new ArdCameras());
+ for (ArdCameras camera : ardCameras) {
+ CameraCmd cmd = new CameraCmd();
+ cmd.setCameraId(camera.getId());
+ boolean onLineNew = iHikClientService.isOnLine(cmd);//鐩告満瀹炴椂鐘舵��
+ boolean onLineOld = "1".equals(camera.getState());//鐩告満鍘嗗彶鐘舵��
+ //褰撶姸鎬佸彂鐢熷彉鍖栨椂锛屾洿鏂板疄鏃剁姸鎬�
+ if (onLineNew != onLineOld) {
+ if (onLineNew) {
+ camera.setState("1");
+ } else {
+ camera.setState("0");
+ }
+ iArdCamerasService.updateArdCameras(camera);
+ }
+ }
+ }
+
+ /**
+ * 瀹氭椂鑾峰彇app鐢ㄦ埛鍦ㄧ嚎鐘舵��
+ * 鍒樿嫃涔�
+ * 2023/8/9 9:17:48
+ */
+ public void appUserState() {
+ try {
+ List<SysUser> SysUserList = sysUserService.selectAllAppUserList(new SysUser());
+ if (SysUserList.size() > 0) {
+ for (SysUser sysUser : SysUserList) {
+ String state = sysUser.getAppOnlineState();//鑾峰彇褰撳墠鐢ㄦ埛鐨勫湪绾跨姸鎬�
+ Boolean online = rongCloudService.checkOnline(sysUser.getUserId());//浠庤瀺浜戣幏鍙栧湪绾跨姸鎬�
+ if (state != null) {
+ Boolean appOnlineState = state.equals("1");
+ if (appOnlineState == online) {
+ continue;
+ }
+ }
+ sysUser.setAppOnlineState(online ? "1" : "0");
+ sysUserService.updateUserProfile(sysUser);
+ }
+ }
+ } catch (Exception ex) {
+ log.error("铻嶄簯鍦ㄧ嚎鎺ュ彛寮傚父锛�" + ex.getMessage());
+ }
+ }
+}
diff --git a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/syncDeviceStateTask.java b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/syncDeviceStateTask.java
deleted file mode 100644
index 4f13eaf..0000000
--- a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/syncDeviceStateTask.java
+++ /dev/null
@@ -1,43 +0,0 @@
-package com.ruoyi.quartz.task;
-
-import com.ruoyi.device.camera.domain.ArdCameras;
-import com.ruoyi.device.camera.domain.CameraCmd;
-import com.ruoyi.device.camera.service.IArdCamerasService;
-import com.ruoyi.device.hiksdk.service.IHikClientService;
-import org.springframework.stereotype.Component;
-
-import javax.annotation.Resource;
-import java.util.List;
-
-/**
- * @Description: 鍚屾璁惧鐘舵�佷换鍔�
- * @ClassName: syncDeviceStateTask
- * @Author: 鍒樿嫃涔�
- * @Date: 2023骞�10鏈�08鏃�11:06:42
- **/
-@Component("syncTask")
-public class syncDeviceStateTask {
- @Resource
- IArdCamerasService iArdCamerasService;
- @Resource
- IHikClientService iHikClientService;
-
- public void cameraState() {
- List<ArdCameras> ardCameras = iArdCamerasService.selectArdCamerasListNoDataScope(new ArdCameras());
- for (ArdCameras camera : ardCameras) {
- CameraCmd cmd = new CameraCmd();
- cmd.setCameraId(camera.getId());
- boolean onLineNew = iHikClientService.isOnLine(cmd);//鐩告満瀹炴椂鐘舵��
- boolean onLineOld = "1".equals(camera.getState());//鐩告満鍘嗗彶鐘舵��
- //褰撶姸鎬佸彂鐢熷彉鍖栨椂锛屾洿鏂板疄鏃剁姸鎬�
- if (onLineNew != onLineOld) {
- if (onLineNew) {
- camera.setState("1");
- } else {
- camera.setState("0");
- }
- iArdCamerasService.updateArdCameras(camera);
- }
- }
- }
-}
diff --git a/ruoyi-quartz/src/main/resources/mapper/quartz/SysJobLogMapper.xml b/ruoyi-quartz/src/main/resources/mapper/quartz/SysJobLogMapper.xml
index 42b7ccd..10d9669 100644
--- a/ruoyi-quartz/src/main/resources/mapper/quartz/SysJobLogMapper.xml
+++ b/ruoyi-quartz/src/main/resources/mapper/quartz/SysJobLogMapper.xml
@@ -42,6 +42,7 @@
and create_time <= to_timestamp(#{params.endTime},'yyyy-MM-DD')
</if>
</where>
+ order by create_time desc
</select>
<select id="selectJobLogAll" resultMap="SysJobLogResult">
diff --git a/ruoyi-quartz/src/main/resources/mapper/quartz/SysJobMapper.xml b/ruoyi-quartz/src/main/resources/mapper/quartz/SysJobMapper.xml
index cdda8bd..a9cdddb 100644
--- a/ruoyi-quartz/src/main/resources/mapper/quartz/SysJobMapper.xml
+++ b/ruoyi-quartz/src/main/resources/mapper/quartz/SysJobMapper.xml
@@ -41,6 +41,7 @@
AND invoke_target like ('%${invokeTarget}%')
</if>
</where>
+ order by create_time desc
</select>
<select id="selectJobAll" resultMap="SysJobResult">
--
Gitblit v1.9.3