瀏覽代碼

相机截图开发

gao.qiang 3 周之前
父節點
當前提交
76c7c20c00

+ 83 - 83
hazard-admin/src/main/java/com/ozs/web/controller/shotschedule/CaptureStreamListener.java

@@ -26,92 +26,92 @@ import java.time.LocalTime;
 @Slf4j
 public class CaptureStreamListener implements StreamListener<String, ObjectRecord<String, String>> {
 
-    @Resource
-    private StringRedisTemplate stringRedisTemplate;
-
-    @Resource
-    public RedisTemplate<String, String> redisTemplate;
-
-    /**
-     * 生成 runable 任务服务提供类
-     */
-    @Resource
-    private GenPictureTaskService genPictureTaskService;
-
-    /**
-     * Redis 缓存服务提供类
-     */
-    @Resource
-    private RedisService redisService;
+//    @Resource
+//    private StringRedisTemplate stringRedisTemplate;
+//
+//    @Resource
+//    public RedisTemplate<String, String> redisTemplate;
+//
+//    /**
+//     * 生成 runable 任务服务提供类
+//     */
+//    @Resource
+//    private GenPictureTaskService genPictureTaskService;
+//
+//    /**
+//     * Redis 缓存服务提供类
+//     */
+//    @Resource
+//    private RedisService redisService;
+//
+//    @Override
+//    protected void finalize() throws Throwable {
+//        super.finalize();
+//    }
 
     @Override
-    protected void finalize() throws Throwable {
-        super.finalize();
-    }
-
-    @Override
-    @Async
+//    @Async
     public void onMessage(ObjectRecord<String, String> message) {
-        ShotPictureTaskExecutors.RUNNING_ATOMIC_INT.incrementAndGet();
-        BaseCameraVO vo = null;
-        try {
-            // 消息ID
-            RecordId recordId = message.getId();
-            // 消息的key和value
-            String value = message.getValue();
-            if (StringUtils.isNotBlank(value) && value.indexOf("cameraCode") == -1) {
-                stringRedisTemplate.opsForStream().acknowledge(RedisPushService.STREAM_KEY, RedisPushService.STREAM_CONSUMER_GROUP_KEY, recordId.getValue());
-                stringRedisTemplate.opsForStream().delete(RedisPushService.STREAM_KEY, recordId.getValue());
-                ShotPictureTaskExecutors.RUNNING_ATOMIC_INT.decrementAndGet();
-                return;
-            }
-            Dict dataDict = JSONUtil.toBean(value, Dict.class);
-
-            String cameraCode = dataDict.getStr("cameraCode");
-            String railwayName = dataDict.getStr("railwayName");
-            String installMiles = dataDict.getStr("installMiles");
-            Boolean isAlarm = dataDict.getBool("isAlarm");
-            String camera_type_hash = isAlarm ? ShotPictureTaskExecutors.CAMERA_ALARM_HASH : ShotPictureTaskExecutors.CAMERA_NORMAL_HASH;
-
-            Object cacheObj = redisTemplate.opsForHash().get(camera_type_hash, cameraCode);
-            vo = JSONUtil.toBean(ObjectUtils.toString(cacheObj), BaseCameraVO.class);
-            vo.setStatus("running");
-            if (vo.getIsAlarm() == null) {
-                vo.setIsAlarm(isAlarm);
-            }
-            redisService.addToHash(camera_type_hash, vo.getCameraCode(), vo);
-
-            DateTime nextExecuteTime = DateTime.now();
-            if (StringUtils.isNotBlank(dataDict.getStr("nextExecuteTime"))) {
-                nextExecuteTime = DateTime.of(dataDict.getStr("nextExecuteTime"), "yyyy-MM-dd HH:mm:ss");
-            }
-            DateTime now = DateTime.now();
-            StringBuilder fileName = new StringBuilder(cameraCode);
-            fileName.append("-");
-            fileName.append(DateTime.now().toString("yyyyMMddHHmmss"));
-            String isNormalPath = isAlarm ? "alarm" : "normal";
-            String filePath = dataDict.getStr("address")+"/"+isNormalPath+"/"+railwayName+"/"+installMiles+"/"+ LocalDate.now().getYear() +"/"+ LocalDate.now().getMonthValue() +"/"+LocalDate.now().getDayOfMonth()+ "/"+ LocalTime.now().getHour()+"/" +fileName + ".jpeg";
-            // 超过时间则进行抓拍
-            if (now.isAfterOrEquals(nextExecuteTime) && nextExecuteTime.between(now, DateUnit.MINUTE) < 2) {
-                genPictureTaskService.makePicture(cameraCode, dataDict.getStr("channel"), filePath, vo.getIsAlarm());
-            }
-            // 通过RedisTemplate手动确认消息
-            stringRedisTemplate.opsForStream().acknowledge(RedisPushService.STREAM_KEY, RedisPushService.STREAM_CONSUMER_GROUP_KEY, recordId.getValue());
-            stringRedisTemplate.opsForStream().delete(RedisPushService.STREAM_KEY, recordId.getValue());
-        } catch (Exception e) {
-            log.error("摄像头抓图出现异常, ", e);
-        } finally {
-            Boolean isAlarm = vo.getIsAlarm();
-            if (isAlarm) {
-                vo.setNextExecuteTime(DateTime.now().offset(DateField.SECOND, 1).toString("yyyy-MM-dd HH:mm:ss"));
-            } else {
-                vo.setNextExecuteTime(DateTime.now().offset(DateField.MINUTE, 1).toString("yyyy-MM-dd HH:mm:ss"));
-            }
-            vo.setStatus("complete");
-            redisService.addToHash(isAlarm ? ShotPictureTaskExecutors.CAMERA_ALARM_HASH :
-                    ShotPictureTaskExecutors.CAMERA_NORMAL_HASH, vo.getCameraCode(), vo);
-            ShotPictureTaskExecutors.RUNNING_ATOMIC_INT.decrementAndGet();
-        }
+//        ShotPictureTaskExecutors.RUNNING_ATOMIC_INT.incrementAndGet();
+//        BaseCameraVO vo = null;
+//        try {
+//            // 消息ID
+//            RecordId recordId = message.getId();
+//            // 消息的key和value
+//            String value = message.getValue();
+//            if (StringUtils.isNotBlank(value) && value.indexOf("cameraCode") == -1) {
+//                stringRedisTemplate.opsForStream().acknowledge(RedisPushService.STREAM_KEY, RedisPushService.STREAM_CONSUMER_GROUP_KEY, recordId.getValue());
+//                stringRedisTemplate.opsForStream().delete(RedisPushService.STREAM_KEY, recordId.getValue());
+//                ShotPictureTaskExecutors.RUNNING_ATOMIC_INT.decrementAndGet();
+//                return;
+//            }
+//            Dict dataDict = JSONUtil.toBean(value, Dict.class);
+//
+//            String cameraCode = dataDict.getStr("cameraCode");
+//            String railwayName = dataDict.getStr("railwayName");
+//            String installMiles = dataDict.getStr("installMiles");
+//            Boolean isAlarm = dataDict.getBool("isAlarm");
+//            String camera_type_hash = isAlarm ? ShotPictureTaskExecutors.CAMERA_ALARM_HASH : ShotPictureTaskExecutors.CAMERA_NORMAL_HASH;
+//
+//            Object cacheObj = redisTemplate.opsForHash().get(camera_type_hash, cameraCode);
+//            vo = JSONUtil.toBean(ObjectUtils.toString(cacheObj), BaseCameraVO.class);
+//            vo.setStatus("running");
+//            if (vo.getIsAlarm() == null) {
+//                vo.setIsAlarm(isAlarm);
+//            }
+//            redisService.addToHash(camera_type_hash, vo.getCameraCode(), vo);
+//
+//            DateTime nextExecuteTime = DateTime.now();
+//            if (StringUtils.isNotBlank(dataDict.getStr("nextExecuteTime"))) {
+//                nextExecuteTime = DateTime.of(dataDict.getStr("nextExecuteTime"), "yyyy-MM-dd HH:mm:ss");
+//            }
+//            DateTime now = DateTime.now();
+//            StringBuilder fileName = new StringBuilder(cameraCode);
+//            fileName.append("-");
+//            fileName.append(DateTime.now().toString("yyyyMMddHHmmss"));
+//            String isNormalPath = isAlarm ? "alarm" : "normal";
+//            String filePath = dataDict.getStr("address")+"/"+isNormalPath+"/"+railwayName+"/"+installMiles+"/"+ LocalDate.now().getYear() +"/"+ LocalDate.now().getMonthValue() +"/"+LocalDate.now().getDayOfMonth()+ "/"+ LocalTime.now().getHour()+"/" +fileName + ".jpeg";
+//            // 超过时间则进行抓拍
+//            if (now.isAfterOrEquals(nextExecuteTime) && nextExecuteTime.between(now, DateUnit.MINUTE) < 2) {
+//                genPictureTaskService.makePicture(cameraCode, dataDict.getStr("channel"), filePath, vo.getIsAlarm());
+//            }
+//            // 通过RedisTemplate手动确认消息
+//            stringRedisTemplate.opsForStream().acknowledge(RedisPushService.STREAM_KEY, RedisPushService.STREAM_CONSUMER_GROUP_KEY, recordId.getValue());
+//            stringRedisTemplate.opsForStream().delete(RedisPushService.STREAM_KEY, recordId.getValue());
+//        } catch (Exception e) {
+//            log.error("摄像头抓图出现异常, ", e);
+//        } finally {
+//            Boolean isAlarm = vo.getIsAlarm();
+//            if (isAlarm) {
+//                vo.setNextExecuteTime(DateTime.now().offset(DateField.SECOND, 1).toString("yyyy-MM-dd HH:mm:ss"));
+//            } else {
+//                vo.setNextExecuteTime(DateTime.now().offset(DateField.MINUTE, 1).toString("yyyy-MM-dd HH:mm:ss"));
+//            }
+//            vo.setStatus("complete");
+//            redisService.addToHash(isAlarm ? ShotPictureTaskExecutors.CAMERA_ALARM_HASH :
+//                    ShotPictureTaskExecutors.CAMERA_NORMAL_HASH, vo.getCameraCode(), vo);
+//            ShotPictureTaskExecutors.RUNNING_ATOMIC_INT.decrementAndGet();
+//        }
     }
 
 }

