Commit 244abd0a authored by tianyiming's avatar tianyiming

bug修改

parent 2b08a284
......@@ -991,7 +991,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
JSONArray equList = (JSONArray) filterParams.get("EQU_LIST");
if (ObjectUtils.isEmpty(equList) || equList.contains("8000") || equList.contains("all")) {
// 获取压力管道长度
BigDecimal pipeLength = getPipeLength(pipeQuery, "pipeLength");
BigDecimal pipeLength = getPipeLength(boolMust, builder, "pipeLength");
Map<String, Object> pipeMap = new HashMap<>();
pipeMap.put("name", "压力管道(千米)");
pipeMap.put("value", pipeLength.divide(new BigDecimal(1000), 2, BigDecimal.ROUND_HALF_UP));
......@@ -1080,12 +1080,11 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
if ("1".equals(item)) {
queryBuilder.must(QueryBuilders.termsQuery("IS_INTO_MANAGEMENT", Boolean.TRUE))
.must(existsQuery("USE_ORG_CODE"))
.mustNot(QueryBuilders.termQuery("USE_ORG_CODE",""));
.mustNot(QueryBuilders.termQuery("USE_ORG_CODE", ""));
} else {
queryBuilder
.should(QueryBuilders.boolQuery().mustNot(existsQuery("IS_INTO_MANAGEMENT")))
.should(QueryBuilders.boolQuery().mustNot(QueryBuilders.termQuery("IS_INTO_MANAGEMENT", "")))
.should(QueryBuilders.termsQuery("IS_INTO_MANAGEMENT", Boolean.FALSE))
.should(QueryBuilders.termQuery("IS_INTO_MANAGEMENT", Boolean.FALSE))
.should(QueryBuilders.boolQuery().mustNot(existsQuery("USE_ORG_CODE")))
.should(QueryBuilders.termQuery("USE_ORG_CODE", ""))
.minimumShouldMatch(1);
......@@ -1098,7 +1097,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
JSONArray dates = (JSONArray) v;
String startDate = dates.getString(0);
String endDate = dates.getString(1);
if(!"".equals(startDate) && !"".equals(endDate)){
if (!"".equals(startDate) && !"".equals(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")) {
......@@ -1144,7 +1143,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
QueryBuilders.rangeQuery(dateField).gte(startDate).lte(endDate),
ScoreMode.None
);
if(!"".equals(startDate) && !"".equals(endDate)){
if (!"".equals(startDate) && !"".equals(endDate)) {
boolMust.must(fieldQuery);
boolMust.filter(dateQuery);
}
......@@ -1295,13 +1294,16 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
return ObjectUtils.isEmpty(response) ? 0 : response.getCount();
}
private BigDecimal getPipeLength(BoolQueryBuilder boolMust, String countField) {
private BigDecimal getPipeLength(BoolQueryBuilder boolMust, SearchSourceBuilder builder, String countField) {
SearchRequest request = new SearchRequest();
request.indices(StatisticalAnalysisEnum.equip.getKey());
SearchSourceBuilder builder = new SearchSourceBuilder();
BigDecimal pipeLong;
BoolQueryBuilder pipeLengthQuery = QueryBuilderUtils.copyBoolQuery(boolMust);
pipeLengthQuery.must(QueryBuilders.existsQuery("pipeLength"));
pipeLengthQuery.must(existsQuery("SUPERVISORY_CODE"));
pipeLengthQuery.mustNot(QueryBuilders.termQuery("SUPERVISORY_CODE", ""));
SumAggregationBuilder pipeLengthAgg = AggregationBuilders.sum(countField).field("pipeLength").missing(0);
builder.query(boolMust);
builder.query(pipeLengthQuery);
builder.aggregation(pipeLengthAgg).size(0);
request.source(builder);
try {
......@@ -1333,6 +1335,20 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
String nestedFieldKey = path + ".paramKey";
String tail = "BIG_DECIMAL".equals(fieldType) ? ".doubleValue" : ".strValue";
TermsQueryBuilder termsQueryBuilder = QueryBuilders.termsQuery(nestedFieldKey, paramKey);
if ("chargingMedium".equals(paramKey)) {
List<DictionarieValueModel> fillingMedium = Systemctl.dictionarieClient.dictValues("FILLING_MEDIUM").getResult();
Object finalValue = value;
List<DictionarieValueModel> collect = fillingMedium.stream().filter(e -> e.getDictDataValue().contains(finalValue.toString())).collect(Collectors.toList());
if (!ObjectUtils.isEmpty(collect)) {
if (collect.size() == 1) {
value = collect.get(0).getDictDataKey();
}
if (collect.size() > 1) {
value = collect.stream().map(DictionarieValueModel::getDictDataKey).collect(Collectors.toList());
condition = "in";
}
}
}
switch (condition) {
case "eq":
NestedQueryBuilder eqQuery = QueryBuilders.nestedQuery(
......@@ -1444,7 +1460,14 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
}
break;
case "in":
JSONArray inValues = (JSONArray) value;
JSONArray inValues= new JSONArray();
if (value instanceof JSONArray) {
inValues = (JSONArray) value;
}
if (value instanceof List) {
// value转化为jsONArray
inValues.addAll((List) value);
}
NestedQueryBuilder inQuery = QueryBuilders.nestedQuery(
path,
QueryBuilders.boolQuery().must(termsQueryBuilder).must(QueryBuilders.termsQuery(path + tail, inValues)),
......@@ -3046,7 +3069,6 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
if (groupField.equals("EQU_LIST_CODE")) {
gasBoolQueryBuilder = QueryBuilderUtils.copyBoolQuery(boolMust);
}
BoolQueryBuilder pipeBoolMust = QueryBuilderUtils.copyBoolQuery(boolMust);
if (!"2300".equals(equipCode)) {
boolMust.mustNot(QueryBuilders.matchQuery("EQU_CATEGORY_CODE", "2300"));
}
......@@ -3061,7 +3083,9 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
tabTotalMap.put(StatisticalAnalysisEnum.equip.getCode(), otherCount.toString());
List<String> codes = new ArrayList<>();
BoolQueryBuilder pipeBoolMust = QueryBuilderUtils.copyBoolQuery(boolMust);
for (Map<String, Object> categoryMap : staticCountByGroupMap) {
BoolQueryBuilder queryBuilder = QueryBuilderUtils.copyBoolQuery(pipeBoolMust);
String code = categoryMap.get("value").toString();
codes.add(code);
// 去除类别中的气瓶
......@@ -3076,11 +3100,8 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
map.put("fieldKey", groupField.replace("_CODE", ""));
Object value = staticCountByGroup.containsKey(code) ? staticCountByGroup.get(code) : 0L;
if (code.startsWith("8")) {
pipeBoolMust.must(QueryBuilders.termQuery(groupField, code));
pipeBoolMust.must(QueryBuilders.existsQuery("pipeLength"));
pipeBoolMust.must(existsQuery("SUPERVISORY_CODE"));
pipeBoolMust.mustNot(QueryBuilders.termQuery("SUPERVISORY_CODE",""));
BigDecimal pipeLength = getPipeLength(pipeBoolMust, code);
queryBuilder.must(QueryBuilders.termQuery(groupField, code));
BigDecimal pipeLength = getPipeLength(queryBuilder, builder, code);
value = pipeLength.divide(new BigDecimal(1000), 4, BigDecimal.ROUND_HALF_UP);
}
map.put("value", value);
......@@ -3156,7 +3177,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
if (groupField.equals("EQU_DEFINE_CODE")) {
pipeBoolMust.mustNot(QueryBuilders.termsQuery("EQU_DEFINE_CODE", codes));
}
BigDecimal pipeLength = getPipeLength(pipeBoolMust, "other");
BigDecimal pipeLength = getPipeLength(pipeBoolMust, builder, "other");
BigDecimal divide = pipeLength.divide(new BigDecimal(1000), 4, BigDecimal.ROUND_HALF_UP);
otherPipeLength = otherPipeLength.add(divide);
staticCountByGroup.put("N/A", otherPipeLength);
......
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