|
@@ -4,14 +4,16 @@ import java.io.File;
|
|
|
import java.nio.file.Path;
|
|
|
import java.nio.file.Paths;
|
|
|
import java.util.Arrays;
|
|
|
+import java.util.Date;
|
|
|
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.HttpResponseEntity;
|
|
|
-import com.taais.biz.domain.ToInfrared;
|
|
|
+import com.taais.biz.domain.*;
|
|
|
+import com.taais.biz.domain.vo.StartToInfraredTask;
|
|
|
+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;
|
|
@@ -32,15 +34,14 @@ import org.springframework.http.ResponseEntity;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import com.taais.biz.mapper.TrackSequenceMapper;
|
|
|
-import com.taais.biz.domain.TrackSequence;
|
|
|
import com.taais.biz.domain.bo.TrackSequenceBo;
|
|
|
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.TrackSequenceTableDef.TRACK_SEQUENCE;
|
|
|
-import static com.taais.biz.service.impl.VideoStableServiceImpl.removeFileExtension;
|
|
|
-import static com.taais.biz.service.impl.VideoStableServiceImpl.sendPostMsg;
|
|
|
+import static com.taais.biz.service.impl.VideoStableServiceImpl.*;
|
|
|
+import static com.taais.biz.service.impl.VideoStableServiceImpl.makeDir;
|
|
|
|
|
|
/**
|
|
|
* 注视轨迹序列Service业务层处理
|
|
@@ -57,6 +58,11 @@ public class TrackSequenceServiceImpl extends BaseServiceImpl<TrackSequenceMappe
|
|
|
@Value("${server.track_sequence_stop_url}")
|
|
|
private String track_sequence_stop_url;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private AlgorithmConfigTrackServiceImpl algorithmConfigTrackService;
|
|
|
+ @Autowired
|
|
|
+ private AlgorithmModelTrackServiceImpl algorithmModelTrackService;
|
|
|
+
|
|
|
@Autowired
|
|
|
private ISysOssService ossService;
|
|
|
|
|
@@ -176,6 +182,8 @@ public class TrackSequenceServiceImpl extends BaseServiceImpl<TrackSequenceMappe
|
|
|
trackSequence.setStatus(NOT_START);
|
|
|
trackSequence.setRemarks(trackSequenceBo.getRemarks());
|
|
|
|
|
|
+ trackSequence.setAlgorithmModelId(trackSequenceBo.getAlgorithmModelId());
|
|
|
+
|
|
|
return this.save(trackSequence);// 使用全局配置的雪花算法主键生成器生成ID值
|
|
|
}
|
|
|
|
|
@@ -211,13 +219,52 @@ public class TrackSequenceServiceImpl extends BaseServiceImpl<TrackSequenceMappe
|
|
|
public CommonResult start(Long id) {
|
|
|
TrackSequence trackSequence = getById(id);
|
|
|
|
|
|
- HttpResponseEntity responseEntity = sendPostMsg(track_sequence_start_url, trackSequence);
|
|
|
+ SysOssVo inputOssEntity = ossService.getById(trackSequence.getInputOssId());
|
|
|
+
|
|
|
+ String filePath = inputOssEntity.getFileName();
|
|
|
+ String localPath = TaaisConfig.getProfile();
|
|
|
+ String resourcePath = localPath + StringUtils.substringAfter(filePath, Constants.RESOURCE_PREFIX);
|
|
|
+
|
|
|
+ String fileName = StringUtils.substringAfterLast(filePath, "/");
|
|
|
+ String fileName_without_suffix = removeFileExtension(fileName);
|
|
|
+
|
|
|
+ Path path = Paths.get(resourcePath);
|
|
|
+ Path inputPath = path.resolveSibling(fileName_without_suffix + "_images");
|
|
|
+ Path outputPath = path.resolveSibling(fileName_without_suffix + "_to_infrared");
|
|
|
+
|
|
|
+ makeDir(inputPath.toString());
|
|
|
+ makeDir(outputPath.toString());
|
|
|
+
|
|
|
+ ZipUtils.unzip(resourcePath, inputPath.toString());
|
|
|
+
|
|
|
+ trackSequence.setInputPath(inputPath.toString());
|
|
|
+ trackSequence.setOutputPath(outputPath.toString());
|
|
|
+
|
|
|
+ trackSequence.setStartTime(new Date());
|
|
|
+
|
|
|
+ AlgorithmModelTrack algorithmModelTrack = algorithmModelTrackService.getById(trackSequence.getAlgorithmModelId());
|
|
|
+ AlgorithmConfigTrack algorithmConfigTrack = algorithmConfigTrackService.getById(algorithmModelTrack.getAlgorithmId());
|
|
|
+
|
|
|
+ StartToInfraredTask startToInfraredTask = new StartToInfraredTask();
|
|
|
+ startToInfraredTask.setBizId(trackSequence.getId());
|
|
|
+
|
|
|
+ // if (algorithmConfigTrack.getType() == AlgorithmType.TRAIN) {
|
|
|
+ startToInfraredTask.setModel_path(algorithmModelTrack.getModelAddress());
|
|
|
+ // }
|
|
|
+
|
|
|
+ startToInfraredTask.setOtherParams(algorithmConfigTrack.getParameterConfig());
|
|
|
+ startToInfraredTask.setSource_dir(trackSequence.getInputPath());
|
|
|
+ startToInfraredTask.setResult_dir(trackSequence.getOutputPath());
|
|
|
+
|
|
|
+ HttpResponseEntity responseEntity = sendPostMsg(algorithmConfigTrack.getAlgorithmAddress(), startToInfraredTask);
|
|
|
if (ObjectUtil.isNotNull(responseEntity) && responseEntity.getStatus() == 200) {
|
|
|
- trackSequence.setStatus(BizConstant.VideoStatus.INTERRUPTED);
|
|
|
+ trackSequence.setStatus(BizConstant.VideoStatus.RUNNING);
|
|
|
updateById(trackSequence);
|
|
|
- return CommonResult.fail("开始任务成功");
|
|
|
+ return CommonResult.success("任务开始成功,请等待完成");
|
|
|
} else {
|
|
|
- return CommonResult.fail("开始任务失败");
|
|
|
+ trackSequence.setStatus(BizConstant.VideoStatus.FAILED);
|
|
|
+ updateById(trackSequence);
|
|
|
+ return CommonResult.fail("任务开始失败,请检查!");
|
|
|
}
|
|
|
}
|
|
|
|