Commit f847fa07 authored by tianyiming's avatar tianyiming

修改bug

parent c5e89e11
...@@ -231,10 +231,10 @@ public class ComprehensiveStatisticalAnalysisServiceImpl { ...@@ -231,10 +231,10 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
if (v instanceof JSONArray) { if (v instanceof JSONArray) {
if (!((JSONArray) v).contains("all")) { if (!((JSONArray) v).contains("all")) {
String field = k; String field = k;
if (k.equals("newPost") || k.equals("subPost") || k.equals("equipType") || k.equals("unitType")) { if (k.equals("equipType") || k.equals("unitType") || k.equals("newPost") || k.equals("subPost")) {
boolMust.must(QueryBuilders.existsQuery(field)); boolMust.must(QueryBuilders.existsQuery(field));
((JSONArray) v).forEach(item -> boolMust.should(QueryBuilders.wildcardQuery(field + ".keyword", "*" + item + "*"))); ((JSONArray) v).forEach(item -> boolMust.must(QueryBuilders.wildcardQuery(k.equals("equipType") ? field : field + ".keyword", "*" + item + "*")));
boolMust.minimumShouldMatch(1); // boolMust.minimumShouldMatch(1);
} else if (k.equals("education")) { } else if (k.equals("education")) {
boolMust.must(QueryBuilders.existsQuery(field)); boolMust.must(QueryBuilders.existsQuery(field));
TermsQueryBuilder termsQuery = QueryBuilders.termsQuery(field, (JSONArray) v); TermsQueryBuilder termsQuery = QueryBuilders.termsQuery(field, (JSONArray) v);
...@@ -311,7 +311,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl { ...@@ -311,7 +311,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
String endDate = DateUtils.convertDateToString(issueDates.getDate(1), DateUtils.DATE_PATTERN); String endDate = DateUtils.convertDateToString(issueDates.getDate(1), DateUtils.DATE_PATTERN);
NestedQueryBuilder nestedQuery = QueryBuilders.nestedQuery( NestedQueryBuilder nestedQuery = QueryBuilders.nestedQuery(
"licenses", "licenses",
QueryBuilders.rangeQuery(k).gte(startDate).lte(endDate), QueryBuilders.rangeQuery("licenses." + k).gte(startDate).lte(endDate),
ScoreMode.Avg ScoreMode.Avg
); );
boolMust.filter(nestedQuery); boolMust.filter(nestedQuery);
...@@ -330,9 +330,14 @@ public class ComprehensiveStatisticalAnalysisServiceImpl { ...@@ -330,9 +330,14 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
if (!ObjectUtils.isEmpty(filter.get("sort"))) { if (!ObjectUtils.isEmpty(filter.get("sort"))) {
JSONObject sort = JSONObject.parseObject(JSONObject.toJSONString(filter.get("sort"))); JSONObject sort = JSONObject.parseObject(JSONObject.toJSONString(filter.get("sort")));
String field = sort.getString("field"); String field = sort.getString("field");
SortOrder sortOrder = sort.getString("order").equals("desc") ? SortOrder.DESC : SortOrder.ASC; if (field.equals("subPostName")) {
FieldSortBuilder sortBuilder = SortBuilders.fieldSort(field + ".keyword").order(sortOrder); field = "subPost";
builder.sort(sortBuilder); } else if (field.equals("postName")) {
field = "newPost";
} else if (field.equals("superviseOrgName")) {
field = "superviseOrgCode";
}
builder.sort(field, sort.getString("order").equals("desc") ? SortOrder.DESC : SortOrder.ASC);
} }
builder.query(boolMust); builder.query(boolMust);
builder.from((current - 1) * size); builder.from((current - 1) * size);
...@@ -346,8 +351,11 @@ public class ComprehensiveStatisticalAnalysisServiceImpl { ...@@ -346,8 +351,11 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
for (SearchHit hit : response.getHits().getHits()) { for (SearchHit hit : response.getHits().getHits()) {
JSONObject jsonObject = (JSONObject) JSONObject.toJSON(hit); JSONObject jsonObject = (JSONObject) JSONObject.toJSON(hit);
JSONObject dto = jsonObject.getJSONObject("sourceAsMap"); JSONObject dto = jsonObject.getJSONObject("sourceAsMap");
if (dto.containsKey("identification")) { if (dto.containsKey("identification") && !ObjectUtils.isEmpty(dto.get("identification"))) {
dto.put("identification", JSONObject.parseObject(JSONObject.parseArray(dto.get("identification").toString()).get(0).toString()).get("url")); JSONArray jsonArray = JSONObject.parseArray(dto.get("identification").toString());
if (!ObjectUtils.isEmpty(jsonArray)) {
dto.put("identification", JSONObject.parseObject(JSONObject.parseArray(dto.get("identification").toString()).get(0).toString()).get("url"));
}
} }
if (dto.containsKey("equipType")) { if (dto.containsKey("equipType")) {
String[] equipCodes = dto.get("equipType").toString().split(","); String[] equipCodes = dto.get("equipType").toString().split(",");
...@@ -405,7 +413,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl { ...@@ -405,7 +413,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
boolMust.minimumShouldMatch(1); boolMust.minimumShouldMatch(1);
} else if (k.equals("industrySupervisor") || k.equals("operatingStatus")) { } else if (k.equals("industrySupervisor") || k.equals("operatingStatus")) {
boolMust.must(QueryBuilders.existsQuery(field)); boolMust.must(QueryBuilders.existsQuery(field));
TermsQueryBuilder termsQuery = QueryBuilders.termsQuery(field, (JSONArray) v); TermsQueryBuilder termsQuery = QueryBuilders.termsQuery(field+".keyword", ((JSONArray) v).get(0));
boolMust.must(termsQuery); boolMust.must(termsQuery);
} else if (k.equals("itemCode") || k.equals("subItemCode") || k.equals("permitStatus")) { } else if (k.equals("itemCode") || k.equals("subItemCode") || k.equals("permitStatus")) {
String path = "licenses"; String path = "licenses";
...@@ -463,9 +471,9 @@ public class ComprehensiveStatisticalAnalysisServiceImpl { ...@@ -463,9 +471,9 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
// 排序 // 排序
if (!ObjectUtils.isEmpty(filter.get("sort"))) { if (!ObjectUtils.isEmpty(filter.get("sort"))) {
JSONObject sort = JSONObject.parseObject(JSONObject.toJSONString(filter.get("sort"))); JSONObject sort = JSONObject.parseObject(JSONObject.toJSONString(filter.get("sort")));
String field = sort.getString("field"); String field = sort.getString("field").equals("permissionStatus") ? "licenses.expiryDate" : sort.getString("field") + ".keyword";
SortOrder sortOrder = sort.getString("order").equals("desc") ? SortOrder.DESC : SortOrder.ASC; SortOrder sortOrder = sort.getString("order").equals("desc") ? SortOrder.DESC : SortOrder.ASC;
FieldSortBuilder sortBuilder = SortBuilders.fieldSort(field + ".keyword").order(sortOrder); FieldSortBuilder sortBuilder = SortBuilders.fieldSort(field).order(sortOrder);
builder.sort(sortBuilder); builder.sort(sortBuilder);
} }
...@@ -621,8 +629,10 @@ public class ComprehensiveStatisticalAnalysisServiceImpl { ...@@ -621,8 +629,10 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
field = "EQU_CATEGORY_CODE"; field = "EQU_CATEGORY_CODE";
} else if (field.equals("EQU_DEFINE")) { } else if (field.equals("EQU_DEFINE")) {
field = "EQU_DEFINE_CODE"; field = "EQU_DEFINE_CODE";
} else { } else if (field.equals("ORG_BRANCH_NAME")) {
field = field + ".keyword"; field = "ORG_BRANCH_CODE";
} else if (field.equals("USE_UNIT_NAME")) {
field = "USE_UNIT_CREDIT_CODE";
} }
builder.sort(field, sort.getString("order").equals("desc") ? SortOrder.DESC : SortOrder.ASC); builder.sort(field, sort.getString("order").equals("desc") ? SortOrder.DESC : SortOrder.ASC);
} }
...@@ -1419,6 +1429,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl { ...@@ -1419,6 +1429,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
/** /**
* 特殊处理字典,value为name * 特殊处理字典,value为name
*
* @param list * @param list
* @return * @return
*/ */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment