1
0

13 Achegas 61db8f83ab ... 2634f88ec7

Autor SHA1 Mensaxe Data
  Suuuuuukang 2634f88ec7 fix: 图片导出带标签txt文件 hai 3 meses
  Sk18834839360 8a01dd3249 Merge branch 'dev_lsk_0325' of www/taais into develop hai 3 meses
  Suuuuuukang f0d4740dce fix: todo-打开文件夹重试 hai 3 meses
  Sk18834839360 c4322e7286 Merge branch 'dev_lsk_0325' of www/taais into develop hai 3 meses
  Suuuuuukang eec2928bfc feat: 目标检测启动停止,打开文件夹重试 hai 3 meses
  Sk18834839360 cf2c4a7617 Merge branch 'dev_lsk_sjkz' of www/taais into develop hai 3 meses
  allen 4a4c9a61e4 Merge remote-tracking branch 'origin/develop' into develop hai 3 meses
  Li f730016553 fix: update params hai 4 meses
  Suuuuuukang 070f226895 feat: 打开文件夹功能 hai 4 meses
  Suuuuuukang ee24f0c20c fix: 数据扩增bug fix hai 4 meses
  Suuuuuukang 48be7658c9 feat: 数据扩增逻辑重做 hai 4 meses
  WANGKANG 4e2f8f0df4 feat: add new feature hai 5 meses
  Eagle d721421cb1 [FEATURE] 多源信息融合、异源图像匹配、电子稳相的暂停、继续、停止功能 hai 5 meses

+ 2 - 0
taais-modules/taais-biz/src/main/java/com/taais/biz/constant/BizConstant.java

@@ -126,6 +126,8 @@ public class BizConstant {
     public static final String DOCKER_OBJ_MATCH_PATH = "/objectMatch";
     public static final String TYPE_OBJ_TRACE = "OBJ_TRACE";
     public static final String DOCKER_MAT_TASK = "/obj_track";
+
+    public static final String TYPE_DATA_EXPAND = "DATA_EXPAND";
 //    public static final String MULTI_OBJ_TRACE_URL = "127.0.0.1:10027/objTrace";
 //    public static final String MULTI_OBJ_MATCH_URL = "127.0.0.1:10028/imgMatch";
 }

+ 1 - 1
taais-modules/taais-biz/src/main/java/com/taais/biz/controller/DataController.java

