Commit 146ad182 authored by tianyiming's avatar tianyiming

fix(Statistics): 修改bug

parent f87a83b3
...@@ -322,7 +322,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl { ...@@ -322,7 +322,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
} }
// 组装人员过滤条件 // 组装人员过滤条件
String orgCode = filter.getString("orgCode"); String orgCode = filter.getString("orgCode");
personOrgCodeBoolMust(orgCode, boolMust); personOrgCodeBoolMust(orgCode, boolMust, StatisticalAnalysisEnum.person.getCode());
this.getPersonBoolQueryBuilder(filterParams, boolMust, filterType); this.getPersonBoolQueryBuilder(filterParams, boolMust, filterType);
if ("custom".equals(filterType)) { if ("custom".equals(filterType)) {
JSONArray leftGroup = filterParams.getJSONArray("group1"); JSONArray leftGroup = filterParams.getJSONArray("group1");
...@@ -403,15 +403,16 @@ public class ComprehensiveStatisticalAnalysisServiceImpl { ...@@ -403,15 +403,16 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
return result; return result;
} }
private void personOrgCodeBoolMust(String orgCode, BoolQueryBuilder boolMust) { private void personOrgCodeBoolMust(String orgCode, BoolQueryBuilder boolMust, String type) {
String superviseOrgCodeKey = type.equals(StatisticalAnalysisEnum.person.getCode()) ? "superviseOrgCode" : "superviseOrgCode.keyword";
String officeRegion = commonMapper.getCompanyCodeByOrgCode(orgCode); String officeRegion = commonMapper.getCompanyCodeByOrgCode(orgCode);
BoolQueryBuilder queryBuilder1 = QueryBuilders.boolQuery(); BoolQueryBuilder queryBuilder1 = QueryBuilders.boolQuery();
BoolQueryBuilder queryBuilder2 = QueryBuilders.boolQuery(); BoolQueryBuilder queryBuilder2 = QueryBuilders.boolQuery();
EnhancedDynamicQueryBuilder enhancedDynamicQueryBuilder = new EnhancedDynamicQueryBuilder(); EnhancedDynamicQueryBuilder enhancedDynamicQueryBuilder = new EnhancedDynamicQueryBuilder();
queryBuilder1.must(QueryBuilders.termQuery("superviseOrgCode", "50")) queryBuilder1.must(QueryBuilders.termQuery(superviseOrgCodeKey, "50"))
.must(QueryBuilders.wildcardQuery("officeRegion", "*" + officeRegion + "*")); .must(QueryBuilders.wildcardQuery("officeRegion", "*" + officeRegion + "*"));
queryBuilder2.mustNot(QueryBuilders.termQuery("superviseOrgCode", "50")) queryBuilder2.mustNot(QueryBuilders.termQuery(superviseOrgCodeKey, "50"))
.must(QueryBuilders.prefixQuery("superviseOrgCode", orgCode)); .must(QueryBuilders.prefixQuery(superviseOrgCodeKey, orgCode));
enhancedDynamicQueryBuilder.add(queryBuilder1, or); enhancedDynamicQueryBuilder.add(queryBuilder1, or);
enhancedDynamicQueryBuilder.add(queryBuilder2, or); enhancedDynamicQueryBuilder.add(queryBuilder2, or);
boolMust.must(enhancedDynamicQueryBuilder.build()); boolMust.must(enhancedDynamicQueryBuilder.build());
...@@ -497,14 +498,18 @@ public class ComprehensiveStatisticalAnalysisServiceImpl { ...@@ -497,14 +498,18 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
boolMust.must(licencesQueryBuilder.build()); boolMust.must(licencesQueryBuilder.build());
} else if (k.equals("issueDate")) { } else if (k.equals("issueDate")) {
JSONArray issueDates = (JSONArray) v; JSONArray issueDates = (JSONArray) v;
String startDate = DateUtils.convertDateToString(issueDates.getDate(0), DateUtils.DATE_PATTERN); Date startDate = issueDates.getDate(0);
String endDate = DateUtils.convertDateToString(issueDates.getDate(1), DateUtils.DATE_PATTERN); Date endDate = issueDates.getDate(1);
NestedQueryBuilder nestedQuery = QueryBuilders.nestedQuery( if (!"".equals(startDate) && !"".equals(endDate) && !ObjectUtils.isEmpty(startDate) && !ObjectUtils.isEmpty(endDate)) {
"licenses", String startDateString = DateUtils.convertDateToString(startDate, DateUtils.DATE_PATTERN);
QueryBuilders.rangeQuery("licenses." + k).gte(startDate).lte(endDate), String endDateString = DateUtils.convertDateToString(endDate, DateUtils.DATE_PATTERN);
ScoreMode.None NestedQueryBuilder nestedQuery = QueryBuilders.nestedQuery(
); "licenses",
boolMust.filter(nestedQuery); QueryBuilders.rangeQuery("licenses." + k).gte(startDateString).lte(endDateString),
ScoreMode.None
);
boolMust.filter(nestedQuery);
}
} }
} }
} else if (v instanceof String) { } else if (v instanceof String) {
...@@ -570,7 +575,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl { ...@@ -570,7 +575,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
BoolQueryBuilder boolMust = QueryBuilders.boolQuery(); BoolQueryBuilder boolMust = QueryBuilders.boolQuery();
String orgCode = filter.getString("orgCode"); String orgCode = filter.getString("orgCode");
boolMust.must(QueryBuilders.prefixQuery("superviseOrgCode.keyword", orgCode)); personOrgCodeBoolMust(orgCode, boolMust, StatisticalAnalysisEnum.company.getCode());
JSONObject filterParams = JSONObject.parseObject(JSONObject.toJSONString(filter.get("filterParams"))); JSONObject filterParams = JSONObject.parseObject(JSONObject.toJSONString(filter.get("filterParams")));
String filterType = filter.getString("filterType"); String filterType = filter.getString("filterType");
...@@ -1152,7 +1157,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl { ...@@ -1152,7 +1157,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
JSONArray dates = (JSONArray) v; JSONArray dates = (JSONArray) v;
String startDate = dates.getString(0); String startDate = dates.getString(0);
String endDate = dates.getString(1); String endDate = dates.getString(1);
if (!"".equals(startDate) && !"".equals(endDate)) { if (!"".equals(startDate) && !"".equals(endDate) && !ObjectUtils.isEmpty(startDate) && !ObjectUtils.isEmpty(endDate)) {
boolMust.filter(QueryBuilders.rangeQuery(field).gte(startDate).lte(endDate)); boolMust.filter(QueryBuilders.rangeQuery(field).gte(startDate).lte(endDate));
} }
} else if (k.equals("EQU_LIST") || k.equals("EQU_CATEGORY") || k.equals("EQU_DEFINE") || k.equals("DATA_QUALITY_SCORE")) { } else if (k.equals("EQU_LIST") || k.equals("EQU_CATEGORY") || k.equals("EQU_DEFINE") || k.equals("DATA_QUALITY_SCORE")) {
...@@ -3142,16 +3147,16 @@ public class ComprehensiveStatisticalAnalysisServiceImpl { ...@@ -3142,16 +3147,16 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
boolMust.must(QueryBuilders.prefixQuery("ORG_BRANCH_CODE", orgCode)); boolMust.must(QueryBuilders.prefixQuery("ORG_BRANCH_CODE", orgCode));
data = queryDpEquipStatistics(filter, request, builder, boolMust, tabTotalMap); data = queryDpEquipStatistics(filter, request, builder, boolMust, tabTotalMap);
} else if (StatisticalAnalysisEnum.company.getCode().equals(businessType)) { } else if (StatisticalAnalysisEnum.company.getCode().equals(businessType)) {
boolMust.must(QueryBuilders.prefixQuery("superviseOrgCode.keyword", orgCode)); personOrgCodeBoolMust(orgCode, boolMust,StatisticalAnalysisEnum.company.getCode());
data = queryDpCompanyStatistics(filter, request, builder, boolMust, tabTotalMap); data = queryDpCompanyStatistics(filter, request, builder, boolMust, tabTotalMap);
} else if (StatisticalAnalysisEnum.person.getCode().equals(businessType)) { } else if (StatisticalAnalysisEnum.person.getCode().equals(businessType)) {
personOrgCodeBoolMust(orgCode, boolMust); personOrgCodeBoolMust(orgCode, boolMust,StatisticalAnalysisEnum.person.getCode());
data = queryDpPersonStatistics(filter, request, builder, boolMust, tabTotalMap); data = queryDpPersonStatistics(filter, request, builder, boolMust, tabTotalMap);
} else if (StatisticalAnalysisEnum.inspectionCompany.getCode().equals(businessType)) { } else if (StatisticalAnalysisEnum.inspectionCompany.getCode().equals(businessType)) {
boolMust.must(QueryBuilders.prefixQuery("superviseOrgCode.keyword", orgCode)); personOrgCodeBoolMust(orgCode, boolMust,StatisticalAnalysisEnum.company.getCode());
data = queryDpInspectionCompanyStatistics(filter, request, builder, boolMust, tabTotalMap); data = queryDpInspectionCompanyStatistics(filter, request, builder, boolMust, tabTotalMap);
} else { } else {
personOrgCodeBoolMust(orgCode, boolMust); personOrgCodeBoolMust(orgCode, boolMust,StatisticalAnalysisEnum.person.getCode());
data = queryDpInspectionPersonStatistics(filter, request, builder, boolMust, tabTotalMap); data = queryDpInspectionPersonStatistics(filter, request, builder, boolMust, tabTotalMap);
} }
...@@ -3256,7 +3261,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl { ...@@ -3256,7 +3261,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
companyBoolMust.must(companyUnitTypeBoolMust); companyBoolMust.must(companyUnitTypeBoolMust);
BoolQueryBuilder personBoolMust = QueryBuilders.boolQuery(); BoolQueryBuilder personBoolMust = QueryBuilders.boolQuery();
personOrgCodeBoolMust(orgCode, personBoolMust); personOrgCodeBoolMust(orgCode, personBoolMust, StatisticalAnalysisEnum.person.getCode());
personBoolMust.must(companyUnitTypeBoolMust); personBoolMust.must(companyUnitTypeBoolMust);
BoolQueryBuilder inspectionCompanyBoolMust = QueryBuilders.boolQuery(); BoolQueryBuilder inspectionCompanyBoolMust = QueryBuilders.boolQuery();
...@@ -3266,7 +3271,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl { ...@@ -3266,7 +3271,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
BoolQueryBuilder inspectionPersonBoolMust = QueryBuilders.boolQuery(); BoolQueryBuilder inspectionPersonBoolMust = QueryBuilders.boolQuery();
personOrgCodeBoolMust(orgCode, inspectionPersonBoolMust); personOrgCodeBoolMust(orgCode, personBoolMust, StatisticalAnalysisEnum.person.getCode());
inspectionPersonBoolMust.must(inspectionUnitTypeBoolMust); inspectionPersonBoolMust.must(inspectionUnitTypeBoolMust);
inspectionPersonBoolMust.mustNot(QueryBuilders.wildcardQuery("unitType.keyword", "*检验检测机构*")); inspectionPersonBoolMust.mustNot(QueryBuilders.wildcardQuery("unitType.keyword", "*检验检测机构*"));
...@@ -4034,7 +4039,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl { ...@@ -4034,7 +4039,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
JSONObject filterParams = JSONObject.parseObject(JSONObject.toJSONString(filter.get("filterParams"))); JSONObject filterParams = JSONObject.parseObject(JSONObject.toJSONString(filter.get("filterParams")));
String filterType = "advanced"; String filterType = "advanced";
// 组装人员过滤条件 // 组装人员过滤条件
personOrgCodeBoolMust(orgCode, boolQuery); personOrgCodeBoolMust(orgCode, boolQuery, StatisticalAnalysisEnum.person.getCode());
this.getPersonBoolQueryBuilder(filterParams, boolQuery, filterType); this.getPersonBoolQueryBuilder(filterParams, boolQuery, filterType);
// 查询 // 查询
JSONObject expiryDateStatus = this.getExpiryDateStatusGroupStatistics(boolQuery); JSONObject expiryDateStatus = this.getExpiryDateStatusGroupStatistics(boolQuery);
......
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