PatentController.java 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  1. package cn.cslg.pas.controller;
  2. import cn.cslg.pas.common.core.base.Constants;
  3. import cn.cslg.pas.common.dto.*;
  4. import cn.cslg.pas.common.dto.PatentExport.PatentExportParams;
  5. import cn.cslg.pas.common.dto.PatentExport.TaskParams;
  6. import cn.cslg.pas.common.dto.business.EsCountDTO;
  7. import cn.cslg.pas.common.dto.business.SelectClaimDTO;
  8. import cn.cslg.pas.common.model.cronModel.Records;
  9. import cn.cslg.pas.common.model.request.StringRequest;
  10. import cn.cslg.pas.common.utils.*;
  11. import cn.cslg.pas.common.utils.Response;
  12. import cn.cslg.pas.common.vo.business.*;
  13. import cn.cslg.pas.common.vo.PatentWithIdVO;
  14. import cn.cslg.pas.common.vo.StarPatentVO;
  15. import cn.cslg.pas.common.vo.business.EsAllCountVO;
  16. import cn.cslg.pas.common.vo.business.PatentKinVO;
  17. import cn.cslg.pas.common.vo.business.PatentNoVO;
  18. import cn.cslg.pas.common.vo.es.EsCustomFieldBatchVO;
  19. import cn.cslg.pas.factorys.businessFactory.Business;
  20. import cn.cslg.pas.factorys.businessFactory.BusinessFactory;
  21. import cn.cslg.pas.service.business.PDFExportFirstPageService;
  22. import cn.cslg.pas.service.business.PatentExportService;
  23. import cn.cslg.pas.service.business.MergePersonService;
  24. import cn.cslg.pas.service.business.es.EsCountService;
  25. import cn.cslg.pas.service.business.es.EsPatentService;
  26. import cn.cslg.pas.service.business.es.EsService;
  27. import cn.cslg.pas.service.common.FileManagerService;
  28. import cn.cslg.pas.service.common.PatentStarApiService;
  29. import cn.hutool.core.util.IdUtil;
  30. import io.swagger.v3.oas.annotations.Operation;
  31. import org.springframework.beans.factory.annotation.Autowired;
  32. import org.springframework.core.io.InputStreamResource;
  33. import org.springframework.http.HttpHeaders;
  34. import org.springframework.http.MediaType;
  35. import org.springframework.http.ResponseEntity;
  36. import org.springframework.scheduling.annotation.Async;
  37. import org.springframework.web.bind.annotation.*;
  38. import java.io.ByteArrayInputStream;
  39. import java.io.IOException;
  40. import java.net.URLEncoder;
  41. import java.nio.charset.StandardCharsets;
  42. import java.util.List;
  43. @RequestMapping(Constants.API_XiaoSHI + "/patent")
  44. @RestController
  45. public class PatentController {
  46. @Autowired
  47. private BusinessFactory businessFactory;
  48. @Autowired
  49. private EsCountService esCountService;
  50. @Autowired
  51. private EsPatentService patentService;
  52. @Autowired
  53. private MergePersonService mergePersonService;
  54. @Autowired
  55. private EsService esService;
  56. @Autowired
  57. private PatentStarApiService patentStarApiService;
  58. @Autowired
  59. private CacheUtils cacheUtils;
  60. @Autowired
  61. private PatentExportService patentExportService;
  62. @Autowired
  63. private PDFExportFirstPageService pdfExportFirstPageService;
  64. @Operation(summary = "查询专利")
  65. @PostMapping("/queryPatent")
  66. public Response queryPatent(@RequestBody StringRequest stringRequest) throws Exception {
  67. Business business = businessFactory.getClass("patentService");
  68. Records records = (Records) business.queryMessage(stringRequest);
  69. return Response.success(records);
  70. }
  71. @Operation(summary = "查询专利详情")
  72. @PostMapping("/selectPatentDetail")
  73. public Response selectPatentDetail(@RequestBody PatentNoVO vo) throws Exception {
  74. PatentColumnDTO dto = patentService.selectPatentDetail(vo);
  75. return Response.success(dto);
  76. }
  77. @GetMapping("/getTextPdf")
  78. @Operation(summary = "获得中国专利pdf全文")
  79. public Response getTextPdf(String appNo) throws IOException {
  80. List<InnerPatentPdfDTO> pdfDTOS = patentService.getTextPdf(appNo);
  81. return Response.success(pdfDTOS);
  82. }
  83. @GetMapping("/getFigure")
  84. @Operation(summary = "内部获取附图")
  85. public Response getFigure(String appNo) throws IOException {
  86. List<String> figures = patentService.getFigure(appNo);
  87. return Response.success(figures);
  88. }
  89. @Operation(summary = "根据专利号查询同族")
  90. @PostMapping("/selectKinByPatentNo")
  91. public Response selectKinByPatentNo(@RequestBody PatentKinVO vo) throws Exception {
  92. List<PatentKinDTO> dto = patentService.selectKinByPatentNo(vo);
  93. return Response.success(dto);
  94. }
  95. @Operation(summary = "查询分页信息")
  96. @PostMapping("/getPatentPageMessage")
  97. public Response getPatentPageMessage(@RequestBody StringRequest stringRequest) throws Exception {
  98. Records records = patentService.getPatentPageMessage(stringRequest);
  99. return Response.success(records);
  100. }
  101. @Operation(summary = "专利的聚合统计")
  102. @PostMapping("/esCountAnalysis")
  103. public Response esCountAnalysis(@RequestBody EsAllCountVO countVO) throws Exception {
  104. EsCountDTO dto = esCountService.esCountAnalysis(countVO);
  105. return Response.success(dto);
  106. }
  107. @Operation(summary = "根据专利号查询内部专利")
  108. @GetMapping("/queryPatentByNo")
  109. public Response queryPatentByNo(String patentNo) throws Exception {
  110. PatentWithIdVO patentWithIdVO = esService.getIdByPatentNo(patentNo);
  111. if (patentWithIdVO == null) {
  112. return Response.success(null);
  113. }
  114. return Response.success(patentWithIdVO.getPatent());
  115. }
  116. @Operation(summary = "根据专利号查询内部专利")
  117. @GetMapping("/queryPatentByNoFromWeb")
  118. public Response queryPatentByNoFromWeb(String patentNo) throws Exception {
  119. StarPatentVO starPatentVO = patentStarApiService.getPatentByNo(patentNo);
  120. if (starPatentVO == null) {
  121. return Response.success(null);
  122. }
  123. return Response.success(starPatentVO);
  124. }
  125. @Operation(summary = "根据专利号查询内部权利要求")
  126. @GetMapping("/queryClaimByPatentNo")
  127. public Response queryClaimByPatentNo(String patentNo) throws Exception {
  128. SelectClaimDTO dto = esService.selectClaim(patentNo);
  129. return Response.success(dto);
  130. }
  131. //------------------------合并-----------------------------
  132. @Operation(summary = "专利列表上新增发明人/权利人/申请人合并")
  133. @PostMapping("/mergePerson")
  134. public Response mergePerson(@RequestBody MergePersonVO personVO) throws Exception {
  135. Integer personId = mergePersonService.mergePerson(personVO);
  136. return Response.success(personId);
  137. }
  138. @Operation(summary = "专利列表上再次新增发明人/权利人/申请人合并")
  139. @PostMapping("/mergePersonAgain")
  140. public Response mergePersonAgain(@RequestBody MergePersonAgainVO againVO) throws Exception {
  141. Integer personId = mergePersonService.mergePersonAgain(againVO);
  142. return Response.success(personId);
  143. }
  144. @Operation(summary = "专利列表上编辑发明人/权利人/申请人合并")
  145. @PostMapping("/updateMergePerson")
  146. public Response updateMergePerson(@RequestBody MergePersonVO personVO) throws Exception{
  147. Integer personId = mergePersonService.updateMergePerson(personVO);
  148. return Response.success(personId);
  149. }
  150. @Operation(summary = "发明人/权利人/申请人合并列表查询")
  151. @PostMapping("/selectMergePerson")
  152. public Response selectMergePerson(@RequestBody MergePersonQueryVO vo) {
  153. Records records = mergePersonService.selectMergePersonList(vo);
  154. return Response.success(records);
  155. }
  156. @Operation(summary = "合并人员详情")
  157. @PostMapping("/selectMergePersonDetail")
  158. public Response selectMergePersonDetail(@RequestBody MergePersonIdVO vo) {
  159. MergePersonQueryDTO dto = mergePersonService.selectMergePersonDetail(vo);
  160. return Response.success(dto);
  161. }
  162. @Operation(summary = "获取所有发明人/权利人/申请人")
  163. @PostMapping("/getMergePerson")
  164. public Response getMergePerson(@RequestBody GetAllPersonVO vo) throws Exception {
  165. Records records = mergePersonService.getMergePerson(vo);
  166. return Response.success(records);
  167. }
  168. @Operation(summary = "发明人/权利人/申请人合并后的名称移除")
  169. @PostMapping("/delMergedName")
  170. public Response delMergedName(@RequestBody MergedNameVO vo) throws Exception {
  171. Integer id = mergePersonService.delMergedName(vo);
  172. return Response.success(id);
  173. }
  174. @Operation(summary = "发明人/权利人/申请人合并记录删除")
  175. @PostMapping("/delMergePerson")
  176. public Response delMergePerson(@RequestBody MergePersonIdVO vo) throws Exception {
  177. Integer id = mergePersonService.delMergePerson(vo);
  178. return Response.success(id);
  179. }
  180. //-------------------------------获取所有国家-----------------
  181. @Operation(summary = "获取所有国家列表查询")
  182. @GetMapping("/getAllCountry")
  183. public Response getAllCountry() {
  184. List<GetAllCountryDTO> allCountry = mergePersonService.getAllCountry();
  185. return Response.success(allCountry);
  186. }
  187. //--------------------导出-----------------------
  188. @PostMapping("/exportPDFFirstPage")
  189. @Operation(summary = "导出专利PDF")
  190. public ResponseEntity<InputStreamResource> exportPDFFirstPage(@RequestBody EsCustomFieldBatchVO EsVO) throws IOException {
  191. byte[] fileData = pdfExportFirstPageService.mergePdfFirstPage(EsVO);
  192. //保存生成excel的地址
  193. String fileName = IdUtil.simpleUUID() + ".pdf";
  194. //文件原始名中的中文字符可能会乱码,对文件名进行URL编码
  195. String encodedFileName = URLEncoder.encode(fileName, StandardCharsets.UTF_8.toString());
  196. return ResponseEntity.ok().contentLength(fileData.length)
  197. .header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + encodedFileName + "\"")
  198. .contentType(MediaType.parseMediaType("application/octet-stream"))
  199. .body(new InputStreamResource(new ByteArrayInputStream(fileData)));
  200. }
  201. // @PostMapping("/exportPatentExcel")
  202. // @Operation(summary = "导出专利")
  203. // public ResponseEntity<InputStreamResource> export(@RequestBody EsCustomFieldBatchVO EsVO) throws IOException {
  204. // byte[] fileData = patentExportService.exportPatent(EsVO);
  205. // //保存生成excel的地址
  206. // String fileName = IdUtil.simpleUUID() + ".xls";
  207. // //文件原始名中的中文字符可能会乱码,对文件名进行URL编码
  208. // String encodedFileName = URLEncoder.encode(fileName, StandardCharsets.UTF_8.toString());
  209. // return ResponseEntity.ok().contentLength(fileData.length)
  210. // .header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + encodedFileName + "\"")
  211. // .contentType(MediaType.parseMediaType("application/octet-stream"))
  212. // .body(new InputStreamResource(new ByteArrayInputStream(fileData)));
  213. // }
  214. @PostMapping("/exportPatentExcel")
  215. @Operation(summary = "导出专利")
  216. public Response export(@RequestBody EsCustomFieldBatchVO EsVO) throws IOException {
  217. patentExportService.exportPatent(EsVO);
  218. Records records = new Records();
  219. records.setData("导出成功");
  220. return Response.success(records);
  221. }
  222. }