From ed578bfc2ab4bb54110571f7ad3fff46727fa2de Mon Sep 17 00:00:00 2001 From: ‘liusuyi’ <1951119284@qq.com> Date: 星期三, 12 七月 2023 10:31:07 +0800 Subject: [PATCH] 优化 --- ard-work/src/main/java/com/ruoyi/alarm/globalAlarm/service/impl/GlobalAlarmServiceImpl.java | 7 +-- ard-work/src/main/java/com/ruoyi/alarm/radarAlarm/mapper/ArdAlarmRadarMapper.java | 4 + ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/MinioTask.java | 16 +++---- ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/AlarmTask.java | 22 +++++++--- ard-work/src/main/resources/mapper/alarm/ArdAlarmCameraMapper.xml | 12 +----- 5 files changed, 30 insertions(+), 31 deletions(-) diff --git a/ard-work/src/main/java/com/ruoyi/alarm/globalAlarm/service/impl/GlobalAlarmServiceImpl.java b/ard-work/src/main/java/com/ruoyi/alarm/globalAlarm/service/impl/GlobalAlarmServiceImpl.java index b54a8a4..2288d4f 100644 --- a/ard-work/src/main/java/com/ruoyi/alarm/globalAlarm/service/impl/GlobalAlarmServiceImpl.java +++ b/ard-work/src/main/java/com/ruoyi/alarm/globalAlarm/service/impl/GlobalAlarmServiceImpl.java @@ -365,7 +365,7 @@ String defenseName = ardAlarmExternal.getDefenseName(); String alarmType = ardAlarmExternal.getAlarmType(); String alarmTime = fmt.format(ardAlarmExternal.getAlarmTime()); - ardAlarmRadarMapper.updateViewTimeByCondition(defenseName, alarmType, alarmTime, DateUtils.getTime()); + ardAlarmExternalMapper.updateViewTimeByCondition(defenseName, alarmType, alarmTime, DateUtils.getTime()); return ardAlarmExternal; } case 1006: @@ -717,7 +717,6 @@ return minDistanceCameraId; } - public static void main(String[] args) { Comparator<Obj> PriorityDescCom = Comparator.comparingInt(Obj::getPriority).reversed(); Comparator<Obj> NumDescCom = Comparator.comparingInt(Obj::getNum).reversed(); @@ -738,8 +737,8 @@ log.info("==================================================================="); priorityQueue.add(new Obj(999, 5, "2023-07-01 16:00:01")); PriorityBlockingQueue queue = new PriorityBlockingQueue<>(priorityQueue); - while (priorityQueue.size() > 0) { - Obj task = priorityQueue.poll(); + while (queue.size() > 0) { + Obj task = (Obj)queue.poll(); log.info("姝e湪鎺掗槦銆恜riority銆�" + task.getPriority() + "銆恘um銆�" + task.getNum() + "銆恆larmTime銆�" + task.getAlarmTime()); } } diff --git a/ard-work/src/main/java/com/ruoyi/alarm/radarAlarm/mapper/ArdAlarmRadarMapper.java b/ard-work/src/main/java/com/ruoyi/alarm/radarAlarm/mapper/ArdAlarmRadarMapper.java index 2375c9e..704db09 100644 --- a/ard-work/src/main/java/com/ruoyi/alarm/radarAlarm/mapper/ArdAlarmRadarMapper.java +++ b/ard-work/src/main/java/com/ruoyi/alarm/radarAlarm/mapper/ArdAlarmRadarMapper.java @@ -75,7 +75,9 @@ * 鏌ユ壘5鍒嗛挓鍐呭紩瀵艰繃鐨勮褰� */ public ArdAlarmRadar getArdAlarmRadarWithGuide(ArdAlarmRadar ardAlarmRadar); - + /** + * 鑾峰彇鏈紩瀵肩殑璁板綍鏁伴噺 + */ public int getArdAlarmRadarWithNotGuide(@Param("ardAlarmRadar") ArdAlarmRadar ardAlarmRadar, @Param("guideTime") Date guideTime); public int updateViewTimeByCondition(@Param("name")String name,@Param("alarmType")String alarmType,@Param("alarmTime") String alarmTime,@Param("viewTime") String viewTime); diff --git a/ard-work/src/main/resources/mapper/alarm/ArdAlarmCameraMapper.xml b/ard-work/src/main/resources/mapper/alarm/ArdAlarmCameraMapper.xml index bd0217f..702bd6d 100644 --- a/ard-work/src/main/resources/mapper/alarm/ArdAlarmCameraMapper.xml +++ b/ard-work/src/main/resources/mapper/alarm/ArdAlarmCameraMapper.xml @@ -16,7 +16,6 @@ <result property="latitude" column="latitude" /> <result property="ruleId" column="rule_id" /> <result property="picUrl" column="pic_url" /> - <result property="recordUrl" column="record_url" /> <result property="viewTime" column="view_time" /> <result property="createBy" column="create_by" /> <result property="createTime" column="create_time" /> @@ -25,7 +24,7 @@ </resultMap> <sql id="selectArdAlarmCameraVo"> - select id, camera_id, camera_name, camera_channel, camera_type, alarm_type, alarm_time, longitude, latitude, rule_id, pic_url, record_url, view_time, create_by, create_time, user_id, dept_id from ard_alarm_camera + select id, camera_id, camera_name, camera_channel, camera_type, alarm_type, alarm_time, longitude, latitude, rule_id, pic_url, view_time, create_by, create_time, user_id, dept_id from ard_alarm_camera </sql> <select id="selectArdAlarmCameraList" parameterType="ArdAlarmCamera" resultMap="ArdAlarmCameraResult"> @@ -36,7 +35,6 @@ <if test="cameraChannel != null "> and camera_channel = #{cameraChannel}</if> <if test="cameraType != null and cameraType != ''"> and camera_type = #{cameraType}</if> <if test="alarmType != null and alarmType != ''"> and alarm_type = #{alarmType}</if> -<!-- <if test="alarmTime != null "> and alarm_time = #{alarmTime}</if>--> <if test="params.beginTime != null and params.beginTime != ''"><!-- 寮�濮嬫椂闂存绱� --> AND alarm_time >= to_timestamp(#{params.beginTime},'yyyy-MM-DD HH24:MI:ss') </if> @@ -47,7 +45,6 @@ <if test="latitude != null "> and latitude = #{latitude}</if> <if test="ruleId != null "> and rule_id = #{ruleId}</if> <if test="picUrl != null and picUrl != ''"> and pic_url = #{picUrl}</if> - <if test="recordUrl != null and recordUrl != ''"> and record_url = #{recordUrl}</if> <if test="viewTime != null "> and view_time = #{viewTime}</if> <if test="userId != null and userId != ''"> and user_id = #{userId}</if> <if test="deptId != null "> and dept_id = #{deptId}</if> @@ -74,7 +71,6 @@ <if test="latitude != null">latitude,</if> <if test="ruleId != null">rule_id,</if> <if test="picUrl != null">pic_url,</if> - <if test="recordUrl != null">record_url,</if> <if test="viewTime != null">view_time,</if> <if test="createBy != null">create_by,</if> <if test="createTime != null">create_time,</if> @@ -93,7 +89,6 @@ <if test="latitude != null">#{latitude},</if> <if test="ruleId != null">#{ruleId},</if> <if test="picUrl != null">#{picUrl},</if> - <if test="recordUrl != null">#{recordUrl},</if> <if test="viewTime != null">#{viewTime},</if> <if test="createBy != null">#{createBy},</if> <if test="createTime != null">#{createTime},</if> @@ -115,7 +110,6 @@ <if test="latitude != null">latitude = #{latitude},</if> <if test="ruleId != null">rule_id = #{ruleId},</if> <if test="picUrl != null">pic_url = #{picUrl},</if> - <if test="recordUrl != null">record_url = #{recordUrl},</if> <if test="viewTime != null">view_time = #{viewTime},</if> <if test="createBy != null">create_by = #{createBy},</if> <if test="createTime != null">create_time = #{createTime},</if> @@ -136,8 +130,7 @@ </foreach> </delete> <select id="selectListAllByCommand" resultMap="ArdAlarmCameraResult"> - SELECT T - .* + SELECT T.* FROM ( SELECT @@ -147,7 +140,6 @@ aac.alarm_time, aac.longitude, aac.latitude, - aac.record_url, ROW_NUMBER () OVER ( PARTITION BY aac.camera_id ORDER BY aac.alarm_time DESC ) AS rn, COUNT ( CASE WHEN aac.view_time IS NULL THEN 1 END ) OVER ( PARTITION BY aac.camera_id ) AS COUNT, COUNT ( aac.alarm_time ) OVER ( PARTITION BY camera_id ) AS total 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 index 1dc3ebe..d22d07d 100644 --- a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/AlarmTask.java +++ b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/AlarmTask.java @@ -41,22 +41,30 @@ * @淇敼浜哄拰鍏跺畠淇℃伅 */ public void globalAlarmCountPush() { - IGlobalAlarmService globalAlarmService = SpringUtils.getBean(IGlobalAlarmService.class); - Map<String, Object> stringIntegerMap = globalAlarmService.selectAlarmLogsCount(); - if (ONLINE_USER_SESSIONS.size() > 0) { + 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() { - log.info("瀹氭椂娓呯悊寮曞闃熷垪"); - for(PriorityBlockingQueue<GuideTask> guideQueue:GuidePriorityQueue.cameraQueueMap.values()) - { - guideQueue.clear(); + 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/MinioTask.java index b78e9b7..de78377 100644 --- a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/MinioTask.java +++ b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/MinioTask.java @@ -23,7 +23,7 @@ public class MinioTask { public void delHistoryTask(Integer saveDays) { - log.info("鎵ц鍘嗗彶鏁版嵁鍒犻櫎"); + log.debug("鎵ц鍘嗗彶鏁版嵁鍒犻櫎"); //閬嶅巻瀛樺偍 try { List<String> buckets=new ArrayList<>(); @@ -33,7 +33,6 @@ Iterable<Result<Item>> listObjectsPic = MinioUtils.getObjectsByBucket(name); for (Result<Item> result : listObjectsPic) { Item item = result.get(); - log.info(item.objectName() + "鍒涘缓鏃堕棿锛�" + item.lastModified()); DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss").withZone(ZoneId.of("Asia/Shanghai")); String objectTime = item.lastModified().format(formatter); @@ -43,17 +42,16 @@ calendar.setTime(now); calendar.add(Calendar.DATE, saveDays); SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - String nowTime = fmt.format(calendar.getTime()); + String expireTime = fmt.format(calendar.getTime()); - log.info("objectTime : " + objectTime); - log.info("nowTime : " + nowTime); - - if (objectTime.compareTo(nowTime) < 0) { - log.info("objectTime 鏃堕棿鍦� nowTime 涔嬪墠"); + if (objectTime.compareTo(expireTime) < 0) { + log.debug("objectTime : " + objectTime); + log.debug("expireTime : " + expireTime); + log.debug("objectTime 鏃堕棿鍦� expireTime 涔嬪墠,鎵ц鍒犻櫎"); boolean b = MinioUtils.removeObject(name, item.objectName()); if(b) { - log.info("鍒犻櫎杩囨湡鏁版嵁锛�"+ item.objectName()+"---"+item.lastModified()); + log.debug("鎴愬姛鍒犻櫎杩囨湡鏁版嵁锛�"+ item.objectName()+"---"+item.lastModified()); } } } -- Gitblit v1.9.3