浏览代码

feat: 总任务新增初步完成

WANGKANG 5 月之前
父节点
当前提交
3f8f55ce0b

+ 41 - 22
taais-modules/taais-biz/src/main/java/com/taais/biz/service/impl/AlgorithmTaskTrackServiceImpl.java

@@ -28,6 +28,7 @@ import org.springframework.transaction.annotation.Transactional;
 import java.nio.file.Path;
 import java.nio.file.Paths;
 import java.util.Arrays;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
@@ -116,15 +117,28 @@ public class AlgorithmTaskTrackServiceImpl extends BaseServiceImpl<AlgorithmTask
         return PageResult.build(page);
     }
 
+    public Long parseLong(Object obj) {
+        if (obj instanceof Long) {
+            return (Long) obj;
+        } else {
+            try {
+                return Long.parseLong(obj.toString());
+            } catch (NumberFormatException e) {
+                // 处理解析失败的情况
+                throw new IllegalArgumentException("参数不是一个有效的Long值: " + obj);
+            }
+        }
+    }
+
     public ToInfraredBo cteateToInfraredTaskBo(Map<String, Object> params) {
         ToInfraredBo toInfraredBo = new ToInfraredBo();
-        toInfraredBo.setName("ToInfrared_" + (String) params.get("name"));
-        toInfraredBo.setInputOssId((Long) params.get("inputDatasetOssId"));
+        toInfraredBo.setName("ToInfrared_" + params.get("name"));
+        toInfraredBo.setInputOssId(parseLong(params.get("inputDatasetOssId")));
         toInfraredBo.setRemarks((String) params.get("remarks"));
-        toInfraredBo.setParentTaskId((Long) params.get("parentTaskId"));
+        toInfraredBo.setParentTaskId(parseLong(params.get("parentTaskId")));
 
-        toInfraredBo.setAlgorithmModelId((Long) params.get("toInfraredModelId"));
-        toInfraredBo.setAlgorithmId((Long) params.get("toInfraredAlgorithmId"));
+        toInfraredBo.setAlgorithmModelId(parseLong(params.get("toInfraredModelId")));
+        toInfraredBo.setAlgorithmId(parseLong(params.get("toInfraredAlgorithmId")));
 
         toInfraredBo.setOtherParams((Map<String, Object>) params.get("toInfraredAlgorithmParams"));
 
@@ -133,16 +147,19 @@ public class AlgorithmTaskTrackServiceImpl extends BaseServiceImpl<AlgorithmTask
 
     public TrackSequenceBo createTrackSequencePredictBo(Map<String, Object> params) {
         TrackSequenceBo trackSequenceBo = new TrackSequenceBo();
-        trackSequenceBo.setName("TrackSequence_predict_" + (String) params.get("name"));
-        trackSequenceBo.setInputOssId((Long) params.get("inputDatasetOssId"));
+        trackSequenceBo.setName("TrackSequence_predict_" + params.get("name"));
+        trackSequenceBo.setInputOssId(parseLong(params.get("inputDatasetOssId")));
         trackSequenceBo.setRemarks((String) params.get("remarks"));
-        trackSequenceBo.setParentTaskId((Long) params.get("parentTaskId"));
+        trackSequenceBo.setParentTaskId(parseLong(params.get("parentTaskId")));
 
-        trackSequenceBo.setAlgorithmModelId((Long) params.get("trackSequenceModelId"));
-        trackSequenceBo.setAlgorithmId((Long) params.get("trackSequenceAlgorithmId"));
+        trackSequenceBo.setAlgorithmModelId(parseLong(params.get("trackSequenceModelId")));
+        trackSequenceBo.setAlgorithmId(parseLong(params.get("trackSequenceAlgorithmId")));
 
         Map<String, Object> otherParams = (Map<String, Object>) params.get("trackSequenceAlgorithmParams");
-        otherParams.put("algorithmModelTargetDetectionId", (Long) params.get("TD_modelId"));
+        if (ObjectUtil.isNull(otherParams)) {
+            otherParams = new HashMap<>();
+        }
+        otherParams.put("algorithmModelTargetDetectionId", params.get("TD_modelId"));
         trackSequenceBo.setOtherParams(otherParams);
 
         return trackSequenceBo;
@@ -150,18 +167,21 @@ public class AlgorithmTaskTrackServiceImpl extends BaseServiceImpl<AlgorithmTask
 
     public TrackSequenceBo createTrackSequenceEvaluateBo(Map<String, Object> params) {
         TrackSequenceBo trackSequenceBo = new TrackSequenceBo();
-        trackSequenceBo.setName("TrackSequence_evaluate_" + (String) params.get("name"));
-        trackSequenceBo.setInputOssId((Long) params.get("inputDatasetOssId"));
+        trackSequenceBo.setName("TrackSequence_evaluate_" + params.get("name"));
+        trackSequenceBo.setInputOssId(parseLong(params.get("inputDatasetOssId")));
         trackSequenceBo.setRemarks((String) params.get("remarks"));
-        trackSequenceBo.setParentTaskId((Long) params.get("parentTaskId"));
+        trackSequenceBo.setParentTaskId(parseLong(params.get("parentTaskId")));
 
 //        trackSequenceBo.setAlgorithmModelId((Long) params.get("trackSequenceEvaluateModelId"));
-        trackSequenceBo.setAlgorithmId((Long) params.get("trackSequenceEvaluateAlgorithmId"));
+        trackSequenceBo.setAlgorithmId(parseLong(params.get("trackSequenceEvaluateAlgorithmId")));
 
         Map<String, Object> otherParams = (Map<String, Object>) params.get("trackSequenceEvaluateAlgorithmParams");
-        otherParams.put("algorithmModelTargetDetectionId", (Long) params.get("TD_modelId"));
-        otherParams.put("trackSequencePredictTaskId", (Long) params.get("trackSequencePredictTaskId"));
-        otherParams.put("inputLabelOssId", (Long) params.get("inputEvaluateLabelOssId"));
+        if (ObjectUtil.isNull(otherParams)) {
+            otherParams = new HashMap<>();
+        }
+        otherParams.put("algorithmModelTargetDetectionId", params.get("TD_modelId"));
+        otherParams.put("trackSequencePredictTaskId", params.get("trackSequencePredictTaskId"));
+        otherParams.put("inputLabelOssId", params.get("inputEvaluateLabelOssId"));
         trackSequenceBo.setOtherParams(otherParams);
 
         return trackSequenceBo;
@@ -208,7 +228,7 @@ public class AlgorithmTaskTrackServiceImpl extends BaseServiceImpl<AlgorithmTask
             TrackSequence trackSequenceEvaluateTask = trackSequenceService.insert2(trackSequenceEvaluateBo);
         }
 
-        return this.save(algorithmTaskTrack);//使用全局配置的雪花算法主键生成器生成ID值
+        return true;
     }
 
     private Long getNewOssId(ToInfrared toInfraredTask) {
@@ -225,10 +245,9 @@ public class AlgorithmTaskTrackServiceImpl extends BaseServiceImpl<AlgorithmTask
         oss.setService("Local");
         boolean flag = ossService.save(oss);
 
-        if(flag) {
+        if (flag) {
             return oss.getOssId();
-        }
-        else {
+        } else {
             throw new RuntimeException("save oss failed");
         }
     }