修复定时录像删除

This commit is contained in:
648540858 2023-11-24 10:47:33 +08:00
parent 29ef68038d
commit ffc8a530f3
4 changed files with 7 additions and 8 deletions

View File

@ -41,12 +41,12 @@ public class CloudRecordTimer {
/** /**
* 定时查询待删除的录像文件 * 定时查询待删除的录像文件
*/ */
// @Scheduled(fixedRate = 5000) //每五秒执行一次方便测试 // @Scheduled(fixedRate = 10000) //每五秒执行一次方便测试
@Scheduled(cron = "0 0 0 * * ?") //每天的0点执行 @Scheduled(cron = "0 0 0 * * ?") //每天的0点执行
public void execute(){ public void execute(){
logger.info("[录像文件定时清理] 开始清理过期录像文件"); logger.info("[录像文件定时清理] 开始清理过期录像文件");
// 获取配置了assist的流媒体节点 // 获取配置了assist的流媒体节点
List<MediaServerItem> mediaServerItemList = mediaServerService.getAllWithAssistPort(); List<MediaServerItem> mediaServerItemList = mediaServerService.getAllOnline();
if (mediaServerItemList.isEmpty()) { if (mediaServerItemList.isEmpty()) {
return; return;
} }
@ -70,8 +70,7 @@ public class CloudRecordTimer {
String date = new File(cloudRecordItem.getFilePath()).getParentFile().getName(); String date = new File(cloudRecordItem.getFilePath()).getParentFile().getName();
JSONObject jsonObject = zlmresTfulUtils.deleteRecordDirectory(mediaServerItem, cloudRecordItem.getApp(), JSONObject jsonObject = zlmresTfulUtils.deleteRecordDirectory(mediaServerItem, cloudRecordItem.getApp(),
cloudRecordItem.getStream(), date, cloudRecordItem.getFileName()); cloudRecordItem.getStream(), date, cloudRecordItem.getFileName());
if (jsonObject.getInteger("code") == 0) { if (jsonObject.getInteger("code") != 0) {
}else {
logger.warn("[录像文件定时清理] 删除磁盘文件错误: {}:{}", cloudRecordItem.getFilePath(), jsonObject); logger.warn("[录像文件定时清理] 删除磁盘文件错误: {}:{}", cloudRecordItem.getFilePath(), jsonObject);
} }
} }

View File

@ -81,8 +81,8 @@ public class MediaConfig{
@Value("${media.record-assist-port:0}") @Value("${media.record-assist-port:0}")
private Integer recordAssistPort = 0; private Integer recordAssistPort = 0;
@Value("${media.record-date:7}") @Value("${media.record-day:7}")
private Integer recordDay = 7; private Integer recordDay;
@Value("${media.record-path}") @Value("${media.record-path}")
private String recordPath; private String recordPath;

View File

@ -101,7 +101,7 @@ public interface CloudRecordServiceMapper {
int changeCollectById(@Param("collect") boolean collect, @Param("recordId") Integer recordId); int changeCollectById(@Param("collect") boolean collect, @Param("recordId") Integer recordId);
@Delete(" <script>" + @Delete(" <script>" +
"delete from wvp_cloud_record where media_server_id=#{mediaServerId} and id in " + "delete from wvp_cloud_record where id in " +
" <foreach collection='cloudRecordItemIdList' item='item' open='(' separator=',' close=')' > #{item.id}</foreach>" + " <foreach collection='cloudRecordItemIdList' item='item' open='(' separator=',' close=')' > #{item.id}</foreach>" +
" </script>") " </script>")
int deleteList(List<CloudRecordItem> cloudRecordItemIdList); int deleteList(List<CloudRecordItem> cloudRecordItemIdList);

View File

@ -155,7 +155,7 @@ media:
# 录像路径 # 录像路径
record-path: ./www/record record-path: ./www/record
# 录像保存时长 # 录像保存时长
record-date: 7 record-day: 7
# 启用多端口模式, 多端口模式使用端口区分每路流,兼容性更好。 单端口使用流的ssrc区分 点播超时建议使用多端口测试 # 启用多端口模式, 多端口模式使用端口区分每路流,兼容性更好。 单端口使用流的ssrc区分 点播超时建议使用多端口测试
rtp: rtp:
# [可选] 是否启用多端口模式, 开启后会在portRange范围内选择端口用于媒体流传输 # [可选] 是否启用多端口模式, 开启后会在portRange范围内选择端口用于媒体流传输