Ver Fonte

Merge branch 'dev_wk2' into develop

allen há 2 semanas atrás
pai
commit
fe294f6fb4

+ 20 - 20
taais-modules/taais-biz/src/main/java/com/taais/biz/service/impl/TargetDetectionServiceImpl.java

@@ -5,7 +5,6 @@
 package com.taais.biz.service.impl;
 
 import cn.hutool.core.util.ObjectUtil;
-import com.alibaba.fastjson2.JSON;
 import com.mybatisflex.core.paginate.Page;
 import com.mybatisflex.core.query.QueryWrapper;
 import com.taais.biz.constant.BizConstant;
@@ -18,7 +17,6 @@ import com.taais.biz.mapper.TargetDetectionMapper;
 import com.taais.biz.service.ITargetDetectionService;
 import com.taais.biz.utils.ZipUtils;
 import com.taais.common.core.config.TaaisConfig;
-import com.taais.common.core.constant.Constants;
 import com.taais.common.core.core.domain.CommonResult;
 import com.taais.common.core.core.page.PageResult;
 import com.taais.common.core.utils.MapstructUtils;
@@ -30,7 +28,6 @@ import com.taais.system.domain.vo.SysOssVo;
 import com.taais.system.service.ISysOssService;
 import jakarta.annotation.Resource;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
 import org.springframework.core.io.FileSystemResource;
 import org.springframework.http.HttpHeaders;
 import org.springframework.http.HttpStatus;
@@ -42,7 +39,6 @@ import java.io.File;
 import java.io.IOException;
 import java.nio.file.Path;
 import java.nio.file.Paths;
-import java.text.DecimalFormat;
 import java.util.*;
 
 import static com.taais.biz.constant.BizConstant.VideoStatus.NOT_START;
@@ -55,11 +51,11 @@ import static com.taais.biz.service.impl.VideoStableServiceImpl.sendPostMsg;
  * 目标检测Service业务层处理
  *
  * @author wangkang
- *         2024-09-29
+ * 2024-09-29
  */
 @Service
 public class TargetDetectionServiceImpl extends BaseServiceImpl<TargetDetectionMapper, TargetDetection>
-        implements ITargetDetectionService {
+    implements ITargetDetectionService {
     @Resource
     private TargetDetectionMapper targetDetectionMapper;
     @Autowired
@@ -140,16 +136,19 @@ public class TargetDetectionServiceImpl extends BaseServiceImpl<TargetDetectionM
             Long modelId = entity.getAlgorithmModelId();
             if (ObjectUtil.isNotNull(modelId)) {
                 AlgorithmModelTrack model = algorithmModelTrackService.getById(modelId);
-                entity.setModelName(model.getModelName());
-
+                if (ObjectUtil.isNotNull(model)) {
+                    entity.setModelName(model.getModelName());
+                }
             }
 
             Long algorithmId = entity.getAlgorithmId();
             if (ObjectUtil.isNotNull(algorithmId)) {
                 AlgorithmConfigTrackVo config = algorithmConfigTrackService.selectById(algorithmId);
-                entity.setType(config.getType());
-                entity.setSubsystem(config.getSubsystem());
-                entity.setAlgorithmName(config.getAlgorithmName());
+                if (ObjectUtil.isNotNull(config)) {
+                    entity.setType(config.getType());
+                    entity.setSubsystem(config.getSubsystem());
+                    entity.setAlgorithmName(config.getAlgorithmName());
+                }
             }
         });
         page.getRecords().sort(Comparator.comparing(TargetDetectionVo::getCreateTime).reversed());
@@ -205,8 +204,15 @@ public class TargetDetectionServiceImpl extends BaseServiceImpl<TargetDetectionM
             throw new RuntimeException("算法配置参数为空");
         }
 
+        String unzipPath = getUnZipDirPath(ossEntity);
+        File file = new File(unzipPath);
+        if (!file.exists()) {
+            String resourcePath = getResourcePath(ossService.getById(entity.getInputOssId()));
+            ZipUtils.unzip(resourcePath, unzipPath);
+        }
+
         Map<String, Object> algorithmParameters = getAlgorithmParameters(algorithmConfig.getParameters(),
-                entityBo.getOtherParams());
+            entityBo.getOtherParams());
 
         // 步骤4. 构造可以直接传给前端的map数据结构
         Map<String, Object> result = new HashMap<>();
@@ -245,12 +251,6 @@ public class TargetDetectionServiceImpl extends BaseServiceImpl<TargetDetectionM
         makeDir(entity.getInputPath());
         makeDir(entity.getOutputPath());
 
