|
@@ -1,10 +1,11 @@
|
|
|
+/**
|
|
|
+ * 20241029 ©WANGKANG 1686617586@qq.com
|
|
|
+ */
|
|
|
+
|
|
|
package com.taais.biz.service.impl;
|
|
|
|
|
|
-import java.io.BufferedReader;
|
|
|
import java.io.File;
|
|
|
-import java.io.FileReader;
|
|
|
import java.io.IOException;
|
|
|
-import java.nio.file.Files;
|
|
|
import java.nio.file.Path;
|
|
|
import java.nio.file.Paths;
|
|
|
import java.util.Arrays;
|
|
@@ -48,7 +49,6 @@ import com.taais.biz.domain.vo.TrackSequenceVo;
|
|
|
import com.taais.biz.service.ITrackSequenceService;
|
|
|
|
|
|
import static com.taais.biz.constant.BizConstant.VideoStatus.NOT_START;
|
|
|
-import static com.taais.biz.domain.table.AlgorithmModelTrackTableDef.ALGORITHM_MODEL_TRACK;
|
|
|
import static com.taais.biz.domain.table.TrackSequenceTableDef.TRACK_SEQUENCE;
|
|
|
import static com.taais.biz.service.impl.ToInfraredServiceImpl.readLogContent;
|
|
|
import static com.taais.biz.service.impl.VideoStableServiceImpl.*;
|
|
@@ -248,49 +248,58 @@ public class TrackSequenceServiceImpl extends BaseServiceImpl<TrackSequenceMappe
|
|
|
@Override
|
|
|
public CommonResult start(Long id) {
|
|
|
TrackSequence entity = getById(id);
|
|
|
+ AlgorithmModelTrack algorithmModelTrack = algorithmModelTrackService.getById(entity.getAlgorithmModelId());
|
|
|
+ AlgorithmConfigTrack algorithmConfigTrack = algorithmConfigTrackService.getById(entity.getAlgorithmId());
|
|
|
+ StartTaskConfig startTaskConfig = new StartTaskConfig();
|
|
|
|
|
|
- SysOssVo inputOssEntity = ossService.getById(entity.getInputOssId());
|
|
|
+ if (algorithmConfigTrack.getType().equals(BizConstant.AlgorithmType.TEST) && entity.getName().startsWith("MASC")) {
|
|
|
+ startTaskConfig.setBizType(BizConstant.BizType.TRACK_SEQUENCE);
|
|
|
+ startTaskConfig.setBizId(entity.getId());
|
|
|
|
|
|
- String filePath = inputOssEntity.getFileName();
|
|
|
- String localPath = TaaisConfig.getProfile();
|
|
|
- String resourcePath = localPath + StringUtils.substringAfter(filePath, Constants.RESOURCE_PREFIX);
|
|
|
+ startTaskConfig.setOtherParams(algorithmConfigTrack.getParameterConfig());
|
|
|
|
|
|
- String fileName = StringUtils.substringAfterLast(filePath, "/");
|
|
|
- String fileName_without_suffix = removeFileExtension(fileName);
|
|
|
+ startTaskConfig.setSource_dir(entity.getInputPath());
|
|
|
+ startTaskConfig.setResult_dir(entity.getOutputPath());
|
|
|
+ startTaskConfig.setLog_path(entity.getOutputPath() + File.separator + getLogFileName(entity));
|
|
|
+ } else {
|
|
|
+ SysOssVo inputOssEntity = ossService.getById(entity.getInputOssId());
|
|
|
|
|
|
- Path path = Paths.get(resourcePath);
|
|
|
- Path inputPath = path.resolveSibling(fileName_without_suffix + BizConstant.UNZIP_SUFFIX);
|
|
|
- Path outputPath = path.resolveSibling(entity.getId().toString() + BizConstant.TRACK_SEQUENCE_SUFFIX);
|
|
|
+ String filePath = inputOssEntity.getFileName();
|
|
|
+ String localPath = TaaisConfig.getProfile();
|
|
|
+ String resourcePath = localPath + StringUtils.substringAfter(filePath, Constants.RESOURCE_PREFIX);
|
|
|
|
|
|
-// makeDir(inputPath.toString());
|
|
|
- makeDir(outputPath.toString());
|
|
|
+ String fileName = StringUtils.substringAfterLast(filePath, "/");
|
|
|
+ String fileName_without_suffix = removeFileExtension(fileName);
|
|
|
|
|
|
- File file = new File(inputPath.toString());
|
|
|
- if (!file.exists()) {
|
|
|
- ZipUtils.unzip(resourcePath, inputPath.toString());
|
|
|
- }
|
|
|
+ Path path = Paths.get(resourcePath);
|
|
|
+ Path inputPath = path.resolveSibling(fileName_without_suffix + BizConstant.UNZIP_SUFFIX);
|
|
|
+ Path outputPath = path.resolveSibling(entity.getId().toString() + BizConstant.TRACK_SEQUENCE_SUFFIX);
|
|
|
|
|
|
- entity.setInputPath(inputPath.toString());
|
|
|
- entity.setOutputPath(outputPath.toString());
|
|
|
+// makeDir(inputPath.toString());
|
|
|
+ makeDir(outputPath.toString());
|
|
|
|
|
|
- entity.setStartTime(new Date());
|
|
|
+ File file = new File(inputPath.toString());
|
|
|
+ if (!file.exists()) {
|
|
|
+ ZipUtils.unzip(resourcePath, inputPath.toString());
|
|
|
+ }
|
|
|
|
|
|
- AlgorithmModelTrack algorithmModelTrack = algorithmModelTrackService.getById(entity.getAlgorithmModelId());
|
|
|
- AlgorithmConfigTrack algorithmConfigTrack = algorithmConfigTrackService.getById(entity.getAlgorithmId());
|
|
|
+ entity.setInputPath(inputPath.toString());
|
|
|
+ entity.setOutputPath(outputPath.toString());
|
|
|
|
|
|
- StartTaskConfig startTaskConfig = new StartTaskConfig();
|
|
|
- startTaskConfig.setBizType(BizConstant.BizType.TRACK_SEQUENCE);
|
|
|
- startTaskConfig.setBizId(entity.getId());
|
|
|
+ entity.setStartTime(new Date());
|
|
|
|
|
|
- startTaskConfig.setOtherParams(algorithmConfigTrack.getParameterConfig());
|
|
|
+ startTaskConfig.setBizType(BizConstant.BizType.TRACK_SEQUENCE);
|
|
|
+ startTaskConfig.setBizId(entity.getId());
|
|
|
|
|
|
- startTaskConfig.setSource_dir(entity.getInputPath());
|
|
|
- startTaskConfig.setResult_dir(entity.getOutputPath());
|
|
|
- startTaskConfig.setLog_path(entity.getOutputPath() + File.separator + getLogFileName(entity));
|
|
|
+ startTaskConfig.setOtherParams(algorithmConfigTrack.getParameterConfig());
|
|
|
|
|
|
- if (BizConstant.AlgorithmType.REASONING.equals(algorithmConfigTrack.getType())) {
|
|
|
- String modelPath = algorithmModelTrack.getModelAddress();
|
|
|
- startTaskConfig.setModel_path(modelPath);
|
|
|
+ startTaskConfig.setSource_dir(entity.getInputPath());
|
|
|
+ startTaskConfig.setResult_dir(entity.getOutputPath());
|
|
|
+ startTaskConfig.setLog_path(entity.getOutputPath() + File.separator + getLogFileName(entity));
|
|
|
+
|
|
|
+ if (BizConstant.AlgorithmType.REASONING.equals(algorithmConfigTrack.getType())) {
|
|
|
+ String modelPath = algorithmModelTrack.getModelAddress();
|
|
|
+ startTaskConfig.setModel_path(modelPath);
|
|
|
// if (algorithmModelTrack.getModelName().startsWith("masc") || algorithmModelTrack.getModelName().startsWith("MASC")) {
|
|
|
// String modelPath = algorithmModelTrack.getModelAddress() + File.separator + algorithmModelTrack.getModelName().substring(5);
|
|
|
// startTaskConfig.setModel_path(modelPath);
|
|
@@ -300,9 +309,8 @@ public class TrackSequenceServiceImpl extends BaseServiceImpl<TrackSequenceMappe
|
|
|
// } else {
|
|
|
// return CommonResult.fail("模型命名失败,请以MASC或CAT开头命名模型");
|
|
|
// }
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
HttpResponseEntity responseEntity = sendPostMsg(algorithmConfigTrack.getAlgorithmAddress(), startTaskConfig);
|
|
|
if (ObjectUtil.isNotNull(responseEntity) && responseEntity.getStatus() == 200) {
|
|
|
entity.setStatus(BizConstant.VideoStatus.RUNNING);
|
|
@@ -451,4 +459,49 @@ public class TrackSequenceServiceImpl extends BaseServiceImpl<TrackSequenceMappe
|
|
|
|
|
|
return CommonResult.success(res, "success");
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public CommonResult addEvaluate(AddEvaluate addEvaluate) {
|
|
|
+ // 检查任务名称
|
|
|
+ if (ObjectUtil.isEmpty(addEvaluate.getName()) || (!addEvaluate.getName().startsWith("MASC") && !addEvaluate.getName().startsWith("CAT"))) {
|
|
|
+ return CommonResult.fail("任务命名错误,需以MASC或CAT开头!");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (ObjectUtil.isEmpty(addEvaluate.getAlgorithmId())) {
|
|
|
+ return CommonResult.fail("请指定算法!");
|
|
|
+ }
|
|
|
+
|
|
|
+ AlgorithmConfigTrackVo config = algorithmConfigTrackService.selectById(addEvaluate.getAlgorithmId());
|
|
|
+ if (ObjectUtil.isNull(config)) {
|
|
|
+ return CommonResult.fail("找不到指定的算法!");
|
|
|
+ }
|
|
|
+
|
|
|
+ TrackSequence entity = this.getById(addEvaluate.getId());
|
|
|
+ TrackSequence evaluate_entity = new TrackSequence();
|
|
|
+ evaluate_entity.setStatus(NOT_START);
|
|
|
+ evaluate_entity.setUrl(entity.getUrl());
|
|
|
+ evaluate_entity.setInputPath(entity.getInputPath() + ";" + entity.getOutputPath() + File.separator + "gaze" + File.separator + "txt");
|
|
|
+ evaluate_entity.setZipFilePath(entity.getZipFilePath());
|
|
|
+ evaluate_entity.setAlgorithmModelId(entity.getAlgorithmModelId());
|
|
|
+ evaluate_entity.setInputOssId(entity.getInputOssId());
|
|
|
+
|
|
|
+ evaluate_entity.setName(addEvaluate.getName());
|
|
|
+ evaluate_entity.setAlgorithmId(addEvaluate.getAlgorithmId());
|
|
|
+ evaluate_entity.setRemarks(addEvaluate.getRemarks());
|
|
|
+
|
|
|
+ boolean flag__ = save(evaluate_entity);
|
|
|
+
|
|
|
+ if (flag__) {
|
|
|
+ Path path = Paths.get(entity.getOutputPath());
|
|
|
+ evaluate_entity.setOutputPath(path.resolveSibling(evaluate_entity.getId().toString() + BizConstant.TRACK_SEQUENCE_SUFFIX).toString());
|
|
|
+ boolean flag___ = updateById(evaluate_entity);
|
|
|
+ if (flag___) {
|
|
|
+ return CommonResult.success("新增评估任务成功!");
|
|
|
+ } else {
|
|
|
+ return CommonResult.success("新增评估任务成功! 更新输出路径失败");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ return CommonResult.success("新增评估任务失败!");
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|