|
@@ -427,8 +427,9 @@ public class CameraUtil {
|
|
|
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
|
|
|
Date date = new Date();
|
|
|
+ String format = sdf.format(date);
|
|
|
Calendar calendar = new GregorianCalendar();
|
|
|
- calendar.setTime(date);
|
|
|
+ calendar.setTime(sdf.parse(format));
|
|
|
//正数,日期天数加
|
|
|
//负数,日期天数减 提前45天
|
|
|
if (!ObjectUtils.isEmpty(sysCameraRecordTime)) {
|
|
@@ -438,18 +439,15 @@ public class CameraUtil {
|
|
|
calendar.add(Calendar.DAY_OF_YEAR, -45);
|
|
|
}
|
|
|
date = calendar.getTime();
|
|
|
- log.info("date======================================" + sdf.format(date));
|
|
|
+ log.info("过期date======================================" + sdf.format(date));
|
|
|
//遍历每个进行视频录制的摄像头
|
|
|
File file = new File(transcribeFilePath);
|
|
|
- log.info("file.Name()======================================" + file.getName());
|
|
|
- log.info("file.exists()======================================" + file.exists());
|
|
|
if (file.exists() && file.isDirectory()) {
|
|
|
//获取文件夹中所有的子文件夹和文件
|
|
|
File[] files = file.listFiles();
|
|
|
if (!ObjectUtils.isEmpty(files) && files.length > 0) {
|
|
|
for (File file1 : files) {
|
|
|
// file1=/opt/streams/record/flv/34020000001320000167
|
|
|
- log.info("file1.Name()======================================" + file1.getName());
|
|
|
if (file1.exists() && file1.isDirectory()) {
|
|
|
//相机文件
|
|
|
File[] fs = file1.listFiles();
|
|
@@ -458,9 +456,9 @@ public class CameraUtil {
|
|
|
// f=/opt/streams/record/flv/34020000001320000167/20230328_192033_192037-91509173-cd5a-11ed-8a42-fa163e4e1e9f.flv
|
|
|
//fName=20230328_192033_192037-91509173-cd5a-11ed-8a42-fa163e4e1e9f.flv
|
|
|
String fName = f.getName();
|
|
|
- log.info("fName======================================" + fName);
|
|
|
String[] split = fName.split("_");
|
|
|
- if (split.length > 0) {
|
|
|
+ //没有进行分割长度就是1
|
|
|
+ if (split.length > 1) {
|
|
|
//20230328
|
|
|
String s = split[0];
|
|
|
Date parse = sdf.parse(s);
|
|
@@ -468,7 +466,10 @@ public class CameraUtil {
|
|
|
long dateTime = date.getTime();
|
|
|
//删除过期文件
|
|
|
if (fTime < dateTime) {
|
|
|
+ log.info("文件过期时间===========================" + dateTime);
|
|
|
+ log.info("该文件保存时间===========================" + fTime);
|
|
|
f.delete();
|
|
|
+ log.info("删除过期视频文件===========================" + fName);
|
|
|
}
|
|
|
}
|
|
|
}
|