浏览代码

feat: 可见光转红外预测、推理接口对接完成

WANGKANG 10 月之前
父节点
当前提交
15638ce67f

+ 2 - 2
taais-common/taais-common-core/src/main/java/com/taais/common/core/config/TaaisConfig.java

@@ -17,7 +17,7 @@ public class TaaisConfig {
     /**
      * 文件路径
      */
-
+    @Value("${taais.profile}")
     private static String profile;
     /**
      * 获取地址开关
@@ -46,7 +46,7 @@ public class TaaisConfig {
         return profile;
     }
 
-//    @Value("${taais.profile}")
+
     public void setProfile(String profile) {
         TaaisConfig.profile = profile;
     }

+ 6 - 6
taais-modules/taais-biz/src/main/java/com/taais/biz/controller/VideoStableController.java

@@ -62,15 +62,15 @@ public class VideoStableController extends BaseController {
 
             Path inputPath = null;
             Path outputPath = null;
-            String osName = System.getProperty("os.name");
+//            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 {
+//            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());
-            }
+//            }
             System.out.println("inputPath: " + inputPath.toString());
             System.out.println("outputPath: " + outputPath.toString());
 

+ 63 - 21
taais-modules/taais-biz/src/main/java/com/taais/biz/service/impl/ToInfraredServiceImpl.java

@@ -263,14 +263,14 @@ public class ToInfraredServiceImpl extends BaseServiceImpl<ToInfraredMapper, ToI
 
         startToInfraredTask.setOtherParams(algorithmConfigTrack.getParameterConfig());
 
-        String osName = System.getProperty("os.name");
-        if (osName.toLowerCase().contains("windows")) {
-            startToInfraredTask.setSource_dir("C:" + toInfrared.getInputPath());
-            startToInfraredTask.setResult_dir("C:" + toInfrared.getOutputPath());
-        } else {
+//        String osName = System.getProperty("os.name");
+//        if (osName.toLowerCase().contains("windows")) {
+//            startToInfraredTask.setSource_dir("C:" + toInfrared.getInputPath());
+//            startToInfraredTask.setResult_dir("C:" + toInfrared.getOutputPath());
+//        } else {
             startToInfraredTask.setSource_dir(toInfrared.getInputPath());
             startToInfraredTask.setResult_dir(toInfrared.getOutputPath());
-        }
+//        }
 
         // startToInfraredTask.setSource_dir(toInfrared.getInputPath());
         // startToInfraredTask.setResult_dir(toInfrared.getOutputPath());
@@ -296,7 +296,11 @@ public class ToInfraredServiceImpl extends BaseServiceImpl<ToInfraredMapper, ToI
     public CommonResult stop(Long id) {
         ToInfrared toInfrared = getById(id);
 
-        HttpResponseEntity responseEntity = sendPostMsg(to_infrared_stop_url, toInfrared);
+        StartToInfraredTask startToInfraredTask = new StartToInfraredTask();
+        startToInfraredTask.setBizType(BizConstant.BizType.TO_INFRARED);
+        startToInfraredTask.setBizId(toInfrared.getId());
+
+        HttpResponseEntity responseEntity = sendPostMsg(to_infrared_stop_url, startToInfraredTask);
         if (ObjectUtil.isNotNull(responseEntity) && responseEntity.getStatus() == 200) {
             toInfrared.setStatus(BizConstant.VideoStatus.INTERRUPTED);
             updateById(toInfrared);
@@ -356,29 +360,67 @@ public class ToInfraredServiceImpl extends BaseServiceImpl<ToInfraredMapper, ToI
         }
 
         String outputPath = toInfrared.getOutputPath();
-        String zipFilePath = outputPath + ".zip";
 
-        String osName = System.getProperty("os.name");
-        if (osName.toLowerCase().contains("windows")) {
-            zipFilePath = "C://" + zipFilePath;
-        }
+//        String osName = System.getProperty("os.name");
+//        if (osName.toLowerCase().contains("windows")) {
+//            outputPath = outputPath;
+//        }
 
-        try {
-            ZipUtils.zipFolderFiles(outputPath, zipFilePath);
-        } catch (IOException e) {
-            throw new RuntimeException(e);
-        }
+        File  modelDir= new File(outputPath + File.separator + BizConstant.MODEL_PATH);
 
-        File file = new File(zipFilePath);
+        if (!modelDir.exists() || !modelDir.isDirectory()) {
+            return ResponseEntity.status(HttpStatus.NOT_FOUND).body(null);
+        }
 
-        if (!file.exists() || !file.isFile()) {
+        File[] modelFiles = modelDir.listFiles();
+        if(modelFiles == null || modelFiles.length == 0) {
             return ResponseEntity.status(HttpStatus.NOT_FOUND).body(null);
         }
 
-        org.springframework.core.io.Resource resource = new FileSystemResource(file);
+        for(int i=0; i< modelFiles.length; i++) {
+            System.out.println(modelFiles[i].getName());
+        }
+
+        File returnFile = modelFiles[modelFiles.length-1];
+
+        org.springframework.core.io.Resource resource = new FileSystemResource(returnFile);
         return ResponseEntity.ok()
-            .header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + file.getName() + "\"")
+            .header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + returnFile.getName() + "\"")
             .header(HttpHeaders.CONTENT_TYPE, "application/octet-stream")
             .body(resource);
     }
+
+//    @Override
+//    public ResponseEntity<org.springframework.core.io.Resource> zipImages(Long id) {
+//        ToInfrared toInfrared = this.getById(id);
+//        if (ObjectUtil.isNull(toInfrared)) {
+//            return ResponseEntity.status(HttpStatus.NOT_FOUND).body(null);
+//        }
+//
+//        String outputPath = toInfrared.getOutputPath();
+//        String zipFilePath = outputPath + ".zip";
+//
+//        String osName = System.getProperty("os.name");
+//        if (osName.toLowerCase().contains("windows")) {
+//            zipFilePath = "C:" + zipFilePath;
+//        }
+//
+//        try {
+//            ZipUtils.zipFolderFiles(outputPath, zipFilePath);
+//        } catch (IOException e) {
+//            throw new RuntimeException(e);
+//        }
+//
+//        File file = new File(zipFilePath);
+//
+//        if (!file.exists() || !file.isFile()) {
+//            return ResponseEntity.status(HttpStatus.NOT_FOUND).body(null);
+//        }
+//
+//        org.springframework.core.io.Resource resource = new FileSystemResource(file);
+//        return ResponseEntity.ok()
+//            .header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + file.getName() + "\"")
+//            .header(HttpHeaders.CONTENT_TYPE, "application/octet-stream")
+//            .body(resource);
+//    }
 }

+ 6 - 6
taais-modules/taais-biz/src/main/java/com/taais/biz/service/impl/VideoStableServiceImpl.java

@@ -298,15 +298,15 @@ public class VideoStableServiceImpl extends BaseServiceImpl<VideoStableMapper, V
 
         Path inputPath = null;
         Path outputPath = null;
-        String osName = System.getProperty("os.name");
+//        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 {
+//        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());

+ 2 - 2
taais-modules/taais-biz/src/main/java/com/taais/biz/utils/ZipUtils.java

@@ -112,8 +112,8 @@ public class ZipUtils {
 
     public static void main(String[] args) {
         try {
-            zipFolderFiles("C:\\home\\ObjectDetection_Web\\upload\\2024\\10\\12\\VEDAI_20241012085201A001_to_infrared",
-                "C:\\home\\ObjectDetection_Web\\upload\\2024\\10\\12\\VEDAI_20241012085201A001_to_infrared.zip");
+            zipFolderFiles("C:\\home\\ObjectDetection_Web\\upload\\2024\\10\\12\\dataset_20241012115340A001_to_infrared",
+                "C:\\home\\ObjectDetection_Web\\upload\\2024\\10\\12\\dataset_20241012115340A001_to_infrared.zip");
         } catch (IOException e) {
             e.printStackTrace();
         }