修复压缩包中的 cad创建带文件名的文件夹

This commit is contained in:
gaoxiongzaq 2023-10-25 10:12:08 +08:00
parent be4080c80d
commit fdb5325e02
2 changed files with 10 additions and 8 deletions

View File

@ -323,14 +323,16 @@ public class FileHandlerService implements InitializingBean {
* @param outputFilePath pdf输出文件路径 * @param outputFilePath pdf输出文件路径
* @return 转换是否成功 * @return 转换是否成功
*/ */
public String cadToPdf(String inputFilePath, String outputFilePath ,String cadPreviewType) throws Exception { public String cadToPdf(String inputFilePath, String outputFilePath ,String cadPreviewType ,String fileKey) throws Exception {
final InterruptionTokenSource source = new InterruptionTokenSource();//CAD延时 final InterruptionTokenSource source = new InterruptionTokenSource();//CAD延时
int index = outputFilePath.lastIndexOf("."); if (!ObjectUtils.isEmpty(fileKey)) { //判断 是压缩包的创建新的目录
String folder = outputFilePath.substring(0, index); int index = outputFilePath.lastIndexOf("/"); //截取最后一个斜杠的前面的内容
File path = new File(folder); String folder = outputFilePath.substring(0, index);
//目录不存在 创建新的目录 File path = new File(folder);
if (!path.exists()) { //目录不存在 创建新的目录
path.mkdirs(); if (!path.exists()) {
path.mkdirs();
}
} }
Callable<String> call = () -> { Callable<String> call = () -> {
File outputFile = new File(outputFilePath); File outputFile = new File(outputFilePath);

View File

@ -54,7 +54,7 @@ public class CadFilePreviewImpl implements FilePreview {
String imageUrls = null; String imageUrls = null;
if (StringUtils.hasText(outFilePath)) { if (StringUtils.hasText(outFilePath)) {
try { try {
imageUrls = fileHandlerService.cadToPdf(filePath, outFilePath,cadPreviewType); imageUrls = fileHandlerService.cadToPdf(filePath, outFilePath,cadPreviewType,fileKey);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }