|
@@ -94,7 +94,40 @@ public class ReportDocumentService extends ServiceImpl<ReportDocumentMapper, Rep
|
|
|
String fileName = IdUtil.simpleUUID() + ".docx";
|
|
|
String directoryName = fileUtils.createDirectory();
|
|
|
String outPath = fileUtils.getSavePath(directoryName)+fileName;
|
|
|
- //根据报告Id获得报告信息
|
|
|
+
|
|
|
+ XWPFTemplate template =this.getstabilityMaps(reportId,filePath);
|
|
|
+ // 读取模板、数据并渲染
|
|
|
+// 文件是否已存在,则删除
|
|
|
+ File file = new File(outPath);
|
|
|
+ if (file.exists()) {
|
|
|
+ file.delete();
|
|
|
+ }
|
|
|
+// 生成word保存在指定目录
|
|
|
+ template.writeToFile(outPath);
|
|
|
+ template.close();
|
|
|
+ //导出成功后,导出报告记录入库
|
|
|
+ String url = fileUtils.getDirectory2(directoryName) + fileName;
|
|
|
+ PersonnelVO personnelVO =cacheUtils.getLoginUser(loginUtils.getId());
|
|
|
+ ReportDocument reportDocument =new ReportDocument();
|
|
|
+ reportDocument.setReportId(reportId);
|
|
|
+ reportDocument.setFileName(fileName);
|
|
|
+ reportDocument.setFilePath(url);
|
|
|
+ reportDocument.setPersonId(personnelVO.getId());
|
|
|
+ reportDocument.setTemplateId(reportTemplate.getId());
|
|
|
+ reportDocument.setTemplateName(reportTemplate.getTemplateName());
|
|
|
+ reportDocument.setPersonName(personnelVO.getName());
|
|
|
+ reportDocument.insert();
|
|
|
+ return Response.success(url);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @autor
|
|
|
+ * @return
|
|
|
+ * @description 装载稳定和无效模板信息
|
|
|
+ */
|
|
|
+ private XWPFTemplate getstabilityMaps(Integer reportId,String filePath) throws IOException {
|
|
|
+ //根据报告Id获得报告信息
|
|
|
Report report = reportService.getById(reportId);
|
|
|
// 根据拆分人(报告的创建人)Id和报告ID获得所有特征
|
|
|
LambdaQueryWrapper<Features> allFeaturesWrapper = new LambdaQueryWrapper<>();
|
|
@@ -204,8 +237,11 @@ public class ReportDocumentService extends ServiceImpl<ReportDocumentMapper, Rep
|
|
|
List<AssoScenarIOS> partScenariosRecords = scenariosRecords.stream().filter(item -> item.getScenariosID().equals(item1.getId())).collect(Collectors.toList());
|
|
|
List<Integer> featureRecordsIds = partScenariosRecords.stream().map(AssoScenarIOS::getFeatureRecordID).collect(Collectors.toList());
|
|
|
List<AssoRecordsFeature> assoRecordsFeatures1 = assoRecordsFeatures.stream().filter(item->featureRecordsIds.contains(item.getId())).collect(Collectors.toList());
|
|
|
- List<Integer> partRecordIds=assoRecordsFeatures1.stream().map(AssoRecordsFeature::getRecordsId).collect(Collectors.toList());
|
|
|
- List<Integer> partFetIds =assoRecordsFeatures1.stream().map(AssoRecordsFeature::getFeatureId).collect(Collectors.toList());
|
|
|
+ List<Integer> partRecordIds= assoRecordsFeatures1.stream().map(AssoRecordsFeature::getRecordsId).collect(Collectors.toList());
|
|
|
+ List<Integer> partFetIds = assoRecordsFeatures1.stream().map(AssoRecordsFeature::getFeatureId).collect(Collectors.toList());
|
|
|
+ //获得共识特征的ID
|
|
|
+ List<Integer> comFetIds =partScenariosRecords.stream().map(AssoScenarIOS::getFeaturesID).collect(Collectors.toList());
|
|
|
+ partFetIds.addAll(comFetIds);
|
|
|
//获得单个对比方案的权要的所有特征
|
|
|
List<Features> partFeatures = allFeatures.stream().filter(item -> partFetIds.contains(item.getId())).collect(Collectors.toList());
|
|
|
List<CompareRecords> records = compareRecords.stream().filter(item -> partRecordIds.contains(item.getId())).collect(Collectors.toList());
|
|
@@ -261,7 +297,6 @@ public class ReportDocumentService extends ServiceImpl<ReportDocumentMapper, Rep
|
|
|
}
|
|
|
});
|
|
|
//比较所有专利号和权要所有权要的大小,如果相等则将该专利加入到新颖性列表中
|
|
|
-
|
|
|
List<String> noveltyFiles = new ArrayList<>();
|
|
|
patentNOs.forEach(
|
|
|
item -> {
|
|
@@ -338,58 +373,30 @@ public class ReportDocumentService extends ServiceImpl<ReportDocumentMapper, Rep
|
|
|
allRightScenarios.add(map);
|
|
|
resultMaps.add(resultMap);
|
|
|
});
|
|
|
-
|
|
|
-
|
|
|
- // 为表格的显示绑定行循环
|
|
|
- LoopRowTableRenderPolicy policy = new LoopRowTableRenderPolicy();
|
|
|
- HtmlRenderPolicy htmlRenderPolicy = new HtmlRenderPolicy();
|
|
|
- // 将bz设置为行循环绑定的数据源的key,即key是bz的value会在模板中的{{bz}}处进行解析
|
|
|
- Configure configure = Configure.builder().bind("patentList", policy).bind("fileDetails", policy).bind("allResults", policy).bind("remark",htmlRenderPolicy).build();
|
|
|
+ //1.系统数据
|
|
|
+ //存放单条对比结果的map
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
- //1.系统数据
|
|
|
String date = DateUtils.formatDate(new Date(), DateUtils.YYYY_MM_DD);
|
|
|
String[] ds = date.split("-");
|
|
|
map.put("sys", new SystemMO(ds[0], ds[1], ds[2], "", "reportName"));
|
|
|
map.put("patentList", patentListMaps);
|
|
|
map.put("combinations", allRightScenarios);
|
|
|
map.put("allResults",resultMaps);
|
|
|
+ // 为表格的显示绑定行循环
|
|
|
+ LoopRowTableRenderPolicy policy = new LoopRowTableRenderPolicy();
|
|
|
+ HtmlRenderPolicy htmlRenderPolicy = new HtmlRenderPolicy();
|
|
|
+ // 将bz设置为行循环绑定的数据源的key,即key是bz的value会在模板中的{{bz}}处进行解析
|
|
|
+ Configure configure = Configure.builder().bind("patentList", policy).bind("fileDetails", policy).bind("allResults", policy).bind("remark",htmlRenderPolicy).build();
|
|
|
// 读取模板、数据并渲染
|
|
|
XWPFTemplate template = XWPFTemplate.compile(filePath, configure).render(map);
|
|
|
-// 文件是否已存在,则删除
|
|
|
- File file = new File(outPath);
|
|
|
- if (file.exists()) {
|
|
|
- file.delete();
|
|
|
- }
|
|
|
-// 生成word保存在指定目录
|
|
|
- template.writeToFile(outPath);
|
|
|
- template.close();
|
|
|
- //导出成功后,导出报告记录入库
|
|
|
- String url = fileUtils.getDirectory2(directoryName) + fileName;
|
|
|
- PersonnelVO personnelVO =cacheUtils.getLoginUser(loginUtils.getId());
|
|
|
- ReportDocument reportDocument =new ReportDocument();
|
|
|
- reportDocument.setReportId(reportId);
|
|
|
- reportDocument.setFileName(fileName);
|
|
|
- reportDocument.setFilePath(url);
|
|
|
- reportDocument.setPersonId(personnelVO.getId());
|
|
|
- reportDocument.setTemplateId(reportTemplate.getId());
|
|
|
- reportDocument.setTemplateName(reportTemplate.getTemplateName());
|
|
|
- reportDocument.setPersonName(personnelVO.getName());
|
|
|
- reportDocument.insert();
|
|
|
- return Response.success(url);
|
|
|
+return template;
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
-/* *//**
|
|
|
- * @autor
|
|
|
- * @return
|
|
|
- * @description 装载稳定和无效模板信息
|
|
|
- *//*
|
|
|
- private Map<String, Object> getstabilityMaps(){
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- }*/
|
|
|
+//
|
|
|
+// private XWPFTemplate FTOtemplate(Integer reportId,String filePath){
|
|
|
+//
|
|
|
+// XWPFTemplate template = XWPFTemplate.compile(filePath, configure).render(map);
|
|
|
+// return template;
|
|
|
+// }
|
|
|
|
|
|
}
|
|
|
|