PatentController.java 14 KB

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