法规清单-导出word,获取word模板完善。

This commit is contained in:
wangzhijiang
2022-06-11 16:24:41 +08:00
parent e9d2db2e2a
commit 74a5f5d0b1
@@ -5464,13 +5464,13 @@ public class ProjectLawsInventoryEOServiceImpl extends ServiceImpl<ProjectLawsIn
dataMap.put("REGULATION_ENG", StringUtils.isNotEmpty(regulationOwnerName) ? regulationOwnerName : "");
log.debug("导出word报告,查询数据结束 =============================================================================");
log.debug("导出word报告,获取模板开始 =============================================================================");
File templateFile = new File(exportPdfTempPath + "temp/ComplianceReportTemplate.docx");
//File templateFile = new File(exportPdfTempPath + "temp/ComplianceReportTemplate.docx");
InputStream inputStream = ProjectLawsInventoryEOServiceImpl.class.getClassLoader().getResourceAsStream("exportPdfTemp/ComplianceReportTemplate.docx");
try {
/*try {
FileUtils.copyInputStreamToFile(inputStream, templateFile);
} catch (IOException e) {
e.printStackTrace();
}
}*/
//
// try {
// OutputStream os = new FileOutputStream(templateFile);
@@ -5486,7 +5486,8 @@ public class ProjectLawsInventoryEOServiceImpl extends ServiceImpl<ProjectLawsIn
// }
log.debug("导出word报告,获取模板结束 =============================================================================");
if(templateFile != null){
//if(templateFile != null){
if(inputStream != null){
try {
String uuid = UUID.randomUUID().toString();
//final String TEMP_FILE_PATH = System.getProperty("os.name").toLowerCase().contains("windows") ? System.getProperty("user.dir") + File.separator : "/home/admin/tempfile/";
@@ -5499,8 +5500,8 @@ public class ProjectLawsInventoryEOServiceImpl extends ServiceImpl<ProjectLawsIn
String outFile = TEMP_FILE_PATH + uuid + ".docx";
exportFile = new File(outFile);
FileOutputStream os = new FileOutputStream(outFile);
WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.load(new FileInputStream(templateFile));
// WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.load(inputStream);
//WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.load(new FileInputStream(templateFile));
WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.load(inputStream);
//验证符合性流程实例id
String verifyPId = projectTaskInventoryEO.getVerifyPId();
@@ -5675,4 +5676,16 @@ public class ProjectLawsInventoryEOServiceImpl extends ServiceImpl<ProjectLawsIn
WordprocessingMLPackage template = WordprocessingMLPackage.load(new FileInputStream(new File(name)));
return template;
}
// public static void main(String[] args){
// InputStream inputStream = ProjectLawsInventoryEOServiceImpl.class.getClassLoader().getResourceAsStream("exportPdfTemp/ComplianceReportTemplate.docx");
// Resource resource = new ClassPathResource("ComplianceReportTemplate.docx");
// try {
// InputStream inputStream1 = resource.getInputStream();
// System.out.println(inputStream1 != null);
// } catch (IOException e) {
// e.printStackTrace();
// }
// System.out.println(inputStream != null);
// }
}