allen 1 anno fa
parent
commit
4d2d4ebb38

+ 3 - 3
taais-common/taais-common-core/src/main/java/com/taais/common/core/utils/ServletUtils.java

@@ -29,7 +29,7 @@ public class ServletUtils extends JakartaServletUtil {
      * 获取String参数
      */
     public static String getParameter(String name) {
-        return getRequest().getParameter(name);
+        return getRequest() == null ? null :getRequest().getParameter(name);
     }
 
     /**
@@ -57,7 +57,7 @@ public class ServletUtils extends JakartaServletUtil {
      * 获取Boolean参数
      */
     public static Boolean getParameterToBool(String name) {
-        return Convert.toBool(getRequest().getParameter(name));
+        return Convert.toBool(getRequest() == null ? null: getRequest().getParameter(name));
     }
 
     /**
@@ -96,7 +96,7 @@ public class ServletUtils extends JakartaServletUtil {
      * 获取request
      */
     public static HttpServletRequest getRequest() {
-        return getRequestAttributes().getRequest();
+        return getRequestAttributes() == null ? null : getRequestAttributes().getRequest();
     }
 
     /**

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

@@ -131,10 +131,14 @@ public class AlgorithmTaskController extends BaseController {
     @Log(title = "算法任务", businessType = BusinessType.INSERT)
     @RepeatSubmit()
     @PostMapping("/create")
-    public CommonResult<Void> create(@Validated @RequestBody CreateTaskDto taskDto) {
+    public CommonResult<Object> create(@RequestBody CreateTaskDto taskDto) {
         String string = algorithmTaskService.create(taskDto);
         if (StringUtils.isNotEmpty(string)) {
-            return CommonResult.fail("新增算法任务记录失败!失败圆晕:"+string);
+            try {
+                return CommonResult.success(Long.parseLong(string));
+            } catch (NumberFormatException e) {
+                return CommonResult.fail("新增算法任务记录失败!失败圆晕:"+string);
+            }
         }
         return CommonResult.success();
     }

+ 3 - 1
taais-modules/taais-biz/src/main/java/com/taais/biz/domain/dto/task/AlgorithmSubtaskParamDto.java

@@ -3,6 +3,8 @@ package com.taais.biz.domain.dto.task;
 import com.taais.biz.domain.dto.AlgorithmConfigParamDto;
 import lombok.Data;
 
+import java.util.List;
+
 /**
  * @author allen
  */
@@ -12,5 +14,5 @@ public class AlgorithmSubtaskParamDto {
 
     public String resultPath;
 
-    public AlgorithmConfigParamDto otherParams;
+    public List<AlgorithmConfigParamDto> otherParams;
 }

+ 4 - 2
taais-modules/taais-biz/src/main/java/com/taais/biz/service/impl/AlgorithmBizProcessServiceImpl.java

@@ -105,8 +105,10 @@ public class AlgorithmBizProcessServiceImpl extends BaseServiceImpl<AlgorithmBiz
     @Override
     public boolean insert(AlgorithmBizProcessBo algorithmBizProcessBo) {
     AlgorithmBizProcess algorithmBizProcess =MapstructUtils.convert(algorithmBizProcessBo, AlgorithmBizProcess. class);
-
-        return this.save(algorithmBizProcess);//使用全局配置的雪花算法主键生成器生成ID值
+        boolean save = this.save(algorithmBizProcess);
+        algorithmBizProcessBo.setId(algorithmBizProcess.getId());
+        algorithmBizProcessBo.setVersion(algorithmBizProcess.getVersion());
+        return save;//使用全局配置的雪花算法主键生成器生成ID值
     }
 
     /**

+ 4 - 2
taais-modules/taais-biz/src/main/java/com/taais/biz/service/impl/AlgorithmDataProcessServiceImpl.java

@@ -106,8 +106,10 @@ public class AlgorithmDataProcessServiceImpl extends BaseServiceImpl<AlgorithmDa
     @Override
     public boolean insert(AlgorithmDataProcessBo algorithmDataProcessBo) {
     AlgorithmDataProcess algorithmDataProcess =MapstructUtils.convert(algorithmDataProcessBo, AlgorithmDataProcess. class);
-
-        return this.save(algorithmDataProcess);//使用全局配置的雪花算法主键生成器生成ID值
+        boolean save = this.save(algorithmDataProcess);
+        algorithmDataProcessBo.setId(algorithmDataProcess.getId());
+        algorithmDataProcessBo.setVersion(algorithmDataProcess.getVersion());
+        return save;//使用全局配置的雪花算法主键生成器生成ID值
     }
 
     /**

+ 4 - 2
taais-modules/taais-biz/src/main/java/com/taais/biz/service/impl/AlgorithmSubtaskServiceImpl.java

@@ -121,8 +121,10 @@ public class AlgorithmSubtaskServiceImpl extends BaseServiceImpl<AlgorithmSubtas
     @Override
     public boolean insert(AlgorithmSubtaskBo algorithmSubtaskBo) {
     AlgorithmSubtask algorithmSubtask =MapstructUtils.convert(algorithmSubtaskBo, AlgorithmSubtask. class);
-
-        return this.save(algorithmSubtask);//使用全局配置的雪花算法主键生成器生成ID值
+        boolean save = this.save(algorithmSubtask);
+        algorithmSubtaskBo.setId(algorithmSubtask.getId());
+        algorithmSubtask.setVersion(algorithmSubtask.getVersion());
+        return save;//使用全局配置的雪花算法主键生成器生成ID值
     }
 
     /**

+ 41 - 12
taais-modules/taais-biz/src/main/java/com/taais/biz/service/impl/AlgorithmTaskServiceImpl.java

@@ -2,6 +2,7 @@ package com.taais.biz.service.impl;
 
 import cn.hutool.core.util.ObjectUtil;
 import com.google.gson.Gson;
+import com.google.gson.reflect.TypeToken;
 import com.mybatisflex.core.paginate.Page;
 import com.mybatisflex.core.query.QueryWrapper;
 import com.taais.biz.constant.BizConstant;
@@ -34,6 +35,7 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import java.io.IOException;
+import java.lang.reflect.Type;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
@@ -134,8 +136,10 @@ public class AlgorithmTaskServiceImpl extends BaseServiceImpl<AlgorithmTaskMappe
     @Override
     public boolean insert(AlgorithmTaskBo algorithmTaskBo) {
     AlgorithmTask algorithmTask =MapstructUtils.convert(algorithmTaskBo, AlgorithmTask. class);
-
-        return this.save(algorithmTask);//使用全局配置的雪花算法主键生成器生成ID值
+        boolean save = this.save(algorithmTask);
+        algorithmTaskBo.setId(algorithmTask.getId());
+        algorithmTaskBo.setVersion(algorithmTask.getVersion());
+        return save;//使用全局配置的雪花算法主键生成器生成ID值
     }
 
     /**
@@ -180,7 +184,7 @@ public class AlgorithmTaskServiceImpl extends BaseServiceImpl<AlgorithmTaskMappe
         // 异步处理
         AlgorithmTaskServiceImpl taskService = applicationContext.getBean(AlgorithmTaskServiceImpl.class);
         taskService.processTask(taskDto, algorithmTask);
-        return null;
+        return String.valueOf(algorithmTask.getId());
     }
 
     // task start
@@ -250,8 +254,8 @@ public class AlgorithmTaskServiceImpl extends BaseServiceImpl<AlgorithmTaskMappe
         }
         // 11 如果有该,推理数据增强
         if (selectTask.contains(BizConstant.STEP11_REASONING_DATA_ENHANCEMENT)) {
+            reasoningDataFolderPathList = createReasoningDataEnhancementSubtask(algorithmTask, taskDto, reasoningDataFolderPathList);
         }
-        reasoningDataFolderPathList = createReasoningDataEnhancementSubtask(algorithmTask, taskDto, reasoningDataFolderPathList);
         // 12 如果有该,推理数据扩充
         if (selectTask.contains(BizConstant.STEP12_REASONING_DATA_EXPANSION)) {
             reasoningDataFolderPathList = createReasoningDataExpansionSubtask(algorithmTask, taskDto, reasoningDataFolderPathList);
@@ -260,6 +264,7 @@ public class AlgorithmTaskServiceImpl extends BaseServiceImpl<AlgorithmTaskMappe
         if (selectTask.contains(BizConstant.STEP13_REASONING)) {
             createReasoningSubtask(algorithmTask, taskDto, reasoningDataFolderPathList);
         }
+        log.info("=========================创建结束===============================");
     }
 
     private void createTestSubtask(AlgorithmTaskBo algorithmTask, CreateTaskDto taskDto, List<String> testDataFolderPathList) {
@@ -276,11 +281,13 @@ public class AlgorithmTaskServiceImpl extends BaseServiceImpl<AlgorithmTaskMappe
                 algorithmBizProcessBo.setStatus(BizConstant.TASK_STATUS_PENDING);
                 algorithmBizProcessBo.setPreprocessPath(testDataFolderPath);
                 algorithmBizProcessBo.setIndex(index);
+                algorithmBizProcessBo.setSubTaskId(algorithmSubtask.getId());
                 bizProcessService.insert(algorithmBizProcessBo);
 
                 // 组装结果路径 并更新结果路径和参数
                 String resultPath = BizConstant.TASK_FOLDER_PATH_HEAD + algorithmTask.getId()
                     + BizConstant.TASK_FOLDER_PATH_MID_TEST + BizConstant.TASK_FOLDER_PATH_TRAIL_RESULT + algorithmBizProcessBo.getId() + "/";
+                resultPath = resultPath.replaceAll("//", "/");
                 String finallyParams = buildFinallyParams(dto.getParams(), testDataFolderPath, resultPath);
                 algorithmBizProcessBo.setResultPath(resultPath);
                 algorithmBizProcessBo.setParameters(finallyParams);
@@ -310,7 +317,9 @@ public class AlgorithmTaskServiceImpl extends BaseServiceImpl<AlgorithmTaskMappe
             // 组装结果路径 更新参数和结果路径
             String resultPath = BizConstant.TASK_FOLDER_PATH_HEAD + algorithmTask.getId()
                 + BizConstant.TASK_FOLDER_PATH_MID_TEST + BizConstant.TASK_FOLDER_PATH_TRAIL_EXPANSION + processBo.getId() + "/";
+            resultPath = resultPath.replaceAll("//", "/");
             String finallyParams = buildFinallyParams(taskDto.getTestDataExpansion().getParams(), testDataFolderPath, resultPath);
+            processBo.setResultPath(resultPath);
             processBo.setParameters(finallyParams);
             processBo.setLog(resultPath+BizConstant.TASK_FOLDER_LOG_PATH);
             processService.update(processBo);
@@ -340,10 +349,11 @@ public class AlgorithmTaskServiceImpl extends BaseServiceImpl<AlgorithmTaskMappe
             // 组装结果路径 并更新参数和结果路径
             String resultPath = BizConstant.TASK_FOLDER_PATH_HEAD + algorithmTask.getId()
                 + BizConstant.TASK_FOLDER_PATH_MID_TEST + BizConstant.TASK_FOLDER_PATH_TRAIL_ENHANCEMENT + processBo.getId() + "/";
+            resultPath = resultPath.replaceAll("//", "/");
             // create AlgorithmDataProcess 创建数据处理
             String finallyParams = buildFinallyParams(taskDto.getTestDataEnhancement().getParams(), testDataFolderPath, resultPath);
-            processBo.setParameters(finallyParams);
             processBo.setResultPath(resultPath);
+            processBo.setParameters(finallyParams);
             processBo.setLog(resultPath+BizConstant.TASK_FOLDER_LOG_PATH);
             processService.update(processBo);
             returnList.add(resultPath);
@@ -365,8 +375,9 @@ public class AlgorithmTaskServiceImpl extends BaseServiceImpl<AlgorithmTaskMappe
 
             String destinationPath = BizConstant.TASK_FOLDER_PATH_HEAD + algorithmTask.getId()
                 + BizConstant.TASK_FOLDER_PATH_MID_TEST + BizConstant.TASK_FOLDER_PATH_TRAIL_ORIGINAL + index + "/";
+            destinationPath = destinationPath.replaceAll("//", "/");
             // 同步到文件夹
-            copyToDestinationFolder(testDataList, destinationPath.replaceAll("//","/"));
+            copyToDestinationFolder(testDataList, destinationPath);
             returnList.add(destinationPath);
             index++;
         }
@@ -387,11 +398,13 @@ public class AlgorithmTaskServiceImpl extends BaseServiceImpl<AlgorithmTaskMappe
                 algorithmBizProcessBo.setStatus(BizConstant.TASK_STATUS_PENDING);
                 algorithmBizProcessBo.setPreprocessPath(reasoningDataFolderPath);
                 algorithmBizProcessBo.setIndex(index);
+                algorithmBizProcessBo.setSubTaskId(algorithmSubtask.getId());
                 bizProcessService.insert(algorithmBizProcessBo);
 
                 // 组装结果路径 并更新结果路径和参数
                 String resultPath = BizConstant.TASK_FOLDER_PATH_HEAD + algorithmTask.getId()
                     + BizConstant.TASK_FOLDER_PATH_MID_REASONING + BizConstant.TASK_FOLDER_PATH_TRAIL_RESULT + algorithmBizProcessBo.getId() + "/";
+                resultPath = resultPath.replaceAll("//", "/");
                 String finallyParams = buildFinallyParams(dto.getParams(), reasoningDataFolderPath, resultPath);
                 algorithmBizProcessBo.setResultPath(resultPath);
                 algorithmBizProcessBo.setParameters(finallyParams);
@@ -421,7 +434,9 @@ public class AlgorithmTaskServiceImpl extends BaseServiceImpl<AlgorithmTaskMappe
             // 组装结果路径 更新参数和结果路径
             String resultPath = BizConstant.TASK_FOLDER_PATH_HEAD + algorithmTask.getId()+"/"
                 + BizConstant.TASK_FOLDER_PATH_MID_REASONING + BizConstant.TASK_FOLDER_PATH_TRAIL_EXPANSION + processBo.getId() + "/";
+            resultPath = resultPath.replaceAll("//", "/");
             String finallyParams = buildFinallyParams(taskDto.getReasoningDataExpansion().getParams(), reasoningDataFolderPath, resultPath);
+            processBo.setResultPath(resultPath);
             processBo.setParameters(finallyParams);
             processBo.setLog(resultPath+BizConstant.TASK_FOLDER_LOG_PATH);
             processService.update(processBo);
@@ -454,10 +469,11 @@ public class AlgorithmTaskServiceImpl extends BaseServiceImpl<AlgorithmTaskMappe
             // 组装结果路径 并更新参数和结果路径
             String resultPath = BizConstant.TASK_FOLDER_PATH_HEAD + algorithmTask.getId() + "/"
                 + BizConstant.TASK_FOLDER_PATH_MID_REASONING + BizConstant.TASK_FOLDER_PATH_TRAIL_ENHANCEMENT + processBo.getId() + "/";
+            resultPath = resultPath.replaceAll("//", "/");
             // create AlgorithmDataProcess 创建数据处理
             String finallyParams = buildFinallyParams(taskDto.getReasoningDataEnhancement().getParams(), reasoningDataFolderPath, resultPath);
-            processBo.setParameters(finallyParams);
             processBo.setResultPath(resultPath);
+            processBo.setParameters(finallyParams);
             processBo.setLog(resultPath+BizConstant.TASK_FOLDER_LOG_PATH);
             processService.update(processBo);
             returnList.add(resultPath);
@@ -479,8 +495,9 @@ public class AlgorithmTaskServiceImpl extends BaseServiceImpl<AlgorithmTaskMappe
 
             String destinationPath = BizConstant.TASK_FOLDER_PATH_HEAD + algorithmTask.getId()
                 + BizConstant.TASK_FOLDER_PATH_MID_REASONING + BizConstant.TASK_FOLDER_PATH_TRAIL_ORIGINAL + index + "/";
+            destinationPath = destinationPath.replaceAll("//", "/");
             // 同步到文件夹
-            copyToDestinationFolder(reasoningDataList, destinationPath.replaceAll("//","/"));
+            copyToDestinationFolder(reasoningDataList, destinationPath);
             returnList.add(destinationPath);
             index++;
         }
@@ -508,10 +525,11 @@ public class AlgorithmTaskServiceImpl extends BaseServiceImpl<AlgorithmTaskMappe
             // 组装结果路径 并更新参数和结果路径
             String resultPath = BizConstant.TASK_FOLDER_PATH_HEAD + algorithmTask.getId()
                 + BizConstant.TASK_FOLDER_PATH_MID_TRAIN + BizConstant.TASK_FOLDER_PATH_TRAIL_ENHANCEMENT + processBo.getId() + "/";
+            resultPath = resultPath.replaceAll("//", "/");
             // create AlgorithmDataProcess 创建数据处理
             String finallyParams = buildFinallyParams(taskDto.getTrainDataEnhancement().getParams(), trainDataFolderPath, resultPath);
-            processBo.setParameters(finallyParams);
             processBo.setResultPath(resultPath);
+            processBo.setParameters(finallyParams);
             processBo.setLog(resultPath+BizConstant.TASK_FOLDER_LOG_PATH);
             processService.update(processBo);
             returnList.add(resultPath);
@@ -532,14 +550,17 @@ public class AlgorithmTaskServiceImpl extends BaseServiceImpl<AlgorithmTaskMappe
                 // 创建算法处理任务
                 AlgorithmBizProcessBo algorithmBizProcessBo = new AlgorithmBizProcessBo();
                 algorithmBizProcessBo.setAlgorithmId(dto.getAlgorithmId());
+                algorithmBizProcessBo.setModelId(dto.getModelId());
                 algorithmBizProcessBo.setStatus(BizConstant.TASK_STATUS_PENDING);
                 algorithmBizProcessBo.setPreprocessPath(trainDataFolderPath);
                 algorithmBizProcessBo.setIndex(index);
+                algorithmBizProcessBo.setSubTaskId(algorithmSubtask.getId());
                 bizProcessService.insert(algorithmBizProcessBo);
 
                 // 组装结果路径 并更新结果路径和参数
                 String resultPath = BizConstant.TASK_FOLDER_PATH_HEAD + algorithmTask.getId()
                     + BizConstant.TASK_FOLDER_PATH_MID_TRAIN + BizConstant.TASK_FOLDER_PATH_TRAIL_RESULT + algorithmBizProcessBo.getId() + "/";
+                resultPath = resultPath.replaceAll("//", "/");
                 String finallyParams = buildFinallyParams(dto.getParams(), trainDataFolderPath, resultPath);
                 algorithmBizProcessBo.setResultPath(resultPath);
                 algorithmBizProcessBo.setParameters(finallyParams);
@@ -569,7 +590,9 @@ public class AlgorithmTaskServiceImpl extends BaseServiceImpl<AlgorithmTaskMappe
             // 组装结果路径 更新参数和结果路径
             String resultPath = BizConstant.TASK_FOLDER_PATH_HEAD + algorithmTask.getId()
                 + BizConstant.TASK_FOLDER_PATH_MID_TRAIN + BizConstant.TASK_FOLDER_PATH_TRAIL_EXPANSION + processBo.getId() + "/";
+            resultPath = resultPath.replaceAll("//", "/");
             String finallyParams = buildFinallyParams(taskDto.getTrainDataExpansion().getParams(), trainDataFolderPath, resultPath);
+            processBo.setResultPath(resultPath);
             processBo.setParameters(finallyParams);
             processBo.setLog(resultPath+BizConstant.TASK_FOLDER_LOG_PATH);
             processService.update(processBo);
@@ -585,6 +608,11 @@ public class AlgorithmTaskServiceImpl extends BaseServiceImpl<AlgorithmTaskMappe
         AlgorithmSubtaskBo algorithmSubtask = new AlgorithmSubtaskBo();
         algorithmSubtask.setTaskId(algorithmTask.getId());
         algorithmSubtask.setIndex(Long.valueOf(step));
+        // todo allen
+        algorithmSubtask.setName("todo allen");
+        algorithmSubtask.setType("todo allen");
+        algorithmSubtask.setParameters("null");
+
         algorithmSubtask.setStatus(BizConstant.TASK_STATUS_PENDING);
         return algorithmSubtask;
     }
@@ -594,7 +622,7 @@ public class AlgorithmTaskServiceImpl extends BaseServiceImpl<AlgorithmTaskMappe
         algorithmSubtaskParamDto.setSourcePath(trainDataFolderPath);
         algorithmSubtaskParamDto.setResultPath(resultPath);
         Gson gson = new Gson();
-        AlgorithmConfigParamDto otherParams = gson.fromJson(params, AlgorithmConfigParamDto.class);
+        List<AlgorithmConfigParamDto> otherParams = gson.fromJson(params, new TypeToken<List<AlgorithmConfigParamDto>>() {}.getType());
         algorithmSubtaskParamDto.setOtherParams(otherParams);
 
         // 将User对象转换为JSON字符串
@@ -613,7 +641,8 @@ public class AlgorithmTaskServiceImpl extends BaseServiceImpl<AlgorithmTaskMappe
             String destinationPath = BizConstant.TASK_FOLDER_PATH_HEAD + algorithmTask.getId()
                 + BizConstant.TASK_FOLDER_PATH_MID_TRAIN + BizConstant.TASK_FOLDER_PATH_TRAIL_ORIGINAL + index + "/";
             // 同步到文件夹
-            copyToDestinationFolder(trainDataList, destinationPath.replaceAll("//","/"));
+            destinationPath = destinationPath.replaceAll("//", "/");
+            copyToDestinationFolder(trainDataList, destinationPath);
             returnList.add(destinationPath);
             index++;
         }
@@ -642,7 +671,7 @@ public class AlgorithmTaskServiceImpl extends BaseServiceImpl<AlgorithmTaskMappe
 
     private List<DataVo> getDataListByDataSelect(DataSelectDto trainDataSelect) {
         String condition = trainDataSelect.getCondition();
-        if(trainDataSelect.getConditionSelected() && StringUtils.isNotEmpty(condition)){
+        if(trainDataSelect.getConditionSelected()){
             Gson gson = new Gson();
             DataBo data = gson.fromJson(condition, DataBo.class);
             return dataService.selectList(data);

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

@@ -3,15 +3,15 @@ package com.taais.biz.service.impl;
 import cn.hutool.core.util.ObjectUtil;
 import com.mybatisflex.core.paginate.Page;
 import com.mybatisflex.core.query.QueryWrapper;
-import com.taais.common.core.core.page.PageResult;
-import com.taais.common.core.utils.MapstructUtils;
-import com.taais.common.orm.core.page.PageQuery;
-import com.taais.common.orm.core.service.impl.BaseServiceImpl;
 import com.taais.biz.domain.Data;
 import com.taais.biz.domain.bo.DataBo;
 import com.taais.biz.domain.vo.DataVo;
 import com.taais.biz.mapper.DataMapper;
 import com.taais.biz.service.IDataService;
+import com.taais.common.core.core.page.PageResult;
+import com.taais.common.core.utils.MapstructUtils;
+import com.taais.common.orm.core.page.PageQuery;
+import com.taais.common.orm.core.service.impl.BaseServiceImpl;
 import jakarta.annotation.Resource;
 import org.springframework.stereotype.Service;