|
@@ -18,8 +18,10 @@ import cn.cslg.pas.domain.es.Patent;
|
|
|
import cn.cslg.pas.domain.es.PatentPerson;
|
|
|
import cn.cslg.pas.domain.es.Priorities;
|
|
|
import cn.cslg.pas.domain.es.Text;
|
|
|
+import cn.cslg.pas.exception.ExceptionEnum;
|
|
|
import cn.cslg.pas.exception.XiaoShiException;
|
|
|
import cn.cslg.pas.mapper.AvoidDesignMapper;
|
|
|
+import cn.cslg.pas.mapper.ProjectMapper;
|
|
|
import cn.cslg.pas.service.business.*;
|
|
|
import cn.cslg.pas.service.business.es.*;
|
|
|
import cn.cslg.pas.service.business.invalidReport.AssoReasonLiteratureService;
|
|
@@ -38,6 +40,7 @@ import com.deepoove.poi.data.Pictures;
|
|
|
import com.deepoove.poi.plugin.table.LoopRowTableRenderPolicy;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
|
+import org.apache.commons.lang3.ObjectUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.ddr.poi.html.HtmlRenderPolicy;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -104,6 +107,8 @@ public class ReportExportService {
|
|
|
private EvidenceReasonService evidenceReasonService;
|
|
|
@Autowired
|
|
|
private TortCompareRecordService tortCompareRecordService;
|
|
|
+ @Autowired
|
|
|
+ private ProjectMapper projectMapper;
|
|
|
|
|
|
/**
|
|
|
* @param projectId
|
|
@@ -117,9 +122,16 @@ public class ReportExportService {
|
|
|
ReportTemple reportTemplate = templeService.getById(templeId);
|
|
|
//获得模板路径
|
|
|
String templateFilePath = fileUtils.getPath(reportTemplate.getTemplatePath());
|
|
|
-
|
|
|
+ //获取项目名称
|
|
|
+ String name = "";
|
|
|
+ Project project = projectMapper.selectById(projectId);
|
|
|
+ if (ObjectUtils.isNotEmpty(project) && StringUtils.isNotEmpty(project.getName())) {
|
|
|
+ name = project.getName();
|
|
|
+ } else {
|
|
|
+ name = IdUtil.simpleUUID();
|
|
|
+ }
|
|
|
//读取模板后保存生成word的地址
|
|
|
- String fileName = IdUtil.simpleUUID() + ".docx";
|
|
|
+ String fileName = name + ".docx";
|
|
|
String directoryName = fileUtils.createDirectory();
|
|
|
String outPath = fileUtils.getSavePath(directoryName) + fileName;
|
|
|
|
|
@@ -317,7 +329,12 @@ public class ReportExportService {
|
|
|
HtmlRenderPolicy htmlRenderPolicy = new HtmlRenderPolicy();
|
|
|
// 将bz设置为行循环绑定的数据源的key,即key是bz的value会在模板中的{{bz}}处进行解析
|
|
|
Configure configure = Configure.builder().bind("cM", policy).bind("targetDescription", htmlRenderPolicy).bind("compareDescription",htmlRenderPolicy).build();
|
|
|
- XWPFTemplate template = XWPFTemplate.compile(filePath, configure).render(map1);
|
|
|
+ XWPFTemplate template = null;
|
|
|
+ try {
|
|
|
+ template = XWPFTemplate.compile(filePath, configure).render(map1);
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR,"未匹配到模版文件");
|
|
|
+ }
|
|
|
return template;
|
|
|
}
|
|
|
|
|
@@ -355,7 +372,12 @@ public class ReportExportService {
|
|
|
.bind("littleDirection", htmlRenderPolicy)
|
|
|
.bind("wholeDirection", htmlRenderPolicy)
|
|
|
.build();
|
|
|
- XWPFTemplate template = XWPFTemplate.compile(path, configure).render(new HashMap<>());
|
|
|
+ XWPFTemplate template = null;
|
|
|
+ try {
|
|
|
+ template = XWPFTemplate.compile(path, configure).render(new HashMap<>());
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR,"未匹配到模版文件");
|
|
|
+ }
|
|
|
return template;
|
|
|
}
|
|
|
|
|
@@ -591,7 +613,12 @@ public class ReportExportService {
|
|
|
HtmlRenderPolicy htmlRenderPolicy = new HtmlRenderPolicy();
|
|
|
// 将bz设置为行循环绑定的数据源的key,即key是bz的value会在模板中的{{bz}}处进行解析
|
|
|
Configure configure = Configure.builder().bind("cM", policy).bind("targetDescription", htmlRenderPolicy).build();
|
|
|
- XWPFTemplate template = XWPFTemplate.compile(filePath, configure).render(map);
|
|
|
+ XWPFTemplate template = null;
|
|
|
+ try {
|
|
|
+ template = XWPFTemplate.compile(filePath, configure).render(map);
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR,"未匹配到模版文件");
|
|
|
+ }
|
|
|
return template;
|
|
|
|
|
|
}
|
|
@@ -988,7 +1015,12 @@ public class ReportExportService {
|
|
|
.bind("remark", htmlRenderPolicy)
|
|
|
.build();
|
|
|
// 读取模板、数据并渲染
|
|
|
- XWPFTemplate template = XWPFTemplate.compile(filePath, configure).render(map);
|
|
|
+ XWPFTemplate template = null;
|
|
|
+ try {
|
|
|
+ template = XWPFTemplate.compile(filePath, configure).render(map);
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR,"未匹配到模版文件");
|
|
|
+ }
|
|
|
return template;
|
|
|
}
|
|
|
|
|
@@ -1378,7 +1410,12 @@ public class ReportExportService {
|
|
|
.bind("remark", htmlRenderPolicy)
|
|
|
.build();
|
|
|
// 读取模板、数据并渲染
|
|
|
- XWPFTemplate template = XWPFTemplate.compile(filePath, configure).render(map);
|
|
|
+ XWPFTemplate template = null;
|
|
|
+ try {
|
|
|
+ template = XWPFTemplate.compile(filePath, configure).render(map);
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR,"未匹配到模版文件");
|
|
|
+ }
|
|
|
return template;
|
|
|
}
|
|
|
}
|