chendayu há 2 anos atrás
pai
commit
2d130e2059
27 ficheiros alterados com 1272 adições e 67 exclusões
  1. 9 9
      src/main/java/com/example/demo/controller/AssoTaskPersonelController.java
  2. 30 0
      src/main/java/com/example/demo/domain/dto/GetClaimsInfoParamsDTO.java
  3. 30 0
      src/main/java/com/example/demo/domain/dto/GetDescriptionInfoParamsDTO.java
  4. 30 0
      src/main/java/com/example/demo/domain/dto/GetFuTuParamsDTO.java
  5. 30 0
      src/main/java/com/example/demo/domain/dto/GetSearchBiblioParamsDTO.java
  6. 38 0
      src/main/java/com/example/demo/domain/entity/AppNo.java
  7. 34 0
      src/main/java/com/example/demo/domain/entity/Application.java
  8. 39 0
      src/main/java/com/example/demo/domain/entity/Image.java
  9. 27 0
      src/main/java/com/example/demo/domain/entity/ImageInfo.java
  10. 34 0
      src/main/java/com/example/demo/domain/entity/Inventor.java
  11. 23 2
      src/main/java/com/example/demo/domain/entity/PatentCell.java
  12. 81 0
      src/main/java/com/example/demo/domain/entity/PatentZhuLu.java
  13. 30 0
      src/main/java/com/example/demo/domain/entity/Priority.java
  14. 38 0
      src/main/java/com/example/demo/domain/entity/PriorityNumber.java
  15. 32 0
      src/main/java/com/example/demo/domain/entity/Priorityy.java
  16. 38 0
      src/main/java/com/example/demo/domain/entity/PubNo.java
  17. 23 0
      src/main/java/com/example/demo/domain/entity/PubReference.java
  18. 20 0
      src/main/java/com/example/demo/domain/entity/Section.java
  19. 40 0
      src/main/java/com/example/demo/domain/entity/SerachBiblioData.java
  20. 15 0
      src/main/java/com/example/demo/exception/XiaoShiException.java
  21. 2 0
      src/main/java/com/example/demo/model/dto/WebQueryDTO.java
  22. 109 0
      src/main/java/com/example/demo/service/OutInterfaceService.java
  23. 452 9
      src/main/java/com/example/demo/service/UploadFromWebService.java
  24. 33 31
      src/main/java/com/example/demo/service/WebLoginConfigService.java
  25. 15 15
      src/main/java/com/example/demo/util/FileUtils.java
  26. 18 0
      src/main/java/com/example/demo/util/ThrowException.java
  27. 2 1
      src/main/resources/application-dev.yml

+ 9 - 9
src/main/java/com/example/demo/controller/AssoTaskPersonelController.java

@@ -13,6 +13,7 @@ import org.springframework.web.bind.annotation.*;
 import java.io.IOException;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
+import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
 
