zero 6 月之前
父節點
當前提交
62dd4d745f

+ 1 - 0
src/main/java/cn/cslg/pas/common/dto/InnerPatentPdfDTO.java

@@ -6,5 +6,6 @@ import lombok.Data;
 public class InnerPatentPdfDTO {
 
     private String pdfGuid;
+    //0公开  1授权
     private Integer type;
 }

+ 169 - 0
src/main/java/cn/cslg/pas/common/dto/PatentInfoDTO.java

@@ -0,0 +1,169 @@
+package cn.cslg.pas.common.dto;
+
+import cn.cslg.pas.domain.es.*;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.Data;
+
+import java.util.Date;
+import java.util.List;
+
+@Data
+public class PatentInfoDTO {
+
+    /**
+     * 标题
+     */
+    private List<Text> title;
+
+    /**
+     * 摘要
+     */
+    private List<Text> abstractStr;
+
+    /**
+     * 申请人地址
+     */
+    private PersonAddress applicantAddr;
+
+    /**
+     * 公开号
+     */
+    private String publicNo;
+
+    /**
+     * 公开日
+     */
+    @JsonFormat(
+            pattern = "yyyy-MM-dd",
+            timezone = "GMT+8"
+    )
+    private Date publicDate;
+
+    /**
+     * 申请号
+     */
+    private String appNo;
+
+    /**
+     * 申请日
+     */
+    @JsonFormat(
+            pattern = "yyyy-MM-dd",
+            timezone = "GMT+8"
+    )
+    private Date appDate;
+
+    /**
+     * 授权号
+     */
+    private String grantNo;
+
+    /**
+     * 授权日
+     */
+    @JsonFormat(
+            pattern = "yyyy-MM-dd",
+            timezone = "GMT+8"
+    )
+    private Date grantDate;
+
+    /**
+     * 申请国家
+     */
+    private String appCountry;
+
+    /**
+     * IPC分类号(主)
+     */
+    private PatentClassify mipc;
+
+    /**
+     * ipc集合
+     */
+    private List<PatentClassify> ipc;
+
+    /**
+     * CPC分类号(主)
+     */
+    private PatentClassify mcpc;
+
+    /**
+     * cpc集合
+     */
+    private List<PatentClassify> cpc;
+
+    /**
+     * UPC分类号(主)
+     */
+    private PatentClassify mupc;
+
+
+    /**
+     * UPC集合
+     */
+    private List<PatentClassify> upc;
+
+    /**
+     * UPC分类号(主)
+     */
+    private PatentClassify mloc;
+
+
+    /**
+     * UPC集合
+     */
+    private List<PatentClassify> loc;
+
+    /**
+     * 专利状态
+     */
+    private String simpleStatus;
+
+    /**
+     * 类型
+     */
+    private String patentType;
+
+    /**
+     * 权利要求
+     */
+    private List<Text> claim;
+
+    /**
+     * 申请人
+     */
+    private List<String> applicant;
+
+    /**
+     * 权利人
+     */
+    private List<String> rightHolder;
+
+    /**
+     * 发明人
+     */
+    private List<String> inventor;
+
+    /**
+     * 代理机构
+     */
+    private String agency;
+
+    /**
+     * 代理人
+     */
+    private List<String> agent;
+
+    //外部专利的原始申请号
+    private String rowApplicationNo;
+
+    private Boolean ifSearch = true;
+
+    //txt文档guid
+    private String txtGuid;
+
+    //pdf
+    private List<InnerPatentPdfDTO> pdfDTOS;
+
+}

+ 66 - 0
src/main/java/cn/cslg/pas/common/utils/FileUtils.java

@@ -4,7 +4,11 @@ package cn.cslg.pas.common.utils;
 import cn.cslg.pas.Application;
 import cn.hutool.core.util.IdUtil;
 import com.alibaba.fastjson.JSON;
+import org.apache.commons.fileupload.FileItem;
+import org.apache.commons.fileupload.disk.DiskFileItemFactory;
 import org.springframework.boot.system.ApplicationHome;
+import org.springframework.http.MediaType;
+import org.springframework.mock.web.MockMultipartFile;
 import org.springframework.stereotype.Service;
 import org.springframework.web.multipart.MultipartFile;
 
@@ -198,6 +202,23 @@ public class FileUtils {
         return fileInputStream;
     }
 
