|
|
@ -63,24 +63,30 @@ public class PartyBaseInfoServiceImpl implements PartyBaseInfoService { |
|
|
|
public Boolean statsPartyMemberBaseInfoToScreen(String customerId, String dateId) { |
|
|
|
List<CustomerAgencyInfoResultDTO> agencyIdList = agencyService.selectAllAgencyId(customerId); |
|
|
|
if (!CollectionUtils.isEmpty(agencyIdList)){ |
|
|
|
// 根据组织级别分组
|
|
|
|
Map<String, List<CustomerAgencyInfoResultDTO>> groupByLevel = agencyIdList.stream().collect(Collectors.groupingBy(CustomerAgencyInfoResultDTO::getLevel)); |
|
|
|
if (groupByLevel.containsKey(ScreenConstant.COMMUNITY)){ |
|
|
|
// 社区级别
|
|
|
|
List<CustomerAgencyInfoResultDTO> customerGridInfoList = groupByLevel.get(ScreenConstant.COMMUNITY); |
|
|
|
disPose(customerGridInfoList,true,customerId,dateId); |
|
|
|
} |
|
|
|
if (groupByLevel.containsKey(ScreenConstant.STREET)){ |
|
|
|
// 街道级别
|
|
|
|
List<CustomerAgencyInfoResultDTO> customerGridInfoList = groupByLevel.get(ScreenConstant.STREET); |
|
|
|
disPose(customerGridInfoList,false,customerId,dateId); |
|
|
|
} |
|
|
|
if (groupByLevel.containsKey(ScreenConstant.DISTRICT)){ |
|
|
|
// 区级
|
|
|
|
List<CustomerAgencyInfoResultDTO> customerGridInfoList = groupByLevel.get(ScreenConstant.DISTRICT); |
|
|
|
disPose(customerGridInfoList,false,customerId,dateId); |
|
|
|
} |
|
|
|
if (groupByLevel.containsKey(ScreenConstant.CITY)){ |
|
|
|
// 市级
|
|
|
|
List<CustomerAgencyInfoResultDTO> customerGridInfoList = groupByLevel.get(ScreenConstant.CITY); |
|
|
|
disPose(customerGridInfoList,false,customerId,dateId); |
|
|
|
} |
|
|
|
if (groupByLevel.containsKey(ScreenConstant.PROVINCE)){ |
|
|
|
// 省级
|
|
|
|
List<CustomerAgencyInfoResultDTO> customerGridInfoList = groupByLevel.get(ScreenConstant.PROVINCE); |
|
|
|
disPose(customerGridInfoList,false,customerId,dateId); |
|
|
|
} |
|
|
@ -96,13 +102,16 @@ public class PartyBaseInfoServiceImpl implements PartyBaseInfoService { |
|
|
|
*/ |
|
|
|
public void disPose(List<CustomerAgencyInfoResultDTO> agencyIdList, Boolean isGrid, String customerId, String dateId){ |
|
|
|
if (!CollectionUtils.isEmpty(agencyIdList)){ |
|
|
|
// 网格ID或机关Id
|
|
|
|
List<String> orgIds = agencyIdList.stream().map(m -> m.getAgencyId()).collect(Collectors.toList()); |
|
|
|
List<PartyBaseInfoFormDTO> result = new ArrayList<>(); |
|
|
|
if (isGrid == true){ |
|
|
|
// 是 community 级别,子级为gridId
|
|
|
|
List<UserCountResultDTO> userCountList = userGridDailyService.selectUserCount(customerId, dateId); |
|
|
|
agencyIdList.forEach(agency -> { |
|
|
|
// 1. 处理社区下的所有网格中的党员信息
|
|
|
|
String agencyId = agency.getAgencyId(); |
|
|
|
// 获取下级所有agencyId【根据agencyMap中的level判断下级orgId是否是gridId】(此处直接作为gridId)
|
|
|
|
Map<String, Object> agencyMap = agencyService.selectAllSubAgencyId(agencyId, customerId); |
|
|
|
List<String> gridIds = (List<String>) agencyMap.get(agencyId); |
|
|
|
orgIds.addAll(gridIds); |
|
|
@ -140,7 +149,7 @@ public class PartyBaseInfoServiceImpl implements PartyBaseInfoService { |
|
|
|
}); |
|
|
|
} |
|
|
|
}); |
|
|
|
// 2. 处理社区级别的党员信息
|
|
|
|
// 2. 处理社区级别的党员信息(因为网格级别的已算出,社区级别直接累加)
|
|
|
|
Map<String, List<PartyBaseInfoFormDTO>> groupByAgency = result.stream().collect(Collectors.groupingBy(PartyBaseInfoFormDTO::getParentId)); |
|
|
|
groupByAgency.forEach((commAgencyId,party) -> { |
|
|
|
PartyBaseInfoFormDTO form = new PartyBaseInfoFormDTO(); |
|
|
@ -163,8 +172,10 @@ public class PartyBaseInfoServiceImpl implements PartyBaseInfoService { |
|
|
|
}); |
|
|
|
delAndInsert(result,customerId,dateId,orgIds); |
|
|
|
}else { |
|
|
|
// 级别为 street,district,city,province
|
|
|
|
agencyIdList.forEach(agency -> { |
|
|
|
String agencyId = agency.getAgencyId(); |
|
|
|
// 查询下级机关的党员信息,直接累加
|
|
|
|
List<PartyInfoResultDTO> partyInfoList = cpcBaseDataService.selectPartyInfo(customerId, dateId, agencyId); |
|
|
|
if (!CollectionUtils.isEmpty(partyInfoList)){ |
|
|
|
PartyBaseInfoFormDTO form = new PartyBaseInfoFormDTO(); |
|
|
@ -207,6 +218,7 @@ public class PartyBaseInfoServiceImpl implements PartyBaseInfoService { |
|
|
|
int birthDayMonth = birth.getMonthValue(); |
|
|
|
int birthDayOfMonth = birth.getDayOfMonth(); |
|
|
|
int age = nowYear - birthDayYear; |
|
|
|
// 当前月小于出生年的月份 或者 当前月等于出生年的月 并且 当前日小于出生年的日,就是不满一岁
|
|
|
|
if (nowMonth < birthDayMonth || (nowMonth == birthDayMonth && nowDayOfMonth < birthDayOfMonth)) { |
|
|
|
age--; |
|
|
|
} |
|
|
@ -223,6 +235,7 @@ public class PartyBaseInfoServiceImpl implements PartyBaseInfoService { |
|
|
|
*/ |
|
|
|
public Integer disposeAgeArea(List<PartyMemberInfoResultDTO> partyMemberInfoList, Integer startAge,Integer endAge ){ |
|
|
|
if (!CollectionUtils.isEmpty(partyMemberInfoList)){ |
|
|
|
// 计算大于多少岁并小于多少岁的人
|
|
|
|
List<PartyMemberInfoResultDTO> collect = partyMemberInfoList.stream().filter(p -> p.getAge() >= startAge).filter(p -> p.getAge() <= endAge).collect(Collectors.toList()); |
|
|
|
return collect.size(); |
|
|
|
} |
|
|
@ -241,8 +254,10 @@ public class PartyBaseInfoServiceImpl implements PartyBaseInfoService { |
|
|
|
if (!CollectionUtils.isEmpty(partyMemberInfoList)){ |
|
|
|
List<PartyMemberInfoResultDTO> collect = new ArrayList<>(); |
|
|
|
if (isGreater == true){ |
|
|
|
// 大于
|
|
|
|
collect = partyMemberInfoList.stream().filter(p -> p.getAge() > age).collect(Collectors.toList()); |
|
|
|
}else { |
|
|
|
// 小于
|
|
|
|
collect = partyMemberInfoList.stream().filter(p -> p.getAge() < age).collect(Collectors.toList()); |
|
|
|
} |
|
|
|
return collect.size(); |
|
|
@ -260,10 +275,13 @@ public class PartyBaseInfoServiceImpl implements PartyBaseInfoService { |
|
|
|
*/ |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void delAndInsert(List<PartyBaseInfoFormDTO> result, String customerId, String dateId, List<String> orgIds){ |
|
|
|
// 查询客户下所有的agency
|
|
|
|
List<PartyBaseInfoFormDTO> partyBaseInfoList = agencyService.selectAllAgencyIdToParty(customerId,dateId); |
|
|
|
// 查询客户下所有的grid
|
|
|
|
List<PartyBaseInfoFormDTO> resultList = gridService.selectAllGridIdToParty(customerId, dateId); |
|
|
|
resultList.addAll(partyBaseInfoList); |
|
|
|
List<PartyBaseInfoFormDTO> finalResult = new ArrayList<>(); |
|
|
|
// 因为是根据级别来删除,插入,所以把需要操作的orgIds单独出来
|
|
|
|
resultList.forEach(rl -> { |
|
|
|
orgIds.forEach(orgId -> { |
|
|
|
if (rl.getOrgId().equals(orgId)){ |
|
|
|