123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337 |
- 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.dto.es.EsDateRangeDTO;
- import cn.cslg.pas.common.dto.es.EsValueCurveDTO;
- import cn.cslg.pas.common.model.cronModel.PersonnelVO;
- 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.common.vo.es.EsDateRangeVO;
- import cn.cslg.pas.common.vo.es.EsProductPatentVO;
- import cn.cslg.pas.common.vo.es.EsValueCurveVO;
- import cn.cslg.pas.domain.business.ImportTask;
- import cn.cslg.pas.domain.business.Product;
- import cn.cslg.pas.exception.XiaoShiException;
- import cn.cslg.pas.factorys.businessFactory.Business;
- import cn.cslg.pas.factorys.businessFactory.BusinessFactory;
- import cn.cslg.pas.service.business.CustomAnalyseService;
- import cn.cslg.pas.service.business.ImportTaskService;
- 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.*;
- 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.apache.commons.io.input.XmlStreamReaderException;
- 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 EsProductPatentService esProductPatentService;
- @Autowired
- private EsValueCurveService esValueCurveService;
- @Autowired
- private PatentStarApiService patentStarApiService;
- @Autowired
- private CacheUtils cacheUtils;
- @Autowired
- private PatentExportService patentExportService;
- @Autowired
- private PDFExportFirstPageService pdfExportFirstPageService;
- @Autowired
- private ImportTaskService importTaskService;
- @Autowired
- private LoginUtils loginUtils;
- @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 = "根据专利号查询内部专利")
- @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("/esCountAnalysis")
- public Response esCountAnalysis(@RequestBody EsAllCountVO countVO) throws Exception {
- EsCountDTO dto = esCountService.esCountAnalysis(countVO);
- return Response.success(dto);
- }
- @Operation(summary = "分析统计的栏位日期最大/最小值")
- @PostMapping("/getFieldRange")
- public Response getFieldRange(@RequestBody EsDateRangeVO rangeVO) throws Exception {
- EsDateRangeDTO dto = esCountService.getFieldRange(rangeVO);
- return Response.success(dto);
- }
- //------------------------合并-----------------------------
- @Operation(summary = "专利列表上新增发明人/权利人/申请人合并")
- @PostMapping("/mergePerson")
- public Response mergePerson(@RequestBody MergePersonVO personVO) throws Exception {
- Integer personId = null;
- try {
- personId = mergePersonService.mergePerson(personVO);
- } catch (Exception e) {
- return Response.success(e.getMessage());
- }
- 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 = null;
- try {
- personId = mergePersonService.updateMergePerson(personVO);
- } catch (Exception e) {
- return Response.success(e.getMessage());
- }
- 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);
- }
- @Operation(summary = "获取国内省份列表查询")
- @GetMapping("/getAllProvince")
- public Response getAllProvince() {
- List<GetAllCountryDTO> allCountry = mergePersonService.getAllProvince();
- return Response.success(allCountry);
- }
- //--------------------导出-----------------------
- @PostMapping("/exportPDFFirstPage")
- @Operation(summary = "导出专利PDF")
- public Response exportPDFFirstPage(@RequestBody EsCustomFieldBatchVO EsVO) throws IOException {
- ExportTaskDTO exportTaskDTO = new ExportTaskDTO();
- exportTaskDTO.setProjectId(EsVO.getProjectId());
- exportTaskDTO.setType(7);
- PersonnelVO personnelVO = cacheUtils.getLoginUser(loginUtils.getId());
- exportTaskDTO.setCreateId(personnelVO.getId());
- exportTaskDTO.setCreateName(personnelVO.getName());
- Integer taskId = importTaskService.addExportTask(exportTaskDTO);
- exportTaskDTO.setEsVO(EsVO);
- exportTaskDTO.setTaskId(taskId);
- try {
- pdfExportFirstPageService.mergePdfFirstPage(exportTaskDTO);
- } catch (Exception e) {
- throw new XiaoShiException("导出失败");
- }
- Records records = new Records();
- records.setData("正在导出PDF首页");
- return Response.success(records);
- }
- @PostMapping("/exportPatentExcel")
- @Operation(summary = "导出专利")
- public Response exportPatentExcel(@RequestBody EsCustomFieldBatchVO EsVO) throws IOException {
- ExportTaskDTO exportTaskDTO = new ExportTaskDTO();
- exportTaskDTO.setProjectId(EsVO.getProjectId());
- exportTaskDTO.setType(6);
- PersonnelVO personnelVO = cacheUtils.getLoginUser(loginUtils.getId());
- exportTaskDTO.setCreateId(personnelVO.getId());
- exportTaskDTO.setCreateName(personnelVO.getName());
- Integer taskId = importTaskService.addExportTask(exportTaskDTO);
- exportTaskDTO.setEsVO(EsVO);
- exportTaskDTO.setTaskId(taskId);
- patentExportService.exportPatent(exportTaskDTO);
- Records records = new Records();
- records.setData("导出专利");
- return Response.success(records);
- }
- //---------------------------------商品化专利----------------
- @Operation(summary = "根据专利号查询商品化专利")
- @PostMapping("/selectProductByPatentNo")
- public Response selectProductByPatentNo(@RequestBody SelectProductVO vo) throws Exception {
- Records records = (Records) patentService.selectProductByPatentNo(vo);
- return Response.success(records);
- }
- @Operation(summary = "添加商品化专利")
- @PostMapping("/addProductPatent")
- public Response addProductPatent(@RequestBody EsProductPatentVO vo) throws Exception {
- List<Integer> ids = esProductPatentService.addProductPatent(vo);
- return Response.success(ids);
- }
- @Operation(summary = "删除商品化专利")
- @PostMapping("/delProductPatent")
- public Response delProductPatent(@RequestBody EsProductPatentVO vo) throws Exception {
- List<Integer> ids = esProductPatentService.delProductPatent(vo);
- return Response.success(ids);
- }
- //---------------------------价值曲线---------------------
- @PostMapping("/selectValueCurve")
- @Operation(summary = "查询价值曲线")
- public Response selectValueCurve(@RequestBody EsValueCurveVO vo) throws Exception {
- List<EsValueCurveDTO> list = esValueCurveService.selectValueCurve(vo);
- Records records = new Records();
- records.setData(list);
- return Response.success(records);
- }
- }
|