+    public static FileInputStream bytesToFile(String fileName,byte[] bytes) {
+        String name = fileName + ".txt";
+        File file = new File(name);
+        FileInputStream fileInputStream = null;
+        try {
+            OutputStream output = new FileOutputStream(file);
+            BufferedOutputStream bufferedOutput = new BufferedOutputStream(output);
+            bufferedOutput.write(bytes);
+            fileInputStream = new FileInputStream(file);
+            file.deleteOnExit();
+            return fileInputStream;
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        return fileInputStream;
+    }
+
     public String getTempPath(String fileName) {
         String tempPath = getStaticPath(COMMON_FILE) + FILE_SEPARATOR + "temp";
         File file = new File(tempPath);
@@ -336,4 +357,49 @@ public class FileUtils {
         }
         return tempFile;
     }
+
+    public static MultipartFile convertBytesToMultipartFile(byte[] fileData, String fileName) throws IOException {
+        InputStream inputStream = new ByteArrayInputStream(fileData);
+        MultipartFile multipartFile = new MockMultipartFile(fileName, fileName, "application/octet-stream", inputStream);
+        return multipartFile;
+    }
+
+//    public static MultipartFile getMultipartFile(byte[] fileData, String fileName) throws IOException {
+//        InputStream inputStream = new ByteArrayInputStream(fileData);
+//        FileItem fileItem = createFileItem(inputStream, fileName);
+//        return new CommonsMultipartFile(fileItem);
+//    }
+
+    public static FileItem createFileItem(InputStream inputStream, String fileName) {
+        DiskFileItemFactory factory = new DiskFileItemFactory();
+        FileItem fileItem = factory.createItem("file", MediaType.MULTIPART_FORM_DATA_VALUE, true, fileName);
+        int read = 0;
+        OutputStream os = null;
+        byte[] buffer = new byte[10 * 1024 * 1024];
+        try {
+            os = fileItem.getOutputStream();
+            while ((read = inputStream.read(buffer, 0, 4096)) != -1) {
+                os.write(buffer, 0, read);
+            }
+            inputStream.close();
+        } catch (IOException e) {
+            throw new IllegalArgumentException("Failed to Output");
+        } finally {
+            if (os != null) {
+                try {
+                    os.close();
+                } catch (IOException e) {
+                    throw new IllegalArgumentException("The OutputStream is failed");
+                }
+            }
+            if (inputStream != null) {
+                try {
+                    inputStream.close();
+                } catch (IOException e) {
+                    throw new IllegalArgumentException("The InputStream is failed");
+                }
+            }
+        }
+        return fileItem;
+    }
 }

+ 7 - 0
src/main/java/cn/cslg/pas/controller/outApi/PatentStarController.java

@@ -174,4 +174,11 @@ public class PatentStarController {
         GetPatentSimilarScoreVO getPatentSimilarScoreVO= pythonApiService.getPatentSimilarMess(getPatentSimilarScoreDTO);
         return Response.success(getPatentSimilarScoreVO);
     }
+
+    @GetMapping("/queryPatentDetailByPatentNo")
+    @Operation(summary = "用于窍笔根据号码获取专利检索详情数据")
+    public Response queryPatentDetailByPatentNo(String patentNo) throws IOException {
+        PatentInfoDTO infoDTO = patentStarApiService.queryPatentDetailByPatentNo(patentNo);
+        return Response.success(infoDTO);
+    }
 }

+ 97 - 0
src/main/java/cn/cslg/pas/service/common/PatentStarApiService.java

@@ -23,6 +23,7 @@ import cn.cslg.pas.service.WebLoginConfigService;
 import cn.cslg.pas.service.importPatent.WebVOTransformService;
 import cn.cslg.pas.service.novelty.AssoRetrieveRecordProjectService;
 import cn.cslg.pas.service.query.FormatQueryService;
+import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.sun.istack.NotNull;
@@ -31,6 +32,7 @@ import lombok.experimental.Accessors;
 import lombok.extern.slf4j.Slf4j;
 import okhttp3.*;
 import okhttp3.Response;
+import org.apache.commons.lang3.ObjectUtils;
 import org.dom4j.Document;
 import org.dom4j.DocumentException;
 import org.dom4j.Element;
@@ -45,6 +47,7 @@ import org.springframework.context.ApplicationContext;
 import org.springframework.context.annotation.Lazy;
 import org.springframework.stereotype.Service;
 import org.springframework.util.CollectionUtils;
+import org.springframework.web.multipart.MultipartFile;
 
 import java.io.File;
 import java.io.IOException;
