注释监控截图功能
This commit is contained in:
parent
e3f44e6948
commit
7bae930daa
4
pom.xml
4
pom.xml
@ -58,11 +58,11 @@
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<!-- <dependency>
|
||||
<groupId>org.bytedeco</groupId>
|
||||
<artifactId>javacv-platform</artifactId>
|
||||
<version>1.5.9</version>
|
||||
</dependency>
|
||||
</dependency>-->
|
||||
|
||||
<!-- 以spring-boot-starter的方式引用 -->
|
||||
<!--验证码-->
|
||||
|
||||
@ -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;
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
@ -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<ProjectVideoConfig> configList = projectVideoConfigService.list(new LambdaQueryWrapper<ProjectVideoConfig>()
|
||||
.eq(ProjectVideoConfig::getIsEnable, 1));
|
||||
List<VideoItem> itemList = videoItemService.list();
|
||||
String basePath = "videoItemCover";
|
||||
for (ProjectVideoConfig projectVideoConfig : configList) {
|
||||
if (Objects.equals(projectVideoConfig.getVideoType(), 3)) {
|
||||
List<VideoItem> 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<ProjectVideoConfig> configList = projectVideoConfigService.list(new LambdaQueryWrapper<ProjectVideoConfig>()
|
||||
// .eq(ProjectVideoConfig::getIsEnable, 1));
|
||||
// List<VideoItem> itemList = videoItemService.list();
|
||||
// String basePath = "videoItemCover";
|
||||
// for (ProjectVideoConfig projectVideoConfig : configList) {
|
||||
// if (Objects.equals(projectVideoConfig.getVideoType(), 3)) {
|
||||
// List<VideoItem> 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();
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user