|
@@ -1,24 +1,37 @@
|
|
|
package cn.cslg.pas.service;
|
|
|
|
|
|
+import cn.cslg.pas.common.dto.PatentDetailDTO;
|
|
|
import cn.cslg.pas.common.model.SystemMO;
|
|
|
import cn.cslg.pas.common.utils.DateUtils;
|
|
|
import cn.cslg.pas.common.utils.FileUtils;
|
|
|
-import cn.cslg.pas.domain.business.Project;
|
|
|
+import cn.cslg.pas.common.utils.FormatUtil;
|
|
|
+import cn.cslg.pas.common.utils.PatentRightUtils;
|
|
|
+import cn.cslg.pas.common.vo.AvoidFeaturesVO;
|
|
|
+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.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.TempleService;
|
|
|
+import cn.cslg.pas.service.business.es.EsPatentService;
|
|
|
import cn.cslg.pas.service.common.FileManagerService;
|
|
|
import cn.hutool.core.util.IdUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.deepoove.poi.XWPFTemplate;
|
|
|
import com.deepoove.poi.config.Configure;
|
|
|
+import com.deepoove.poi.data.PictureRenderData;
|
|
|
import com.deepoove.poi.data.PictureType;
|
|
|
import com.deepoove.poi.data.Pictures;
|
|
|
import com.deepoove.poi.plugin.table.LoopRowTableRenderPolicy;
|
|
|
-import org.apache.commons.lang3.StringUtils;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.poi.ss.usermodel.PictureData;
|
|
|
import org.ddr.poi.html.HtmlRenderPolicy;
|
|
|
+import org.joda.time.format.FormatUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
@@ -26,7 +39,9 @@ import java.io.File;
|
|
|
import java.io.FileInputStream;
|
|
|
import java.io.IOException;
|
|
|
import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
+@Slf4j
|
|
|
@Service
|
|
|
public class ReportExportService {
|
|
|
@Autowired
|
|
@@ -37,15 +52,18 @@ public class ReportExportService {
|
|
|
private ReportProjectService reportProjectService;
|
|
|
@Autowired
|
|
|
private FileManagerService fileManagerService;
|
|
|
-
|
|
|
+ @Autowired
|
|
|
+ private EsPatentService esPatentService;
|
|
|
+ @Autowired
|
|
|
+ private AvoidDesignMapper avoidDesignMapper;
|
|
|
/**
|
|
|
- * @param reportId
|
|
|
+ * @param projectId
|
|
|
* @param templeId
|
|
|
* @return
|
|
|
* @throws IOException
|
|
|
* @function: 导出报告
|
|
|
*/
|
|
|
- public String exportReport(Integer reportId, Integer templeId) throws IOException {
|
|
|
+ public String exportReport(Integer projectId, Integer templeId) throws IOException {
|
|
|
//根据模板ID获得模板
|
|
|
// ReportTemple reportTemplate = templeService.getById(templeId);
|
|
|
// //获得模板路径
|
|
@@ -55,9 +73,9 @@ public class ReportExportService {
|
|
|
String directoryName = fileUtils.createDirectory();
|
|
|
String outPath = fileUtils.getSavePath(directoryName) + fileName;
|
|
|
|
|
|
- ReportProject report = reportProjectService.getById(reportId);
|
|
|
+
|
|
|
XWPFTemplate template = null;
|
|
|
- template = this.avoidDesignTemplate(1);
|
|
|
+ template = this.avoidDesignTemplate(projectId);
|
|
|
// if (report.getReportType() == 0 || report.getReportType() == 2) {
|
|
|
// template = this.getstabilityTemplate(report, filePath);
|
|
|
// } else if (report.getReportType() == 3) {
|
|
@@ -172,36 +190,39 @@ public class ReportExportService {
|
|
|
// return template;
|
|
|
// }
|
|
|
|
|
|
- private XWPFTemplate avoidDesignTemplate(Integer reportId) throws IOException {
|
|
|
+ private XWPFTemplate avoidDesignTemplate(Integer projectId) throws IOException {
|
|
|
String filePath = fileUtils.getPath("/11.docx");
|
|
|
|
|
|
-// log.info("开始处理导出规避设计报告,参数为:{}, {}", reportId, filePath);
|
|
|
-// Report report = reportService.getById(reportId);
|
|
|
-// String signPatentNo = report.getSignPatentNo();
|
|
|
-//
|
|
|
-// //装载标的专利信息
|
|
|
-// Map<String, Object> signPatent = this.signPantentMess(report.getSignPatentNo());
|
|
|
-// System.out.println(signPatent.get(""));
|
|
|
-// Map<String, Object> map = new HashMap<>();
|
|
|
-// //装载标的专利信息
|
|
|
-// map.put("signPatent", signPatent);
|
|
|
-// map.put("rights", signPatent.get("rights"));
|
|
|
-// //装载公开/公告号
|
|
|
-// map.put("pantentNo", signPatentNo);
|
|
|
-//
|
|
|
-// //装载年月日
|
|
|
-// String date = DateUtils.formatDate(new Date(), DateUtils.YYYY_MM_DD);
|
|
|
-// String[] dates = date.split("-");
|
|
|
-// SystemMO systemMO = new SystemMO()
|
|
|
-// .setYear(dates[0])
|
|
|
-// .setMonth(dates[1])
|
|
|
-// .setDay(dates[2]);
|
|
|
-// map.put("sys", systemMO);
|
|
|
+ log.info("开始处理导出规避设计报告,参数为:{}, {}", projectId, filePath);
|
|
|
+ LambdaQueryWrapper<ReportProject> queryWrapper= new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper.eq(ReportProject::getProjectId,projectId);
|
|
|
+
|
|
|
+ ReportProject report = reportProjectService.getOne(queryWrapper,false);
|
|
|
+ String signPatentNo = report.getSignPatentNo();
|
|
|
+
|
|
|
+ //装载标的专利信息
|
|
|
+ Map<String, Object> signPatent = this.signPatentMess(report.getSignPatentNo());
|
|
|
+ System.out.println(signPatent.get(""));
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ //装载标的专利信息
|
|
|
+ map.put("signPatent", signPatent);
|
|
|
+ map.put("rights", signPatent.get("rights"));
|
|
|
+ //装载公开/公告号
|
|
|
+ map.put("patentNo", signPatentNo);
|
|
|
+
|
|
|
+ //装载年月日
|
|
|
+ String date = DateUtils.formatDate(new Date(), DateUtils.YYYY_MM_DD);
|
|
|
+ String[] dates = date.split("-");
|
|
|
+ SystemMO systemMO = new SystemMO()
|
|
|
+ .setYear(dates[0])
|
|
|
+ .setMonth(dates[1])
|
|
|
+ .setDay(dates[2]);
|
|
|
+ map.put("sys", systemMO);
|
|
|
//
|
|
|
-// //装载特征、解释、回避设计方向、回避设计总体方向
|
|
|
-// List<AvoidFeaturesVO> features = avoidDesignLittleDirectionMapper.selectWholeByReportId(reportId);
|
|
|
+ //装载特征、解释、回避设计方向、回避设计总体方向
|
|
|
+ List<AvoidFeaturesVO> features = avoidDesignMapper.selectAvoidDesign(projectId);
|
|
|
// String wholeDirection = avoidDesignWholeDirectionMapper.selectWholeDirectionByReportId(reportId);
|
|
|
-// map.put("features", features);
|
|
|
+ map.put("features", features);
|
|
|
// map.put("wholeDirection", wholeDirection);
|
|
|
//
|
|
|
//绑定政策(绑定集合和元素循环遍历)
|
|
@@ -209,21 +230,104 @@ public class ReportExportService {
|
|
|
//把指定元素内容识别传输成html格式
|
|
|
HtmlRenderPolicy htmlRenderPolicy = new HtmlRenderPolicy();
|
|
|
Configure configure = Configure.builder()
|
|
|
-// .bind("signPatent.rights", policy)
|
|
|
-// .bind("features", policy)
|
|
|
-// .bind("explainText", htmlRenderPolicy)
|
|
|
-// .bind("littleDirection", htmlRenderPolicy)
|
|
|
-// .bind("wholeDirection", htmlRenderPolicy)
|
|
|
+ .bind("signPatent.rights", policy)
|
|
|
+ .bind("features", policy)
|
|
|
+ .bind("explainText", htmlRenderPolicy)
|
|
|
+ .bind("littleDirection", htmlRenderPolicy)
|
|
|
+ .bind("wholeDirection", htmlRenderPolicy)
|
|
|
.build();
|
|
|
- Map<String, Object> map = new HashMap<>();
|
|
|
- byte[] bytes = fileManagerService.downloadSystemFileFromFMS("CN202022791374.3_p");
|
|
|
-
|
|
|
-
|
|
|
- FileInputStream fileInputStream = FileUtils.byteToFile(bytes, "aa.png");
|
|
|
- map.put("p", Pictures.ofStream(fileInputStream, PictureType.PNG)
|
|
|
- .create());
|
|
|
- map.put("a", "张");
|
|
|
XWPFTemplate template = XWPFTemplate.compile(filePath, configure).render(map);
|
|
|
return template;
|
|
|
}
|
|
|
+
|
|
|
+ public Map<String, Object> signPatentMess(String patentNo) throws IOException {
|
|
|
+// PatentNoVO patentVO = new PatentNoVO();
|
|
|
+// patentVO.setPatentNo(patentNo);
|
|
|
+// //根据专利号查询专利详细信息
|
|
|
+// PatentDetailDTO patentDetailDTO = esPatentService.selectPatentDetail(patentVO);
|
|
|
+// //装载单个专利的信息
|
|
|
+ Map<String, Object> patentMap = new HashMap<>();
|
|
|
+// StringBuilder applicants = new StringBuilder();
|
|
|
+// StringBuilder rightPerson = new StringBuilder();
|
|
|
+//
|
|
|
+// //申请日
|
|
|
+// patentMap.put("applicationDate", patentDetailDTO.getAppDate());
|
|
|
+//
|
|
|
+// //公开日
|
|
|
+// patentMap.put("publicDate", patentDetailDTO.getPublicDate());
|
|
|
+// //公开号
|
|
|
+// patentMap.put("publicNo", patentDetailDTO.getPublicNo());
|
|
|
+// //专利号
|
|
|
+// patentMap.put("patentNo", patentDetailDTO.getPatentNo());
|
|
|
+// //专利权人
|
|
|
+// patentMap.put("rightPerson", rightPerson);
|
|
|
+// //图示
|
|
|
+// String guid = FormatUtil.getPictureFormat(patentDetailDTO.getAppNo());
|
|
|
+// PictureRenderData pictureData = this.guidToStream(guid);
|
|
|
+// if (pictureData != null) {
|
|
|
+// patentMap.put("abstractPath", pictureData);
|
|
|
+// }
|
|
|
+// //获得标题
|
|
|
+// if (patentDetailDTO.getTitle() != null && patentDetailDTO.getTitle().size() > 0) {
|
|
|
+// Text title = patentDetailDTO.getTitle().stream()
|
|
|
+// .filter(item -> item.getIfOrigin().equals(true)).findFirst().orElse(null);
|
|
|
+// if (title != null) {
|
|
|
+// patentMap.put("name", title.getTextContent());
|
|
|
+// }
|
|
|
+// }
|
|
|
+//
|
|
|
+// //获得权要
|
|
|
+// List<Map<String, Object>> rights= this.getClaimMaps(patentDetailDTO.getClaim(),patentDetailDTO.getPatentNo());
|
|
|
+//
|
|
|
+// patentMap.put("rights", rights);
|
|
|
+ return patentMap;
|
|
|
+ }
|
|
|
+
|
|
|
+ private PictureRenderData guidToStream(String guid) {
|
|
|
+ PictureRenderData pictureRenderData = null;
|
|
|
+
|
|
|
+ byte[] bytes = null;
|
|
|
+
|
|
|
+ if (bytes != null) {
|
|
|
+ try {
|
|
|
+ bytes = fileManagerService.downloadSystemFileFromFMS(guid);
|
|
|
+ } catch (Exception e) {
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ FileInputStream fileInputStream = FileUtils.byteToFile(bytes);
|
|
|
+ pictureRenderData = Pictures.ofStream(fileInputStream, PictureType.PNG)
|
|
|
+ .create();
|
|
|
+
|
|
|
+ return pictureRenderData;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private List<Map<String, Object>> getClaimMaps(List<Text> claims, String patentNo) {
|
|
|
+ List<Map<String, Object>> rights = new ArrayList<>();
|
|
|
+ if (claims == null || claims.size() == 0) {
|
|
|
+ return rights;
|
|
|
+
|
|
|
+ }
|
|
|
+ Text claim = claims.stream().filter(item -> item.getIfOrigin().equals(true)).findFirst().orElse(null);
|
|
|
+ if (claim == null) {
|
|
|
+ return rights;
|
|
|
+ }
|
|
|
+ PatentRightParams params = new PatentRightParams();
|
|
|
+ params.setContent(claim.getTextContent());
|
|
|
+ params.setPatentNo(patentNo);
|
|
|
+
|
|
|
+ List<RePatentClaim> patentRights = PatentRightUtils.formatPatentRight(params);
|
|
|
+ //给权要进行格式更改
|
|
|
+ patentRights.forEach(item -> {
|
|
|
+ Map<String, Object> temMap = new HashMap<>();
|
|
|
+ temMap.put("rightName", "权" + (item.getSort() + 1));
|
|
|
+ temMap.put("content", item.getContent());
|
|
|
+ temMap.put("rightNameLong", "权利要求" + (item.getSort() + 1));
|
|
|
+ temMap.put("parentSort", item.getParentSort());
|
|
|
+ temMap.put("sort", item.getSort());
|
|
|
+ rights.add(temMap);
|
|
|
+ });
|
|
|
+ return rights;
|
|
|
+ }
|
|
|
}
|