Explorar o código

fix: 解决可见光转红外开始训练失败,和日志问题

WANGKANG hai 8 meses
pai
achega
d7ba906f59

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

@@ -277,6 +277,8 @@ public class ToInfraredServiceImpl extends BaseServiceImpl<ToInfraredMapper, ToI
 
         if (BizConstant.AlgorithmType.REASONING.equals(algorithmConfigTrack.getType())) {
             startTaskConfig.setModel_path(algorithmModelTrack.getModelAddress());
+            startTaskConfig.setSource_dir(entity.getInputPath() + File.separator + BizConstant.PREDICT_PATH);
+            startTaskConfig.setResult_dir(entity.getOutputPath() + File.separator + BizConstant.PREDICT_PATH);
         }
 
 
@@ -385,18 +387,28 @@ public class ToInfraredServiceImpl extends BaseServiceImpl<ToInfraredMapper, ToI
         ToInfrared entity = getById(id);
         String outPutPath = entity.getOutputPath();
         String logPath = outPutPath + File.separator + getLogFileName(entity);
+        System.out.println(logPath);
         File file = new File(logPath);
         if (!file.exists()) {
             return CommonResult.fail("日志文件不存在!");
         }
-        try (BufferedReader br = new BufferedReader(new FileReader(logPath))) {
-            String log = Files.readString(Paths.get(logPath));
-            log = log.replaceAll("\n", "<br/>\n");
-            return CommonResult.success(log, "success");
-        } catch (Exception e) {
+        return CommonResult.success(readLogContent(logPath), "success");
+    }
+
+    public String readLogContent(String path) {
+        String content = "";
+        try(BufferedReader br = new BufferedReader(new FileReader(path))) {
+            String line;
+            while ((line = br.readLine()) != null) {
+                content += ( line + "<br />\n");
+            }
+        }catch(Exception e) {
             e.printStackTrace();
-            return CommonResult.fail("读取日志失败!" + e.getMessage());
+            System.out.println("读取文件失败!" + e.getMessage());
+            content =  "读取文件失败!" + e.getMessage();
         }
+
+        return content;
     }
 
     @Override