注释监控截图功能
This commit is contained in:
parent
e3f44e6948
commit
7bae930daa
4
pom.xml
4
pom.xml
@ -58,11 +58,11 @@
|
|||||||
</repositories>
|
</repositories>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<!-- <dependency>
|
||||||
<groupId>org.bytedeco</groupId>
|
<groupId>org.bytedeco</groupId>
|
||||||
<artifactId>javacv-platform</artifactId>
|
<artifactId>javacv-platform</artifactId>
|
||||||
<version>1.5.9</version>
|
<version>1.5.9</version>
|
||||||
</dependency>
|
</dependency>-->
|
||||||
|
|
||||||
<!-- 以spring-boot-starter的方式引用 -->
|
<!-- 以spring-boot-starter的方式引用 -->
|
||||||
<!--验证码-->
|
<!--验证码-->
|
||||||
|
|||||||
@ -587,23 +587,23 @@ public class AsyncConfig {
|
|||||||
return executor;
|
return executor;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean("saveVideoItemCover")
|
// @Bean("saveVideoItemCover")
|
||||||
public ThreadPoolTaskExecutor saveVideoItemCoverExecutor() {
|
// public ThreadPoolTaskExecutor saveVideoItemCoverExecutor() {
|
||||||
MdcThreadPoolTaskExecutor executor = new MdcThreadPoolTaskExecutor();
|
// MdcThreadPoolTaskExecutor executor = new MdcThreadPoolTaskExecutor();
|
||||||
/** 核心线程数(默认线程数) */
|
// /** 核心线程数(默认线程数) */
|
||||||
executor.setCorePoolSize(1);
|
// executor.setCorePoolSize(1);
|
||||||
/** 最大线程数 */
|
// /** 最大线程数 */
|
||||||
executor.setMaxPoolSize(1);
|
// executor.setMaxPoolSize(1);
|
||||||
executor.setQueueCapacity(queueCapacity * 1000);
|
// executor.setQueueCapacity(queueCapacity * 1000);
|
||||||
/** 允许线程空闲时间(单位:默认为秒) */
|
// /** 允许线程空闲时间(单位:默认为秒) */
|
||||||
executor.setKeepAliveSeconds(60);
|
// executor.setKeepAliveSeconds(60);
|
||||||
/** 线程池名前缀 */
|
// /** 线程池名前缀 */
|
||||||
executor.setThreadNamePrefix("saveVideoItemCoverExecutor-");
|
// executor.setThreadNamePrefix("saveVideoItemCoverExecutor-");
|
||||||
// 线程池对拒绝任务的处理策略
|
// // 线程池对拒绝任务的处理策略
|
||||||
executor.setRejectedExecutionHandler(new ThreadPoolExecutor.AbortPolicy());
|
// executor.setRejectedExecutionHandler(new ThreadPoolExecutor.AbortPolicy());
|
||||||
// 初始化
|
// // 初始化
|
||||||
executor.initialize();
|
// executor.initialize();
|
||||||
return executor;
|
// return executor;
|
||||||
}
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -214,46 +214,46 @@ public class VideoItemTask {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* 每2个小时更新一下监控封面
|
// * 每2个小时更新一下监控封面
|
||||||
*
|
// *
|
||||||
* @throws Exception
|
// * @throws Exception
|
||||||
*/
|
// */
|
||||||
@RequestMapping("saveVideoItemCover")
|
// @RequestMapping("saveVideoItemCover")
|
||||||
@SchedulerLock(name = "saveVideoItemCover", lockAtMostFor = 1000 * 60, lockAtLeastFor = 1000 * 60)
|
// @SchedulerLock(name = "saveVideoItemCover", lockAtMostFor = 1000 * 60, lockAtLeastFor = 1000 * 60)
|
||||||
@Scheduled(cron = "0 0 */2 * * ?")
|
// @Scheduled(cron = "0 0 */2 * * ?")
|
||||||
public void saveVideoItemCover() throws Exception {
|
// public void saveVideoItemCover() throws Exception {
|
||||||
List<ProjectVideoConfig> configList = projectVideoConfigService.list(new LambdaQueryWrapper<ProjectVideoConfig>()
|
// List<ProjectVideoConfig> configList = projectVideoConfigService.list(new LambdaQueryWrapper<ProjectVideoConfig>()
|
||||||
.eq(ProjectVideoConfig::getIsEnable, 1));
|
// .eq(ProjectVideoConfig::getIsEnable, 1));
|
||||||
List<VideoItem> itemList = videoItemService.list();
|
// List<VideoItem> itemList = videoItemService.list();
|
||||||
String basePath = "videoItemCover";
|
// String basePath = "videoItemCover";
|
||||||
for (ProjectVideoConfig projectVideoConfig : configList) {
|
// for (ProjectVideoConfig projectVideoConfig : configList) {
|
||||||
if (Objects.equals(projectVideoConfig.getVideoType(), 3)) {
|
// if (Objects.equals(projectVideoConfig.getVideoType(), 3)) {
|
||||||
List<VideoItem> items = itemList.stream().filter(o -> Objects.equals(o.getVideoId(), projectVideoConfig.getId())).collect(Collectors.toList());
|
// List<VideoItem> items = itemList.stream().filter(o -> Objects.equals(o.getVideoId(), projectVideoConfig.getId())).collect(Collectors.toList());
|
||||||
for (VideoItem item : items) {
|
// for (VideoItem item : items) {
|
||||||
saveVideoItemCoverAsync(basePath, projectVideoConfig, item);
|
// saveVideoItemCoverAsync(basePath, projectVideoConfig, item);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Async("saveVideoItemCover")
|
// @Async("saveVideoItemCover")
|
||||||
public void saveVideoItemCoverAsync(String basePath, ProjectVideoConfig projectVideoConfig, VideoItem item) throws Exception {
|
// public void saveVideoItemCoverAsync(String basePath, ProjectVideoConfig projectVideoConfig, VideoItem item) throws Exception {
|
||||||
try {
|
// try {
|
||||||
String url = HikVideoUtil.callPostApiGetPreviewURL(item.getSerialNumber(), "rtsp",
|
// String url = HikVideoUtil.callPostApiGetPreviewURL(item.getSerialNumber(), "rtsp",
|
||||||
2, projectVideoConfig.getAccount(),
|
// 2, projectVideoConfig.getAccount(),
|
||||||
projectVideoConfig.getPassword(), projectVideoConfig.getAppId(), projectVideoConfig.getAppSecret());
|
// projectVideoConfig.getPassword(), projectVideoConfig.getAppId(), projectVideoConfig.getAppSecret());
|
||||||
if (url != null) {
|
// if (url != null) {
|
||||||
String uuidPic = IdUtil.fastUUID() + ".jpg";
|
// String uuidPic = IdUtil.fastUUID() + ".jpg";
|
||||||
String picPath = PathUtil.getBasePath() + "/" + basePath + "/" + uuidPic;
|
// String picPath = PathUtil.getBasePath() + "/" + basePath + "/" + uuidPic;
|
||||||
new File(picPath).getParentFile().mkdirs();
|
// new File(picPath).getParentFile().mkdirs();
|
||||||
RtspUtils.getVideoImagePathByRSTP(url, picPath);
|
// RtspUtils.getVideoImagePathByRSTP(url, picPath);
|
||||||
item.setCoverUrl(PathUtil.getServerUrl() + "/image/" + basePath + "/" + uuidPic);
|
// item.setCoverUrl(PathUtil.getServerUrl() + "/image/" + basePath + "/" + uuidPic);
|
||||||
videoItemService.updateById(item);
|
// videoItemService.updateById(item);
|
||||||
}
|
// }
|
||||||
} catch (Exception e) {
|
// } catch (Exception e) {
|
||||||
e.printStackTrace();
|
// e.printStackTrace();
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user