|
@@ -2,6 +2,7 @@ package com.taais.biz.service.impl;
|
|
|
|
|
|
import java.io.File;
|
|
import java.io.File;
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
|
|
+import java.nio.file.Path;
|
|
import java.nio.file.Paths;
|
|
import java.nio.file.Paths;
|
|
import java.util.Arrays;
|
|
import java.util.Arrays;
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
@@ -15,11 +16,17 @@ import com.taais.biz.domain.bo.Video2imageBo;
|
|
import com.taais.biz.domain.vo.Video2imageVo;
|
|
import com.taais.biz.domain.vo.Video2imageVo;
|
|
import com.taais.biz.mapper.Video2imageMapper;
|
|
import com.taais.biz.mapper.Video2imageMapper;
|
|
import com.taais.biz.service.IVideo2imageService;
|
|
import com.taais.biz.service.IVideo2imageService;
|
|
|
|
+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.MapstructUtils;
|
|
|
|
+import com.taais.common.core.utils.StringUtils;
|
|
import com.taais.common.orm.core.page.PageQuery;
|
|
import com.taais.common.orm.core.page.PageQuery;
|
|
import com.taais.common.core.core.page.PageResult;
|
|
import com.taais.common.core.core.page.PageResult;
|
|
import com.taais.common.orm.core.service.impl.BaseServiceImpl;
|
|
import com.taais.common.orm.core.service.impl.BaseServiceImpl;
|
|
|
|
+import com.taais.system.domain.vo.SysOssVo;
|
|
|
|
+import com.taais.system.service.ISysOssService;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.core.io.FileSystemResource;
|
|
import org.springframework.core.io.FileSystemResource;
|
|
import org.springframework.core.io.Resource;
|
|
import org.springframework.core.io.Resource;
|
|
import org.springframework.http.HttpHeaders;
|
|
import org.springframework.http.HttpHeaders;
|
|
@@ -28,9 +35,10 @@ import org.springframework.http.ResponseEntity;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
-import static com.taais.biz.constant.BizConstant.VideoStatus.END;
|
|
|
|
-import static com.taais.biz.constant.BizConstant.VideoStatus.RUNNING;
|
|
|
|
|
|
+import static com.taais.biz.constant.BizConstant.UPLOAD_DIR;
|
|
|
|
+import static com.taais.biz.constant.BizConstant.VideoStatus.*;
|
|
import static com.taais.biz.domain.table.Video2imageTableDef.VIDEO2IMAGE;
|
|
import static com.taais.biz.domain.table.Video2imageTableDef.VIDEO2IMAGE;
|
|
|
|
+import static com.taais.biz.service.impl.VideoStableServiceImpl.removeFileExtension;
|
|
|
|
|
|
import com.taais.biz.utils.VideoCapture;
|
|
import com.taais.biz.utils.VideoCapture;
|
|
import com.taais.biz.utils.ZipUtils;
|
|
import com.taais.biz.utils.ZipUtils;
|
|
@@ -44,6 +52,8 @@ import com.taais.biz.utils.ZipUtils;
|
|
@Service
|
|
@Service
|
|
@Slf4j
|
|
@Slf4j
|
|
public class Video2imageServiceImpl extends BaseServiceImpl<Video2imageMapper, Video2image> implements IVideo2imageService {
|
|
public class Video2imageServiceImpl extends BaseServiceImpl<Video2imageMapper, Video2image> implements IVideo2imageService {
|
|
|
|
+ @Autowired
|
|
|
|
+ private ISysOssService ossService;
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public QueryWrapper query() {
|
|
public QueryWrapper query() {
|
|
@@ -121,9 +131,41 @@ public class Video2imageServiceImpl extends BaseServiceImpl<Video2imageMapper, V
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
public boolean insert(Video2imageBo video2imageBo) {
|
|
public boolean insert(Video2imageBo video2imageBo) {
|
|
- Video2image video2image = MapstructUtils.convert(video2imageBo, Video2image.class);
|
|
|
|
|
|
+ // 检查input_oss_id是否存在
|
|
|
|
+ if (ObjectUtil.isNull(video2imageBo.getInputOssId())) {
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ SysOssVo ossEntity = ossService.getById(video2imageBo.getInputOssId());
|
|
|
|
+ if (ObjectUtil.isNull(ossEntity)) {
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ Video2image newVideo2image = new Video2image();
|
|
|
|
+
|
|
|
|
+ newVideo2image.setInputOssId(video2imageBo.getInputOssId());
|
|
|
|
+ newVideo2image.setUrl(ossEntity.getUrl());
|
|
|
|
+
|
|
|
|
+ String filePath = ossEntity.getFileName();
|
|
|
|
+ String localPath = TaaisConfig.getProfile();
|
|
|
|
+ String resourcePath = localPath + StringUtils.substringAfter(filePath, Constants.RESOURCE_PREFIX);
|
|
|
|
+ newVideo2image.setPath(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());
|
|
|
|
+ newVideo2image.setOutPath(outPath.toString());
|
|
|
|
+
|
|
|
|
+ newVideo2image.setZipFilePath(path.resolveSibling(fileName_without_suffix + ".zip").toString());
|
|
|
|
+
|
|
|
|
+ newVideo2image.setName(video2imageBo.getName());
|
|
|
|
+ newVideo2image.setFps(video2imageBo.getFps());
|
|
|
|
+ newVideo2image.setStatus(NOT_START);
|
|
|
|
+ newVideo2image.setRemarks(video2imageBo.getRemarks());
|
|
|
|
|
|
- return this.save(video2image);// 使用全局配置的雪花算法主键生成器生成ID值
|
|
|
|
|
|
+ return this.save(newVideo2image);// 使用全局配置的雪花算法主键生成器生成ID值
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|