@@ -24,16 +25,15 @@ public class AssoTaskPersonelController {
     private final UploadFromWebService uploadFromWebService;
 
     @PostMapping("/getStar")
-    public List<PatentCell> getPatentStar(@RequestBody WebQueryDTO WebQueryDTO) throws Exception {
-        List<PatentCell> patentData = null;
-        if (WebQueryDTO.getWebConfigId() == 1 || WebQueryDTO.getWebConfigId() == 4) {
-            patentData = uploadFromWebService.getPatentStar(WebQueryDTO);
+    public List<PatentCell> getPatentStar(@RequestBody WebQueryDTO webQueryDTO) throws Exception {
+        List<PatentCell> patentData = new ArrayList<>();
+        //专利之星
+        if (webQueryDTO.getWebConfigId() == 1 || webQueryDTO.getWebConfigId() == 4) {
+            patentData = uploadFromWebService.getPatentStar(webQueryDTO);
+        //欧专局
+        } else if (webQueryDTO.getWebConfigId() == 2) {
+            patentData = uploadFromWebService.getEPO(webQueryDTO);
         }
-//        else if (id == 2) {
-////            patentData = uploadFromWebService.getHeXiang(conditions, id);
-//        } else if (id == 3) {
-//            //patentData = uploadFromWebService.getPatentya();
-//        }
         return patentData;
     }
 

+ 30 - 0
src/main/java/com/example/demo/domain/dto/GetClaimsInfoParamsDTO.java

@@ -0,0 +1,30 @@
+package com.example.demo.domain.dto;
+
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+
+/**
+ * 远程调用爬取欧专局,获取获取权要信息的接口的DTO类
+ *
+ * @Author chenyu
+ * @Date 2023/4/12
+ */
+@Accessors(chain = true)
+@Data
+public class GetClaimsInfoParamsDTO implements Serializable {
+    /**
+     * 国家前2位首字母
+     */
+    private String cc;
+    /**
+     * 专利号数字
+     */
+    private String number;
+    /**
+     * 专利种类
+     */
+    private String kind;
+
+}

+ 30 - 0
src/main/java/com/example/demo/domain/dto/GetDescriptionInfoParamsDTO.java

@@ -0,0 +1,30 @@
+package com.example.demo.domain.dto;
+
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+
+/**
+ * 远程调用爬取欧专局,获取说明书信息的接口的DTO类
+ *
+ * @Author chenyu
+ * @Date 2023/4/12
+ */
+@Accessors(chain = true)
+@Data
+public class GetDescriptionInfoParamsDTO implements Serializable {
+    /**
+     * 国家前2位首字母
+     */
+    private String cc;
+    /**
+     * 专利号数字
+     */
+    private String number;
+    /**
+     * 专利种类
+     */
+    private String kind;
+
+}

+ 30 - 0
src/main/java/com/example/demo/domain/dto/GetFuTuParamsDTO.java

@@ -0,0 +1,30 @@
+package com.example.demo.domain.dto;
+
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+
+/**
+ * 远程调用爬取欧专局,获取附件的接口的DTO类
+ *
+ * @Author chenyu
+ * @Date 2023/4/12
+ */
+@Accessors(chain = true)
+@Data
+public class GetFuTuParamsDTO implements Serializable {
+    /**
+     * 附件链接
+     */
+    private String link;
+    /**
+     * 附件页数
+     */
+    private Integer page;
+    /**
+     * 附件类型
+     */
+    private String type;
+
+}

+ 30 - 0
src/main/java/com/example/demo/domain/dto/GetSearchBiblioParamsDTO.java

@@ -0,0 +1,30 @@
+package com.example.demo.domain.dto;
+
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+
+/**
+ * 远程调用爬取欧专局,获取一批专利著录接口的DTO类
+ *
+ * @Author chenyu
+ * @Date 2023/4/11
+ */
+@Accessors(chain = true)
+@Data
+public class GetSearchBiblioParamsDTO implements Serializable {
+    /**
+     * 检索信息条件
+     */
+    private String query;
+    /**
+     * 起始专利数(1代表从第1个专利开始,注意不是页数)
+     */
+    private Integer start;
+    /**
+     * 最后专利数(10代表到第10个专利为止,注意不是页数)
+     */
+    private Integer end;
+
+}

+ 38 - 0
src/main/java/com/example/demo/domain/entity/AppNo.java

@@ -0,0 +1,38 @@
+package com.example.demo.domain.entity;
+
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+
+/**
+ * 申请号
+ *
+ * @Author chenyu
+ * @Date 2023/4/11
+ */
+@Accessors(chain = true)
+@Data
+public class AppNo implements Serializable {
+    /**
+     * 申请号类型(如:docdb、epodoc、original)
+     */
+    private String type;
+    /**
+     * 申请国家(如:AU)
+     */
+    private String country;
+    /**
+     * 申请号数字(如:2021229172)
+     */
+    private String number;
+    /**
+     * 申请号类型格式(如:A)
+     */
+    private String kind;
+    /**
+     * 申请号日期(如:2021-08-25T00:00:00)
+     */
+    private String date;
+
+}

+ 34 - 0
src/main/java/com/example/demo/domain/entity/Application.java

@@ -0,0 +1,34 @@
+package com.example.demo.domain.entity;
+
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+
+/**
+ * 这是啥???
+ *
+ * @Author chenyu
+ * @Date 2023/4/11
+ */
+@Accessors(chain = true)
+@Data
+public class Application implements Serializable {
+    /**
+     * 这是啥
+     */
+    private Integer sequence;
+    /**
+     * 国家前两位首字母
+     */
+    private String country;
+    /**
+     * 英文翻译名称(外国专利使用英文翻译名称)
+     */
+    private String enName;
+    /**
+     * 原始名称(中国专利使用原始名称)
+     */
+    private String originalName;
+
+}

+ 39 - 0
src/main/java/com/example/demo/domain/entity/Image.java

@@ -0,0 +1,39 @@
+package com.example.demo.domain.entity;
+
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * 封装images信息(imageType、urlLink、formatOptions)
+ *
+ * @Author chenyu
+ * @Date 2023/4/12
+ */
+@Accessors(chain = true)
+@Data
+public class Image implements Serializable {
+    /**
+     * 图片类型("FullDocument"为说明书pdf、"FirstPageClipping"为摘要附图、"Drawing"为其他附图)
+     */
+    private String imageType;
+    /**
+     * 图片页数(此属性值作为调用获取具体图片的接口的参数)
+     */
+    private Integer numberOfPages;
+    /**
+     * 链接参数(此属性值作为调用获取具体图片的接口的参数)
+     */
+    private String urlLink;
+    /**
+     * 图片格式((此属性值作为调用获取具体图片的接口的参数)(说明书FullDocument用application/pdf、摘要附图FirstPageClipping用image/jpeg、其他附图Drawing用application/tiff)
+     */
+    private List<String> formatOptions;
+    /**
+     * 无用类,仅为了放入ImageInfo中凑数(为了JSONObject.parseObject能转化成功)
+     */
+    private List<Section> sections;
+
+}

+ 27 - 0
src/main/java/com/example/demo/domain/entity/ImageInfo.java

@@ -0,0 +1,27 @@
+package com.example.demo.domain.entity;
+
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * 图片信息(接收http://192.168.1.24:5001/api/OPSQuery/GetImagesInfo接口的返回值data)
+ *
+ * @Author chenyu
+ * @Date 2023/4/12
+ */
+@Accessors(chain = true)
+@Data
+public class ImageInfo implements Serializable {
+    /**
+     * 无用类,仅为了放入ImageInfo中凑数(为了JSONObject.parseObject能转化成功)
+     */
+    private PubReference pubReference;
+    /**
+     * 代表各种附件的信息(封装着三种附件的类型、链接、附件页数)
+     */
+    private List<Image> images;
+
+}

+ 34 - 0
src/main/java/com/example/demo/domain/entity/Inventor.java

@@ -0,0 +1,34 @@
+package com.example.demo.domain.entity;
+
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+
+/**
+ * 发明人信息
+ *
+ * @Author chenyu
+ * @Date 2023/4/11
+ */
+@Accessors(chain = true)
+@Data
+public class Inventor implements Serializable {
+    /**
+     * 这是啥
+     */
+    private Integer sequence;
+    /**
+     * 国家前两位首字母
+     */
+    private String country;
+    /**
+     * 英文名(外国专利使用英文名)
+     */
+    private String enName;
+    /**
+     * 原名(中国专利使用原名)
+     */
+    private String originalName;
+
+}

+ 23 - 2
src/main/java/com/example/demo/domain/entity/PatentCell.java

@@ -14,12 +14,15 @@ import java.util.List;
 @Data
 public class PatentCell {
     /**
-     * 管理员用户名
+     * 专利号
      */
     private String patentNo;
+    /**
+     * 著录标题
+     */
     private String title;
     /**
-     * 申请日
+     * 申请
      */
     private String applications;
     private String legal;
@@ -30,6 +33,10 @@ public class PatentCell {
      */
     private String picUrl;
     /**
+     * 其他附图路径
+     */
+    private List<String> otherUrls;
+    /**
      * 申请号
      */
     private String applicationNo;
@@ -114,7 +121,13 @@ public class PatentCell {
      * PDF文档大小
      */
     private Long PDFSize;
+    /**
+     * PDF文档名称
+     */
     private String PDFName;
+    /**
+     * PDF信息
+     */
     private UploadFileDTO pdf;
     /**
      * 说明书
@@ -148,6 +161,14 @@ public class PatentCell {
      * 权要数量
      */
     private String rightsNum;
+    /**
+     * 同族号
+     */
+    private String familyId;
+    /**
+     * 优先权信息(优先权号、优先权国家、优先权日)
+     */
+    private List<Priority> priorities;
 
     @Data
     public static class PatentAffair {

+ 81 - 0
src/main/java/com/example/demo/domain/entity/PatentZhuLu.java

@@ -0,0 +1,81 @@
+package com.example.demo.domain.entity;
+
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * 专利著录信息(接收http://192.168.1.24:5001/api/OPSQuery/SearchBiblio接口的返回值data)
+ *
+ * @Author chenyu
+ * @Date 2023/4/11
+ */
+@Accessors(chain = true)
+@Data
+public class PatentZhuLu implements Serializable {
+    /**
+     * 申请国家
+     */
+    private String appCountry;
+    /**
+     * 同族号
+     */
+    private String familyId;
+    /**
+     * 多个申请号(只需取type是docdb的)
+     */
+    private List<AppNo> appNos;
+    /**
+     * 申请日
+     */
+    private String appDate;
+    /**
+     * 多个公开号(只需取type是docdb的)
+     */
+    private List<PubNo> pubNos;
+    /**
+     * 公开日
+     */
+    private String pubDate;
+    /**
+     * 多个ipc分类号
+     */
+    private List<String> ipCs;
+    /**
+     * 多个cpc分类号
+     */
+    private List<String> cpCs;
+    /**
+     * 多个申请人
+     */
+    private List<Application> applications;
+    /**
+     * 多个发明人
+     */
+    private List<Inventor> inventors;
+    /**
+     * 英文翻译标题
+     */
+    private String enTitle;
+    /**
+     * 原始标题
+     */
+    private String olTitle;
+    /**
+     * 英文翻译摘要
+     */
+    private String enAbstract;
+    /**
+     * 原始摘要
+     */
+    private String olAbstract;
+    /**
+     * 优先权
+     */
+    private List<Priorityy> priorties;
+
+
+
+}

+ 30 - 0
src/main/java/com/example/demo/domain/entity/Priority.java

@@ -0,0 +1,30 @@
+package com.example.demo.domain.entity;
+
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+
+/**
+ * 优先权信息(优先权号、优先权国家、优先权日)
+ *
+ * @Author chenyu
+ * @Date 2023/4/12
+ */
+@Accessors(chain = true)
+@Data
+public class Priority implements Serializable {
+    /**
+     * 优先权号
+     */
+    private String priorityNo;
+    /**
+     * 优先权国家
+     */
+    private String priorityCountry;
+    /**
+     * 优先权日
+     */
+    private String priorityDate;
+
+}

+ 38 - 0
src/main/java/com/example/demo/domain/entity/PriorityNumber.java

@@ -0,0 +1,38 @@
+package com.example.demo.domain.entity;
+
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+
+/**
+ * 优先权Number这是啥
+ *
+ * @Author chenyu
+ * @Date 2023/4/11
+ */
+@Accessors(chain = true)
+@Data
+public class PriorityNumber implements Serializable {
+    /**
+     * 优先权Number类型(如:epodoc、original)
+     */
+    private String type;
+    /**
+     * 优先权Number国家(如:GB)
+     */
+    private String country;
+    /**
+     * 优先权number(如:GB20200003495)
+     */
+    private String number;
+    /**
+     * 优先权Number类型格式(如:A)
+     */
+    private String kind;
+    /**
+     * 优先权Number日期(如:0001-01-01T00:00:00)
+     */
+    private String date;
+
+}

+ 32 - 0
src/main/java/com/example/demo/domain/entity/Priorityy.java

@@ -0,0 +1,32 @@
+package com.example.demo.domain.entity;
+
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * 优先权信息
+ *
+ * @Author chenyu
+ * @Date 2023/4/11
+ */
+@Accessors(chain = true)
+@Data
+public class Priorityy implements Serializable {
+    /**
+     * 优先权顺序
+     */
+    private Integer sequence;
+    /**
+     * 优先权Number这是啥
+     */
+    private List<PriorityNumber> numbers;
+    /**
+     * 优先权日期
+     */
+    private String date;
+
+
+}

+ 38 - 0
src/main/java/com/example/demo/domain/entity/PubNo.java

@@ -0,0 +1,38 @@
+package com.example.demo.domain.entity;
+
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+
+/**
+ * 公开号
+ *
+ * @Author chenyu
+ * @Date 2023/4/11
+ */
+@Accessors(chain = true)
+@Data
+public class PubNo implements Serializable {
+    /**
+     * 公开号类型(如:docdb、epodoc)
+     */
+    private String type;
+    /**
+     * 公开号国家(如:AU)
+     */
+    private String country;
+    /**
+     * 公开号数字(如:2021229172)
+     */
+    private String number;
+    /**
+     * 申请号类型格式(如:A1)
+     */
+    private String kind;
+    /**
+     * 申请号日期(如:2023-04-06T00:00:00)
+     */
+    private String date;
+
+}

+ 23 - 0
src/main/java/com/example/demo/domain/entity/PubReference.java

@@ -0,0 +1,23 @@
+package com.example.demo.domain.entity;
+
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+
+/**
+ * 无用类,仅为了放入ImageInfo中凑数(为了JSONObject.parseObject能转化成功)
+ *
+ * @Author chenyu
+ * @Date 2023/4/13
+ */
+@Accessors(chain = true)
+@Data
+public class PubReference implements Serializable {
+    private String type;
+    private String country;
+    private String number;
+    private String kind;
+    private String date;
+
+}

+ 20 - 0
src/main/java/com/example/demo/domain/entity/Section.java

@@ -0,0 +1,20 @@
+package com.example.demo.domain.entity;
+
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+
+/**
+ * 无用类,仅为了放入ImageInfo中凑数(为了JSONObject.parseObject能转化成功)
+ *
+ * @Author chenyu
+ * @Date 2023/4/13
+ */
+@Accessors(chain = true)
+@Data
+public class Section implements Serializable {
+    private String name;
+    private Integer startPage;
+
+}

+ 40 - 0
src/main/java/com/example/demo/domain/entity/SerachBiblioData.java

@@ -0,0 +1,40 @@
+package com.example.demo.domain.entity;
+
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * 用来封装远程调用爬取欧专局获取一批专利著录接口返回的数据("data")
+ *
+ * @Author chenyu
+ * @Date 2023/4/11
+ */
+@Accessors(chain = true)
+@Data
+public class SerachBiblioData implements Serializable {
+    /**
+     * 专利总数量(欧专局的接口最多返回专利数量为10000)
+     */
+    private Integer totals;
+    /**
+     * 检索时输入的起始专利(1代表第1件,注意不是页数)
+     */
+    private Integer start;
+    /**
+     * 检索时输入的最后专利(50代表第50件,注意不是页数)
+     */
+    private Integer end;
+    /**
+     * 检索时输入的检索条件信息检索式即conditions
+     */
+    private String cql;
+    /**
+     * 检索到的所有专利的著录信息
+     */
+    private List<PatentZhuLu> patents;
+
+
+}

+ 15 - 0
src/main/java/com/example/demo/exception/XiaoShiException.java

@@ -0,0 +1,15 @@
+package com.example.demo.exception;
+
+/**
+ * 整个项目通用异常类
+ *
+ * @Author chenyu
+ * @Date 2023/3/7
+ */
+public class XiaoShiException extends RuntimeException {
+
+    public XiaoShiException(String message) {
+        super(message);
+    }
+
+}

+ 2 - 0
src/main/java/com/example/demo/model/dto/WebQueryDTO.java

@@ -1,9 +1,11 @@
 package com.example.demo.model.dto;
 
 import lombok.Data;
+import lombok.experimental.Accessors;
 
 import java.util.List;
 
+@Accessors(chain = true)
 @Data
 public class WebQueryDTO {
     /**

+ 109 - 0
src/main/java/com/example/demo/service/OutInterfaceService.java

@@ -1,7 +1,12 @@
 package com.example.demo.service;
 
 
+import com.example.demo.domain.dto.GetClaimsInfoParamsDTO;
+import com.example.demo.domain.dto.GetDescriptionInfoParamsDTO;
+import com.example.demo.domain.dto.GetFuTuParamsDTO;
+import com.example.demo.domain.dto.GetSearchBiblioParamsDTO;
 import com.example.demo.domain.entity.PatentCell;
+import com.example.demo.domain.entity.PubNo;
 import com.google.gson.Gson;
 
 import lombok.RequiredArgsConstructor;
@@ -29,6 +34,8 @@ public class OutInterfaceService {
     private String PCSUrl;
     @Value("${PASUrl}")
     private String PASUrl;
+    @Value("${OPSUrl}")
+    private String OPSUrl;
 
 
     /**
@@ -52,4 +59,106 @@ public class OutInterfaceService {
         return Objects.requireNonNull(httpClient.newCall(request).execute().body()).string();
     }
 
+    /**
+     * 远程调用获取附件文件流的接口
+     *
+     * @return
+     */
+    public byte[] getPatentFile(GetFuTuParamsDTO getFuTuParamsDTO) throws IOException {
+        //String param = new Gson().toJson(getFuTuParamsDTO);
+        //RequestBody requestBody = RequestBody.create(MediaType.parse("application/json"), param);
+        OkHttpClient okHttpClient = new OkHttpClient.Builder()
+                .connectTimeout(60, TimeUnit.SECONDS)
+                .writeTimeout(60, TimeUnit.SECONDS)
+                .readTimeout(60, TimeUnit.SECONDS)
+                .build();
+        Request request = new Request.Builder()
+                .url(OPSUrl + "/api/OPSQuery/GetPatentFile?link=" + getFuTuParamsDTO.getLink() + "&page=" + getFuTuParamsDTO.getPage() + "&type=" + getFuTuParamsDTO.getType())
+                .get()
+                .build();
+        byte[] buffer = okHttpClient.newCall(request).execute().body().bytes();
+        return buffer;
+    }
+
+    /**
+     * 远程调用获取Image信息的接口
+     *
+     * @return
+     */
+    public String getImagesInfo(PubNo pubNo) throws IOException {
+        String pn = pubNo.getCountry() + pubNo.getNumber() + "." + pubNo.getKind();
+        //String param = new Gson().toJson(pn);
+        //RequestBody requestBody = RequestBody.create(MediaType.parse("application/json"), param);
+        OkHttpClient okHttpClient = new OkHttpClient.Builder()
+                .connectTimeout(60, TimeUnit.SECONDS)
+                .writeTimeout(60, TimeUnit.SECONDS)
+                .readTimeout(60, TimeUnit.SECONDS)
+                .build();
+        Request request = new Request.Builder()
+                .url(OPSUrl + "/api/OPSQuery/GetImagesInfo?Pn=" + pn)
+                .get()
+                .build();
+        return Objects.requireNonNull(okHttpClient.newCall(request).execute().body()).string();
+    }
+
+    /**
+     * 远程调用获取说明书的接口
+     *
+     * @return
+     */
+    public String getDescriptionInfo(GetDescriptionInfoParamsDTO getDescriptionInfoParamsDTO) throws IOException {
+        //String param = new Gson().toJson(getDescriptionInfoParamsDTO);
+        //RequestBody requestBody = RequestBody.create(MediaType.parse("application/json"), param);
+        OkHttpClient okHttpClient = new OkHttpClient.Builder()
+                .connectTimeout(60, TimeUnit.SECONDS)
+                .writeTimeout(60, TimeUnit.SECONDS)
+                .readTimeout(60, TimeUnit.SECONDS)
+                .build();
+        Request request = new Request.Builder()
+                .url(OPSUrl + "/api/OPSQuery/GetDescriptionInfo?cc=" + getDescriptionInfoParamsDTO.getCc() + "&number=" + getDescriptionInfoParamsDTO.getNumber() + "&kind=" + getDescriptionInfoParamsDTO.getKind())
+                .get()
+                .build();
+        return Objects.requireNonNull(okHttpClient.newCall(request).execute().body()).string();
+    }
+
+    /**
+     * 远程调用获取权要信息的接口
+     *
+     * @return
+     */
+    public String getClaimsInfo(GetClaimsInfoParamsDTO getClaimsInfoParamsDTO) throws IOException {
+        //String param = new Gson().toJson(getClaimsInfoParamsDTO);
+        //RequestBody requestBody = RequestBody.create(MediaType.parse("application/json"), param);
+        OkHttpClient okHttpClient = new OkHttpClient.Builder()
+                .connectTimeout(60, TimeUnit.SECONDS)
+                .writeTimeout(60, TimeUnit.SECONDS)
+                .readTimeout(60, TimeUnit.SECONDS)
+                .build();
+        Request request = new Request.Builder()
+                .url(OPSUrl + "/api/OPSQuery/GetClaimsInfo?cc=" + getClaimsInfoParamsDTO.getCc() + "&number=" + getClaimsInfoParamsDTO.getNumber() + "&kind=" + getClaimsInfoParamsDTO.getKind())
+                .get()
+                .build();
+        return Objects.requireNonNull(okHttpClient.newCall(request).execute().body()).string();
+    }
+
+    /**
+     * 远程调用获取一批专利著录的接口
+     *
+     * @return
+     */
+    public String getSearchBiblio(GetSearchBiblioParamsDTO getSearchBiblioParamsDTO) throws IOException {
+        //String param = new Gson().toJson(getSearchBiblioParamsDTO);
+        //RequestBody requestBody = RequestBody.create(MediaType.parse("application/json"), param);
+        OkHttpClient okHttpClient = new OkHttpClient.Builder()
+                .connectTimeout(60, TimeUnit.SECONDS)
+                .writeTimeout(60, TimeUnit.SECONDS)
+                .readTimeout(60, TimeUnit.SECONDS)
+                .build();
+        Request request = new Request.Builder()
+                .url(OPSUrl + "/api/OPSQuery/SearchBiblio?query=" + getSearchBiblioParamsDTO.getQuery() + "&start=" + getSearchBiblioParamsDTO.getStart() + "&end=" + getSearchBiblioParamsDTO.getEnd())
+                .get()
+                .build();
+        return Objects.requireNonNull(okHttpClient.newCall(request).execute().body()).string();
+    }
+
 }

+ 452 - 9
src/main/java/com/example/demo/service/UploadFromWebService.java

@@ -1,15 +1,20 @@
 package com.example.demo.service;
 
+import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
-import com.example.demo.base.Constants;
-import com.example.demo.domain.dto.UploadFileDTO;
+import com.example.demo.domain.dto.*;
 import com.example.demo.domain.entity.*;
+import com.example.demo.exception.XiaoShiException;
 import com.example.demo.model.dto.TaskWebSocketDTO;
 import com.example.demo.model.dto.WebQueryDTO;
 import com.example.demo.util.*;
+import com.spire.pdf.FileFormat;
+import com.spire.pdf.PdfDocument;
+import com.spire.pdf.PdfDocumentBase;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.fileupload.FileItem;
+import org.apache.commons.fileupload.disk.DiskFileItemFactory;
 import org.openqa.selenium.By;
 import org.openqa.selenium.WebDriver;
 import org.openqa.selenium.WebElement;
@@ -18,13 +23,14 @@ import org.openqa.selenium.chrome.ChromeOptions;
 import org.openqa.selenium.interactions.Actions;
 import org.openqa.selenium.support.ui.ExpectedConditions;
 import org.openqa.selenium.support.ui.WebDriverWait;
+import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.context.annotation.Lazy;
 import org.springframework.stereotype.Service;
+import org.springframework.web.multipart.MultipartFile;
+import org.springframework.web.multipart.commons.CommonsMultipartFile;
 
-import java.io.IOException;
-import java.math.BigDecimal;
-import java.text.DecimalFormat;
+import java.io.*;
 import java.util.*;
 import java.util.concurrent.TimeUnit;
 import java.util.regex.Matcher;
@@ -66,8 +72,6 @@ public class UploadFromWebService {
             //conditions = this.formatConditions(conditions);
             //根据id 获得网站配置
             WebConfig webConfig = webConfigService.getConfigById(id);
-            //根据网站id和用户的租户获得登录信息
-            WebLoginConfig webLoginConfig = webLoginConfigService.getLoginConfig(webConfig.getId());
             if (webConfig == null) {
                 qrtzTaskDetail.setTaskDetailState(3);
                 qrtzTaskDetail.setSuccessNum(successNum);
@@ -85,7 +89,10 @@ public class UploadFromWebService {
                         .setFileName("")
                         .setUrl("")
                         .setTotal(successNum), ResponseEnum.PATENT_IMPORT_TASK_SUCCESS), "null");
+                return null;
             }
+            //根据网站id和用户的租户获得登录信息
+            WebLoginConfig webLoginConfig = webLoginConfigService.getLoginConfig(webConfig.getId());
             //1.获得驱动
             //  System.setProperty("webdriver.chrome.driver", "D:\\driver\\chromedriver.exe");
             System.setProperty("webdriver.chrome.driver", url);
@@ -331,7 +338,7 @@ public class UploadFromWebService {
                             stringBuilder.append("\r\n");
                             for (int t = 1; t < textP1.size(); t++) {
                                 String tem = String.format("%04d", flag);
-                                stringBuilder.append("[" + tem + "]" + textP1.get(t).getText());
+                                stringBuilder.append("[").append(tem).append("]").append(textP1.get(t).getText());
                                 stringBuilder.append("\r\n");
                                 flag += 1;
                             }
@@ -497,6 +504,442 @@ public class UploadFromWebService {
         return patentCells;
     }
 
+    /**
+     * 下载欧专局专利数据
+     *
+     * @param webQueryDTO 前台传来的下载条件等数据
+     * @return 返回
+     * @throws IOException 抛出IO异常
+     */
+    public List<PatentCell> getEPO(WebQueryDTO webQueryDTO) throws Exception {
+        log.info("开始处理【下载欧专局专利数据】的业务,参数为:{}", webQueryDTO);
+        List<PatentCell> patentCells = new ArrayList<>();
+
+        //1.从DTO中取出网站id、检索信息条件、下载字段、专题库id、报告id
+        Integer webId = webQueryDTO.getWebConfigId();
+        List<String> cells = webQueryDTO.getConCells();
+        String conditions = webQueryDTO.getConditions();
+        Integer projectId = webQueryDTO.getProjectId();
+        Integer reportId = webQueryDTO.getReportId();
+
+        //定义每次检索的专利数量(每次检索50件)
+        int size = 50;
+
+        //2.根据检索式conditions先检索一件专利著录信息【此操作主要是为了获得专利总数量count】
+        SerachBiblioData serachBiblioData = getSerachBiblioData(conditions, 1, 1);
+        if (serachBiblioData == null || serachBiblioData.getTotals() == 0) {
+            //conditions没有检索到任何相关专利(杰哥处理)
+            ThrowException.throwXiaoShiException("检索失败,未检索出任何相关专利信息");
+        }
+
+        //获得专利总数量
+        Integer count = serachBiblioData.getTotals();
+
+        //3.根据专利总数量count计算检索次数,来循环检索
+        for (int i = 1; i <= count; i += size) {
+            //3.1根据检索式conditions、专利开始数i、专利最后数i + size - 1检索专利著录信息
+            serachBiblioData = getSerachBiblioData(conditions, i, i + size - 1);
+            //获取检索结果中的所有专利著录信息
+            if (serachBiblioData == null || serachBiblioData.getTotals() == 0) {
+                continue;
+            }
+            List<PatentZhuLu> patents = serachBiblioData.getPatents();
+
+            //3.2遍历专利
+            for (PatentZhuLu patent : patents) {
+                PatentCell patentCell = new PatentCell();
+                PubNo pubNO = new PubNo();
+                //装载专利著录
+                if (cells.contains("1")) {
+                    setPatentZhuLu(patentCell, patent, pubNO);
+                }
+                //装载权要
+                if (cells.contains("2")) {
+                    try {
+                        setPatentClaim(patentCell, pubNO);
+                    } catch (XiaoShiException e) {
+                        //权要接口不支持检索该国家类型专利则跳过该专利,继续下一个专利
+                        //continue;
+                        //虽然拿不到权要,但是可以拿其他的,能拿到啥都返回
+                        log.info(e.getMessage());
+                    }
+                }
+                //装载说明书文本
+                if (cells.contains("3")) {
+                    try {
+                        setPatentInstructionText(patentCell, pubNO);
+                    } catch (XiaoShiException e) {
+                        //说明书接口不支持检索该国家类型专利则跳过该专利,继续下一个专利
+                        //continue;
+                        //虽然拿不到说明书,但是可以拿其他的,能拿到啥都返回
+                        log.info(e.getMessage());
+                    }
+                }
+
+                //以下代码是在准备一会要调用拿取各种附图的接口所需的参数(FullDocument->说明书pdf、Drawing->其他附图、FirstPageClipping->摘要附图)
+                String fullDocumentLink = "", fullDocumentType = "", drawingLink = "", drawingType = "", firstPageClippingLink = "", firstPageClippingType = "";
+                Integer fullDocumentPage = 0, drawingPage = 0, firstPageClippingPage = 0;
+                //根据当前专利号调用接口获取一会调用拿取各种附图的接口的参数
+                try {
+                    ImageInfo imageInfo = getImage(pubNO);
+                    for (Image image : imageInfo.getImages()) {
+                        //如果附件类型是说明书
+                        if (image.getImageType().equals("FullDocument")) {
+                            fullDocumentLink = image.getUrlLink();
+                            fullDocumentPage = image.getNumberOfPages();
+                            for (String formatOption : image.getFormatOptions()) {
+                                if (formatOption.contains("pdf")) {
+                                    fullDocumentType = formatOption;
+                                }
+                            }
+                        }
+                        //如果附件类型是其他附件
+                        if (image.getImageType().equals("Drawing")) {
+                            drawingLink = image.getUrlLink();
+                            drawingPage = image.getNumberOfPages();
+                            for (String formatOption : image.getFormatOptions()) {
+                                if (formatOption.contains("tiff")) {
+                                    drawingType = formatOption;
+                                }
+                            }
+                        }
+                        //如果附件类型是摘要附图
+                        if (image.getImageType().equals("FirstPageClipping")) {
+                            firstPageClippingLink = image.getUrlLink();
+                            firstPageClippingPage = image.getNumberOfPages();
+                            for (String formatOption : image.getFormatOptions()) {
+                                if (formatOption.contains("jpeg")) {
+                                    firstPageClippingType = formatOption;
+                                }
+                            }
+                        }
+                    }
+
+                    //装载说明书pdf
+                    if (cells.contains("4")) {
+                        setFuJian(fullDocumentLink, fullDocumentPage, fullDocumentType, patentCell, ".pdf");
+                    }
+                    //装载摘要附图
+                    if (cells.contains("6")) {
+                        setFuJian(firstPageClippingLink, firstPageClippingPage, firstPageClippingType, patentCell, ".jpeg");
+                    }
+                    //装载其他附图
+                    if (cells.contains("7")) {
+                        setFuJian(drawingLink, drawingPage, drawingType, patentCell, ".tiff");
+                    }
+                } catch (XiaoShiException e) {
+                    //虽然拿不到所有附图,但是可以拿其他的,能拿到啥是啥
+                    log.info(e.getMessage());
+                }
+
+                //4.保存专利信息(发送给专题库)
+                patentCells.add(patentCell);
+            }
+        }
+
+        return patentCells;
+
+    }
+
+    /**
+     * 装载其他附件方法
+     *
+     * @param link       附件链接
+     * @param page       附件页数
+     * @param type       附件类型
+     * @param patentCell 实体类对象
+     */
+//    private void setOtherImage(String link, Integer page, String type, PatentCell patentCell) throws IOException {
+//        GetFuTuParamsDTO getFuTuParamsDTO = new GetFuTuParamsDTO()
+//                .setLink(link)
+//                .setPage(page)
+//                .setType(type);
+//        outInterfaceService.getPatentFile(getFuTuParamsDTO);
+//
+//    }
+
+    /**
+     * 装载摘要附图方法
+     *
+     * @param link       附件链接
+     * @param page       附件页数
+     * @param type       附件类型
+     * @param patentCell 实体类对象
+     */
+//    private void setAbstractImage(String link, Integer page, String type, PatentCell patentCell) throws IOException {
+//        GetFuTuParamsDTO getFuTuParamsDTO = new GetFuTuParamsDTO()
+//                .setLink(link)
+//                .setPage(page)
+//                .setType(type);
+//        outInterfaceService.getPatentFile(getFuTuParamsDTO);
+//
+//    }
+
+    /**
+     * 装载说明书附件pdf方法
+     *
+     * @param link       附件链接
+     * @param page       附件页数
+     * @param type       附件类型
+     * @param patentCell 实体类对象
+     */
+    private void setFuJian(String link, Integer page, String type, PatentCell patentCell, String FuJianSuffix) throws Exception {
+        //合并说明书pdf文档时所需的读取流数组
+        InputStream[] streams = new InputStream[page];
+        //其他附图url数组
+        ArrayList<String> otherUrls = new ArrayList<>();
+        //遍历附件页数
+        for (int i = 1; i <= page; i++) {
+            GetFuTuParamsDTO getFuTuParamsDTO = new GetFuTuParamsDTO()
+                    .setLink(link)
+                    .setPage(i)
+                    .setType(type);
+            byte[] buffer = outInterfaceService.getPatentFile(getFuTuParamsDTO);
+            InputStream inputStream = new ByteArrayInputStream(buffer);
+            streams[i - 1] = inputStream;
+//            File file = File.createTempFile("new_url", FuJianSuffix);
+//            FileOutputStream out = new FileOutputStream(file);
+//            out.write(buffer);
+//            out.close();
+//            streams[i - 1] = new FileInputStream(file);
+//            DiskFileItemFactory diskFileItemFactory = new DiskFileItemFactory(16, null);
+//            FileItem item = diskFileItemFactory.createItem(file.getName(), "text/plain", true, file.getName());
+//            int bytesRead = 0;
+//            buffer = new byte[8192];
+//            try {
+//                FileInputStream fis = new FileInputStream(file);
+//                OutputStream os = item.getOutputStream();
+//                int len = 8192;
+//                while ((bytesRead = fis.read(buffer, 0, len)) != -1) {
+//                    os.write(buffer, 0, bytesRead);
+//                }
+//                os.close();
+//                fis.close();
+//            } catch (IOException e) {
+//                e.printStackTrace();
+//            }
+//            MultipartFile multipartFile = new CommonsMultipartFile(item);
+//            UploadFileDTO fileDTO = fileUtils.uploadFile(multipartFile);
+//            switch (FuJianSuffix) {
+//                case ".pdf":
+//                    streams[i - 1] = new FileInputStream(fileDTO.getPath());
+//                    break;
+//                case ".jpeg":
+//                    patentCell.setPicUrl(fileDTO.getPath());
+//                    break;
+//                case ".tiff":
+//                    otherUrls.add(fileDTO.getPath());
+//                    break;
+//            }
+        }
+
+        if (FuJianSuffix.equals(".pdf")) {
+            //合并说明书多个pdf文件
+            PdfDocumentBase doc = PdfDocument.mergeFiles(streams);
+            //保存结果文件
+            doc.save("merge.pdf", FileFormat.PDF);
+            doc.close();
+        } else if (FuJianSuffix.equals(".tiff")) {
+            patentCell.setOtherUrls(otherUrls);
+        }
+
+
+    }
+
+    /**
+     * 获取Image信息方法(从信息中获取三种附图的检索参数)
+     *
+     * @param pubNo 公开号对象
+     */
+    private ImageInfo getImage(PubNo pubNo) throws IOException {
+        String res = outInterfaceService.getImagesInfo(pubNo);
+        JSONObject jsonObject = JSONObject.parseObject(res);
+        if (!jsonObject.get("status").toString().equals("200")) {
+            //若发生类似400、500等异常(杰哥处理)
+            ThrowException.throwXiaoShiException("Image信息接口无法检索该国家专利");
+        }
+        //拿到检索结果(未格式化的含有页面等标签的说明书)
+        String unFormatData = jsonObject.get("data").toString();
+        String data = unFormatData.substring(unFormatData.indexOf("[") + 1, unFormatData.lastIndexOf("]"));
+        ImageInfo imageInfo = JSONObject.parseObject(data, ImageInfo.class);
+        return imageInfo;
+    }
+
+    /**
+     * 装载说明书方法
+     *
+     * @param patentCell 实体类对象
+     * @param pubNo      公开号对象
+     */
+    private void setPatentInstructionText(PatentCell patentCell, PubNo pubNo) throws IOException {
+        GetDescriptionInfoParamsDTO getDescriptionInfoParamsDTO = new GetDescriptionInfoParamsDTO()
+                .setCc(pubNo.getCountry())
+                .setNumber(pubNo.getNumber())
+                .setKind(pubNo.getKind());
+        String res = outInterfaceService.getDescriptionInfo(getDescriptionInfoParamsDTO);
+        JSONObject jsonObject = JSONObject.parseObject(res);
+        if (!jsonObject.get("status").toString().equals("200")) {
+            //若发生类似400、500等异常(杰哥处理)
+            ThrowException.throwXiaoShiException("说明书接口无法检索该国家专利");
+        }
+        //拿到检索结果(未格式化的含有页面等标签的说明书)
+        //String unformatInstructionText = JSONObject.parseObject(jsonObject.get("data").toString(), String.class);
+        List<String> unformatInstructionText = JSONObject.parseObject(jsonObject.get("data").toString(), List.class);
+        StringBuilder builder = new StringBuilder();
+        for (String n : unformatInstructionText) {
+            builder.append(n);
+        }
+//        String regex = "<p>(.+?)</p>";
+//        Matcher matcher = Pattern.compile(regex).matcher(unformatInstructionText);
+//        if (matcher.find()) {
+//            patentCell.setPatentInstructionText(matcher.group());
+//        }
+        patentCell.setPatentInstructionText(builder + "");
+    }
+
+    /**
+     * 装载权要方法
+     *
+     * @param patentCell 实体类对象
+     * @param pubNo      公开号对象
+     */
+    private void setPatentClaim(PatentCell patentCell, PubNo pubNo) throws IOException {
+        GetClaimsInfoParamsDTO getClaimsInfoParamsDTO = new GetClaimsInfoParamsDTO()
+                .setCc(pubNo.getCountry())
+                .setNumber(pubNo.getNumber())
+                .setKind(pubNo.getKind());
+        String res = outInterfaceService.getClaimsInfo(getClaimsInfoParamsDTO);
+        JSONObject jsonObject = JSONObject.parseObject(res);
+        if (!jsonObject.get("status").toString().equals("200")) {
+            //若发生类似400、500等异常(杰哥处理)
+            ThrowException.throwXiaoShiException("权要接口无法检索该国家专利");
+        }
+        //拿到检索结果(未格式化的含有页面等标签的权要)并格式化权要
+        //String unformatRight = JSONObject.parseObject(jsonObject.get("data").toString(), String.class);
+        ArrayList<String> unformatRights = JSONObject.parseObject(jsonObject.get("data").toString(), ArrayList.class);
+        //String[] rightArr = unformatRight.split("\n");
+        //ArrayList<String> rights = new ArrayList<>(Arrays.asList(rightArr));
+        patentCell.setRights(unformatRights);
+    }
+
+    /**
+     * 装载著录方法
+     *
+     * @param patentCell 实体类对象
+     * @param patent     专利对象
+     * @param pubNo      公开号对象
+     */
+    private void setPatentZhuLu(PatentCell patentCell, PatentZhuLu patent, PubNo pubNo) {
+        //装载申请号
+        for (AppNo appNo : patent.getAppNos()) {
+            if (appNo.getType().equals("docdb")) {
+                patentCell.setApplicationNo(appNo.getCountry() + appNo.getNumber() + appNo.getKind());
+            }
+        }
+        //装载申请日
+        patentCell.setApplicationDate(patent.getAppDate());
+        //装载国家/省市
+        patentCell.setCountry(patent.getAppCountry());
+        //装载公开号
+        for (PubNo n : patent.getPubNos()) {
+            if (n.getType().equals("docdb")) {
+                BeanUtils.copyProperties(n, pubNo);
+                patentCell.setPublicNo(n.getCountry() + n.getNumber() + n.getKind());
+            }
+        }
+        //装载专利号
+        patentCell.setPatentNo(patentCell.getPublicNo());
+        //装载公开日
+        patentCell.setPubilcDate(patent.getPubDate());
+        //装载授权公告号(未找到)
+        //装载授权公告日(未找到)
+        //装载主分类号
+        List<String> ipCs = patent.getIpCs();
+        List<String> cpCs = patent.getCpCs();
+        ipCs.addAll(cpCs);
+        patentCell.setMainIpc(ipCs.get(0));
+        //装载分类号
+        patentCell.setIpc(ipCs);
+        //装载申请人
+        ArrayList<String> applicationPersons = new ArrayList<>();
+        for (Application application : patent.getApplications()) {
+            applicationPersons.add(application.getOriginalName());
+        }
+        patentCell.setApplicationPersons(applicationPersons);
+        //装载申请人地址(未找到)
+        //装载发明人
+        ArrayList<String> inventors = new ArrayList<>();
+        for (Inventor inventor : patent.getInventors()) {
+            inventors.add(inventor.getOriginalName());
+        }
+        patentCell.setInventors(inventors);
+        //装载当前权利人(未找到)
+        //装载代理人(未找到)
+        //装载代理机构(未找到)
+        //装载范畴分类(未找到)
+        //装载当前状态(未找到)
+        //装载同族号
+        patentCell.setFamilyId(patent.getFamilyId());
+        //装载著录标题
+        String olTitle = patent.getOlTitle();
+        String enTitle = patent.getEnTitle();
+        if (olTitle == null) {
+            patentCell.setTitle(enTitle);
+        } else {
+            patentCell.setTitle(olTitle);
+        }
+        //装载摘要
+        String olAbstract = patent.getOlAbstract();
+        String enAbstract = patent.getEnAbstract();
+        if (olAbstract == null) {
+            patentCell.setAbstrText(enAbstract);
+        } else {
+            patentCell.setAbstrText(olAbstract);
+        }
+        //装载优先权号、优先权国家、优先权日
+        ArrayList<Priority> priorities = new ArrayList<>();
+        List<Priorityy> priorties = patent.getPriorties();
+        for (Priorityy priorty : priorties) {
+            for (PriorityNumber number : priorty.getNumbers()) {
+                if (number.getType().equals("epodoc")) {
+                    Priority priority = new Priority()
+                            .setPriorityNo(number.getNumber().substring(2))
+                            .setPriorityCountry(number.getNumber().substring(0, 2))
+                            .setPriorityDate(priorty.getDate());
+                    priorities.add(priority);
+                }
+            }
+        }
+        patentCell.setPriorities(priorities);
+    }
+
+    //调用接口获取一批专利著录信息
+    private SerachBiblioData getSerachBiblioData(String conditions, Integer start, Integer size) throws IOException {
+        GetSearchBiblioParamsDTO getSearchBiblioParamsDTO = new GetSearchBiblioParamsDTO()
+                .setQuery(conditions)
+                .setStart(start)
+                .setEnd(size);
+        String res = outInterfaceService.getSearchBiblio(getSearchBiblioParamsDTO);
+        if (res == null || res.equals("")) {
+            return null;
+        }
+        JSONObject jsonObject = JSONObject.parseObject(res);
+        if (!jsonObject.get("status").toString().equals("200")) {
+            //若发生类似400、500等异常(杰哥处理)
+            return null;
+        }
+        //返回检索结果data
+        return JSONObject.parseObject(jsonObject.get("data").toString(), SerachBiblioData.class);
+    }
+
+    /**
+     * 下载爬取智慧芽专利数据
+     *
+     * @param patentVO
+     * @return
+     * @throws IOException
+     * @throws InterruptedException
+     */
     public List<PatentCell> getPatentya(String patentVO) throws IOException, InterruptedException {
         //1.获得驱动
         System.setProperty("webdriver.chrome.driver", "D:\\driver\\chromedriver.exe");

+ 33 - 31
src/main/java/com/example/demo/service/WebLoginConfigService.java

@@ -29,49 +29,51 @@ import java.util.List;
 @Service
 @RequiredArgsConstructor(onConstructor_ = {@Lazy})
 public class WebLoginConfigService extends ServiceImpl<WebLoginConfigMapper, WebLoginConfig> {
-    private final CacheUtils cacheUtils ;
-    private final LoginUtils  loginUtils;
-//添加配置
-    public void addLoginConfig(ConfigDTO configDTO){
+    private final CacheUtils cacheUtils;
+    private final LoginUtils loginUtils;
+
+    //添加配置
+    public void addLoginConfig(ConfigDTO configDTO) {
         PersonnelVO personnelVO = cacheUtils.getLoginUserPersonnel(loginUtils.getId());
-        LambdaQueryWrapper<WebLoginConfig> wrapper =new LambdaQueryWrapper<>();
-        wrapper.eq(WebLoginConfig::getWebId,configDTO.getWebId())
-                .eq(WebLoginConfig::getTenantId,personnelVO.getTenantId());
-        List<WebLoginConfig> configs =this.list(wrapper);
-        WebLoginConfig config =new WebLoginConfig();
-        if(configs.size()>0){
-            config =configs.get(0);
+        LambdaQueryWrapper<WebLoginConfig> wrapper = new LambdaQueryWrapper<>();
+        wrapper.eq(WebLoginConfig::getWebId, configDTO.getWebId())
+                .eq(WebLoginConfig::getTenantId, personnelVO.getTenantId());
+        List<WebLoginConfig> configs = this.list(wrapper);
+        WebLoginConfig config = new WebLoginConfig();
+        if (configs.size() > 0) {
+            config = configs.get(0);
         }
-       config.setWebId(configDTO.getWebId());
-       config.setTenantId(personnelVO.getTenantId());
-       config.setLoginAccount(configDTO.getLoginAccount());
-       config.setLoginPassword(configDTO.getLoginPassword());
-       this.saveOrUpdate(config);
+        config.setWebId(configDTO.getWebId());
+        config.setTenantId(personnelVO.getTenantId());
+        config.setLoginAccount(configDTO.getLoginAccount());
+        config.setLoginPassword(configDTO.getLoginPassword());
+        this.saveOrUpdate(config);
     }
-    public WebLoginConfig getLoginConfig(Integer webId){
+
+    public WebLoginConfig getLoginConfig(Integer webId) {
         PersonnelVO personnelVO = cacheUtils.getLoginUserPersonnel(loginUtils.getId());
-        LambdaQueryWrapper<WebLoginConfig> wrapper =new LambdaQueryWrapper<>();
-        wrapper.eq(WebLoginConfig::getWebId,webId)
-                .eq(WebLoginConfig::getTenantId,personnelVO.getTenantId());
-        List<WebLoginConfig> configs =this.list(wrapper);
-        WebLoginConfig config =new WebLoginConfig();
-        if(configs.size()>0){
-            config =configs.get(0);
+        LambdaQueryWrapper<WebLoginConfig> wrapper = new LambdaQueryWrapper<>();
+        wrapper.eq(WebLoginConfig::getWebId, webId)
+                .eq(WebLoginConfig::getTenantId, personnelVO.getTenantId());
+        List<WebLoginConfig> configs = this.list(wrapper);
+        WebLoginConfig config = new WebLoginConfig();
+        if (configs.size() > 0) {
+            config = configs.get(0);
+        } else {
+            config = null;
         }
-        else {
-            config=null;
-        }
-      return config;
+        return config;
     }
 
-   public IPage<ConfigVO> queryLoginConfig(QueryConfigVO queryConfigVO){
+    public IPage<ConfigVO> queryLoginConfig(QueryConfigVO queryConfigVO) {
         PersonnelVO personnelVO = cacheUtils.getLoginUserPersonnel(loginUtils.getId());
         queryConfigVO.setTenantId(personnelVO.getTenantId());
         IPage<ConfigVO> dataPage = baseMapper.getPageList(new Page<>(queryConfigVO.getCurrent(), queryConfigVO.getSize()), queryConfigVO);
         return dataPage;
     }
-    public Boolean deleteConfig(List<Integer> ids){
-      return   this.removeByIds(ids);
+
+    public Boolean deleteConfig(List<Integer> ids) {
+        return this.removeByIds(ids);
     }
 
 }

+ 15 - 15
src/main/java/com/example/demo/util/FileUtils.java

@@ -131,7 +131,7 @@ public class FileUtils {
             FileInputStream fis = new FileInputStream(file);
             OutputStream os = item.getOutputStream();
             int len = 8192;
-            while ((bytesRead = fis.read(buffer, 0, len)) != -1){
+            while ((bytesRead = fis.read(buffer, 0, len)) != -1) {
                 os.write(buffer, 0, bytesRead);
             }
             os.close();
@@ -139,11 +139,12 @@ public class FileUtils {
         } catch (IOException e) {
             e.printStackTrace();
         }
-        return (MultipartFile)new CommonsMultipartFile(item);
+        return (MultipartFile) new CommonsMultipartFile(item);
     }
-    public static File getFile(String url,String type) throws Exception {
+
+    public static File getFile(String url, String type) throws Exception {
         //读取图片类型
-        String fileName = url.substring(url.lastIndexOf("."),url.length());
+        String fileName = url.substring(url.lastIndexOf("."), url.length());
         File file = null;
 
         URL urlfile;
@@ -191,7 +192,7 @@ public class FileUtils {
 
     /**
      * @param fileUrl 资源地址
-     * @param tmpFile  临时文件
+     * @param tmpFile 临时文件
      * @Description: 网络资源转file, 用完以后必须删除该临时文件
      * @return: 返回值
      */
@@ -229,8 +230,8 @@ public class FileUtils {
         return savedFile;
     }
 
-    public static MultipartFile urlToMultipartFile(String  url,String type) throws Exception {
-        File file =FileUtils.getFile(url,type);
+    public static MultipartFile urlToMultipartFile(String url, String type) throws Exception {
+        File file = FileUtils.getFile(url, type);
         DiskFileItemFactory diskFileItemFactory = new DiskFileItemFactory(16, null);
         FileItem item = diskFileItemFactory.createItem(file.getName(), "text/plain", true, file.getName());
         int bytesRead = 0;
@@ -239,7 +240,7 @@ public class FileUtils {
             FileInputStream fis = new FileInputStream(file);
             OutputStream os = item.getOutputStream();
             int len = 8192;
-            while ((bytesRead = fis.read(buffer, 0, len)) != -1){
+            while ((bytesRead = fis.read(buffer, 0, len)) != -1) {
                 os.write(buffer, 0, bytesRead);
             }
             os.close();
@@ -247,19 +248,19 @@ public class FileUtils {
         } catch (IOException e) {
             e.printStackTrace();
         }
-        return (MultipartFile)new CommonsMultipartFile(item);
+        return (MultipartFile) new CommonsMultipartFile(item);
     }
 
 
-    public  UploadFileDTO uploadToLocal(String  url,String type) throws Exception {
-        MultipartFile file = FileUtils.urlToMultipartFile(url,type);
+    public UploadFileDTO uploadToLocal(String url, String type) throws Exception {
+        MultipartFile file = FileUtils.urlToMultipartFile(url, type);
         UploadFileDTO fileDTO = fileUtils.uploadFile(file);
-     return  fileDTO;
+        return fileDTO;
 
     }
 
     public static String readerMethod() throws IOException {
-       String ah= FileUtils.getStaticPath("setting.json");
+        String ah = FileUtils.getStaticPath("setting.json");
         File file = new File(ah);
         FileReader fileReader = new FileReader(file);
         Reader reader = new InputStreamReader(new FileInputStream(file), "Utf-8");
@@ -271,10 +272,9 @@ public class FileUtils {
         fileReader.close();
         reader.close();
         String jsonStr = sb.toString();
-       return jsonStr;
+        return jsonStr;
     }
 
 
-
 }
 

+ 18 - 0
src/main/java/com/example/demo/util/ThrowException.java

@@ -0,0 +1,18 @@
+package com.example.demo.util;
+
+import com.example.demo.exception.XiaoShiException;
+import lombok.extern.slf4j.Slf4j;
+
+/**
+ * @Author chenyu
+ * @Date 2023/4/2
+ */
+@Slf4j
+public class ThrowException {
+
+    public static void throwXiaoShiException(String message) {
+        log.info("{}", message);
+        throw new XiaoShiException(message);
+    }
+
+}

+ 2 - 1
src/main/resources/application-dev.yml

@@ -55,9 +55,10 @@ spring:
     job-store-type: jdbc
     #初始化表结构
     jdbc:
-      initialize-schema: never
+      initialize-schema: always
 PCSUrl: http://localhost:8879
 PASUrl: http://localhost:8877
+OPSUrl: http://192.168.1.24:5001
 mybatis-plus:
   mapper-locations: classpath:mapper/*.xml
 logging: