Browse Source

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	src/test/java/cn/cslg/pas/service/EsServiceTests.java
xiexiang 1 year ago
parent
commit
f03d75f37e
41 changed files with 2509 additions and 74 deletions
  1. 17 0
      src/main/java/cn/cslg/pas/common/dto/ConfigDTO.java
  2. 47 0
      src/main/java/cn/cslg/pas/common/dto/PatentStarDTO.java
  3. 59 0
      src/main/java/cn/cslg/pas/common/dto/PatentStarListDTO.java
  4. 31 0
      src/main/java/cn/cslg/pas/common/dto/RetrieveRecordDTO.java
  5. 12 0
      src/main/java/cn/cslg/pas/common/dto/RetrieveRecordDeDTO.java
  6. 21 0
      src/main/java/cn/cslg/pas/common/dto/RetrieveRecordQueryDTO.java
  7. 4 0
      src/main/java/cn/cslg/pas/common/utils/DateUtils.java
  8. 18 0
      src/main/java/cn/cslg/pas/common/utils/MathUtils.java
  9. 2 1
      src/main/java/cn/cslg/pas/common/utils/ResponseEnum.java
  10. 112 0
      src/main/java/cn/cslg/pas/common/utils/WebSocketServer.java
  11. 17 0
      src/main/java/cn/cslg/pas/common/vo/ConfigVO.java
  12. 59 2
      src/main/java/cn/cslg/pas/common/vo/ImportTaskAMVO.java
  13. 21 0
      src/main/java/cn/cslg/pas/common/vo/QueryConfigVO.java
  14. 145 0
      src/main/java/cn/cslg/pas/common/vo/StarPatentVO.java
  15. 31 0
      src/main/java/cn/cslg/pas/common/vo/TaskWebSocketDTO.java
  16. 115 0
      src/main/java/cn/cslg/pas/controller/ImportTaskController.java
  17. 43 0
      src/main/java/cn/cslg/pas/domain/WebLoginConfig.java
  18. 45 0
      src/main/java/cn/cslg/pas/domain/business/AssoImportTaskField.java
  19. 2 2
      src/main/java/cn/cslg/pas/domain/business/AssoTaskField.java
  20. 6 0
      src/main/java/cn/cslg/pas/domain/business/ImportTask.java
  21. 60 0
      src/main/java/cn/cslg/pas/domain/business/RetrieveRecord.java
  22. 3 0
      src/main/java/cn/cslg/pas/domain/es/Patent.java
  23. 32 0
      src/main/java/cn/cslg/pas/domain/es/PatentJoin.java
  24. 16 0
      src/main/java/cn/cslg/pas/mapper/AssoImportTaskFieldMapper.java
  25. 16 0
      src/main/java/cn/cslg/pas/mapper/RetrieveRecordMapper.java
  26. 25 0
      src/main/java/cn/cslg/pas/mapper/WebLoginConfigMapper.java
  27. 83 0
      src/main/java/cn/cslg/pas/service/WebLoginConfigService.java
  28. 13 0
      src/main/java/cn/cslg/pas/service/business/AssoImportTaskFieldService.java
  29. 79 25
      src/main/java/cn/cslg/pas/service/business/es/EsService.java
  30. 53 0
      src/main/java/cn/cslg/pas/service/common/MessageService.java
  31. 783 0
      src/main/java/cn/cslg/pas/service/common/PatentStarApiService.java
  32. 123 0
      src/main/java/cn/cslg/pas/service/common/RetrieveRecordService.java
  33. 36 11
      src/main/java/cn/cslg/pas/service/importPatent/GetPatentFromExcelThread.java
  34. 285 0
      src/main/java/cn/cslg/pas/service/importPatent/ImportFromWebToEsService.java
  35. 54 12
      src/main/java/cn/cslg/pas/service/importPatent/SavePatentToEsThread.java
  36. 4 1
      src/main/java/cn/cslg/pas/service/importPatent/SchedulingTaskService.java
  37. 0 1
      src/main/java/cn/cslg/pas/service/importPatent/TaskThread.java
  38. 23 0
      src/main/resources/mapper/WebLoginConfigMapper.xml
  39. 10 8
      src/test/java/cn/cslg/pas/service/CommonServiceTests.java
  40. 4 7
      src/test/java/cn/cslg/pas/service/EsServiceTests.java
  41. 0 4
      src/test/java/cn/cslg/pas/service/EventServiceTests.java

+ 17 - 0
src/main/java/cn/cslg/pas/common/dto/ConfigDTO.java

@@ -0,0 +1,17 @@
+package cn.cslg.pas.common.dto;
+
+import lombok.Data;
+
+@Data
+public class ConfigDTO {
+
+    private String loginAccount;
+
+    private String loginPassword;
+
+    private Integer tenantId;
+
+    private Integer webId;
+
+
+}

+ 47 - 0
src/main/java/cn/cslg/pas/common/dto/PatentStarDTO.java

@@ -0,0 +1,47 @@
+package cn.cslg.pas.common.dto;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+/**
+ * 专利之星检索dto类
+ *
+ * @author 李仁杰
+ */
+
+@Accessors(chain = true)
+@Data
+public class PatentStarDTO {
+    /**
+     * 检索式
+     */
+    @JsonProperty(value = "CurrentQuery")
+    private String CurrentQuery;
+    /**
+     * 表示检索中文库或世界库(CN中文专利库 WD世界专利库)
+     */
+    @JsonProperty(value = "DBType")
+    private String DBType;
+    /**
+     * 当前页,最多 200 页
+     */
+    @JsonProperty(value = "PageNum")
+    private Integer PageNum;
+    /**
+     * 每页条数,最多 50 条
+     */
+    @JsonProperty(value = "RowCount")
+    private Integer RowCount;
+    /**
+     * 排序字段:“AD”,“PD”,“GD”, “ID”
+     */
+    @JsonProperty(value = "OrderBy")
+    private String OrderBy;
+    /**
+     * 排序方式:“ASC”,“DESC”
+     */
+    @JsonProperty(value = "OrderByType")
+    private String OrderByType;
+
+}

+ 59 - 0
src/main/java/cn/cslg/pas/common/dto/PatentStarListDTO.java

@@ -0,0 +1,59 @@
+package cn.cslg.pas.common.dto;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.Data;
+import lombok.experimental.Accessors;
+import org.joda.time.DateTime;
+
+/**
+ * 专利之星检索dto类
+ *
+ * @author 李仁杰
+ */
+
+@Accessors(chain = true)
+@Data
+public class PatentStarListDTO {
+    private Integer retrieveRecordId;
+    /**
+     * 检索式
+     */
+    @JsonProperty(value = "CurrentQuery")
+    private String CurrentQuery;
+    /**
+     * 表示检索中文库或世界库(CN中文专利库 WD世界专利库)
+     */
+    @JsonProperty(value = "DBType")
+    private String DBType;
+    /**
+     * 当前页,最多 200 页
+     */
+    @JsonProperty(value = "PageNum")
+    private Integer PageNum;
+    /**
+     * 每页条数,最多 50 条
+     */
+    @JsonProperty(value = "RowCount")
+    private Integer RowCount;
+    /**
+     * 排序字段:“AD”,“PD”,“GD”, “ID”
+     */
+    @JsonProperty(value = "OrderBy")
+    private String OrderBy;
+    /**
+     * 排序方式:“ASC”,“DESC”
+     */
+    @JsonProperty(value = "OrderByType")
+    private String OrderByType;
+
+    private Integer total;
+
+    private DateTime startTime;
+
+    private DateTime endTime;
+
+    private String orginCondition;
+
+    private Boolean formed;
+
+}

+ 31 - 0
src/main/java/cn/cslg/pas/common/dto/RetrieveRecordDTO.java

@@ -0,0 +1,31 @@
+package cn.cslg.pas.common.dto;
+
+import lombok.Data;
+
+import java.util.Date;
+
+@Data
+public class RetrieveRecordDTO {
+
+    private Integer id;
+    /**
+     * 检索式
+     */
+    private String conditions;
+    /**
+     * 数据库类型
+     */
+    private String dbType;
+
+    /**
+     * 检索时间
+     */
+    private Date retrieveTime;
+
+    /**
+     * 更新时间
+     */
+    private Date updateTime;
+
+    private Integer totalNum;
+}

+ 12 - 0
src/main/java/cn/cslg/pas/common/dto/RetrieveRecordDeDTO.java

@@ -0,0 +1,12 @@
+package cn.cslg.pas.common.dto;
+
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class RetrieveRecordDeDTO {
+
+    private List<Integer> ids;
+    private Boolean isAll;
+}

+ 21 - 0
src/main/java/cn/cslg/pas/common/dto/RetrieveRecordQueryDTO.java

@@ -0,0 +1,21 @@
+package cn.cslg.pas.common.dto;
+
+import lombok.Data;
+
+@Data
+public class RetrieveRecordQueryDTO {
+    /**
+     * 每页条数
+     */
+    private Integer size;
+
+    /**
+     * 当前页数
+     */
+    private Integer current;
+
+    /**
+     * 数据总数
+     */
+    private Integer total;
+}

+ 4 - 0
src/main/java/cn/cslg/pas/common/utils/DateUtils.java

@@ -663,4 +663,8 @@ public class DateUtils {
         calendar.set(Calendar.SECOND, 0);
         calendar.set(Calendar.SECOND, 0);
         return calendar.getTime();
         return calendar.getTime();
     }
     }
+
+
+
+
 }
 }

+ 18 - 0
src/main/java/cn/cslg/pas/common/utils/MathUtils.java

@@ -13,5 +13,23 @@ public class MathUtils {
         value = bd.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
         value = bd.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
         return value;
         return value;
     }
     }
+    public static String fun(int n,int num) {
+        // n 表示目标进制, num 要转换的值
+        String str= "";
+        int yushu ;      // 保存余数
+        int shang = num;      // 保存商
+        while (shang>0) {
+            yushu = shang %n;
+            shang = shang/n;
 
 
+            // 10-15 -> a-f
+            if(yushu>9) {
+                str =(char)('a'+(yushu-10)) + str;
+            }else {
+                str = yushu+str;
+            }
+        }
+
+        return str;
+    }
 }
 }

+ 2 - 1
src/main/java/cn/cslg/pas/common/utils/ResponseEnum.java

