ソースを参照

5/27 导出报告

lwhhszx 1 年間 前
コミット
e4b9290813

+ 4 - 3
src/main/java/cn/cslg/pas/service/common/OPSService.java

@@ -78,8 +78,7 @@ public class OPSService {
      *
      * @return
      */
-    public String getImagesInfo(PubNo pubNo) throws IOException {
-        String pn = pubNo.getCountry() + pubNo.getNumber() + "." + pubNo.getKind();
+    public String getImagesInfo(String pubNo) throws IOException {
         //String param = new Gson().toJson(pn);
         //RequestBody requestBody = RequestBody.create(MediaType.parse("application/json"), param);
         OkHttpClient okHttpClient = new OkHttpClient.Builder()
@@ -88,12 +87,14 @@ public class OPSService {
                 .readTimeout(60, TimeUnit.SECONDS)
                 .build();
         Request request = new Request.Builder()
-                .url(OPSUrl + "/api/OPSQuery/GetImagesInfo?Pn=" + pn)
+                .url(OPSUrl + "/api/OPSQuery/GetImagesInfo?Pn=" + pubNo)
                 .get()
                 .build();
         return Objects.requireNonNull(okHttpClient.newCall(request).execute().body()).string();
     }
 
+
+
     /**
      * 远程调用获取附件文件流的接口
      *

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

@@ -370,6 +370,9 @@ public class PatentStarApiService {
                 // 打印服务端返回结果
                 return Objects.requireNonNull(response.body()).string();
             }
+            else {
+                response.close();
+            }
         } catch (IOException e) {
             e.printStackTrace();
         }
@@ -454,6 +457,10 @@ public class PatentStarApiService {
                 // 打印服务端返回结果
                 return Objects.requireNonNull(response.body()).string();
             }
+            else {
+                response.close();
+            }
+
         } catch (IOException e) {
             e.printStackTrace();
         }
@@ -601,6 +608,9 @@ public class PatentStarApiService {
                 // 打印服务端返回结果
                 return Objects.requireNonNull(response.body()).string();
             }
+            else {
+                response.close();
+            }
         } catch (IOException e) {
             e.printStackTrace();
         }

+ 32 - 11
src/main/java/cn/cslg/pas/service/importPatent/GetPatentPictureFromWebThread.java

@@ -57,22 +57,43 @@ public class GetPatentPictureFromWebThread extends Thread {
             }
             UploadPatentWebDTO uploadPatentWebDTO = uploadPatentWebDTOs.remove(0);
             try {
+                String usedNo = uploadPatentWebDTO.getStarPatentVO().getPublicNo();
+                if (usedNo == null) {
+                    usedNo = uploadPatentWebDTO.getStarPatentVO().getPublicAccreditNo();
+                }
+                if (usedNo.contains("CN")) {
+                    PatentStarApiService patentStarApiService = applicationContext.getBean(PatentStarApiService.class);
 
-                PatentStarApiService patentStarApiService = applicationContext.getBean(PatentStarApiService.class);
-                String pictureUrl = patentStarApiService.getPictureApi(uploadPatentWebDTO.getStarPatentVO().getRowApplicationNo());
+                    String pictureUrl = patentStarApiService.getPictureApi(uploadPatentWebDTO.getStarPatentVO().getRowApplicationNo());
+
+                    if (pictureUrl != null && !pictureUrl.contains("408")) {
+                        File file = FileUtils.getPictureFileByUrl(pictureUrl);
+                        FileManagerService fileManagerService = applicationContext.getBean(FileManagerService.class);
+                        String guid = FormatUtil.getPictureFormat(uploadPatentWebDTO.getStarPatentVO().getApplicationNo());
+                        fileManagerService.uploadFileWithGuid(file, guid);
+                    } else {
+                        recordQuestionPatent(uploadPatentWebDTO.getStarPatentVO().getApplicationNo());
+                    }
+                } else {
+                    ImportSinglePatentService importSinglePatentService = applicationContext.getBean(ImportSinglePatentService.class);
+                    byte[] bytes = importSinglePatentService.getImages(usedNo);
+                    if (bytes != null) {
+                        File file = FileUtils.getFileByBytes(bytes, usedNo, "jpg");
+                        FileManagerService fileManagerService = applicationContext.getBean(FileManagerService.class);
+                        String guid = FormatUtil.getPictureFormat(uploadPatentWebDTO.getStarPatentVO().getApplicationNo());
+                        fileManagerService.uploadFileWithGuid(file, guid);
+                        file.delete();
+                    } else {
+                        recordQuestionPatent(uploadPatentWebDTO.getStarPatentVO().getApplicationNo());
+
+                    }
 
-                if (pictureUrl != null && !pictureUrl.contains("408")) {
-                    File file = FileUtils.getPictureFileByUrl(pictureUrl);
-                    FileManagerService fileManagerService = applicationContext.getBean(FileManagerService.class);
-                    String guid = FormatUtil.getPictureFormat(uploadPatentWebDTO.getStarPatentVO().getApplicationNo());
-                    fileManagerService.uploadFileWithGuid(file, guid);
-                }
-                else {
-                    recordQuestionPatent(uploadPatentWebDTO.getStarPatentVO().getApplicationNo());
                 }
                 taskThread.updateProcess(false, 2, "");
             } catch (Exception e) {
                 taskThread.updateProcess(true, 2, "");
+                recordQuestionPatent(uploadPatentWebDTO.getStarPatentVO().getApplicationNo());
+
                 e.printStackTrace();
             }
 
@@ -108,7 +129,7 @@ public class GetPatentPictureFromWebThread extends Thread {
         }
     }
 
-    public void recordQuestionPatent(String appNo){
+    public void recordQuestionPatent(String appNo) {
         PatentImportErrorLog patentImportErrorLog = new PatentImportErrorLog();
         patentImportErrorLog.setPatentNo(appNo);
         patentImportErrorLog.setErrorType(3);

+ 3 - 6
src/main/java/cn/cslg/pas/service/importPatent/ImportSinglePatentService.java

@@ -915,12 +915,9 @@ public class ImportSinglePatentService {
     }
 
     public byte[] getImages(String publicNo) throws IOException {
-        PatentNoDetailVO patentNoDetailVO = patentNoUtil.getPatentNoDetail(publicNo);
-        PubNo pubNo = new PubNo();
-        pubNo.setCountry(patentNoDetailVO.getCc());
-        pubNo.setNumber(patentNoDetailVO.getNumber());
-        pubNo.setKind(patentNoDetailVO.getKind());
-        String res = opsService.getImagesInfo(pubNo);
+
+        String res = opsService.getImagesInfo(publicNo);
+        if(res==null){return null;}
         JSONObject jsonObject = JSONObject.parseObject(res);
         String imageInfo = jsonObject.getString("data");
         // 删除第一个 `[`