Parcourir la source

Merge remote-tracking branch 'origin/master'

lwhhszx il y a 1 an
Parent
commit
48eea35085
1 fichiers modifiés avec 29 ajouts et 32 suppressions
  1. 29 32
      src/main/java/cn/cslg/pas/service/business/es/EsService.java

+ 29 - 32
src/main/java/cn/cslg/pas/service/business/es/EsService.java

@@ -181,7 +181,7 @@ public class EsService {
         //1. 解析检索条件
         treeNode tree = expressManager.getInstance().Parse(condition, false);
         //3. 从es中检索数据
-        Query q = formatQueryService.EsQueryToQuery((operateNode) tree, "patent",projectId);
+        Query q = formatQueryService.EsQueryToQuery((operateNode) tree, "patent", projectId);
         builder.query(q);
         //判断同族分组
         String str = "";
@@ -261,7 +261,7 @@ public class EsService {
             List<StringTermsBucket> termsBuckets = agg.sterms().buckets().array();
             for (StringTermsBucket termsBucket : termsBuckets) {
                 String key = termsBucket.key().stringValue();
-                PatentColumnDTO columnDTO = this.getPatentColumnDTO(key, projectId,esField);
+                PatentColumnDTO columnDTO = this.getPatentColumnDTO(key, projectId, esField);
                 list.add(columnDTO);
             }
         } else {
@@ -344,7 +344,7 @@ public class EsService {
     }
 
     //拼接专题库id或其他id条件
-    public String appendIdsCondition(String searchCondition,Integer taskId,String productFrom,Integer projectId,Integer productId) {
+    public String appendIdsCondition(String searchCondition, Integer taskId, String productFrom, Integer projectId, Integer productId) {
         String condition = "";
         if (taskId != null) {
             if (searchCondition != null && !"".equals(searchCondition.trim())) {
@@ -546,10 +546,8 @@ public class EsService {
         Query q1 = QueryBuilders.hasParent(i -> i.parentType("patent").query(j -> j.ids(IdsQuery.of(k -> k.values(parentId)))));
         Query q2 = QueryBuilders.exists(i -> i.field("custom_field"));
         Query q3 = QueryBuilders.term(i -> i.field("custom_field.project_id").value(projectId));
-
         Query q4 = QueryBuilders.term(i -> i.field("custom_field.field").value(fieldId));
-        Query finalQ = q3;
-        Query bool = QueryBuilders.bool(i -> i.must(q1, q2, finalQ, q4));
+        Query bool = QueryBuilders.bool(i -> i.must(q1, q2, q3, q4));
         builder.query(bool);
 
         List<SortOptions> optionsList = new ArrayList<>();
@@ -639,7 +637,7 @@ public class EsService {
         String dateStr = "\'" + s + "\'";
         String projectId = "ctx._source.custom_field.project_id = " + customField.getProjectId() + ";";
         String taskId = "ctx._source.custom_field.task_id = " + customField.getTaskId() + ";";
-        String ifNew = "ctx._source.custom_field.if_new = " + 1+ ";";
+        String ifNew = "ctx._source.custom_field.if_new = " + 1 + ";";
         String field = "ctx._source.custom_field.field=" + customField.getField() + ";";
         String fieldType = "ctx._source.custom_field.field_type = " + customField.getFieldType() + ";";
         String personId = "ctx._source.custom_field.person_id = " + customField.getPersonId() + ";";
@@ -647,11 +645,10 @@ public class EsService {
         String fieldValue = "ctx._source.custom_field.field_value = " + valueField + ";";
         String statsValue = "ctx._source.custom_field.stats_value = " + valueStats;
 
-        String source = projectId + taskId + field + fieldType + personId + createTime + fieldValue + statsValue;
+        String source = projectId + taskId + ifNew + field + fieldType + personId + createTime + fieldValue + statsValue;
         InlineScript inlineScript = InlineScript.of(i -> i.lang("painless").source(source));
         Script script = Script.of(i -> i.inline(inlineScript));
         Query query = QueryBuilders.term(i -> i.field("_id").value(id));
-        //.waitForActiveShards(WaitForActiveShards.of(t -> t.count(1)))
         UpdateByQueryRequest request = UpdateByQueryRequest.of(i -> i.index("patent").script(script).refresh(true).query(query));
         try {
             client.updateByQuery(request);
@@ -1166,28 +1163,28 @@ public class EsService {
                     legalEvents.add(item.source());
                 });
             }
-               if(!cnLegalApiStr.contains("408")) {
-                   List<ChinaLeagalStatus> chinaLeagalStatuses = JSON.parseArray(cnLegalApiStr, ChinaLeagalStatus.class);
-                   chinaLeagalStatuses.forEach(item -> {
-                       LegalEvent tem = legalEvents.stream().filter(em -> em.getEventDate() != null && em.getEventDate().compareTo(item.getLegalDate()) == 0).findFirst().orElse(null);
-                       if (tem == null) {
-                           LegalEvent legalEvent1 = new LegalEvent();
-                           legalEvent1.setEventDate(item.getLegalDate());
-                           legalEvent1.setCode(item.getLegalCode());
-                           legalEvent1.setAppNo(starPatentVO.getApplicationNo());
-                           legalEvent1.setGrantNo(starPatentVO.getPublicAccreditNo());
-                           legalEvent1.setPublicNo(starPatentVO.getPublicNo());
-                           legalEvent1.setDescription(item.getLegalStatusInfo());
-                           legalEvent1.setName(item.getLegalStatus());
-                           try {
-                               String reId = this.addLegalEvent(legalEvent1);
-                           } catch (Exception e) {
-                               throw new XiaoShiException(e.getMessage());
-                           }
-                       }
-
-                   });
-               }
+            if (!cnLegalApiStr.contains("408")) {
+                List<ChinaLeagalStatus> chinaLeagalStatuses = JSON.parseArray(cnLegalApiStr, ChinaLeagalStatus.class);
+                chinaLeagalStatuses.forEach(item -> {
+                    LegalEvent tem = legalEvents.stream().filter(em -> em.getEventDate() != null && em.getEventDate().compareTo(item.getLegalDate()) == 0).findFirst().orElse(null);
+                    if (tem == null) {
+                        LegalEvent legalEvent1 = new LegalEvent();
+                        legalEvent1.setEventDate(item.getLegalDate());
+                        legalEvent1.setCode(item.getLegalCode());
+                        legalEvent1.setAppNo(starPatentVO.getApplicationNo());
+                        legalEvent1.setGrantNo(starPatentVO.getPublicAccreditNo());
+                        legalEvent1.setPublicNo(starPatentVO.getPublicNo());
+                        legalEvent1.setDescription(item.getLegalStatusInfo());
+                        legalEvent1.setName(item.getLegalStatus());
+                        try {
+                            String reId = this.addLegalEvent(legalEvent1);
+                        } catch (Exception e) {
+                            throw new XiaoShiException(e.getMessage());
+                        }
+                    }
+
+                });
+            }
 
         }
         return "";
@@ -1222,7 +1219,7 @@ public class EsService {
             Patent esMess = hit.source();
             if (esMess != null) {
                 dto.setClaimContent(esMess.getClaim());
-                    dto.setClaim(esMess.getClaim().get(0).getTextContent());
+                dto.setClaim(esMess.getClaim().get(0).getTextContent());
             }
         }
         return dto;