zero 1 rok temu
rodzic
commit
34246d30c4

+ 83 - 0
src/main/java/cn/cslg/pas/factorys/EsBuilderFactory/IdsQueryBuilder.java

@@ -0,0 +1,83 @@
+package cn.cslg.pas.factorys.EsBuilderFactory;
+
+import co.elastic.clients.elasticsearch._types.query_dsl.Query;
+import co.elastic.clients.elasticsearch._types.query_dsl.QueryBuilders;
+import org.springframework.stereotype.Component;
+
+import java.text.ParseException;
+import java.util.Arrays;
+import java.util.List;
+
+@Component
+public class IdsQueryBuilder implements IQueryBuilder{
+    private String field = "";
+    private String value = "";
+    private String operator = "";
+    public String path = "";
+    public String fieldType = "";
+    public Integer projectId = null;
+    public Integer childProjectId = null;
+
+    @Override
+    public Query creteQuery() throws ParseException {
+        String[] split = value.split(",");
+        List<String> list = Arrays.asList(split);
+        return QueryBuilders.ids(i -> i.values(list));
+    }
+
+    public String getField() {
+        return field;
+    }
+
+    public void setField(String field) {
+        this.field = field;
+    }
+
+    public String getValue() {
+        return value;
+    }
+
+    public void setValue(String value) {
+        this.value = value;
+    }
+
+    public String getOperator() {
+        return operator;
+    }
+
+    public void setOperator(String operator) {
+        this.operator = operator;
+    }
+
+    public String getPath() {
+        return path;
+    }
+
+    public void setPath(String path) {
+        this.path = path;
+    }
+
+    public String getFieldType() {
+        return fieldType;
+    }
+
+    public void setFieldType(String fieldType) {
+        this.fieldType = fieldType;
+    }
+
+    public Integer getProjectId() {
+        return projectId;
+    }
+
+    public void setProjectId(Integer projectId) {
+        this.projectId = projectId;
+    }
+
+    public Integer getChildProjectId() {
+        return childProjectId;
+    }
+
+    public void setChildProjectId(Integer childProjectId) {
+        this.childProjectId = childProjectId;
+    }
+}

+ 2 - 4
src/main/java/cn/cslg/pas/service/business/es/EsService.java

@@ -35,12 +35,9 @@ import co.elastic.clients.elasticsearch.core.*;
 import co.elastic.clients.elasticsearch.core.search.Hit;
 import co.elastic.clients.json.JsonData;
 import com.alibaba.fastjson.JSON;
-import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson2.JSONObject;
 import lombok.RequiredArgsConstructor;
 import org.apache.commons.lang3.ObjectUtils;
 import org.apache.commons.lang3.StringUtils;
-import org.elasticsearch.client.RequestOptions;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Lazy;
@@ -588,6 +585,7 @@ public class EsService {
         String s = format.format(customField.getCreateTime());
         String dateStr = "\'" + s + "\'";
         String projectId = "ctx._source.custom_field.project_id = " + customField.getProjectId() + ";";
+        String taskId = "ctx._source.custom_field.task_id = " + customField.getTaskId() + ";";
         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() + ";";
@@ -595,7 +593,7 @@ public class EsService {
         String fieldValue = "ctx._source.custom_field.field_value = " + valueField + ";";
         String statsValue = "ctx._source.custom_field.stats_value = " + valueStats;
 
-        String source = projectId + field + fieldType + personId + createTime + fieldValue + statsValue;
+        String source = projectId + taskId + 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));

+ 12 - 0
src/main/resources/jsons/patent.json

@@ -1283,6 +1283,18 @@
     "ifAsCondition": "true"
   },
   {
+    "name": "文档ids",
+    "type": "String",
+    "value": "ids",
+    "field": "ids",
+    "esField": "ids",
+    "esClass": "idsQueryBuilder",
+    "ifSearch": "false",
+    "ifGroup": "false",
+    "ifShow": "false",
+    "ifAsCondition": "false"
+  },
+  {
     "name": "业务任务",
     "type": "String",
     "value": "taskId",

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

@@ -510,4 +510,22 @@ public class EventServiceTests {
         Object personData = mergePerson.getData();
         System.out.println(personData);
     }
+
+    @Test
+    public void test104() throws Exception {
+//        List<String> parentIds = esCountService.getParentIds(44, null, 290);
+//        System.out.println(parentIds.size());
+//        parentIds.forEach(System.out::println);
+
+//        List<String> idsList = esService.getIdsList("(field=44 and fieldValue=48)",null);
+//        System.out.println(idsList);
+//        Long idsCount = esService.getIdsCount("NCOQKI8Bz9TGU8OYquJE",null,null);
+//        System.out.println(idsCount);
+//        String s = "(field=44 and fieldValue=48)";
+//        String s1 = s.substring(0, s.indexOf("and")-1)+")";
+//        System.out.println(s1);
+//        if (s.contains("48")) {
+//            System.out.println("shduahdi");
+//        }
+    }
 }