@@ -10,7 +10,8 @@ public enum ResponseEnum {
     ERROR(0, "请求失败"),
     ERROR(0, "请求失败"),
     NO_PERMISSION(201,"无权限"),
     NO_PERMISSION(201,"无权限"),
     PARAMS_ERROR(202,"参数错误"),
     PARAMS_ERROR(202,"参数错误"),
-    CONDITION_ERROR(203, "检索式错误")
+    CONDITION_ERROR(203, "检索式错误"),
+    PATENT_IMPORT_TASK_SUCCESS(903, "WebSocket请求成功")
     ;
     ;
 
 
     private Integer code;
     private Integer code;

+ 112 - 0
src/main/java/cn/cslg/pas/common/utils/WebSocketServer.java

@@ -0,0 +1,112 @@
+package cn.cslg.pas.common.utils;
+
+import cn.cslg.pas.common.core.base.Constants;
+import jakarta.websocket.*;
+import jakarta.websocket.server.PathParam;
+import jakarta.websocket.server.ServerEndpoint;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Component;
+
+import java.io.IOException;
+import java.util.concurrent.CopyOnWriteArraySet;
+
+@Slf4j
+@Component
+@ServerEndpoint(Constants.API_XiaoSHI + "/ws/{sid}")
+public class WebSocketServer {
+
+    //静态变量,用来记录当前在线连接数。应该把它设计成线程安全的。
+    private static int onlineCount = 0;
+    //concurrent包的线程安全Set,用来存放每个客户端对应的MyWebSocket对象。
+    private static CopyOnWriteArraySet<WebSocketServer> webSocketSet
+            = new CopyOnWriteArraySet<WebSocketServer>();
+    //与某个客户端的连接会话,需要通过它来给客户端发送数据
+    private Session session;
+    //接收sid
+    private String sid = "";
+
+    /**
+     * 连接建立成功调用的方法
+     */
+    @OnOpen
+    public void onOpen(Session session, @PathParam("sid") String sid) {
+        this.session = session;
+        webSocketSet.add(this);     //加入set中
+        addOnlineCount();           //在线数加1
+        log.info("有新窗口开始监听:" + sid + ",当前在线人数为" + getOnlineCount());
+        this.sid = sid;
+        try {
+            sendMessage(Response.success("连接成功").toString());
+        } catch (IOException e) {
+            log.error("websocket IO异常");
+        }
+    }
+
+    /**
+     * 连接关闭调用的方法
+     */
+    @OnClose
+    public void onClose() {
+        webSocketSet.remove(this);  //从set中删除
+        subOnlineCount();           //在线数减1
+        log.info("有一连接关闭!当前在线人数为" + getOnlineCount());
+    }
+
+    /**
+     * 收到客户端消息后调用的方法
+     *
+     * @param message 客户端发送过来的消息
+     */
+    @OnMessage
+    public void onMessage(String message, Session session) {
+        log.info("收到来自窗口" + sid + "的信息:" + message);
+        //群发消息
+        for (WebSocketServer item : webSocketSet) {
+            try {
+                item.sendMessage(message);
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+    }
+
+    @OnError
+    public void onError(Session session, Throwable error) {
+        log.error("发生错误");
+        error.printStackTrace();
+    }
+
+    //实现服务器主动推送
+    public synchronized void sendMessage(String message) throws IOException {
+        this.session.getBasicRemote().sendText(message);
+    }
+
+    //群发自定义消息
+    public synchronized static void sendInfo(String message, @PathParam("sid") String sid) {
+        log.info("推送消息到窗口" + sid + ",推送内容:" + message);
+        for (WebSocketServer item : webSocketSet) {
+            try {
+                //这里可以设定只推送给这个sid的,为null则全部推送
+                if (sid == null || "null".equals(sid)) {
+                    item.sendMessage(message);
+                } else if (item.sid.equals(sid)) {
+                    item.sendMessage(message);
+                }
+            } catch (IOException e) {
+                continue;
+            }
+        }
+    }
+
+    public static synchronized int getOnlineCount() {
+        return onlineCount;
+    }
+
+    public static synchronized void addOnlineCount() {
+        WebSocketServer.onlineCount++;
+    }
+
+    public static synchronized void subOnlineCount() {
+        WebSocketServer.onlineCount--;
+    }
+}

+ 17 - 0
src/main/java/cn/cslg/pas/common/vo/ConfigVO.java

@@ -0,0 +1,17 @@
+package cn.cslg.pas.common.vo;
+
+import lombok.Data;
+
+@Data
+public class ConfigVO {
+
+    private String loginAccount;
+
+    private String loginPassword;
+
+    private String webAddress;
+
+    private String webName;
+    private Integer id;
+    private Integer webId;
+}

+ 59 - 2
src/main/java/cn/cslg/pas/common/vo/ImportTaskAMVO.java

@@ -1,5 +1,6 @@
 package cn.cslg.pas.common.vo;
 package cn.cslg.pas.common.vo;
 
 
+import com.baomidou.mybatisplus.annotation.TableField;
 import lombok.Data;
 import lombok.Data;
 
 
 import java.util.List;
 import java.util.List;
@@ -9,11 +10,67 @@ import java.util.List;
  */
  */
 @Data
 @Data
 public class ImportTaskAMVO {
 public class ImportTaskAMVO {
+    /**
+     * 查询条件
+     */
+    private String condition;
+    /**
+     * 任务id
+     */
     private Integer id;
     private Integer id;
     private String fileGuid;
     private String fileGuid;
-    private Integer type;
+
+    /**
+     * 导入总条数
+     */
     private Integer allNum;
     private Integer allNum;
+
+    /**
+     * 进度
+     */
+    private Double progress;
+
+    /**
+     * 完成条数
+     */
     private Integer successNum;
     private Integer successNum;
-    private Integer   sourceId;
 
 
+    /**
+     * 失败条数
+     */
+    private Integer defaultNum;
+    /**
+     * 任务类型
+     * 1.excel导入 2.专利号导入 3.专利号文件导入 4.检索导入 5.pdf文档导入
+     */
+    private Integer type;
+
+    /**
+     * 状态
+     */
+    private Integer state;
+    private Integer sourceId;
+    /**
+     * 报告或数据库id
+     */
+    private Integer projectId;
+
+    /**
+     * 产品id
+     */
+    private Integer productId;
+
+    /**
+     * 若是检索导入/专利号导入则必填
+     * 五位数字
+     * 第1著录项目2附图
+     * 3权利要求,4说明书文本,5pdf文档
+     */
+    private Integer importContent;
+
+    private  Integer status;
+    private Integer endNum;
+    private String orderBy;
+    private  String orderByType;
+    private String DBType;
 }
 }

+ 21 - 0
src/main/java/cn/cslg/pas/common/vo/QueryConfigVO.java

@@ -0,0 +1,21 @@
+package cn.cslg.pas.common.vo;
+
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+/**
+ * @author 沈永艺
+ * @date 2022-8-3
+ * @description VO基类
+ */
+
+@Data
+@Accessors(chain = true)
+public class QueryConfigVO {
+    private Integer tenantId;
+    private Integer webId;
+    private String loginAccount;
+    private Long current;
+    private Long size;
+
+}

+ 145 - 0
src/main/java/cn/cslg/pas/common/vo/StarPatentVO.java

@@ -0,0 +1,145 @@
+package cn.cslg.pas.common.vo;
+
+import cn.cslg.pas.common.model.importTaskModel.PatentAgent;
+import cn.cslg.pas.common.model.importTaskModel.PatentApplicant;
+import cn.cslg.pas.common.model.importTaskModel.PatentInventor;
+import com.alibaba.fastjson.annotation.JSONField;
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+import java.util.List;
+
+@Accessors(chain = true)
+@Data
+public class StarPatentVO implements Serializable {
+    /**
+     * 原始申请号
+     */
+    @JSONField(name = "ANO")
+    private String rowApplicationNo;
+    /**
+     * 专利类型(1和8为发明 2和9为新型 3为外观)
+     */
+    @JSONField(name = "PT")
+    private Integer patentType;
+    /**
+     * 专利类型
+     */
+    private String type;
+    /**
+     * 申请人地址
+     */
+    @JSONField(name = "DZ")
+    private String applicationAddress;
+    /**
+     * 主分类号
+     */
+    @JSONField(name = "MC")
+    private String mainIpc;
+    /**
+     * IPC分类号
+     */
+    @JSONField(name = "IC")
+    private String ipcListStr;
+    /**
+     * 公告日
+     */
+    @JSONField(name = "GD")
+    private String publicAccreditDate;
+    /**
+     * 摘要
+     */
+    @JSONField(name = "AB")
+    private String abstractStr;
+    /**
+     * 申请日
+     */
+    @JSONField(name = "AD")
+    private String applicationDate;
+    /**
+     * 发明人
+     */
+    @JSONField(name = "IN")
+    private String inventorStr;
+    /**
+     * 专利号
+     */
+    private String patentNo;
+    /**
+     * 公告号
+     */
+    @JSONField(name = "GN")
+    private String publicAccreditNo;
+    /**
+     * 代理机构
+     */
+    @JSONField(name = "AGN")
+    private String agencyStr;
+    /**
+     * 申请号
+     */
+    @JSONField(name = "AN")
+    private String applicationNo;
+    /**
+     * 申请人
+     */
+    @JSONField(name = "PA")
+    private String applicantStr;
+    /**
+     * 代理人
+     */
+    @JSONField(name = "AT")
+    private String agentStr;
+    /**
+     * 公开日
+     */
+    @JSONField(name = "PD")
+    private String publicDate;
+    /**
+     * 标题
+     */
+    @JSONField(name = "TI")
+    private String name;
+    /**
+     * 权利人
+     */
+    @JSONField(name = "PE")
+    private String currentApplicantStr;
+    /**
+     * 法律状态
+     */
+    @JSONField(name = "LG")
+    private Integer LG;
+    /**
+     * 公开号
+     */
+    @JSONField(name = "PN")
+    private String publicNo;
+    /**
+     * 受理局
+     */
+    @JSONField(name = "GJ")
+    private String bureau;
+    /**
+     * 优先权
+     */
+    @JSONField(name = "PR")
+    private String priorityNo;
+    /**
+     * 优先权日
+     */
+    @JSONField(name = "PRD")
+    private String priorityDate;
+
+    private List<PatentInventor> inventor;
+    private List<String> ipcList;
+    private List<PatentApplicant> applicant;
+//    private PatentAgency agency;
+    private List<PatentAgent> agent;
+    private String simpleStatus;
+    /**
+     * 摘要附图路径
+     */
+    private String abstractPath;
+}

+ 31 - 0
src/main/java/cn/cslg/pas/common/vo/TaskWebSocketDTO.java

@@ -0,0 +1,31 @@
+package cn.cslg.pas.common.vo;
+
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+@Data
+@Accessors(chain = true)
+public class TaskWebSocketDTO {
+    /**
+     * 专题库id
+     */
+    private Integer projectId;
+    /**
+     * 报告id
+     */
+    private Integer reportId;
+    /**
+     * 产品id
+     */
+    private Integer productId;
+    private Integer total;
+    private Integer index;
+    private Integer taskId;
+    private Integer taskStatus;
+    private Boolean complete;
+    private String url;
+    private String fileName;
+    private Integer taskType;
+    private Long percentage;
+    private String oldName;
+}

+ 115 - 0
src/main/java/cn/cslg/pas/controller/ImportTaskController.java

@@ -0,0 +1,115 @@
+package cn.cslg.pas.controller;
+
+
+import cn.cslg.pas.common.core.base.Constants;
+import cn.cslg.pas.common.dto.AddSelfFieldDTO;
+import cn.cslg.pas.common.model.cronModel.Records;
+import cn.cslg.pas.common.utils.Response;
+import cn.cslg.pas.common.utils.StringUtils;
+import cn.cslg.pas.common.vo.EntityVO;
+import cn.cslg.pas.common.vo.PersonSelfFieldVO;
+import cn.cslg.pas.domain.business.SystemDict;
+import cn.cslg.pas.service.business.AssoScenarioMatterService;
+import cn.cslg.pas.service.business.CommonService;
+import cn.cslg.pas.service.business.ScenarioService;
+import cn.cslg.pas.service.business.SystemDictService;
+import cn.cslg.pas.service.common.PersonFieldService;
+import io.swagger.v3.oas.annotations.Operation;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+@Slf4j
+@RequestMapping(Constants.API_XiaoSHI + "/importTask")
+@RestController
+public class ImportTaskController {
+    @Autowired
+    private SystemDictService systemDictService;
+    @Autowired
+    private CommonService commonService;
+    @Autowired
+    private ScenarioService scenarioService;
+    @Autowired
+    private AssoScenarioMatterService assoScenarioMatterService;
+
+    @Autowired
+    private PersonFieldService personFieldService;
+    @PostMapping("getParams")
+    @Operation(summary = "获得实体类栏位信息")
+    public Response getQueryConditions(@RequestBody List<String> tables) {
+        List<EntityVO> vos = commonService.getQueryConditions(tables);
+        return Response.success(vos);
+    }
+
+    @GetMapping("data")
+    @Operation(summary = "通用数据")
+    public Object getCommonData(String keys) {
+        List<String> typeList = StringUtils.changeStringToString(keys, ",");
+        List<SystemDict> systemDictList = systemDictService.getSystemDictListByType(typeList);
+        Map<String, Object> map = new HashMap<>();
+        for (String type : typeList) {
+            map.put(type, systemDictList.stream().filter(item -> item.getType().equals(type)).collect(Collectors.toList()));
+        }
+        return Response.success(map);
+    }
+
+
+    @GetMapping("getCustomField")
+    @Operation(summary = "查询个人栏位配置")
+    public Response getCustomField(String tableName) {
+        try {
+          List<PersonSelfFieldVO> personSelfFieldVOS= personFieldService.getCustomField(tableName);
+            Records records =new Records();
+            records.setData(personSelfFieldVOS);
+            return Response.success(records);
+        }
+        catch (Exception e){
+                return Response.error(e.getMessage());
+        }
+
+    }
+
+
+    @PostMapping("setCustomField")
+    @Operation(summary = "设置个人栏位配置")
+    public Response setCustomField(@RequestBody AddSelfFieldDTO addSelfFieldDTO) {
+        try {
+            List<PersonSelfFieldVO> personSelfFieldVOS= personFieldService.setCustomField(addSelfFieldDTO);
+            Records records =new Records();
+            records.setData(personSelfFieldVOS);
+            return Response.success(records);
+        }
+        catch (Exception e){
+            return Response.error(e.getMessage());
+        }
+
+    }
+    @GetMapping("/scenario")
+    @Operation(summary = "查询应用场景")
+    public Response queryAllScenario(){
+        Records records = new Records();
+        records.setData(scenarioService.queryAll());
+        return Response.success(records);
+    }
+
+    @PostMapping("/matter")
+    @Operation(summary = "查询处理事项")
+    public Response queryMatter(@RequestBody List<Integer> scenarioIds){
+        Records records = new Records();
+        records.setData(assoScenarioMatterService.queryMatterIds(scenarioIds));
+        return Response.success(records);
+    }
+
+    @GetMapping("/queryCrons")
+    @Operation(summary = "查找核心结论")
+    public Response queryCrons(Integer reportType){
+        Records records = new Records();
+        records.setData(systemDictService.getCrons(reportType));
+        return Response.success(records);
+    }
+}

+ 43 - 0
src/main/java/cn/cslg/pas/domain/WebLoginConfig.java

@@ -0,0 +1,43 @@
+package cn.cslg.pas.domain;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * 网站配置
+ * @TableName web_config
+ */
+@Data
+@TableName(value ="web_login_config")
+public class WebLoginConfig implements Serializable {
+    /**
+     * ID
+     */
+    @TableId(type = IdType.AUTO)
+    private Integer id;
+    @TableField(value = "login_account")
+    private String loginAccount;
+
+    @TableField(value = "login_password")
+    private String loginPassword;
+
+    /**
+     * 账号
+     */
+    @TableField(value = "tenant_id")
+    private Integer tenantId;
+
+    @TableField(value = "web_Id")
+    private Integer webId;
+
+    @TableField(value = "web_config")
+    private String webConfig;
+    @TableField(value = "web_group")
+    private Integer webGroup;
+
+}

+ 45 - 0
src/main/java/cn/cslg/pas/domain/business/AssoImportTaskField.java

@@ -0,0 +1,45 @@
+package cn.cslg.pas.domain.business;
+
+import cn.cslg.pas.domain.BaseEntity;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+/**
+ * 任务与栏位关联表
+ * @Author xiexiang
+ * @Date 2023/11/15
+ */
+@Data
+@TableName("asso_task_field")
+public class AssoImportTaskField extends BaseEntity<AssoImportTaskField> {
+    /**
+     * 任务id
+     */
+    @TableField(value = "import_task_id")
+    private Integer importTaskId;
+
+    /**
+     * 专题库/报告/产品id
+     */
+    @TableField(value = "project_id")
+    private Integer projectId;
+
+    /**
+     * 栏位类型
+     */
+    @TableField(value = "field_type")
+    private Integer fieldType;
+
+    /**
+     * 栏位
+     */
+    @TableField(value = "field_id")
+    private Integer fieldId;
+
+    /**
+     * 栏位值id
+     */
+    @TableField(value = "field_value_id")
+    private Integer fieldValueId;
+}

+ 2 - 2
src/main/java/cn/cslg/pas/domain/business/AssoTaskField.java

@@ -16,8 +16,8 @@ public class AssoTaskField extends BaseEntity<AssoTaskField> {
     /**
     /**
      * 任务id
      * 任务id
      */
      */
-    @TableField(value = "import_task_id")
-    private Integer importTaskId;
+    @TableField(value = "task_id")
+    private Integer taskId;
 
 
     /**
     /**
      * 专题库/报告/产品id
      * 专题库/报告/产品id

+ 6 - 0
src/main/java/cn/cslg/pas/domain/business/ImportTask.java

@@ -80,4 +80,10 @@ public class ImportTask extends BaseEntity<ImportTask> {
      */
      */
     @TableField(value = "create_time")
     @TableField(value = "create_time")
     private Date createTime;
     private Date createTime;
+    /**
+     * 完成数量
+     */
+    @TableField(value = "end_num")
+    private Integer endNum;
+
 }
 }

+ 60 - 0
src/main/java/cn/cslg/pas/domain/business/RetrieveRecord.java

@@ -0,0 +1,60 @@
+package cn.cslg.pas.domain.business;
+
+import cn.cslg.pas.domain.BaseEntity;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+import java.util.Date;
+
+/**
+ * 检索记录实体类
+ * @author 李仁杰
+ * 2023/7/8
+ */
+@Data
+@TableName(value ="retrieve_record")
+public class RetrieveRecord extends BaseEntity<RetrieveRecord> {
+
+    /**
+     * 检索式
+     */
+    @TableField(value = "conditions")
+    private String conditions;
+    @TableField(value = "db_type")
+    private String dbType;
+    /**
+     * 租户
+     */
+    @TableField(value = "tenant_id")
+    private Integer tenantId;
+    /**
+     * 总条数
+     */
+    @TableField(value = "total_num")
+    private Integer totalNum;
+
+    /**
+     * 创建时间
+     */
+    @TableField(value = "create_time")
+    private Date createTime;
+
+    /**
+     * 创建人id
+     */
+    @TableField(value = "create_id")
+    private String createId;
+
+    /**
+     * 检索时间
+     */
+    @TableField(value = "retrieve_time")
+    private Date retrieveTime;
+
+    /**
+     * 更新时间
+     */
+    @TableField(value = "update_time")
+    private Date updateTime;
+}

+ 3 - 0
src/main/java/cn/cslg/pas/domain/es/Patent.java

@@ -421,5 +421,8 @@ public class Patent {
      */
      */
     @JsonProperty("markings")
     @JsonProperty("markings")
     List<Marking> markings;
     List<Marking> markings;
+    @JsonProperty("patent_join")
+    PatentJoin patentJoin;
+
 
 
 }
 }

+ 32 - 0
src/main/java/cn/cslg/pas/domain/es/PatentJoin.java

@@ -0,0 +1,32 @@
+package cn.cslg.pas.domain.es;
+
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import org.springframework.stereotype.Component;
+
+/**
+ * es关联
+ */
+@Component
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class PatentJoin {
+
+    /**
+     * code码
+     */
+    @JsonProperty("parent")
+    private String parent;
+
+    /**
+     * 名称
+     */
+    @JsonProperty("name")
+    private String name;
+
+
+}

+ 16 - 0
src/main/java/cn/cslg/pas/mapper/AssoImportTaskFieldMapper.java

@@ -0,0 +1,16 @@
+package cn.cslg.pas.mapper;
+
+import cn.cslg.pas.domain.business.AssoEventFile;
+import cn.cslg.pas.domain.business.AssoImportTaskField;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.springframework.stereotype.Repository;
+
+/**
+ * 任务可见栏位表
+ *
+ * @author chenyu
+ * @date 2023/10/20
+ */
+@Repository
+public interface AssoImportTaskFieldMapper extends BaseMapper<AssoImportTaskField> {
+}

+ 16 - 0
src/main/java/cn/cslg/pas/mapper/RetrieveRecordMapper.java

@@ -0,0 +1,16 @@
+package cn.cslg.pas.mapper;
+
+import cn.cslg.pas.domain.business.RetrieveRecord;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * <p>
+ * 检索记录表 Mapper 接口
+ * </p>
+ *
+ * @author 王岩
+ * @since 2022-03-25
+ */
+public interface RetrieveRecordMapper extends BaseMapper<RetrieveRecord> {
+
+}

+ 25 - 0
src/main/java/cn/cslg/pas/mapper/WebLoginConfigMapper.java

@@ -0,0 +1,25 @@
+package cn.cslg.pas.mapper;
+
+import cn.cslg.pas.common.vo.ConfigVO;
+import cn.cslg.pas.common.vo.QueryConfigVO;
+import cn.cslg.pas.domain.WebLoginConfig;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+/**
+* @author admin
+* @description 针对表【web_config(网站配置)】的数据库操作Mapper
+* @createDate 2023-03-08 18:51:17
+* @Entity cn.cslg.pas.domain.WebConfig
+*/
+@Mapper
+public interface WebLoginConfigMapper extends BaseMapper<WebLoginConfig> {
+    IPage<ConfigVO> getPageList(Page<ConfigVO> page, @Param("params") QueryConfigVO params);
+}
+
+
+
+

+ 83 - 0
src/main/java/cn/cslg/pas/service/WebLoginConfigService.java

@@ -0,0 +1,83 @@
+package cn.cslg.pas.service;
+import cn.cslg.pas.common.dto.ConfigDTO;
+import cn.cslg.pas.common.model.cronModel.PersonnelVO;
+import cn.cslg.pas.common.utils.CacheUtils;
+
+import cn.cslg.pas.common.utils.LoginUtils;
+import cn.cslg.pas.common.vo.ConfigVO;
+import cn.cslg.pas.common.vo.QueryConfigVO;
+import cn.cslg.pas.domain.WebLoginConfig;
+import cn.cslg.pas.mapper.WebLoginConfigMapper;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import lombok.RequiredArgsConstructor;
+import org.springframework.context.annotation.Lazy;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * @author admin
+ * @description 针对表【web_config(网站配置)】的数据库操作Service实现
+ * @createDate 2023-03-08 18:51:17
+ */
+@Service
+@RequiredArgsConstructor(onConstructor_ = {@Lazy})
+public class WebLoginConfigService extends ServiceImpl<WebLoginConfigMapper, WebLoginConfig> {
+    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);
+        }
+        config.setWebId(configDTO.getWebId());
+        config.setTenantId(personnelVO.getTenantId());
+        config.setLoginAccount(configDTO.getLoginAccount());
+        config.setLoginPassword(configDTO.getLoginPassword());
+        this.saveOrUpdate(config);
+    }
+
+    public WebLoginConfig getLoginConfig(Integer webId, Integer tenantId) {
+        List<WebLoginConfig> configs = this.list(new LambdaQueryWrapper<WebLoginConfig>().eq(WebLoginConfig::getWebId, webId).eq(WebLoginConfig::getTenantId, tenantId));
+        WebLoginConfig config;
+        if (configs.size() > 0) {
+            config = configs.get(0);
+        } else {
+            config = null;
+        }
+        return config;
+    }
+
+    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 WebLoginConfig getConfig(Integer webId,Integer webGroup) {
+        List<WebLoginConfig> configs = this.list(new LambdaQueryWrapper<WebLoginConfig>().eq(WebLoginConfig::getWebId, webId).eq(WebLoginConfig::getWebGroup,webGroup));
+        WebLoginConfig config;
+        if (configs.size() > 0) {
+            config = configs.get(0);
+        } else {
+            config = null;
+        }
+        return config;
+    }
+
+}

