소스 검색

fix: menu update

28968 7 달 전
부모
커밋
519041381d

+ 64 - 4
taais-modules/taais-biz/src/main/java/com/taais/biz/controller/DataAugmentationController.java

@@ -1,9 +1,7 @@
 package com.taais.biz.controller;
 
 
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
+import java.io.*;
 import java.nio.file.DirectoryStream;
 import java.nio.file.Files;
 import java.nio.file.Path;
@@ -14,11 +12,14 @@ import java.util.regex.Pattern;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
 
+import com.alibaba.fastjson2.JSONArray;
+import com.alibaba.fastjson2.JSONObject;
 import com.mybatisflex.core.query.QueryWrapper;
 import com.taais.biz.domain.DataAugmentation;
 import com.taais.biz.domain.bo.DataAugmentationBo;
 import com.taais.biz.domain.bo.DataAugmentationResultBo;
 import com.taais.biz.domain.bo.VideoStableStartResultBo;
+import com.taais.biz.domain.dto.Metric;
 import com.taais.biz.domain.vo.DataAugmentationVo;
 import com.taais.biz.domain.vo.TaskDictDataVo;
 import com.taais.biz.service.IVideoStableService;
@@ -80,6 +81,7 @@ public class DataAugmentationController extends BaseController {
         try (Stream<Path> paths = Files.list(inputPath)) {
             return paths.sorted()
                 .skip(idx)
+                .filter(path -> !path.toString().toLowerCase().endsWith(".json"))
                 .findFirst()
                 .orElseThrow(() -> new IllegalArgumentException("Index " + idx + " is out of bounds for the list of files in " + inputPath));
         }
@@ -167,7 +169,9 @@ public class DataAugmentationController extends BaseController {
                 Stream<Path> inputFilePathStream = Files.list(imagePath);
                 inputFileList = inputFilePathStream
                     .filter(Files::isRegularFile)  // 只选择常规文件(排除子目录、排除图像拼接算法_sift输入中的txt文件)
-                    .filter(path -> !path.toString().toLowerCase().endsWith(".txt")).map(path -> {
+                    .filter(path -> !path.toString().toLowerCase().endsWith(".txt"))
+                    .filter(path -> !path.toString().toLowerCase().endsWith(".json"))
+                    .map(path -> {
                             return path.getFileName().toString();
                     }).collect(Collectors.toList());
             } else {
@@ -233,9 +237,28 @@ public class DataAugmentationController extends BaseController {
     @SaCheckPermission("demo:dataAugmentation:list")
     @GetMapping("/list")
     public CommonResult<PageResult<DataAugmentationVo>> list(DataAugmentationBo dataAugmentationBo) {
+        if (dataAugmentationBo.getTaskType() == null) {
+            return CommonResult.success(dataAugmentationService.selectPage1(dataAugmentationBo, "dataAugmentation"));
+        }
+        return CommonResult.success(dataAugmentationService.selectPage(dataAugmentationBo));
+    }
+    @SaCheckPermission("demo:dataAugmentation:list")
+    @GetMapping("/imageMosaicList")
+    public CommonResult<PageResult<DataAugmentationVo>> imageMosaicList(DataAugmentationBo dataAugmentationBo) {
+        if (dataAugmentationBo.getTaskType() == null) {
+            return CommonResult.success(dataAugmentationService.selectPage1(dataAugmentationBo, "imageMosaic"));
+        }
         return CommonResult.success(dataAugmentationService.selectPage(dataAugmentationBo));
     }
 
+    @SaCheckPermission("demo:dataAugmentation:list")
+    @GetMapping("/targetDamageAcessList")
+    public CommonResult<PageResult<DataAugmentationVo>> targetDamageAcessList(DataAugmentationBo dataAugmentationBo) {
+        if (dataAugmentationBo.getTaskType() == null) {
+            return CommonResult.success(dataAugmentationService.selectPage1(dataAugmentationBo, "targetDamageAcess"));
+        }
+        return CommonResult.success(dataAugmentationService.selectPage(dataAugmentationBo));
+    }
     /**
      * 导出数据增强列表
      */
@@ -341,6 +364,43 @@ public class DataAugmentationController extends BaseController {
             return CommonResult.fail("日志文件" + filePath + "读取失败!");
         }
     }
+    /**
+     * 获取算法结果指标
+     */
+    @SaCheckPermission("demo:dataAugmentation:query")
+    @GetMapping(value = "/metric/{id}")
+    public CommonResult<List<Metric>> getMetric(@PathVariable Long id) {
+        DataAugmentation byId = dataAugmentationService.getById(id);
+        String outputPath = byId.getOutputPath();
+        Path path = Paths.get(outputPath, "result.json");
+        try{
+
+            if (!Files.exists(path)) {
+                return CommonResult.fail( "算法指标文件" + path.toString() + "不存在!");
+            }
+            StringBuilder jsonContent = new StringBuilder();
+            try (BufferedReader reader = new BufferedReader(new FileReader(path.toString()))) {
+                String line;
+                while ((line = reader.readLine()) != null) {
+                    jsonContent.append(line);
+                }
+            }
+            // 解析 JSON 数组
+            JSONArray jsonArray = JSONArray.parseArray(jsonContent.toString());
+            List<Metric> metricList = new ArrayList<>();
+            for (int i = 0; i < jsonArray.size(); i++) {
+                JSONObject jsonObject = jsonArray.getJSONObject(i);
+                Metric metric = new Metric(
+                    jsonObject.getString("name"),
+                    jsonObject.getString("value")
+                );
+                metricList.add(metric);
+            }
+            return CommonResult.success((metricList), "获取算法指标成功");
+        } catch (Exception e) {
+            return CommonResult.fail("算法指标文件" + path.toString() + "读取失败!");
+        }
+    }
 
     @SaCheckPermission("demo:dataAugmentation:query")
     @GetMapping(value = "/getTaskDictData")

+ 14 - 0
taais-modules/taais-biz/src/main/java/com/taais/biz/domain/dto/Metric.java

@@ -0,0 +1,14 @@
+package com.taais.biz.domain.dto;
+
+import lombok.Data;
+
+@Data
+public class Metric {
+    private String name;
+    private String value;
+
+    public Metric(String name, String value) {
+        this.name = name;
+        this.value = value;
+    }
+}

+ 1 - 0
taais-modules/taais-biz/src/main/java/com/taais/biz/service/IDataAugmentationService.java

@@ -79,4 +79,5 @@ public interface IDataAugmentationService extends IBaseService<DataAugmentation>
 
     CommonResult stop(Long id);
 
+    PageResult<DataAugmentationVo> selectPage1(DataAugmentationBo dataAugmentationBo, String type);
 }

+ 31 - 0
taais-modules/taais-biz/src/main/java/com/taais/biz/service/impl/DataAugmentationServiceImpl.java

@@ -150,6 +150,37 @@ public class DataAugmentationServiceImpl extends BaseServiceImpl<DataAugmentatio
         return PageResult.build(page);
     }
 
+    @Override
+    public PageResult<DataAugmentationVo> selectPage1(DataAugmentationBo dataAugmentationBo, String type) {
+        QueryWrapper queryWrapper = buildQueryWrapper(dataAugmentationBo);
+        if ("dataAugmentation".equals(type)) {
+            queryWrapper.and(wrapper -> {
+                wrapper.or(orWrapper -> {
+                    orWrapper.and(DATA_AUGMENTATION.TASK_TYPE.eq("图像增强"));
+                    orWrapper.or(DATA_AUGMENTATION.TASK_TYPE.eq("图像逆光"));
+                });
+            });
+        }
+        else if ("imageMosaic".equals(type)) {
+            queryWrapper.and(wrapper -> {
+                wrapper.or(orWrapper -> {
+                    orWrapper.and(DATA_AUGMENTATION.TASK_TYPE.eq("侦察图像拼接算法_coordinate"));
+                    orWrapper.or(DATA_AUGMENTATION.TASK_TYPE.eq("侦察图像拼接算法_sift"));
+                });
+            });
+        }
+        else if ("targetDamageAcess".equals(type)) {
+            queryWrapper.and(wrapper -> {
+                wrapper.or(orWrapper -> {
+                    orWrapper.and(DATA_AUGMENTATION.TASK_TYPE.eq("目标毁伤评估"));
+                });
+            });
+        }
+
+        Page<DataAugmentationVo> page = this.pageAs(PageQuery.build(), queryWrapper, DataAugmentationVo.class);
+        return PageResult.build(page);
+    }
+
     /**
      * 新增数据增强
      *