|
|
@ -58,6 +58,10 @@ import org.springframework.stereotype.Service; |
|
|
|
import java.util.*; |
|
|
|
import java.util.concurrent.CompletableFuture; |
|
|
|
import java.util.concurrent.ExecutionException; |
|
|
|
import java.util.concurrent.ExecutorService; |
|
|
|
import java.util.concurrent.atomic.AtomicInteger; |
|
|
|
import java.util.concurrent.CompletableFuture; |
|
|
|
import java.util.concurrent.ExecutionException; |
|
|
|
import java.util.concurrent.atomic.AtomicReference; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
@ -89,6 +93,9 @@ public class CoverageServiceImpl implements CoverageService { |
|
|
|
@Autowired |
|
|
|
private IcResiCategoryWarnService icResiCategoryWarnService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private ExecutorService executorService; |
|
|
|
|
|
|
|
// 1:出租 0:自住 2:闲置 3:未售出
|
|
|
|
public static final Integer HOUSE_RENT_FLAG_RENT = 1; |
|
|
|
|
|
|
@ -580,10 +587,11 @@ public class CoverageServiceImpl implements CoverageService { |
|
|
|
return heartService.countCommunityOrgEntities(customerId, agencyId, staffOrgIds, search, categoryKey); |
|
|
|
} else if (CoveragePlaceTypeEnum.PARTY_UNIT.getCode().equals(placeType)) { |
|
|
|
// 机关直属部门(联建单位) 楼宇党建 0;两新组织 1;区域单位党建 2;机关直属部门 3;社会团体 4;民办非企业单位 5;基金会 6;其他 7
|
|
|
|
if (categoryKey.equals("pu_jgzsbm")) { |
|
|
|
String partyUnitType = "3"; |
|
|
|
return heartService.countPartyUnitEntities(customerId, agencyId, staffOrgIds, partyUnitType, search); |
|
|
|
} |
|
|
|
// if (categoryKey.equals("pu_jgzsbm")) {
|
|
|
|
// String partyUnitType = "3";
|
|
|
|
// }
|
|
|
|
String[] parts = categoryKey.split("_"); |
|
|
|
return heartService.countPartyUnitEntities(customerId, agencyId, staffOrgIds, parts[1], search); |
|
|
|
} else if (CoveragePlaceTypeEnum.DANGEROUS_CHEMICALS.getCode().equals(placeType)) { |
|
|
|
// 危化企业
|
|
|
|
return orgCoverageService.countDangerousChemicalEntities(customerId, staffOrgIds, search, categoryKey); |
|
|
@ -690,17 +698,16 @@ public class CoverageServiceImpl implements CoverageService { |
|
|
|
|
|
|
|
} else if (CoveragePlaceTypeEnum.PARTY_UNIT.getCode().equals(placeType)) { |
|
|
|
// 机关直属部门(联建单位) 楼宇党建 0;两新组织 1;区域单位党建 2;机关直属部门 3;社会团体 4;民办非企业单位 5;基金会 6;其他 7
|
|
|
|
if (categoryKey.equals("pu_jgzsbm")) { |
|
|
|
String partyUnitType = "3"; |
|
|
|
// if (categoryKey.equals("pu_jgzsbm")) {
|
|
|
|
// String partyUnitType = "3";
|
|
|
|
// }
|
|
|
|
String[] parts = categoryKey.split("_"); |
|
|
|
List<IcPartyUnitEntity> l = heartService.searchPartyUnitEntities( |
|
|
|
customerId, agencyId, staffOrgIds, partyUnitType, search, isPage, pageNo, pageSize); |
|
|
|
|
|
|
|
customerId, agencyId, staffOrgIds, parts[1], search, isPage, pageNo, pageSize); |
|
|
|
return l.stream() |
|
|
|
.map(dc -> new CoverageAnalisisDataListResultDTO(dc.getId(), categoryKey, |
|
|
|
isPage ? categoryDict.getCategoryName() : null, placeType, isPage ? dc.getUnitName() : null, dc.getLatitude(), dc.getLongitude())) |
|
|
|
.collect(Collectors.toList()); |
|
|
|
} |
|
|
|
return new ArrayList<>(); |
|
|
|
} else if (CoveragePlaceTypeEnum.DANGEROUS_CHEMICALS.getCode().equals(placeType)) { |
|
|
|
// 危化企业
|
|
|
|
List<IcDangerousChemicalsEntity> l = orgCoverageService.searchDangerousChemicalEntities( |
|
|
@ -802,7 +809,7 @@ public class CoverageServiceImpl implements CoverageService { |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public List<AnalysisResourceCategoriesResult> listAnalysisResourceCategories() { |
|
|
|
public List<AnalysisResourceCategoriesResult> listAnalysisResourceCategories(String agencyId) { |
|
|
|
|
|
|
|
// 获取所有菜单的url
|
|
|
|
List<String> menuUrls = new ArrayList<>(128); |
|
|
@ -822,7 +829,7 @@ public class CoverageServiceImpl implements CoverageService { |
|
|
|
continue; |
|
|
|
} |
|
|
|
|
|
|
|
AnalysisResourceCategoriesResult categoriesOfThisCoverage = new AnalysisResourceCategoriesResult(); |
|
|
|
AnalysisResourceCategoriesResult coverageResult = new AnalysisResourceCategoriesResult(); |
|
|
|
HashMap<String, AnalysisResourceCategoriesResult.PlaceType> placeTypeMap = new HashMap<>(); |
|
|
|
|
|
|
|
List<IcCoverageCategoryDictEntity> categoryDictEntities = govOrgCoverageService.listResourceCategoryEntities(coverage.getKey()); |
|
|
@ -836,9 +843,9 @@ public class CoverageServiceImpl implements CoverageService { |
|
|
|
if (StringUtils.isBlank(category.getPlaceTypeInAnalysis())) { |
|
|
|
// 没有placetype的
|
|
|
|
if ("all".equals(category.getMenuUrl()) || menuUrls.contains(category.getMenuUrl())) { |
|
|
|
categoriesOfThisCoverage.getCategories() |
|
|
|
coverageResult.getCategories() |
|
|
|
.add(new AnalysisResourceCategoriesResult.Category(category.getCategoryKey(), category.getCategoryName(), |
|
|
|
category.getCoverageType(), category.getPlaceType(), category.getQuantity())); |
|
|
|
category.getCoverageType(), category.getPlaceType(), 0)); |
|
|
|
} |
|
|
|
} else { |
|
|
|
// 有placetype的
|
|
|
@ -847,35 +854,96 @@ public class CoverageServiceImpl implements CoverageService { |
|
|
|
|
|
|
|
if (placeType == null) { |
|
|
|
placeType = new AnalysisResourceCategoriesResult.PlaceType( |
|
|
|
category.getPlaceTypeInAnalysis(), CoveragePlaceTypeEnum.getEnum(category.getPlaceTypeInAnalysis()).getName(), category.getQuantity(), new ArrayList<>()); |
|
|
|
category.getPlaceTypeInAnalysis(), CoveragePlaceTypeEnum.getEnum(category.getPlaceTypeInAnalysis()).getName(), new AtomicInteger(0), new ArrayList<>()); |
|
|
|
placeTypeMap.put(category.getPlaceTypeInAnalysis(), placeType); |
|
|
|
} |
|
|
|
|
|
|
|
placeType.getCategories().add(new AnalysisResourceCategoriesResult.Category(category.getCategoryKey(), |
|
|
|
category.getCategoryName(), category.getCoverageType(), category.getPlaceType(), category.getQuantity())); |
|
|
|
placeType.setQuantity(placeType.getQuantity() + category.getQuantity()); // todo 0改为category的count
|
|
|
|
category.getCategoryName(), category.getCoverageType(), category.getPlaceType(), 0)); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
AtomicReference<Integer> total = new AtomicReference<>(0); |
|
|
|
placeTypeMap.forEach((placeTypeKey, placeType) -> { |
|
|
|
categoriesOfThisCoverage.getPlaceTypesInAnalysis().add(placeType); |
|
|
|
total.updateAndGet(v -> v + placeType.getQuantity()); |
|
|
|
coverageResult.getPlaceTypesInAnalysis().add(placeType); |
|
|
|
}); |
|
|
|
|
|
|
|
categoriesOfThisCoverage.setCoverageType(coverage.getKey()); |
|
|
|
categoriesOfThisCoverage.setCoverageName(CoverageEnums.getEnum(coverage.getKey()).getCoverageName()); |
|
|
|
categoriesOfThisCoverage.setQuantity(total.get()); |
|
|
|
results.add(categoriesOfThisCoverage); |
|
|
|
coverageResult.setCoverageType(coverage.getKey()); |
|
|
|
coverageResult.setCoverageName(CoverageEnums.getEnum(coverage.getKey()).getCoverageName()); |
|
|
|
results.add(coverageResult); |
|
|
|
} |
|
|
|
|
|
|
|
String customerId = EpmetRequestHolder.getLoginUserCustomerId(); |
|
|
|
String userId = EpmetRequestHolder.getLoginUserId(); |
|
|
|
|
|
|
|
Map<String,String> stafInfoMap=getStaffPidsFromStaffInfo(customerId, userId, agencyId,OrgConstant.AGENCY); |
|
|
|
String staffOrgPath = stafInfoMap.get(OrgConstant.AGENC_PATH); |
|
|
|
|
|
|
|
// 填充数量quantity字段
|
|
|
|
fillQuantities4ResourcesCoverages(results, customerId, agencyId, staffOrgPath); |
|
|
|
|
|
|
|
return results; |
|
|
|
} |
|
|
|
|
|
|
|
private void fillQuantities4ResourcesCoverages(ArrayList<AnalysisResourceCategoriesResult> coverages, String customerId, String agencyId, String staffOrgIds) { |
|
|
|
|
|
|
|
ArrayList<CompletableFuture<Void>> futures = new ArrayList<>(); |
|
|
|
|
|
|
|
coverages.forEach(coverage -> { |
|
|
|
List<AnalysisResourceCategoriesResult.Category> categoriesInCoverage = coverage.getCategories(); |
|
|
|
List<AnalysisResourceCategoriesResult.PlaceType> placeTypesInCoverage = coverage.getPlaceTypesInAnalysis(); |
|
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(categoriesInCoverage)) { |
|
|
|
// 直属于图层的category。异步提交计算任务
|
|
|
|
CompletableFuture<Void> future = CompletableFuture.runAsync(() -> fillQuantities4ResourcesCategories(coverage, null, categoriesInCoverage, customerId, agencyId, staffOrgIds)); |
|
|
|
futures.add(future); |
|
|
|
} |
|
|
|
if (CollectionUtils.isNotEmpty(placeTypesInCoverage)) { |
|
|
|
// placeType,需要拆开来算, 异步提交计算任务
|
|
|
|
placeTypesInCoverage.forEach(placeType -> { |
|
|
|
List<AnalysisResourceCategoriesResult.Category> categoriesInPlaceType = placeType.getCategories(); |
|
|
|
CompletableFuture<Void> future = CompletableFuture.runAsync(() -> fillQuantities4ResourcesCategories(coverage, placeType, categoriesInPlaceType, customerId, agencyId, staffOrgIds)); |
|
|
|
futures.add(future); |
|
|
|
}); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
// 等待异步任务计算完成
|
|
|
|
futures.forEach(f -> { |
|
|
|
try { |
|
|
|
f.get(); |
|
|
|
} catch (InterruptedException e) { |
|
|
|
log.error("【五大图层】可视化-右侧资源列表异步计算数量quantity失败,计算被中止,错误信息:{}", ExceptionUtils.getErrorStackTrace(e)); |
|
|
|
} catch (ExecutionException e) { |
|
|
|
log.error("【五大图层】可视化-右侧资源列表异步计算数量quantity失败,错误信息:{}", ExceptionUtils.getErrorStackTrace(e)); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
private void fillQuantities4ResourcesCategories(AnalysisResourceCategoriesResult coverage, |
|
|
|
AnalysisResourceCategoriesResult.PlaceType placeType, |
|
|
|
List<AnalysisResourceCategoriesResult.Category> categories, |
|
|
|
String customerId, String agencyId, String staffOrgIds) { |
|
|
|
|
|
|
|
AtomicInteger total = new AtomicInteger(); |
|
|
|
|
|
|
|
categories.forEach(cat -> { |
|
|
|
Integer quantity = doDataListCount(customerId, agencyId, staffOrgIds, cat.getPlaceType(), cat.getCategoryKey(), null, null); |
|
|
|
cat.setQuantity(quantity); |
|
|
|
total.getAndAdd(quantity); |
|
|
|
}); |
|
|
|
|
|
|
|
// 分别给所属的coverage和placeType的quantity增加quantity
|
|
|
|
coverage.getQuantity().getAndAdd(total.get()); |
|
|
|
|
|
|
|
if (placeType != null) { |
|
|
|
placeType.getQuantity().getAndAdd(total.get()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public List<AnalysisGovernedTargetsResult> listGovernedTargetCategories() { |
|
|
|
public List<AnalysisGovernedTargetsResult> listGovernedTargetCategories(String agencyId) { |
|
|
|
|
|
|
|
// 获取所有菜单的url
|
|
|
|
List<String> menuUrls = new ArrayList<>(128); |
|
|
@ -898,7 +966,6 @@ public class CoverageServiceImpl implements CoverageService { |
|
|
|
|
|
|
|
List<AnalysisGovernedTargetsResult> results = new ArrayList<>(); |
|
|
|
HashMap<String, List<AnalysisGovernedTargetsResult>> placeTypeTargetMap = new HashMap<>(); |
|
|
|
HashMap<String, Integer> placeTypeQuantityMap = new HashMap<>(); |
|
|
|
|
|
|
|
targetCategories.forEach(rc -> { |
|
|
|
String placeTypeInAnalysis = rc.getPlaceTypeInAnalysis(); |
|
|
@ -912,7 +979,7 @@ public class CoverageServiceImpl implements CoverageService { |
|
|
|
// 只有一层,没有子级
|
|
|
|
if (menuUrls.contains(rc.getMenuUrl()) || "all".equals(rc.getMenuUrl())) { |
|
|
|
results.add(new AnalysisGovernedTargetsResult(rc.getCategoryKey(), rc.getCategoryName(), rc.getCoverageType(), |
|
|
|
rc.getPlaceType(), CoveragePlaceTypeEnum.getEnum(rc.getPlaceType()).getName(), rc.getQuantity(), new ArrayList<>())); |
|
|
|
rc.getPlaceType(), CoveragePlaceTypeEnum.getEnum(rc.getPlaceType()).getName(), 0, new ArrayList<>())); |
|
|
|
} |
|
|
|
} else { |
|
|
|
// 有子级,需要使用placeTypeInAnalysis分组
|
|
|
@ -921,12 +988,9 @@ public class CoverageServiceImpl implements CoverageService { |
|
|
|
if (CollectionUtils.isEmpty(targets)) { |
|
|
|
targets = new ArrayList<>(); |
|
|
|
placeTypeTargetMap.put(placeTypeInAnalysis, targets); |
|
|
|
placeTypeQuantityMap.put(placeTypeInAnalysis, 0); |
|
|
|
} |
|
|
|
targets.add(new AnalysisGovernedTargetsResult(rc.getCategoryKey(), rc.getCategoryName(), rc.getCoverageType(), |
|
|
|
rc.getPlaceType(), CoveragePlaceTypeEnum.getEnum(rc.getPlaceType()).getName(), rc.getQuantity(), new ArrayList<>())); |
|
|
|
|
|
|
|
placeTypeQuantityMap.put(placeTypeInAnalysis, placeTypeQuantityMap.get(placeTypeInAnalysis) + rc.getQuantity()); |
|
|
|
rc.getPlaceType(), CoveragePlaceTypeEnum.getEnum(rc.getPlaceType()).getName(), 0, new ArrayList<>())); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
@ -936,16 +1000,84 @@ public class CoverageServiceImpl implements CoverageService { |
|
|
|
placeTypeTargetMap.forEach((placeTypeInAnalysis, targetObjects) -> { |
|
|
|
AnalysisGovernedTargetsResult tr = new AnalysisGovernedTargetsResult(); |
|
|
|
tr.setPlaceType(placeTypeInAnalysis); |
|
|
|
tr.setQuantity(placeTypeQuantityMap.get(placeTypeInAnalysis)); |
|
|
|
tr.setPlaceTypeName(CoveragePlaceTypeEnum.getEnum(placeTypeInAnalysis).getName()); |
|
|
|
tr.setChildren(targetObjects); |
|
|
|
results.add(tr); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
String customerId = EpmetRequestHolder.getLoginUserCustomerId(); |
|
|
|
String staffId = EpmetRequestHolder.getLoginUserId(); |
|
|
|
|
|
|
|
Map<String,String> agencyMap=getStaffPidsFromStaffInfo(customerId,staffId,agencyId,OrgConstant.AGENCY); |
|
|
|
String agencyPath = agencyMap.get(OrgConstant.AGENC_PATH); |
|
|
|
|
|
|
|
// 再最后,多线程setQuantity
|
|
|
|
fillQuantities4GovernedTarges(results, customerId, agencyId, agencyPath); |
|
|
|
|
|
|
|
return results; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 填充数量,接收参数为多个placeType(对应左侧菜单的所有一级) |
|
|
|
* @param results |
|
|
|
*/ |
|
|
|
private void fillQuantities4GovernedTarges(List<AnalysisGovernedTargetsResult> results, String customerId, String agencyId, String staffOrgIds) { |
|
|
|
|
|
|
|
ArrayList<CompletableFuture<Void>> futures = new ArrayList<>(); |
|
|
|
|
|
|
|
results.stream().forEach(targetsOfOnePlaceType -> { |
|
|
|
CompletableFuture<Void> future = CompletableFuture.runAsync(() -> { |
|
|
|
fillQuantities4GovernedTarges(targetsOfOnePlaceType, customerId, agencyId, staffOrgIds); |
|
|
|
}, executorService); |
|
|
|
|
|
|
|
futures.add(future); |
|
|
|
}); |
|
|
|
|
|
|
|
// 此处是为了等待计算完成
|
|
|
|
futures.forEach(future -> { |
|
|
|
try { |
|
|
|
future.get(); |
|
|
|
} catch (InterruptedException e) { |
|
|
|
log.error("【五大图层】可视化-左侧异步计算数量quantity失败,计算被中止,错误信息:{}", ExceptionUtils.getErrorStackTrace(e)); |
|
|
|
} catch (ExecutionException e) { |
|
|
|
log.error("【五大图层】可视化-左侧异步计算数量quantity失败,错误信息:{}", ExceptionUtils.getErrorStackTrace(e)); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 填充数量,接收参数为左侧单个placeType |
|
|
|
* @param targetsOfOnePlaceType |
|
|
|
* @param customerId |
|
|
|
* @param agencyId |
|
|
|
* @param staffOrgIds |
|
|
|
*/ |
|
|
|
private void fillQuantities4GovernedTarges(AnalysisGovernedTargetsResult targetsOfOnePlaceType, String customerId, String agencyId, String staffOrgIds) { |
|
|
|
List<AnalysisGovernedTargetsResult> children = targetsOfOnePlaceType.getChildren(); |
|
|
|
if (CollectionUtils.isEmpty(children)) { |
|
|
|
// 城市管理时间 || 安全生产隐患等只有一层的
|
|
|
|
Integer quantity = doDataListCount(customerId, agencyId, staffOrgIds, targetsOfOnePlaceType.getPlaceType(), |
|
|
|
targetsOfOnePlaceType.getCategoryKey(), null, null); |
|
|
|
targetsOfOnePlaceType.setQuantity(quantity); |
|
|
|
} else { |
|
|
|
// 综合治理人群 || 公共服务人群等有子级的
|
|
|
|
|
|
|
|
AtomicInteger totalOfPlaceType = new AtomicInteger(); |
|
|
|
children.forEach(governedTarget -> { |
|
|
|
Integer quantity = doDataListCount(customerId, agencyId, staffOrgIds, governedTarget.getPlaceType(), |
|
|
|
governedTarget.getCategoryKey(), null, null); |
|
|
|
governedTarget.setQuantity(quantity); |
|
|
|
totalOfPlaceType.addAndGet(quantity); |
|
|
|
}); |
|
|
|
|
|
|
|
// 设置这一组的总数
|
|
|
|
targetsOfOnePlaceType.setQuantity(totalOfPlaceType.get()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 五大图层,左侧菜单,点击事件,查询人.事的分布 |
|
|
|
* |
|
|
|