|
@@ -6,6 +6,13 @@ import java.util.List;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
import com.mybatisflex.core.paginate.Page;
|
|
|
import com.mybatisflex.core.query.QueryWrapper;
|
|
|
+import com.taais.biz.constant.BizConstant;
|
|
|
+import com.taais.biz.domain.bo.TargetIdentificationSubtaskBo;
|
|
|
+import com.taais.biz.domain.bo.TargetIdentificationSubtaskDetailsBo;
|
|
|
+import com.taais.biz.domain.dto.task.CreateTargetIdentificationTaskDto;
|
|
|
+import com.taais.biz.domain.dto.task.TaskDto;
|
|
|
+import com.taais.biz.service.ITargetIdentificationSubtaskDetailsService;
|
|
|
+import com.taais.biz.service.ITargetIdentificationSubtaskService;
|
|
|
import com.taais.common.core.utils.MapstructUtils;
|
|
|
import com.taais.common.core.utils.StringUtils;
|
|
|
import com.taais.common.orm.core.page.PageQuery;
|
|
@@ -32,6 +39,11 @@ public class TargetIdentificationTaskServiceImpl extends BaseServiceImpl<TargetI
|
|
|
@Resource
|
|
|
private TargetIdentificationTaskMapper targetIdentificationTaskMapper;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private ITargetIdentificationSubtaskService subtaskService;
|
|
|
+ @Resource
|
|
|
+ private ITargetIdentificationSubtaskDetailsService subtaskDetailsService;
|
|
|
+
|
|
|
@Override
|
|
|
public QueryWrapper query() {
|
|
|
return super.query().from(TARGET_IDENTIFICATION_TASK);
|
|
@@ -130,7 +142,76 @@ public class TargetIdentificationTaskServiceImpl extends BaseServiceImpl<TargetI
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public String createTask(Object o) {
|
|
|
+ @Transactional
|
|
|
+ public String createTask(CreateTargetIdentificationTaskDto taskDto) {
|
|
|
+ String errorMsg = "";
|
|
|
+ // 检查数据是否有问题
|
|
|
+ errorMsg = checkTask(taskDto);
|
|
|
+
|
|
|
+ if (StringUtils.isNotEmpty(errorMsg)){
|
|
|
+ return errorMsg;
|
|
|
+ }
|
|
|
+ // 创建任务
|
|
|
+ TargetIdentificationTaskBo taskBo = new TargetIdentificationTaskBo();
|
|
|
+ taskBo.setName(taskDto.getTaskName());
|
|
|
+ taskBo.setStatus(BizConstant.TASK_STATUS_PENDING);
|
|
|
+ // todo 确保保存后有id
|
|
|
+ this.insert(taskBo);
|
|
|
+
|
|
|
+ // 创建训练子任务
|
|
|
+ if(taskDto.getTaskItemList().contains(CreateTargetIdentificationTaskDto.TASK_TYPE_SINGLE_DATA_AND_MORE_ALGORITHM)){
|
|
|
+ createTrainTask(taskBo.getId(),taskDto);
|
|
|
+ }
|
|
|
+ // 创建测试子任务
|
|
|
+ if (taskDto.getTaskItemList().contains(CreateTargetIdentificationTaskDto.TASK_TYPE_SINGLE_DATA_AND_MORE_ALGORITHM){
|
|
|
+ createTestTask(taskBo.getId(),taskDto);
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void createTestTask(Long taskId, CreateTargetIdentificationTaskDto taskDto) {
|
|
|
+ List<TaskDto> algTaskList = taskDto.getAlgTaskList();
|
|
|
+ List<String> testBatchNumList = taskDto.getTestBatchNumList();
|
|
|
+ TargetIdentificationSubtaskBo subtask = new TargetIdentificationSubtaskBo();
|
|
|
+ subtask.setName("测试");
|
|
|
+ subtask.setStatus(BizConstant.TASK_STATUS_PENDING);
|
|
|
+ subtask.setTaskId(taskId);
|
|
|
+ // todo set others params
|
|
|
+
|
|
|
+ // todo 保证有主键id
|
|
|
+
|
|
|
+ subtaskService.insert(subtask);
|
|
|
+
|
|
|
+ for (TaskDto algTask : algTaskList) {
|
|
|
+ // 通过算法id 获取算法配置
|
|
|
+ Long algorithmId = algTask.getAlgorithmId();
|
|
|
+ // todo
|
|
|
+ String algUrl = "";
|
|
|
+ String algName = "";
|
|
|
+ // algConfig = xxxService.getById(algorithmId)
|
|
|
+ // alg algUrl = algConfig.getTestUrl()
|
|
|
+ // alg algName = algConfig.getName()
|
|
|
+
|
|
|
+ for (String batchNum : testBatchNumList) {
|
|
|
+ createSubTaskDetails(subtask, algUrl,algName, algTask, testBatchNumList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void createSubTaskDetails(TargetIdentificationSubtaskBo subtask, String algUrl, String algName, TaskDto algTask, List<String> testBatchNumList) {
|
|
|
+ //
|
|
|
+ TargetIdentificationSubtaskDetailsBo subtaskDetail = new TargetIdentificationSubtaskDetailsBo();
|
|
|
+ // 通过算法id获取算法配置
|
|
|
+ subtaskDetail.setName(algName);
|
|
|
+ subtaskDetailsService.insert(subtaskDetail);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void createTrainTask(Long taskId, CreateTargetIdentificationTaskDto taskDto) {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ // todo 检查数据是否有问题
|
|
|
+ private String checkTask(CreateTargetIdentificationTaskDto taskDto) {
|
|
|
return null;
|
|
|
}
|
|
|
|