|
@@ -1,6 +1,8 @@
|
|
|
package com.taais.biz.service.impl;
|
|
|
|
|
|
import java.io.File;
|
|
|
+import java.nio.file.Path;
|
|
|
+import java.nio.file.Paths;
|
|
|
import java.util.Arrays;
|
|
|
import java.util.List;
|
|
|
|
|
@@ -28,6 +30,7 @@ import com.taais.biz.domain.vo.DataSeqVo;
|
|
|
import com.taais.biz.service.IDataSeqService;
|
|
|
|
|
|
import static com.taais.biz.domain.table.DataSeqTableDef.DATA_SEQ;
|
|
|
+import static com.taais.biz.service.impl.VideoStableServiceImpl.removeFileExtension;
|
|
|
import static com.taais.biz.utils.ZipUtils.unzip;
|
|
|
|
|
|
/**
|
|
@@ -195,7 +198,7 @@ public class DataSeqServiceImpl extends BaseServiceImpl<DataSeqMapper, DataSeq>
|
|
|
String resourcePath = localPath + StringUtils.substringAfter(filePath, Constants.RESOURCE_PREFIX);
|
|
|
String unzipPath = resourcePath.substring(0, resourcePath.lastIndexOf(".")) + BizConstant.UNZIP_SUFFIX;
|
|
|
|
|
|
- String urlPrefix = ossEntity.getUrl().substring(0, ossEntity.getUrl().lastIndexOf(".")) + BizConstant.UNZIP_SUFFIX;
|
|
|
+ String urlPrefix = ossEntity.getUrl().substring(0, ossEntity.getUrl().lastIndexOf(".")) + BizConstant.UNZIP_SUFFIX;
|
|
|
|
|
|
// 列出unzipPath下所有图片文件
|
|
|
File directory = new File(unzipPath);
|
|
@@ -204,6 +207,41 @@ public class DataSeqServiceImpl extends BaseServiceImpl<DataSeqMapper, DataSeq>
|
|
|
return imageList;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public List<String> getImages(Long inputOdssId, String subsystem, Boolean isInput, String dir) {
|
|
|
+ // 检查input_oss_id是否存在
|
|
|
+ if (ObjectUtil.isNull(inputOdssId)) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ SysOssVo ossEntity = ossService.getById(inputOdssId);
|
|
|
+ if (ObjectUtil.isNull(ossEntity)) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ String filePath = ossEntity.getFileName();
|
|
|
+ String localPath = TaaisConfig.getProfile();
|
|
|
+ String resourcePath = localPath + StringUtils.substringAfter(filePath, Constants.RESOURCE_PREFIX);
|
|
|
+ String unzipPath = resourcePath.substring(0, resourcePath.lastIndexOf(".")) + BizConstant.UNZIP_SUFFIX + "/" + dir;
|
|
|
+ String resultPath = resourcePath.substring(0, resourcePath.lastIndexOf(".")) + subsystem + "/" + dir;
|
|
|
+
|
|
|
+
|
|
|
+ if (isInput) {
|
|
|
+ String urlPrefix = ossEntity.getUrl().substring(0, ossEntity.getUrl().lastIndexOf(".")) + BizConstant.UNZIP_SUFFIX + "/" + dir;
|
|
|
+ // 列出unzipPath下所有图片文件
|
|
|
+ File directory = new File(unzipPath);
|
|
|
+ File[] files = directory.listFiles();
|
|
|
+ List<String> imageList = Arrays.asList(files).stream().filter(file -> isImageFile(file)).map(file -> urlPrefix + "/" + file.getName()).toList();
|
|
|
+ return imageList;
|
|
|
+ } else {
|
|
|
+ String urlPrefix = ossEntity.getUrl().substring(0, ossEntity.getUrl().lastIndexOf(".")) + subsystem + "/" + dir;
|
|
|
+ // 列出unzipPath下所有图片文件
|
|
|
+ File directory = new File(resultPath);
|
|
|
+ File[] files = directory.listFiles();
|
|
|
+ List<String> imageList = Arrays.asList(files).stream().filter(file -> isImageFile(file)).map(file -> urlPrefix + "/" + file.getName()).toList();
|
|
|
+ return imageList;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
// 常见图片格式的后缀
|
|
|
private static final String[] IMAGE_EXTENSIONS = {
|
|
|
".jpg", ".jpeg", ".png", ".gif", ".bmp", ".tiff", ".tif", ".webp"
|
|
@@ -211,6 +249,9 @@ public class DataSeqServiceImpl extends BaseServiceImpl<DataSeqMapper, DataSeq>
|
|
|
|
|
|
// 判断文件是否为常见图片格式
|
|
|
private static boolean isImageFile(File file) {
|
|
|
+ if (file.isDirectory()) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
String fileName = file.getName().toLowerCase();
|
|
|
for (String extension : IMAGE_EXTENSIONS) {
|
|
|
if (fileName.endsWith(extension)) {
|