PatentController.java 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  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.dto.es.EsDateRangeDTO;
  9. import cn.cslg.pas.common.model.cronModel.PersonnelVO;
  10. import cn.cslg.pas.common.model.cronModel.Records;
  11. import cn.cslg.pas.common.model.request.StringRequest;
  12. import cn.cslg.pas.common.utils.*;
  13. import cn.cslg.pas.common.utils.Response;
  14. import cn.cslg.pas.common.vo.business.*;
  15. import cn.cslg.pas.common.vo.PatentWithIdVO;
  16. import cn.cslg.pas.common.vo.StarPatentVO;
  17. import cn.cslg.pas.common.vo.business.EsAllCountVO;
  18. import cn.cslg.pas.common.vo.business.PatentKinVO;
  19. import cn.cslg.pas.common.vo.business.PatentNoVO;
  20. import cn.cslg.pas.common.vo.es.EsCustomFieldBatchVO;
  21. import cn.cslg.pas.common.vo.es.EsDateRangeVO;
  22. import cn.cslg.pas.common.vo.es.EsProductPatentVO;
  23. import cn.cslg.pas.domain.business.ImportTask;
  24. import cn.cslg.pas.exception.XiaoShiException;
  25. import cn.cslg.pas.factorys.businessFactory.Business;
  26. import cn.cslg.pas.factorys.businessFactory.BusinessFactory;
  27. import cn.cslg.pas.service.business.CustomAnalyseService;
  28. import cn.cslg.pas.service.business.ImportTaskService;
  29. import cn.cslg.pas.service.business.PDFExportFirstPageService;
  30. import cn.cslg.pas.service.business.PatentExportService;
  31. import cn.cslg.pas.service.business.MergePersonService;
  32. import cn.cslg.pas.service.business.es.EsCountService;
  33. import cn.cslg.pas.service.business.es.EsPatentService;
  34. import cn.cslg.pas.service.business.es.EsProductPatentService;
  35. import cn.cslg.pas.service.business.es.EsService;
  36. import cn.cslg.pas.service.common.FileManagerService;
  37. import cn.cslg.pas.service.common.PatentStarApiService;
  38. import cn.hutool.core.util.IdUtil;
  39. import io.swagger.v3.oas.annotations.Operation;
  40. import org.apache.commons.io.input.XmlStreamReaderException;
  41. import org.springframework.beans.factory.annotation.Autowired;
  42. import org.springframework.core.io.InputStreamResource;
  43. import org.springframework.http.HttpHeaders;
  44. import org.springframework.http.MediaType;
  45. import org.springframework.http.ResponseEntity;
  46. import org.springframework.scheduling.annotation.Async;
  47. import org.springframework.web.bind.annotation.*;
  48. import java.io.ByteArrayInputStream;
  49. import java.io.IOException;
  50. import java.net.URLEncoder;
  51. import java.nio.charset.StandardCharsets;
  52. import java.util.List;
  53. @RequestMapping(Constants.API_XiaoSHI + "/patent")
  54. @RestController
  55. public class PatentController {
  56. @Autowired
  57. private BusinessFactory businessFactory;
  58. @Autowired
  59. private EsCountService esCountService;
  60. @Autowired
  61. private EsPatentService patentService;
  62. @Autowired
  63. private MergePersonService mergePersonService;
  64. @Autowired
  65. private EsService esService;
  66. @Autowired
  67. private EsProductPatentService esProductPatentService;
  68. @Autowired
  69. private PatentStarApiService patentStarApiService;
  70. @Autowired
  71. private CacheUtils cacheUtils;
  72. @Autowired
  73. private PatentExportService patentExportService;
  74. @Autowired
  75. private PDFExportFirstPageService pdfExportFirstPageService;
  76. @Autowired
  77. private ImportTaskService importTaskService;
  78. @Autowired
  79. private LoginUtils loginUtils;
  80. @Operation(summary = "查询专利")
  81. @PostMapping("/queryPatent")
  82. public Response queryPatent(@RequestBody StringRequest stringRequest) throws Exception {
  83. Business business = businessFactory.getClass("patentService");
  84. Records records = (Records) business.queryMessage(stringRequest);
  85. return Response.success(records);
  86. }
  87. @Operation(summary = "查询专利详情")
  88. @PostMapping("/selectPatentDetail")
  89. public Response selectPatentDetail(@RequestBody PatentNoVO vo) throws Exception {
  90. PatentColumnDTO dto = patentService.selectPatentDetail(vo);
  91. return Response.success(dto);
  92. }
  93. @GetMapping("/getTextPdf")
  94. @Operation(summary = "获得中国专利pdf全文")
  95. public Response getTextPdf(String appNo) throws IOException {
  96. List<InnerPatentPdfDTO> pdfDTOS = patentService.getTextPdf(appNo);
  97. return Response.success(pdfDTOS);
  98. }
  99. @GetMapping("/getFigure")
  100. @Operation(summary = "内部获取附图")
  101. public Response getFigure(String appNo) throws IOException {
  102. List<String> figures = patentService.getFigure(appNo);
  103. return Response.success(figures);
  104. }
  105. @Operation(summary = "根据专利号查询同族")
  106. @PostMapping("/selectKinByPatentNo")
  107. public Response selectKinByPatentNo(@RequestBody PatentKinVO vo) throws Exception {
  108. List<PatentKinDTO> dto = patentService.selectKinByPatentNo(vo);
  109. return Response.success(dto);
  110. }
  111. @Operation(summary = "查询分页信息")
  112. @PostMapping("/getPatentPageMessage")
  113. public Response getPatentPageMessage(@RequestBody StringRequest stringRequest) throws Exception {
  114. Records records = patentService.getPatentPageMessage(stringRequest);
  115. return Response.success(records);
  116. }
  117. @Operation(summary = "根据专利号查询内部专利")
  118. @GetMapping("/queryPatentByNo")
  119. public Response queryPatentByNo(String patentNo) throws Exception {
  120. PatentWithIdVO patentWithIdVO = esService.getIdByPatentNo(patentNo);
  121. if (patentWithIdVO == null) {
  122. return Response.success(null);
  123. }
  124. return Response.success(patentWithIdVO.getPatent());
  125. }
  126. @Operation(summary = "根据专利号查询内部专利")
  127. @GetMapping("/queryPatentByNoFromWeb")
  128. public Response queryPatentByNoFromWeb(String patentNo) throws Exception {
  129. StarPatentVO starPatentVO = patentStarApiService.getPatentByNo(patentNo);
  130. if (starPatentVO == null) {
  131. return Response.success(null);
  132. }
  133. return Response.success(starPatentVO);
  134. }
  135. @Operation(summary = "根据专利号查询内部权利要求")
  136. @GetMapping("/queryClaimByPatentNo")
  137. public Response queryClaimByPatentNo(String patentNo) throws Exception {
  138. SelectClaimDTO dto = esService.selectClaim(patentNo);
  139. return Response.success(dto);
  140. }
  141. //----------------------------统计分析-------------------------
  142. @Operation(summary = "专利的聚合统计")
  143. @PostMapping("/esCountAnalysis")
  144. public Response esCountAnalysis(@RequestBody EsAllCountVO countVO) throws Exception {
  145. EsCountDTO dto = esCountService.esCountAnalysis(countVO);
  146. return Response.success(dto);
  147. }
  148. @Operation(summary = "分析统计的栏位日期最大/最小值")
  149. @PostMapping("/getFieldRange")
  150. public Response getFieldRange(@RequestBody EsDateRangeVO rangeVO) throws Exception {
  151. EsDateRangeDTO dto = esCountService.getFieldRange(rangeVO);
  152. return Response.success(dto);
  153. }
  154. //------------------------合并-----------------------------
  155. @Operation(summary = "专利列表上新增发明人/权利人/申请人合并")
  156. @PostMapping("/mergePerson")
  157. public Response mergePerson(@RequestBody MergePersonVO personVO) throws Exception {
  158. Integer personId = null;
  159. try {
  160. personId = mergePersonService.mergePerson(personVO);
  161. } catch (Exception e) {
  162. return Response.success(e.getMessage());
  163. }
  164. return Response.success(personId);
  165. }
  166. @Operation(summary = "专利列表上再次新增发明人/权利人/申请人合并")
  167. @PostMapping("/mergePersonAgain")
  168. public Response mergePersonAgain(@RequestBody MergePersonAgainVO againVO) throws Exception {
  169. Integer personId = mergePersonService.mergePersonAgain(againVO);
  170. return Response.success(personId);
  171. }
  172. @Operation(summary = "专利列表上编辑发明人/权利人/申请人合并")
  173. @PostMapping("/updateMergePerson")
  174. public Response updateMergePerson(@RequestBody MergePersonVO personVO) throws Exception{
  175. Integer personId = null;
  176. try {
  177. personId = mergePersonService.updateMergePerson(personVO);
  178. } catch (Exception e) {
  179. return Response.success(e.getMessage());
  180. }
  181. return Response.success(personId);
  182. }
  183. @Operation(summary = "发明人/权利人/申请人合并列表查询")
  184. @PostMapping("/selectMergePerson")
  185. public Response selectMergePerson(@RequestBody MergePersonQueryVO vo) {
  186. Records records = mergePersonService.selectMergePersonList(vo);
  187. return Response.success(records);
  188. }
  189. @Operation(summary = "合并人员详情")
  190. @PostMapping("/selectMergePersonDetail")
  191. public Response selectMergePersonDetail(@RequestBody MergePersonIdVO vo) {
  192. MergePersonQueryDTO dto = mergePersonService.selectMergePersonDetail(vo);
  193. return Response.success(dto);
  194. }
  195. @Operation(summary = "获取所有发明人/权利人/申请人")
  196. @PostMapping("/getMergePerson")
  197. public Response getMergePerson(@RequestBody GetAllPersonVO vo) throws Exception {
  198. Records records = mergePersonService.getMergePerson(vo);
  199. return Response.success(records);
  200. }
  201. @Operation(summary = "发明人/权利人/申请人合并后的名称移除")
  202. @PostMapping("/delMergedName")
  203. public Response delMergedName(@RequestBody MergedNameVO vo) throws Exception {
  204. Integer id = mergePersonService.delMergedName(vo);
  205. return Response.success(id);
  206. }
  207. @Operation(summary = "发明人/权利人/申请人合并记录删除")
  208. @PostMapping("/delMergePerson")
  209. public Response delMergePerson(@RequestBody MergePersonIdVO vo) throws Exception {
  210. Integer id = mergePersonService.delMergePerson(vo);
  211. return Response.success(id);
  212. }
  213. //-------------------------------获取所有国家-----------------
  214. @Operation(summary = "获取所有国家列表查询")
  215. @GetMapping("/getAllCountry")
  216. public Response getAllCountry() {
  217. List<GetAllCountryDTO> allCountry = mergePersonService.getAllCountry();
  218. return Response.success(allCountry);
  219. }
  220. @Operation(summary = "获取国内省份列表查询")
  221. @GetMapping("/getAllProvince")
  222. public Response getAllProvince() {
  223. List<GetAllCountryDTO> allCountry = mergePersonService.getAllProvince();
  224. return Response.success(allCountry);
  225. }
  226. //--------------------导出-----------------------
  227. @PostMapping("/exportPDFFirstPage")
  228. @Operation(summary = "导出专利PDF")
  229. public Response exportPDFFirstPage(@RequestBody EsCustomFieldBatchVO EsVO) throws IOException {
  230. ExportTaskDTO exportTaskDTO = new ExportTaskDTO();
  231. exportTaskDTO.setProjectId(EsVO.getProjectId());
  232. exportTaskDTO.setType(7);
  233. PersonnelVO personnelVO = cacheUtils.getLoginUser(loginUtils.getId());
  234. exportTaskDTO.setCreateId(personnelVO.getId());
  235. exportTaskDTO.setCreateName(personnelVO.getName());
  236. Integer taskId = importTaskService.addExportTask(exportTaskDTO);
  237. exportTaskDTO.setEsVO(EsVO);
  238. exportTaskDTO.setTaskId(taskId);
  239. try {
  240. pdfExportFirstPageService.mergePdfFirstPage(exportTaskDTO);
  241. } catch (Exception e) {
  242. throw new XiaoShiException("导出失败");
  243. }
  244. Records records = new Records();
  245. records.setData("正在导出PDF首页");
  246. return Response.success(records);
  247. }
  248. @PostMapping("/exportPatentExcel")
  249. @Operation(summary = "导出专利")
  250. public Response exportPatentExcel(@RequestBody EsCustomFieldBatchVO EsVO) throws IOException {
  251. ExportTaskDTO exportTaskDTO = new ExportTaskDTO();
  252. exportTaskDTO.setProjectId(EsVO.getProjectId());
  253. exportTaskDTO.setType(6);
  254. PersonnelVO personnelVO = cacheUtils.getLoginUser(loginUtils.getId());
  255. exportTaskDTO.setCreateId(personnelVO.getId());
  256. exportTaskDTO.setCreateName(personnelVO.getName());
  257. Integer taskId = importTaskService.addExportTask(exportTaskDTO);
  258. exportTaskDTO.setEsVO(EsVO);
  259. exportTaskDTO.setTaskId(taskId);
  260. patentExportService.exportPatent(exportTaskDTO);
  261. Records records = new Records();
  262. records.setData("导出专利");
  263. return Response.success(records);
  264. }
  265. //---------------------------------商品化专利----------------
  266. @Operation(summary = "添加商品化专利")
  267. @PostMapping("/addProductPatent")
  268. public Response addProductPatent(EsProductPatentVO vo) throws Exception {
  269. List<Integer> ids = esProductPatentService.addProductPatent(vo);
  270. return Response.success(ids);
  271. }
  272. @Operation(summary = "删除商品化专利")
  273. @PostMapping("/delProductPatent")
  274. public Response delProductPatent(EsProductPatentVO vo) throws Exception {
  275. List<Integer> ids = esProductPatentService.delProductPatent(vo);
  276. return Response.success(ids);
  277. }
  278. }