+ 34 - 34
hazard-admin/src/main/java/com/ozs/web/controller/shotschedule/GenPictureTaskService.java

@@ -20,40 +20,40 @@ import java.net.URL;
 @Service
 public class GenPictureTaskService {
 
-    /**
-     * 摄像头截图服务接口
-     */
-    @Resource
-    CameraCaptureService cameraCaptureService;
-
-    @Value("${shot.urlAddress}")
-    private String urlAddress;
-
-    public boolean makePicture(String cameraCode, String channel, String filePath, boolean isAlarm) {
-        long start = System.currentTimeMillis();
-        if (!ObjectUtils.isEmpty(cameraCode)) {
-            try {
-//                if (log.isDebugEnabled()) {
-//                    log.debug("请求url======" + urlAddress + cameraCode + "/" + channel);
-//                }
-                URL url = new URL(urlAddress + cameraCode + "/" + channel);
-//                if (log.isDebugEnabled()) {
-//                    log.debug("正常摄像头截图开始, url: " + url + ", fileName: " + filePath);
-//                }
-                boolean capture = cameraCaptureService.getCapture(url, cameraCode, filePath);
-                if (capture && isAlarm) {
-                    ThreadUtil.sleep(500);
-                    cameraCaptureService.getCapture(url, cameraCode, filePath);
-                }
-//                if (log.isDebugEnabled()) {
-//                    log.debug("正常摄像头截图结束, url: " + url + (capture ? "" : ", 出现错误") + ", 共计耗时: " + ((System.currentTimeMillis() - start) / 1000) + "s");
+//    /**
+//     * 摄像头截图服务接口
+//     */
+//    @Resource
+//    CameraCaptureService cameraCaptureService;
+//
+//    @Value("${shot.urlAddress}")
+//    private String urlAddress;
+//
+//    public boolean makePicture(String cameraCode, String channel, String filePath, boolean isAlarm) {
+//        long start = System.currentTimeMillis();
+//        if (!ObjectUtils.isEmpty(cameraCode)) {
+//            try {
+////                if (log.isDebugEnabled()) {
+////                    log.debug("请求url======" + urlAddress + cameraCode + "/" + channel);
+////                }
+//                URL url = new URL(urlAddress + cameraCode + "/" + channel);
+////                if (log.isDebugEnabled()) {
+////                    log.debug("正常摄像头截图开始, url: " + url + ", fileName: " + filePath);
+////                }
+//                boolean capture = cameraCaptureService.getCapture(url, cameraCode, filePath);
+//                if (capture && isAlarm) {
+//                    ThreadUtil.sleep(500);
+//                    cameraCaptureService.getCapture(url, cameraCode, filePath);
 //                }
-                return capture;
-            } catch (Throwable e) {
-                log.error("正常摄像头截图异常", e);
-            }
-        }
-        return false;
-    }
+////                if (log.isDebugEnabled()) {
+////                    log.debug("正常摄像头截图结束, url: " + url + (capture ? "" : ", 出现错误") + ", 共计耗时: " + ((System.currentTimeMillis() - start) / 1000) + "s");
+////                }
+//                return capture;
+//            } catch (Throwable e) {
+//                log.error("正常摄像头截图异常", e);
+//            }
+//        }
+//        return false;
+//    }
 
 }

+ 14 - 14
hazard-admin/src/main/java/com/ozs/web/controller/shotschedule/RedisPushService.java

@@ -13,19 +13,19 @@ import java.util.Collections;
 @Slf4j
 public class RedisPushService {
 
-    @Resource
-    private StringRedisTemplate stringRedisTemplate;
-
-    public final static String STREAM_KEY = "capture";
-    public final static String STREAM_CONSUMER_GROUP_KEY = "capture_group_1";
-
-    public void pushMsg(String msg) {
-        // 创建消息记录流, 以及指定stream
-        //创建的记录指定一个流的关键字(Key)STREAM_KEY
-        StringRecord stringRecord = StreamRecords.string(Collections.singletonMap("data", msg)).withStreamKey(STREAM_KEY);
-        // 将消息添加至消息队列中
-        this.stringRedisTemplate.opsForStream().add(stringRecord);
-//        log.info("{}已发送消息: {}", STREAM_KEY, msg);
-    }
+//    @Resource
+//    private StringRedisTemplate stringRedisTemplate;
+//
+//    public final static String STREAM_KEY = "capture";
+//    public final static String STREAM_CONSUMER_GROUP_KEY = "capture_group_1";
+//
+//    public void pushMsg(String msg) {
+//        // 创建消息记录流, 以及指定stream
+//        //创建的记录指定一个流的关键字(Key)STREAM_KEY
+//        StringRecord stringRecord = StreamRecords.string(Collections.singletonMap("data", msg)).withStreamKey(STREAM_KEY);
+//        // 将消息添加至消息队列中
+//        this.stringRedisTemplate.opsForStream().add(stringRecord);
+////        log.info("{}已发送消息: {}", STREAM_KEY, msg);
+//    }
 
 }

+ 76 - 76
hazard-admin/src/main/java/com/ozs/web/controller/shotschedule/RedisStreamConsumerConfig.java

