zero 6 ay önce
ebeveyn
işleme
14dbdcbcfd

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

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

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

@@ -25,12 +25,14 @@ import cn.cslg.pas.service.novelty.AssoRetrieveRecordProjectService;
 import cn.cslg.pas.service.query.FormatQueryService;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
+import com.alibaba.fastjson2.JSON;
 import com.sun.istack.NotNull;
 import lombok.RequiredArgsConstructor;
 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);
@@ -1429,4 +1434,95 @@ 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 "";
+    }
 }