Browse Source

截图定时优化

wyyay 10 months ago
parent
commit
08e26acf1c

+ 31 - 0
business-service/src/main/java/com/ozs/service/entity/vo/BaseCameraVO.java

@@ -0,0 +1,31 @@
+package com.ozs.service.entity.vo;
+
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+
+/**
+ * @author wyy
+ * @subject
+ * @creat 2024/3/7
+ */
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+@Builder
+public class BaseCameraVO implements Serializable{
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 相机编码
+     */
+    private String cameraCode;
+
+    /**
+     * 通道编号
+     */
+    private String channel;
+}

+ 7 - 7
business-service/src/main/java/com/ozs/service/service/RedisService.java

@@ -1,6 +1,6 @@
 package com.ozs.service.service;
 
-import com.ozs.service.entity.BaseCameraManagement;
+import com.ozs.service.entity.vo.BaseCameraVO;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.stereotype.Service;
@@ -17,7 +17,7 @@ import java.util.concurrent.TimeUnit;
 public class RedisService {
 
     @Autowired
-    public RedisTemplate<String, BaseCameraManagement> redisTemplate;
+    public RedisTemplate<String, BaseCameraVO> redisTemplate;
 
     // =============================common============================
     /**
@@ -77,7 +77,7 @@ public class RedisService {
      * @param value 值
      * @return true成功 false失败
      */
-    public boolean set(String key, BaseCameraManagement value) {
+    public boolean set(String key, BaseCameraVO value) {
         try {
             redisTemplate.opsForValue().set(key, value);
             return true;
@@ -95,7 +95,7 @@ public class RedisService {
      * @param time 时间(秒) time要大于0 如果time小于等于0 将设置无限期
      * @return true成功 false 失败
      */
-    public boolean set(String key, BaseCameraManagement value, long time) {
+    public boolean set(String key, BaseCameraVO value, long time) {
         try {
             if (time > 0) {
                 redisTemplate.opsForValue().set(key, value, time, TimeUnit.SECONDS);
@@ -110,17 +110,17 @@ public class RedisService {
     }
 
     // 将对象添加到set集合
-    public void addToSet(String key, BaseCameraManagement object) {
+    public void addToSet(String key, BaseCameraVO object) {
         redisTemplate.opsForSet().add(key, object);
     }
 
     // 从set集合中删除对象
-    public long removeFromSet(String key, BaseCameraManagement object) {
+    public long removeFromSet(String key, BaseCameraVO object) {
         return redisTemplate.opsForSet().remove(key, object);
     }
 
     // 获取set集合中的所有对象
-    public Set<BaseCameraManagement> getSetMembers(String key) {
+    public Set<BaseCameraVO> getSetMembers(String key) {
         return redisTemplate.opsForSet().members(key);
     }
 }

+ 17 - 13
business-service/src/main/java/com/ozs/service/service/impl/MsgAlarmServiceImpl.java

@@ -1,28 +1,20 @@
 package com.ozs.service.service.impl;
 
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.github.pagehelper.PageHelper;
 import com.ozs.common.constant.Constants;
-import com.ozs.common.core.redis.RedisCache;
-import com.ozs.common.utils.AppendUtils;
-import com.ozs.common.utils.StringUtils;
 import com.ozs.service.entity.BaseCameraManagement;
-import com.ozs.service.entity.BaseUser;
 import com.ozs.service.entity.MsgAlarm;
 import com.ozs.service.entity.vo.*;
 import com.ozs.service.mapper.BaseCameraManagementMapper;
-import com.ozs.service.mapper.BaseUserMapper;
 import com.ozs.service.mapper.MsgAlarmMapper;
 import com.ozs.service.service.MsgAlarmService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.ozs.service.service.RedisService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
-import org.springframework.util.CollectionUtils;
-import org.springframework.util.ObjectUtils;
 
 import java.util.*;
 import java.util.stream.Collectors;
@@ -164,14 +156,17 @@ public class MsgAlarmServiceImpl extends ServiceImpl<MsgAlarmMapper, MsgAlarm> i
 
     @Override
     public void getNormalBaseCameraManagementsCache(String setType) {
-        Set<BaseCameraManagement> alarmSet = redisService.getSetMembers(Constants.ALARM_SET);
+        Set<BaseCameraVO> alarmSet = redisService.getSetMembers(Constants.ALARM_SET);
         QueryWrapper<BaseCameraManagement> queryWrapper = new QueryWrapper<>();
         if(Constants.ALARM_SET.equals(setType)) {
             // 使用QueryWrapper和notin方法根据cameraCode列表查询BaseCameraManagement数据
             queryWrapper.notIn("camera_code", alarmSet);
             Set<BaseCameraManagement> set = baseCameraManagementMapper.selectList(queryWrapper).stream().collect(Collectors.toSet());
             set.forEach(item -> {
-                redisService.addToSet(Constants.NORMAL_SET, item);
+                BaseCameraVO  baseCameraVO=new BaseCameraVO();
+                baseCameraVO.setCameraCode(item.getCameraCode());
+                baseCameraVO.setChannel(item.getChannel());
+                redisService.addToSet(Constants.NORMAL_SET, baseCameraVO);
             });
         }
     }
@@ -182,7 +177,10 @@ public class MsgAlarmServiceImpl extends ServiceImpl<MsgAlarmMapper, MsgAlarm> i
         if (lockedMsgAlarms.isEmpty()) {
             Set<BaseCameraManagement> normalSet = baseCameraManagementMapper.selectList(null).stream().collect(Collectors.toSet());
             normalSet.forEach(item ->{
-                redisService.addToSet(Constants.NORMAL_SET,item);
+                BaseCameraVO  baseCameraVO=new BaseCameraVO();
+                baseCameraVO.setCameraCode(item.getCameraCode());
+                baseCameraVO.setChannel(item.getChannel());
+                redisService.addToSet(Constants.NORMAL_SET,baseCameraVO);
             });
             redisService.addToSet(Constants.ALARM_SET,null);
         }
@@ -192,13 +190,19 @@ public class MsgAlarmServiceImpl extends ServiceImpl<MsgAlarmMapper, MsgAlarm> i
         queryWrapperAlarm.in("camera_code", cameraCodeSet);
         Set<BaseCameraManagement> alarmSet = baseCameraManagementMapper.selectList(queryWrapperAlarm).stream().collect(Collectors.toSet());
         alarmSet.forEach(item->{
-            redisService.addToSet(Constants.ALARM_SET, item);
+            BaseCameraVO  baseCameraVO=new BaseCameraVO();
+            baseCameraVO.setCameraCode(item.getCameraCode());
+            baseCameraVO.setChannel(item.getChannel());
+            redisService.addToSet(Constants.ALARM_SET, baseCameraVO);
         });
         QueryWrapper<BaseCameraManagement> queryWrapperNormal = new QueryWrapper<>();
         queryWrapperNormal.notIn("camera_code", cameraCodeSet);
         Set<BaseCameraManagement> normalSet = baseCameraManagementMapper.selectList(queryWrapperNormal).stream().collect(Collectors.toSet());
         normalSet.forEach(item->{
-            redisService.addToSet(Constants.NORMAL_SET, item);
+            BaseCameraVO  baseCameraVO=new BaseCameraVO();
+            baseCameraVO.setCameraCode(item.getCameraCode());
+            baseCameraVO.setChannel(item.getChannel());
+            redisService.addToSet(Constants.NORMAL_SET, baseCameraVO);
         });
     }
 

+ 4 - 4
business-service/src/main/java/com/ozs/service/utils/CustomRedisConfig.java

@@ -1,6 +1,6 @@
 package com.ozs.service.utils;
 
-import com.ozs.service.entity.BaseCameraManagement;
+import com.ozs.service.entity.vo.BaseCameraVO;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
 import org.springframework.data.redis.connection.RedisConnectionFactory;
@@ -17,10 +17,10 @@ import org.springframework.data.redis.serializer.StringRedisSerializer;
 public class CustomRedisConfig {
     @Bean
     @SuppressWarnings("all")
-    public RedisTemplate<String, BaseCameraManagement> myObjectRedisTemplate(RedisConnectionFactory redisConnectionFactory) {
-        RedisTemplate<String, BaseCameraManagement> template = new RedisTemplate<String, BaseCameraManagement>();
+    public RedisTemplate<String, BaseCameraVO> myObjectRedisTemplate(RedisConnectionFactory redisConnectionFactory) {
+        RedisTemplate<String, BaseCameraVO> template = new RedisTemplate<String, BaseCameraVO>();
         template.setConnectionFactory(redisConnectionFactory);
-        Jackson2JsonRedisSerializer jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer(BaseCameraManagement.class);
+        Jackson2JsonRedisSerializer jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer(BaseCameraVO.class);
         StringRedisSerializer stringRedisSerializer = new StringRedisSerializer();
         // key采用String的序列化方式
         template.setKeySerializer(stringRedisSerializer);

+ 4 - 1
hazard-admin/src/main/java/com/ozs/web/controller/accountmanagment/MsgAlarmController.java

@@ -498,7 +498,10 @@ public class MsgAlarmController extends BaseController {
         msgAlarm.setReleasedUrl(url);
         log.info("updateIsLock----------msgAlarm" + msgAlarm);
         BaseCameraManagement bcm = msgAlarmService.getBaseCameraManagementByCamereCode(msgAlarm.getCameraCode());
-        redisService.removeFromSet(Constants.ALARM_SET,bcm);
+        BaseCameraVO  baseCameraVO=new BaseCameraVO();
+        baseCameraVO.setCameraCode(bcm.getCameraCode());
+        baseCameraVO.setChannel(bcm.getChannel());
+        redisService.removeFromSet(Constants.ALARM_SET,baseCameraVO);
         boolean b = msgAlarmService.updateById(msgAlarm);
         msgAlarmService.getNormalBaseCameraManagementsCache(Constants.ALARM_SET);
 //        LambdaQueryWrapper<MsgAppPush> wrapper = new LambdaQueryWrapper<>();

+ 0 - 7
hazard-admin/src/main/java/com/ozs/web/controller/shotschedule/ShotPictureExecutors.java

@@ -1,7 +1,5 @@
 package com.ozs.web.controller.shotschedule;
 
-import com.ozs.common.core.domain.entity.SysDictData;
-import com.ozs.common.utils.DictUtils;
 import com.ozs.system.service.ISysDictDataService;
 import com.ozs.system.service.ISysDictTypeService;
 import lombok.extern.slf4j.Slf4j;
@@ -13,13 +11,8 @@ import org.springframework.scheduling.annotation.EnableAsync;
 import org.springframework.scheduling.annotation.EnableScheduling;
 import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
-import org.springframework.util.CollectionUtils;
 
 import javax.annotation.Resource;
-import java.util.List;
-import java.util.Objects;
-import java.util.concurrent.Executors;
-import java.util.concurrent.ScheduledExecutorService;
 
 /**
  * @author wyy

+ 3 - 8
hazard-admin/src/main/java/com/ozs/web/controller/shotschedule/TaskService.java

@@ -1,13 +1,10 @@
 package com.ozs.web.controller.shotschedule;
 
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.ozs.common.constant.Constants;
 import com.ozs.common.core.domain.entity.SysDictData;
-import com.ozs.common.core.redis.RedisCache;
 import com.ozs.common.utils.DictUtils;
-import com.ozs.common.utils.MinioUtils;
 import com.ozs.common.utils.uuid.IdUtils;
-import com.ozs.service.entity.BaseCameraManagement;
+import com.ozs.service.entity.vo.BaseCameraVO;
 import com.ozs.service.service.BaseCameraManagementService;
 import com.ozs.service.service.MsgAlarmService;
 import com.ozs.service.service.RedisService;
@@ -36,8 +33,6 @@ import java.util.Set;
 @Slf4j
 @Service
 public class TaskService {
-    @Resource
-    BaseCameraManagementService baseCameraManagementService;
     @Resource
     MsgAlarmService msgAlarmService;
     @Resource
@@ -75,7 +70,7 @@ public class TaskService {
             msgAlarmService.initializationCameraCache();
         }
         SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
-        Set<BaseCameraManagement> normalSet = redisService.getSetMembers(Constants.NORMAL_SET);
+        Set<BaseCameraVO> normalSet = redisService.getSetMembers(Constants.NORMAL_SET);
         if (!CollectionUtils.isEmpty(normalSet)) {
             String finalAddress = address;
             normalSet.forEach(item -> {
@@ -128,7 +123,7 @@ public class TaskService {
         if(!isHasKeyAlarm){
             msgAlarmService.initializationCameraCache();
         }
-        Set<BaseCameraManagement> alarmSet = redisService.getSetMembers(Constants.ALARM_SET);
+        Set<BaseCameraVO> alarmSet = redisService.getSetMembers(Constants.ALARM_SET);
         if(!CollectionUtils.isEmpty(alarmSet)){
             String finalAddress = address;
             alarmSet.forEach(item -> {

+ 5 - 1
hazard-sdk/src/main/java/com/ozs/controller/upload/GeoHazardMonitorTokenController.java

@@ -19,6 +19,7 @@ import com.ozs.service.entity.BaseUser;
 import com.ozs.service.entity.MsgAlarm;
 import com.ozs.service.entity.MsgAlarmFrequency;
 import com.ozs.service.entity.SvcAddress;
+import com.ozs.service.entity.vo.BaseCameraVO;
 import com.ozs.service.service.*;
 import com.ozs.vo.ReqDeviceVo;
 import com.ozs.vo.ReqMsgAlarmVo;
@@ -198,7 +199,10 @@ public class GeoHazardMonitorTokenController {
                 msgAlarm.setAlarmTime(new Date(reqMsgAlarmVo.getAlarmTime()));
                 log.info("时间++++get" + msgAlarm.getAlarmTime());
                 BaseCameraManagement bcm = msgAlarmService.getBaseCameraManagementByCamereCode(msgAlarm.getCameraCode());
-                redisService.addToSet(Constants.ALARM_SET,bcm);
+                BaseCameraVO baseCameraVO=new BaseCameraVO();
+                baseCameraVO.setCameraCode(bcm.getCameraCode());
+                baseCameraVO.setChannel(bcm.getChannel());
+                redisService.addToSet(Constants.ALARM_SET,baseCameraVO);
                 msgAlarmService.getNormalBaseCameraManagementsCache(Constants.ALARM_SET);
                 msgAlarmService.save(msgAlarm);
                 msgAlarmVice.setImageUrl(url.substring(0, url.length() - 1));