@@ -20,81 +20,81 @@ import java.util.Collections;
 @Slf4j
 public class RedisStreamConsumerConfig {
 
-    //注入Redis模板
-    @Resource
-    private RedisTemplate<String, Object> redisTemplate;
-
-    @Bean
-    public StreamMessageListenerContainer<String, ObjectRecord<String, String>> captureConsumerListener(
-            RedisConnectionFactory connectionFactory, CaptureStreamListener streamListener) {
-        StreamMessageListenerContainer<String, ObjectRecord<String, String>> container =
-                streamContainer(RedisPushService.STREAM_KEY, connectionFactory, streamListener);
-        container.start();
-        return container;
-    }
-
-    /**
-     * @param myStream 从哪个流接收数据
-     * @param connectionFactory
-     * @param streamListener 绑定的监听类
-     * @return
-     */
-    private StreamMessageListenerContainer<String, ObjectRecord<String, String>> streamContainer(String myStream,
-                                                                                                 RedisConnectionFactory connectionFactory, StreamListener<String, ObjectRecord<String, String>> streamListener) {
-        StreamMessageListenerContainer.StreamMessageListenerContainerOptions<String, ObjectRecord<String, String>> options =
-                StreamMessageListenerContainer.StreamMessageListenerContainerOptions
-                        .builder()
-                        .pollTimeout(Duration.ofSeconds(5)) // 拉取消息超时时间
-                        .batchSize(1) // 批量抓取消息
-                        .targetType(String.class) // 传递的数据类型
-//                        .executor(Executors.newFixedThreadPool(1))
-                        .build();
-        StreamMessageListenerContainer<String, ObjectRecord<String, String>> container = StreamMessageListenerContainer
-                .create(connectionFactory, options);
-        //指定消费最新的消息
-        StreamOffset<String> offset = StreamOffset.create(myStream, ReadOffset.lastConsumed());
-        //创建消费者
-        StreamMessageListenerContainer.StreamReadRequest<String> streamReadRequest = null;
-        try {
-            streamReadRequest = buildStreamReadRequest(offset, streamListener);
-        } catch (Exception e) {
-            log.error(e.getMessage());
-        }
-        //指定消费者对象
-        container.register(streamReadRequest, streamListener);
-        return container;
-    }
-
-    private StreamMessageListenerContainer.StreamReadRequest<String> buildStreamReadRequest(StreamOffset<String> offset,
-                                                                                            StreamListener<String, ObjectRecord<String, String>> streamListener) throws Exception {
-        Consumer consumer = null;
-        if (streamListener instanceof CaptureStreamListener) {
-            //如果 流不存在 创建 stream 流
-            if( !redisTemplate.hasKey(RedisPushService.STREAM_KEY)){
-                redisTemplate.opsForStream().add(RedisPushService.STREAM_KEY, Collections.singletonMap("status", "init"));
-                log.debug("初始化stream: " + RedisPushService.STREAM_KEY + "成功!");
-            }
-            //创建消费者组
-            try {
-                redisTemplate.opsForStream().createGroup(RedisPushService.STREAM_KEY, RedisPushService.STREAM_CONSUMER_GROUP_KEY);
-            } catch (Exception e) {
-                log.debug("消费者组: " + RedisPushService.STREAM_CONSUMER_GROUP_KEY + "已存在");
-            }
-            consumer = Consumer.from(RedisPushService.STREAM_CONSUMER_GROUP_KEY, RedisPushService.STREAM_KEY);
-        } else {
-            throw new Exception("无法识别的stream key");
-        }
-        StreamMessageListenerContainer.StreamReadRequest<String> streamReadRequest = StreamMessageListenerContainer.StreamReadRequest.builder(offset)
-                .errorHandler((error) -> {
-                    error.printStackTrace();
-                    log.error(error.getMessage());
-                })
-                .cancelOnError(e -> false)
-                .consumer(consumer)
-                //关闭自动ack确认
-                .autoAcknowledge(false)
-                .build();
-        return streamReadRequest;
-    }
+//    //注入Redis模板
+//    @Resource
+//    private RedisTemplate<String, Object> redisTemplate;
+//
+//    @Bean
+//    public StreamMessageListenerContainer<String, ObjectRecord<String, String>> captureConsumerListener(
+//            RedisConnectionFactory connectionFactory, CaptureStreamListener streamListener) {
+//        StreamMessageListenerContainer<String, ObjectRecord<String, String>> container =
+//                streamContainer(RedisPushService.STREAM_KEY, connectionFactory, streamListener);
+//        container.start();
+//        return container;
+//    }
+//
+//    /**
+//     * @param myStream 从哪个流接收数据
+//     * @param connectionFactory
+//     * @param streamListener 绑定的监听类
+//     * @return
+//     */
+//    private StreamMessageListenerContainer<String, ObjectRecord<String, String>> streamContainer(String myStream,
+//                                                                                                 RedisConnectionFactory connectionFactory, StreamListener<String, ObjectRecord<String, String>> streamListener) {
+//        StreamMessageListenerContainer.StreamMessageListenerContainerOptions<String, ObjectRecord<String, String>> options =
+//                StreamMessageListenerContainer.StreamMessageListenerContainerOptions
+//                        .builder()
+//                        .pollTimeout(Duration.ofSeconds(5)) // 拉取消息超时时间
+//                        .batchSize(1) // 批量抓取消息
+//                        .targetType(String.class) // 传递的数据类型
+////                        .executor(Executors.newFixedThreadPool(1))
+//                        .build();
+//        StreamMessageListenerContainer<String, ObjectRecord<String, String>> container = StreamMessageListenerContainer
+//                .create(connectionFactory, options);
+//        //指定消费最新的消息
+//        StreamOffset<String> offset = StreamOffset.create(myStream, ReadOffset.lastConsumed());
+//        //创建消费者
+//        StreamMessageListenerContainer.StreamReadRequest<String> streamReadRequest = null;
+//        try {
+//            streamReadRequest = buildStreamReadRequest(offset, streamListener);
+//        } catch (Exception e) {
+//            log.error(e.getMessage());
+//        }
+//        //指定消费者对象
+//        container.register(streamReadRequest, streamListener);
+//        return container;
+//    }
+//
+//    private StreamMessageListenerContainer.StreamReadRequest<String> buildStreamReadRequest(StreamOffset<String> offset,
+//                                                                                            StreamListener<String, ObjectRecord<String, String>> streamListener) throws Exception {
+//        Consumer consumer = null;
+//        if (streamListener instanceof CaptureStreamListener) {
+//            //如果 流不存在 创建 stream 流
+//            if( !redisTemplate.hasKey(RedisPushService.STREAM_KEY)){
+//                redisTemplate.opsForStream().add(RedisPushService.STREAM_KEY, Collections.singletonMap("status", "init"));
+//                log.debug("初始化stream: " + RedisPushService.STREAM_KEY + "成功!");
+//            }
+//            //创建消费者组
+//            try {
+//                redisTemplate.opsForStream().createGroup(RedisPushService.STREAM_KEY, RedisPushService.STREAM_CONSUMER_GROUP_KEY);
+//            } catch (Exception e) {
+//                log.debug("消费者组: " + RedisPushService.STREAM_CONSUMER_GROUP_KEY + "已存在");
+//            }
+//            consumer = Consumer.from(RedisPushService.STREAM_CONSUMER_GROUP_KEY, RedisPushService.STREAM_KEY);
+//        } else {
+//            throw new Exception("无法识别的stream key");
+//        }
+//        StreamMessageListenerContainer.StreamReadRequest<String> streamReadRequest = StreamMessageListenerContainer.StreamReadRequest.builder(offset)
+//                .errorHandler((error) -> {
+//                    error.printStackTrace();
+//                    log.error(error.getMessage());
+//                })
+//                .cancelOnError(e -> false)
+//                .consumer(consumer)
+//                //关闭自动ack确认
+//                .autoAcknowledge(false)
+//                .build();
+//        return streamReadRequest;
+//    }
 
 }

