Commit 8c1b259e authored by tianyiming's avatar tianyiming

大屏综合统计-企业、人员调整

parent 697f31c6
......@@ -15,9 +15,9 @@ public enum StatisticalAnalysisEnum {
*/
company("企业", "company", "idx_biz_enterprise_info"),
inspectionCompany("检验检测机构", "inspectionCompany", "idx_biz_enterprise_info"),
person("人员", "person", "idx_biz_user_info"),
inspectionPerson("检验检测人员", "inspectionPerson", "idx_biz_user_info"),
equip("设备", "equip", "idx_biz_equipment_info");
private String name;
......
......@@ -6,8 +6,13 @@ import lombok.Getter;
@AllArgsConstructor
@Getter
public enum UnitCategoryEnum {
use("使用单位", "use"),
license("许可单位", "license");
use("使用单位", "use","use"), // 企业和个人主体
produce("生产单位", "produce","license"), // 设计单位、制造单位、安装改造维修单位
filling("充装单位", "filling","license"), // 充装单位
inspection("检验机构", "inspection","license"), // 检验机构
detection("检测机构", "detection","license"); // 检测机构
private final String name;
private final String code;
private final String type;
}
......@@ -812,8 +812,8 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
private String getFilterPermitStatusOrLicensesStatus(JSONArray leftGroup, JSONArray rightGroup, String code) {
String filed = code.equals(StatisticalAnalysisEnum.company.getCode()) ? "permitStatus" : "expiryDate";
List<Object> LeftNoLicenseList = leftGroup.stream().filter(e->"certNo".equals(((JSONObject) e).getString("field")) && ((JSONObject) e).containsKey("value") && ((JSONObject) e).getString("value").equals("0") && ((JSONObject) e).containsKey("itemCondition") && !((JSONObject) e).getString("itemCondition").equals("notIn") ).collect(Collectors.toList());
List<Object> rightNoLicenseList = rightGroup.stream().filter(e->"certNo".equals(((JSONObject) e).getString("field")) && ((JSONObject) e).containsKey("value") && ((JSONObject) e).getString("value").equals("0") && ((JSONObject) e).containsKey("itemCondition") && !((JSONObject) e).getString("itemCondition").equals("notIn") ).collect(Collectors.toList());
List<Object> LeftNoLicenseList = leftGroup.stream().filter(e -> "certNo".equals(((JSONObject) e).getString("field")) && ((JSONObject) e).containsKey("value") && ((JSONObject) e).getString("value").equals("0") && ((JSONObject) e).containsKey("itemCondition") && !((JSONObject) e).getString("itemCondition").equals("notIn")).collect(Collectors.toList());
List<Object> rightNoLicenseList = rightGroup.stream().filter(e -> "certNo".equals(((JSONObject) e).getString("field")) && ((JSONObject) e).containsKey("value") && ((JSONObject) e).getString("value").equals("0") && ((JSONObject) e).containsKey("itemCondition") && !((JSONObject) e).getString("itemCondition").equals("notIn")).collect(Collectors.toList());
Boolean noLicense = false;
if (LeftNoLicenseList.size() > 0 || rightNoLicenseList.size() > 0) {
noLicense = true;
......@@ -3089,6 +3089,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
JSONObject filterParams = JSONObject.parseObject(JSONObject.toJSONString(filter.get("filterParams")));
String filterType = "advanced";
String unitCategory = filterParams.getString("unitCategory");
// 组装人员过滤条件
this.getPersonBoolQueryBuilder(filterParams, boolMust, filterType);
......@@ -3098,12 +3099,36 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
.map(filterParamsObj -> filterParams.getJSONArray("unitType"))
.map(unitTypeObj -> !unitTypeObj.isEmpty())
.orElse(false);
boolean is3LeveFlag = Optional.of(filter)
.map(obj -> obj.getJSONObject("filterParams"))
.map(filterParamsObj -> filterParamsObj.getJSONArray("threeLevel"))
.map(threeLevelObj -> !threeLevelObj.isEmpty())
.orElse(false);
Map<String, Object> result = new HashMap<>();
// 一级统计
if (!is2LeveFlag) {
return getTotalAggMapsByUnitType(request, builder, boolMust, tabTotalMap, StatisticalAnalysisEnum.person);
// 计算总数
boolMust.should(QueryBuilders.matchQuery("unitType", UnitTypeEnum.sydw.getName()))
.should(QueryBuilders.matchQuery("unitType", UnitTypeEnum.grzt.getName()))
.should(QueryBuilders.matchQuery("unitType", UnitTypeEnum.zzdw.getName()))
.should(QueryBuilders.matchQuery("unitType", UnitTypeEnum.sjdw.getName()))
.should(QueryBuilders.matchQuery("unitType", UnitTypeEnum.azgzwxdw.getName()))
.should(QueryBuilders.matchQuery("unitType", UnitTypeEnum.czdw.getName()))
.minimumShouldMatch(1);
result = getTotalAggMapsByUnitType(request, builder, boolMust, tabTotalMap, StatisticalAnalysisEnum.person);
} else if (!is3LeveFlag) {
if (unitCategory.equals(UnitCategoryEnum.use.getCode())) {
boolMust.should(QueryBuilders.matchQuery("unitType", UnitTypeEnum.sydw.getName()))
.should(QueryBuilders.matchQuery("unitType", UnitTypeEnum.grzt.getName()))
.minimumShouldMatch(1);
} else if (unitCategory.equals(UnitCategoryEnum.produce.getCode())) {
boolMust.should(QueryBuilders.matchQuery("unitType", UnitTypeEnum.zzdw.getName()))
.should(QueryBuilders.matchQuery("unitType", UnitTypeEnum.sjdw.getName()))
.should(QueryBuilders.matchQuery("unitType", UnitTypeEnum.azgzwxdw.getName()))
.minimumShouldMatch(1);
} else {
// 二级统计
Map<String, Object> result = new HashMap<>();
boolMust.must(QueryBuilders.wildcardQuery("unitType.keyword", "*" + UnitTypeEnum.czdw.getName() + "*"));
JSONObject expiryDateStatus = this.getExpiryDateStatusGroupStatistics(boolMust);
JSONObject personType = this.getPersonTypeGroupStatistics(boolMust);
result.put("tabTotalMap", new JSONObject()
......@@ -3112,12 +3137,37 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
result.put("datas", new JSONObject()
.fluentPut("expiryDateStatus", expiryDateStatus)
.fluentPut("personType", personType));
return Collections.singletonList(result);
}
result = getTotalAggMapsByUnitType(request, builder, boolMust, tabTotalMap, StatisticalAnalysisEnum.person);
} else {
JSONArray threeLevel = filterParams.getJSONArray("threeLevel");
String filterCode = threeLevel.getString(0);
String unitType;
if (filterCode.equals("use")) {
unitType = UnitTypeEnum.sydw.getName();
} else if (filterCode.equals("person")) {
unitType = UnitTypeEnum.grzt.getName();
} else if (filterCode.equals("design")) {
unitType = UnitTypeEnum.sjdw.getName();
} else if (filterCode.equals("factory")) {
unitType = UnitTypeEnum.zzdw.getName();
} else {
unitType = UnitTypeEnum.azgzwxdw.getName();
}
boolMust.must(QueryBuilders.wildcardQuery("unitType.keyword", "*" + unitType + "*"));
JSONObject expiryDateStatus = this.getExpiryDateStatusGroupStatistics(boolMust);
JSONObject personType = this.getPersonTypeGroupStatistics(boolMust);
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));
}
return Collections.singletonList(result);
}
private List<Map<String, Object>> getTotalAggMapsByUnitType(SearchRequest request, SearchSourceBuilder builder, BoolQueryBuilder boolMust, Map<String, Object> tabTotalMap, StatisticalAnalysisEnum statisticalAnalysisEnum) {
// 计算总数
private Map<String, Object> getTotalAggMapsByUnitType(SearchRequest request, SearchSourceBuilder builder, BoolQueryBuilder boolMust, Map<String, Object> tabTotalMap, StatisticalAnalysisEnum statisticalAnalysisEnum) {
long total = this.queryDpStatisticsTotalByIndex(boolMust, statisticalAnalysisEnum.getKey());
// 聚合查询
builder.size(0);// 不返回任何文档,只返回聚合结果
......@@ -3137,7 +3187,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
}
// 汇总总数
tabTotalMap.put(statisticalAnalysisEnum.getCode(), total);
return Collections.singletonList(result);
return result;
}
public void buildPersonWithCompanyTypeGroupResult(Terms unitTypesTerms, Map<String, Object> result) {
......@@ -3202,44 +3252,165 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
.map(filterParamsObj -> filterParamsObj.getJSONArray("unitType"))
.map(unitTypeObj -> !unitTypeObj.isEmpty())
.orElse(false);
boolean is3LeveFlag = Optional.of(filter)
.map(obj -> obj.getJSONObject("filterParams"))
.map(filterParamsObj -> filterParamsObj.getJSONArray("threeLevel"))
.map(threeLevelObj -> !threeLevelObj.isEmpty())
.orElse(false);
// 一级统计
if (!is2LeveFlag) {
return getTotalAggMapsByUnitType(request, builder, boolMust, tabTotalMap, StatisticalAnalysisEnum.company);
} else {
// 二级统计
if (!is2LeveFlag && !is3LeveFlag) {
// 计算总数
boolMust.should(QueryBuilders.matchQuery("unitType", UnitTypeEnum.sydw.getName()))
.should(QueryBuilders.matchQuery("unitType", UnitTypeEnum.grzt.getName()))
.should(QueryBuilders.matchQuery("unitType", UnitTypeEnum.zzdw.getName()))
.should(QueryBuilders.matchQuery("unitType", UnitTypeEnum.sjdw.getName()))
.should(QueryBuilders.matchQuery("unitType", UnitTypeEnum.azgzwxdw.getName()))
.should(QueryBuilders.matchQuery("unitType", UnitTypeEnum.czdw.getName()))
.minimumShouldMatch(1);
Map<String, Object> datas = getTotalAggMapsByUnitType(request, builder, boolMust, tabTotalMap, StatisticalAnalysisEnum.company);
return getUseAndProductAndFillingStatistics(datas);
} else if (is2LeveFlag && !is3LeveFlag) {
Map<String, Object> result = new HashMap<>();
String unitType = filterParams.getJSONArray("unitType").getString(0);
// 使用单位:使用单位 返回管控级别和所属行业;个人主体 前端不下钻
boolMust.must(QueryBuilders.matchQuery("unitType", unitType));
Long companyCount = getStatisticCount(boolMust, StatisticalAnalysisEnum.company.getKey());
JSONObject industrySupervisor = this.getItemGroupStatisticsByItemName(boolMust,
StatisticalAnalysisEnum.company.getKey(),
"industrySupervisorAggName",
"industrySupervisor",
this::buildIndustrySupervisorGroupResult);
if (unitCategory.equals(UnitCategoryEnum.use.getType())) {
getTotalAggMapsByUnitType(request, builder, boolMust, tabTotalMap, StatisticalAnalysisEnum.company);
JSONObject regulatoryLabels = this.getItemGroupStatisticsByItemName(boolMust,
StatisticalAnalysisEnum.company.getKey(),
"regulatoryLabelsAggName",
"regulatoryLabels",
this::buildRegulatoryLabelsGroupResult);
Long levelControl1 = 0L;
Long levelControl2 = 0L;
Long levelControl3 = 0L;
for (String key : regulatoryLabels.keySet()) {
if (key.contains("levelControl1")) {
levelControl1 += regulatoryLabels.getLong(key);
} else if (key.contains("levelControl2")) {
levelControl2 += regulatoryLabels.getLong(key);
} else if (key.contains("levelControl3")) {
levelControl3 += regulatoryLabels.getLong(key);
}
}
Map<String, Long> levelControlMap = new HashMap<>();
levelControlMap.put("levelControl1", levelControl1);
levelControlMap.put("levelControl2", levelControl2);
levelControlMap.put("levelControl3", levelControl3);
result.put("datas", new JSONObject()
.fluentPut("regulatoryLabels", levelControlMap)
.fluentPut("industrySupervisor", industrySupervisor));
} else if (unitCategory.equals(UnitCategoryEnum.produce.getCode())) {
Map<String, Object> datas = getTotalAggMapsByUnitType(request, builder, boolMust, tabTotalMap, StatisticalAnalysisEnum.company);
Map<String, Object> productMap = new HashMap<>();
productMap.put("design", datas.get("sjdw"));
productMap.put("factory", datas.get("zzdw"));
productMap.put("construction", datas.get("azgzwxdw"));
result.put("datas", new JSONObject()
.fluentPut("companyType", productMap)
.fluentPut("industrySupervisor", industrySupervisor));
} else if (unitCategory.equals(UnitCategoryEnum.filling.getCode())) {
getTotalAggMapsByUnitType(request, builder, boolMust, tabTotalMap, StatisticalAnalysisEnum.company);
JSONObject permitStatus = getPermitStatusGroupStatistics(boolMust);
result.put("datas", new JSONObject()
.fluentPut("permitStatus", permitStatus)
.fluentPut("industrySupervisor", industrySupervisor));
}
result.put("tabTotalMap", new JSONObject()
.fluentPut("regulatoryLabelsTotal", companyCount)
.fluentPut("industrySupervisorTotal", this.sumWithJSONObjectValues(industrySupervisor)));
return Collections.singletonList(result);
} else if (is3LeveFlag) {
Map<String, Object> result = new HashMap<>();
JSONArray threeLevel = filterParams.getJSONArray("threeLevel");
String filterCode = threeLevel.getString(0);
Map<String, Long> levelControlMap = new HashMap<>();
Map<String, Object> companyMap = new HashMap<>();
JSONObject permitStatus = new JSONObject();
if (unitCategory.equals(UnitCategoryEnum.use.getCode())) {
if (filterCode.equals("levelControl1") || filterCode.equals("levelControl2")) {
boolMust.must(QueryBuilders.wildcardQuery("regulatoryLabels.keyword", (filterCode.contains("1") ? "*一级管控*" : "*二级管控*")));
getTotalAggMapsByUnitType(request, builder, boolMust, tabTotalMap, StatisticalAnalysisEnum.company);
JSONObject regulatoryLabels = this.getItemGroupStatisticsByItemName(boolMust,
StatisticalAnalysisEnum.company.getKey(),
"regulatoryLabelsAggName",
"regulatoryLabels",
this::buildRegulatoryLabelsGroupResult);
for (String key : regulatoryLabels.keySet()) {
if (key.contains(filterCode)) {
levelControlMap.put(key, regulatoryLabels.getLong(key));
}
}
} else {
Map<String, Object> datas = getTotalAggMapsByUnitType(request, builder, boolMust, tabTotalMap, StatisticalAnalysisEnum.company);
companyMap.put("use", datas.get("sydw"));
companyMap.put("grzt", datas.get("grzt"));
}
} else if (unitCategory.equals(UnitCategoryEnum.produce.getCode())) {
String unitType = filterCode.equals("design") ? UnitTypeNewEnum.sjdw.getLabel() : filterCode.equals("factory") ? UnitTypeNewEnum.zzdw.getLabel() : UnitTypeNewEnum.azgzwxdw.getLabel();
boolMust.must(QueryBuilders.wildcardQuery("unitType.keyword", "*" + unitType + "*"));
getTotalAggMapsByUnitType(request, builder, boolMust, tabTotalMap, StatisticalAnalysisEnum.company);
permitStatus = getPermitStatusGroupStatistics(boolMust);
}
Long companyCount = getStatisticCount(boolMust, StatisticalAnalysisEnum.company.getKey());
JSONObject industrySupervisor = this.getItemGroupStatisticsByItemName(boolMust,
StatisticalAnalysisEnum.company.getKey(),
"industrySupervisorAggName",
"industrySupervisor",
this::buildIndustrySupervisorGroupResult);
result.put("tabTotalMap", new JSONObject()
.fluentPut("regulatoryLabelsTotal", companyCount)
.fluentPut("industrySupervisorTotal", this.sumWithJSONObjectValues(industrySupervisor)));
if (unitCategory.equals(UnitCategoryEnum.use.getCode())) {
if (filterCode.equals("levelControl1") || filterCode.equals("levelControl2")) {
result.put("datas", new JSONObject()
.fluentPut("regulatoryLabels", regulatoryLabels)
.fluentPut("regulatoryLabels", levelControlMap)
.fluentPut("industrySupervisor", industrySupervisor));
} else if (unitCategory.equals(UnitCategoryEnum.license.getCode())) {// 许可单位:设计单位、制造单位、充装单位、检验机构、检查机构、安装改造维修单位
JSONObject permitStatus = getPermitStatusGroupStatistics(boolMust);
result.put("tabTotalMap", new JSONObject()
.fluentPut("permitStatusTotal", companyCount));
} else {
result.put("datas", new JSONObject()
.fluentPut("permitStatus", permitStatus));
.fluentPut("company", companyMap)
.fluentPut("industrySupervisor", industrySupervisor));
}
} else if (unitCategory.equals(UnitCategoryEnum.produce.getCode())) {
result.put("datas", new JSONObject()
.fluentPut("permitStatus", permitStatus)
.fluentPut("industrySupervisor", industrySupervisor));
}
result.put("tabTotalMap", new JSONObject()
.fluentPut("regulatoryLabelsTotal", companyCount)
.fluentPut("industrySupervisorTotal", this.sumWithJSONObjectValues(industrySupervisor)));
return Collections.singletonList(result);
}
return null;
}
private List<Map<String, Object>> getUseAndProductAndFillingStatistics(Map<String, Object> datas) {
Map<String, Object> result = new HashMap<>();
Long filling = 0L;
Long use = 0L;
Long produce = 0L;
for (String key : datas.keySet()) {
if (key.equals("sydw")) {
use += Long.valueOf(datas.get("sydw").toString());
} else if (key.equals("grzt")) {
use += Long.valueOf(datas.get("grzt").toString());
} else if (key.equals("sjdw")) {
produce += Long.valueOf(datas.get("sjdw").toString());
} else if (key.equals("zzdw")) {
produce += Long.valueOf(datas.get("zzdw").toString());
} else if (key.equals("azgzwxdw")) {
produce += Long.valueOf(datas.get("azgzwxdw").toString());
} else if (key.equals("czdw")) {
filling = Long.valueOf(datas.get("czdw").toString());
}
}
result.put("use", use);
result.put("produce", produce);
result.put("filling", filling);
return Collections.singletonList(result);
}
private List<Map<String, Object>> queryDpEquipStatistics(JSONObject filter, SearchRequest request, SearchSourceBuilder builder, BoolQueryBuilder boolMust, Map<String, Object> tabTotalMap) {
......@@ -3343,7 +3514,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
SearchSourceBuilder scoreBuilder = new SearchSourceBuilder();
Map<String, Object> scoreCountByGroup = new HashMap<>();
getStatisticCountByGroup(request, scoreBuilder, scoreQuery, "DATA_QUALITY_SCORE", scoreCountByGroup, "scoreCount");
if(!code.startsWith("8")){
if (!code.startsWith("8")) {
for (String key : scoreCountByGroup.keySet()) {
Long classCount = "1".equals(key) ? oneClassCount += (Long) scoreCountByGroup.get(key) : ("2".equals(key) ? (twoClassCount += (Long) scoreCountByGroup.get(key)) : (threeClassCount += (Long) scoreCountByGroup.get(key)));
}
......
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