|
@@ -11,10 +11,13 @@ import cn.cslg.pas.common.vo.PatentRightParams;
|
|
|
import cn.cslg.pas.common.vo.RePatentClaim;
|
|
|
import cn.cslg.pas.common.vo.business.PatentNoVO;
|
|
|
import cn.cslg.pas.domain.business.ReportProject;
|
|
|
+import cn.cslg.pas.domain.business.ReportTemple;
|
|
|
+import cn.cslg.pas.domain.business.TemplateConfig;
|
|
|
import cn.cslg.pas.domain.es.Text;
|
|
|
import cn.cslg.pas.exception.XiaoShiException;
|
|
|
import cn.cslg.pas.mapper.AvoidDesignMapper;
|
|
|
import cn.cslg.pas.service.business.ReportProjectService;
|
|
|
+import cn.cslg.pas.service.business.TemplateConfigService;
|
|
|
import cn.cslg.pas.service.business.TempleService;
|
|
|
import cn.cslg.pas.service.business.es.EsPatentService;
|
|
|
import cn.cslg.pas.service.common.FileManagerService;
|
|
@@ -56,6 +59,9 @@ public class ReportExportService {
|
|
|
private EsPatentService esPatentService;
|
|
|
@Autowired
|
|
|
private AvoidDesignMapper avoidDesignMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private TemplateConfigService templateConfigService;
|
|
|
/**
|
|
|
* @param projectId
|
|
|
* @param templeId
|
|
@@ -65,28 +71,34 @@ public class ReportExportService {
|
|
|
*/
|
|
|
public String exportReport(Integer projectId, Integer templeId) throws IOException {
|
|
|
//根据模板ID获得模板
|
|
|
-// ReportTemple reportTemplate = templeService.getById(templeId);
|
|
|
-// //获得模板路径
|
|
|
-// String filePath = fileUtils.getPath(reportTemplate.getTemplatePath());
|
|
|
+ ReportTemple reportTemplate = templeService.getById(templeId);
|
|
|
+ //获得模板路径
|
|
|
+ String templateFilePath = fileUtils.getPath(reportTemplate.getTemplatePath());
|
|
|
//读取模板后保存生成word的地址
|
|
|
String fileName = IdUtil.simpleUUID() + ".docx";
|
|
|
String directoryName = fileUtils.createDirectory();
|
|
|
String outPath = fileUtils.getSavePath(directoryName) + fileName;
|
|
|
|
|
|
-
|
|
|
+ //根据ProjectId 获得报告
|
|
|
+ LambdaQueryWrapper<ReportProject> queryWrapper =new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper.eq(ReportProject::getProjectId,projectId);
|
|
|
+ ReportProject report =reportProjectService.getOne(queryWrapper,false);
|
|
|
+if(report==null){
|
|
|
+ throw new XiaoShiException("报告不存在");
|
|
|
+}
|
|
|
XWPFTemplate template = null;
|
|
|
template = this.avoidDesignTemplate(projectId);
|
|
|
-// if (report.getReportType() == 0 || report.getReportType() == 2) {
|
|
|
+ if (report.getReportType() == 0 || report.getReportType() == 2) {
|
|
|
// template = this.getstabilityTemplate(report, filePath);
|
|
|
-// } else if (report.getReportType() == 3) {
|
|
|
+ } else if (report.getReportType() == 3) {
|
|
|
// template = this.FTOtemplate(reportId, filePath, templeId);
|
|
|
-// } else if (report.getReportType() == 4) {
|
|
|
+ } else if (report.getReportType() == 4) {
|
|
|
// template = this.Torttemplate(reportId, filePath, templeId);
|
|
|
-// } else if (report.getReportType() == 5) {
|
|
|
+ } else if (report.getReportType() == 5) {
|
|
|
// template = this.avoidDesignTemplate(reportId, filePath);
|
|
|
-// } else if (report.getReportType() == 1) {
|
|
|
+ } else if (report.getReportType() == 1) {
|
|
|
// template = this.getThirdTemplate(report, filePath);
|
|
|
-// }
|
|
|
+ }
|
|
|
// 读取模板、数据并渲染
|
|
|
// 文件是否已存在,则删除
|
|
|
File file = new File(outPath);
|
|
@@ -330,4 +342,135 @@ public class ReportExportService {
|
|
|
});
|
|
|
return rights;
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param reportId
|
|
|
+ * @param filePath
|
|
|
+ * @return
|
|
|
+ * @description 装载FTO模板
|
|
|
+ */
|
|
|
+ private XWPFTemplate FTOTemplate(Integer reportId, String filePath, Integer templateId) throws IOException {
|
|
|
+ //根据报告ID获得自定义字段值的信息
|
|
|
+// List<Map<String, Object>> fieldMaps = reportFieldService.getFieldsMap(reportId);
|
|
|
+// //获得模板的配置信息
|
|
|
+// LambdaQueryWrapper<TemplateConfig> templateConfigWrapper = new LambdaQueryWrapper<TemplateConfig>();
|
|
|
+// templateConfigWrapper.eq(TemplateConfig::getTemplateId, templateId);
|
|
|
+// List<TemplateConfig> templateConfigs = templateConfigService.list(templateConfigWrapper);
|
|
|
+// List<Map<String, Object>> loadMaps = new ArrayList<>();
|
|
|
+// //根据配置信息装载
|
|
|
+// for (TemplateConfig item : templateConfigs) {
|
|
|
+// for (Map<String, Object> map : fieldMaps) {
|
|
|
+// //如果自定义字段的值映射到配置则装载
|
|
|
+// if (map.get("CName").toString().equals(item.getValueName())) {
|
|
|
+// //装载
|
|
|
+// map.put("CName", item.getMapName());
|
|
|
+// map.put("order", item.getOrderNum());
|
|
|
+// loadMaps.add(map);
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+// //
|
|
|
+// List<Map<String, Object>> classifyMaps = new ArrayList<>();
|
|
|
+// //装载信息
|
|
|
+// for (Map<String, Object> map : loadMaps) {
|
|
|
+// Map<String, Object> classifyMap = new HashMap<>();
|
|
|
+// classifyMap.put("classify", map.get("CName"));
|
|
|
+// //根据自定义字段ID和值Id查询专利号
|
|
|
+// List<String> patentNos = reportFieldPatentLinkService.getPatentNos(Integer.parseInt(map.get("FId").toString()), Integer.parseInt(map.get("CId").toString()));
|
|
|
+// PatentVO patentVO = new PatentVO();
|
|
|
+// patentVO.setPatentNos(patentNos);
|
|
|
+// //根据专利号查询专利详细信息
|
|
|
+// String resBody = outInterfaceService.getPatentDTOListForRMS(patentVO);
|
|
|
+// JSONObject jsonObject = JSONObject.parseObject(resBody);
|
|
|
+// List<JSONObject> patentDTOS = JSON.parseArray(jsonObject.get("data").toString(), JSONObject.class);
|
|
|
+// //根据专利号和报告Id获得对比记录
|
|
|
+// //存放公告专利
|
|
|
+// List<Map<String, Object>> announcePatents = new ArrayList<>();
|
|
|
+// //存放公开专利
|
|
|
+// List<Map<String, Object>> publicPatents = new ArrayList<>();
|
|
|
+// //存放失效专利信息
|
|
|
+// List<Map<String, Object>> lapsePatents = new ArrayList<>();
|
|
|
+// for (JSONObject patent : patentDTOS) {
|
|
|
+// List<JSONObject> applicantJSONs = JSON.parseArray(patent.get("applicant").toString(), JSONObject.class);
|
|
|
+// StringBuilder applicants = new StringBuilder();
|
|
|
+// StringBuilder rightPerson = new StringBuilder();
|
|
|
+// applicantJSONs.forEach(tem -> {
|
|
|
+// if (Integer.parseInt(tem.get("dataType").toString()) == 1) {
|
|
|
+// applicants.append(tem.get("name") + "\r");
|
|
|
+// } else {
|
|
|
+// rightPerson.append(tem.get("name") + "\r");
|
|
|
+// }
|
|
|
+// });
|
|
|
+// //装载同族信息
|
|
|
+// JSONObject familys = JSONObject.parseObject(patent.get("family").toString());
|
|
|
+// List<String> patSnaps = JSON.parseArray(familys.get("patSnap").toString(), String.class);
|
|
|
+// List<String> simples = JSON.parseArray(familys.get("simple").toString(), String.class);
|
|
|
+// List<String> inpadocs = JSON.parseArray(familys.get("inpadoc").toString(), String.class);
|
|
|
+// patSnaps.addAll(simples);
|
|
|
+// patSnaps.addAll(inpadocs);
|
|
|
+// String familyStr = StringUtils.join(patSnaps, ",");
|
|
|
+// //装载法律状态
|
|
|
+// StringBuilder affair = new StringBuilder();
|
|
|
+// List<JSONObject> affaires = JSON.parseArray(patent.get("affair").toString(), JSONObject.class);
|
|
|
+// affaires.forEach(item -> {
|
|
|
+// affair.append(item.get("status") + "\r");
|
|
|
+// }
|
|
|
+//
|
|
|
+// );
|
|
|
+// //装载单个专利的信息
|
|
|
+// Map<String, Object> patentMap = new HashMap<>();
|
|
|
+// //同族专利
|
|
|
+// patentMap.put("simpleFamilys", familyStr);
|
|
|
+// //引用专利
|
|
|
+// patentMap.put("quotePatents", patent.get("quote"));
|
|
|
+// //申请日
|
|
|
+// patentMap.put("applicationDate", patent.get("applicationDate"));
|
|
|
+// //公开日
|
|
|
+// patentMap.put("publicDate", patent.get("publicDate"));
|
|
|
+// //专利号
|
|
|
+// patentMap.put("publicNo", patent.get("publicNo"));
|
|
|
+// patentMap.put("firstPublicDate", patent.get("firstPublicDate"));
|
|
|
+// patentMap.put("applicant", applicants);
|
|
|
+// patentMap.put("rightPerson", rightPerson);
|
|
|
+// patentMap.put("affair", affair);
|
|
|
+// //优先权日
|
|
|
+// patentMap.put("priorityDate", patent.get("priorityDate"));
|
|
|
+// //图示
|
|
|
+// patentMap.put("abstractPath", "http://139.224.24.90:8081" + patent.get("abstractPath"));
|
|
|
+// //获得专利对比记录的信息
|
|
|
+// Map<String, Object> temMap = compareMessageService.queryforTemplate(patent.get("patentNo").toString(), reportId);
|
|
|
+// List<CompareMessageVO> compareMessageVOS = (List<CompareMessageVO>) temMap.get("compareMessageVOs");
|
|
|
+// //装载对比记录的信息
|
|
|
+// patentMap.put("cM", compareMessageVOS);
|
|
|
+// patentMap.put("rightNum", temMap.get("right"));
|
|
|
+// patentMap.put("mainRightNum", temMap.get("mainRight"));
|
|
|
+// Integer status = Integer.parseInt(patent.get("simpleStatusInt").toString());
|
|
|
+// if (status == 1 || status == 5 || status == 6) {
|
|
|
+// announcePatents.add(patentMap);
|
|
|
+// } else if (status == 2) {
|
|
|
+// lapsePatents.add(patentMap);
|
|
|
+// } else if (status == 3) {
|
|
|
+// publicPatents.add(patentMap);
|
|
|
+// }
|
|
|
+// classifyMap.put("publicPatents", publicPatents);
|
|
|
+// classifyMap.put("lapsePatents", lapsePatents);
|
|
|
+// classifyMap.put("announcePatents", announcePatents);
|
|
|
+// }
|
|
|
+// classifyMaps.add(classifyMap);
|
|
|
+// }
|
|
|
+// Map<String, Object> map = new HashMap<>();
|
|
|
+// 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("classifys", classifyMaps);
|
|
|
+// // 为表格的显示绑定行循环
|
|
|
+// LoopRowTableRenderPolicy policy = new LoopRowTableRenderPolicy();
|
|
|
+// 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);
|
|
|
+// return template;
|
|
|
+ return null;
|
|
|
+ }
|
|
|
}
|