Browse Source

定时任务:关闭录制视频添加

gao.qiang 1 year ago
parent
commit
99c9b6fd81
1 changed files with 21 additions and 3 deletions
  1. 21 3
      hazard-admin/src/main/java/com/ozs/web/core/util/CameraUtil.java

+ 21 - 3
hazard-admin/src/main/java/com/ozs/web/core/util/CameraUtil.java

@@ -441,10 +441,10 @@ public class CameraUtil {
         List<BaseCameraManagement> list = baseCameraManagementService.list(wrapper);
         log.info("list======================================" + list);
         List<String> collect = list.stream().map(BaseCameraManagement::getCameraCode).collect(Collectors.toList());
-//        List<String> collect=new ArrayList<>();
+//        List<String> collect = new ArrayList<>();
 //        collect.add("42010001541320001116");
         //遍历每个进行视频录制的摄像头
-        File file = new File("D://file");
+        File file = new File(transcribeFilePath);
         log.info("closeRecording-file.Name()======================================" + file.getName());
         log.info("closeRecording-file.exists()======================================" + file.exists());
         if (file.exists() && file.isDirectory()) {
@@ -456,7 +456,7 @@ public class CameraUtil {
                     log.info("closeRecording-cameraCode---------------" + collect);
                     String substring = file1.toString().substring(file1.toString().lastIndexOf("\\") + 1);
                     if (collect.contains(substring)) {
-                        File[] files1 = file1.listFiles();
+                        File[] files1 = CameraUtil.getCurFilesList(file1.toString());
                         if (!ObjectUtils.isEmpty(files1) && files1.length > 0) {
                             int length = files1.length;
                             File file2 = files1[length - 1];
@@ -504,6 +504,24 @@ public class CameraUtil {
         }
     }
 
+    public static File[] getCurFilesList(String filePath) {
+        File path = new File(filePath);
+        File[] listFiles = path.listFiles(new java.io.FileFilter() {
+
+            @Override
+            public boolean accept(File pathname) {
+                if (pathname.isFile()) {
+                    return true;
+                } else {
+
+                    return false;
+                }
+            }
+        });
+
+        return listFiles;
+    }
+
     public static void main(String[] args) throws InterruptedException, ParseException, IOException {
         CameraUtil cameraUtil = new CameraUtil();
         cameraUtil.closeRecording();