From 638481baf17965767f2574beba80f1a1c5116761 Mon Sep 17 00:00:00 2001 From: zxc <1272811460@qq.com> Date: Thu, 24 Sep 2020 09:36:48 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=9A=E5=91=98=E5=9F=BA=E6=9C=AC=E6=83=85?= =?UTF-8?q?=E5=86=B5=E6=8A=BD=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/PartyBaseInfoServiceImpl.java | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/impl/PartyBaseInfoServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/impl/PartyBaseInfoServiceImpl.java index 050b8df4ce..f3c758df72 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/impl/PartyBaseInfoServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/impl/PartyBaseInfoServiceImpl.java @@ -63,24 +63,30 @@ public class PartyBaseInfoServiceImpl implements PartyBaseInfoService { public Boolean statsPartyMemberBaseInfoToScreen(String customerId, String dateId) { List agencyIdList = agencyService.selectAllAgencyId(customerId); if (!CollectionUtils.isEmpty(agencyIdList)){ + // 根据组织级别分组 Map> groupByLevel = agencyIdList.stream().collect(Collectors.groupingBy(CustomerAgencyInfoResultDTO::getLevel)); if (groupByLevel.containsKey(ScreenConstant.COMMUNITY)){ + // 社区级别 List customerGridInfoList = groupByLevel.get(ScreenConstant.COMMUNITY); disPose(customerGridInfoList,true,customerId,dateId); } if (groupByLevel.containsKey(ScreenConstant.STREET)){ + // 街道级别 List customerGridInfoList = groupByLevel.get(ScreenConstant.STREET); disPose(customerGridInfoList,false,customerId,dateId); } if (groupByLevel.containsKey(ScreenConstant.DISTRICT)){ + // 区级 List customerGridInfoList = groupByLevel.get(ScreenConstant.DISTRICT); disPose(customerGridInfoList,false,customerId,dateId); } if (groupByLevel.containsKey(ScreenConstant.CITY)){ + // 市级 List customerGridInfoList = groupByLevel.get(ScreenConstant.CITY); disPose(customerGridInfoList,false,customerId,dateId); } if (groupByLevel.containsKey(ScreenConstant.PROVINCE)){ + // 省级 List customerGridInfoList = groupByLevel.get(ScreenConstant.PROVINCE); disPose(customerGridInfoList,false,customerId,dateId); } @@ -96,13 +102,16 @@ public class PartyBaseInfoServiceImpl implements PartyBaseInfoService { */ public void disPose(List agencyIdList, Boolean isGrid, String customerId, String dateId){ if (!CollectionUtils.isEmpty(agencyIdList)){ + // 网格ID或机关Id List orgIds = agencyIdList.stream().map(m -> m.getAgencyId()).collect(Collectors.toList()); List result = new ArrayList<>(); if (isGrid == true){ + // 是 community 级别,子级为gridId List userCountList = userGridDailyService.selectUserCount(customerId, dateId); agencyIdList.forEach(agency -> { // 1. 处理社区下的所有网格中的党员信息 String agencyId = agency.getAgencyId(); + // 获取下级所有agencyId【根据agencyMap中的level判断下级orgId是否是gridId】(此处直接作为gridId) Map agencyMap = agencyService.selectAllSubAgencyId(agencyId, customerId); List gridIds = (List) agencyMap.get(agencyId); orgIds.addAll(gridIds); @@ -140,7 +149,7 @@ public class PartyBaseInfoServiceImpl implements PartyBaseInfoService { }); } }); - // 2. 处理社区级别的党员信息 + // 2. 处理社区级别的党员信息(因为网格级别的已算出,社区级别直接累加) Map> 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 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 partyMemberInfoList, Integer startAge,Integer endAge ){ if (!CollectionUtils.isEmpty(partyMemberInfoList)){ + // 计算大于多少岁并小于多少岁的人 List 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 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 result, String customerId, String dateId, List orgIds){ + // 查询客户下所有的agency List partyBaseInfoList = agencyService.selectAllAgencyIdToParty(customerId,dateId); + // 查询客户下所有的grid List resultList = gridService.selectAllGridIdToParty(customerId, dateId); resultList.addAll(partyBaseInfoList); List finalResult = new ArrayList<>(); + // 因为是根据级别来删除,插入,所以把需要操作的orgIds单独出来 resultList.forEach(rl -> { orgIds.forEach(orgId -> { if (rl.getOrgId().equals(orgId)){