Commit 02fa5621 authored by tianyiming's avatar tianyiming

修改bug

parent 3689cffd
......@@ -16,9 +16,9 @@ public enum DataQualityScoreEnum {
* *设备等级
*/
I("I级", "3"),
II("II级", "2"),
III("III级", "1"),
I("级", "3"),
II("级", "2"),
III("级", "1"),
;
private String name;
......
......@@ -130,6 +130,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
} else if (TechnicalParameter.ParamType.DATE.equals(paramMetaList.get(i).getParamType())) {
skillConfig.put("type", "date");
}
skillConfig.put("fieldType", paramMetaList.get(i).getParamType());
skillConfig.put("isMulti", false);
object.put("skillConfig", skillConfig);
list.add(object);
......@@ -546,19 +547,21 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
String filterType = filter.getString("filterType");
//快捷筛选和自定义筛选解析筛选规则不一致
if (filterType.equals("advanced")) {
JSONObject finalFilterParams = filterParams;
filterParams.forEach((k, v) -> {
if (k.equals("techParam")) {
JSONArray techParams = (JSONArray) v;
if (!techParams.contains("all") && techParams.size() == 1) {
JSONObject paramRangeJson = JSONObject.parseObject(JSONObject.toJSONString(filterParams.get("paramRange")));
JSONObject paramRangeJson = JSONObject.parseObject(JSONObject.toJSONString(finalFilterParams.get("paramRange")));
String paramKey = techParams.getString(0);
String condition = paramRangeJson.getString("condition");
Object value = paramRangeJson.getString("value");
getParamQuery(paramKey, condition, value, false, boolMust, null, null);
String fieldType = paramRangeJson.getString("fieldType");
getParamQuery(paramKey, condition, value, fieldType, false, boolMust, null, null);
}
} else if (!k.equals("paramRange")) {
if (v instanceof JSONArray) {
if (!((JSONArray) v).contains("all")) {
if (!((JSONArray) v).contains("all") || ((JSONArray) v).size() != 0) {
String field = k;
if (k.equals("unitType")) {
String finalField = field;
......@@ -671,7 +674,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
List<JSONObject> list = new LinkedList<>();
long totle = 0;
long pipeLong = 0L;
double pipeLong = 0;
try {
SearchResponse response = restHighLevelClient.search(request, RequestOptions.DEFAULT);
for (SearchHit hit : response.getHits().getHits()) {
......@@ -684,9 +687,9 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
if (!ObjectUtils.isEmpty(techParams)) {
Object obj = techParams.stream().filter(item -> JSONObject.parseObject(JSONObject.toJSONString(item)).get("paramKey").equals("pipeLength")).findFirst().get();
JSONObject jsonParam = JSONObject.parseObject(JSONObject.toJSONString(obj));
if (jsonParam.containsKey("strValue")) {
String pipeLength = JSONObject.parseObject(JSONObject.toJSONString(obj)).get("strValue").toString();
pipeLong += Long.parseLong(pipeLength);
if (jsonParam.containsKey("doubleValue")) {
String pipeLength = JSONObject.parseObject(JSONObject.toJSONString(obj)).get("doubleValue").toString();
pipeLong += Double.parseDouble(pipeLength);
}
}
}
......@@ -706,37 +709,41 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
sum.put("value", totle);
statics.add(sum);
if (!ObjectUtils.isEmpty(filterParams) && filterParams.containsKey("EQU_LIST")) {
JSONArray equList = (JSONArray) filterParams.get("EQU_LIST");
if (equList.contains("8000") || equList.contains("all")) {
// 压力管道长度
Map<String, Object> pipeMap = new HashMap<>();
pipeMap.put("name", "压力管道(千米)");
pipeMap.put("value", pipeLong);
statics.add(pipeMap);
}
if (equList.contains("2000") || equList.contains("all")) {
// 气瓶数量
Map<String, Object> gasMap = new HashMap<>();
gasMap.put("name", "气瓶(个)");
Map<String, Object> gas = new HashMap<>();
gas.put(DPMapStatisticsItemEnum.GAS.getCode(), 0);
long cylinderNum = stCommonService.staticsCenterMapCountDataForCylinder(gas, orgCode, true, true, false);
// 1. 8大类设备数量统计,压力容器里包括气瓶所以需要特殊处理,在统计压力容器时去掉气瓶的数量
stCommonService.staticsCenterMapCountDataForEquip(gas, cylinderNum, orgCode, true, true, false);
gasMap.put("value", gas.get(DPMapStatisticsItemEnum.GAS.getCode()));
statics.add(gasMap);
}
if(ObjectUtils.isEmpty(filterParams) || !filterParams.containsKey("EQU_LIST")){
filterParams = new JSONObject();
JSONArray jsonArray = new JSONArray();
jsonArray.add("all");
filterParams.put("EQU_LIST", jsonArray);
}
JSONArray equList = (JSONArray) filterParams.get("EQU_LIST");
if (equList.contains("8000") || equList.contains("all")) {
// 压力管道长度
Map<String, Object> pipeMap = new HashMap<>();
pipeMap.put("name", "压力管道(千米)");
pipeMap.put("value", pipeLong);
statics.add(pipeMap);
}
if (equList.contains("2000") || equList.contains("all")) {
// 气瓶数量
Map<String, Object> gasMap = new HashMap<>();
gasMap.put("name", "气瓶(个)");
Map<String, Object> gas = new HashMap<>();
gas.put(DPMapStatisticsItemEnum.GAS.getCode(), 0);
long cylinderNum = stCommonService.staticsCenterMapCountDataForCylinder(gas, orgCode, true, true, false);
// 1. 8大类设备数量统计,压力容器里包括气瓶所以需要特殊处理,在统计压力容器时去掉气瓶的数量
stCommonService.staticsCenterMapCountDataForEquip(gas, cylinderNum, orgCode, true, true, false);
gasMap.put("value", gas.get(DPMapStatisticsItemEnum.GAS.getCode()));
statics.add(gasMap);
}
result.put("statics", statics);
return result;
}
private void getParamQuery(String paramKey, String condition, Object value, Boolean isCustom, BoolQueryBuilder boolMust, EnhancedDynamicQueryBuilder builder, String andOr) {
private void getParamQuery(String paramKey, String condition, Object value, String fieldType, Boolean isCustom, BoolQueryBuilder boolMust, EnhancedDynamicQueryBuilder builder, String andOr) {
String path = "techParams";
String nestedFieldKey = path + ".paramKey";
String doubleEnd = ".doubleValue";
String stringEnd = ".strValue";
String tail = "BIG_DECIMAL".equals(fieldType) ? ".doubleValue" : ".strValue";
NestedQueryBuilder keyNestedQuery = QueryBuilders.nestedQuery(
path,
QueryBuilders.boolQuery().must(QueryBuilders.termsQuery(nestedFieldKey, paramKey)),
......@@ -751,7 +758,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
case "eq":
NestedQueryBuilder eqQuery = QueryBuilders.nestedQuery(
path,
QueryBuilders.boolQuery().must(QueryBuilders.termsQuery(path + stringEnd, value)),
QueryBuilders.boolQuery().must(QueryBuilders.termsQuery(path + tail, value)),
ScoreMode.Avg
);
if (isCustom) {
......@@ -764,7 +771,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
boolMust.must(keyNestedQuery);
NestedQueryBuilder neqQuery = QueryBuilders.nestedQuery(
path,
QueryBuilders.boolQuery().mustNot(QueryBuilders.termsQuery(path + stringEnd, value)),
QueryBuilders.boolQuery().mustNot(QueryBuilders.termsQuery(path + tail, value)),
ScoreMode.Avg
);
if (isCustom) {
......@@ -776,7 +783,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
case "like":
NestedQueryBuilder likeQuery = QueryBuilders.nestedQuery(
path,
QueryBuilders.boolQuery().must(QueryBuilders.wildcardQuery(path + stringEnd, "*" + value + "*")),
QueryBuilders.boolQuery().must(QueryBuilders.wildcardQuery(path + tail, "*" + value + "*")),
ScoreMode.Avg
);
if (isCustom) {
......@@ -788,7 +795,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
case "notLike":
NestedQueryBuilder notLikeQuery = QueryBuilders.nestedQuery(
path,
QueryBuilders.boolQuery().must(QueryBuilders.wildcardQuery(path + stringEnd, "*" + value + "*")),
QueryBuilders.boolQuery().must(QueryBuilders.wildcardQuery(path + tail, "*" + value + "*")),
ScoreMode.Avg
);
if (isCustom) {
......@@ -800,7 +807,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
case "gt":
NestedQueryBuilder gtQuery = QueryBuilders.nestedQuery(
path,
QueryBuilders.rangeQuery(path + doubleEnd).gt(value.toString()),
QueryBuilders.rangeQuery(path + tail).gt(value.toString()),
ScoreMode.Avg
);
if (isCustom) {
......@@ -812,7 +819,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
case "gte":
NestedQueryBuilder gteQuery = QueryBuilders.nestedQuery(
path,
QueryBuilders.boolQuery().must(QueryBuilders.rangeQuery(path + doubleEnd).gte(value.toString())),
QueryBuilders.boolQuery().must(QueryBuilders.rangeQuery(path + tail).gte(value.toString())),
ScoreMode.Avg
);
if (isCustom) {
......@@ -824,7 +831,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
case "lt":
NestedQueryBuilder ltQuery = QueryBuilders.nestedQuery(
path,
QueryBuilders.boolQuery().must(QueryBuilders.rangeQuery(path + doubleEnd).lt(value.toString())),
QueryBuilders.boolQuery().must(QueryBuilders.rangeQuery(path + tail).lt(value.toString())),
ScoreMode.Avg
);
if (isCustom) {
......@@ -836,7 +843,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
case "lte":
NestedQueryBuilder lteQuery = QueryBuilders.nestedQuery(
path,
QueryBuilders.boolQuery().must(QueryBuilders.rangeQuery(path + doubleEnd).lte(value.toString())),
QueryBuilders.boolQuery().must(QueryBuilders.rangeQuery(path + tail).lte(value.toString())),
ScoreMode.Avg
);
if (isCustom) {
......@@ -849,7 +856,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
JSONArray btValues = (JSONArray) value;
NestedQueryBuilder betweenQuery = QueryBuilders.nestedQuery(
path,
QueryBuilders.boolQuery().must(QueryBuilders.rangeQuery(path + doubleEnd).gte(Double.parseDouble(btValues.get(0).toString())).lte(Double.parseDouble(btValues.get(1).toString()))),
QueryBuilders.boolQuery().must(QueryBuilders.rangeQuery(path + tail).gte(Double.parseDouble(btValues.get(0).toString())).lte(Double.parseDouble(btValues.get(1).toString()))),
ScoreMode.Avg
);
if (isCustom) {
......@@ -862,7 +869,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
JSONArray inValues = (JSONArray) value;
NestedQueryBuilder inQuery = QueryBuilders.nestedQuery(
path,
QueryBuilders.boolQuery().must(QueryBuilders.termsQuery(path + stringEnd, inValues)),
QueryBuilders.boolQuery().must(QueryBuilders.termsQuery(path + tail, inValues)),
ScoreMode.Avg
);
if (isCustom) {
......@@ -875,7 +882,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
JSONArray notInValues = (JSONArray) value;
NestedQueryBuilder notInQuery = QueryBuilders.nestedQuery(
path,
QueryBuilders.boolQuery().must(QueryBuilders.termsQuery(path + stringEnd, notInValues)),
QueryBuilders.boolQuery().must(QueryBuilders.termsQuery(path + tail, notInValues)),
ScoreMode.Avg
);
if (isCustom) {
......@@ -940,7 +947,8 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
String itemCondition = paramRange.getString("itemCondition");
Object value = paramRange.get("value");
String andOr = paramRange.getString("andOr");
getParamQuery(field, itemCondition, value, true, null, builder, andOr);
String fieldType = paramRange.getString("fieldType");
getParamQuery(field, itemCondition, value, fieldType, true, null, builder, andOr);
}
private void groupHandler(JSONArray group, EnhancedDynamicQueryBuilder builder) {
......@@ -1053,7 +1061,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
.should(QueryBuilders.wildcardQuery("subPost.keyword", "*6764*"))
.should(QueryBuilders.wildcardQuery("subPost.keyword", "*6765*"))
.minimumShouldMatch(1);
// 无资质要求查询
// 无资质要求查询
BoolQueryBuilder noCertRequestQuery = QueryBuilders.boolQuery()
.mustNot(QueryBuilders.wildcardQuery("newPost.keyword", "*66151*"))
.mustNot(QueryBuilders.wildcardQuery("newPost.keyword", "*66152*"))
......@@ -1697,6 +1705,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
object.put("key", paramMetaList.get(i).getParamKey());
object.put("value", paramMetaList.get(i).getParamKey());
object.put("label", paramMetaList.get(i).getParamLabel());
object.put("fieldType", paramMetaList.get(i).getParamType());
list.add(object);
}
return list;
......
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