PatentController.java 16 KB

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