+ 256 - 256
hazard-admin/src/main/java/com/ozs/web/controller/shotschedule/ShotPictureTaskExecutors.java

@@ -50,260 +50,260 @@ import java.util.stream.Collectors;
 @Slf4j
 public class ShotPictureTaskExecutors {
 
-    @Value("${shot.storeAddress}")
-    private String storeAddress;
-
-    @Value("${shot.isMaster}")
-    private Boolean isMaster;
-
-    /**
-     * Redis 缓存服务提供类
-     */
-    @Resource
-    private RedisService redisService;
-
-    @Resource
-    public RedisTemplate<String, String> redisTemplate;
-
-    @Resource
-    private ISysDictTypeService iSysDictTypeService;
-
-    @Resource
-    private RedisPushService redisPushService;
-
-    @Resource
-    private MsgAlarmMapper msgAlarmMapper;
-
-    @Resource
-    private BaseCameraManagementMapper baseCameraManagementMapper;
-
-    @Resource
-    private BaseRailwayManagementMapper baseRailwayManagementMapper;
-    @Autowired
-    RedisCache redisCache;
-
-
-    /**
-     * REDIS 抓拍摄像头分布式锁
-     */
-    private final static String LOCK_CAMELA_NORMAL_KEY = "lock_camela_normal";
-
-    public static final String CAMERA_ALARM_HASH = "camera_alarm_hash";
-    public static final String CAMERA_NORMAL_HASH = "camera_normal_hash";
-
-    public final static AtomicInteger RUNNING_ATOMIC_INT = new AtomicInteger(0);
-
-    /**
-     * 处理非预警摄像头截图, 间隔: 60s
-     */
-    @Async
-    @Scheduled(fixedDelay = 60 * 1000, initialDelay = 3 * 1000)
-    public synchronized void initCameraConfig() {
-        if (!isMaster) return;
-        // 获取分布式锁
-        boolean lockSuccess = redisTemplate.opsForValue().setIfAbsent(LOCK_CAMELA_NORMAL_KEY, "execute", Duration.ofSeconds(60));
-        if (lockSuccess) {
-            // 查询未解除的报警摄像头(报警摄像头逻辑沿用wangyy代码)
-            List<String> lockedMsgAlarmCameraCodes = msgAlarmMapper.selectList(new QueryWrapper<MsgAlarm>().eq("is_lock", 2))
-                    .stream().map(f -> f.getCameraCode()).distinct().collect(Collectors.toList());
-            try {
-                QueryWrapper<BaseCameraManagement> queryWrapper = new QueryWrapper<>();
-                queryWrapper.select("distinct camera_code, channel,railway_code,install_mile");
-                // 获取数据库中最新摄像头相关内容
-                List<BaseCameraManagement> dbAlarms = baseCameraManagementMapper.selectList(queryWrapper).stream().collect(Collectors.toList());
-                List<BaseRailwayManagement> dbRailways = baseRailwayManagementMapper.selectList(null);
-                //如果相机表不为空
-                if (!CollectionUtils.isEmpty(dbAlarms)) {
-                    //循环线路集合
-                    for(BaseRailwayManagement dbRailway:dbRailways){
-                        //把线路名称和编码放入缓存
-                        redisCache.setCacheObject(dbRailway.getRailwayCode(),dbRailway.getRailwayName());
-                    }
-                    //获取缓存中的报警的相机数据
-                    Set<Object> hashAlarmKeys = redisService.redisTemplate.opsForHash().keys(CAMERA_ALARM_HASH);
-                    //获取缓存中的非报警的相机数据
-                    Set<Object> hashNormalKeys = redisService.redisTemplate.opsForHash().keys(CAMERA_NORMAL_HASH);
-                    // 数据库中存在的数据, 但是缓存中不存在, 则进行补全
-                    for (BaseCameraManagement dbAlarm : dbAlarms) {
-                        BaseCameraVO  vo = new BaseCameraVO();
-                        vo.setCameraCode(dbAlarm.getCameraCode());
-                        vo.setChannel(dbAlarm.getChannel());
-                        vo.setInstallMiles(AppendUtils.stringAppend(dbAlarm.getInstallMile()));
-                        vo.setRailwayName(redisCache.getCacheObject(dbAlarm.getRailwayCode()));
-                        vo.setNextExecuteTime(DateTime.now().toString("yyyy-MM-dd HH:mm:ss"));
-                        //如果未解除的报警摄像头集合包含该相机编码 且  缓存中的报警的相机数据不包含该相机
-                        if (lockedMsgAlarmCameraCodes.contains(vo.getCameraCode()) && !hashAlarmKeys.contains(vo.getCameraCode())) {
-                            vo.setIsAlarm(true);
-                            //把该相机相机信息放入报警相机缓存中
-                            redisService.addToHash(CAMERA_ALARM_HASH, vo.getCameraCode(), vo);
-                            //如果未解除的报警摄像头集合不包含该相机编码 且  缓存中的非报警的相机数据不包含该相机
-                        } else if (!lockedMsgAlarmCameraCodes.contains(vo.getCameraCode()) && !hashNormalKeys.contains(vo.getCameraCode())) {
-                            vo.setIsAlarm(false);
-                            //把该相机相机信息放入未报警相机缓存中
-                            redisService.addToHash(CAMERA_NORMAL_HASH, vo.getCameraCode(), vo);
-                        }
-                    }
-                    // 循环redis缓存中获取的报警集合 排除缓存中未删除, 但是系统中删除的情况
-                    for (Object hashAlarmKey : hashAlarmKeys) {
-                        //如果报警信息数据库不存在但报警缓存中存在, 则进行删除
-                        if(!lockedMsgAlarmCameraCodes.contains(hashAlarmKey)){
-                            redisService.redisTemplate.opsForHash().delete(CAMERA_ALARM_HASH, hashAlarmKey);
-                        }
-                        // 如果在数据库和缓存中都不存在, 则进行删除删除
-                        if (!hashAlarmKeys.contains(hashAlarmKey) && !hashNormalKeys.contains(hashAlarmKey)) {
-                            redisService.redisTemplate.opsForHash().delete(CAMERA_ALARM_HASH, hashAlarmKey);
-                            redisService.redisTemplate.opsForHash().delete(CAMERA_NORMAL_HASH, hashAlarmKey);
-                        } else if (hashAlarmKeys.contains(hashAlarmKey) && hashNormalKeys.contains(hashAlarmKey)) {  // 如果两个缓存中都存在, 则删除正常摄像头
-                            redisService.redisTemplate.opsForHash().delete(CAMERA_NORMAL_HASH, hashAlarmKey);
-                        }
-                    }
-                } else {
-                    // 如果未找到数据库数据, 则清空抓图摄像头集合
-                    redisService.redisTemplate.delete(CAMERA_ALARM_HASH);
-                    redisService.redisTemplate.delete(CAMERA_NORMAL_HASH);
-                }
-            } catch (Exception e) {
-                log.error("缓存 [摄像头抓图] 调度任务配置出现异常, ", e);
-            } finally {
-                redisTemplate.delete(LOCK_CAMELA_NORMAL_KEY);
-            }
-        }
-    }
-
-    /**
-     * 处理非预警摄像头截图, 间隔: 5s
-     */
-    @Scheduled(fixedDelay = 5 * 1000, initialDelay = 10 * 1000)
-    public void batchProcess() {
-        //如果截图开关是false直接返回
-        if (!isMaster) return;
-        // 填充默认路径
-        String address = storeAddress;
-        //获取截图开关
-        Integer status = redisCache.getCacheObject("shot_switch");
-        //如果截图开关为空
-        if(status == null){
-            //从字典中获取
-            List<SysDictData> dataList = iSysDictTypeService.selectDictDataByType("shot_switch");
-            if(CollectionUtils.isEmpty(dataList)){
-                //不执行
-                redisCache.setCacheObject("shot_switch",2);
-                status = redisCache.getCacheObject("shot_switch");
-            }else{
-                redisCache.setCacheObject("shot_switch",dataList.get(0).getStatus());
-                status = redisCache.getCacheObject("shot_switch");
-            }
-        }
-        // 判断开关是否执行
-        if (status != 1) {
-            return;
-        }
-        // 获取字典值: 截图存放路径
-        List<SysDictData> addressDataList = DictUtils.getDictCache("shot_address");
-        //如果 截图存放路径为空
-        if(CollectionUtils.isEmpty(addressDataList) || Objects.isNull(addressDataList.get(0))){
-            //把截图存放路径放入缓存
-            DictUtils.setDictCache("shot_address", addressDataList = iSysDictTypeService.selectDictDataByType("shot_address"));
-        }
-        //如果 截图存放路径不为空
-        if(!CollectionUtils.isEmpty(addressDataList) && Objects.nonNull(addressDataList.get(0))){
-            //截图存放路径赋值
-            address = addressDataList.get(0).getDictLabel();
-        }
-        // 设置路径地址为字典表最终值  获取缓存中的非报警的相机数据
-        Map<Object, Object> entries = redisService.redisTemplate.opsForHash().entries(CAMERA_NORMAL_HASH);
-        //如果不为空
-        if (!CollectionUtils.isEmpty(entries)) {
-            //赋值截图存放路径
-            final String finalAddress = address;
-            //循环非报警的相机数据
-            for (Map.Entry<Object, Object> entry : entries.entrySet()) {
-                BaseCameraVO item = (BaseCameraVO) entry.getValue();
-                //获取下次执行时间
-                DateTime nextExecuteTime = DateTime.of(item.getNextExecuteTime(), "yyyy-MM-dd HH:mm:ss");
-                //如果下一个执行时间是否为null  或 当前时间大于或等于下一个执行时间  或 下次执行时间是否距离当前时间超过5分钟 并且 状态是否为 "running"
-                boolean after = item.getNextExecuteTime() == null ||
-                        DateTime.now().isAfterOrEquals(nextExecuteTime) ||
-                        (nextExecuteTime.between(DateTime.now(), DateUnit.MINUTE) > 5 && "running".equalsIgnoreCase(item.getStatus()));
-                //下次执行时间 距离当前时间超过 5 分钟 并且
-                //确保 item 的状态是 "running"。
-                if ((nextExecuteTime.between(DateTime.now(), DateUnit.MINUTE) > 5 && "running".equalsIgnoreCase(item.getStatus()))) {
-                    //把状态设置成空
-                    item.setStatus("");
-                }
-                // after是真并且状态是空  或者   状态等于complete
-                if (after && (StringUtils.isBlank(item.getStatus()) || "complete".equalsIgnoreCase(item.getStatus()))) {
-                    Dict dict = new Dict();
-                    dict.put("cameraCode", item.getCameraCode());
-                    dict.put("channel", item.getChannel());
-                    dict.put("address", finalAddress);
-                    dict.put("railwayName", item.getRailwayName());
-                    dict.put("installMiles", item.getInstallMiles());
-                    dict.put("isAlarm", false);
-                    dict.put("nextExecuteTime", item.getNextExecuteTime());
-                    //调用方法
-                    redisPushService.pushMsg(JSONUtil.toJsonStr(dict));
-                }
-            }
-        }
-    }
-
-    /**
-     * 处理预警摄像头截图, 间隔: 1s
-     */
-    @Scheduled(fixedDelay = 1 * 1000, initialDelay = 10 * 1000)
-    public void batchAlarmProcess() {
-        if (!isMaster) return;
-        // 填充默认路径
-        String address = storeAddress;
-        //获取截图开关
-        Integer status = redisCache.getCacheObject("shot_switch");
-        if(status == null){
-            List<SysDictData> dataList = iSysDictTypeService.selectDictDataByType("shot_switch");
-            if(CollectionUtils.isEmpty(dataList)){
-                redisCache.setCacheObject("shot_switch",2);
-                status = redisCache.getCacheObject("shot_switch");
-            }else{
-                redisCache.setCacheObject("shot_switch",dataList.get(0).getStatus());
-                status = redisCache.getCacheObject("shot_switch");
-            }
-        }
-        // 判断开关是否执行
-        if (status != 1) {
-            return;
-        }
-        // 获取字典值: 截图存放路径
-        List<SysDictData> addressDataList = DictUtils.getDictCache("shot_address");
-        if(CollectionUtils.isEmpty(addressDataList) || Objects.isNull(addressDataList.get(0))){
-            DictUtils.setDictCache("shot_address", addressDataList = iSysDictTypeService.selectDictDataByType("shot_address"));
-        }
-        if(!CollectionUtils.isEmpty(addressDataList) && Objects.nonNull(addressDataList.get(0))){
-            address = addressDataList.get(0).getDictLabel();
-        }
-        Map<Object, Object> alarmEntries = redisService.redisTemplate.opsForHash().entries(CAMERA_ALARM_HASH);
-        if (!CollectionUtils.isEmpty(alarmEntries)) {
-            final String finalAddress = address;
-            for (Map.Entry<Object, Object> entry : alarmEntries.entrySet()) {
-                BaseCameraVO item = (BaseCameraVO) entry.getValue();
-                DateTime nextExecuteTime = DateTime.of(item.getNextExecuteTime(), "yyyy-MM-dd HH:mm:ss");
-                boolean after = item.getNextExecuteTime() == null ||
-                        DateTime.now().isAfterOrEquals(nextExecuteTime) ||
-                        (nextExecuteTime.between(DateTime.now(), DateUnit.MINUTE) > 5 && "running".equalsIgnoreCase(item.getStatus()));
-                if ((nextExecuteTime.between(DateTime.now(), DateUnit.MINUTE) > 5 && "running".equalsIgnoreCase(item.getStatus()))) {
-                    item.setStatus("");
-                }
-                if (after && (StringUtils.isBlank(item.getStatus()) || "complete".equalsIgnoreCase(item.getStatus()))) {
-                    Dict dict = new Dict();
-                    dict.put("cameraCode", item.getCameraCode());
-                    dict.put("channel", item.getChannel());
-                    dict.put("address", finalAddress);
-                    dict.put("railwayName", item.getRailwayName());
-                    dict.put("installMiles", item.getInstallMiles());
-                    dict.put("isAlarm", true);
-                    dict.put("nextExecuteTime", item.getNextExecuteTime());
-                    redisPushService.pushMsg(JSONUtil.toJsonStr(dict));
-                }
-            }
-        }
-    }
+//    @Value("${shot.storeAddress}")
+//    private String storeAddress;
+//
+//    @Value("${shot.isMaster}")
+//    private Boolean isMaster;
+//
+//    /**
+//     * Redis 缓存服务提供类
+//     */
+//    @Resource
+//    private RedisService redisService;
+//
+//    @Resource
+//    public RedisTemplate<String, String> redisTemplate;
+//
+//    @Resource
+//    private ISysDictTypeService iSysDictTypeService;
+//
+//    @Resource
+//    private RedisPushService redisPushService;
+//
+//    @Resource
+//    private MsgAlarmMapper msgAlarmMapper;
+//
+//    @Resource
+//    private BaseCameraManagementMapper baseCameraManagementMapper;
+//
+//    @Resource
+//    private BaseRailwayManagementMapper baseRailwayManagementMapper;
+//    @Autowired
+//    RedisCache redisCache;
+//
+//
+//    /**
+//     * REDIS 抓拍摄像头分布式锁
+//     */
+//    private final static String LOCK_CAMELA_NORMAL_KEY = "lock_camela_normal";
+//
+//    public static final String CAMERA_ALARM_HASH = "camera_alarm_hash";
+//    public static final String CAMERA_NORMAL_HASH = "camera_normal_hash";
+//
+//    public final static AtomicInteger RUNNING_ATOMIC_INT = new AtomicInteger(0);
+//
+//    /**
+//     * 处理非预警摄像头截图, 间隔: 60s
+//     */
+//    @Async
+//    @Scheduled(fixedDelay = 60 * 1000, initialDelay = 3 * 1000)
+//    public synchronized void initCameraConfig() {
+//        if (!isMaster) return;
+//        // 获取分布式锁
+//        boolean lockSuccess = redisTemplate.opsForValue().setIfAbsent(LOCK_CAMELA_NORMAL_KEY, "execute", Duration.ofSeconds(60));
+//        if (lockSuccess) {
+//            // 查询未解除的报警摄像头(报警摄像头逻辑沿用wangyy代码)
+//            List<String> lockedMsgAlarmCameraCodes = msgAlarmMapper.selectList(new QueryWrapper<MsgAlarm>().eq("is_lock", 2))
+//                    .stream().map(f -> f.getCameraCode()).distinct().collect(Collectors.toList());
+//            try {
+//                QueryWrapper<BaseCameraManagement> queryWrapper = new QueryWrapper<>();
+//                queryWrapper.select("distinct camera_code, channel,railway_code,install_mile");
+//                // 获取数据库中最新摄像头相关内容
+//                List<BaseCameraManagement> dbAlarms = baseCameraManagementMapper.selectList(queryWrapper).stream().collect(Collectors.toList());
+//                List<BaseRailwayManagement> dbRailways = baseRailwayManagementMapper.selectList(null);
+//                //如果相机表不为空
+//                if (!CollectionUtils.isEmpty(dbAlarms)) {
+//                    //循环线路集合
+//                    for(BaseRailwayManagement dbRailway:dbRailways){
+//                        //把线路名称和编码放入缓存
+//                        redisCache.setCacheObject(dbRailway.getRailwayCode(),dbRailway.getRailwayName());
+//                    }
+//                    //获取缓存中的报警的相机数据
+//                    Set<Object> hashAlarmKeys = redisService.redisTemplate.opsForHash().keys(CAMERA_ALARM_HASH);
+//                    //获取缓存中的非报警的相机数据
+//                    Set<Object> hashNormalKeys = redisService.redisTemplate.opsForHash().keys(CAMERA_NORMAL_HASH);
+//                    // 数据库中存在的数据, 但是缓存中不存在, 则进行补全
+//                    for (BaseCameraManagement dbAlarm : dbAlarms) {
+//                        BaseCameraVO  vo = new BaseCameraVO();
+//                        vo.setCameraCode(dbAlarm.getCameraCode());
+//                        vo.setChannel(dbAlarm.getChannel());
+//                        vo.setInstallMiles(AppendUtils.stringAppend(dbAlarm.getInstallMile()));
+//                        vo.setRailwayName(redisCache.getCacheObject(dbAlarm.getRailwayCode()));
+//                        vo.setNextExecuteTime(DateTime.now().toString("yyyy-MM-dd HH:mm:ss"));
+//                        //如果未解除的报警摄像头集合包含该相机编码 且  缓存中的报警的相机数据不包含该相机
+//                        if (lockedMsgAlarmCameraCodes.contains(vo.getCameraCode()) && !hashAlarmKeys.contains(vo.getCameraCode())) {
+//                            vo.setIsAlarm(true);
+//                            //把该相机相机信息放入报警相机缓存中
+//                            redisService.addToHash(CAMERA_ALARM_HASH, vo.getCameraCode(), vo);
+//                            //如果未解除的报警摄像头集合不包含该相机编码 且  缓存中的非报警的相机数据不包含该相机
+//                        } else if (!lockedMsgAlarmCameraCodes.contains(vo.getCameraCode()) && !hashNormalKeys.contains(vo.getCameraCode())) {
+//                            vo.setIsAlarm(false);
+//                            //把该相机相机信息放入未报警相机缓存中
+//                            redisService.addToHash(CAMERA_NORMAL_HASH, vo.getCameraCode(), vo);
+//                        }
+//                    }
+//                    // 循环redis缓存中获取的报警集合 排除缓存中未删除, 但是系统中删除的情况
+//                    for (Object hashAlarmKey : hashAlarmKeys) {
+//                        //如果报警信息数据库不存在但报警缓存中存在, 则进行删除
+//                        if(!lockedMsgAlarmCameraCodes.contains(hashAlarmKey)){
+//                            redisService.redisTemplate.opsForHash().delete(CAMERA_ALARM_HASH, hashAlarmKey);
+//                        }
+//                        // 如果在数据库和缓存中都不存在, 则进行删除删除
+//                        if (!hashAlarmKeys.contains(hashAlarmKey) && !hashNormalKeys.contains(hashAlarmKey)) {
+//                            redisService.redisTemplate.opsForHash().delete(CAMERA_ALARM_HASH, hashAlarmKey);
+//                            redisService.redisTemplate.opsForHash().delete(CAMERA_NORMAL_HASH, hashAlarmKey);
+//                        } else if (hashAlarmKeys.contains(hashAlarmKey) && hashNormalKeys.contains(hashAlarmKey)) {  // 如果两个缓存中都存在, 则删除正常摄像头
+//                            redisService.redisTemplate.opsForHash().delete(CAMERA_NORMAL_HASH, hashAlarmKey);
+//                        }
+//                    }
+//                } else {
+//                    // 如果未找到数据库数据, 则清空抓图摄像头集合
+//                    redisService.redisTemplate.delete(CAMERA_ALARM_HASH);
+//                    redisService.redisTemplate.delete(CAMERA_NORMAL_HASH);
+//                }
+//            } catch (Exception e) {
+//                log.error("缓存 [摄像头抓图] 调度任务配置出现异常, ", e);
+//            } finally {
+//                redisTemplate.delete(LOCK_CAMELA_NORMAL_KEY);
+//            }
+//        }
+//    }
+//
+//    /**
+//     * 处理非预警摄像头截图, 间隔: 5s
+//     */
+//    @Scheduled(fixedDelay = 5 * 1000, initialDelay = 10 * 1000)
+//    public void batchProcess() {
+//        //如果截图开关是false直接返回
+//        if (!isMaster) return;
+//        // 填充默认路径
+//        String address = storeAddress;
+//        //获取截图开关
+//        Integer status = redisCache.getCacheObject("shot_switch");
+//        //如果截图开关为空
+//        if(status == null){
+//            //从字典中获取
+//            List<SysDictData> dataList = iSysDictTypeService.selectDictDataByType("shot_switch");
+//            if(CollectionUtils.isEmpty(dataList)){
+//                //不执行
+//                redisCache.setCacheObject("shot_switch",2);
+//                status = redisCache.getCacheObject("shot_switch");
+//            }else{
+//                redisCache.setCacheObject("shot_switch",dataList.get(0).getStatus());
+//                status = redisCache.getCacheObject("shot_switch");
+//            }
+//        }
+//        // 判断开关是否执行
+//        if (status != 1) {
+//            return;
+//        }
+//        // 获取字典值: 截图存放路径
+//        List<SysDictData> addressDataList = DictUtils.getDictCache("shot_address");
+//        //如果 截图存放路径为空
+//        if(CollectionUtils.isEmpty(addressDataList) || Objects.isNull(addressDataList.get(0))){
+//            //把截图存放路径放入缓存
+//            DictUtils.setDictCache("shot_address", addressDataList = iSysDictTypeService.selectDictDataByType("shot_address"));
+//        }
+//        //如果 截图存放路径不为空
+//        if(!CollectionUtils.isEmpty(addressDataList) && Objects.nonNull(addressDataList.get(0))){
+//            //截图存放路径赋值
+//            address = addressDataList.get(0).getDictLabel();
+//        }
+//        // 设置路径地址为字典表最终值  获取缓存中的非报警的相机数据
+//        Map<Object, Object> entries = redisService.redisTemplate.opsForHash().entries(CAMERA_NORMAL_HASH);
+//        //如果不为空
+//        if (!CollectionUtils.isEmpty(entries)) {
+//            //赋值截图存放路径
+//            final String finalAddress = address;
+//            //循环非报警的相机数据
+//            for (Map.Entry<Object, Object> entry : entries.entrySet()) {
+//                BaseCameraVO item = (BaseCameraVO) entry.getValue();
+//                //获取下次执行时间
+//                DateTime nextExecuteTime = DateTime.of(item.getNextExecuteTime(), "yyyy-MM-dd HH:mm:ss");
+//                //如果下一个执行时间是否为null  或 当前时间大于或等于下一个执行时间  或 下次执行时间是否距离当前时间超过5分钟 并且 状态是否为 "running"
+//                boolean after = item.getNextExecuteTime() == null ||
+//                        DateTime.now().isAfterOrEquals(nextExecuteTime) ||
+//                        (nextExecuteTime.between(DateTime.now(), DateUnit.MINUTE) > 5 && "running".equalsIgnoreCase(item.getStatus()));
+//                //下次执行时间 距离当前时间超过 5 分钟 并且
+//                //确保 item 的状态是 "running"。
+//                if ((nextExecuteTime.between(DateTime.now(), DateUnit.MINUTE) > 5 && "running".equalsIgnoreCase(item.getStatus()))) {
+//                    //把状态设置成空
+//                    item.setStatus("");
+//                }
+//                // after是真并且状态是空  或者   状态等于complete
+//                if (after && (StringUtils.isBlank(item.getStatus()) || "complete".equalsIgnoreCase(item.getStatus()))) {
+//                    Dict dict = new Dict();
+//                    dict.put("cameraCode", item.getCameraCode());
+//                    dict.put("channel", item.getChannel());
+//                    dict.put("address", finalAddress);
+//                    dict.put("railwayName", item.getRailwayName());
+//                    dict.put("installMiles", item.getInstallMiles());
+//                    dict.put("isAlarm", false);
+//                    dict.put("nextExecuteTime", item.getNextExecuteTime());
+//                    //调用方法
+//                    redisPushService.pushMsg(JSONUtil.toJsonStr(dict));
+//                }
+//            }
+//        }
+//    }
+//
+//    /**
+//     * 处理预警摄像头截图, 间隔: 1s
+//     */
+//    @Scheduled(fixedDelay = 1 * 1000, initialDelay = 10 * 1000)
+//    public void batchAlarmProcess() {
+//        if (!isMaster) return;
+//        // 填充默认路径
+//        String address = storeAddress;
+//        //获取截图开关
+//        Integer status = redisCache.getCacheObject("shot_switch");
+//        if(status == null){
+//            List<SysDictData> dataList = iSysDictTypeService.selectDictDataByType("shot_switch");
+//            if(CollectionUtils.isEmpty(dataList)){
+//                redisCache.setCacheObject("shot_switch",2);
+//                status = redisCache.getCacheObject("shot_switch");
+//            }else{
+//                redisCache.setCacheObject("shot_switch",dataList.get(0).getStatus());
+//                status = redisCache.getCacheObject("shot_switch");
+//            }
+//        }
+//        // 判断开关是否执行
+//        if (status != 1) {
+//            return;
+//        }
+//        // 获取字典值: 截图存放路径
+//        List<SysDictData> addressDataList = DictUtils.getDictCache("shot_address");
+//        if(CollectionUtils.isEmpty(addressDataList) || Objects.isNull(addressDataList.get(0))){
+//            DictUtils.setDictCache("shot_address", addressDataList = iSysDictTypeService.selectDictDataByType("shot_address"));
+//        }
+//        if(!CollectionUtils.isEmpty(addressDataList) && Objects.nonNull(addressDataList.get(0))){
+//            address = addressDataList.get(0).getDictLabel();
+//        }
+//        Map<Object, Object> alarmEntries = redisService.redisTemplate.opsForHash().entries(CAMERA_ALARM_HASH);
+//        if (!CollectionUtils.isEmpty(alarmEntries)) {
+//            final String finalAddress = address;
+//            for (Map.Entry<Object, Object> entry : alarmEntries.entrySet()) {
+//                BaseCameraVO item = (BaseCameraVO) entry.getValue();
+//                DateTime nextExecuteTime = DateTime.of(item.getNextExecuteTime(), "yyyy-MM-dd HH:mm:ss");
+//                boolean after = item.getNextExecuteTime() == null ||
+//                        DateTime.now().isAfterOrEquals(nextExecuteTime) ||
+//                        (nextExecuteTime.between(DateTime.now(), DateUnit.MINUTE) > 5 && "running".equalsIgnoreCase(item.getStatus()));
+//                if ((nextExecuteTime.between(DateTime.now(), DateUnit.MINUTE) > 5 && "running".equalsIgnoreCase(item.getStatus()))) {
+//                    item.setStatus("");
+//                }
+//                if (after && (StringUtils.isBlank(item.getStatus()) || "complete".equalsIgnoreCase(item.getStatus()))) {
+//                    Dict dict = new Dict();
+//                    dict.put("cameraCode", item.getCameraCode());
+//                    dict.put("channel", item.getChannel());
+//                    dict.put("address", finalAddress);
+//                    dict.put("railwayName", item.getRailwayName());
+//                    dict.put("installMiles", item.getInstallMiles());
+//                    dict.put("isAlarm", true);
+//                    dict.put("nextExecuteTime", item.getNextExecuteTime());
+//                    redisPushService.pushMsg(JSONUtil.toJsonStr(dict));
+//                }
+//            }
+//        }
+//    }
 }

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