@@ -86,6 +89,8 @@ public class PatentStarApiService {
     private AssoRetrieveRecordProjectService assoRetrieveRecordProjectService;
     @Autowired
     private NOSCacheService cacheService;
+    @Autowired
+    private FileManagerService fileManagerService;
 
     public Records patentStarSearchLocal(PatentStarListDTO patentStarListDTO) throws IOException {
         RetrieveRecord retrieveRecord = retrieveRecordService.setRetrieveRecord(patentStarListDTO);
@@ -1141,6 +1146,98 @@ public class PatentStarApiService {
     }
 
     /**
+     * 根据专利号查询外部权利要求
+     *
+     * @param patentNo
+     * @return
+     * @throws IOException
+     */
+    public PatentInfoDTO queryPatentDetailByPatentNo(String patentNo) throws IOException {
+        PatentStarListDTO patentStarListDTO = new PatentStarListDTO();
+        String condition = "AN=" + patentNo + " OR " + "PN=" + patentNo + " OR " + "GN=" + patentNo;
+        patentStarListDTO.setCurrentQuery(condition);
+        String index = patentNo.substring(0, 2);
+        if (index.equals("CN") || index.equals("ZL")) {
+            patentStarListDTO.setDBType("CN");
+        } else {
+            patentStarListDTO.setDBType("WD");
+        }
+        patentStarListDTO.setOrderBy("AD");
+        patentStarListDTO.setOrderByType("DESC");
+        patentStarListDTO.setPageNum(1);
+        patentStarListDTO.setRowCount(10);
+        Records records = this.patentStarSearchLocal(patentStarListDTO);
+        Object data = records.getData();
+        String s = JSON.toJSONString(data);
+        List<PatentColumnDTO> list = JSON.parseArray(s, PatentColumnDTO.class);
+        PatentInfoDTO dto = new PatentInfoDTO();
+        if (!CollectionUtils.isEmpty(list)) {
+            for (PatentColumnDTO columnDTO : list) {
+                BeanUtils.copyProperties(columnDTO, dto);
+            }
+        }
+        if (StringUtils.isNotEmpty(dto.getRowApplicationNo())) {
+            String txtGuid = this.getTxtGuid(dto.getRowApplicationNo(), patentNo);
+            dto.setTxtGuid(txtGuid);
+        }
+        List<InnerPatentPdfDTO> pdfList = this.getExternalTextPdf(dto.getAppNo(), dto.getRowApplicationNo(), dto.getPublicNo(), dto.getGrantNo());
+        if (!CollectionUtils.isEmpty(pdfList)) {
+            List<InnerPatentPdfDTO> pdfDTOS = new ArrayList<>();
+            for (InnerPatentPdfDTO innerPatentPdfDTO : pdfList) {
+                File file = FileUtils.getFileByUrl(innerPatentPdfDTO.getPdfGuid());
+                List<String> guidList = fileManagerService.uploadFileGetGuid2(Collections.singletonList(file));
+                if (!CollectionUtils.isEmpty(guidList)) {
+                    InnerPatentPdfDTO pdfDTO = new InnerPatentPdfDTO();
+                    pdfDTO.setPdfGuid(guidList.get(0));
+                    pdfDTO.setType(innerPatentPdfDTO.getType());
+                    pdfDTOS.add(pdfDTO);
+                }
+            }
+            dto.setPdfDTOS(pdfDTOS);
+        }
+        return dto;
+    }
+
+    public String getTxtGuid(String rowApplicationNo,String patentNo) throws IOException {
+        StringBuilder builder = new StringBuilder();
+        SelectClaimDTO externalClaim = this.queryExternalClaim(rowApplicationNo);
+        if (ObjectUtils.isNotEmpty(externalClaim)) {
+            List<Text> claimContent = externalClaim.getClaimContent();
+            if (!CollectionUtils.isEmpty(claimContent)) {
+                Text text = claimContent.stream().filter(i -> i.getIfOrigin().equals(true)).findFirst().orElse(null);
+                if (ObjectUtils.isNotEmpty(text)) {
+                    String claim = text.getTextContent();
+                    String claimStr = claim.replaceAll("\t", "\n");
+                    builder.append("                                   权利要求");
+                    builder.append("\n");
+                    builder.append(claimStr);
+                }
+            }
+        }
+        List<Text> fullText = this.getCnFullText(rowApplicationNo);
+        if (!CollectionUtils.isEmpty(fullText)) {
+            Text text = fullText.stream().filter(i -> i.getIfOrigin().equals(true)).findFirst().orElse(null);
+            if (ObjectUtils.isNotEmpty(text)) {
+                String specification = text.getTextContent();
+                builder.append("\n");
+                builder.append("\n");
+                builder.append("\n");
+                builder.append("                                         说明书");
+                builder.append("\n");
+                builder.append(specification);
+            }
+        }
+        String result = builder.toString();
+        byte[] bytes = result.getBytes();
+        MultipartFile multipartFile = FileUtils.convertBytesToMultipartFile(bytes, patentNo + "-" + "文本文档.txt");
+        List<String> list = fileManagerService.uploadFileGetGuid(Collections.singletonList(multipartFile));
+        if (!CollectionUtils.isEmpty(list)) {
+            return list.get(0);
+        }
+        return "";
+    }
+
+    /**
      * 查询外部专利同族专利
      *
      * @param vo