PatentController.java 14 KB

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