diff --git a/pom.xml b/pom.xml index d5c79101e..1b1832541 100644 --- a/pom.xml +++ b/pom.xml @@ -58,11 +58,11 @@ - + diff --git a/src/main/java/com/zhgd/xmgl/config/AsyncConfig.java b/src/main/java/com/zhgd/xmgl/config/AsyncConfig.java index b01772ba3..c1129c2f4 100644 --- a/src/main/java/com/zhgd/xmgl/config/AsyncConfig.java +++ b/src/main/java/com/zhgd/xmgl/config/AsyncConfig.java @@ -587,23 +587,23 @@ public class AsyncConfig { return executor; } - @Bean("saveVideoItemCover") - public ThreadPoolTaskExecutor saveVideoItemCoverExecutor() { - MdcThreadPoolTaskExecutor executor = new MdcThreadPoolTaskExecutor(); - /** 核心线程数(默认线程数) */ - executor.setCorePoolSize(1); - /** 最大线程数 */ - executor.setMaxPoolSize(1); - executor.setQueueCapacity(queueCapacity * 1000); - /** 允许线程空闲时间(单位:默认为秒) */ - executor.setKeepAliveSeconds(60); - /** 线程池名前缀 */ - executor.setThreadNamePrefix("saveVideoItemCoverExecutor-"); - // 线程池对拒绝任务的处理策略 - executor.setRejectedExecutionHandler(new ThreadPoolExecutor.AbortPolicy()); - // 初始化 - executor.initialize(); - return executor; - } +// @Bean("saveVideoItemCover") +// public ThreadPoolTaskExecutor saveVideoItemCoverExecutor() { +// MdcThreadPoolTaskExecutor executor = new MdcThreadPoolTaskExecutor(); +// /** 核心线程数(默认线程数) */ +// executor.setCorePoolSize(1); +// /** 最大线程数 */ +// executor.setMaxPoolSize(1); +// executor.setQueueCapacity(queueCapacity * 1000); +// /** 允许线程空闲时间(单位:默认为秒) */ +// executor.setKeepAliveSeconds(60); +// /** 线程池名前缀 */ +// executor.setThreadNamePrefix("saveVideoItemCoverExecutor-"); +// // 线程池对拒绝任务的处理策略 +// executor.setRejectedExecutionHandler(new ThreadPoolExecutor.AbortPolicy()); +// // 初始化 +// executor.initialize(); +// return executor; +// } } diff --git a/src/main/java/com/zhgd/xmgl/task/VideoItemTask.java b/src/main/java/com/zhgd/xmgl/task/VideoItemTask.java index 977e00282..242fd0ba7 100644 --- a/src/main/java/com/zhgd/xmgl/task/VideoItemTask.java +++ b/src/main/java/com/zhgd/xmgl/task/VideoItemTask.java @@ -214,46 +214,46 @@ public class VideoItemTask { } } } - - /** - * 每2个小时更新一下监控封面 - * - * @throws Exception - */ - @RequestMapping("saveVideoItemCover") - @SchedulerLock(name = "saveVideoItemCover", lockAtMostFor = 1000 * 60, lockAtLeastFor = 1000 * 60) - @Scheduled(cron = "0 0 */2 * * ?") - public void saveVideoItemCover() throws Exception { - List configList = projectVideoConfigService.list(new LambdaQueryWrapper() - .eq(ProjectVideoConfig::getIsEnable, 1)); - List itemList = videoItemService.list(); - String basePath = "videoItemCover"; - for (ProjectVideoConfig projectVideoConfig : configList) { - if (Objects.equals(projectVideoConfig.getVideoType(), 3)) { - List items = itemList.stream().filter(o -> Objects.equals(o.getVideoId(), projectVideoConfig.getId())).collect(Collectors.toList()); - for (VideoItem item : items) { - saveVideoItemCoverAsync(basePath, projectVideoConfig, item); - } - } - } - } - - @Async("saveVideoItemCover") - public void saveVideoItemCoverAsync(String basePath, ProjectVideoConfig projectVideoConfig, VideoItem item) throws Exception { - try { - String url = HikVideoUtil.callPostApiGetPreviewURL(item.getSerialNumber(), "rtsp", - 2, projectVideoConfig.getAccount(), - projectVideoConfig.getPassword(), projectVideoConfig.getAppId(), projectVideoConfig.getAppSecret()); - if (url != null) { - String uuidPic = IdUtil.fastUUID() + ".jpg"; - String picPath = PathUtil.getBasePath() + "/" + basePath + "/" + uuidPic; - new File(picPath).getParentFile().mkdirs(); - RtspUtils.getVideoImagePathByRSTP(url, picPath); - item.setCoverUrl(PathUtil.getServerUrl() + "/image/" + basePath + "/" + uuidPic); - videoItemService.updateById(item); - } - } catch (Exception e) { - e.printStackTrace(); - } - } +// +// /** +// * 每2个小时更新一下监控封面 +// * +// * @throws Exception +// */ +// @RequestMapping("saveVideoItemCover") +// @SchedulerLock(name = "saveVideoItemCover", lockAtMostFor = 1000 * 60, lockAtLeastFor = 1000 * 60) +// @Scheduled(cron = "0 0 */2 * * ?") +// public void saveVideoItemCover() throws Exception { +// List configList = projectVideoConfigService.list(new LambdaQueryWrapper() +// .eq(ProjectVideoConfig::getIsEnable, 1)); +// List itemList = videoItemService.list(); +// String basePath = "videoItemCover"; +// for (ProjectVideoConfig projectVideoConfig : configList) { +// if (Objects.equals(projectVideoConfig.getVideoType(), 3)) { +// List items = itemList.stream().filter(o -> Objects.equals(o.getVideoId(), projectVideoConfig.getId())).collect(Collectors.toList()); +// for (VideoItem item : items) { +// saveVideoItemCoverAsync(basePath, projectVideoConfig, item); +// } +// } +// } +// } +// +// @Async("saveVideoItemCover") +// public void saveVideoItemCoverAsync(String basePath, ProjectVideoConfig projectVideoConfig, VideoItem item) throws Exception { +// try { +// String url = HikVideoUtil.callPostApiGetPreviewURL(item.getSerialNumber(), "rtsp", +// 2, projectVideoConfig.getAccount(), +// projectVideoConfig.getPassword(), projectVideoConfig.getAppId(), projectVideoConfig.getAppSecret()); +// if (url != null) { +// String uuidPic = IdUtil.fastUUID() + ".jpg"; +// String picPath = PathUtil.getBasePath() + "/" + basePath + "/" + uuidPic; +// new File(picPath).getParentFile().mkdirs(); +// RtspUtils.getVideoImagePathByRSTP(url, picPath); +// item.setCoverUrl(PathUtil.getServerUrl() + "/image/" + basePath + "/" + uuidPic); +// videoItemService.updateById(item); +// } +// } catch (Exception e) { +// e.printStackTrace(); +// } +// } }