|
@@ -1,5 +1,6 @@
|
|
|
package com.taais.biz.service.impl;
|
|
|
|
|
|
+import java.io.File;
|
|
|
import java.nio.file.Path;
|
|
|
import java.nio.file.Paths;
|
|
|
import java.util.Arrays;
|
|
@@ -8,9 +9,12 @@ 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.common.core.config.TaaisConfig;
|
|
|
import com.taais.common.core.constant.Constants;
|
|
|
+import com.taais.common.core.core.domain.CommonResult;
|
|
|
import com.taais.common.core.utils.MapstructUtils;
|
|
|
import com.taais.common.core.utils.StringUtils;
|
|
|
import com.taais.common.orm.core.page.PageQuery;
|
|
@@ -20,6 +24,11 @@ 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;
|
|
|
+import org.springframework.http.ResponseEntity;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import com.taais.biz.mapper.TrackSequenceMapper;
|
|
@@ -31,6 +40,7 @@ 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;
|
|
|
|
|
|
/**
|
|
|
* 注视轨迹序列Service业务层处理
|
|
@@ -40,6 +50,13 @@ import static com.taais.biz.service.impl.VideoStableServiceImpl.removeFileExtens
|
|
|
*/
|
|
|
@Service
|
|
|
public class TrackSequenceServiceImpl extends BaseServiceImpl<TrackSequenceMapper, TrackSequence> implements ITrackSequenceService {
|
|
|
+
|
|
|
+ @Value("${server.track_sequence_start_url}")
|
|
|
+ private String track_sequence_start_url;
|
|
|
+
|
|
|
+ @Value("${server.track_sequence_stop_url}")
|
|
|
+ private String track_sequence_stop_url;
|
|
|
+
|
|
|
@Autowired
|
|
|
private ISysOssService ossService;
|
|
|
|
|
@@ -190,4 +207,54 @@ public class TrackSequenceServiceImpl extends BaseServiceImpl<TrackSequenceMappe
|
|
|
return this.removeByIds(Arrays.asList(ids));
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public CommonResult start(Long id) {
|
|
|
+ TrackSequence trackSequence = getById(id);
|
|
|
+
|
|
|
+ HttpResponseEntity responseEntity = sendPostMsg(track_sequence_start_url, trackSequence);
|
|
|
+ if (ObjectUtil.isNotNull(responseEntity) && responseEntity.getStatus() == 200) {
|
|
|
+ trackSequence.setStatus(BizConstant.VideoStatus.INTERRUPTED);
|
|
|
+ updateById(trackSequence);
|
|
|
+ return CommonResult.fail("开始任务成功");
|
|
|
+ } else {
|
|
|
+ return CommonResult.fail("开始任务失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public CommonResult stop(Long id) {
|
|
|
+ TrackSequence trackSequence = getById(id);
|
|
|
+
|
|
|
+ HttpResponseEntity responseEntity = sendPostMsg(track_sequence_stop_url, trackSequence);
|
|
|
+ if (ObjectUtil.isNotNull(responseEntity) && responseEntity.getStatus() == 200) {
|
|
|
+ trackSequence.setStatus(BizConstant.VideoStatus.INTERRUPTED);
|
|
|
+ updateById(trackSequence);
|
|
|
+ return CommonResult.fail("终止任务成功");
|
|
|
+ } else {
|
|
|
+ return CommonResult.fail("终止任务失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ResponseEntity<org.springframework.core.io.Resource> zipImages(Long id) {
|
|
|
+ TrackSequence trackSequence = this.getById(id);
|
|
|
+ if (ObjectUtil.isNull(trackSequence)) {
|
|
|
+ return ResponseEntity.status(HttpStatus.NOT_FOUND).body(null);
|
|
|
+ }
|
|
|
+
|
|
|
+ String sourceFolderPath = trackSequence.getOutputPath();
|
|
|
+ String zipFilePath = Paths.get(sourceFolderPath).resolveSibling(trackSequence.getName() + ".zip").toString();
|
|
|
+
|
|
|
+ File file = new File(zipFilePath);
|
|
|
+
|
|
|
+ if (!file.exists() || !file.isFile()) {
|
|
|
+ return ResponseEntity.status(HttpStatus.NOT_FOUND).body(null);
|
|
|
+ }
|
|
|
+
|
|
|
+ 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);
|
|
|
+ }
|
|
|
}
|