+ 13 - 0
src/main/java/cn/cslg/pas/service/business/AssoImportTaskFieldService.java

@@ -0,0 +1,13 @@
+package cn.cslg.pas.service.business;
+
+
+
+import cn.cslg.pas.domain.business.AssoImportTaskField;
+import cn.cslg.pas.mapper.AssoImportTaskFieldMapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+@Service
+public class AssoImportTaskFieldService extends ServiceImpl<AssoImportTaskFieldMapper, AssoImportTaskField> {
+
+}

+ 79 - 25
src/main/java/cn/cslg/pas/service/business/es/EsService.java

@@ -1,30 +1,27 @@
 package cn.cslg.pas.service.business.es;
 package cn.cslg.pas.service.business.es;
 
 
 import cn.cslg.pas.common.vo.PatentWithIdVO;
 import cn.cslg.pas.common.vo.PatentWithIdVO;
-import cn.cslg.pas.domain.School;
 import cn.cslg.pas.domain.es.Patent;
 import cn.cslg.pas.domain.es.Patent;
 import co.elastic.clients.elasticsearch.ElasticsearchClient;
 import co.elastic.clients.elasticsearch.ElasticsearchClient;
 import co.elastic.clients.elasticsearch._types.SortOrder;
 import co.elastic.clients.elasticsearch._types.SortOrder;
 import co.elastic.clients.elasticsearch._types.query_dsl.BoolQuery;
 import co.elastic.clients.elasticsearch._types.query_dsl.BoolQuery;
+import co.elastic.clients.elasticsearch._types.query_dsl.HasChildQuery;
 import co.elastic.clients.elasticsearch.core.*;
 import co.elastic.clients.elasticsearch.core.*;
 import co.elastic.clients.elasticsearch.core.search.Hit;
 import co.elastic.clients.elasticsearch.core.search.Hit;
-import co.elastic.clients.elasticsearch.core.search.TotalHits;
-import com.github.pagehelper.util.StringUtil;
 import lombok.RequiredArgsConstructor;
 import lombok.RequiredArgsConstructor;
 import org.springframework.context.annotation.Lazy;
 import org.springframework.context.annotation.Lazy;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
 
 
 import java.io.IOException;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.ArrayList;
-import java.util.HashMap;
 import java.util.List;
 import java.util.List;
-import java.util.Map;
 
 
 
 
 @Service
 @Service
 @RequiredArgsConstructor(onConstructor_ = {@Lazy})
 @RequiredArgsConstructor(onConstructor_ = {@Lazy})
 public class EsService {
 public class EsService {
     private final ElasticsearchClient client;
     private final ElasticsearchClient client;
+
     /**
     /**
      * @param patent
      * @param patent
      * @throws Exception
      * @throws Exception
@@ -33,12 +30,26 @@ public class EsService {
         IndexResponse indexResponse = client.index(i -> i
         IndexResponse indexResponse = client.index(i -> i
                 .index("patent")
                 .index("patent")
                 //传入user对象
                 //传入user对象
-                .document(patent));
-
+                .document(patent)
+        );
         return indexResponse.id();
         return indexResponse.id();
 
 
     }
     }
 
 
+    /**
+     * @param patent
+     * @throws Exception
+     */
+    public String addChildPatent(Patent patent, String id) throws Exception {
+        IndexResponse indexResponse = client.index(i -> i
+                .index("patent")
+                .routing(id)
+                //传入user对象
+                .document(patent)
+        );
+        return indexResponse.id();
+
+    }
 
 
     /**
     /**
      * 根据专利号获取专利id
      * 根据专利号获取专利id
@@ -48,7 +59,7 @@ public class EsService {
      * @throws Exception
      * @throws Exception
      */
      */
     public PatentWithIdVO getIdByPatentNo(String patentNo) throws Exception {
     public PatentWithIdVO getIdByPatentNo(String patentNo) throws Exception {
-        PatentWithIdVO patentWithIdVO =null;
+        PatentWithIdVO patentWithIdVO = null;
         String id = null;
         String id = null;
         SearchResponse<Patent> response = client.search(
         SearchResponse<Patent> response = client.search(
                 s -> s.index("patent")
                 s -> s.index("patent")
@@ -58,42 +69,50 @@ public class EsService {
                                                 .query(patentNo)
                                                 .query(patentNo)
                                 )
                                 )
                         )
                         )
-                ,Patent.class
+                , Patent.class
 
 
         );
         );
         List<Hit<Patent>> hits = response.hits().hits();
         List<Hit<Patent>> hits = response.hits().hits();
         if (hits != null && hits.size() > 0) {
         if (hits != null && hits.size() > 0) {
             id = hits.get(0).id();
             id = hits.get(0).id();
-            Patent patent =hits.get(0).source();
-            patentWithIdVO =new PatentWithIdVO();
+            Patent patent = hits.get(0).source();
+            patentWithIdVO = new PatentWithIdVO();
             patentWithIdVO.setPatent(patent);
             patentWithIdVO.setPatent(patent);
             patentWithIdVO.setId(id);
             patentWithIdVO.setId(id);
         }
         }
         return patentWithIdVO;
         return patentWithIdVO;
     }
     }
 
 