-        File file = new File(entity.getInputPath());
-        if (!file.exists()) {
-            String resourcePath = getResourcePath(ossService.getById(entity.getInputOssId()));
-            ZipUtils.unzip(resourcePath, entity.getInputPath());
-        }
-
         return entity;
     }
 
@@ -418,8 +418,8 @@ public class TargetDetectionServiceImpl extends BaseServiceImpl<TargetDetectionM
 
         org.springframework.core.io.Resource resource = new FileSystemResource(file);
         return ResponseEntity.ok()
-                .header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + file.getName() + "\"")
-                .header(HttpHeaders.CONTENT_TYPE, "application/octet-stream").body(resource);
+            .header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + file.getName() + "\"")
+            .header(HttpHeaders.CONTENT_TYPE, "application/octet-stream").body(resource);
     }
 
     @Override

+ 19 - 18
taais-modules/taais-biz/src/main/java/com/taais/biz/service/impl/ToInfraredServiceImpl.java

@@ -12,7 +12,6 @@ import com.taais.biz.constant.BizConstant;
 import com.taais.biz.domain.*;
 import com.taais.biz.domain.bo.ToInfraredBo;
 import com.taais.biz.domain.vo.AlgorithmConfigTrackVo;
-import com.taais.biz.domain.vo.AlgorithmModelTrackVo;
 import com.taais.biz.domain.vo.StartTaskConfig;
 import com.taais.biz.domain.vo.ToInfraredVo;
 import com.taais.biz.mapper.ToInfraredMapper;
@@ -33,7 +32,6 @@ import com.taais.system.service.ISysOssService;
 import jakarta.annotation.Resource;
 import lombok.extern.log4j.Log4j2;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
 import org.springframework.core.io.FileSystemResource;
 import org.springframework.http.HttpHeaders;
 import org.springframework.http.HttpStatus;
@@ -61,7 +59,7 @@ import static com.taais.biz.service.impl.VideoStableServiceImpl.*;
  * 可见光转红外Service业务层处理
  *
  * @author 0
- *         2024-09-20
+ * 2024-09-20
  */
 @Service
 @Log4j2
@@ -143,16 +141,19 @@ public class ToInfraredServiceImpl extends BaseServiceImpl<ToInfraredMapper, ToI
             Long modelId = entity.getAlgorithmModelId();
             if (ObjectUtil.isNotNull(modelId)) {
                 AlgorithmModelTrack model = algorithmModelTrackService.getById(modelId);
-                entity.setModelName(model.getModelName());
-
+                if (ObjectUtil.isNotNull(model)) {
+                    entity.setModelName(model.getModelName());
+                }
             }
 
             Long algorithmId = entity.getAlgorithmId();
             if (ObjectUtil.isNotNull(algorithmId)) {
                 AlgorithmConfigTrackVo config = algorithmConfigTrackService.selectById(algorithmId);
-                entity.setType(config.getType());
-                entity.setSubsystem(config.getSubsystem());
-                entity.setAlgorithmName(config.getAlgorithmName());
+                if (ObjectUtil.isNotNull(config)) {
+                    entity.setType(config.getType());
+                    entity.setSubsystem(config.getSubsystem());
+                    entity.setAlgorithmName(config.getAlgorithmName());
+                }
             }
         });
         page.getRecords().sort(Comparator.comparing(ToInfraredVo::getCreateTime).reversed());
@@ -268,7 +269,7 @@ public class ToInfraredServiceImpl extends BaseServiceImpl<ToInfraredMapper, ToI
     }
 
     public static Map<String, Object> getAlgorithmParameters(String algorithmConfigStr,
-            Map<String, Object> otherParams) {
+                                                             Map<String, Object> otherParams) {
         Map<String, Object> algorithmParameters = new HashMap<>();
         List<Dict> config_list = JsonUtils.parseArrayMap(algorithmConfigStr);
 
@@ -306,7 +307,7 @@ public class ToInfraredServiceImpl extends BaseServiceImpl<ToInfraredMapper, ToI
         }
 
         Map<String, Object> algorithmParameters = getAlgorithmParameters(algorithmConfig.getParameters(),
-                entityBo.getOtherParams());
+            entityBo.getOtherParams());
 
         // 步骤4. 构造可以直接传给前端的map数据结构
         Map<String, Object> result = new HashMap<>();
@@ -342,15 +343,15 @@ public class ToInfraredServiceImpl extends BaseServiceImpl<ToInfraredMapper, ToI
         // 步骤 5. 将算法参数map序列化为json字符串,保存到数据库中
         entity.setAlgorithmParameters(JsonUtils.toJsonString(result));
 
-        makeDir(entity.getInputPath());
-        makeDir(entity.getOutputPath());
-
         File file = new File(entity.getInputPath());
         if (!file.exists()) {
             String resourcePath = getResourcePath(ossService.getById(entity.getInputOssId()));
             ZipUtils.unzip(resourcePath, entity.getInputPath());
         }
 
+        makeDir(entity.getInputPath());
+        makeDir(entity.getOutputPath());
+
         return entity;
     }
 
@@ -574,7 +575,7 @@ public class ToInfraredServiceImpl extends BaseServiceImpl<ToInfraredMapper, ToI
         ArrayList<Map<String, String>> res = new ArrayList<>();
         for (File file : files) {
             if (file.getName().endsWith(".log") || file.getName().endsWith(".json")
-                    || file.getName().startsWith("events.out")) {
+                || file.getName().startsWith("events.out")) {
                 continue;
             }
             idx += 1;
@@ -704,8 +705,8 @@ public class ToInfraredServiceImpl extends BaseServiceImpl<ToInfraredMapper, ToI
 
         org.springframework.core.io.Resource resource = new FileSystemResource(file);
         return ResponseEntity.ok()
-                .header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + file.getName() + "\"")
-                .header(HttpHeaders.CONTENT_TYPE, "application/octet-stream").body(resource);
+            .header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + file.getName() + "\"")
+            .header(HttpHeaders.CONTENT_TYPE, "application/octet-stream").body(resource);
     }
 
     public ResponseEntity<org.springframework.core.io.Resource> getLastModelFile(ToInfrared toInfrared) {
@@ -729,7 +730,7 @@ public class ToInfraredServiceImpl extends BaseServiceImpl<ToInfraredMapper, ToI
 
         org.springframework.core.io.Resource resource = new FileSystemResource(returnFile);
         return ResponseEntity.ok()
-                .header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + returnFile.getName() + "\"")
-                .header(HttpHeaders.CONTENT_TYPE, "application/octet-stream").body(resource);
+            .header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + returnFile.getName() + "\"")
+            .header(HttpHeaders.CONTENT_TYPE, "application/octet-stream").body(resource);
     }
 }

+ 24 - 27
taais-modules/taais-biz/src/main/java/com/taais/biz/service/impl/TrackSequenceServiceImpl.java

@@ -6,7 +6,6 @@ package com.taais.biz.service.impl;
 
 import cn.hutool.core.lang.Dict;
 import cn.hutool.core.util.ObjectUtil;
-import com.alibaba.fastjson2.JSON;
 import com.mybatisflex.core.paginate.Page;
 import com.mybatisflex.core.query.QueryWrapper;
 import com.taais.biz.constant.BizConstant;
@@ -24,19 +23,13 @@ import com.taais.common.core.constant.Constants;
 import com.taais.common.core.core.domain.CommonResult;
 import com.taais.common.core.core.page.PageResult;
 import com.taais.common.core.utils.MapstructUtils;
-import com.taais.common.core.utils.StringUtils;
 import com.taais.common.json.utils.JsonUtils;
 import com.taais.common.orm.core.page.PageQuery;
 import com.taais.common.orm.core.service.impl.BaseServiceImpl;
 import com.taais.common.websocket.utils.WebSocketUtils;
-import com.taais.system.domain.SysOss;
 import com.taais.system.domain.vo.SysOssVo;
 import com.taais.system.service.ISysOssService;
-import com.taais.system.service.impl.SysOssServiceImpl;
-
 import jakarta.annotation.Resource;
-
-import org.apache.commons.lang3.ObjectUtils;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.core.io.FileSystemResource;
@@ -50,24 +43,24 @@ import java.io.File;
 import java.io.IOException;
 import java.nio.file.Path;
 import java.nio.file.Paths;
-import java.text.DecimalFormat;
 import java.util.*;
 
 import static com.taais.biz.constant.BizConstant.VideoStatus.NOT_START;
 import static com.taais.biz.domain.table.TrackSequenceTableDef.TRACK_SEQUENCE;
-import static com.taais.biz.service.impl.TargetDetectionServiceImpl.*;
+import static com.taais.biz.service.impl.TargetDetectionServiceImpl.getTrainInputPath;
 import static com.taais.biz.service.impl.ToInfraredServiceImpl.*;
-import static com.taais.biz.service.impl.VideoStableServiceImpl.*;
+import static com.taais.biz.service.impl.VideoStableServiceImpl.makeDir;
+import static com.taais.biz.service.impl.VideoStableServiceImpl.sendPostMsg;
 
 /**
  * 注视轨迹序列Service业务层处理
  *
  * @author wangkang
- *         2024-09-22
+ * 2024-09-22
  */
 @Service
 public class TrackSequenceServiceImpl extends BaseServiceImpl<TrackSequenceMapper, TrackSequence>
-        implements ITrackSequenceService {
+    implements ITrackSequenceService {
 
     private static final String MASC = "MASC";
     private static final String CAT = "CAT";
@@ -195,16 +188,19 @@ public class TrackSequenceServiceImpl extends BaseServiceImpl<TrackSequenceMappe
             Long modelId = entity.getAlgorithmModelId();
             if (ObjectUtil.isNotNull(modelId)) {
                 AlgorithmModelTrack model = algorithmModelTrackService.getById(modelId);
-                entity.setModelName(model.getModelName());
-
+                if (ObjectUtil.isNotNull(model)) {
+                    entity.setModelName(model.getModelName());
+                }
             }
 
             Long algorithmId = entity.getAlgorithmId();
             if (ObjectUtil.isNotNull(algorithmId)) {
                 AlgorithmConfigTrackVo config = algorithmConfigTrackService.selectById(algorithmId);
-                entity.setType(config.getType());
-                entity.setSubsystem(config.getSubsystem());
-                entity.setAlgorithmName(config.getAlgorithmName());
+                if (ObjectUtil.isNotNull(config)) {
+                    entity.setType(config.getType());
+                    entity.setSubsystem(config.getSubsystem());
+                    entity.setAlgorithmName(config.getAlgorithmName());
+                }
             }
         });
         page.getRecords().sort(Comparator.comparing(TrackSequenceVo::getCreateTime).reversed());
@@ -277,8 +273,15 @@ public class TrackSequenceServiceImpl extends BaseServiceImpl<TrackSequenceMappe
             throw new RuntimeException("算法配置参数为空");
         }
 
+        String unzipPath = getUnZipDirPath(ossEntity);
+        File file = new File(unzipPath);
+        if (!file.exists()) {
+            String resourcePath = getResourcePath(ossService.getById(entity.getInputOssId()));
+            ZipUtils.unzip(resourcePath, unzipPath);
+        }
+
         Map<String, Object> algorithmParameters = getAlgorithmParameters(algorithmConfig.getParameters(),
-                entityBo.getOtherParams());
+            entityBo.getOtherParams());
 
         // 步骤4. 构造可以直接传给前端的map数据结构
         Map<String, Object> result = new HashMap<>();
@@ -347,12 +350,6 @@ public class TrackSequenceServiceImpl extends BaseServiceImpl<TrackSequenceMappe
         makeDir(entity.getInputPath());
         makeDir(entity.getOutputPath());
 
-        File file = new File(entity.getInputPath());
-        if (!file.exists()) {
-            String resourcePath = getResourcePath(ossService.getById(entity.getInputOssId()));
-            ZipUtils.unzip(resourcePath, entity.getInputPath());
-        }
-
         return entity;
     }
 
@@ -467,8 +464,8 @@ public class TrackSequenceServiceImpl extends BaseServiceImpl<TrackSequenceMappe
 
         org.springframework.core.io.Resource resource = new FileSystemResource(file);
         return ResponseEntity.ok()
-                .header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + file.getName() + "\"")
-                .header(HttpHeaders.CONTENT_TYPE, "application/octet-stream").body(resource);
+            .header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + file.getName() + "\"")
+            .header(HttpHeaders.CONTENT_TYPE, "application/octet-stream").body(resource);
     }
 
     @Override
@@ -520,7 +517,7 @@ public class TrackSequenceServiceImpl extends BaseServiceImpl<TrackSequenceMappe
         } else if (entity.getName().startsWith(CAT)) {
             AlgorithmModelTrack modelTrack = algorithmModelTrackService.getById(entity.getAlgorithmModelId());
             AlgorithmConfigTrack algorithmConfigTrack = algorithmConfigTrackService
-                    .getById(modelTrack.getAlgorithmId());
+                .getById(modelTrack.getAlgorithmId());
 
             AlgorithmModelTrackVo res = new AlgorithmModelTrackVo();