|
@@ -1,7 +1,10 @@
|
|
|
package com.taais.biz.service.impl;
|
|
|
|
|
|
+import java.io.BufferedReader;
|
|
|
import java.io.File;
|
|
|
+import java.io.FileReader;
|
|
|
import java.io.IOException;
|
|
|
+import java.nio.file.Files;
|
|
|
import java.nio.file.Path;
|
|
|
import java.nio.file.Paths;
|
|
|
import java.util.Arrays;
|
|
@@ -270,7 +273,7 @@ public class TargetDetectionServiceImpl extends BaseServiceImpl<TargetDetectionM
|
|
|
|
|
|
startTaskConfig.setSource_dir(entity.getInputPath());
|
|
|
startTaskConfig.setResult_dir(entity.getOutputPath());
|
|
|
- startTaskConfig.setLog_path(entity.getOutputPath() + File.separator + "log.log");
|
|
|
+ startTaskConfig.setLog_path(entity.getOutputPath() + File.separator + getLogFileName(entity));
|
|
|
|
|
|
if (BizConstant.AlgorithmType.REASONING.equals(algorithmConfigTrack.getType())) {
|
|
|
String modelPath = algorithmModelTrack.getModelAddress() + File.separator + algorithmModelTrack.getModelName();
|
|
@@ -328,11 +331,11 @@ public class TargetDetectionServiceImpl extends BaseServiceImpl<TargetDetectionM
|
|
|
algorithmModelTrack.setModelStatus("200".equals(status) ? BizConstant.ModelStatus.END : BizConstant.ModelStatus.FAILED);
|
|
|
|
|
|
AlgorithmConfigTrack algorithmConfigTrack = algorithmConfigTrackService.getById(algorithmModelTrack.getAlgorithmId());
|
|
|
- String params = algorithmConfigTrack.getParameterConfig();
|
|
|
+ String params = algorithmConfigTrack.getParameterConfig();
|
|
|
HashMap<String, Object> parse = (HashMap<String, Object>) JSON.parse((params));
|
|
|
|
|
|
- if("200".equals(status) && ObjectUtil.isNull(algorithmModelTrack.getModelAddress())) {
|
|
|
- algorithmModelTrack.setModelAddress(entity.getOutputPath() + File.separator + ((HashMap<String, String>)parse.get("dataset")).get("classes"));
|
|
|
+ if ("200".equals(status) && ObjectUtil.isNull(algorithmModelTrack.getModelAddress())) {
|
|
|
+ algorithmModelTrack.setModelAddress(entity.getOutputPath() + File.separator + ((HashMap<String, String>) parse.get("dataset")).get("classes"));
|
|
|
|
|
|
System.out.println(parse.get("dataset"));
|
|
|
algorithmModelTrackService.updateById(algorithmModelTrack);
|
|
@@ -392,4 +395,27 @@ public class TargetDetectionServiceImpl extends BaseServiceImpl<TargetDetectionM
|
|
|
.header(HttpHeaders.CONTENT_TYPE, "application/octet-stream")
|
|
|
.body(resource);
|
|
|
}
|
|
|
+
|
|
|
+ private String getLogFileName(TargetDetection entity) {
|
|
|
+ return entity.getId() + BizConstant.TARGET_DETECTION_SUFFIX + ".log";
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public CommonResult getLog(Long id) {
|
|
|
+ TargetDetection entity = getById(id);
|
|
|
+ String outPutPath = entity.getOutputPath();
|
|
|
+ String logPath = outPutPath + File.separator + getLogFileName(entity);
|
|
|
+ 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) {
|
|
|
+ e.printStackTrace();
|
|
|
+ return CommonResult.fail("读取日志失败!");
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|