+    /**
+     * @param key
+     * @param page
+     * @param limit
+     * @return
+     * @throws IOException
+     */
+    public List<Patent> search(String key, Integer page, Integer limit) throws IOException {
 
 
-    public List<Patent> search(String key,Integer page,Integer limit) throws IOException {
         SearchRequest.Builder builder = new SearchRequest.Builder();
         SearchRequest.Builder builder = new SearchRequest.Builder();
         //设置查询索引
         //设置查询索引
         builder.index("patent");
         builder.index("patent");
         //组装查询条件
         //组装查询条件
         BoolQuery.Builder boolQuery = new BoolQuery.Builder();
         BoolQuery.Builder boolQuery = new BoolQuery.Builder();
 
 
-            boolQuery.should(q -> q.matchPhrasePrefix(m -> m
-                    .query(key)
-                    //字段名
-                    .field("title")
-            ));
-            //多字段匹配
-            boolQuery.should(q->q.matchPhrasePrefix(m->m.query(key).field("content")));
+        boolQuery.should(q -> q.matchPhrasePrefix(m -> m
+                .query(key)
+                //字段名
+                .field("title")
+        ));
 
 
+        //多字段匹配
+        boolQuery.should(q -> q.matchPhrasePrefix(m -> m.query(key).field("content")));
 
 
         builder.query(q -> q.bool(boolQuery.build()));
         builder.query(q -> q.bool(boolQuery.build()));
         //分页
         //分页
-        if(page!=null && limit!=null){
+        if (page != null && limit != null) {
             builder.from(page).size(limit);
             builder.from(page).size(limit);
         }
         }
+
         //排序
         //排序
         builder.sort(sortOptionsBuilder -> sortOptionsBuilder
         builder.sort(sortOptionsBuilder -> sortOptionsBuilder
                 .field(fieldSortBuilder -> fieldSortBuilder
                 .field(fieldSortBuilder -> fieldSortBuilder
@@ -110,19 +129,54 @@ public class EsService {
     }
     }
 
 
 
 
-    public Integer updateDocument(Patent patent,String id){
-        UpdateRequest<Patent,Patent> req;
+    public Integer updateDocument(Patent patent, String id) {
+        UpdateRequest<Patent, Patent> req;
         req = UpdateRequest.of(
         req = UpdateRequest.of(
-                b-> b.index("patent").id(id)
+                b -> b.index("patent").id(id)
                         .doc(patent)
                         .doc(patent)
         );
         );
         try {
         try {
-            client.update(req,Patent.class);
-            return  1;
+            client.update(req, Patent.class);
+            return 1;
         } catch (IOException e) {
         } catch (IOException e) {
             return -1;
             return -1;
         }
         }
     }
     }
+
+
+    /**
+     * @param key
+     * @param page
+     * @param limit
+     * @return
+     * @throws IOException
+     */
+    public List<Patent> searchChild(String key, Integer page, Integer limit) throws IOException {
+
+        SearchRequest.Builder builder = new SearchRequest.Builder();
+        //设置查询索引
+        builder.index("patent");
+        //组装查询条件
+        HasChildQuery.Builder hasChildQuery = new HasChildQuery.Builder();
+        hasChildQuery.type("project");
+        hasChildQuery.query(q -> q.match(m -> m
+                .query(key)
+                //字段名
+                .field("project_id")
+        ));
+
+
+        builder.query(q -> q.hasChild(hasChildQuery.build()));
+        SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+        List<Patent> list = new ArrayList<>();
+        List<Hit<Patent>> hits = response.hits().hits();
+        for (Hit<Patent> hit : hits) {
+            Patent esMess = hit.source();
+            list.add(esMess);
+        }
+
+        return list;
+    }
 }
 }
 
 
 
 

+ 53 - 0
src/main/java/cn/cslg/pas/service/common/MessageService.java

@@ -0,0 +1,53 @@
+package cn.cslg.pas.service.common;
+
+
+import cn.cslg.pas.common.core.base.Constants;
+
+import cn.cslg.pas.common.utils.Response;
+import cn.cslg.pas.common.utils.ResponseEnum;
+import cn.cslg.pas.common.utils.WebSocketServer;
+import cn.cslg.pas.common.vo.ImportTaskAMVO;
+
+import cn.cslg.pas.common.vo.TaskWebSocketDTO;
+import cn.cslg.pas.domain.business.ImportTask;
+import org.springframework.stereotype.Service;
+
+import java.util.Locale;
+
+/**
+ * 处理消息通知
+ *
+ * @Author 李仁杰
+ */
+@Service
+public class MessageService {
+
+    /**
+     * 通过WebSocket 在每一次循环结束后 向前端发送完成进度
+     *
+     * @param total      专利总数量
+     * @param i          当前专利下标
+     * @param percentage 进度(需要计算)
+     */
+    public void sendWebsocketMessage(ImportTaskAMVO importTaskAMVO, Integer total, Integer i, Long percentage) {
+        //通过WebSocket 在每一次循环结束后 向前端发送完成进度
+        //percentage:total == 0 ? 0 : Math.round((total.equals(i) ? (i * 1D) : (i + 1D)) / total * 100D)
+        //当任务状态为完成时,flag为true
+        boolean flag = importTaskAMVO.getStatus().equals(2);
+        WebSocketServer.sendInfo(Response.websocket(new TaskWebSocketDTO()
+                .setTaskId(importTaskAMVO.getId())
+                .setTaskStatus(importTaskAMVO.getStatus())
+//                .setProjectId(importTaskAMVO.getProjectId())
+//                .setReportId(importTaskAMVO.getReportId())
+//                .setProductId(importTaskAMVO.getProductId())
+                .setComplete(flag)
+                .setIndex(i)
+                .setTaskType(importTaskAMVO.getType())
+                .setPercentage(percentage)
+                .setFileName(importTaskAMVO.getFileGuid())
+                .setOldName("")
+                .setUrl("")
+                .setTotal(total), ResponseEnum.PATENT_IMPORT_TASK_SUCCESS), 1 + "");
+    }
+
+}

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

@@ -0,0 +1,783 @@
+package cn.cslg.pas.service.common;
+
+import cn.cslg.pas.common.config.XDns;
+
+import cn.cslg.pas.common.dto.PatentStarDTO;
+import cn.cslg.pas.common.dto.PatentStarListDTO;
+import cn.cslg.pas.common.model.cronModel.PersonnelVO;
+import cn.cslg.pas.common.model.importTaskModel.PatentApplicant;
+import cn.cslg.pas.common.utils.*;
+import cn.cslg.pas.common.vo.StarPatentVO;
+import cn.cslg.pas.domain.WebLoginConfig;
+import cn.cslg.pas.domain.business.RetrieveRecord;
+import cn.cslg.pas.service.WebLoginConfigService;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import okhttp3.FormBody;
+import okhttp3.OkHttpClient;
+import okhttp3.Request;
+import okhttp3.Response;
+import org.joda.time.DateTime;
+import org.joda.time.format.DateTimeFormat;
+import org.joda.time.format.DateTimeFormatter;
+import org.springframework.beans.BeanUtils;
+import org.springframework.stereotype.Service;
+
+import java.io.IOException;
+import java.util.*;
+import java.util.concurrent.TimeUnit;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * 调用外部接口的Service类 PCS:权限系统
+ *
+ * @Author chenyu
+ * @Date 2023/4/25
+ */
+@RequiredArgsConstructor
+@Slf4j
+@Service
+
+public class PatentStarApiService {
+    private final RetrieveRecordService retrieveRecordService;
+    private final CacheUtils cacheUtils;
+    private final LoginUtils loginUtils;
+    private final WebLoginConfigService webLoginConfigService;
+//
+//    //装载专利信息
+//    public void loadStarPatentVOS(List<StarPatentVO> starPatentVOS, JSONObject Data) {
+//        String aa = Data.toString();
+//        starPatentVOS.forEach(item -> {
+//            //专利类型
+//            Integer patentType = item.getPatentType();
+//            if (patentType != null) {
+//                if (patentType.equals(2) || patentType.equals(9)) {
+//                    item.setType("实用新型");
+//                } else if (patentType.equals(1) || patentType.equals(8)) {
+//                    item.setType("发明");
+//                } else if (patentType.equals(3)) {
+//                    item.setType("外观设计");
+//                }
+//            }
+//
+//            //如果有公开号,则将公开号作为专利号
+//            if (item.getApplicationNo() != null && !item.getApplicationNo().equals("") && item.getApplicationNo().contains("CN")) {
+//                item.setPatentNo(item.getApplicationNo());
+//            } else if (item.getPublicNo() != null && !item.getPublicNo().equals("")) {
+//                item.setPatentNo(item.getPublicNo());
+//                //如果没有公开号,但是有公告号,则将公告号作为公开号和专利号
+//            }
+//            if (item.getPublicAccreditNo() != null && !item.getPublicAccreditNo().equals("")) {
+//                if (item.getPublicNo() == null || item.getPublicNo().equals("")) {
+//                    item.setPublicNo(item.getPublicAccreditNo());
+//                }
+//                if (item.getPatentNo() == null) {
+//                    item.setPatentNo(item.getPublicAccreditNo());
+//                }
+//            } else {
+//                System.out.println("");
+//
+//            }
+//
+//            //如果没有公开日就将公告日作为公开日
+//            if (item.getPublicDate() == null || item.getPublicDate().equals("")) {
+//                item.setPublicDate(item.getPublicAccreditDate());
+//            }
+//            item.setApplicant(new ArrayList<>());
+//            item.setAgent(new ArrayList<>());
+//            item.setIpcList(Arrays.asList(item.getIpcListStr().split(";")));
+//            if (item.getApplicationAddress() == null) {
+//                item.setApplicationAddress("");
+//            }
+//
+//            List<String> applicationAddress = Arrays.asList(item.getApplicationAddress().split(";"));
+//            List<String> applicants = Arrays.asList(item.getApplicantStr().split(";"));
+//            //装载申请人
+//            for (int i = 0; i < applicants.size(); i++) {
+//                PatentApplicant patentApplicant = new PatentApplicant();
+//                patentApplicant.setType(2);
+//                patentApplicant.setDataType(2);
+//                patentApplicant.setName(applicants.get(i));
+//                if (applicationAddress.size() > i) {
+//                    patentApplicant.setAddressStr(applicationAddress.get(i));
+//                }
+//                item.getApplicant().add(patentApplicant);
+//            }
+//
+//            //装载权利人
+//            if (item.getCurrentApplicantStr() != null && !item.getCurrentApplicantStr().equals("")) {
+//                List<String> cApplicants = Arrays.asList(item.getCurrentApplicantStr().split(";"));
+//                cApplicants.forEach(
+//                        tem -> {
+//                            PatentApplicant patentApplicant = new PatentApplicant();
+//                            patentApplicant.setType(2);
+//                            patentApplicant.setDataType(1);
+//                            patentApplicant.setName(tem);
+//                            item.getApplicant().add(patentApplicant);
+//                        }
+//                );
+//            }
+//
+//            //优先权
+//            if (item.getPriorityNo() != null && !item.getPriorityNo().equals("")) {
+//
+//            }
+//
+//            //代理机构
+//            if (item.getAgencyStr() != null && !item.getAgencyStr().equals("")) {
+//                PatentAgency patentAgency = new PatentAgency();
+//                patentAgency.setName(item.getAgencyStr().split(" ")[0]);
+//                item.setAgency(patentAgency);
+//            }
+//
+//            //发明人
+//            if (item.getInventorStr() != null && !item.getInventorStr().equals("")) {
+//                item.setInventor(new ArrayList<>());
+//                List<String> inventors = Arrays.asList(item.getInventorStr().split(";"));
+//                inventors.forEach(
+//                        tem -> {
+//                            PatentInventor patentInventor = new PatentInventor();
+//                            patentInventor.setName(tem);
+//                            item.getInventor().add(patentInventor);
+//                            ;
+//                        }
+//                );
+//            }
+//
+//            //代理人
+//            if (item.getAgentStr() != null && !item.getAgentStr().equals("")) {
+//                List<String> agent = Arrays.asList(item.getAgentStr().split(";"));
+//                agent.forEach(
+//                        tem -> {
+//                            PatentAgent patentAgent = new PatentAgent();
+//                            patentAgent.setName(tem);
+//                            item.getAgent().add(patentAgent);
+//                        }
+//                );
+//            }
+//            //TODO 此处不调用取附图接口,(遍历调接口效率太低)  提出者:罗总
+//            //附图
+////            if (item.getApplicationNo() != null && item.getApplicationNo() != "") {
+////                String apN = item.getApplicationNo().replace(".", "");
+////
+////                //String path = this.getPictureApi(apN.substring(2));
+////                //item.setAbstractPath(path);
+////            }
+//            if (item.getLG() != null) {
+//                switch (item.getLG()) {
+//                    case 1:
+//                        item.setSimpleStatus("有效");
+//                        break;
+//                    case 2:
+//                        item.setSimpleStatus("失效");
+//                        break;
+//                    case 3:
+//                        item.setSimpleStatus("审中");
+//                        break;
+//                }
+//            }
+//            //法律状态
+//        });
+//    }
+
+    public Map<String, Object> patentStarSearchLocal(PatentStarListDTO PatentStarListDTO) throws IOException {
+        RetrieveRecord retrieveRecord = new RetrieveRecord();
+        retrieveRecord.setConditions(PatentStarListDTO.getCurrentQuery());
+        if (PatentStarListDTO.getRetrieveRecordId() != null) {
+            //retrieveRecord = retrieveRecordService.getById(PatentStarListDTO.getRetrieveRecordId());
+            //PatentStarListDTO.setCurrentQuery(retrieveRecord.getConditions());
+            //PatentStarListDTO.setDBType(retrieveRecord.getDbType());
+        }
+        Map<String, Object> map = this.patentStarSearchApi(PatentStarListDTO);
+        if (map == null) {
+            ThrowException.throwXiaoShiException("检索失败,请检查检索式");
+        }
+        //记录检索历史
+        retrieveRecord.setRetrieveTime(new Date());
+        retrieveRecord.setTotalNum(Integer.parseInt(map.get("total").toString()));
+        retrieveRecord.setDbType(PatentStarListDTO.getDBType());
+        if (PatentStarListDTO.getRetrieveRecordId() == null) {
+            //获取创建人信息
+            PersonnelVO personnelVO = cacheUtils.getLoginUser(loginUtils.getId());
+            retrieveRecord.setCreateTime(new Date());
+            retrieveRecord.setCreateId(personnelVO.getId());
+            retrieveRecord.setTenantId(personnelVO.getTenantId());
+            retrieveRecord.insert();
+        }
+//        else {
+//            retrieveRecord.updateById();
+//        }
+        map.put("retrieveRecordId", retrieveRecord.getId());
+        return map;
+
+    }
+
+
+    public Map<String, Object> patentStarSearchApi(PatentStarListDTO PatentStarListDTO) throws IOException {
+        try {
+            if (PatentStarListDTO.getFormed() == null || PatentStarListDTO.getFormed() == false) {
+                String formQuery = PatentStarListDTO.getCurrentQuery();
+//                PatentStarListDTO.setCurrentQuery(PatentStarApiService.formatQuery(formQuery));
+                if (PatentStarListDTO.getDBType().equals("WD")) {
+                    StringBuilder stringBuilder = new StringBuilder(PatentStarListDTO.getCurrentQuery());
+                    stringBuilder.insert(PatentStarListDTO.getCurrentQuery().length() - 1, "-CN/GJ");
+                    PatentStarListDTO.setCurrentQuery(stringBuilder.toString());
+
+                }
+            }
+        } catch (Exception e) {
+            return null;
+        }
+        JSONObject configObject = this.getConfigObject(4, 1);
+        String appId = configObject.getString("appId");
+        String appKey = configObject.getString("appKey");
+        PatentStarDTO patentStarDto = new PatentStarDTO();
+        BeanUtils.copyProperties(PatentStarListDTO, patentStarDto);
+        String json = JSONObject.toJSONString(patentStarDto);
+        String url = "http://s.patentstar.com.cn/SearchAPI/PatentSearch/ResultGet";
+        Long currentTimeMillis = System.currentTimeMillis() / 1000;
+        String Sign = appKey + currentTimeMillis.toString();
+        String signMd5 = FormatUtil.MD5(Sign);
+        // 创建一个OkHttpClient对象
+        OkHttpClient okHttpClient = new OkHttpClient.Builder()
+                .connectTimeout(60, TimeUnit.SECONDS)
+                .writeTimeout(60, TimeUnit.SECONDS)
+                .readTimeout(60, TimeUnit.SECONDS)
+                .dns(new XDns(100000))
+                .build();
+        // 创建一个RequestBody(参数1:数据类型 参数2传递的json串)
+        FormBody.Builder builder = new FormBody.Builder();
+        builder.add("AppID", appId);
+        builder.add("Stamp", currentTimeMillis.toString());
+        builder.add("Sign", signMd5);
+        builder.add("QueryJson", json);
+        FormBody requestBody = builder.build();
+        // 创建一个请求对象
+        Request request = new Request.Builder().url(url).post(requestBody).build();
+        // 发送请求获取响应
+        try {
+            Response response = okHttpClient.newCall(request).execute();
+            // 判断请求是否成功
+            if (response.isSuccessful()) {
+                JSONObject jsonObject = JSONObject.parseObject(Objects.requireNonNull(response.body()).string());
+                if (jsonObject.get("Ret").equals(500) || jsonObject.get("Data") == null) {
+                    return null;
+                }
+                JSONObject Data = (JSONObject) jsonObject.get("Data");
+                List<StarPatentVO> starPatentVOS = JSONArray.parseArray(Data.get("List").toString(), StarPatentVO.class);
+//                this.loadStarPatentVOS(starPatentVOS, Data);
+                // 打印服务端返回结果
+                //  return Objects.requireNonNull(response.body()).string();
+                Map<String, Object> reMap = new HashMap<>();
+                reMap.put("size", PatentStarListDTO.getRowCount());
+                reMap.put("current", PatentStarListDTO.getPageNum());
+                reMap.put("records", starPatentVOS);
+                reMap.put("total", Data.get("HitCount"));
+                return reMap;
+            }
+        } catch (IOException e) {
+            e.printStackTrace();
+            return null;
+        }
+        return null;
+    }
+
+    public List<PatentStarListDTO> getSplitedConditions(PatentStarListDTO patentStarListDTO, int patentNum) throws IOException {
+        DateTime nowDate = new DateTime();
+        DateTime date = DateUtils2.formStrToDateTime("1900-01-01");
+        //超过1万的列表
+        List<PatentStarListDTO> PatentStarListDTOs = new ArrayList<>();
+        //返回的列表
+        List<PatentStarListDTO> reDtos = new ArrayList<>();
+        patentStarListDTO.setStartTime(date);
+        patentStarListDTO.setEndTime(nowDate);
+        String formQuery = patentStarListDTO.getCurrentQuery();
+//        patentStarListDTO.setOrginCondition(PatentStarApiService.formatQuery(formQuery));
+        PatentStarListDTOs.add(patentStarListDTO);
+        while (PatentStarListDTOs.size() > 0) {
+            PatentStarListDTO dto = PatentStarListDTOs.get(0);
+            PatentStarListDTOs.remove(dto);
+            Map<String, Object> map1 = this.patentStarSearchApi(dto);
+            Integer total1 = Integer.parseInt(map1.get("total").toString());
+            dto.setTotal(total1);
+            patentStarListDTO.setFormed(true);
+            if (total1 > patentNum) {
+                DateTime startTime1 = dto.getStartTime();
+                DateTime endTime1 = dto.getEndTime();
+                List<DateTime> dateTimes = DateUtils2.formStrToDateTime(startTime1, endTime1);
+                PatentStarListDTO dto1 = new PatentStarListDTO();
+                BeanUtils.copyProperties(dto, dto1);
+                dto1.setStartTime(dateTimes.get(0));
+                dto1.setEndTime(dateTimes.get(1));
+                this.setConditions(dto1);
+                PatentStarListDTO dto2 = new PatentStarListDTO();
+                BeanUtils.copyProperties(dto, dto2);
+                dto2.setStartTime(dateTimes.get(2));
+                dto2.setEndTime(dateTimes.get(3));
+                this.setConditions(dto2);
+                PatentStarListDTOs.add(dto1);
+                PatentStarListDTOs.add(dto2);
+            } else if (total1 != 0) {
+                reDtos.add(dto);
+            }
+
+        }
+
+        return reDtos;
+    }
+
+    public void setConditions(PatentStarListDTO PatentStarListDTO) {
+        DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyyMMdd");
+        String startStr = formatter.print(PatentStarListDTO.getStartTime());
+        String endStr = formatter.print(PatentStarListDTO.getEndTime());
+        String cond = "*(" + startStr + ">" + endStr + "/" + "AD)";
+        Integer len = PatentStarListDTO.getOrginCondition().length();
+        StringBuilder stringBuilder = new StringBuilder(PatentStarListDTO.getOrginCondition());
+        stringBuilder.insert(len - 1, cond);
+        PatentStarListDTO.setCurrentQuery(stringBuilder.toString());
+    }
+
+    /**
+     * @param appNo
+     * @return
+     * @throws IOException
+     * @author 李仁杰
+     * 从专利之星获取中国专利著录
+     */
+    public String getCnBibApi(String appNo) {
+        String url = "https://api.patentstar.com.cn/api/Patent/CnBibo/" + appNo;
+        JSONObject configObject = this.getConfigObject(4, 2);
+        String appId = configObject.getString("appId");
+        String appKey = configObject.getString("appKey");
+        Long currentTimeMillis = System.currentTimeMillis() / 1000;
+        String Sign = appId + appKey + currentTimeMillis.toString();
+        String signMd5 = FormatUtil.MD5(Sign);
+        // 创建一个OkHttpClient对象
+        OkHttpClient okHttpClient = new OkHttpClient.Builder()
+                .connectTimeout(60, TimeUnit.SECONDS)
+                .writeTimeout(60, TimeUnit.SECONDS)
+                .readTimeout(60, TimeUnit.SECONDS)
+                .dns(new XDns(100000))
+                .build();
+        // 创建一个请求对象
+        Request request = new Request.Builder().url(url)
+                .addHeader("_appid", appId)
+                .addHeader("_timestamp", currentTimeMillis.toString())
+                .addHeader("_sign", signMd5)
+                .get().build();
+        // 发送请求获取响应
+        try {
+            Response response = okHttpClient.newCall(request).execute();
+            // 判断请求是否成功
+            if (response.isSuccessful()) {
+                // 打印服务端返回结果
+                return Objects.requireNonNull(response.body()).string();
+            }
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        return "{}";
+
+    }
+
+
+    /**
+     * @param
+     * @return
+     * @throws IOException
+     * @author 李仁杰
+     * 从专利之星获取中国专利摘要附图
+     */
+    public String getPictureApi(String appNo) {
+        String url = "https://api.patentstar.com.cn/api/Patent/CnMainImage/" + appNo;
+        JSONObject configObject = this.getConfigObject(4, 2);
+        String appId = configObject.getString("appId");
+        String appKey = configObject.getString("appKey");
+        Long currentTimeMillis = System.currentTimeMillis() / 1000;
+        String Sign = appId + appKey + currentTimeMillis.toString();
+        String signMd5 = FormatUtil.MD5(Sign);
+        // 创建一个OkHttpClient对象
+        OkHttpClient okHttpClient = new OkHttpClient.Builder()
+                .connectTimeout(60, TimeUnit.SECONDS)
+                .writeTimeout(60, TimeUnit.SECONDS)
+                .readTimeout(60, TimeUnit.SECONDS)
+                .dns(new XDns(100000))
+                .build();
+        // 创建一个请求对象
+        Request request = new Request.Builder().url(url)
+                .addHeader("_appid", appId)
+                .addHeader("_timestamp", currentTimeMillis.toString())
+                .addHeader("_sign", signMd5)
+                .get().build();
+        // 发送请求获取响应
+        try {
+            Response response = okHttpClient.newCall(request).execute();
+            // 判断请求是否成功
+            if (response.isSuccessful()) {
+                // 打印服务端返回结果
+                return Objects.requireNonNull(response.body()).string();
+            }
+        } catch (IOException e) {
+            e.printStackTrace();
+            return null;
+        }
+        return "{}";
+    }
+
+    /**
+     * @param appNo
+     * @return
+     * @throws IOException
+     * @author 李仁杰
+     * 从专利之星获取中国专利外观图
+     */
+    public String getWGPictureApi(String appNo) throws IOException {
+
+        String url = "https://api.patentstar.com.cn/api/Patent/CnWGImage/" + appNo;
+        JSONObject configObject = this.getConfigObject(4, 2);
+        String appId = configObject.getString("appId");
+        String appKey = configObject.getString("appKey");
+        Long currentTimeMillis = System.currentTimeMillis() / 1000;
+        String Sign = appId + appKey + currentTimeMillis.toString();
+        String signMd5 = FormatUtil.MD5(Sign);
+        // 创建一个OkHttpClient对象
+        OkHttpClient okHttpClient = new OkHttpClient.Builder()
+                .connectTimeout(60, TimeUnit.SECONDS)
+                .writeTimeout(60, TimeUnit.SECONDS)
+                .readTimeout(60, TimeUnit.SECONDS)
+                .dns(new XDns(100000))
+                .build();
+        // 创建一个请求对象
+        Request request = new Request.Builder().url(url)
+                .addHeader("_appid", appId)
+                .addHeader("_timestamp", currentTimeMillis.toString())
+                .addHeader("_sign", signMd5)
+                .get().build();
+        // 发送请求获取响应
+        try {
+            Response response = okHttpClient.newCall(request).execute();
+            // 判断请求是否成功
+            if (response.isSuccessful()) {
+                // 打印服务端返回结果
+                return Objects.requireNonNull(response.body()).string();
+            }
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        return "{}";
+    }
+
+    /**
+     * @param appNo
+     * @return
+     * @throws IOException
+     * @author 李仁杰
+     * 从专利之星获取中国专利法律状态
+     */
+    public String getCnLegalApi(String appNo) {
+        String url = "https://api.patentstar.com.cn/api/Patent/CnLegal/" + appNo;
+        JSONObject configObject = this.getConfigObject(4, 2);
+        String appId = configObject.getString("appId");
+        String appKey = configObject.getString("appKey");
+        Long currentTimeMillis = System.currentTimeMillis() / 1000;
+        String Sign = appId + appKey + currentTimeMillis.toString();
+        String signMd5 = FormatUtil.MD5(Sign);
+        // 创建一个OkHttpClient对象
+        OkHttpClient okHttpClient = new OkHttpClient.Builder()
+                .connectTimeout(60, TimeUnit.SECONDS)
+                .writeTimeout(60, TimeUnit.SECONDS)
+                .readTimeout(60, TimeUnit.SECONDS)
+                .dns(new XDns(100000))
+                .build();
+        // 创建一个请求对象
+        Request request = new Request.Builder().url(url)
+                .addHeader("_appid", appId)
+                .addHeader("_timestamp", currentTimeMillis.toString())
+                .addHeader("_sign", signMd5)
+                .get().build();
+        // 发送请求获取响应
+        try {
+            Response response = okHttpClient.newCall(request).execute();
+            // 判断请求是否成功
+            if (response.isSuccessful()) {
+                // 打印服务端返回结果
+                return Objects.requireNonNull(response.body()).string();
+            }
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        return "{}";
+    }
+
+    /**
+     * @param appNo
+     * @return
+     * @throws IOException
+     * @author 李仁杰
+     * 从专利之星获取中国专利全文图片
+     */
+    public String getCnPdfApi(String appNo) throws IOException {
+        String url = "https://api.patentstar.com.cn/api/Patent/CnPdf/" + appNo;
+        JSONObject configObject = this.getConfigObject(4, 2);
+        String appId = configObject.getString("appId");
+        String appKey = configObject.getString("appKey");
+        Long currentTimeMillis = System.currentTimeMillis() / 1000;
+        String Sign = appId + appKey + currentTimeMillis.toString();
+        String signMd5 = FormatUtil.MD5(Sign);
+        // 创建一个OkHttpClient对象
+        OkHttpClient okHttpClient = new OkHttpClient.Builder()
+                .connectTimeout(60, TimeUnit.SECONDS)
+                .writeTimeout(60, TimeUnit.SECONDS)
+                .readTimeout(60, TimeUnit.SECONDS)
+                .dns(new XDns(100000))
+                .build();
+        // 创建一个请求对象
+        Request request = new Request.Builder().url(url)
+                .addHeader("_appid", appId)
+                .addHeader("_timestamp", currentTimeMillis.toString())
+                .addHeader("_sign", signMd5)
+                .get().build();
+        // 发送请求获取响应
+        try {
+            Response response = okHttpClient.newCall(request).execute();
+            // 判断请求是否成功
+            if (response.isSuccessful()) {
+                // 打印服务端返回结果
+                return Objects.requireNonNull(response.body()).string();
+            }
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        return "{}";
+    }
+
+    /**
+     * @param appNo
+     * @return
+     * @throws IOException
+     * @author 李仁杰
+     * 从专利之星获取中国专利全文文本
+     */
+
+    public String getCnFullXmlApi(String appNo) throws IOException {
+        String url = "https://api.patentstar.com.cn/api/Patent/CnFullXml/" + appNo;
+        JSONObject configObject = this.getConfigObject(4, 2);
+        String appId = configObject.getString("appId");
+        String appKey = configObject.getString("appKey");
+        Long currentTimeMillis = System.currentTimeMillis() / 1000;
+        String Sign = appId + appKey + currentTimeMillis.toString();
+        String signMd5 = FormatUtil.MD5(Sign);
+        // 创建一个OkHttpClient对象
+        OkHttpClient okHttpClient = new OkHttpClient.Builder()
+                .connectTimeout(60, TimeUnit.SECONDS)
+                .writeTimeout(60, TimeUnit.SECONDS)
+                .readTimeout(60, TimeUnit.SECONDS)
+                .dns(new XDns(100000))
+                .build();
+        // 创建一个请求对象
+        Request request = new Request.Builder().url(url)
+                .addHeader("_appid", appId)
+                .addHeader("_timestamp", currentTimeMillis.toString())
+                .addHeader("_sign", signMd5)
+                .get().build();
+        // 发送请求获取响应
+        try {
+            Response response = okHttpClient.newCall(request).execute();
+            // 判断请求是否成功
+            if (response.isSuccessful()) {
+                // 打印服务端返回结果
+                return Objects.requireNonNull(response.body()).string();
+            }
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        return "{}";
+    }
+
+    /**
+     * @param patentNo
+     * @return
+     * @throws IOException
+     * @author 李仁杰
+     * 从专利之星获取世界专利pdf
+     */
+    public String getEnPdfApi(String patentNo) {
+        String url = "  https://api.patentstar.com.cn/api/Patent/EnPdf/" + patentNo;
+        JSONObject configObject = this.getConfigObject(4, 2);
+        String appId = configObject.getString("appId");
+        String appKey = configObject.getString("appKey");
+//        String appId = "1000046";
+//        String appkey = "6AE6D4DC6AF94F26862501EDEE9E27A2";
+        Long currentTimeMillis = System.currentTimeMillis() / 1000;
+        String Sign = appId + appKey + currentTimeMillis.toString();
+        String signMd5 = FormatUtil.MD5(Sign);
+        // 创建一个OkHttpClient对象
+        OkHttpClient okHttpClient = new OkHttpClient.Builder()
+                .connectTimeout(60, TimeUnit.SECONDS)
+                .writeTimeout(60, TimeUnit.SECONDS)
+                .readTimeout(60, TimeUnit.SECONDS)
+                .dns(new XDns(100000))
+                .build();
+        // 创建一个请求对象
+        Request request = new Request.Builder().url(url)
+                .addHeader("_appid", appId)
+                .addHeader("_timestamp", currentTimeMillis.toString())
+                .addHeader("_sign", signMd5)
+                .get().build();
+        // 发送请求获取响应
+        try {
+            Response response = okHttpClient.newCall(request).execute();
+            // 判断请求是否成功
+            if (response.isSuccessful()) {
+                // 打印服务端返回结果
+                return Objects.requireNonNull(response.body()).string();
+            }
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        return "{}";
+    }
+
+    /**
+     * @param patentNo
+     * @return
+     * @throws IOException
+     * @author 李仁杰
+     * 从专利之星获取世界专利著录信息
+     */
+    public String getENBibApi(String patentNo) {
+        String url = "https://api.patentstar.com.cn/api/Patent/EnBib/" + patentNo;
+        JSONObject configObject = this.getConfigObject(4, 2);
+        String appId = configObject.getString("appId");
+        String appKey = configObject.getString("appKey");
+        Long currentTimeMillis = System.currentTimeMillis() / 1000;
+        String Sign = appId + appKey + currentTimeMillis.toString();
+        String signMd5 = FormatUtil.MD5(Sign);
+        // 创建一个OkHttpClient对象
+        OkHttpClient okHttpClient = new OkHttpClient.Builder()
+                .connectTimeout(60, TimeUnit.SECONDS)
+                .writeTimeout(60, TimeUnit.SECONDS)
+                .readTimeout(60, TimeUnit.SECONDS)
+                .dns(new XDns(100000))
+                .build();
+        // 创建一个请求对象
+        Request request = new Request.Builder().url(url)
+                .addHeader("_appid", appId)
+                .addHeader("_timestamp", currentTimeMillis.toString())
+                .addHeader("_sign", signMd5)
+                .get().build();
+        // 发送请求获取响应
+        try {
+            Response response = okHttpClient.newCall(request).execute();
+            // 判断请求是否成功
+            if (response.isSuccessful()) {
+                // 打印服务端返回结果
+                return Objects.requireNonNull(response.body()).string();
+            }
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        return "{}";
+    }
+
+    /**
+     * @param patentNo
+     * @return
+     * @throws IOException
+     * @author 李仁杰
+     * 从专利之星获取同族专利
+     */
+    public String getFamilyByPubNoApi(String patentNo) {
+        String url = "https://api.patentstar.com.cn/api/Patent/FamilyByPubNo/" + patentNo;
+        JSONObject configObject = this.getConfigObject(4, 2);
+        String appId = configObject.getString("appId");
+        String appKey = configObject.getString("appKey");
+        Long currentTimeMillis = System.currentTimeMillis() / 1000;
+        String Sign = appId + appKey + currentTimeMillis.toString();
+        String signMd5 = FormatUtil.MD5(Sign);
+        // 创建一个OkHttpClient对象
+        OkHttpClient okHttpClient = new OkHttpClient.Builder()
+                .connectTimeout(60, TimeUnit.SECONDS)
+                .writeTimeout(60, TimeUnit.SECONDS)
+                .readTimeout(60, TimeUnit.SECONDS)
+                .dns(new XDns(100000))
+                .build();
+        // 创建一个请求对象
+        Request request = new Request.Builder().url(url)
+                .addHeader("_appid", appId)
+                .addHeader("_timestamp", currentTimeMillis.toString())
+                .addHeader("_sign", signMd5)
+                .get().build();
+        // 发送请求获取响应
+        try {
+            Response response = okHttpClient.newCall(request).execute();
+            // 判断请求是否成功
+            if (response.isSuccessful()) {
+                // 打印服务端返回结果
+                return Objects.requireNonNull(response.body()).string();
+            }
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        return "{}";
+    }
+
+    /**
+     * @param patentNo
+     * @return
+     * @throws IOException
+     * @author 李仁杰
+     * 获得专利被引用次数api
+     */
+    public String getCitedNumByPubNoApi(String patentNo) throws IOException {
+        String url = "https://api.patentstar.com.cn/api/Patent/CitedNumByPubNo/" + patentNo;
+        JSONObject configObject = this.getConfigObject(4, 2);
+        String appId = configObject.getString("appId");
+        String appKey = configObject.getString("appKey");
+        Long currentTimeMillis = System.currentTimeMillis() / 1000;
+        String Sign = appId + appKey + currentTimeMillis.toString();
+        String signMd5 = FormatUtil.MD5(Sign);
+        // 创建一个OkHttpClient对象
+        OkHttpClient okHttpClient = new OkHttpClient.Builder()
+                .connectTimeout(60, TimeUnit.SECONDS)
+                .writeTimeout(60, TimeUnit.SECONDS)
+                .readTimeout(60, TimeUnit.SECONDS)
+                .dns(new XDns(100000))
+                .build();
+        // 创建一个请求对象
+        Request request = new Request.Builder().url(url)
+                .addHeader("_appid", appId)
+                .addHeader("_timestamp", currentTimeMillis.toString())
+                .addHeader("_sign", signMd5)
+                .get().build();
+        // 发送请求获取响应
+        try {
+            Response response = okHttpClient.newCall(request).execute();
+            // 判断请求是否成功
+            if (response.isSuccessful()) {
+                // 打印服务端返回结果
+                return Objects.requireNonNull(response.body()).string();
+            }
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        return "{}";
+    }
+
+
+    public JSONObject getConfigObject(Integer webId, Integer webGroup) {
+
+        WebLoginConfig webLoginConfig = webLoginConfigService.getConfig(webId, webGroup);
+        if (webLoginConfig == null) {
+            return null;
+        }
+        String config = webLoginConfig.getWebConfig();
+        JSONObject jsonObject = JSONObject.parseObject(config);
+        return jsonObject;
+    }
+
+}

+ 123 - 0
src/main/java/cn/cslg/pas/service/common/RetrieveRecordService.java

@@ -0,0 +1,123 @@
+package cn.cslg.pas.service.common;
+
+
+import cn.cslg.pas.common.dto.RetrieveRecordDTO;
+import cn.cslg.pas.common.dto.RetrieveRecordDeDTO;
+import cn.cslg.pas.common.dto.RetrieveRecordQueryDTO;
+import cn.cslg.pas.common.model.cronModel.PersonnelVO;
+import cn.cslg.pas.common.utils.CacheUtils;
+import cn.cslg.pas.common.utils.LoginUtils;
+import cn.cslg.pas.common.utils.Response;
+import cn.cslg.pas.domain.business.RetrieveRecord;
+import cn.cslg.pas.mapper.RetrieveRecordMapper;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import lombok.RequiredArgsConstructor;
+import org.springframework.beans.BeanUtils;
+import org.springframework.context.annotation.Lazy;
+import org.springframework.stereotype.Service;
+
+import java.util.Date;
+import java.util.List;
+
+/**
+ * <p>
+ * 检索记录表
+ * </p>
+ *
+ * @author 谢翔
+ * @since 2022-07-9
+ */
+@Service
+@RequiredArgsConstructor(onConstructor_ = {@Lazy})
+public class RetrieveRecordService extends ServiceImpl<RetrieveRecordMapper, RetrieveRecord> {
+    private final CacheUtils cacheUtils;
+    private final LoginUtils loginUtils;
+
+    /**
+     * 新增检索记录
+     * @param retrieveRecordDTO
+     */
+    public Response addRetrieveRecord(RetrieveRecordDTO retrieveRecordDTO){
+        //判空
+        if(retrieveRecordDTO != null){
+            //新建实体类
+            RetrieveRecord retrieveRecord = new RetrieveRecord();
+            //复制
+            BeanUtils.copyProperties(retrieveRecordDTO, retrieveRecord);
+            //获取创建人信息
+            PersonnelVO personnelVO = cacheUtils.getLoginUser(loginUtils.getId());
+            retrieveRecord.setCreateId(personnelVO.getId());
+            retrieveRecord.setDbType(retrieveRecordDTO.getDbType());
+            retrieveRecord.setConditions(retrieveRecordDTO.getConditions());
+            retrieveRecord.setTotalNum(retrieveRecordDTO.getTotalNum());
+            retrieveRecord.setTenantId(personnelVO.getTenantId());
+            //数据入表
+            retrieveRecord.insert();
+            return Response.success("新增成功");
+        } else {
+            return Response.error("传入参数不能为空");
+        }
+    }
+
+    /**
+     * 更新检索记录表
+     * @param retrieveRecordDTO
+     * @return
+     */
+    public Response updateRetrieveRecord(RetrieveRecordDTO retrieveRecordDTO){
+        //判空
+        if(retrieveRecordDTO != null){
+            Integer id = retrieveRecordDTO.getId();
+            //根据传入对象的id查询出实体类
+            RetrieveRecord retrieveRecord = this.getById(id);
+            retrieveRecord.setDbType(retrieveRecordDTO.getDbType());
+            retrieveRecord.setConditions(retrieveRecordDTO.getConditions());
+            retrieveRecord.setUpdateTime(new Date());
+            retrieveRecord.updateById();
+            return Response.success("更新成功");
+        } else {
+            return Response.error("更新失败");
+        }
+    }
+
+    /**
+     * 删除检索历史
+     * @return
+     */
+    public Response deleteRetrieveRecord(RetrieveRecordDeDTO retrieveRecordDeDTO){
+       List<Integer> ids = retrieveRecordDeDTO.getIds();
+       Boolean isAll =retrieveRecordDeDTO.getIsAll();
+       if(isAll!=null&& isAll){
+           this.remove(new LambdaQueryWrapper<RetrieveRecord>());
+       }
+       else {
+           //判空
+           if (ids != null && ids.size() > 0) {
+               this.removeByIds(ids);
+               return Response.success("删除成功");
+           } else {
+               return Response.error("删除错误");
+           }
+       }
+        return Response.success("删除成功");
+    }
+
+    /**
+     * 查询检索历史
+     * @return
+     */
+    public IPage<RetrieveRecord> queryRetrieveRecord(RetrieveRecordQueryDTO retrieveRecordQueryDTO){
+        //获取当前登陆人信息
+        PersonnelVO personnelVO = cacheUtils.getLoginUser(loginUtils.getId());
+        String createId = personnelVO.getId();
+        LambdaQueryWrapper<RetrieveRecord> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.eq(RetrieveRecord::getCreateId, createId)
+        .orderByDesc(RetrieveRecord::getUpdateTime);
+        IPage<RetrieveRecord> retrieveRecords = this.page(new Page<>(retrieveRecordQueryDTO.getCurrent(),retrieveRecordQueryDTO.getSize()),queryWrapper);
+        List<RetrieveRecord> retrieveRecordList =retrieveRecords.getRecords();
+        return retrieveRecords;
+    }
+}

+ 36 - 11
src/main/java/cn/cslg/pas/service/importPatent/GetPatentFromExcelThread.java

@@ -7,6 +7,7 @@ import cn.cslg.pas.common.vo.PatentData;
 import cn.cslg.pas.common.vo.UploadParamsVO;
 import cn.cslg.pas.common.vo.UploadParamsVO;
 import cn.cslg.pas.common.vo.UploadSettingVO;
 import cn.cslg.pas.common.vo.UploadSettingVO;
 import cn.cslg.pas.domain.es.Patent;
 import cn.cslg.pas.domain.es.Patent;
+import cn.cslg.pas.domain.es.Text;
 import cn.cslg.pas.service.common.ExcuteDataToVOService;
 import cn.cslg.pas.service.common.ExcuteDataToVOService;
 import cn.cslg.pas.service.common.ExcuteUploadSettingService;
 import cn.cslg.pas.service.common.ExcuteUploadSettingService;
 import cn.cslg.pas.service.common.FileManagerService;
 import cn.cslg.pas.service.common.FileManagerService;
@@ -53,22 +54,21 @@ public class GetPatentFromExcelThread extends Thread {
             Integer lastIndex = importTaskAMVO.getSuccessNum();
             Integer lastIndex = importTaskAMVO.getSuccessNum();
             Integer sourceId = importTaskAMVO.getSourceId();
             Integer sourceId = importTaskAMVO.getSourceId();
             //解析数据源类,通过数据来源id(如1:智慧芽)解析数据源配置文件,获得数据源配置文件对象jsonData
             //解析数据源类,通过数据来源id(如1:智慧芽)解析数据源配置文件,获得数据源配置文件对象jsonData
-            ExcuteDataToVOService excuteDataToVOService =applicationContext.getBean(ExcuteDataToVOService.class);
-            ExcuteUploadSettingService excuteUploadSettingService =applicationContext.getBean(ExcuteUploadSettingService.class);
+            ExcuteDataToVOService excuteDataToVOService = applicationContext.getBean(ExcuteDataToVOService.class);
+            ExcuteUploadSettingService excuteUploadSettingService = applicationContext.getBean(ExcuteUploadSettingService.class);
             List<UploadSettingVO.Column> jsonData = excuteUploadSettingService.ExcuteUploadSetting(sourceId.toString());
             List<UploadSettingVO.Column> jsonData = excuteUploadSettingService.ExcuteUploadSetting(sourceId.toString());
             //解析Excel文件获得工作簿
             //解析Excel文件获得工作簿
             Sheet sheet = ReadExcelUtils.readExcel(tempFile);
             Sheet sheet = ReadExcelUtils.readExcel(tempFile);
             //遍历专利总数量,在循环中将专利一个一个存入消费者专利队列
             //遍历专利总数量,在循环中将专利一个一个存入消费者专利队列
             for (int i = lastIndex; i < total; i++) {
             for (int i = lastIndex; i < total; i++) {
-
                 PatentData patentData = ReadExcelUtils.readExcelOneRow(tempFile, sheet, i + 1);
                 PatentData patentData = ReadExcelUtils.readExcelOneRow(tempFile, sheet, i + 1);
                 //调用装载数据类(根据数据源配置文件对象和专利源数据生成专利数据)
                 //调用装载数据类(根据数据源配置文件对象和专利源数据生成专利数据)
                 UploadParamsVO uploadParamsVO = excuteDataToVOService.fileToPatentVO(patentData, jsonData);
                 UploadParamsVO uploadParamsVO = excuteDataToVOService.fileToPatentVO(patentData, jsonData);
-
-
+                this.loadPatent(uploadParamsVO);
                 //专利丢入消费者队列,并唤醒消费者线程
                 //专利丢入消费者队列,并唤醒消费者线程
                 savePatentToEsThread.awakeTask(uploadParamsVO.getPatent());
                 savePatentToEsThread.awakeTask(uploadParamsVO.getPatent());
             }
             }
+            //专利取完通知消费者线程
             savePatentToEsThread.setIfProductAll(true);
             savePatentToEsThread.setIfProductAll(true);
             //删除临时文件tempFile
             //删除临时文件tempFile
             new File(tempFile.getPath()).delete();
             new File(tempFile.getPath()).delete();
@@ -77,18 +77,43 @@ public class GetPatentFromExcelThread extends Thread {
         }
         }
     }
     }
 
 
-    public GetPatentFromExcelThread(ImportTaskAMVO importTaskAMVO, SavePatentToEsThread savePatentToEsThread,ApplicationContext applicationContext) {
+    public GetPatentFromExcelThread(ImportTaskAMVO importTaskAMVO, SavePatentToEsThread savePatentToEsThread, ApplicationContext applicationContext) {
         this.importTaskAMVO = importTaskAMVO;
         this.importTaskAMVO = importTaskAMVO;
         this.savePatentToEsThread = savePatentToEsThread;
         this.savePatentToEsThread = savePatentToEsThread;
-        this.applicationContext= applicationContext;
+        this.applicationContext = applicationContext;
     }
     }
 
 
 
 
-    public void loadPatent(Patent patent) {
-        //如果是中国专利,就将申请号作为专利号
-        if (patent.getPatentNo().contains("CN")) {
-            patent.setPatentNo(patent.getAppNo());  //将申请号设为专利号patentNo
+    public void loadPatent(UploadParamsVO uploadParamsVO) {
+        Patent patent = uploadParamsVO.getPatent();
+        String patentNo =patent.getPatentNo();
+        String contry =patentNo.substring(0,2);
+        if (uploadParamsVO.getTitle() != null) {
+            List<Text> texts = new ArrayList<>();
+            if (uploadParamsVO.getTitle().getName() != null) {
+                Text text = new Text();
+                text.setTextContent(uploadParamsVO.getTitle().getName());
+                text.setIfOrigin(true);
+                text.setLanguage(contry);
+                texts.add(text);
+            }
+            if (uploadParamsVO.getTitle().getNameOut() != null) {
+                Text text = new Text();
+                text.setTextContent(uploadParamsVO.getTitle().getNameOut());
+                text.setIfOrigin(false);
+                text.setLanguage("CN");
+                texts.add(text);
+            }
+            if (texts.size() != 0) {
+                patent.setTitle(texts);
+            }
+
         }
         }
+        //如果是中国专利,就将申请号作为专利号
+//        if (patent.getPatentNo().contains("CN")) {
+//            patent.setPatentNo(patent.getAppNo());  //将申请号设为专利号patentNo
+//        }
+
 
 
         //装载权利要求
         //装载权利要求
 
 

+ 285 - 0
src/main/java/cn/cslg/pas/service/importPatent/ImportFromWebToEsService.java

@@ -0,0 +1,285 @@
+package cn.cslg.pas.service.importPatent;
+
+import cn.cslg.pas.common.utils.MathUtils;
+import cn.cslg.pas.common.utils.ThrowException;
+import cn.cslg.pas.common.vo.ImportTaskAMVO;
+import cn.cslg.pas.common.vo.StarPatentVO;
+import cn.cslg.pas.common.vo.UploadParamsVO;
+import cn.cslg.pas.domain.es.Patent;
+import cn.cslg.pas.factorys.PatentImportFactory.PatentImportImp;
+import cn.cslg.pas.service.common.PatentStarApiService;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Service;
+
+
+@Scope("prototype")
+@Service
+public class ImportFromWebToEsService implements PatentImportImp {
+    private TaskThread taskThread;
+    private PatentStarApiService patentStarApiService;
+
+    @Override
+    public void startPatentThread() {
+        ImportTaskAMVO importTaskAMVO = new ImportTaskAMVO();
+        //若本次下载任务是超过一万条专利的全部下载任务
+        int patentNum = 10000;
+        if (importTaskAMVO.getEndNum() <= patentNum) {
+//            excuteLessThan10000(task);
+        } else {
+            //                Integer total = importTaskAMVO.getAllNum();  //任务专利总数量
+//                Integer successNum = importTaskAMVO.getSuccessNum();
+//                String orderBy = importTaskAMVO.getOrderBy();  //排序字段
+//                String orderByType = importTaskAMVO.getOrderByType();  //排序类型
+//                String dbType = importTaskAMVO.getDBType();  //检索数据库类型
+//                List<String> cells = importTaskAMVO.getConfigCells();  //下载字段
+//                Integer startNumber = importTaskAMVO.getStartNumber();  //下载起始条数位置
+//                List<String> isDeletePatentNos = task.getIsDeletePatentNos();  //起止条数中不需要下载的专利号
+//
+//                //如果完成数量大于0,则当前下载任务为暂停后的继续下载,则开始位置更新
+//                if (successNum > 0) {
+//                    startNumber += successNum;
+//                }
+//
+//                //获得返回的的多个检索式 patentStarListDtos
+//                List<PatentStarListDto> patentStarListDtos = patentStarApiService.getSplitedConditions(new PatentStarListDto()
+//                        .setCurrentQuery(task.getConditions())
+//                        .setOrderBy(orderBy)
+//                        .setOrderByType(orderByType)
+//                        .setDBType(dbType), patentNum);
+//
+//                int produceSuccessNum = 0;
+//                int countForStart = 0;  //定义变量countForStart,记录检索式的专利总数量(目的是找出下载开始位置专利所属的那个检索式)
+//                //第1层:遍历多个检索式
+//                for (PatentStarListDto patentStarListDto : patentStarListDtos) {
+//                    //还没有到开始位置,则跳过,继续判断下一个检索式
+//                    countForStart += patentStarListDto.getTotal();
+//                    if (countForStart < startNumber) {
+//                        continue;
+//                    }
+//
+//
+//                    //至此,即找到了当前检索式即为要下载的专利开始位置所属的检索式,重新计算开始位置startNumber(即要下载的专利的开始位置,对应了当前检索式中该专利位置)
+//                    startNumber = startNumber - (countForStart - patentStarListDto.getTotal());
+//                    //第一个检索式下载完成后,从第二个检索式开始 startNumber都是从1开始下载
+//                    if (startNumber < 0) {
+//                        startNumber = 1;
+//                    }
+//                    //调用方法,入参为开始位置和结束位置(即当前检索式最后一个专利的位置,即当前检索式的专利总数量total),获得开始页数、结束页数、开始页数的开始位置、结束页数的结束位置
+//                    Calculate calculate = calculateFromStartAndEndNumber(startNumber, patentStarListDto.getTotal());
+//                    Integer startPage = calculate.getStartPage();
+//                    Integer startNum = calculate.getStartNum();
+//                    Integer endPage = calculate.getEndPage();
+//
+//                    //第2层:遍历检索页数
+//                    for (Integer i = startPage; i <= endPage; i++) {
+//                        //调用一般检索接口,返回一批专利著录相关数据
+//                        patentStarListDto
+//                                .setPageNum(i)
+//                                .setRowCount(50)
+//                                .setFormed(true);
+//                        Map<String, Object> resultMap = patentStarApiService.patentStarSearchApi(patentStarListDto);
+//                        if (resultMap == null || (Integer) resultMap.get("total") == 0) {
+//                            ThrowException.throwXiaoShiException("未检索到相关专利");
+//                        }
+//
+//                        List<StarPatentVO> starPatents = (List<StarPatentVO>) resultMap.get("records");
+//                        //第3层:遍历专利
+//                        for (int j = 0; j < starPatents.size(); j++) {
+//                            //若任务状态为已暂停,则结束本次任务的下载
+//                            if (pTaskId.equals(task.getId()) && pTaskStatus == 4) {
+//                                return;
+//                            }
+//                            //若生产的数量达到了总数,则结束本次任务的下载
+//                            if (produceSuccessNum == total) {
+//                                return;
+//                            }
+//                            //如果还没到要下载的专利的开始位置,则跳过,继续判断下一个专利
+//                            if (i.equals(startPage) && j < startNum - 1) {
+//                                continue;
+//                            }
+//                            //如果当前遍历到的专利号是需要删除的专利,则跳过,不下载它
+//                            if (isDeletePatentNos != null && isDeletePatentNos.size() > 0 && isDeletePatentNos.contains(starPatents.get(j).getApplicationNo())) {
+//                                continue;
+//                            }
+//
+//                            //将专利丢入各生产线程,进行生产和消费
+//                            UploadParamsVO uploadParamsVO = new UploadParamsVO();
+//                            uploadParamsVO.setPatent(new Patent());
+//                            uploadParamsVO.getPatent().setPatentNo(starPatents.get(j).getPatentNo());
+//                            uploadPatentBatchService.getOneOrInsertOne(uploadParamsVO);
+//
+//                            PQueueData pQueueData = new PQueueData()
+//                                    .setTask(task)
+//                                    .setStarPatent(starPatents.get(j))
+//                                    .setUploadParamsVO(uploadParamsVO);
+//
+//                            //专利丢入著录生产者队列,并唤醒著录生产者线程
+//                            if (cells.contains("1")) {
+//                                pantentQueueService.zhuluToPQueue(pQueueData);
+//                            }
+//                            //专利丢入权要生产者队列,并唤醒权要生产者线程
+//                            if (cells.contains("2")) {
+//                                pantentQueueService.rightToPQueue(pQueueData);
+//                            }
+//                            //专利丢入说明书文本生产者队列,并唤醒说明书文本生产者线程
+//                            if (cells.contains("3")) {
+//                                pantentQueueService.instructionTextToPQueue(pQueueData);
+//                            }
+//                            //专利丢入说明书pdf生产者队列,并唤醒说明书pdf生产者线程
+//                            if (cells.contains("4")) {
+//                                pantentQueueService.instructionPDFToPQueue(pQueueData);
+//                            }
+//                            //专利丢入摘要附图生产者队列,并唤醒摘要附图生产者线程
+//                            if (cells.contains("6")) {
+//                                pantentQueueService.imageToPQueue(pQueueData);
+//                            }
+//
+//                            produceSuccessNum++;  //计数,每生产完一个,生产完成数量++
+//
+//                        }
+//                    }
+//
+//                }
+
+        }
+        SavePatentToEsThread savePatentToEsThread = new SavePatentToEsThread(taskThread, taskThread.getApplicationContext());
+        GetPatentFromExcelThread getPatentFromExcelThread = new GetPatentFromExcelThread(taskThread.getImportTaskAMVO(), savePatentToEsThread, taskThread.getApplicationContext());
+        savePatentToEsThread.start();
+        getPatentFromExcelThread.start();
+    }
+
+    private void excuteLessThan10000(ImportTaskAMVO importTaskAMVO) {
+        try {
+            Integer successNum = importTaskAMVO.getSuccessNum();  //成功条数(即上一次下载到的位置)
+            String conditions = importTaskAMVO.getCondition();  //检索式
+            String orderBy = importTaskAMVO.getOrderBy();  //排序字段
+            String orderByType = importTaskAMVO.getOrderByType();  //排序类型
+            String dbType = importTaskAMVO.getDBType();  //检索数据库类型
+            Integer importContent = importTaskAMVO.getImportContent();  //下载字段
+            //十进制转二进制
+            String imContents = MathUtils.fun(2, importContent);
+            //下载字段
+            char[] importCells = imContents.toCharArray();
+
+            //startToEndNum:起止条数中需要下载的专利总数量
+            int startToEndNum = 0;
+//            if (endNumber > 0) {
+//                startToEndNum = endNumber - startNumber + 1;
+//                if (isDeletePatentNos != null && isDeletePatentNos.size() > 0) {
+//                    startToEndNum = startToEndNum - isDeletePatentNos.size();
+//                }
+//            }
+//
+//            //如果完成数量大于0,则当前下载任务为暂停后的继续下载,则开始位置更新
+//            if (successNum > 0) {
+//                if (startNumber == null) {  //多个专利号导入任务没有startNumber这些值
+//                    startNumber = 0;
+//                }
+//                startNumber += successNum;
+//            }
+//
+//            //若有起止条数,并且完成条数在起止条数内(即起止条数中专利还没有下载完)
+//            if (endNumber > 0 && startNumber <= endNumber && successNum < startToEndNum) {
+//                Calculate calculate = calculateFromStartAndEndNumber(startNumber, endNumber);
+//                Integer startPage = calculate.getStartPage();
+//                Integer startNum = calculate.getStartNum();
+//                Integer endPage = calculate.getEndPage();
+//                Integer endNum = calculate.getEndNum();
+//
+//                //根据计算出的起止页数,一页一页检索
+//                for (int i = startPage; i <= endPage; i++) {
+//                    PatentStarListDto patentStarListDto = new PatentStarListDto()
+//                            .setCurrentQuery(conditions)
+//                            .setOrderBy(orderBy)
+//                            .setOrderByType(orderByType)
+//                            .setPageNum(i)
+//                            .setRowCount(50)
+//                            .setDBType(dbType);
+//                    //调用一般接口返回一批专利著录相关数据
+//                    Map<String, Object> resultMap = patentStarApiService.patentStarSearchApi(patentStarListDto);
+//                    if (resultMap == null || (Integer) resultMap.get("total") == 0) {
+//                        ThrowException.throwXiaoShiException("未检索到相关专利");
+//                    }
+//
+//                    List<StarPatentVO> starPatents = (List<StarPatentVO>) resultMap.get("records");
+//                    //遍历这一页的专利
+//                    for (int j = 0; j < starPatents.size(); j++) {
+//                        //若任务状态为已暂停,则结束生产
+////                        if (pTaskId.equals(task.getId()) && pTaskStatus == 4) {
+////                            return;
+////                        }
+//                        //若还没到开始页的开始位置,则跳过,不下载它
+////                        if (i == startPage && j < startNum - 1) {
+////                            continue;
+////                        }
+////                        //若到了结束页的结束位置
+////                        if (i == endPage && j == endNum) {
+////                            break;
+////                        }
+//                        //若当前遍历到的专利号是需要删除的专利,则跳过,不下载它
+////                        if (isDeletePatentNos != null && isDeletePatentNos.size() > 0 && isDeletePatentNos.contains(starPatents.get(j).getApplicationNo())) {
+////                            continue;
+////                        }
+//
+//                        //将专利丢入各生产线程,进行生产和消费
+//                        UploadParamsVO uploadParamsVO = new UploadParamsVO();
+//                        uploadParamsVO.setPatent(new Patent());
+//                        uploadParamsVO.getPatent().setPatentNo(starPatents.get(j).getPatentNo());
+//
+//                        PQueueData pQueueData = new PQueueData()
+//                                .setTask(task)
+//                                .setStarPatent(starPatents.get(j))
+//                                .setUploadParamsVO(uploadParamsVO);
+//
+//                        //专利丢入著录生产者队列,并唤醒著录生产者线程
+//                        if (cells.contains("1")) {
+//                            pantentQueueService.zhuluToPQueue(pQueueData);
+//                        }
+//                        //专利丢入权要生产者队列,并唤醒权要生产者线程
+//                        if (cells.contains("2")) {
+//                            pantentQueueService.rightToPQueue(pQueueData);
+//                        }
+//                        //专利丢入说明书文本生产者队列,并唤醒说明书文本生产者线程
+//                        if (cells.contains("3")) {
+//                            pantentQueueService.instructionTextToPQueue(pQueueData);
+//                        }
+//                        //专利丢入说明书pdf生产者队列,并唤醒说明书pdf生产者线程
+//                        if (cells.contains("4")) {
+//                            pantentQueueService.instructionPDFToPQueue(pQueueData);
+//                        }
+//                        //专利丢入摘要附图生产者队列,并唤醒摘要附图生产者线程
+//                        if (cells.contains("6")) {
+//                            pantentQueueService.imageToPQueue(pQueueData);
+//                        }
+//
+//                    }
+//
+//                }
+//            }
+//
+//            //下载 isAdd中的专利
+//            if (isAddPatentNos != null && isAddPatentNos.size() > 0) {
+//                String patentNoCondition = StringUtils.join(isAddPatentNos, " OR ");
+//                conditions = "AN=(" + patentNoCondition + ")";
+//                downLoadIsAddPatentNos(isAddPatentNos, task, orderBy, orderByType, dbType, cells, conditions);
+//            }
+//
+        } catch (Exception e) {
+            e.printStackTrace();
+            //生产消费到一半时,发生错误异常,将任务状态置为完成
+//            task = taskService.getById(task.getId());
+//            task.setStatus(2);
+//            taskService.updateById(task);
+        }
+    }
+
+    @Override
+    public void setTaskThread(TaskThread taskThread) {
+        this.taskThread = taskThread;
+        ApplicationContext applicationContext = taskThread.getApplicationContext();
+        this.patentStarApiService = applicationContext.getBean(PatentStarApiService.class);
+    }
+}

+ 54 - 12
src/main/java/cn/cslg/pas/service/importPatent/SavePatentToEsThread.java

@@ -1,9 +1,14 @@
 package cn.cslg.pas.service.importPatent;
 package cn.cslg.pas.service.importPatent;
 
 
+import cn.cslg.pas.common.utils.FormatUtil;
 import cn.cslg.pas.common.vo.ImportTaskAMVO;
 import cn.cslg.pas.common.vo.ImportTaskAMVO;
+import cn.cslg.pas.common.vo.PatentWithIdVO;
 import cn.cslg.pas.domain.es.Patent;
 import cn.cslg.pas.domain.es.Patent;
+import cn.cslg.pas.domain.es.PatentJoin;
 import cn.cslg.pas.service.business.es.EsService;
 import cn.cslg.pas.service.business.es.EsService;
 import cn.cslg.pas.service.common.FileManagerService;
 import cn.cslg.pas.service.common.FileManagerService;
+import cn.cslg.pas.service.common.MessageService;
+import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.ApplicationContext;
 import org.springframework.context.ApplicationContext;
 
 
@@ -21,47 +26,84 @@ public class SavePatentToEsThread extends Thread {
     private final Lock taskLock = new ReentrantLock();
     private final Lock taskLock = new ReentrantLock();
     private final Condition taskCondition = taskLock.newCondition();
     private final Condition taskCondition = taskLock.newCondition();
     private TaskThread taskThread;
     private TaskThread taskThread;
-    private Boolean ifProductAll= false;
+    private Boolean ifProductAll = false;
+
     @Override
     @Override
     public void run() {
     public void run() {
-        while (!ifProductAll||patents.size()>0) {
+        while (!ifProductAll || patents.size() > 0) {
             try {
             try {
+
                 //判断任务队列是否有任务,若没有则线程等待唤醒
                 //判断任务队列是否有任务,若没有则线程等待唤醒
                 if (patents.size() == 0) {
                 if (patents.size() == 0) {
                     taskLock.lock();
                     taskLock.lock();
                     taskCondition.await();
                     taskCondition.await();
                 }
                 }
-             Patent patent=   patents.remove(0);
+
+                Patent patent = patents.remove(0);
                 //根据专利号查询专利
                 //根据专利号查询专利
+                EsService esService = applicationContext.getBean(EsService.class);
+                PatentWithIdVO patentWithIdVO = esService.getIdByPatentNo(patent.getPatentNo());
+
+                String patentId =null;
+                // 若查出专利则更新
+                if (patentWithIdVO != null) {
+                    patentId =patentWithIdVO.getId();
+                    Patent orgPatent = patentWithIdVO.getPatent();
+                    BeanUtils.copyProperties(patent, orgPatent, FormatUtil.getNullPropertyNames(patent));
+                    esService.updateDocument(orgPatent, patentWithIdVO.getId());
+                } else {
+                    PatentJoin patentJoin =new PatentJoin();
+                    patentJoin.setName("patent");
+                    patent.setPatentJoin(patentJoin);
+                    patentId =  esService.addPatent(patent);
+
+                }
+                //判断是否和专题库或报告关联
+                ImportTaskAMVO importTaskAMVO = taskThread.getImportTaskAMVO();
 
 
-                EsService esService =applicationContext.getBean(EsService.class);
-                esService.addPatent(patent);
-                System.out.println("patent"+patent.getPatentNo()+"done");
+                //和专题库或报告进行关联
+                if (importTaskAMVO.getProjectId() != null) {
+                    if(patentId!=null){
+                        Patent patentChild =new Patent();
+                        PatentJoin patentJoin =new PatentJoin();
+                        patentJoin.setParent(patentId);
+                        patentJoin.setName("project");
+                        patentChild.setPatentJoin(patentJoin);
+                        patentChild.setProjectId(importTaskAMVO.getProjectId());
+                     esService.addChildPatent(patentChild ,patentId);
+
+                    }
+
+                }
+                //导入完成,通知前台
+                MessageService messageService = applicationContext.getBean(MessageService.class);
+
+                messageService.sendWebsocketMessage(importTaskAMVO, 1, 1, Long.parseLong("11"));
+                System.out.println("patent" + patent.getPatentNo() + "done");
             } catch (Exception e) {
             } catch (Exception e) {
                 System.out.println(e);
                 System.out.println(e);
             }
             }
         }
         }
-      taskThread.awakeTaskThread();
+        taskThread.awakeTaskThread();
     }
     }
 
 
     public SavePatentToEsThread(TaskThread taskThread, ApplicationContext applicationContext) {
     public SavePatentToEsThread(TaskThread taskThread, ApplicationContext applicationContext) {
-        this.taskThread=taskThread;
-        this.applicationContext =applicationContext;
+        this.taskThread = taskThread;
+        this.applicationContext = applicationContext;
     }
     }
 
 
 
 
     public void awakeTask(Patent patent) {
     public void awakeTask(Patent patent) {
         patents.add(patent);
         patents.add(patent);
         if (taskLock.tryLock()) {
         if (taskLock.tryLock()) {
-
             taskCondition.signalAll();
             taskCondition.signalAll();
             taskLock.unlock();
             taskLock.unlock();
         }
         }
     }
     }
 
 
-    public void setIfProductAll(Boolean ifProductAll){
+    public void setIfProductAll(Boolean ifProductAll) {
 
 
-        this.ifProductAll=ifProductAll;
+        this.ifProductAll = ifProductAll;
 
 
     }
     }
 }
 }

+ 4 - 1
src/main/java/cn/cslg/pas/service/importPatent/SchedulingTaskService.java

@@ -57,7 +57,7 @@ public class SchedulingTaskService {
         List<ImportTaskAMVO> importTaskAMVOS = new ArrayList<>();
         List<ImportTaskAMVO> importTaskAMVOS = new ArrayList<>();
         List<Integer> taskConditionIds = new ArrayList<>();
         List<Integer> taskConditionIds = new ArrayList<>();
         List<ImportTaskCondition> importTaskConditions = new ArrayList<>();
         List<ImportTaskCondition> importTaskConditions = new ArrayList<>();
-        taskConditionIds =importTaskList.stream().map(ImportTask::getId).collect(Collectors.toList());
+        taskConditionIds =importTaskList.stream().map(ImportTask::getImportTaskConditionId).collect(Collectors.toList());
         //根据taskid查询taskCondition
         //根据taskid查询taskCondition
         if (taskConditionIds.size() != 0) {
         if (taskConditionIds.size() != 0) {
             LambdaQueryWrapper<ImportTaskCondition> queryWrapper = new LambdaQueryWrapper<>();
             LambdaQueryWrapper<ImportTaskCondition> queryWrapper = new LambdaQueryWrapper<>();
@@ -72,6 +72,9 @@ public class SchedulingTaskService {
             if(importTaskCondition!=null) {
             if(importTaskCondition!=null) {
                 importTaskAMVO.setFileGuid(importTaskCondition.getFileGuid());
                 importTaskAMVO.setFileGuid(importTaskCondition.getFileGuid());
                 importTaskAMVO.setSourceId(importTaskCondition.getSourceId());
                 importTaskAMVO.setSourceId(importTaskCondition.getSourceId());
+                importTaskAMVO.setProjectId(importTaskCondition.getProjectId());
+                importTaskAMVO.setProductId(importTaskCondition.getProductId());
+                importTaskAMVO.setImportContent(1);
             }
             }
             importTaskAMVOS.add(importTaskAMVO);
             importTaskAMVOS.add(importTaskAMVO);
 
 

+ 0 - 1
src/main/java/cn/cslg/pas/service/importPatent/TaskThread.java

@@ -57,7 +57,6 @@ public class TaskThread extends Thread {
         } catch (InterruptedException e) {
         } catch (InterruptedException e) {
             e.printStackTrace();
             e.printStackTrace();
         }
         }
-//        importTaskAdd.startTask();
         System.out.println("任务结束");
         System.out.println("任务结束");
     }
     }
 
 

+ 23 - 0
src/main/resources/mapper/WebLoginConfigMapper.xml

@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+
+<mapper namespace="cn.cslg.pas.mapper.WebLoginConfigMapper">
+    <select id="getPageList" parameterType="cn.cslg.pas.common.vo.QueryConfigVO"
+            resultType="cn.cslg.pas.common.vo.ConfigVO">
+        select web_name as webName,web_address as webAddress ,login_account as loginAccount ,login_password as
+        loginPassword,b.id as id
+        ,a.id as webId
+        from web_config a
+        left join web_login_config b
+        on a.id=b.web_id
+        <where>
+            b.tenant_id=#{params.tenantId}
+            <if test="params.webId !=null">
+                and a.id =#{params.webId}
+            </if>
+            <if test="params.loginAccount!=null and params.loginAccount!='' ">
+                and b.login_account like concat('%',#{params.loginAccount}, '%')
+            </if>
+        </where>
+    </select>
+</mapper>

+ 10 - 8
src/test/java/cn/cslg/pas/service/CommonServiceTests.java

@@ -3,6 +3,7 @@ package cn.cslg.pas.service;
 import cn.cslg.pas.common.model.common.QueryCondition;
 import cn.cslg.pas.common.model.common.QueryCondition;
 import cn.cslg.pas.common.model.request.QueryRequest;
 import cn.cslg.pas.common.model.request.QueryRequest;
 import cn.cslg.pas.common.model.request.StringRequest;
 import cn.cslg.pas.common.model.request.StringRequest;
+import cn.cslg.pas.common.utils.MathUtils;
 import cn.cslg.pas.common.utils.Response;
 import cn.cslg.pas.common.utils.Response;
 import cn.cslg.pas.common.vo.DepartmentVO;
 import cn.cslg.pas.common.vo.DepartmentVO;
 import cn.cslg.pas.common.vo.business.ScenarioVO;
 import cn.cslg.pas.common.vo.business.ScenarioVO;
@@ -12,6 +13,7 @@ import cn.cslg.pas.domain.business.Matter;
 import cn.cslg.pas.service.business.CommonService;
 import cn.cslg.pas.service.business.CommonService;
 import cn.cslg.pas.service.importPatent.SchedulingTaskService;
 import cn.cslg.pas.service.importPatent.SchedulingTaskService;
 import cn.cslg.pas.service.permissions.PermissionService;
 import cn.cslg.pas.service.permissions.PermissionService;
+import com.alibaba.druid.sql.visitor.functions.Char;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSON;
 import org.assertj.core.internal.Arrays;
 import org.assertj.core.internal.Arrays;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.Test;
@@ -30,8 +32,6 @@ import java.util.stream.Collectors;
 @SpringBootTest
 @SpringBootTest
 public class CommonServiceTests {
 public class CommonServiceTests {
     @Autowired
     @Autowired
-    private EventController eventController;
-    @Autowired
     private PermissionService permissionService;
     private PermissionService permissionService;
     @Autowired
     @Autowired
     private CommonController commonController;
     private CommonController commonController;
@@ -61,9 +61,7 @@ public class CommonServiceTests {
         List<Integer> scenarioIds = new ArrayList<>();
         List<Integer> scenarioIds = new ArrayList<>();
         scenarioIds.add(1);
         scenarioIds.add(1);
         scenarioIds.add(2);
         scenarioIds.add(2);
-//        scenarioIds.add(3);
-//        List<Matter> matterIds = commonController.queryMatter(scenarioIds);
-//        System.out.println(matterIds);
+
     }
     }
 
 
     @Test
     @Test
@@ -75,15 +73,19 @@ public class CommonServiceTests {
      List<DepartmentVO> departmentVOS = JSON.parseArray(json,DepartmentVO.class);
      List<DepartmentVO> departmentVOS = JSON.parseArray(json,DepartmentVO.class);
      System.out.println(departmentVOS);
      System.out.println(departmentVOS);
 
 
-//        scenarioIds.add(3);
-//        List<Matter> matterIds = commonController.queryMatter(scenarioIds);
-//        System.out.println(matterIds);
     }
     }
     @Test
     @Test
     void testImportTask() throws IOException, InterruptedException {
     void testImportTask() throws IOException, InterruptedException {
         schedulingTaskService.startTask();
         schedulingTaskService.startTask();
          Thread.sleep(1000000);
          Thread.sleep(1000000);
     }
     }
+    @Test
+    void test23()  {
+    String a=    MathUtils.fun(2,2);
+       char[] ab =  a.toCharArray();
+    System.out.println(a);
+    System.out.println(ab);
+    }
 
 
 
 
 }
 }

+ 4 - 7
src/test/java/cn/cslg/pas/service/EsServiceTests.java

@@ -1,10 +1,8 @@
 package cn.cslg.pas.service;
 package cn.cslg.pas.service;
 
 
-import cn.cslg.pas.common.dto.business.ProductMarketDataDTO;
 import cn.cslg.pas.common.utils.FormatUtil;
 import cn.cslg.pas.common.utils.FormatUtil;
 import cn.cslg.pas.common.utils.RedisUtil;
 import cn.cslg.pas.common.utils.RedisUtil;
 import cn.cslg.pas.common.vo.PatentWithIdVO;
 import cn.cslg.pas.common.vo.PatentWithIdVO;
-import cn.cslg.pas.controller.ProductMarketDataController;
 import cn.cslg.pas.domain.es.Patent;
 import cn.cslg.pas.domain.es.Patent;
 import cn.cslg.pas.service.business.es.EsService;
 import cn.cslg.pas.service.business.es.EsService;
 
 
@@ -14,8 +12,7 @@ import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.boot.test.context.SpringBootTest;
 
 
-import java.text.SimpleDateFormat;
-import java.util.Date;
+import java.util.List;
 
 
 /**
 /**
  * @author chenyu
  * @author chenyu
@@ -52,12 +49,12 @@ public class EsServiceTests {
     }
     }
 
 
     @Test
     @Test
-    void updatePatent() throws Exception{
-    }
+    void updatePatent() throws Exception{}
 
 
     @Test
     @Test
     void addImportTask() throws  Exception {
     void addImportTask() throws  Exception {
-
+        List<Patent> patentList = esService.searchChild("1",1,10);
+        System.out.println(patentList);
         Thread.sleep(1000000);
         Thread.sleep(1000000);
     }
     }
 }
 }

+ 0 - 4
src/test/java/cn/cslg/pas/service/EventServiceTests.java

@@ -69,12 +69,8 @@ public class EventServiceTests {
         );
         );
         list.add(mulFile);
         list.add(mulFile);
         eventController.addEvent(json_to_string, list);
         eventController.addEvent(json_to_string, list);
-
-
-
     }
     }
 
 
-
     @Test
     @Test
     void groupEvent() throws Exception {
     void groupEvent() throws Exception {
         StringGroupRequest queryRequest = new StringGroupRequest();
         StringGroupRequest queryRequest = new StringGroupRequest();