Commit 76e40646 authored by tianyiming's avatar tianyiming

修改bug

parent 782a0f11
...@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject; ...@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Getter; import lombok.Getter;
import java.util.EnumSet;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
...@@ -46,4 +47,13 @@ public enum DataQualityScoreEnum { ...@@ -46,4 +47,13 @@ public enum DataQualityScoreEnum {
} }
return jsonArray; return jsonArray;
} }
public static String getNameByCode(String code) {
for (DataQualityScoreEnum e : EnumSet.allOf(DataQualityScoreEnum.class)) {
if(e.getCode().equals(code)){
return e.getName();
}
}
return null;
}
} }
...@@ -562,7 +562,9 @@ public class ComprehensiveStatisticalAnalysisServiceImpl { ...@@ -562,7 +562,9 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
} }
} else if (!k.equals("paramRange")) { } else if (!k.equals("paramRange")) {
if (v instanceof JSONArray) { if (v instanceof JSONArray) {
if (!((JSONArray) v).contains("all") || ((JSONArray) v).size() != 0) { // 判断是否需要解析参数
Boolean parseParam = getParamAnalysis(v);
if (parseParam) {
String field = k; String field = k;
if (k.equals("unitType")) { if (k.equals("unitType")) {
String finalField = field; String finalField = field;
...@@ -675,7 +677,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl { ...@@ -675,7 +677,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
List<JSONObject> list = new LinkedList<>(); List<JSONObject> list = new LinkedList<>();
long totle = 0; long totle = 0;
double pipeLong = 0; // 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()) {
...@@ -683,17 +685,19 @@ public class ComprehensiveStatisticalAnalysisServiceImpl { ...@@ -683,17 +685,19 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
JSONObject dto = jsonObject.getJSONObject("sourceAsMap"); JSONObject dto = jsonObject.getJSONObject("sourceAsMap");
dto.put("record", dto.get("SEQUENCE_NBR")); dto.put("record", dto.get("SEQUENCE_NBR"));
dto.put("equipAddress", dto.get("USE_PLACE") + "/" + dto.get("ADDRESS")); dto.put("equipAddress", dto.get("USE_PLACE") + "/" + dto.get("ADDRESS"));
if (dto.get("EQU_LIST_CODE").equals("8000")) { String dataQualityScore = ObjectUtils.isEmpty(dto.get("DATA_QUALITY_SCORE")) ? null : DataQualityScoreEnum.getNameByCode(dto.get("DATA_QUALITY_SCORE").toString());
JSONArray techParams = (JSONArray) dto.get("techParams"); dto.put("DATA_QUALITY_SCORE", dataQualityScore);
if (!ObjectUtils.isEmpty(techParams)) { // if (dto.get("EQU_LIST_CODE").equals("8000")) {
Object obj = techParams.stream().filter(item -> JSONObject.parseObject(JSONObject.toJSONString(item)).get("paramKey").equals("pipeLength")).findFirst().get(); // JSONArray techParams = (JSONArray) dto.get("techParams");
JSONObject jsonParam = JSONObject.parseObject(JSONObject.toJSONString(obj)); // if (!ObjectUtils.isEmpty(techParams)) {
if (jsonParam.containsKey("doubleValue")) { // Object obj = techParams.stream().filter(item -> JSONObject.parseObject(JSONObject.toJSONString(item)).get("paramKey").equals("pipeLength")).findFirst().get();
String pipeLength = JSONObject.parseObject(JSONObject.toJSONString(obj)).get("doubleValue").toString(); // JSONObject jsonParam = JSONObject.parseObject(JSONObject.toJSONString(obj));
pipeLong += Double.parseDouble(pipeLength); // if (jsonParam.containsKey("doubleValue")) {
} // String pipeLength = JSONObject.parseObject(JSONObject.toJSONString(obj)).get("doubleValue").toString();
} // pipeLong += Double.parseDouble(pipeLength);
} // }
// }
// }
list.add(dto); list.add(dto);
} }
totle = Objects.requireNonNull(response.getInternalResponse().hits().getTotalHits()).value; totle = Objects.requireNonNull(response.getInternalResponse().hits().getTotalHits()).value;
...@@ -710,7 +714,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl { ...@@ -710,7 +714,7 @@ 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")) {
filterParams = new JSONObject(); filterParams = new JSONObject();
JSONArray jsonArray = new JSONArray(); JSONArray jsonArray = new JSONArray();
jsonArray.add("all"); jsonArray.add("all");
...@@ -718,14 +722,18 @@ public class ComprehensiveStatisticalAnalysisServiceImpl { ...@@ -718,14 +722,18 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
} }
JSONArray equList = (JSONArray) filterParams.get("EQU_LIST"); JSONArray equList = (JSONArray) filterParams.get("EQU_LIST");
if (equList.contains("8000") || equList.contains("all")) { if (equList.contains("8000") || equList.contains("all") || ObjectUtils.isEmpty(equList)) {
// 压力管道长度 // 压力管道长度
Map<String, Object> pipeMaps = new HashMap<>();
stCommonService.staticsCenterMapCountDataForPipeline(pipeMaps, orgCode, true, false);
// 获取压力管道长度
// getPipeLength(pipeMaps, boolMust, builder, filterParams);
Map<String, Object> pipeMap = new HashMap<>(); Map<String, Object> pipeMap = new HashMap<>();
pipeMap.put("name", "压力管道(千米)"); pipeMap.put("name", "压力管道(千米)");
pipeMap.put("value", pipeLong); pipeMap.put("value", pipeMaps.get("pressurePipelines"));
statics.add(pipeMap); statics.add(pipeMap);
} }
if (equList.contains("2000") || equList.contains("all")) { if (equList.contains("2000") || equList.contains("all") || ObjectUtils.isEmpty(equList)) {
// 气瓶数量 // 气瓶数量
Map<String, Object> gasMap = new HashMap<>(); Map<String, Object> gasMap = new HashMap<>();
gasMap.put("name", "气瓶(个)"); gasMap.put("name", "气瓶(个)");
...@@ -741,6 +749,19 @@ public class ComprehensiveStatisticalAnalysisServiceImpl { ...@@ -741,6 +749,19 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
return result; return result;
} }
private Boolean getParamAnalysis(Object v) {
Boolean result = false;
if (v instanceof JSONArray) {
JSONArray jsonArray = (JSONArray) v;
result = jsonArray.size() != 0 && !jsonArray.get(0).equals("all");
} else if (v instanceof String) {
if ("null".equals(v) || "".equals(v) || null == v) {
result = true;
}
}
return result;
}
private void getParamQuery(String paramKey, String condition, Object value, String fieldType, 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";
...@@ -944,11 +965,12 @@ public class ComprehensiveStatisticalAnalysisServiceImpl { ...@@ -944,11 +965,12 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
} }
private void addTechParam(JSONObject techParam, JSONObject paramRange, EnhancedDynamicQueryBuilder builder) { private void addTechParam(JSONObject techParam, JSONObject paramRange, EnhancedDynamicQueryBuilder builder) {
String field = techParam.getString("value"); JSONObject jsonObject = JSONObject.parseObject(JSONObject.toJSONString(techParam));
String field = jsonObject.getString("value");
String fieldType = jsonObject.getString("fieldType");
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");
String fieldType = paramRange.getString("fieldType");
getParamQuery(field, itemCondition, value, fieldType, true, null, builder, andOr); getParamQuery(field, itemCondition, value, fieldType, true, null, builder, andOr);
} }
......
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