From a4faf5ffe5fd1f6b9de93b5699f151ed1b84ee26 Mon Sep 17 00:00:00 2001
From: xuhy <3313886187@qq.com>
Date: 星期二, 20 一月 2026 11:16:34 +0800
Subject: [PATCH] bug修改
---
ruoyi-admin/src/main/java/com/ruoyi/web/controller/tool/PdfUtils.java | 21 ++++++++++++---------
1 files changed, 12 insertions(+), 9 deletions(-)
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/tool/PdfUtils.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/tool/PdfUtils.java
index 2efa490..49ba247 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/tool/PdfUtils.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/tool/PdfUtils.java
@@ -69,6 +69,7 @@
String inputFile = new File(filePath, fileName).getAbsolutePath();
String outputDir = new File(filePath, "pdf").getAbsolutePath();
+ log.info("开始转换文件:{}", inputFile);
// 创建输出目录
new File(outputDir).mkdirs();
@@ -91,19 +92,20 @@
// 创建进程构建器
ProcessBuilder pb = new ProcessBuilder(command);
+ log.info("执行命令:{}", command);
// 设置环境变量
Map<String, String> env = pb.environment();
env.put("LC_ALL", "zh_CN.UTF-8");
env.put("LANG", "zh_CN.UTF-8");
env.put("LANGUAGE", "zh_CN.UTF-8");
-
+ log.info("环境变量:{}", env);
// 重定向错误流到标准输出
pb.redirectErrorStream(true);
-
+ log.info("启动进程");
// 启动进程
Process process = pb.start();
-
+ log.info("等待进程完成");
// 读取输出
StringBuilder output = new StringBuilder();
try (BufferedReader reader = new BufferedReader(
@@ -111,33 +113,34 @@
String line;
while ((line = reader.readLine()) != null) {
output.append(line).append("\n");
- System.out.println(line);
}
}
-
+ log.info("进程完成,输出:{}", output);
// 等待进程完成,设置超时
if (!process.waitFor(120, TimeUnit.SECONDS)) {
process.destroyForcibly();
throw new RuntimeException("转换超时");
}
-
+ log.info("进程完成,退出码");
int exitCode = process.exitValue();
if (exitCode != 0) {
throw new RuntimeException("转换失败,退出码:" + exitCode + "\n输出:" + output);
}
-
+ log.info("进程完成,退出码:{}", exitCode);
// 检查生成的PDF文件
String pdfFileName = fileName.substring(0, fileName.lastIndexOf(".")) + ".pdf";
File pdfFile = new File(outputDir, pdfFileName);
-
+ log.info("PDF文件:{}", pdfFile);
if (!pdfFile.exists() || pdfFile.length() == 0) {
throw new RuntimeException("PDF文件未生成或为空");
}
String absolutePath = pdfFile.getAbsolutePath();
-
+ log.info("PDF文件绝对路径:{}", absolutePath);
MultipartFile file = convertFileToMultipartFile(pdfFile);
+ log.info("PDF文件转换完成");
// String s = tencentCosUtil.upLoadFile(multipartFile,"/wordToPdf");
String url = ObsUploadUtil.obsUpload(file);
+ log.info("PDF文件上传完成");
return url;
} catch (Exception e) {
--
Gitblit v1.7.1