|
@@ -200,15 +200,34 @@ public class CadastreManageServiceImpl implements CadastreManageService {
|
|
|
log.warn("处理文件失败:文件不存在: {}", theFilePath);
|
|
log.warn("处理文件失败:文件不存在: {}", theFilePath);
|
|
|
return null;
|
|
return null;
|
|
|
}
|
|
}
|
|
|
|
|
+ Long fileSize = Files.size(file);
|
|
|
|
|
|
|
|
- //文件解压到当前目录
|
|
|
|
|
- String unZipPath = file.getParent().toAbsolutePath().toString();
|
|
|
|
|
// 判断是否为压缩文件
|
|
// 判断是否为压缩文件
|
|
|
if (FileExtractUtil.isCompressedFile(theFilePath)) {
|
|
if (FileExtractUtil.isCompressedFile(theFilePath)) {
|
|
|
// 解压文件到同名文件夹并获取目录结构
|
|
// 解压文件到同名文件夹并获取目录结构
|
|
|
- boolean extractRes = FileExtractUtil.extractFile(theFilePath, unZipPath);
|
|
|
|
|
|
|
+ String extractRes = FileExtractUtil.extractToSameNameFolder(theFilePath);
|
|
|
|
|
+ if (StringUtils.isBlank(extractRes)) {
|
|
|
|
|
+ log.warn("解压文件失败:文件不存在: {}", theFilePath);
|
|
|
|
|
+ throw new ServiceException("解压文件失败:文件不存在,");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //这里解压文件名称作为文件名
|
|
|
|
|
+ Path extractPath = Paths.get(extractRes);
|
|
|
|
|
+ String fileName = extractPath.getFileName().toString();
|
|
|
|
|
+ theFileName = fileName.substring(0, fileName.lastIndexOf('.'));
|
|
|
|
|
+
|
|
|
//解压成功文件保存
|
|
//解压成功文件保存
|
|
|
- if (extractRes == true) {
|
|
|
|
|
|
|
+ if (StringUtils.isNotBlank(extractRes)) {
|
|
|
|
|
+ String unZipPath = extractRes;
|
|
|
|
|
+ String innerExtractFileName = FileExtractUtil.getFileDirName(extractRes);
|
|
|
|
|
+ // 如果解压后的文件夹名称不为空,则使用解压后的文件夹名称作为文件名
|
|
|
|
|
+ if(StringUtils.isNotBlank(innerExtractFileName)){
|
|
|
|
|
+ theFileName = innerExtractFileName;
|
|
|
|
|
+ }else {
|
|
|
|
|
+ //如果当前压缩文件最终一级则
|
|
|
|
|
+ unZipPath = unZipPath.replace("/"+theFileName, "");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
CadastreFile cadastreFile = new CadastreFile();
|
|
CadastreFile cadastreFile = new CadastreFile();
|
|
|
cadastreFile.generateId();//生成id
|
|
cadastreFile.generateId();//生成id
|
|
|
cadastreFile.setName(theFileName);
|
|
cadastreFile.setName(theFileName);
|
|
@@ -223,7 +242,7 @@ public class CadastreManageServiceImpl implements CadastreManageService {
|
|
|
if (StringUtils.isNotBlank(updateType)) {
|
|
if (StringUtils.isNotBlank(updateType)) {
|
|
|
cadastreFile.setReadStatus(updateType);
|
|
cadastreFile.setReadStatus(updateType);
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+ cadastreFile.setFileSize(fileSize);
|
|
|
cadastreFile.setStatus("0");
|
|
cadastreFile.setStatus("0");
|
|
|
cadastreFile.setUploadUser("admin");
|
|
cadastreFile.setUploadUser("admin");
|
|
|
cadastreFile.setUploadTime(new Date());
|
|
cadastreFile.setUploadTime(new Date());
|