@@ -120,7 +120,7 @@ public class DataController extends BaseController {
                     log.error("图片源文件不存在:{}", srcFile.getName());
                 }
                 if (!StringUtils.isEmpty(dataVo.getLabelurl())) {
-                    String[] labels = dataVo.getUrl().split("/profile");
+                    String[] labels = dataVo.getLabelurl().split("/profile");
                     File labelurlFile = new File(profile + labels[1]);
                     File labelurlDestFile = new File(tempDir, labelurlFile.getName());
                     if (labelurlFile.exists()) {

+ 58 - 0
taais-modules/taais-biz/src/main/java/com/taais/biz/controller/ObjectMatchController.java

@@ -173,6 +173,64 @@ public class ObjectMatchController extends BaseController {
         return CommonResult.success();
     }
 
+    @GetMapping("/hangup")
+    public CommonResult<Void> hangup(String taskId) {
+        ObjectMatchBo bo = objectMatchService.getById(Long.parseLong(taskId));
+        Map<String, String> params = new HashMap<>();
+
+        params.put("bizId", String.valueOf(bo.getId()));
+        params.put("bizType", TYPE_OBJ_MATCH);
+        params.put("logPath", DOCKER_BASE_PATH + bo.getResultPath() + "/log.log");
+        params.put("sourcePath", DOCKER_BASE_PATH +  bo.getPreprocessPath());
+        params.put("resultPath", DOCKER_BASE_PATH + bo.getResultPath());
+        params.put("otherParams", bo.getParameters());
+
+        log.info("obj_match params: {}", params);
+
+        try {
+            String url = algorithmConfigService.getByAlgorithmName("异源图像匹配定位").getPauseApi();
+            String res = HttpUtil.post(url, JSONUtil.toJsonStr(params));
+            bo.setStatus(TASK_STATUS_PENDING);
+            bo.setEndTime(new Date());
+            bo.setCostSecond((bo.getEndTime().getTime() - bo.getStartTime().getTime()) / 1000);
+        } catch (Exception e) {
+            log.error("HTTP请求失败",e);
+            return CommonResult.fail("HTTP请求失败" + e.getMessage());
+        } finally {
+            objectMatchService.update(bo);
+        }
+        return CommonResult.success();
+    }
+
+    @GetMapping("/stop")
+    public CommonResult<Void> stop(String taskId) {
+        ObjectMatchBo bo = objectMatchService.getById(Long.parseLong(taskId));
+        Map<String, String> params = new HashMap<>();
+
+        params.put("bizId", String.valueOf(bo.getId()));
+        params.put("bizType", TYPE_OBJ_MATCH);
+        params.put("logPath", DOCKER_BASE_PATH + bo.getResultPath() + "/log.log");
+        params.put("sourcePath", DOCKER_BASE_PATH +  bo.getPreprocessPath());
+        params.put("resultPath", DOCKER_BASE_PATH + bo.getResultPath());
+        params.put("otherParams", bo.getParameters());
+
+        log.info("obj_match params: {}", params);
+
+        try {
+            String url = algorithmConfigService.getByAlgorithmName("异源图像匹配定位").getTerminateApi();
+            String res = HttpUtil.post(url, JSONUtil.toJsonStr(params));
+            bo.setStatus(TASK_STATUS_PENDING);
+            bo.setEndTime(new Date());
+            bo.setCostSecond((bo.getEndTime().getTime() - bo.getStartTime().getTime()) / 1000);
+        } catch (Exception e) {
+            log.error("HTTP请求失败",e);
+            return CommonResult.fail("HTTP请求失败" + e.getMessage());
+        } finally {
+            objectMatchService.update(bo);
+        }
+        return CommonResult.success();
+    }
+
     @GetMapping("/result")
     public CommonResult<List<String>> getResult(String taskId) {
         ObjectMatchBo bo = objectMatchService.getById(Long.parseLong(taskId));

+ 84 - 0
taais-modules/taais-biz/src/main/java/com/taais/biz/controller/ObjectTraceMergeController.java

@@ -163,6 +163,90 @@ public class ObjectTraceMergeController extends BaseController {
         return CommonResult.success();
     }
 
+    @PostMapping("/hangup")
+    public CommonResult<Void> hangup(@RequestBody Map<String, String> _params) {
+        if (!_params.containsKey("taskId")) {
+            return CommonResult.fail("请提供任务ID!");
+        }
+        String taskId = _params.get("taskId");
+        ObjectTraceMergeBo vo = objectTraceMergeService.getById(Long.valueOf(taskId));
+        if (vo == null) {
+            return CommonResult.fail("未找到任务内容!");
+        }
+        if (TASK_STATUS_SUCCEED.equals(vo.getStatus())) {
+            return CommonResult.fail("任务已经执行完毕!");
+        }
+//        if (!(TASK_STATUS_PENDING.equals(vo.getStatus()) || TASK_STATUS_FAILED.equals(vo.getStatus()))) {
+//            return CommonResult.fail("任务正在执行中!");
+//        }
+        vo.setEndTime(new Date());
+
+        Map<String, String> params = new HashMap<>();
+        params.put("bizType", TYPE_OBJ_TRACE);
+        params.put("bizId", String.valueOf(vo.getId()));
+        params.put("logPath", DOCKER_BASE_PATH + vo.getResultPath());
+        params.put("sourcePath", vo.getPreprocessPath());
+        params.put("resultPath", DOCKER_BASE_PATH +  vo.getResultPath());
+        params.put("otherParams", vo.getParameters());
+
+        log.info("obj_trace params: {}", params);
+
+        try {
+            String url = algorithmConfigService.getByAlgorithmName("多源信息融合").getPauseApi();
+            String res = HttpUtil.post(url, JSONUtil.toJsonStr(params));
+            vo.setStatus(TASK_STATUS_PENDING);
+        } catch (Exception e) {
+            log.error("HTTP请求失败",e);
+            vo.setStatus(TASK_STATUS_FAILED);
+            return CommonResult.fail("HTTP请求失败" + e.getMessage());
+        } finally {
+            objectTraceMergeService.update(vo);
+        }
+        return CommonResult.success();
+    }
+
+    @PostMapping("/stop")
+    public CommonResult<Void> stop(@RequestBody Map<String, String> _params) {
+        if (!_params.containsKey("taskId")) {
+            return CommonResult.fail("请提供任务ID!");
+        }
+        String taskId = _params.get("taskId");
+        ObjectTraceMergeBo vo = objectTraceMergeService.getById(Long.valueOf(taskId));
+        if (vo == null) {
+            return CommonResult.fail("未找到任务内容!");
+        }
+        if (TASK_STATUS_SUCCEED.equals(vo.getStatus())) {
+            return CommonResult.fail("任务已经执行完毕!");
+        }
+//        if (!(TASK_STATUS_PENDING.equals(vo.getStatus()) || TASK_STATUS_FAILED.equals(vo.getStatus()))) {
+//            return CommonResult.fail("任务正在执行中!");
+//        }
+        vo.setEndTime(new Date());
+
+        Map<String, String> params = new HashMap<>();
+        params.put("bizType", TYPE_OBJ_TRACE);
+        params.put("bizId", String.valueOf(vo.getId()));
+        params.put("logPath", DOCKER_BASE_PATH + vo.getResultPath());
+        params.put("sourcePath", vo.getPreprocessPath());
+        params.put("resultPath", DOCKER_BASE_PATH +  vo.getResultPath());
+        params.put("otherParams", vo.getParameters());
+
+        log.info("obj_trace params: {}", params);
+
+        try {
+            String url = algorithmConfigService.getByAlgorithmName("多源信息融合").getTerminateApi();
+            String res = HttpUtil.post(url, JSONUtil.toJsonStr(params));
+            vo.setStatus(TASK_STATUS_PENDING);
+        } catch (Exception e) {
+            log.error("HTTP请求失败",e);
+            vo.setStatus(TASK_STATUS_FAILED);
+            return CommonResult.fail("HTTP请求失败" + e.getMessage());
+        } finally {
+            objectTraceMergeService.update(vo);
+        }
+        return CommonResult.success();
+    }
+
     @GetMapping("/result")
     public CommonResult<List<String>> execute(String taskId) {
         if (taskId == null) {

+ 20 - 0
taais-modules/taais-biz/src/main/java/com/taais/biz/controller/PublicController.java

@@ -8,6 +8,7 @@ import com.taais.biz.domain.bo.*;
 import com.taais.biz.domain.dto.TaskResultDTO;
 import com.taais.biz.service.*;
 import com.taais.biz.service.impl.AlgorithmModelServiceImpl;
+import com.taais.biz.service.impl.DataAmplificationTaskServiceImpl;
 import com.taais.biz.service.impl.ObjectTraceMergeServiceImpl;
 import com.taais.biz.service.impl.TargetIdentificationSubtaskDetailsServiceImpl;
 import com.taais.biz.service.service.impl.ObjectMatchServiceImpl;
@@ -79,6 +80,9 @@ public class PublicController extends BaseController {
     @Resource
     ObjectMatchServiceImpl objectMatchService;
 
+    @Resource
+    DataAmplificationTaskServiceImpl dataAmplificationTaskService;
+
     @PostMapping("/taskResult")
     public CommonResult<Void> taskResult(@RequestBody TaskResultDTO resultDTO) {
         log.info("taskResult start,params:{}", resultDTO);
@@ -139,6 +143,22 @@ public class PublicController extends BaseController {
             objectMatchService.update(bo);
         } else if (BizConstant.TYPE_DATA_PROCESS.equals(bizType)) {
             errorMsg = dataProcessService.taskResult(resultDTO);
+        } else if (BizConstant.TYPE_DATA_EXPAND.equals(bizType)) {
+            DataAmplificationTaskBo bo = dataAmplificationTaskService.getById(resultDTO.getBizId());
+            if (bo != null) {
+                try {
+                    bo.setInputImagePath(String.valueOf(Integer.parseInt(bo.getOutputImagePath()) - 1));
+                    if (bo.getInputImagePath().equals("0")) {
+                        bo.setEndTime(new Date());
+                        bo.setCostSecond((int) ((bo.getEndTime().getTime() - bo.getStartTime().getTime()) / 1000));
+                        bo.setStatus(resultDTO.getStatus() == 200 ? BizConstant.TASK_STATUS_SUCCEED : BizConstant.TASK_STATUS_FAILED);
+                    }
+                } catch (Exception e) {
+                    log.error("error: {}", e.getMessage());
+                } finally {
+                    dataAmplificationTaskService.update(bo);
+                }
+            }
         } else {
             log.error("这种情况是不可能发生的,参数:{}",resultDTO);
             return CommonResult.fail("这种情况是不可能发生的");

+ 118 - 0
taais-modules/taais-biz/src/main/java/com/taais/biz/controller/TargetIdentificationSubtaskDetailsController.java

@@ -1,15 +1,22 @@
 package com.taais.biz.controller;
 
+import java.awt.*;
+import java.io.BufferedReader;
 import java.io.File;
+import java.io.IOException;
+import java.io.InputStreamReader;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
 import java.util.Map;
 
+import cn.hutool.http.HttpUtil;
+import cn.hutool.json.JSONUtil;
 import com.taais.biz.constant.BizConstant;
 import com.taais.biz.domain.TargetIdentificationSubtask;
 import com.taais.biz.domain.TargetIdentificationSubtaskDetails;
 import com.taais.biz.domain.vo.TargetIdentificationSubtaskVo;
+import com.taais.biz.service.impl.CommonAlgorithmConfigServiceImpl;
 import com.taais.biz.service.impl.TargetIdentificationSubtaskServiceImpl;
 import com.taais.biz.service.impl.TargetIdentificationTaskServiceImpl;
 import com.taais.biz.utils.ZipDirectory;
@@ -34,6 +41,8 @@ import com.taais.biz.service.ITargetIdentificationSubtaskDetailsService;
 
 import com.taais.common.core.core.page.PageResult;
 
+import static com.taais.biz.constant.BizConstant.TYPE_DATA_BIZ_PROCESS;
+
 /**
  * 目标识别子任务Controller
  *
@@ -52,6 +61,9 @@ public class TargetIdentificationSubtaskDetailsController extends BaseController
     @Resource
     private TargetIdentificationSubtaskServiceImpl subtaskService;
 
+    @Resource
+    private CommonAlgorithmConfigServiceImpl algorithmConfigService;
+
     /**
      * 查询目标识别子任务列表
      */
@@ -125,6 +137,79 @@ public class TargetIdentificationSubtaskDetailsController extends BaseController
         return CommonResult.success();
     }
 
+    @PostMapping("/continueTask")
+    public CommonResult<Void> continueTask(@RequestBody Map<String, String> params) {
+        params.put("bizType", TYPE_DATA_BIZ_PROCESS);
+        if (!params.containsKey("bizType") || !params.containsKey("bizId")) {
+            return CommonResult.fail("Error parameters");
+        }
+        try {
+            String url = algorithmConfigService.getByAlgorithmName("多目标检测").getStartApi();
+            HttpUtil.post(url, JSONUtil.toJsonStr(params));
+
+            TargetIdentificationSubtaskDetails details = targetIdentificationSubtaskDetailsService.getById(params.get("bizId"));
+            details.setStatus(BizConstant.TASK_STATUS_PROCESSING);
+            details.setStartTime(new Date());
+            details.setEndTime(null);
+            targetIdentificationSubtaskDetailsService.updateById(details);
+
+            return CommonResult.success();
+        } catch (Exception e) {
+            log.error("target identify pause failure");
+            log.error(e.getMessage());
+            return CommonResult.fail(e.getMessage());
+        }
+
+    }
+
+    @PostMapping("/pauseTask")
+    public CommonResult<Void> pauseTask(@RequestBody Map<String, String> params) {
+        params.put("bizType", TYPE_DATA_BIZ_PROCESS);
+        if (!params.containsKey("bizType") || !params.containsKey("bizId")) {
+            return CommonResult.fail("Error parameters");
+        }
+        try {
+            String url = algorithmConfigService.getByAlgorithmName("多目标检测").getPauseApi();
+            HttpUtil.post(url, JSONUtil.toJsonStr(params));
+
+            TargetIdentificationSubtaskDetails details = targetIdentificationSubtaskDetailsService.getById(params.get("bizId"));
+            details.setStatus(BizConstant.TASK_STATUS_PENDING);
+            details.setEndTime(new Date());
+            targetIdentificationSubtaskDetailsService.updateById(details);
+
+            return CommonResult.success();
+        } catch (Exception e) {
+            log.error("target identify pause failure");
+            log.error(e.getMessage());
+            return CommonResult.fail(e.getMessage());
+        }
+
+    }
+
+    @PostMapping("/stopTask")
+    public CommonResult<Void> stopTask(@RequestBody Map<String, String> params) {
+        params.put("bizType", TYPE_DATA_BIZ_PROCESS);
+        if (!params.containsKey("bizType") || !params.containsKey("bizId")) {
+            return CommonResult.fail("Error parameters");
+        }
+        try {
+            String url = algorithmConfigService.getByAlgorithmName("多目标检测").getTerminateApi();
+            HttpUtil.post(url, JSONUtil.toJsonStr(params));
+
+            TargetIdentificationSubtaskDetails details = targetIdentificationSubtaskDetailsService.getById(params.get("bizId"));
+            details.setStatus(BizConstant.TASK_STATUS_PENDING);
+            details.setEndTime(new Date());
+            targetIdentificationSubtaskDetailsService.updateById(details);
+
+            return CommonResult.success();
+        } catch (Exception e) {
+            log.error("target identify pause failure");
+            log.error(e.getMessage());
+            return CommonResult.fail(e.getMessage());
+        }
+
+    }
+
     /**
      * 执行训练任务
      * @param params
@@ -141,6 +226,7 @@ public class TargetIdentificationSubtaskDetailsController extends BaseController
             }
 
             details.setStartTime(new Date());
+            details.setEndTime(null);
             targetIdentificationSubtaskDetailsService.updateById(details);
             subtaskService.executeOneTask(taskId);
             return CommonResult.success();
@@ -185,6 +271,7 @@ public class TargetIdentificationSubtaskDetailsController extends BaseController
 
             details.setStatus(BizConstant.TASK_STATUS_PENDING);
             details.setStartTime(new Date());
+            details.setEndTime(null);
             targetIdentificationSubtaskDetailsService.updateById(details);
 
             subtaskService.executeOneTask(taskId);
@@ -197,6 +284,37 @@ public class TargetIdentificationSubtaskDetailsController extends BaseController
     @Value("${taais.profile}")
     private String profile;
 
+    @GetMapping("/openDir")
+    public CommonResult<Void> openDir(String directory) throws IOException {
+        log.error("check dir: {}, {}", directory, profile + "/task" + directory);
+        //Desktop.getDesktop().open(new File(profile + "/task" + directory));
+
+        String dir = profile + "/task" + directory + "/";
+        String command = "sudo xdg-open " + dir;
+        Runtime.getRuntime().exec(command);
+        log.error("try open: {}", command);
+
+        ProcessBuilder pb = new ProcessBuilder("sudo", "xdg-open", dir);
+        Process p = pb.start();
+        // 读取错误流避免进程阻塞
+        try (BufferedReader errReader = new BufferedReader(new InputStreamReader(p.getErrorStream()))) {
+            String line;
+            while ((line = errReader.readLine()) != null) {
+                log.error("进程错误: {}", line);
+            }
+        }
+        pb = new ProcessBuilder("xdg-open", dir);
+        p = pb.start();
+        // 读取错误流避免进程阻塞
+        try (BufferedReader errReader = new BufferedReader(new InputStreamReader(p.getErrorStream()))) {
+            String line;
+            while ((line = errReader.readLine()) != null) {
+                log.error("进程错误: {}", line);
+            }
+        }
+        return CommonResult.success();
+    }
+
     @GetMapping("/getImgList")
     public CommonResult<List<String>> getImgList(String taskId, String subPath) {
         String path = profile + "/task/" + taskId;

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

@@ -113,6 +113,11 @@ public class VideoStableController extends BaseController {
         return videoStableService.stop(id);
     }
 
+    @GetMapping("/hangup/{id}")
+    public CommonResult hangup(@PathVariable("id") Long id) {
+        return videoStableService.hangup(id);
+    }
+
     /**
      * 查询视频去抖动列表
      */

+ 2 - 0
taais-modules/taais-biz/src/main/java/com/taais/biz/service/IVideoStableService.java

@@ -78,6 +78,8 @@ public interface IVideoStableService extends IBaseService<VideoStable> {
 
     CommonResult stop(Long id);
 
+    CommonResult hangup(Long id);
+
     List<Map<String, String>> getImages(Long ossId);
 
     CommonResult getLog(Long id);

+ 4 - 0
taais-modules/taais-biz/src/main/java/com/taais/biz/service/impl/DataAmplificationTaskServiceImpl.java

@@ -51,6 +51,10 @@ public class DataAmplificationTaskServiceImpl extends BaseServiceImpl<DataAmplif
         return this.getOneAs(query().where(DATA_AMPLIFICATION_TASK.ID.eq(id)), DataAmplificationTaskVo.class);
     }
 
+    public DataAmplificationTaskBo getById(Long id) {
+        return this.getOneAs(query().where(DATA_AMPLIFICATION_TASK.ID.eq(id)), DataAmplificationTaskBo.class);
+    }
+
     @Override
     public List<DataAmplificationTaskVo> selectList(DataAmplificationTaskBo taskBo) {
         QueryWrapper queryWrapper = buildQueryWrapper(taskBo);

+ 105 - 196
taais-modules/taais-biz/src/main/java/com/taais/biz/service/impl/DataServiceImpl.java

@@ -2,6 +2,10 @@ package com.taais.biz.service.impl;
 
 import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.http.HttpRequest;
+import cn.hutool.http.HttpUtil;
+import cn.hutool.json.JSONUtil;
+import com.alibaba.fastjson2.JSON;
+import com.esotericsoftware.minlog.Log;
 import com.fasterxml.jackson.databind.JsonNode;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.mybatisflex.core.paginate.Page;
@@ -27,6 +31,7 @@ import com.taais.common.core.utils.StringUtils;
 import com.taais.common.core.utils.file.FileUploadUtils;
 import com.taais.common.core.utils.file.FileUtils;
 import com.taais.common.core.utils.file.UnPackedUtil;
+import com.taais.common.core.utils.uuid.UUID;
 import com.taais.common.json.utils.JsonUtils;
 import com.taais.common.orm.core.page.PageQuery;
 import com.taais.common.orm.core.service.impl.BaseServiceImpl;
@@ -55,6 +60,8 @@ import java.time.format.DateTimeFormatter;
 import java.util.*;
 import java.util.concurrent.atomic.AtomicInteger;
 
+import static com.taais.biz.constant.BizConstant.*;
+import static com.taais.biz.constant.BizConstant.TASK_STATUS_FAILED;
 import static com.taais.biz.domain.table.DataTableDef.DATA;
 
 /**
@@ -79,7 +86,7 @@ public class DataServiceImpl extends BaseServiceImpl<DataMapper, Data> implement
     private DataMapper dataMapper;
 
     @Resource
-    private IDataAmplificationTaskService dataAmplificationTaskService;
+    private DataAmplificationTaskServiceImpl dataAmplificationTaskService;
 
     @Resource
     private ISysDictDataService dictDataService;
@@ -439,215 +446,117 @@ public class DataServiceImpl extends BaseServiceImpl<DataMapper, Data> implement
     @Override
     @Transactional
     public CommonResult<Boolean> amplifyForData(String id) {
-        DataAmplificationTaskVo taskVo = dataAmplificationTaskService.selectById(Long.valueOf(id));
-        DataAmplifyDto dataAmplifyDto = new DataAmplifyDto();
-        dataAmplifyDto.setId(taskVo.getId().toString());
-        dataAmplifyDto.setAugmentationType(taskVo.getAugmentationType());
-        List<Map<String, String>> maps = JsonUtils.parseArray(taskVo.getParameters(), Map.class);
-        dataAmplifyDto.setOtherParams(maps);
-        dataAmplifyDto.setBatchNum(taskVo.getDataBatchNums());
-        return this.doAmplify(dataAmplifyDto);
-    }
-
-    private CommonResult<Boolean> doAmplify(DataAmplifyDto dataAmplifyDto) {
-        this.updateEmp(Long.valueOf(dataAmplifyDto.getId()));
-        String[] split = dataAmplifyDto.getBatchNum().split(",");
-        SysDictDataVo sysDictDataVo = dictDataService.selectDictDataByTypeAndLabel("python_api_address", "python_expand_data");
-
-        for (String batchNum : split) {
-            QueryWrapper query = query();
-            query.eq(Data::getBatchNum, batchNum);
-            List<Data> dataList = dataMapper.selectListByQuery(query);
-            if (dataList.isEmpty()) {
-                this.updateFail(Long.valueOf(dataAmplifyDto.getId()));
-                continue;
-            }
+        DataAmplificationTaskBo taskVo = dataAmplificationTaskService.getById(Long.valueOf(id));
+        taskVo.setStartTime(new Date());
+        List<Map<String, String>> otherParams = JsonUtils.parseArray(taskVo.getParameters(), Map.class);
+        Map<String, String> realOtherParams = new HashMap<>();
+        otherParams.forEach(param -> {
+            realOtherParams.put(param.get("agName"), param.containsKey("value") ? param.get("value") : param.get("defaultValue"));
+        });
+        // move data
+        String[] batches = taskVo.getDataBatchNums().split(",");
+        String filepath = "/" + UUID.randomUUID().toString().replace("-", "_");
+        for (String batch : batches) {
+            copyFilesToPath(batch, filepath, "e_");
+        }
 
-            List<Data> dataListInfo = dataList.stream().filter(data -> !StringUtils.isEmpty(data.getUrl())).toList();
-            if (dataListInfo.isEmpty()) {
-                this.updateFail(Long.valueOf(dataAmplifyDto.getId()));
-                continue;
-            }
-            String filePath = TaaisConfig.getUploadPath();
-            LocalDate currentDate = LocalDate.now();
-            // 定义日期格式器
-            DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy/MM/dd");
-            String formattedDate = currentDate.format(formatter);
-            filePath = filePath + File.separator + formattedDate;
-            String finalFilePath = filePath;
-            Map<String, String> otherParams = new HashMap<>();
-            for (Map<String, String> param : dataAmplifyDto.getOtherParams()) {
-                otherParams.put(param.get("agName"), param.get("defaultValue"));
+        // post request
+        Map<String, Object> params = new HashMap<>();
+        params.put("bizType", TYPE_DATA_EXPAND);
+        params.put("bizId", String.valueOf(taskVo.getId()));
+        params.put("logPath", PATH_PREFIX + filepath + "/log.log");
+        params.put("inputImagePath", PATH_PREFIX + filepath);
+        params.put("otherParams", realOtherParams);
+
+        String[] outputs = taskVo.getOutputImagePath().split(";");
+        log.info("check outputs: {} ; {}", outputs, outputs[0]);
+        taskVo.setInputImagePath(String.valueOf(outputs.length));
+        for (String path : outputs) {
+            final String resultPath = TargetIdentificationTaskServiceImpl.PATH_PREFIX + path;
+            params.put("outputImagePath", resultPath);
+
+            log.info("check data expand: {}", params);
+            try {
+                String url = "http://127.0.0.1:11001/augment";
+                String res = HttpUtil.post(url, JSONUtil.toJsonStr(params));
+                taskVo.setStatus(TASK_STATUS_PROCESSING);
+            } catch (Exception e) {
+                log.error("HTTP请求失败",e);
+                taskVo.setStatus(TASK_STATUS_FAILED);
+                return CommonResult.fail("HTTP请求失败" + e.getMessage());
+            } finally {
+                dataAmplificationTaskService.update(taskVo);
             }
-            dataListInfo.forEach(dataInfo -> {
-                try {
-                    boolean success = true;
-                    String message = "";
-                    Date startTime = new Date();
-
-                    //循环调用Python扩增接口
-                    Map<String, Object> bodyJson = new HashMap<>();
-                    bodyJson.put("bizType", "数据扩增");
-                    bodyJson.put("bizId", dataAmplifyDto.getId());
-                    bodyJson.put("augmentationType", dataAmplifyDto.getAugmentationType());
-                    bodyJson.put("inputImagePath", dataInfo.getUrl());
-                    String outputImagePath = finalFilePath + AMPLIFY + System.currentTimeMillis();
-                    File desc = new File(outputImagePath);
-                    if (!desc.exists()) {
-                        log.info("创建文件目录: {}", desc.mkdirs());
-                    }
-                    bodyJson.put("outputImagePath", outputImagePath);
-                    bodyJson.put("otherParams", otherParams);
-                    String logPath = TaaisConfig.getProfile() + "/task/log/" + dataAmplifyDto.getId() + "_log.log";
-                    System.out.println("logPath===>" + logPath);
-                    bodyJson.put("logPath", logPath);
-                    //实际请求接口,接口未提供,暂且注释
-                    String response = HttpRequest.post(sysDictDataVo.getDictValue())
-                        .body(JsonUtils.toJsonString(bodyJson))
-                        .execute().body();
-//                String response = "{\"status\":200,\"msg\":\"扩增成功\"}";
-                    ObjectMapper objectMapper = new ObjectMapper();
-                    JsonNode rootNode = objectMapper.readTree(response);
-                    String resultCode = rootNode.path(RESULT_CODE).asText();
-                    //判断接口是否响应成功
-                    if (!RESULT_STATUS.equals(resultCode)) {
-                        success = false;
-                    }
-                    message = rootNode.path("msg").asText();
-                    //处理当前目录文件,并进行入库
-                    saveDataInfo(outputImagePath, dataInfo);
-
-                    DataAmplificationTaskVo taskVo = dataAmplificationTaskService.selectById(Long.valueOf(dataAmplifyDto.getId()));
-                    Date endTime = new Date();
-                    DataAmplificationTaskBo update = new DataAmplificationTaskBo();
-                    if (taskVo.getInputImagePath() != null) {
-                        update.setInputImagePath(taskVo.getInputImagePath() + "|" + dataInfo.getUrl());
-                    } else {
-                        update.setInputImagePath(dataInfo.getUrl());
-                    }
-                    if (taskVo.getOutputImagePath() != null) {
-                        update.setOutputImagePath(taskVo.getOutputImagePath() + "|" + outputImagePath);
-                    } else {
-                        update.setOutputImagePath(outputImagePath);
-                    }
-                    update.setId(Long.valueOf(dataAmplifyDto.getId()));
-                    update.setStartTime(startTime);
-                    update.setEndTime(endTime);
-                    update.setCostSecond((int) (endTime.getTime() - startTime.getTime()));
-                    update.setStatus(success ? BizConstant.TASK_STATUS_SUCCEED : BizConstant.TASK_STATUS_FAILED);
-                    update.setLog(taskVo.getLog() + "|" + message);
-                    update.setVersion(taskVo.getVersion());
-                    update.setRemarks(taskVo.getRemarks() + "|" + (int) (endTime.getTime() - startTime.getTime()));
-                    dataAmplificationTaskService.update(update);
-                } catch (Exception e) {
-                    throw new RuntimeException(e);
-                }
-            });
         }
-        //根据批次号获取该批次的所有文件数据
-        return CommonResult.success();
-    }
 
-    private void updateFail(Long id) {
-        DataAmplificationTaskVo taskVo = dataAmplificationTaskService.selectById(id);
-        DataAmplificationTaskBo update = new DataAmplificationTaskBo();
-        update.setId(taskVo.getId());
-        update.setStatus(BizConstant.TASK_STATUS_FAILED);
-        update.setLog(taskVo.getLog() + "|" + "该批次下没有文件数据,请重新选择批次!");
-        update.setVersion(taskVo.getVersion());
-        dataAmplificationTaskService.update(update);
+        return CommonResult.success();
     }
 
-    private void updateEmp(Long id) {
-        DataAmplificationTaskVo taskVo = dataAmplificationTaskService.selectById(id);
-        DataAmplificationTaskBo update = new DataAmplificationTaskBo();
-        update.setOutputImagePath("");
-        update.setInputImagePath("");
-        update.setId(id);
-        update.setLog("");
-        update.setVersion(taskVo.getVersion());
-        update.setRemarks("");
-        dataAmplificationTaskService.update(update);
-    }
 
+    public static final String PATH_PREFIX = TaaisConfig.getProfile() + "/amplify";
+    public static final String WORK_DIR = TaaisConfig.getProfile();
     /**
-     * 解析目标目录所有文件,进行文件更名并入库
-     *
-     * @param directoryPath:目录地址
-     * @param dataInfo:深拷贝对象
+     * 移动文件到对应文件夹
+     * @param batch
+     * @param path
+     * @param namePrefix 文件名前缀
      */
-    public void saveDataInfo(String directoryPath, Data dataInfo) {
-        try {
-            // 获取指定目录下所有文件
-            File directory = new File(directoryPath);
-            List<File> extractedImagesFileList = new ArrayList<>();
-            if (directory.exists() && directory.isDirectory()) {
-                File[] files = directory.listFiles();
-                if (files != null) {
-                    for (File file : files) {
-                        initFileInfo(directoryPath, extractedImagesFileList, file.isDirectory(), file.getName());
-                    }
-                }
-            }
+    private void copyFilesToPath(String batch, String path, String namePrefix) {
+        String[] batches = batch.split(",");
 
-            // 获取ID集合
-            List<Long> ids = dataMapper.getIds(extractedImagesFileList.size());
-            if (ids.isEmpty()) {
-                return;
-            }
-
-            List<Data> dataList = new ArrayList<>();
-            AtomicInteger countSize = new AtomicInteger();
-            extractedImagesFileList.forEach(fileInfo -> {
-                Long id = ids.get(countSize.get());
-                Data data = new Data();
-                BeanUtils.copyProperties(dataInfo, data);
+        File dir = new File(PATH_PREFIX + path);
+        if (!dir.exists()) {
+            dir.mkdirs();
+        }
+        dir = new File(PATH_PREFIX + path + "/images");
+        if (!dir.exists()) {
+            dir.mkdirs();
+        }
+        dir = new File(PATH_PREFIX + path + "/labels");
+        if (!dir.exists()) {
+            dir.mkdirs();
+        }
+        dir = new File(PATH_PREFIX + path + "/result");
+        if (!dir.exists()) {
+            dir.mkdirs();
+        }
 
-                if (checkLabeled(fileInfo.getPath())) {
-                    data.setLabeled(Boolean.TRUE);
-                } else {
-                    data.setLabeled(Boolean.FALSE);
+        System.out.println(dir.getAbsolutePath());
+
+        for (String batchNum : batches) {
+            List<DataVo> dataVoList = getDataByBatchNum(batchNum);
+            for (DataVo dataVo : dataVoList) {
+                String[] strings = dataVo.getUrl().split("/profile");
+                String relativePath = WORK_DIR + strings[strings.length - 1];
+                relativePath = relativePath.replace("\\", "/").replace("//", "/");
+                File file = new File(relativePath);
+                System.out.println(file.getAbsolutePath());
+                if (file.exists()) {
+                    try {
+                        File dist = new File(PATH_PREFIX + path + "/images/" + namePrefix + file.getName());
+                        org.apache.commons.io.FileUtils.copyFile(file, dist);
+                        System.out.println("file dist: " + dist.getAbsolutePath());
+                    } catch (IOException e) {
+                        Log.debug("bug found");
+                        continue;
+                    }
                 }
-
-                try {
-                    Path path = Paths.get(fileInfo.getAbsolutePath());
-                    BasicFileAttributes attrs = Files.readAttributes(path, BasicFileAttributes.class);
-                    Instant creationTime = attrs.lastModifiedTime().toInstant();
-                    Date date = Date.from(creationTime);
-
-                    data.setId(id);
-                    data.setGatherTime(date);
-                    data.setName(fileInfo.getName());
-
-                    // 更改图片文件名称
-                    String fileHeaderSuffix = StringUtils.substring(fileInfo.getName(), fileInfo.getName().lastIndexOf("."), fileInfo.getName().length());
-                    String destInfo = fileInfo.getPath().replaceAll(fileInfo.getName(), "");
-                    File newFile = new File(destInfo, id + fileHeaderSuffix);
-                    File oldFile = new File(destInfo, fileInfo.getName());
-                    log.info("saveDataInfo更改用户上传图片文件名称:{}", oldFile.renameTo(newFile));
-
-                    String imagePath = FileUploadUtils.getPathFileName(destInfo, id + fileHeaderSuffix);
-                    data.setUrl(imagePath);
-
-                    if (data.getLabeled()) {
-                        String labeledPath = fileInfo.getPath().replaceFirst("[.][^.]+$", "") + ".txt";
-                        File labeledNewFile = new File(destInfo, id + ".txt");
-                        File labeledOldFile = new File(labeledPath);
-                        log.info("saveDataInfo更改用户上传标注文件名称:{}", labeledOldFile.renameTo(labeledNewFile));
-                        String labelUrl = FileUploadUtils.getPathFileName(destInfo, id + ".txt");
-                        data.setLabelurl(labelUrl);
+                if (dataVo.getLabelurl() != null) {
+                    strings = dataVo.getLabelurl().split("/profile");
+                    relativePath = WORK_DIR + strings[strings.length - 1];
+                    relativePath = relativePath.replace("\\", "/").replace("//", "/");
+                    file = new File(relativePath);
+                    if (file.exists()) {
+                        try {
+                            File dist = new File(PATH_PREFIX + path + "/labels/" + namePrefix + file.getName());
+                            org.apache.commons.io.FileUtils.copyFile(file, dist);
+                            System.out.println("file dist: " + dist.getAbsolutePath());
+                        } catch (IOException e) {
+                            Log.debug("bug found");
+                        }
                     }
-                    dataList.add(data);
-                } catch (IOException e) {
-                    throw new RuntimeException(e);
                 }
-                countSize.getAndIncrement();
-            });
-
-            dataMapper.insertBatch(dataList);
-        } catch (Exception e) {
-            log.error("[saveDataInfo]数据集处理出现未知异常.e:", e);
+            }
         }
     }
-
 }

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

@@ -222,7 +222,7 @@ public class TargetIdentificationTaskServiceImpl extends BaseServiceImpl<TargetI
         // 创建扩增子任务
         if (taskDto.getHasTrainAugmentation()) {
             if (taskDto.getTrainAugmentationParams() != null && StringUtils.isNotEmpty(taskDto.getTrainAugmentationParams().getOtherParams())) {
-                createDataAmplifyTask(taskBo.getId(), taskDto);
+                createDataAmplifyTask(taskBo.getId(), taskDto, records);
             }
         }
         return null;
@@ -535,27 +535,27 @@ public class TargetIdentificationTaskServiceImpl extends BaseServiceImpl<TargetI
         }
     }
 
-    private void createDataAmplifyTask(Long taskId, CreateTargetIdentificationTaskDto taskDto) {
+    private void createDataAmplifyTask(Long taskId, CreateTargetIdentificationTaskDto taskDto, Map<String, String> records) {
         List<String> trainBatchNumList = taskDto.getTrainBatchNumList();
-        for (String batchNumber : trainBatchNumList) {
-            TargetIdentificationSubtaskBo subtask = new TargetIdentificationSubtaskBo();
-            subtask.setName("数据扩增");
-            subtask.setStatus(BizConstant.TASK_STATUS_PENDING);
-            subtask.setTaskId(taskId);
-            subtask.setRemarks("DEFAULT_REMARK");
-            TargetIdentificationSubtask insertSubtask = subtaskService.insertSubtask(subtask);
-
-            DataAmplifyDto amplifyDto = taskDto.getTrainAugmentationParams();
-            DataAmplificationTaskBo dataAmplificationTaskBo = new DataAmplificationTaskBo();
-            dataAmplificationTaskBo.setSubTaskId(insertSubtask.getId());
-            dataAmplificationTaskBo.setName(amplifyDto.getTaskName());
-            dataAmplificationTaskBo.setStatus(BizConstant.TASK_STATUS_PENDING);
-            dataAmplificationTaskBo.setDataBatchNums(batchNumber);
-            dataAmplificationTaskBo.setAugmentationType(amplifyDto.getAugmentationType());
-            dataAmplificationTaskBo.setParameters(JsonUtils.toJsonString(amplifyDto.getOtherParams()));
-            dataAmplificationTaskBo.setDelFlag(0);
-            dataAmplificationTaskService.insert(dataAmplificationTaskBo);
-        }
+
+        TargetIdentificationSubtaskBo subtask = new TargetIdentificationSubtaskBo();
+        subtask.setName("数据扩增");
+        subtask.setStatus(BizConstant.TASK_STATUS_PENDING);
+        subtask.setTaskId(taskId);
+        subtask.setRemarks("DEFAULT_REMARK");
+        TargetIdentificationSubtask insertSubtask = subtaskService.insertSubtask(subtask);
+
+        DataAmplifyDto amplifyDto = taskDto.getTrainAugmentationParams();
+        DataAmplificationTaskBo dataAmplificationTaskBo = new DataAmplificationTaskBo();
+        dataAmplificationTaskBo.setSubTaskId(insertSubtask.getId());
+        dataAmplificationTaskBo.setName(amplifyDto.getTaskName());
+        dataAmplificationTaskBo.setStatus(BizConstant.TASK_STATUS_PENDING);
+        dataAmplificationTaskBo.setDataBatchNums(amplifyDto.getBatchNum());
+        dataAmplificationTaskBo.setAugmentationType(amplifyDto.getAugmentationType());
+        dataAmplificationTaskBo.setParameters(JsonUtils.toJsonString(amplifyDto.getOtherParams()));
+        dataAmplificationTaskBo.setOutputImagePath(String.join(";", records.values()));
+        dataAmplificationTaskBo.setDelFlag(0);
+        dataAmplificationTaskService.insert(dataAmplificationTaskBo);
     }
 
 

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

@@ -339,7 +339,7 @@ public class VideoStableServiceImpl extends BaseServiceImpl<VideoStableMapper, V
 
         HttpResponseEntity responseEntity = sendPostMsg(url, videoStable);
         if (ObjectUtil.isNotNull(responseEntity) && responseEntity.getStatus() == 200) {
-            videoStable.setStatus(BizConstant.VideoStatus.INTERRUPTED);
+            videoStable.setStatus(BizConstant.VideoStatus.NOT_START);
             updateById(videoStable);
             return CommonResult.fail("终止任务成功");
         } else {
@@ -347,6 +347,24 @@ public class VideoStableServiceImpl extends BaseServiceImpl<VideoStableMapper, V
         }
     }
 
+    @Override
+    public CommonResult hangup(Long id) {
+        VideoStable videoStable = getById(id);
+
+        videoStable.setLogPath(videoStable.getOutputPath() + File.separator + getLogFileName(videoStable));
+
+        String url = algorithmConfigService.getByAlgorithmName("电子稳相").getPauseApi();
+
+        HttpResponseEntity responseEntity = sendPostMsg(url, videoStable);
+        if (ObjectUtil.isNotNull(responseEntity) && responseEntity.getStatus() == 200) {
+            videoStable.setStatus(BizConstant.VideoStatus.INTERRUPTED);
+            updateById(videoStable);
+            return CommonResult.fail("暂停任务成功");
+        } else {
+            return CommonResult.fail("暂停任务失败");
+        }
+    }
+
     @Override
     public List<Map<String, String>> getImages(Long inputOdssId) {
         // 检查input_oss_id是否存在