Przeglądaj źródła

fixed 批量删除对比结果

zero 1 rok temu
rodzic
commit
1b2df79cb3

+ 13 - 0
src/main/java/cn/cslg/pas/common/dto/es/DelPatentsDTO.java

@@ -0,0 +1,13 @@
+package cn.cslg.pas.common.dto.es;
+
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class DelPatentsDTO {
+
+    private List<String> patentNos;
+
+    private Integer projectId;
+}

+ 12 - 0
src/main/java/cn/cslg/pas/controller/PatentController.java

@@ -6,6 +6,7 @@ import cn.cslg.pas.common.dto.PatentExport.PatentExportParams;
 import cn.cslg.pas.common.dto.PatentExport.TaskParams;
 import cn.cslg.pas.common.dto.business.EsCountDTO;
 import cn.cslg.pas.common.dto.business.SelectClaimDTO;
+import cn.cslg.pas.common.dto.es.DelPatentsDTO;
 import cn.cslg.pas.common.dto.es.EsDateRangeDTO;
 import cn.cslg.pas.common.dto.es.EsValueCurveDTO;
 import cn.cslg.pas.common.dto.es.RefreshPatentDTO;
@@ -362,4 +363,15 @@ public class PatentController {
         }
           return Response.success("刷新成功");
     }
+
+    @Operation(summary = "批量删除专利")
+    @PostMapping("/deletePatents")
+    public Response deletePatents(@RequestBody DelPatentsDTO vo) throws Exception {
+        try {
+            esService.deletePatents(vo);
+            return Response.success("删除成功");
+        } catch (Exception e) {
+            return Response.error("删除失败");
+        }
+    }
 }

+ 18 - 0
src/main/java/cn/cslg/pas/service/business/es/EsService.java

@@ -9,6 +9,7 @@ import cn.cslg.pas.common.dto.PatentStarListDTO;
 import cn.cslg.pas.common.dto.business.ContentDetailDTO;
 import cn.cslg.pas.common.dto.business.EsPatentFamilyDTO;
 import cn.cslg.pas.common.dto.business.SelectClaimDTO;
+import cn.cslg.pas.common.dto.es.DelPatentsDTO;
 import cn.cslg.pas.common.dto.es.EsCustomFieldValueDTO;
 import cn.cslg.pas.common.model.request.MapRequest;
 import cn.cslg.pas.common.model.request.OrderDTO;
@@ -43,6 +44,8 @@ import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Lazy;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Propagation;
+import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.CollectionUtils;
 
 import java.io.IOException;
@@ -1338,6 +1341,21 @@ public class EsService {
         return list;
     }
 
+    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Throwable.class)
+    public Boolean deletePatents(DelPatentsDTO vo) throws IOException {
+        Integer projectId = vo.getProjectId();
+        List<String> list = vo.getPatentNos();
+        for (String patentNo : list) {
+            Integer number = this.getPatent(patentNo, projectId);
+            if (number < 1) {
+                throw new XiaoShiException("删除失败");
+            } else {
+                return false;
+            }
+        }
+        return true;
+    }
+
     public Integer getPatent(String patentNo, Integer projectId) throws IOException {
         SearchRequest.Builder builder = new SearchRequest.Builder();
         //设置查询索引