|
@@ -8,6 +8,10 @@ import cn.cslg.pas.common.model.cronModel.PersonnelVO;
|
|
|
import cn.cslg.pas.common.model.request.StringRequest;
|
|
|
import cn.cslg.pas.common.utils.*;
|
|
|
import cn.cslg.pas.common.vo.*;
|
|
|
+import cn.cslg.pas.common.vo.business.FTOCompareRecordVO;
|
|
|
+import cn.cslg.pas.common.vo.business.TortCompareRecordVO;
|
|
|
+import cn.cslg.pas.common.vo.business.TortRightVO;
|
|
|
+import cn.cslg.pas.common.vo.business.TortVO;
|
|
|
import cn.cslg.pas.domain.ReportDocument;
|
|
|
import cn.cslg.pas.domain.business.*;
|
|
|
import cn.cslg.pas.domain.es.Patent;
|
|
@@ -98,6 +102,8 @@ public class ReportExportService {
|
|
|
private CompareLiteratureService compareLiteratureService;
|
|
|
@Autowired
|
|
|
private EvidenceReasonService evidenceReasonService;
|
|
|
+ @Autowired
|
|
|
+ private TortCompareRecordService tortCompareRecordService;
|
|
|
|
|
|
/**
|
|
|
* @param projectId
|
|
@@ -106,11 +112,12 @@ public class ReportExportService {
|
|
|
* @throws IOException
|
|
|
* @function: 导出报告
|
|
|
*/
|
|
|
- public String exportReport(Integer projectId, Integer templeId) throws IOException {
|
|
|
+ public String exportReport(Integer projectId, Integer templeId) throws Exception {
|
|
|
//根据模板ID获得模板
|
|
|
ReportTemple reportTemplate = templeService.getById(templeId);
|
|
|
//获得模板路径
|
|
|
String templateFilePath = fileUtils.getPath(reportTemplate.getTemplatePath());
|
|
|
+
|
|
|
//读取模板后保存生成word的地址
|
|
|
String fileName = IdUtil.simpleUUID() + ".docx";
|
|
|
String directoryName = fileUtils.createDirectory();
|
|
@@ -135,20 +142,20 @@ public class ReportExportService {
|
|
|
} else if (report.getReportType() == 1) {
|
|
|
template = this.getThirdTemplate(projectId, templateFilePath);
|
|
|
}
|
|
|
+ if (template == null) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
// 读取模板、数据并渲染
|
|
|
// 文件是否已存在,则删除
|
|
|
File file = new File(outPath);
|
|
|
-
|
|
|
// 生成word保存在指定目录
|
|
|
template.writeToFile(outPath);
|
|
|
template.close();
|
|
|
//导出成功后,导出报告记录入库
|
|
|
-
|
|
|
List<String> ids = fileManagerService.uploadFileGetGuid2(Arrays.asList(file));
|
|
|
if (ids == null || ids.size() == 0) {
|
|
|
throw new XiaoShiException("保存记录失败");
|
|
|
}
|
|
|
-// PersonnelVO personnelVO = cacheUtils.getLoginUser(loginUtils.getId());
|
|
|
PersonnelVO personnelVO = new PersonnelVO();
|
|
|
personnelVO.setId("1");
|
|
|
ReportDocument reportDocument = new ReportDocument();
|
|
@@ -166,88 +173,155 @@ public class ReportExportService {
|
|
|
}
|
|
|
|
|
|
|
|
|
- private XWPFTemplate Torttemplate(Integer reportId, String filePath) throws IOException {
|
|
|
+ private XWPFTemplate Torttemplate(Integer reportId, String filePath) throws Exception {
|
|
|
//根据报告Id查询标的专利号
|
|
|
LambdaQueryWrapper<ReportProject> projectLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
projectLambdaQueryWrapper.eq(ReportProject::getProjectId, reportId);
|
|
|
ReportProject report = reportProjectService.getOne(projectLambdaQueryWrapper, false);
|
|
|
String patentNo = report.getSignPatentNo();
|
|
|
-// PatentVO patentVO = new PatentVO();
|
|
|
-// patentVO.setPatentNos(Arrays.asList(patentNo));
|
|
|
-// //根据专利号查询专利详细信息
|
|
|
-// String resBody = outInterfaceService.getPatentDTOListForRMS(patentVO);
|
|
|
-// JSONObject jsonObject = JSONObject.parseObject(resBody);
|
|
|
-// List<JSONObject> patentDTOS = JSON.parseArray(jsonObject.get("data").toString(), JSONObject.class);
|
|
|
-// //装载单个专利的信息
|
|
|
+ List<Patent> patentList = esPatentService.getPatentsByNo(Arrays.asList(patentNo), true, null, null);
|
|
|
+
|
|
|
+ if (patentList == null || patentList.size() == 0) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ //装载单个专利的信息
|
|
|
Map<String, Object> patentMap = new HashMap<>();
|
|
|
-// JSONObject patent = patentDTOS.get(0);
|
|
|
-// 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");
|
|
|
-// }
|
|
|
-// );
|
|
|
-// //同族专利
|
|
|
-// 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("name", patent.get("name"));
|
|
|
+ Patent patent = patentList.get(0);
|
|
|
+ String applicants = "";
|
|
|
+ String rightPerson = "";
|
|
|
+ if (patent.getApplicant() != null && patent.getApplicant().size() != 0) {
|
|
|
+ List<String> names =patent.getApplicant().stream().map(PatentPerson::getName).collect(Collectors.toList());
|
|
|
+ applicants = StringUtils.join(names, "\n");
|
|
|
+ }
|
|
|
+ if (patent.getRightHolder() != null && patent.getRightHolder().size() != 0) {
|
|
|
+ List<String> names =patent.getRightHolder().stream().map(PatentPerson::getName).collect(Collectors.toList());
|
|
|
+
|
|
|
+ rightPerson = StringUtils.join(names, "\n");
|
|
|
+ }
|
|
|
+
|
|
|
+ //装载同族信息
|
|
|
+ List<Map<String, Object>> familyMaps = esFamilyService.getPatentFamilyByNos(Arrays.asList(patent.getPatentNo()), "simple");
|
|
|
+ if (familyMaps.size() <= 0) {
|
|
|
+ familyMaps = esFamilyService.getPatentFamilyByNos(Arrays.asList(patent.getPatentNo()), "inpadoc");
|
|
|
+ }
|
|
|
+ if (familyMaps != null && familyMaps.size() > 0) {
|
|
|
+ Map<String, Object> familyMap = familyMaps.get(0);
|
|
|
+ if (familyMap.get("nos") != null) {
|
|
|
+ List<String> nos = (List<String>) familyMap.get("nos");
|
|
|
+ if (nos != null && nos.size() > 0) {
|
|
|
+ String nosStr = StringUtils.join(nos, "\n");
|
|
|
+ patentMap.put("simpleFamilys", nosStr);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //装载引用专利
|
|
|
+ Map<String, Object> map = esQuotePatentService.getEsQutePatentByNos(patent.getPatentNo());
|
|
|
+ if (map.get("nos") != null) {
|
|
|
+ List<String> nos = (List<String>) map.get("nos");
|
|
|
+ if (nos != null && nos.size() > 0) {
|
|
|
+ String nosStr = StringUtils.join(nos, "\n");
|
|
|
+ patentMap.put("quotePatents", nosStr);
|
|
|
+ }
|
|
|
+
|
|
|
+ SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ if (patent.getGrantDate() != null) {
|
|
|
+ patentMap.put("publicDate",dateFormat.format(patent.getGrantDate()));
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ patentMap.put("publicDate",dateFormat.format(patent.getPublicDate()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (patent.getGrantNo() != null) {
|
|
|
+ patentMap.put("publicNo", patent.getGrantNo());
|
|
|
+ } else {
|
|
|
+ patentMap.put("publicNo", patent.getPublicNo());
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ patentMap.put("applicant", applicants);
|
|
|
+ patentMap.put("rightPerson", rightPerson);
|
|
|
+ if (patent.getTitle() != null && patent.getTitle().size() > 0) {
|
|
|
+ patentMap.put("name", patent.getTitle().get(0).getTextContent());
|
|
|
+ }
|
|
|
//图示
|
|
|
- patentMap.put("abstractPath", "");
|
|
|
+ String guid = FormatUtil.getPictureFormat(patent.getAppNo());
|
|
|
+ PictureRenderData pictureData = this.guidToStream(guid);
|
|
|
+
|
|
|
+ if (pictureData != null) {
|
|
|
+ patentMap.put("abstractPath", pictureData);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (patent.getPriorities() != null && patent.getPriorities().size() != 0) {
|
|
|
+ List<String> dates = patent.getPriorities().stream().map(Priorities::getPriorityDate).collect(Collectors.toList());
|
|
|
+ String nosStr = StringUtils.join(dates, ";");
|
|
|
+ patentMap.put("priorityDate", nosStr);
|
|
|
+ }
|
|
|
+
|
|
|
//获得专利对比记录的信息
|
|
|
-// Map<String, Object> temMap = compareMessageService.queryforTemplate(patent.get("patentNo").toString(), reportId);
|
|
|
-// List<CompareMessageVO> compareMessageVOS = (List<CompareMessageVO>) temMap.get("compareMessageVOs");
|
|
|
+ TortCompareRecordVO tortCompareRecordVO = tortCompareRecordService.getAllTortTaskResult(reportId, null, 1);
|
|
|
+ List<TortRightVO> tortRightVOS = tortCompareRecordVO.getTortRightVOS();
|
|
|
+
|
|
|
+ List<Map<String, Object>> tortMaps = new ArrayList<>();
|
|
|
+
|
|
|
+ Integer addI = 1;
|
|
|
+ if (tortRightVOS != null && tortRightVOS.size() > 0) {
|
|
|
+ addI =addI-tortRightVOS.get(0).getSort();
|
|
|
+ }
|
|
|
+
|
|
|
+ for (TortRightVO tortRightVO : tortRightVOS) {
|
|
|
+ Integer sort = tortRightVO.getSort();
|
|
|
+ List<TortVO> tortVOS = tortRightVO.getTortVOS();
|
|
|
+ for (TortVO tortVO : tortVOS) {
|
|
|
+ Map<String, Object> tortMap = new HashMap<>();
|
|
|
+ tortMap.put("rightName", "权要" + (sort + addI));
|
|
|
+ tortMap.put("content", tortVO.getContent());
|
|
|
+ tortMap.put("explainText", tortVO.getExplainText());
|
|
|
+ FTOCompareRecordVO ftoCompareRecordVO = tortVO.getFinalRecordVO();
|
|
|
+ if (ftoCompareRecordVO != null) {
|
|
|
+ tortMap.put("targetDescription", ftoCompareRecordVO.getTargetDescription());
|
|
|
+ Integer result = ftoCompareRecordVO.getCompareResult();
|
|
|
+ switch (result) {
|
|
|
+ case 0:
|
|
|
+ tortMap.put("resultStr", "字面相同");
|
|
|
+ break;
|
|
|
+ case 1:
|
|
|
+ tortMap.put("resultStr", "等同");
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ tortMap.put("resultStr", "不等同");
|
|
|
+ break;
|
|
|
+ case 3:
|
|
|
+ tortMap.put("resultStr", "确定");
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ tortMap.put("compareDescription", ftoCompareRecordVO.getCompareDescription());
|
|
|
+ }
|
|
|
+ tortMaps.add(tortMap);
|
|
|
+ }
|
|
|
+ }
|
|
|
//装载对比记录的信息
|
|
|
-// patentMap.put("cM", compareMessageVOS);
|
|
|
+ patentMap.put("cM", tortMaps);
|
|
|
// patentMap.put("rightNum", temMap.get("right"));
|
|
|
// patentMap.put("mainRightNum", temMap.get("mainRight"));
|
|
|
- Map<String, Object> map = new HashMap<>();
|
|
|
+ Map<String, Object> map1 = 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("patentMap", patentMap);
|
|
|
- map.put("", patentNo);
|
|
|
+ map1.put("sys", new SystemMO(ds[0], ds[1], ds[2], "", "reportName"));
|
|
|
+ map1.put("patentMap", patentMap);
|
|
|
+ map1.put("name",patentMap.get("name"));
|
|
|
// 为表格的显示绑定行循环
|
|
|
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);
|
|
|
+ Configure configure = Configure.builder().bind("cM", policy).bind("targetDescription", htmlRenderPolicy).bind("compareDescription",htmlRenderPolicy).build();
|
|
|
+ XWPFTemplate template = XWPFTemplate.compile(filePath, configure).render(map1);
|
|
|
return template;
|
|
|
}
|
|
|
|
|
|
private XWPFTemplate avoidDesignTemplate(Integer projectId, String path) throws IOException {
|
|
|
String filePath = fileUtils.getPath(path);
|
|
|
-
|
|
|
log.info("开始处理导出规避设计报告,参数为:{}, {}", projectId, filePath);
|
|
|
LambdaQueryWrapper<ReportProject> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
queryWrapper.eq(ReportProject::getProjectId, projectId);
|
|
@@ -255,10 +329,6 @@ public class ReportExportService {
|
|
|
ReportProject report = reportProjectService.getOne(queryWrapper, false);
|
|
|
String signPatentNo = report.getSignPatentNo();
|
|
|
|
|
|
- //装载标的专利信息
|
|
|
-
|
|
|
-
|
|
|
- ;
|
|
|
|
|
|
//装载年月日
|
|
|
String date = DateUtils.formatDate(new Date(), DateUtils.YYYY_MM_DD);
|
|
@@ -385,7 +455,6 @@ public class ReportExportService {
|
|
|
}
|
|
|
if (patent.getRightHolder() != null && patent.getRightHolder().size() != 0) {
|
|
|
rightPerson = StringUtils.join(patent.getRightHolder(), "\n");
|
|
|
- } else {
|
|
|
}
|
|
|
String affairStrs = "";
|
|
|
if (patent.getSimpleStatus() != null) {
|