修改word导出bug

This commit is contained in:
zhuyy 2023-10-11 16:23:02 +08:00
parent f5770a9d68
commit d9cdc7293c
2 changed files with 12 additions and 14 deletions

View File

@ -241,17 +241,17 @@
<dependency>
<groupId>cn.afterturn</groupId>
<artifactId>easypoi-base</artifactId>
<version>4.1.2</version>
<version>4.4.0</version>
</dependency>
<dependency>
<groupId>cn.afterturn</groupId>
<artifactId>easypoi-web</artifactId>
<version>4.1.2</version>
<version>4.4.0</version>
</dependency>
<dependency>
<groupId>cn.afterturn</groupId>
<artifactId>easypoi-annotation</artifactId>
<version>4.1.2</version>
<version>4.4.0</version>
</dependency>
<!--pdf-->

View File

@ -31,6 +31,7 @@ import com.ydool.system.mapper.ConfigMapper;
import com.ydool.system.mapper.UserMapper;
import com.ydool.system.request.IdsRequest;
import com.ydool.system.service.impl.DeptServiceImpl;
import lombok.SneakyThrows;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -138,21 +139,19 @@ public class RecruitmentServiceImpl extends BaseService<RecruitmentMapper, Recru
return AjaxResult.ok().data(recruitmentRequest);
}
@SneakyThrows
@Override
public void export(String id, HttpServletResponse response) {
if (StrUtil.isBlank(id)) {
throw new ResultException("id不能为空");
}
File tf = null;
try {
// 本地获取模板路径
// URL url = ResourceUtils.getURL("classpath:doc/象山县国有企业人员招聘报备表.docx");
// 获取线上模板路径
URL url = ResourceUtils.getURL("/mnt/demo26.ydool.net/doc/象山县国有企业人员招聘报备表.docx");
tf = new File(URLDecoder.decode(url.getPath(), "UTF-8"));
} catch (UnsupportedEncodingException | FileNotFoundException e) {
throw new RuntimeException(e);
}
// String path = ResourceUtils.getURL("classpath:").getPath();
// File tf = new File(path, "/doc/象山县国有企业人员招聘报备表.docx");
// 本地获取模板路径
// URL url = ResourceUtils.getURL("classpath:doc/象山县国有企业人员招聘报备表.docx");
// 获取线上模板路径
URL url = ResourceUtils.getURL("/mnt/demo26.ydool.net/doc/象山县国有企业人员招聘报备表.docx");
File tf = new File(URLDecoder.decode(url.getPath(), "UTF-8"));
String wordDir = UploadUtils.getWebRoot();
File to = new File(wordDir);
if (!to.exists()) {
@ -174,7 +173,6 @@ public class RecruitmentServiceImpl extends BaseService<RecruitmentMapper, Recru
// 导出word
String word = exportWord(tf.getPath(), wordDir, fileName, params);
String pdfFileName = "象山县国有企业人员招聘报备表.pdf";
System.out.println("word = " + word);
// 转pdf
Document document = new Document();
document.loadFromFile(word);