123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256 |
- package cn.cslg.pas.controller;
- import cn.cslg.pas.common.core.base.Constants;
- import cn.cslg.pas.common.dto.*;
- import cn.cslg.pas.common.dto.PatentExport.PatentExportParams;
- import cn.cslg.pas.common.dto.PatentExport.TaskParams;
- import cn.cslg.pas.common.dto.business.EsCountDTO;
- import cn.cslg.pas.common.dto.business.SelectClaimDTO;
- import cn.cslg.pas.common.model.cronModel.Records;
- import cn.cslg.pas.common.model.request.StringRequest;
- import cn.cslg.pas.common.utils.*;
- import cn.cslg.pas.common.utils.Response;
- import cn.cslg.pas.common.vo.business.*;
- import cn.cslg.pas.common.vo.PatentWithIdVO;
- import cn.cslg.pas.common.vo.StarPatentVO;
- import cn.cslg.pas.common.vo.business.EsAllCountVO;
- import cn.cslg.pas.common.vo.business.PatentKinVO;
- import cn.cslg.pas.common.vo.business.PatentNoVO;
- import cn.cslg.pas.common.vo.es.EsCustomFieldBatchVO;
- import cn.cslg.pas.factorys.businessFactory.Business;
- import cn.cslg.pas.factorys.businessFactory.BusinessFactory;
- import cn.cslg.pas.service.business.PDFExportFirstPageService;
- import cn.cslg.pas.service.business.PatentExportService;
- import cn.cslg.pas.service.business.MergePersonService;
- import cn.cslg.pas.service.business.es.EsCountService;
- import cn.cslg.pas.service.business.es.EsPatentService;
- import cn.cslg.pas.service.business.es.EsService;
- import cn.cslg.pas.service.common.FileManagerService;
- import cn.cslg.pas.service.common.PatentStarApiService;
- import cn.hutool.core.util.IdUtil;
- import io.swagger.v3.oas.annotations.Operation;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.core.io.InputStreamResource;
- import org.springframework.http.HttpHeaders;
- import org.springframework.http.MediaType;
- import org.springframework.http.ResponseEntity;
- import org.springframework.scheduling.annotation.Async;
- import org.springframework.web.bind.annotation.*;
- import java.io.ByteArrayInputStream;
- import java.io.IOException;
- import java.net.URLEncoder;
- import java.nio.charset.StandardCharsets;
- import java.util.List;
- @RequestMapping(Constants.API_XiaoSHI + "/patent")
- @RestController
- public class PatentController {
- @Autowired
- private BusinessFactory businessFactory;
- @Autowired
- private EsCountService esCountService;
- @Autowired
- private EsPatentService patentService;
- @Autowired
- private MergePersonService mergePersonService;
- @Autowired
- private EsService esService;
- @Autowired
- private PatentStarApiService patentStarApiService;
- @Autowired
- private CacheUtils cacheUtils;
- @Autowired
- private PatentExportService patentExportService;
- @Autowired
- private PDFExportFirstPageService pdfExportFirstPageService;
- @Operation(summary = "查询专利")
- @PostMapping("/queryPatent")
- public Response queryPatent(@RequestBody StringRequest stringRequest) throws Exception {
- Business business = businessFactory.getClass("patentService");
- Records records = (Records) business.queryMessage(stringRequest);
- return Response.success(records);
- }
- @Operation(summary = "查询专利详情")
- @PostMapping("/selectPatentDetail")
- public Response selectPatentDetail(@RequestBody PatentNoVO vo) throws Exception {
- PatentColumnDTO dto = patentService.selectPatentDetail(vo);
- return Response.success(dto);
- }
- @GetMapping("/getTextPdf")
- @Operation(summary = "获得中国专利pdf全文")
- public Response getTextPdf(String appNo) throws IOException {
- List<InnerPatentPdfDTO> pdfDTOS = patentService.getTextPdf(appNo);
- return Response.success(pdfDTOS);
- }
- @GetMapping("/getFigure")
- @Operation(summary = "内部获取附图")
- public Response getFigure(String appNo) throws IOException {
- List<String> figures = patentService.getFigure(appNo);
- return Response.success(figures);
- }
- @Operation(summary = "根据专利号查询同族")
- @PostMapping("/selectKinByPatentNo")
- public Response selectKinByPatentNo(@RequestBody PatentKinVO vo) throws Exception {
- List<PatentKinDTO> dto = patentService.selectKinByPatentNo(vo);
- return Response.success(dto);
- }
- @Operation(summary = "查询分页信息")
- @PostMapping("/getPatentPageMessage")
- public Response getPatentPageMessage(@RequestBody StringRequest stringRequest) throws Exception {
- Records records = patentService.getPatentPageMessage(stringRequest);
- return Response.success(records);
- }
- @Operation(summary = "专利的聚合统计")
- @PostMapping("/esCountAnalysis")
- public Response esCountAnalysis(@RequestBody EsAllCountVO countVO) throws Exception {
- EsCountDTO dto = esCountService.esCountAnalysis(countVO);
- return Response.success(dto);
- }
- @Operation(summary = "根据专利号查询内部专利")
- @GetMapping("/queryPatentByNo")
- public Response queryPatentByNo(String patentNo) throws Exception {
- PatentWithIdVO patentWithIdVO = esService.getIdByPatentNo(patentNo);
- if (patentWithIdVO == null) {
- return Response.success(null);
- }
- return Response.success(patentWithIdVO.getPatent());
- }
- @Operation(summary = "根据专利号查询内部专利")
- @GetMapping("/queryPatentByNoFromWeb")
- public Response queryPatentByNoFromWeb(String patentNo) throws Exception {
- StarPatentVO starPatentVO = patentStarApiService.getPatentByNo(patentNo);
- if (starPatentVO == null) {
- return Response.success(null);
- }
- return Response.success(starPatentVO);
- }
- @Operation(summary = "根据专利号查询内部权利要求")
- @GetMapping("/queryClaimByPatentNo")
- public Response queryClaimByPatentNo(String patentNo) throws Exception {
- SelectClaimDTO dto = esService.selectClaim(patentNo);
- return Response.success(dto);
- }
- //------------------------合并-----------------------------
- @Operation(summary = "专利列表上新增发明人/权利人/申请人合并")
- @PostMapping("/mergePerson")
- public Response mergePerson(@RequestBody MergePersonVO personVO) throws Exception {
- Integer personId = mergePersonService.mergePerson(personVO);
- return Response.success(personId);
- }
- @Operation(summary = "专利列表上再次新增发明人/权利人/申请人合并")
- @PostMapping("/mergePersonAgain")
- public Response mergePersonAgain(@RequestBody MergePersonAgainVO againVO) throws Exception {
- Integer personId = mergePersonService.mergePersonAgain(againVO);
- return Response.success(personId);
- }
- @Operation(summary = "专利列表上编辑发明人/权利人/申请人合并")
- @PostMapping("/updateMergePerson")
- public Response updateMergePerson(@RequestBody MergePersonVO personVO) throws Exception{
- Integer personId = mergePersonService.updateMergePerson(personVO);
- return Response.success(personId);
- }
- @Operation(summary = "发明人/权利人/申请人合并列表查询")
- @PostMapping("/selectMergePerson")
- public Response selectMergePerson(@RequestBody MergePersonQueryVO vo) {
- Records records = mergePersonService.selectMergePersonList(vo);
- return Response.success(records);
- }
- @Operation(summary = "合并人员详情")
- @PostMapping("/selectMergePersonDetail")
- public Response selectMergePersonDetail(@RequestBody MergePersonIdVO vo) {
- MergePersonQueryDTO dto = mergePersonService.selectMergePersonDetail(vo);
- return Response.success(dto);
- }
- @Operation(summary = "获取所有发明人/权利人/申请人")
- @PostMapping("/getMergePerson")
- public Response getMergePerson(@RequestBody GetAllPersonVO vo) throws Exception {
- Records records = mergePersonService.getMergePerson(vo);
- return Response.success(records);
- }
- @Operation(summary = "发明人/权利人/申请人合并后的名称移除")
- @PostMapping("/delMergedName")
- public Response delMergedName(@RequestBody MergedNameVO vo) throws Exception {
- Integer id = mergePersonService.delMergedName(vo);
- return Response.success(id);
- }
- @Operation(summary = "发明人/权利人/申请人合并记录删除")
- @PostMapping("/delMergePerson")
- public Response delMergePerson(@RequestBody MergePersonIdVO vo) throws Exception {
- Integer id = mergePersonService.delMergePerson(vo);
- return Response.success(id);
- }
- //-------------------------------获取所有国家-----------------
- @Operation(summary = "获取所有国家列表查询")
- @GetMapping("/getAllCountry")
- public Response getAllCountry() {
- List<GetAllCountryDTO> allCountry = mergePersonService.getAllCountry();
- return Response.success(allCountry);
- }
- //--------------------导出-----------------------
- @PostMapping("/exportPDFFirstPage")
- @Operation(summary = "导出专利PDF")
- public ResponseEntity<InputStreamResource> exportPDFFirstPage(@RequestBody EsCustomFieldBatchVO EsVO) throws IOException {
- byte[] fileData = pdfExportFirstPageService.mergePdfFirstPage(EsVO);
- //保存生成excel的地址
- String fileName = IdUtil.simpleUUID() + ".pdf";
- //文件原始名中的中文字符可能会乱码,对文件名进行URL编码
- String encodedFileName = URLEncoder.encode(fileName, StandardCharsets.UTF_8.toString());
- return ResponseEntity.ok().contentLength(fileData.length)
- .header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + encodedFileName + "\"")
- .contentType(MediaType.parseMediaType("application/octet-stream"))
- .body(new InputStreamResource(new ByteArrayInputStream(fileData)));
- }
- // @PostMapping("/exportPatentExcel")
- // @Operation(summary = "导出专利")
- // public ResponseEntity<InputStreamResource> export(@RequestBody EsCustomFieldBatchVO EsVO) throws IOException {
- // byte[] fileData = patentExportService.exportPatent(EsVO);
- // //保存生成excel的地址
- // String fileName = IdUtil.simpleUUID() + ".xls";
- // //文件原始名中的中文字符可能会乱码,对文件名进行URL编码
- // String encodedFileName = URLEncoder.encode(fileName, StandardCharsets.UTF_8.toString());
- // return ResponseEntity.ok().contentLength(fileData.length)
- // .header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + encodedFileName + "\"")
- // .contentType(MediaType.parseMediaType("application/octet-stream"))
- // .body(new InputStreamResource(new ByteArrayInputStream(fileData)));
- // }
- @PostMapping("/exportPatentExcel")
- @Operation(summary = "导出专利")
- public Response export(@RequestBody EsCustomFieldBatchVO EsVO) throws IOException {
- patentExportService.exportPatent(EsVO);
- Records records = new Records();
- records.setData("导出成功");
- return Response.success(records);
- }
- }
|