|
|
@ -129,6 +129,13 @@ public class StatsGroupServiceImpl implements StatsGroupService { |
|
|
|
factGroupAgencyMonthlyService.insertAgencyGroupMonthly(lastDayAgency); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @Description 网格小组 【机关-日】 数据统计处理 |
|
|
|
* @param customerAgencyInfos |
|
|
|
* @param timeDim |
|
|
|
* @param customerId |
|
|
|
* @author zxc |
|
|
|
*/ |
|
|
|
public List<AgencyGroupDailyResultDTO> getAgencyGroupDaily(List<DimAgencyDTO> customerAgencyInfos, DimIdGenerator.DimIdBean timeDim,String customerId){ |
|
|
|
if (customerAgencyInfos.size() == NumConstant.ZERO){ |
|
|
|
return new ArrayList<>(); |
|
|
@ -143,10 +150,10 @@ public class StatsGroupServiceImpl implements StatsGroupService { |
|
|
|
agencyResult.setCustomerId(customerId); |
|
|
|
BeanUtils.copyProperties(timeDim,agencyResult); |
|
|
|
//机关下的所有网格(包括直属网格)
|
|
|
|
List<String> allGrid = this.getAllGrid(agencyId); |
|
|
|
List<String> allGrid = this.getAllGrid(agencyId,customerId); |
|
|
|
String pidByAgencyId = dimAgencyService.getPidByAgencyId(agencyId); |
|
|
|
agencyResult.setPid(StringUtils.isBlank(pidByAgencyId)?"0":pidByAgencyId); |
|
|
|
// TODO 1. 机关下有多少网格
|
|
|
|
// 1. 机关下有多少网格
|
|
|
|
List<GridIdListByCustomerResultDTO> customerGridIdList = customerGridService.getCustomerGridIdList(customerId, dateId); |
|
|
|
AtomicReference<Integer> gridSize = new AtomicReference<>(0); |
|
|
|
if (customerGridIdList.size() != NumConstant.ZERO){ |
|
|
@ -161,22 +168,19 @@ public class StatsGroupServiceImpl implements StatsGroupService { |
|
|
|
}else { |
|
|
|
agencyResult.setGridTotal(NumConstant.ZERO); |
|
|
|
} |
|
|
|
|
|
|
|
// TODO 2. 机关下有多少小组,只算 state = ‘approved’
|
|
|
|
// 2. 机关下有多少小组,只算 state = ‘approved’
|
|
|
|
List<AgencyGroupTotalCountResultDTO> agencyGroupTotalCount = groupDataService.getAgencyGroupTotalCount(allGrid,dateId); |
|
|
|
Integer groupCount = agencyGroupTotalCount.stream().collect(Collectors.summingInt(AgencyGroupTotalCountResultDTO::getGridGroupCount)); |
|
|
|
agencyResult.setGroupTotalCount(groupCount); |
|
|
|
// TODO 3. 机关下所有组内人数和(不需要去重) 人员状态 != "removed"
|
|
|
|
// 3. 机关下所有组内人数和(不需要去重) 人员状态 != "removed"
|
|
|
|
List<AgencyGridGroupPeopleTotalResultDTO> agencyGridGroupPeopleTotal = groupDataService.selectAgencyGridGroupPeopleTotal(allGrid,dateId); |
|
|
|
Integer groupPeopleCount = agencyGridGroupPeopleTotal.stream().collect(Collectors.summingInt(AgencyGridGroupPeopleTotalResultDTO::getGridGroupPeopleTotal)); |
|
|
|
agencyResult.setGroupMemberTotalCount(groupPeopleCount); |
|
|
|
|
|
|
|
// TODO 4. 机关下小组平均人数
|
|
|
|
// 4. 机关下小组平均人数
|
|
|
|
agencyResult.setGroupMemberAvgCount( |
|
|
|
agencyResult.getGroupTotalCount() == NumConstant.ZERO ? NumConstant.ZERO : |
|
|
|
agencyResult.getGroupMemberTotalCount()/agencyResult.getGroupTotalCount()); |
|
|
|
|
|
|
|
// TODO 5. 机关下小组人数中位数 小组最大(小)成员数、最多(少)成员小组ID
|
|
|
|
// 5. 机关下小组人数中位数 小组最大(小)成员数、最多(少)成员小组ID
|
|
|
|
List<AgencyGridGroupPeopleResultDTO> agencyGridGroupPeople = groupDataService.selectAgencyEveryGroupPeopleCount(allGrid,dateId); |
|
|
|
List<AgencyGridGroupPeopleResultDTO> sorted = agencyGridGroupPeople.stream().sorted(Comparator.comparing(AgencyGridGroupPeopleResultDTO::getGroupCount).reversed()).collect(Collectors.toList()); |
|
|
|
Integer groupPeopleMedian; |
|
|
@ -190,13 +194,12 @@ public class StatsGroupServiceImpl implements StatsGroupService { |
|
|
|
(sorted.get(sorted.size() / NumConstant.TWO - NumConstant.ONE).getGroupCount() + sorted.get(sorted.size() / 2).getGroupCount()) / 2 : |
|
|
|
sorted.get(sorted.size() / NumConstant.TWO).getGroupCount(); |
|
|
|
agencyResult.setGroupMedian(groupPeopleMedian); |
|
|
|
|
|
|
|
agencyResult.setGroupMemberMaxCount(sorted.get(NumConstant.ZERO).getGroupCount()); |
|
|
|
agencyResult.setMaxMemberGroupId(sorted.get(NumConstant.ZERO).getGroupId()); |
|
|
|
agencyResult.setGroupMemberMinCount(sorted.get(sorted.size() - NumConstant.ONE).getGroupCount()); |
|
|
|
agencyResult.setMinMemberGroupId(sorted.get(sorted.size() - NumConstant.ONE).getGroupId()); |
|
|
|
} |
|
|
|
// TODO 6. 机关下小组增量
|
|
|
|
// 6. 机关下小组增量
|
|
|
|
List<AgencyGroupIncrResultDTO> agencyGroupIncr = groupDataService.selectAgencyGroupIncr(allGrid, dateId); |
|
|
|
Integer groupIncr = agencyGroupIncr.stream().collect(Collectors.summingInt(AgencyGroupIncrResultDTO::getGroupIncr)); |
|
|
|
agencyResult.setGroupIncr(groupIncr); |
|
|
@ -210,9 +213,9 @@ public class StatsGroupServiceImpl implements StatsGroupService { |
|
|
|
* @param agencyId |
|
|
|
* @author zxc |
|
|
|
*/ |
|
|
|
public List<String> getAllGrid(String agencyId){ |
|
|
|
public List<String> getAllGrid(String agencyId,String customerId){ |
|
|
|
List<String> result = new ArrayList<>(); |
|
|
|
List<AgencySubTreeDto> allAgency = dimAgencyService.getAllAgency(null); |
|
|
|
List<AgencySubTreeDto> allAgency = dimAgencyService.getAllAgency(customerId); |
|
|
|
|
|
|
|
Map<String,Set<String>> subGridOfAgency = new HashMap<>(); |
|
|
|
allAgency.forEach(agency -> { |
|
|
@ -237,7 +240,6 @@ public class StatsGroupServiceImpl implements StatsGroupService { |
|
|
|
* @author zxc |
|
|
|
*/ |
|
|
|
void initAgencyGridMap(String pid, AgencySubTreeDto agency, Map<String,Set<String>> subGridOfAgency){ |
|
|
|
|
|
|
|
//向map中放入数据
|
|
|
|
if(subGridOfAgency.containsKey(pid)){ |
|
|
|
//包含key
|
|
|
@ -254,13 +256,10 @@ public class StatsGroupServiceImpl implements StatsGroupService { |
|
|
|
Set<String> grids = new HashSet<>(agency.getGridIds()); |
|
|
|
subGridOfAgency.put(pid,grids); |
|
|
|
} |
|
|
|
|
|
|
|
//定义递归出口
|
|
|
|
if(StringUtils.equals(ModuleConstant.AGENCY_LEVEL_COMMUNITY,agency.getLevel()) || null == agency.getSubAgencies() || agency.getSubAgencies().size() == NumConstant.ZERO){ |
|
|
|
return ; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//定义递归入口
|
|
|
|
agency.getSubAgencies().forEach(obj -> { |
|
|
|
initAgencyGridMap(pid,obj,subGridOfAgency); |
|
|
@ -285,8 +284,4 @@ public class StatsGroupServiceImpl implements StatsGroupService { |
|
|
|
return DimIdGenerator.getDimIdBean(result); |
|
|
|
} |
|
|
|
|
|
|
|
public List<String> getAgencyAllGrid(String customerId,String agencyId){ |
|
|
|
|
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
|