@@ -32,112 +32,112 @@ import java.util.Set;
 @Slf4j
 @Service
 public class TaskService {
-    @Resource
-    MsgAlarmService msgAlarmService;
-    @Resource
-    CameraCaptureService cameraCaptureService;
-    @Value("${shot.urlAddress}")
-    private String urlAddress;
-    @Value("${shot.storeAddress}")
-    private String storeAddress;
-    @Autowired
-    private ISysDictTypeService iSysDictTypeService;
-    @Autowired
-    private RedisService redisService;
-
-    public void getNormalPicture() {
-        String address = storeAddress;
-        List<SysDictData> addressDataList = DictUtils.getDictCache("shot_address");
-        if(CollectionUtils.isEmpty(addressDataList) || Objects.isNull(addressDataList.get(0))){
-            addressDataList = iSysDictTypeService.selectDictDataByType("shot_address");
-            DictUtils.setDictCache("shot_address",addressDataList);
-        }
-        if(!CollectionUtils.isEmpty(addressDataList) && Objects.nonNull(addressDataList.get(0))){
-                address = addressDataList.get(0).getDictLabel();
-        }
-        boolean isHasKeyNormal = redisService.hasKey(Constants.NORMAL_SET);
-        if(!isHasKeyNormal){
-            msgAlarmService.initializationCameraCache();
-        }
-        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
-        Set<BaseCameraVO> normalSet = redisService.getSetMembers(Constants.NORMAL_SET);
-        if (log.isDebugEnabled()) {
-            log.debug("正常摄像机数量:"+normalSet.size());
-        }
-        if (!CollectionUtils.isEmpty(normalSet)) {
-            String finalAddress = address;
-            normalSet.forEach(item -> {
-                String uuid = IdUtils.fastSimpleUUID();
-                if (!ObjectUtils.isEmpty(item.getCameraCode())) {
-                    try {
-                        if (log.isDebugEnabled()) {
-                            log.debug("请求url======" + urlAddress + item.getCameraCode() + "/" + item.getChannel());
-                        }
-                        URL url = new URL(urlAddress + item.getCameraCode() + "/" + item.getChannel());
-                        String dateString = sdf.format(new Date());
-                        String fileName = finalAddress + "/" + "normal" + "/" + dateString + "/" + uuid + ".jpeg";
-                        if (log.isDebugEnabled()) {
-                            log.debug("fileName======" + fileName);
-                            log.debug("正常摄像头截图开始");
-                        }
-                        cameraCaptureService.getCapture(url, fileName);
-                        if (log.isDebugEnabled()) {
-                            log.debug("正常摄像头截图结束");
-                        }
-                    } catch (Throwable e) {
-                        log.error("正常摄像头截图异常",e);
-                    }
-                }
-            });
-        }
-    }
-
-    public void getAlarmPicture() {
-        String address = storeAddress;
-        List<SysDictData> addressDataList = DictUtils.getDictCache("shot_address");
-        if(CollectionUtils.isEmpty(addressDataList) || Objects.isNull(addressDataList.get(0))){
-            addressDataList = iSysDictTypeService.selectDictDataByType("shot_address");
-            DictUtils.setDictCache("shot_address",addressDataList);
-        }
-        if(!CollectionUtils.isEmpty(addressDataList) && Objects.nonNull(addressDataList.get(0))){
-            address = addressDataList.get(0).getDictLabel();
-        }
-        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
-        boolean isHasKeyAlarm = redisService.hasKey(Constants.ALARM_SET);
-        if(!isHasKeyAlarm){
-            msgAlarmService.initializationCameraCache();
-        }
-        Set<BaseCameraVO> alarmSet = redisService.getSetMembers(Constants.ALARM_SET);
-        if (log.isDebugEnabled()) {
-            log.debug("报警摄像机数量:"+alarmSet.size());
-        }
-        if(!CollectionUtils.isEmpty(alarmSet)){
-            String finalAddress = address;
-            alarmSet.forEach(item -> {
-                String uuid = IdUtils.fastSimpleUUID();
-                if(!ObjectUtils.isEmpty(item.getCameraCode())) {
-                    try {
-                        if (log.isDebugEnabled()) {
-                            log.debug("请求url======" + urlAddress + item.getCameraCode() + "/" + item.getChannel());
-                        }
-                        URL url = new URL(urlAddress + item.getCameraCode() + "/" + item.getChannel());
-                        String dateString = sdf.format(new Date());
-                        String fileName = finalAddress + "/" + "alarm" + "/" + dateString + "/" + uuid + ".jpeg";
-                        if (log.isDebugEnabled()) {
-                            log.debug("fileName======" + fileName);
-                            log.debug("报警摄像头截图开始");
-                        }
-                        cameraCaptureService.getCapture(url, fileName);
-                        if (log.isDebugEnabled()) {
-                            log.debug("报警摄像头截图结束");
-                        }
-
-                    } catch (Throwable e) {
-                        log.error("报警摄像头截图异常",e);
-                    }
-                }
-            });
-        }
-    }
+//    @Resource
+//    MsgAlarmService msgAlarmService;
+//    @Resource
+//    CameraCaptureService cameraCaptureService;
+//    @Value("${shot.urlAddress}")
+//    private String urlAddress;
+//    @Value("${shot.storeAddress}")
+//    private String storeAddress;
+//    @Autowired
+//    private ISysDictTypeService iSysDictTypeService;
+//    @Autowired
+//    private RedisService redisService;
+//
+//    public void getNormalPicture() {
+//        String address = storeAddress;
+//        List<SysDictData> addressDataList = DictUtils.getDictCache("shot_address");
+//        if(CollectionUtils.isEmpty(addressDataList) || Objects.isNull(addressDataList.get(0))){
+//            addressDataList = iSysDictTypeService.selectDictDataByType("shot_address");
+//            DictUtils.setDictCache("shot_address",addressDataList);
+//        }
+//        if(!CollectionUtils.isEmpty(addressDataList) && Objects.nonNull(addressDataList.get(0))){
+//                address = addressDataList.get(0).getDictLabel();
+//        }
+//        boolean isHasKeyNormal = redisService.hasKey(Constants.NORMAL_SET);
+//        if(!isHasKeyNormal){
+//            msgAlarmService.initializationCameraCache();
+//        }
+//        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+//        Set<BaseCameraVO> normalSet = redisService.getSetMembers(Constants.NORMAL_SET);
+//        if (log.isDebugEnabled()) {
+//            log.debug("正常摄像机数量:"+normalSet.size());
+//        }
+//        if (!CollectionUtils.isEmpty(normalSet)) {
+//            String finalAddress = address;
+//            normalSet.forEach(item -> {
+//                String uuid = IdUtils.fastSimpleUUID();
+//                if (!ObjectUtils.isEmpty(item.getCameraCode())) {
+//                    try {
+//                        if (log.isDebugEnabled()) {
+//                            log.debug("请求url======" + urlAddress + item.getCameraCode() + "/" + item.getChannel());
+//                        }
+//                        URL url = new URL(urlAddress + item.getCameraCode() + "/" + item.getChannel());
+//                        String dateString = sdf.format(new Date());
+//                        String fileName = finalAddress + "/" + "normal" + "/" + dateString + "/" + uuid + ".jpeg";
+//                        if (log.isDebugEnabled()) {
+//                            log.debug("fileName======" + fileName);
+//                            log.debug("正常摄像头截图开始");
+//                        }
+//                        cameraCaptureService.getCapture(url, fileName);
+//                        if (log.isDebugEnabled()) {
+//                            log.debug("正常摄像头截图结束");
+//                        }
+//                    } catch (Throwable e) {
+//                        log.error("正常摄像头截图异常",e);
+//                    }
+//                }
+//            });
+//        }
+//    }
+//
+//    public void getAlarmPicture() {
+//        String address = storeAddress;
+//        List<SysDictData> addressDataList = DictUtils.getDictCache("shot_address");
+//        if(CollectionUtils.isEmpty(addressDataList) || Objects.isNull(addressDataList.get(0))){
+//            addressDataList = iSysDictTypeService.selectDictDataByType("shot_address");
+//            DictUtils.setDictCache("shot_address",addressDataList);
+//        }
+//        if(!CollectionUtils.isEmpty(addressDataList) && Objects.nonNull(addressDataList.get(0))){
+//            address = addressDataList.get(0).getDictLabel();
+//        }
+//        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+//        boolean isHasKeyAlarm = redisService.hasKey(Constants.ALARM_SET);
+//        if(!isHasKeyAlarm){
+//            msgAlarmService.initializationCameraCache();
+//        }
+//        Set<BaseCameraVO> alarmSet = redisService.getSetMembers(Constants.ALARM_SET);
+//        if (log.isDebugEnabled()) {
+//            log.debug("报警摄像机数量:"+alarmSet.size());
+//        }
+//        if(!CollectionUtils.isEmpty(alarmSet)){
+//            String finalAddress = address;
+//            alarmSet.forEach(item -> {
+//                String uuid = IdUtils.fastSimpleUUID();
+//                if(!ObjectUtils.isEmpty(item.getCameraCode())) {
+//                    try {
+//                        if (log.isDebugEnabled()) {
+//                            log.debug("请求url======" + urlAddress + item.getCameraCode() + "/" + item.getChannel());
+//                        }
+//                        URL url = new URL(urlAddress + item.getCameraCode() + "/" + item.getChannel());
+//                        String dateString = sdf.format(new Date());
+//                        String fileName = finalAddress + "/" + "alarm" + "/" + dateString + "/" + uuid + ".jpeg";
+//                        if (log.isDebugEnabled()) {
+//                            log.debug("fileName======" + fileName);
+//                            log.debug("报警摄像头截图开始");
+//                        }
+//                        cameraCaptureService.getCapture(url, fileName);
+//                        if (log.isDebugEnabled()) {
+//                            log.debug("报警摄像头截图结束");
+//                        }
+//
+//                    } catch (Throwable e) {
+//                        log.error("报警摄像头截图异常",e);
+//                    }
+//                }
+//            });
+//        }
+//    }
 
 }