Commit 02fa5621 authored by tianyiming's avatar tianyiming

修改bug

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