|
@@ -98,185 +98,185 @@ public class ShotPictureTaskExecutors {
|
|
|
*/
|
|
|
// @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);
|
|
|
-// }
|
|
|
-// }
|
|
|
-// // 排除缓存中未删除, 但是系统中删除的情况
|
|
|
-// 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)) { // 如果存在于报警SET中, 则删除正常摄像头
|
|
|
-// 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() {
|
|
|
-// 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");
|
|
|
-// 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", 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));
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 排除缓存中未删除, 但是系统中删除的情况
|
|
|
+ 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)) { // 如果存在于报警SET中, 则删除正常摄像头
|
|
|
+ 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() {
|
|
|
+ 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");
|
|
|
+ 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", 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));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|