|
@@ -1,17 +1,25 @@
|
|
|
package com.taais.biz.service.impl;
|
|
|
|
|
|
+import java.nio.file.Path;
|
|
|
+import java.nio.file.Paths;
|
|
|
import java.util.Arrays;
|
|
|
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.domain.ToInfrared;
|
|
|
+import com.taais.common.core.config.TaaisConfig;
|
|
|
+import com.taais.common.core.constant.Constants;
|
|
|
import com.taais.common.core.utils.MapstructUtils;
|
|
|
import com.taais.common.core.utils.StringUtils;
|
|
|
import com.taais.common.orm.core.page.PageQuery;
|
|
|
import com.taais.common.core.core.page.PageResult;
|
|
|
import com.taais.common.orm.core.service.impl.BaseServiceImpl;
|
|
|
+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.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import com.taais.biz.mapper.TrackSequenceMapper;
|
|
@@ -19,7 +27,10 @@ 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;
|
|
|
|
|
|
/**
|
|
|
* 注视轨迹序列Service业务层处理
|
|
@@ -29,6 +40,9 @@ import static com.taais.biz.domain.table.TrackSequenceTableDef.TRACK_SEQUENCE;
|
|
|
*/
|
|
|
@Service
|
|
|
public class TrackSequenceServiceImpl extends BaseServiceImpl<TrackSequenceMapper, TrackSequence> implements ITrackSequenceService {
|
|
|
+ @Autowired
|
|
|
+ private ISysOssService ossService;
|
|
|
+
|
|
|
@Resource
|
|
|
private TrackSequenceMapper trackSequenceMapper;
|
|
|
|
|
@@ -40,29 +54,29 @@ public class TrackSequenceServiceImpl extends BaseServiceImpl<TrackSequenceMappe
|
|
|
private QueryWrapper buildQueryWrapper(TrackSequenceBo trackSequenceBo) {
|
|
|
QueryWrapper queryWrapper = super.buildBaseQueryWrapper();
|
|
|
queryWrapper.and(TRACK_SEQUENCE.NAME.like
|
|
|
- (trackSequenceBo.getName()));
|
|
|
+ (trackSequenceBo.getName()));
|
|
|
queryWrapper.and(TRACK_SEQUENCE.STATUS.eq
|
|
|
- (trackSequenceBo.getStatus()));
|
|
|
+ (trackSequenceBo.getStatus()));
|
|
|
queryWrapper.and(TRACK_SEQUENCE.START_TIME.eq
|
|
|
- (trackSequenceBo.getStartTime()));
|
|
|
+ (trackSequenceBo.getStartTime()));
|
|
|
queryWrapper.and(TRACK_SEQUENCE.END_TIME.eq
|
|
|
- (trackSequenceBo.getEndTime()));
|
|
|
+ (trackSequenceBo.getEndTime()));
|
|
|
queryWrapper.and(TRACK_SEQUENCE.COST_SECOND.eq
|
|
|
- (trackSequenceBo.getCostSecond()));
|
|
|
+ (trackSequenceBo.getCostSecond()));
|
|
|
queryWrapper.and(TRACK_SEQUENCE.LOG.eq
|
|
|
- (trackSequenceBo.getLog()));
|
|
|
+ (trackSequenceBo.getLog()));
|
|
|
queryWrapper.and(TRACK_SEQUENCE.REMARKS.eq
|
|
|
- (trackSequenceBo.getRemarks()));
|
|
|
+ (trackSequenceBo.getRemarks()));
|
|
|
queryWrapper.and(TRACK_SEQUENCE.URL.eq
|
|
|
- (trackSequenceBo.getUrl()));
|
|
|
+ (trackSequenceBo.getUrl()));
|
|
|
queryWrapper.and(TRACK_SEQUENCE.INPUT_OSS_ID.eq
|
|
|
- (trackSequenceBo.getInputOssId()));
|
|
|
+ (trackSequenceBo.getInputOssId()));
|
|
|
queryWrapper.and(TRACK_SEQUENCE.INPUT_PATH.eq
|
|
|
- (trackSequenceBo.getInputPath()));
|
|
|
+ (trackSequenceBo.getInputPath()));
|
|
|
queryWrapper.and(TRACK_SEQUENCE.OUTPUT_PATH.eq
|
|
|
- (trackSequenceBo.getOutputPath()));
|
|
|
+ (trackSequenceBo.getOutputPath()));
|
|
|
queryWrapper.and(TRACK_SEQUENCE.ZIP_FILE_PATH.eq
|
|
|
- (trackSequenceBo.getZipFilePath()));
|
|
|
+ (trackSequenceBo.getZipFilePath()));
|
|
|
|
|
|
return queryWrapper;
|
|
|
}
|
|
@@ -75,7 +89,7 @@ public class TrackSequenceServiceImpl extends BaseServiceImpl<TrackSequenceMappe
|
|
|
*/
|
|
|
@Override
|
|
|
public TrackSequenceVo selectById(Long id) {
|
|
|
- return this.getOneAs(query().where(TRACK_SEQUENCE.ID.eq(id)), TrackSequenceVo.class);
|
|
|
+ return this.getOneAs(query().where(TRACK_SEQUENCE.ID.eq(id)), TrackSequenceVo.class);
|
|
|
|
|
|
}
|
|
|
|
|
@@ -88,7 +102,7 @@ public class TrackSequenceServiceImpl extends BaseServiceImpl<TrackSequenceMappe
|
|
|
@Override
|
|
|
public List<TrackSequenceVo> selectList(TrackSequenceBo trackSequenceBo) {
|
|
|
QueryWrapper queryWrapper = buildQueryWrapper(trackSequenceBo);
|
|
|
- return this.listAs(queryWrapper, TrackSequenceVo.class);
|
|
|
+ return this.listAs(queryWrapper, TrackSequenceVo.class);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -100,7 +114,7 @@ public class TrackSequenceServiceImpl extends BaseServiceImpl<TrackSequenceMappe
|
|
|
@Override
|
|
|
public PageResult<TrackSequenceVo> selectPage(TrackSequenceBo trackSequenceBo) {
|
|
|
QueryWrapper queryWrapper = buildQueryWrapper(trackSequenceBo);
|
|
|
- Page<TrackSequenceVo> page = this.pageAs(PageQuery.build(), queryWrapper, TrackSequenceVo.class);
|
|
|
+ Page<TrackSequenceVo> page = this.pageAs(PageQuery.build(), queryWrapper, TrackSequenceVo.class);
|
|
|
return PageResult.build(page);
|
|
|
}
|
|
|
|
|
@@ -112,9 +126,40 @@ public class TrackSequenceServiceImpl extends BaseServiceImpl<TrackSequenceMappe
|
|
|
*/
|
|
|
@Override
|
|
|
public boolean insert(TrackSequenceBo trackSequenceBo) {
|
|
|
- TrackSequence trackSequence =MapstructUtils.convert(trackSequenceBo, TrackSequence. class);
|
|
|
+ // 检查input_oss_id是否存在
|
|
|
+ if (ObjectUtil.isNull(trackSequenceBo.getInputOssId())) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ SysOssVo ossEntity = ossService.getById(trackSequenceBo.getInputOssId());
|
|
|
+ if (ObjectUtil.isNull(ossEntity)) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ TrackSequence trackSequence = new TrackSequence();
|
|
|
+
|
|
|
+ trackSequence.setInputOssId(trackSequenceBo.getInputOssId());
|
|
|
+ trackSequence.setUrl(ossEntity.getUrl());
|
|
|
+
|
|
|
+ String filePath = ossEntity.getFileName();
|
|
|
+ String localPath = TaaisConfig.getProfile();
|
|
|
+ String resourcePath = localPath + StringUtils.substringAfter(filePath, Constants.RESOURCE_PREFIX);
|
|
|
+ trackSequence.setInputPath(resourcePath);
|
|
|
+
|
|
|
+ String fileName = StringUtils.substringAfterLast(filePath, "/");
|
|
|
+ String fileName_without_suffix = removeFileExtension(fileName);
|
|
|
+
|
|
|
+ Path path = Paths.get(resourcePath);
|
|
|
+ Path outPath = path.resolveSibling(fileName_without_suffix + "_images" + System.currentTimeMillis());
|
|
|
+ trackSequence.setOutputPath(outPath.toString());
|
|
|
+
|
|
|
+ trackSequence.setZipFilePath(path.resolveSibling(fileName_without_suffix + ".zip").toString());
|
|
|
+
|
|
|
+ trackSequence.setName(trackSequenceBo.getName());
|
|
|
+ trackSequence.setStatus(NOT_START);
|
|
|
+ trackSequence.setRemarks(trackSequenceBo.getRemarks());
|
|
|
|
|
|
- return this.save(trackSequence);//使用全局配置的雪花算法主键生成器生成ID值
|
|
|
+ return this.save(trackSequence);// 使用全局配置的雪花算法主键生成器生成ID值
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -125,10 +170,10 @@ public class TrackSequenceServiceImpl extends BaseServiceImpl<TrackSequenceMappe
|
|
|
*/
|
|
|
@Override
|
|
|
public boolean update(TrackSequenceBo trackSequenceBo) {
|
|
|
- TrackSequence trackSequence =MapstructUtils.convert(trackSequenceBo, TrackSequence. class);
|
|
|
- if (ObjectUtil.isNotNull(trackSequence) && ObjectUtil.isNotNull(trackSequence.getId())){
|
|
|
+ TrackSequence trackSequence = MapstructUtils.convert(trackSequenceBo, TrackSequence.class);
|
|
|
+ if (ObjectUtil.isNotNull(trackSequence) && ObjectUtil.isNotNull(trackSequence.getId())) {
|
|
|
boolean updated = this.updateById(trackSequence);
|
|
|
- return updated;
|
|
|
+ return updated;
|
|
|
}
|
|
|
return false;
|
|
|
}
|