Bladeren bron

fixed 批量删除对比结果

zero 1 jaar geleden
bovenliggende
commit
39e2c8afb9

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

@@ -366,7 +366,7 @@ public class PatentController {
 
     @Operation(summary = "批量删除专利")
     @PostMapping("/deletePatents")
-    public Response deletePatents(@RequestBody DelPatentsDTO vo) throws Exception {
+    public Response deletePatents(@RequestBody EsCustomFieldBatchVO vo) throws Exception {
         try {
             esService.deletePatents(vo);
             return Response.success("删除成功");

+ 28 - 8
src/main/java/cn/cslg/pas/service/business/es/EsService.java

@@ -10,6 +10,7 @@ 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.EsCustomFieldDTO;
 import cn.cslg.pas.common.dto.es.EsCustomFieldValueDTO;
 import cn.cslg.pas.common.model.request.MapRequest;
 import cn.cslg.pas.common.model.request.OrderDTO;
@@ -20,6 +21,7 @@ import cn.cslg.pas.common.utils.parseQueryToTree.expressManager;
 import cn.cslg.pas.common.utils.parseQueryToTree.operateNode;
 import cn.cslg.pas.common.utils.parseQueryToTree.treeNode;
 import cn.cslg.pas.common.vo.*;
+import cn.cslg.pas.common.vo.es.EsCustomFieldBatchVO;
 import cn.cslg.pas.common.vo.es.PatentFamilyMessageWithId;
 import cn.cslg.pas.domain.es.*;
 import cn.cslg.pas.exception.XiaoShiException;
@@ -69,6 +71,8 @@ public class EsService {
     @Lazy
     @Autowired
     private EsCountService esCountService;
+    @Autowired
+    private EsCustomFieldService esCustomFieldService;
 
 
     /**
@@ -1342,15 +1346,31 @@ public class EsService {
     }
 
     @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Throwable.class)
-    public Boolean deletePatents(DelPatentsDTO vo) throws IOException {
+    public Boolean deletePatents(EsCustomFieldBatchVO vo) throws Exception {
         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;
+        Integer startNum = vo.getStartNumber();
+        Integer endNum = vo.getEndNumber();
+        List<String> isAdd = vo.getIsAdd();
+        List<String> isDel = vo.getIsDelete();
+        if (!CollectionUtils.isEmpty(isAdd) && startNum <= 1 && endNum < 1) {
+            isAdd.removeAll(isDel);
+            for (String patentNo : isAdd) {
+                Integer number = this.getPatent(patentNo, projectId);
+                if (number < 1) {
+                    throw new XiaoShiException("删除失败");
+                } else {
+                    return false;
+                }
+            }
+        } else if (startNum >= 1 && endNum > 0) {
+            List<String> patentNos = esCustomFieldService.getPatentNos(vo);
+            for (String patentNo : patentNos) {
+                Integer number = this.getPatent(patentNo, projectId);
+                if (number < 1) {
+                    throw new XiaoShiException("删除失败");
+                } else {
+                    return false;
+                }
             }
         }
         return true;