|
@@ -120,7 +120,6 @@ public class EsCountService {
|
|
|
public void getDatas(String searchCondition,String condition, List<EsCustomFieldValueDTO> customFields, Integer taskId,
|
|
|
Integer projectId, List<EsCountVO> countVOS, List<EsCountDetailDTO> detailDTOS,
|
|
|
EsCountDTO esCountDTO, String firstName, Map<String, List<EsCountDetailDTO>> map,String groupField) throws Exception {
|
|
|
-
|
|
|
if (StringUtils.isNotEmpty(condition)) {
|
|
|
if (searchCondition != null && !"".equals(searchCondition.trim())) {
|
|
|
searchCondition = condition + " AND " + searchCondition;
|
|
@@ -766,12 +765,12 @@ public class EsCountService {
|
|
|
});
|
|
|
});
|
|
|
if (fieldType == null || fieldType != 6) {
|
|
|
- GetUnselectedDTO unselectedDTO = this.getUnselectedCustomNum1(projectId, fieldId, query,esField);
|
|
|
+ Integer customNum1 = this.getUnselectedCustomNum1(projectId, fieldId, query);
|
|
|
EsCountDetailDTO detail = new EsCountDetailDTO();
|
|
|
detail.setField(field);
|
|
|
detail.setName("未选择");
|
|
|
- if (unselectedDTO.getNumber() != null) {
|
|
|
- detail.setNumber(unselectedDTO.getNumber().longValue());
|
|
|
+ if (customNum1 != null) {
|
|
|
+ detail.setNumber(customNum1.longValue());
|
|
|
} else {
|
|
|
detail.setNumber(0L);
|
|
|
}
|
|
@@ -782,22 +781,32 @@ public class EsCountService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- //统计未选择数量
|
|
|
- public GetUnselectedDTO getUnselectedCustomNum1(Integer projectId, String fieldId, Query query,String esField) throws Exception {
|
|
|
- GetUnselectedDTO dto = new GetUnselectedDTO();
|
|
|
+ public List<String> loadingBatchData(Integer projectId, Query query, Integer pageNum, Integer pageSize) throws IOException {
|
|
|
SearchRequest.Builder builder = new SearchRequest.Builder();
|
|
|
//设置查询索引
|
|
|
builder.index("patent");
|
|
|
- builder.size(9999);
|
|
|
- if (StringUtils.isNotEmpty(esField)) {
|
|
|
- Query existQ = QueryBuilders.exists(i -> i.field(esField));
|
|
|
- Query bool = QueryBuilders.bool(i -> i.must(query, existQ));
|
|
|
- builder.query(bool);
|
|
|
- FieldCollapse collapse = FieldCollapse.of(i -> i.field(esField));
|
|
|
- builder.collapse(collapse);
|
|
|
- } else {
|
|
|
+ if (query != null) {
|
|
|
builder.query(query);
|
|
|
+ } else {
|
|
|
+ Query q1 = QueryBuilders.term(i -> i.field("project_id").value(projectId));
|
|
|
+ Query q = QueryBuilders.hasChild(i -> i.type("project").query(q1));
|
|
|
+ builder.query(q);
|
|
|
}
|
|
|
+ builder.from(pageNum).size(pageSize);
|
|
|
+ builder.trackTotalHits(i -> i.enabled(true));
|
|
|
+ SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
|
|
|
+ List<Hit<Patent>> hits = response.hits().hits();
|
|
|
+ return hits.stream().map(Hit::id).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+
|
|
|
+ //统计未选择数量
|
|
|
+ public Integer getUnselectedCustomNum1(Integer projectId, String fieldId, Query query) throws Exception {
|
|
|
+ SearchRequest.Builder builder = new SearchRequest.Builder();
|
|
|
+ //设置查询索引
|
|
|
+ builder.index("patent");
|
|
|
+ builder.query(query);
|
|
|
+ builder.from(0).size(10000);
|
|
|
+ builder.trackTotalHits(i -> i.enabled(true));
|
|
|
SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
|
|
|
List<Hit<Patent>> hits = response.hits().hits();
|
|
|
List<String> list = new ArrayList<>();
|
|
@@ -806,22 +815,22 @@ public class EsCountService {
|
|
|
list.add(id);
|
|
|
}
|
|
|
if (!CollectionUtils.isEmpty(list)) {
|
|
|
- dto = this.ifExistChild(list, projectId,fieldId);
|
|
|
+ return this.ifExistChild1(list, projectId, fieldId);
|
|
|
}
|
|
|
- return dto;
|
|
|
+ return 0;
|
|
|
}
|
|
|
|
|
|
//根据未选择查询专利
|
|
|
- public GetUnselectedDTO getUnselectedCustomNum(Integer projectId,String fieldId) throws Exception {
|
|
|
+ public GetUnselectedDTO getUnselectedCustomNum(Integer projectId, String fieldId) throws Exception {
|
|
|
GetUnselectedDTO dto = new GetUnselectedDTO();
|
|
|
SearchRequest.Builder builder = new SearchRequest.Builder();
|
|
|
//设置查询索引
|
|
|
builder.index("patent");
|
|
|
- Query q = null;
|
|
|
Query query = QueryBuilders.term(i -> i.field("project_id").value(projectId));
|
|
|
- q = QueryBuilders.hasChild(i -> i.type("project").query(query));
|
|
|
- builder.size(9999);
|
|
|
+ Query q = QueryBuilders.hasChild(i -> i.type("project").query(query));
|
|
|
builder.query(q);
|
|
|
+ builder.from(0).size(10000);
|
|
|
+ builder.trackTotalHits(i -> i.enabled(true));
|
|
|
SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
|
|
|
List<Hit<Patent>> hits = response.hits().hits();
|
|
|
List<String> list = new ArrayList<>();
|
|
@@ -830,40 +839,53 @@ public class EsCountService {
|
|
|
list.add(id);
|
|
|
}
|
|
|
if (!CollectionUtils.isEmpty(list)) {
|
|
|
- dto = this.ifExistChild(list,projectId,fieldId);
|
|
|
+ dto = this.ifExistChild(list, projectId, fieldId);
|
|
|
}
|
|
|
return dto;
|
|
|
}
|
|
|
|
|
|
- //查询到对应的ids
|
|
|
- public GetUnselectedDTO ifExistChild(List<String> list, Integer projectId,String fieldId) throws IOException {
|
|
|
- GetUnselectedDTO dto = new GetUnselectedDTO();
|
|
|
- List<String> existChildIds = new ArrayList<>();
|
|
|
- List<String> beinglessChildIds = new ArrayList<>();
|
|
|
+ public Integer ifExistChild1(List<String> list, Integer projectId, String fieldId) throws IOException {
|
|
|
int count = 0;
|
|
|
- for (String id : list) {
|
|
|
- SearchRequest.Builder builder = new SearchRequest.Builder();
|
|
|
- //设置查询索引
|
|
|
- builder.index("patent");
|
|
|
- Query q1 = QueryBuilders.parentId(i -> i.type("project_customfield").id(id));
|
|
|
- Query q2 = QueryBuilders.exists(i -> i.field("custom_field"));
|
|
|
- Query q3 = QueryBuilders.term(i -> i.field("custom_field.if_new").value(1));
|
|
|
- Query q4 = QueryBuilders.term(i -> i.field("custom_field.project_id").value(projectId));
|
|
|
- Query q5 = QueryBuilders.term(i -> i.field("custom_field.field").value(fieldId));
|
|
|
- Query bool = QueryBuilders.bool(i -> i.must(q1, q2, q3,q4,q5));
|
|
|
- builder.query(bool);
|
|
|
- SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
|
|
|
- Long total = response.hits().total().value();
|
|
|
- if (total > 0) {
|
|
|
- existChildIds.add(id);
|
|
|
- } else {
|
|
|
- beinglessChildIds.add(id);
|
|
|
- count++;
|
|
|
- }
|
|
|
+ SearchRequest.Builder builder = new SearchRequest.Builder();
|
|
|
+ //设置查询索引
|
|
|
+ builder.index("patent");
|
|
|
+ Query ids = QueryBuilders.ids(i -> i.values(list));
|
|
|
+ Query q1 = QueryBuilders.hasParent(i -> i.parentType("patent").query(ids));
|
|
|
+ Query q2 = QueryBuilders.exists(i -> i.field("custom_field"));
|
|
|
+ Query q3 = QueryBuilders.term(i -> i.field("custom_field.if_new").value(1));
|
|
|
+ Query q4 = QueryBuilders.term(i -> i.field("custom_field.project_id").value(projectId));
|
|
|
+ Query q5 = QueryBuilders.term(i -> i.field("custom_field.field").value(fieldId));
|
|
|
+ Query bool = QueryBuilders.bool(i -> i.must(q1, q2, q3, q4, q5));
|
|
|
+ builder.query(bool);
|
|
|
+ SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
|
|
|
+ if (response.hits().total() != null) {
|
|
|
+ long total = response.hits().total().value();
|
|
|
+ count = list.size() - (int) total;
|
|
|
}
|
|
|
- dto.setNumber(count);
|
|
|
- dto.setExistChildIds(existChildIds);
|
|
|
- dto.setBeinglessChildIds(beinglessChildIds);
|
|
|
+ return count;
|
|
|
+ }
|
|
|
+
|
|
|
+ //查询到对应的ids
|
|
|
+ public GetUnselectedDTO ifExistChild(List<String> list, Integer projectId, String fieldId) throws IOException {
|
|
|
+ GetUnselectedDTO dto = new GetUnselectedDTO();
|
|
|
+ SearchRequest.Builder builder = new SearchRequest.Builder();
|
|
|
+ //设置查询索引
|
|
|
+ builder.index("patent");
|
|
|
+ Query ids = QueryBuilders.ids(i -> i.values(list));
|
|
|
+ Query q1 = QueryBuilders.hasParent(i -> i.parentType("patent").query(ids));
|
|
|
+ Query q2 = QueryBuilders.exists(i -> i.field("custom_field"));
|
|
|
+ Query q3 = QueryBuilders.term(i -> i.field("custom_field.if_new").value(1));
|
|
|
+ Query q4 = QueryBuilders.term(i -> i.field("custom_field.project_id").value(projectId));
|
|
|
+ Query q5 = QueryBuilders.term(i -> i.field("custom_field.field").value(fieldId));
|
|
|
+ Query bool = QueryBuilders.bool(i -> i.must(q1, q2, q3, q4, q5));
|
|
|
+ builder.query(bool);
|
|
|
+ builder.from(0).size(10000);
|
|
|
+ builder.trackTotalHits(i -> i.enabled(true));
|
|
|
+ SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
|
|
|
+ List<Hit<Patent>> hits = response.hits().hits();
|
|
|
+ List<String> collect = hits.stream().map(Hit::routing).collect(Collectors.toList());
|
|
|
+ list.removeAll(collect);
|
|
|
+ dto.setBeinglessChildIds(list);
|
|
|
return dto;
|
|
|
}
|
|
|
|