Commit 453b1b9b authored by suhuiguang's avatar suhuiguang

Merge branch 'develop_tzs_register' of…

Merge branch 'develop_tzs_register' of http://39.100.92.250:5000/moa/amos-boot-biz into develop_tzs_register
parents 5f8b487c 76e40646
......@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject;
import lombok.AllArgsConstructor;
import lombok.Getter;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.Map;
......@@ -46,4 +47,13 @@ public enum DataQualityScoreEnum {
}
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 {
}
} else if (!k.equals("paramRange")) {
if (v instanceof JSONArray) {
if (!((JSONArray) v).contains("all") || ((JSONArray) v).size() != 0) {
// 判断是否需要解析参数
Boolean parseParam = getParamAnalysis(v);
if (parseParam) {
String field = k;
if (k.equals("unitType")) {
String finalField = field;
......@@ -675,7 +677,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
List<JSONObject> list = new LinkedList<>();
long totle = 0;
double pipeLong = 0;
// double pipeLong = 0;
try {
SearchResponse response = restHighLevelClient.search(request, RequestOptions.DEFAULT);
for (SearchHit hit : response.getHits().getHits()) {
......@@ -683,17 +685,19 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
JSONObject dto = jsonObject.getJSONObject("sourceAsMap");
dto.put("record", dto.get("SEQUENCE_NBR"));
dto.put("equipAddress", dto.get("USE_PLACE") + "/" + dto.get("ADDRESS"));
if (dto.get("EQU_LIST_CODE").equals("8000")) {
JSONArray techParams = (JSONArray) dto.get("techParams");
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("doubleValue")) {
String pipeLength = JSONObject.parseObject(JSONObject.toJSONString(obj)).get("doubleValue").toString();
pipeLong += Double.parseDouble(pipeLength);
}
}
}
String dataQualityScore = ObjectUtils.isEmpty(dto.get("DATA_QUALITY_SCORE")) ? null : DataQualityScoreEnum.getNameByCode(dto.get("DATA_QUALITY_SCORE").toString());
dto.put("DATA_QUALITY_SCORE", dataQualityScore);
// if (dto.get("EQU_LIST_CODE").equals("8000")) {
// JSONArray techParams = (JSONArray) dto.get("techParams");
// 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("doubleValue")) {
// String pipeLength = JSONObject.parseObject(JSONObject.toJSONString(obj)).get("doubleValue").toString();
// pipeLong += Double.parseDouble(pipeLength);
// }
// }
// }
list.add(dto);
}
totle = Objects.requireNonNull(response.getInternalResponse().hits().getTotalHits()).value;
......@@ -710,7 +714,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
sum.put("value", totle);
statics.add(sum);
if(ObjectUtils.isEmpty(filterParams) || !filterParams.containsKey("EQU_LIST")){
if (ObjectUtils.isEmpty(filterParams) || !filterParams.containsKey("EQU_LIST")) {
filterParams = new JSONObject();
JSONArray jsonArray = new JSONArray();
jsonArray.add("all");
......@@ -718,14 +722,18 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
}
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<>();
pipeMap.put("name", "压力管道(千米)");
pipeMap.put("value", pipeLong);
pipeMap.put("value", pipeMaps.get("pressurePipelines"));
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<>();
gasMap.put("name", "气瓶(个)");
......@@ -741,6 +749,19 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
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) {
String path = "techParams";
String nestedFieldKey = path + ".paramKey";
......@@ -944,11 +965,12 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
}
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");
Object value = paramRange.get("value");
String andOr = paramRange.getString("andOr");
String fieldType = paramRange.getString("fieldType");
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