|
@@ -6,6 +6,7 @@ import java.nio.file.Path;
|
|
import java.nio.file.Paths;
|
|
import java.nio.file.Paths;
|
|
import java.util.Arrays;
|
|
import java.util.Arrays;
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
|
|
+import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
@@ -273,4 +274,71 @@ public class VideoStableServiceImpl extends BaseServiceImpl<VideoStableMapper, V
|
|
updateById(videoStable);
|
|
updateById(videoStable);
|
|
return CommonResult.success();
|
|
return CommonResult.success();
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public HashMap<String, Object> getCompareNum(Long taskId) {
|
|
|
|
+ VideoStable videoStable = getById(taskId);
|
|
|
|
+
|
|
|
|
+ Path inputPath = null;
|
|
|
|
+ Path outputPath = null;
|
|
|
|
+ String osName = System.getProperty("os.name");
|
|
|
|
+ // 判断是否是Windows环境
|
|
|
|
+ if (osName.toLowerCase().contains("windows")) {
|
|
|
|
+ inputPath = Paths.get("C:", videoStable.getInputPath());
|
|
|
|
+ outputPath = Paths.get("C:", videoStable.getOutputPath());
|
|
|
|
+ } else {
|
|
|
|
+ inputPath = Paths.get(videoStable.getInputPath());
|
|
|
|
+ outputPath = Paths.get(videoStable.getOutputPath());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 创建File对象
|
|
|
|
+ File in_directory = new File(inputPath.toString());
|
|
|
|
+ File out_directory = new File(outputPath.toString());
|
|
|
|
+
|
|
|
|
+ // 调用方法获取文件数量
|
|
|
|
+ int in_fileCount = countFiles(in_directory);
|
|
|
|
+ int out_fileCount = countFiles(out_directory);
|
|
|
|
+
|
|
|
|
+ // 输出文件数量
|
|
|
|
+ log.info("inFileCount -> " + in_fileCount);
|
|
|
|
+ log.info("outFileCount -> " + out_fileCount);
|
|
|
|
+
|
|
|
|
+ HashMap<String, Object> map = new HashMap<>();
|
|
|
|
+ map.put("inFileCount", in_fileCount);
|
|
|
|
+ map.put("outFileCount", out_fileCount);
|
|
|
|
+ return map;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 递归统计文件夹中的文件数量
|
|
|
|
+ *
|
|
|
|
+ * @param directory 文件夹对象
|
|
|
|
+ * @return 文件数量
|
|
|
|
+ */
|
|
|
|
+ public static int countFiles(File directory) {
|
|
|
|
+ // 检查文件夹是否存在且是一个目录
|
|
|
|
+ if (!directory.exists() || !directory.isDirectory()) {
|
|
|
|
+ System.out.println("指定的路径不是一个有效的文件夹");
|
|
|
|
+ return 0;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 获取文件夹中的所有文件和子文件夹
|
|
|
|
+ File[] files = directory.listFiles();
|
|
|
|
+
|
|
|
|
+ // 初始化文件计数器
|
|
|
|
+ int count = 0;
|
|
|
|
+
|
|
|
|
+ // 遍历文件和子文件夹
|
|
|
|
+ for (File file : files) {
|
|
|
|
+ if (file.isFile()) {
|
|
|
|
+ // 如果是文件,计数器加1
|
|
|
|
+ count++;
|
|
|
|
+ } else if (file.isDirectory()) {
|
|
|
|
+ // 如果是子文件夹,递归调用countFiles方法
|
|
|
|
+ count += countFiles(file);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return count;
|
|
|
|
+ }
|
|
}
|
|
}
|