瀏覽代碼

Merge remote-tracking branch 'origin/dev2' into dev2

chendayu 2 年之前
父節點
當前提交
6775fdc67d

+ 6 - 13
PAS/src/main/java/cn/cslg/pas/common/model/dto/RetrieveRecordDTO.java

@@ -7,33 +7,26 @@ import java.util.Date;
 
 @Data
 public class RetrieveRecordDTO {
+
     private Integer id;
     /**
      * 检索式
      */
-
     private String conditions;
-
     /**
-     * 租户
+     * 数据库类型
      */
-
-    private String  tenantId;
+    private String dbType;
 
     /**
-     * 创建时间
-     */
-
-    private Date createTime;
-
-
-    private Integer createId;
-    /**
      * 检索时间
      */
     private Date retrieveTime;
+
     /**
      * 更新时间
      */
     private Date updateTime;
+
+    private Integer totalNum;
 }

+ 47 - 0
PAS/src/main/java/cn/cslg/pas/common/model/outApi/PatentStarDto.java

@@ -0,0 +1,47 @@
+package cn.cslg.pas.common.model.outApi;
+
+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;
+
+}

+ 1 - 2
PAS/src/main/java/cn/cslg/pas/common/model/outApi/PatentStarListDto.java

@@ -16,6 +16,7 @@ import javax.validation.constraints.NotNull;
 @Accessors(chain = true)
 @Data
 public class PatentStarListDto {
+    private Integer retrieveRecordId;
     /**
      * 检索式
      */
@@ -47,6 +48,4 @@ public class PatentStarListDto {
     @JsonProperty(value = "OrderByType")
     private String OrderByType;
 
-
-
 }

+ 14 - 0
PAS/src/main/java/cn/cslg/pas/common/model/outApi/RetrieveRecordDeDTO.java

@@ -0,0 +1,14 @@
+package cn.cslg.pas.common.model.outApi;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import lombok.Data;
+
+import java.util.Date;
+import java.util.List;
+
+@Data
+public class RetrieveRecordDeDTO {
+
+    private List<Integer> ids;
+    private Boolean isAll;
+}

+ 23 - 0
PAS/src/main/java/cn/cslg/pas/common/model/outApi/RetrieveRecordQueryDTO.java

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

+ 56 - 0
PAS/src/main/java/cn/cslg/pas/controller/RetrieveRecordController.java

@@ -0,0 +1,56 @@
+package cn.cslg.pas.controller;
+
+/**
+ * 检索历史的控制层
+ * @Author xiexiang
+ * @Date 2023/7/10
+ */
+
+import cn.cslg.pas.common.core.base.Constants;
+import cn.cslg.pas.common.model.dto.RetrieveRecordDTO;
+import cn.cslg.pas.common.model.outApi.RetrieveRecordDeDTO;
+import cn.cslg.pas.common.model.outApi.RetrieveRecordQueryDTO;
+import cn.cslg.pas.common.utils.Response;
+import cn.cslg.pas.domain.RetrieveRecord;
+import cn.cslg.pas.service.upLoadPatent.RetrieveRecordService;
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+@Tag(name = "无效理由和证据管理")
+@Slf4j
+@RequiredArgsConstructor
+@RestController
+@RequestMapping(Constants.API_VERSION_V2 + "/RetrieveRecord")
+public class RetrieveRecordController {
+    private final RetrieveRecordService retrieveRecordService;
+
+    @Operation(summary = "添加检索历史")
+    @PostMapping("/addRetrieveRecord")
+    public String addRetrieveRecord(@RequestBody RetrieveRecordDTO retrieveRecordDTO){
+        return Response.success(retrieveRecordService.addRetrieveRecord(retrieveRecordDTO));
+    }
+
+    @Operation(summary = "修改检索历史")
+    @PostMapping("/updateRetrieveRecord")
+    public String updateRetrieveRecord(@RequestBody RetrieveRecordDTO retrieveRecordDTO){
+        return Response.success(retrieveRecordService.updateRetrieveRecord(retrieveRecordDTO));
+    }
+
+    @Operation(summary = "查询检索历史")
+    @PostMapping("/queryRetrieveRecord")
+    public String queryRetrieveRecord(@RequestBody RetrieveRecordQueryDTO retrieveRecordQueryDTO){
+        return Response.success(retrieveRecordService.queryRetrieveRecord(retrieveRecordQueryDTO));
+    }
+
+    @Operation(summary = "删除检索历史")
+    @PostMapping("/deleteRetrieveRecord")
+    public String deleteRetrieveRecord(@RequestBody RetrieveRecordDeDTO retrieveRecordDeDTO){
+        retrieveRecordService.deleteRetrieveRecord(retrieveRecordDeDTO);
+        return Response.success("删除成功");
+    }
+}

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

@@ -28,7 +28,7 @@ public class PatentStarController {
     @PostMapping("/select")
     @Operation(summary = "一般检索接口")
     public String getAreaList(@RequestBody @Validated PatentStarListDto patentStarListDto) throws IOException {
-        Map<String, Object> map = patentStarApiService.patentStarSearchApi(patentStarListDto);
+        Map<String, Object> map = patentStarApiService.patentStarSearchLocal(patentStarListDto);
         if (map == null) {
             return Response.error("检索失败,请检查检索式");
         }

+ 14 - 8
PAS/src/main/java/cn/cslg/pas/domain/RetrieveRecord.java

@@ -16,24 +16,25 @@ import java.util.Date;
  */
 @Data
 @TableName(value ="retrieve_record")
-public class RetrieveRecord implements Serializable {
-    /**
-     * ID
-     */
-    @TableId(type = IdType.AUTO)
-    private Integer id;
+public class RetrieveRecord extends BaseEntity<RetrieveRecord> {
 
     /**
      * 检索式
      */
     @TableField(value = "conditions")
     private String conditions;
-
+    @TableField(value = "db_type")
+    private String dbType;
     /**
      * 租户
      */
     @TableField(value = "tenant_id")
-    private String  tenantId;
+    private Integer tenantId;
+    /**
+     * 总条数
+     */
+    @TableField(value = "total_num")
+    private Integer totalNum;
 
     /**
      * 创建时间
@@ -41,13 +42,18 @@ public class RetrieveRecord implements Serializable {
     @TableField(value = "create_time")
     private Date createTime;
 
+    /**
+     * 创建人id
+     */
     @TableField(value = "create_id")
     private Integer createId;
+
     /**
      * 检索时间
      */
     @TableField(value = "retrieve_time")
     private Date retrieveTime;
+
     /**
      * 更新时间
      */

+ 46 - 10
PAS/src/main/java/cn/cslg/pas/service/outApi/PatentStarApiService.java

@@ -1,16 +1,18 @@
 package cn.cslg.pas.service.outApi;
 
 import cn.cslg.pas.common.model.PatentCell;
-import cn.cslg.pas.common.model.dto.GetClaimsInfoParamsDTO;
-import cn.cslg.pas.common.model.dto.GetDescriptionInfoParamsDTO;
-import cn.cslg.pas.common.model.dto.GetFuTuParamsDTO;
-import cn.cslg.pas.common.model.dto.GetSearchBiblioParamsDTO;
+import cn.cslg.pas.common.model.PersonnelVO;
+import cn.cslg.pas.common.model.dto.*;
+import cn.cslg.pas.common.model.outApi.PatentStarDto;
 import cn.cslg.pas.common.model.outApi.PatentStarListDto;
 import cn.cslg.pas.common.model.vo.outApi.StarPatentVO;
+import cn.cslg.pas.common.utils.CacheUtils;
 import cn.cslg.pas.common.utils.FormatUtil;
 import cn.cslg.pas.common.utils.JsonUtils;
+import cn.cslg.pas.common.utils.SecurityUtils.LoginUtils;
 import cn.cslg.pas.common.utils.SecurityUtils.SecurityUtils;
 import cn.cslg.pas.domain.*;
+import cn.cslg.pas.service.upLoadPatent.RetrieveRecordService;
 import cn.hutool.crypto.SecureUtil;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
@@ -22,6 +24,7 @@ import lombok.extern.slf4j.Slf4j;
 import okhttp3.*;
 import org.apache.commons.lang3.StringEscapeUtils;
 import org.junit.Test;
+import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 
@@ -42,7 +45,9 @@ import java.util.regex.Pattern;
 @Service
 
 public class PatentStarApiService {
-
+    private  final RetrieveRecordService retrieveRecordService;
+    private final CacheUtils cacheUtils;
+    private final LoginUtils loginUtils;
     public static String formatValue(String value) {
         return value.replace("~", ">");
     }
@@ -209,17 +214,48 @@ public class PatentStarApiService {
             //法律状态
         });
     }
+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);
+    //记录检索历史
+    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 {
-            String formQuery = patentStarListDto.getCurrentQuery();
-            patentStarListDto.setCurrentQuery(PatentStarApiService.formatQuery(formQuery));
+                String formQuery = patentStarListDto.getCurrentQuery();
+                patentStarListDto.setCurrentQuery(PatentStarApiService.formatQuery(formQuery));
+
         } catch (Exception e) {
             return null;
         }
-
-        String json = JSONObject.toJSONString(patentStarListDto);
+        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 = "FNYJD7902206FFB741E163BE6536C3689D55" + currentTimeMillis.toString();
@@ -308,6 +344,7 @@ public class PatentStarApiService {
         return "{}";
     }
 
+
     /**
      * @param
      * @return
@@ -439,7 +476,6 @@ public class PatentStarApiService {
      * @author 李仁杰
      * 从专利之星获取中国专利全文图片
      */
-
     public String getCnPdfApi(String appNo) throws IOException {
         String url = "https://api.patentstar.com.cn/api/Patent/CnPdf/" + appNo;
         String appId = "2000041";

+ 93 - 10
PAS/src/main/java/cn/cslg/pas/service/upLoadPatent/RetrieveRecordService.java

@@ -1,40 +1,123 @@
 package cn.cslg.pas.service.upLoadPatent;
 
-import cn.cslg.pas.common.model.vo.AdminUserVO;
+import cn.cslg.pas.common.model.PersonnelVO;
+import cn.cslg.pas.common.model.dto.RetrieveRecordDTO;
+import cn.cslg.pas.common.model.outApi.RetrieveRecordDeDTO;
+import cn.cslg.pas.common.model.outApi.RetrieveRecordQueryDTO;
+import cn.cslg.pas.common.utils.CacheUtils;
 import cn.cslg.pas.common.utils.Response;
-import cn.cslg.pas.common.utils.StringUtils;
-import cn.cslg.pas.domain.AdminUser;
+import cn.cslg.pas.common.utils.SecurityUtils.LoginUtils;
 import cn.cslg.pas.domain.RetrieveRecord;
-import cn.cslg.pas.mapper.AdminUserMapper;
 import cn.cslg.pas.mapper.RetrieveRecordMapper;
-import cn.hutool.crypto.SecureUtil;
-import com.baomidou.mybatisplus.annotation.IdType;
-import com.baomidou.mybatisplus.annotation.TableField;
-import com.baomidou.mybatisplus.annotation.TableId;
 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.ArrayList;
 import java.util.Date;
+import java.util.List;
 
 /**
  * <p>
  * 检索记录表
  * </p>
  *
- * @author 李仁杰
+ * @author 谢翔
  * @since 2022-07-9
  */
 @Service
 @RequiredArgsConstructor(onConstructor_ = {@Lazy})
 public class RetrieveRecordService extends ServiceImpl<RetrieveRecordMapper, RetrieveRecord> {
+    private final CacheUtils cacheUtils;
+    private final LoginUtils loginUtils;
 
-    public  void addRetrieveRecord(){
+    /**
+     * 新增检索记录
+     * @param retrieveRecordDTO
+     */
+    public String 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 String 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 String 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());
+        Integer 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;
     }
 }

+ 13 - 1
PAS/src/main/resources/mapper/TaskMapper.xml

@@ -128,6 +128,18 @@
         <result column="isadd_patentnos" property="isAddPatentNos"/>
         <result column="isdelete_patentnos" property="isDeletePatentNos"/>
     </resultMap>
-
+    <select id="queryTask" resultMap="queryTasksMap">
+        select tas.*
+        from os_task tas
+        left join task_condition ass on tas.task_condition_id = ass.id
+        <where>
+            (tas.task_condition_id is null
+            or tas.id in (
+            select a1
+            .id from os_task a1 left join os_task a2 on a1.task_condition_id =a2.task_condition_id and
+            a1.create_time &lt;= a2.create_time group by a1.task_condition_id having count(*)=1)
+            )
+        </where>
+    </select>
 
 </mapper>