|
|
@ -42,6 +42,8 @@ public class StatsGroupServiceImpl implements StatsGroupService { |
|
|
|
private FactGroupAgencyDailyService factGroupAgencyDailyService; |
|
|
|
@Autowired |
|
|
|
private FactGroupAgencyMonthlyService factGroupAgencyMonthlyService; |
|
|
|
@Autowired |
|
|
|
private DimCustomerService dimCustomerService; |
|
|
|
|
|
|
|
/** |
|
|
|
* @Description 统计【网格-日】 |
|
|
@ -49,11 +51,20 @@ public class StatsGroupServiceImpl implements StatsGroupService { |
|
|
|
* @author zxc |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public void groupGridDaily(String customerId) { |
|
|
|
DimIdGenerator.DimIdBean dimIdBean = this.getDimIdBean(); |
|
|
|
List<DimGridEntity> gridsInfo = dimGridService.getGridListByCustomerId(customerId); |
|
|
|
List<GroupGridDailyResultDTO> resultDTOS = groupDataService.groupGridDaily(customerId,dimIdBean,gridsInfo); |
|
|
|
factGroupGridDailyService.statisticsGroupGridDaily(resultDTOS); |
|
|
|
public void groupGridDaily(Date date) { |
|
|
|
Integer pageNo = NumConstant.ONE; |
|
|
|
Integer pageSize = NumConstant.ONE_HUNDRED; |
|
|
|
List<String> customerIds = dimCustomerService.selectCustomerIdPage(pageNo,pageSize); |
|
|
|
if (customerIds.size() == NumConstant.ZERO){ |
|
|
|
return; |
|
|
|
} |
|
|
|
customerIds.forEach(customerId -> { |
|
|
|
DimIdGenerator.DimIdBean dimIdBean = this.getDimIdBean(date); |
|
|
|
List<DimGridEntity> gridsInfo = dimGridService.getGridListByCustomerId(customerId); |
|
|
|
List<GroupGridDailyResultDTO> resultDTOS = groupDataService.groupGridDaily(customerId,dimIdBean,gridsInfo); |
|
|
|
factGroupGridDailyService.statisticsGroupGridDaily(resultDTOS); |
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@ -61,12 +72,20 @@ public class StatsGroupServiceImpl implements StatsGroupService { |
|
|
|
* @author zxc |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public void groupAgencyDaily(String customerId) { |
|
|
|
DimIdGenerator.DimIdBean dimIdBean = this.getDimIdBean(); |
|
|
|
List<DimAgencyDTO> customerAgencyInfos = dimAgencyService.getAgencyInfoByCustomerId(customerId); |
|
|
|
List<AgencyGroupDailyResultDTO> agencyGroupDaily = this.getAgencyGroupDaily(customerAgencyInfos, dimIdBean, customerId); |
|
|
|
factGroupAgencyDailyService.insertGroupAgencyDaily(agencyGroupDaily); |
|
|
|
public void groupAgencyDaily(Date date) { |
|
|
|
Integer pageNo = NumConstant.ONE; |
|
|
|
Integer pageSize = NumConstant.ONE_HUNDRED; |
|
|
|
List<String> customerIds = dimCustomerService.selectCustomerIdPage(pageNo,pageSize); |
|
|
|
if (customerIds.size() == NumConstant.ZERO){ |
|
|
|
return; |
|
|
|
} |
|
|
|
DimIdGenerator.DimIdBean dimIdBean = this.getDimIdBean(date); |
|
|
|
customerIds.forEach(customerId -> { |
|
|
|
|
|
|
|
List<DimAgencyDTO> customerAgencyInfos = dimAgencyService.getAgencyInfoByCustomerId(customerId); |
|
|
|
List<AgencyGroupDailyResultDTO> agencyGroupDaily = this.getAgencyGroupDaily(customerAgencyInfos, dimIdBean, customerId); |
|
|
|
factGroupAgencyDailyService.insertGroupAgencyDaily(agencyGroupDaily); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@ -74,10 +93,11 @@ public class StatsGroupServiceImpl implements StatsGroupService { |
|
|
|
* @author zxc String customerId |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public void groupAgencyMonthly() { |
|
|
|
List<AgencyMonthlyFormDTO> lastDayAgency = factGroupAgencyDailyService.getLastDayAgency(); |
|
|
|
DimIdGenerator.DimIdBean dimIdBean = this.getDimIdBean(); |
|
|
|
List<AgencyGroupMonthlyResultDTO> monthGroupIncr = factGroupAgencyDailyService.getMonthGroupIncr(dimIdBean.getMonthId()); |
|
|
|
public void groupAgencyMonthly(Date date) { |
|
|
|
DimIdGenerator.DimIdBean dimIdBean = this.getDimIdBean(date); |
|
|
|
String monthId = dimIdBean.getMonthId(); |
|
|
|
List<AgencyMonthlyFormDTO> lastDayAgency = factGroupAgencyDailyService.getLastDayAgency(monthId); |
|
|
|
List<AgencyGroupMonthlyResultDTO> monthGroupIncr = factGroupAgencyDailyService.getMonthGroupIncr(monthId); |
|
|
|
if (monthGroupIncr.size() == NumConstant.ZERO){ |
|
|
|
lastDayAgency.forEach(agency -> { |
|
|
|
agency.setGroupIncr(NumConstant.ZERO); |
|
|
@ -99,6 +119,7 @@ public class StatsGroupServiceImpl implements StatsGroupService { |
|
|
|
return new ArrayList<>(); |
|
|
|
} |
|
|
|
List<AgencyGroupDailyResultDTO> result = new ArrayList<>(); |
|
|
|
String dateId = timeDim.getDateId(); |
|
|
|
List<DimAgencyEntity> agencyList = dimAgencyService.getAgencyListByCustomerId(customerId); |
|
|
|
agencyList.forEach(agency -> { |
|
|
|
AgencyGroupDailyResultDTO agencyResult = new AgencyGroupDailyResultDTO(); |
|
|
@ -113,11 +134,11 @@ public class StatsGroupServiceImpl implements StatsGroupService { |
|
|
|
agencyResult.setGridTotal(allGrid.size()); |
|
|
|
|
|
|
|
// TODO 2. 机关下有多少小组,只算 state = ‘approved’
|
|
|
|
List<AgencyGroupTotalCountResultDTO> agencyGroupTotalCount = groupDataService.getAgencyGroupTotalCount(allGrid); |
|
|
|
List<AgencyGroupTotalCountResultDTO> agencyGroupTotalCount = groupDataService.getAgencyGroupTotalCount(allGrid,dateId); |
|
|
|
Integer groupCount = agencyGroupTotalCount.stream().collect(Collectors.summingInt(AgencyGroupTotalCountResultDTO::getGridGroupCount)); |
|
|
|
agencyResult.setGroupTotalCount(groupCount); |
|
|
|
// TODO 3. 机关下所有组内人数和(不需要去重) 人员状态 != "removed"
|
|
|
|
List<AgencyGridGroupPeopleTotalResultDTO> agencyGridGroupPeopleTotal = groupDataService.selectAgencyGridGroupPeopleTotal(allGrid); |
|
|
|
List<AgencyGridGroupPeopleTotalResultDTO> agencyGridGroupPeopleTotal = groupDataService.selectAgencyGridGroupPeopleTotal(allGrid,dateId); |
|
|
|
Integer groupPeopleCount = agencyGridGroupPeopleTotal.stream().collect(Collectors.summingInt(AgencyGridGroupPeopleTotalResultDTO::getGridGroupPeopleTotal)); |
|
|
|
agencyResult.setGroupMemberTotalCount(groupPeopleCount); |
|
|
|
|
|
|
@ -127,7 +148,7 @@ public class StatsGroupServiceImpl implements StatsGroupService { |
|
|
|
agencyResult.getGroupMemberTotalCount()/agencyResult.getGroupTotalCount()); |
|
|
|
|
|
|
|
// TODO 5. 机关下小组人数中位数 小组最大(小)成员数、最多(少)成员小组ID
|
|
|
|
List<AgencyGridGroupPeopleResultDTO> agencyGridGroupPeople = groupDataService.selectAgencyEveryGroupPeopleCount(allGrid); |
|
|
|
List<AgencyGridGroupPeopleResultDTO> agencyGridGroupPeople = groupDataService.selectAgencyEveryGroupPeopleCount(allGrid,dateId); |
|
|
|
List<AgencyGridGroupPeopleResultDTO> sorted = agencyGridGroupPeople.stream().sorted(Comparator.comparing(AgencyGridGroupPeopleResultDTO::getGroupCount).reversed()).collect(Collectors.toList()); |
|
|
|
Integer groupPeopleMedian; |
|
|
|
if (sorted.size() == NumConstant.ONE){ |
|
|
@ -147,7 +168,7 @@ public class StatsGroupServiceImpl implements StatsGroupService { |
|
|
|
agencyResult.setMinMemberGroupId(sorted.get(sorted.size() - NumConstant.ONE).getGroupId()); |
|
|
|
} |
|
|
|
// TODO 6. 机关下小组增量
|
|
|
|
List<AgencyGroupIncrResultDTO> agencyGroupIncr = groupDataService.selectAgencyGroupIncr(allGrid, timeDim.getDateId()); |
|
|
|
List<AgencyGroupIncrResultDTO> agencyGroupIncr = groupDataService.selectAgencyGroupIncr(allGrid, dateId); |
|
|
|
Integer groupIncr = agencyGroupIncr.stream().collect(Collectors.summingInt(AgencyGroupIncrResultDTO::getGroupIncr)); |
|
|
|
agencyResult.setGroupIncr(groupIncr); |
|
|
|
result.add(agencyResult); |
|
|
@ -222,12 +243,15 @@ public class StatsGroupServiceImpl implements StatsGroupService { |
|
|
|
* @param |
|
|
|
* @author zxc |
|
|
|
*/ |
|
|
|
public DimIdGenerator.DimIdBean getDimIdBean(){ |
|
|
|
public DimIdGenerator.DimIdBean getDimIdBean(Date date){ |
|
|
|
if (date != null){ |
|
|
|
return DimIdGenerator.getDimIdBean(date); |
|
|
|
} |
|
|
|
ZoneId zoneId = ZoneId.systemDefault(); |
|
|
|
LocalDate localDate = LocalDate.now().minusDays(NumConstant.ONE); |
|
|
|
ZonedDateTime zdt = localDate.atStartOfDay(zoneId); |
|
|
|
Date date = Date.from(zdt.toInstant()); |
|
|
|
return DimIdGenerator.getDimIdBean(date); |
|
|
|
Date result = Date.from(zdt.toInstant()); |
|
|
|
return DimIdGenerator.getDimIdBean(result); |
|
|
|
} |
|
|
|
|
|
|
|
public List<String> getAgencyAllGrid(String customerId,String agencyId){ |
|
|
|