Commit 7c5e2b8a authored by tianyiming's avatar tianyiming

refactor(core): 修改bug

parent 07e98c1e
......@@ -45,7 +45,6 @@ import org.elasticsearch.client.core.CountRequest;
import org.elasticsearch.client.core.CountResponse;
import org.elasticsearch.index.query.*;
import org.elasticsearch.search.SearchHit;
import org.elasticsearch.search.aggregations.Aggregation;
import org.elasticsearch.search.aggregations.AggregationBuilders;
import org.elasticsearch.search.aggregations.bucket.nested.ParsedNested;
import org.elasticsearch.search.aggregations.bucket.terms.Terms;
......@@ -2652,6 +2651,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
private void getTypeCount(String businessType, Map<String, Object> tabTotalMap, String orgCode, List<Map<String, Object>> data) {
BoolQueryBuilder equipBoolMust = QueryBuilders.boolQuery();
equipBoolMust.must(QueryBuilders.prefixQuery("ORG_BRANCH_CODE", orgCode));
equipBoolMust.mustNot(QueryBuilders.termsQuery("STATUS",Arrays.asList("草稿","已拒领","待认领")));
BoolQueryBuilder companyBoolMust = QueryBuilders.boolQuery();
companyBoolMust.must(QueryBuilders.prefixQuery("superviseOrgCode", orgCode));
BoolQueryBuilder personBoolMust = QueryBuilders.boolQuery();
......@@ -2803,21 +2803,26 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
List<Map<String, Object>> staticCountByGroupMap = new ArrayList<>();
String equipCode = null;
if (!ObjectUtils.isEmpty(typeData)) {
String id = null;
JSONObject jsonObject = new JSONObject();
if (typeData.size() == 1) {
groupField = "EQU_CATEGORY_CODE";
id = JSONObject.parseObject(JSONObject.toJSONString(typeData.get(0))).getString("key");
jsonObject = JSONObject.parseObject(JSONObject.toJSONString(typeData.get(0)));
} else if (typeData.size() == 2) {
groupField = "EQU_DEFINE_CODE";
id = JSONObject.parseObject(JSONObject.toJSONString(typeData.get(1))).getString("key");
jsonObject = JSONObject.parseObject(JSONObject.toJSONString(typeData.get(1)));
}
id = jsonObject.getString("key");
equipCode = jsonObject.getString("code");
staticCountByGroupMap = tzsCustomFilterMapper.selectEquipmentCategoryByParentId(id);
} else {
groupField = "EQU_LIST_CODE";
Map<String, List<Map<String, Object>>> resourceJson = JsonUtils.getResourceJson(equipCategory);
staticCountByGroupMap = resourceJson.get(EquipmentClassifityEnum.ZHTJFX.getCode());
}
boolMust.mustNot(QueryBuilders.termsQuery("STATUS",Arrays.asList("草稿","已拒领","待认领")));
Map<String, Long> staticCountByGroup = new HashMap<>();
getStatisticCountByGroup(request, builder, boolMust, groupField, staticCountByGroup);
......@@ -2833,7 +2838,8 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
map.put("key", categoryMap.get("key"));
map.put("label", categoryMap.get("label"));
map.put("code", categoryMap.get("value"));
map.put("value", staticCountByGroup.containsKey(code) ? staticCountByGroup.get(code) : 0);
map.put("fieldKey", groupField.replace("_CODE", ""));
map.put("value", staticCountByGroup.containsKey(code) ? staticCountByGroup.get(code) : 0L);
map.put("img", dpEquipPhotoPrefix + code + dpEquipPhotoSuffix);
map.put("measurementUnit", "台套");
// 统计该分类下的数据完整性的分组数量 DATA_QUALITY_SCORE
......@@ -2851,6 +2857,9 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
map.put("NEXT_INSPECT_DATE", nextInspectCountByGroup);
dataMapList.add(map);
}
if(!ObjectUtils.isEmpty(equipCode)){
tabTotalMap.put(equipCode, dataMapList.stream().mapToLong(map -> (Long) map.get("value")).sum());
}
return dataMapList;
}
......@@ -2920,9 +2929,9 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
// 查询
JSONObject expiryDateStatus = this.getExpiryDateStatusGroupStatistics(boolQuery);
JSONObject personType = this.getPersonTypeGroupStatistics(boolQuery);
result.put("tabTotalMap",new JSONObject()
.fluentPut("expiryDateStatusTotal",this.sumWithJSONObjectValues(expiryDateStatus))
.fluentPut("personTypeTotal",this.sumWithJSONObjectValues(personType)));
result.put("tabTotalMap", new JSONObject()
.fluentPut("expiryDateStatusTotal", this.sumWithJSONObjectValues(expiryDateStatus))
.fluentPut("personTypeTotal", this.sumWithJSONObjectValues(personType)));
result.put("datas", new JSONObject()
.fluentPut("expiryDateStatus", expiryDateStatus)
.fluentPut("personType", personType));
......@@ -2931,6 +2940,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
/**
* 对JSONObject类型的所有values求和
*
* @param jsonObject
* @return
*/
......
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