|
|
@ -2,6 +2,7 @@ package com.epmet.service.evaluationindex.extract.toscreen.impl; |
|
|
|
|
|
|
|
import com.epmet.commons.tools.constant.NumConstant; |
|
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
|
import com.epmet.commons.tools.utils.DateUtils; |
|
|
|
import com.epmet.constant.ScreenConstant; |
|
|
|
import com.epmet.dto.extract.form.ScreenExtractFormDTO; |
|
|
|
import com.epmet.dto.extract.form.ScreenPartyBranchDataFormDTO; |
|
|
@ -75,7 +76,7 @@ public class PartyGuideServiceImpl implements PartyGuideService { |
|
|
|
} |
|
|
|
String monthId = screenExtractFormDTO.getMonthId(); |
|
|
|
if (StringUtils.isEmpty(monthId)){ |
|
|
|
monthId = LocalDate.now().toString().replace("-","").substring(NumConstant.ZERO,NumConstant.SIX); |
|
|
|
monthId = LocalDate.now().minusMonths(NumConstant.ONE).toString().replace("-","").substring(NumConstant.ZERO,NumConstant.SIX); |
|
|
|
} |
|
|
|
if (!CollectionUtils.isEmpty(customerIds)){ |
|
|
|
String finalMonthId = monthId; |
|
|
@ -272,8 +273,10 @@ public class PartyGuideServiceImpl implements PartyGuideService { |
|
|
|
if (!CollectionUtils.isEmpty(agencyIdList)){ |
|
|
|
List<ScreenPartyBranchDataFormDTO> result = new ArrayList<>(); |
|
|
|
List<String> orgIds = agencyIdList.stream().map(m -> m.getAgencyId()).collect(Collectors.toList()); |
|
|
|
List<JoinUserCountResultDTO> joinUserCountByAgencyList = actUserRelationService.selectJoinUserCount(customerId, monthId, ScreenConstant.AGENCY); |
|
|
|
List<ScreenPartyBranchDataFormDTO> screenPartyBranchDataByAgencyList = actInfoService.selectActInfo(customerId, monthId, ScreenConstant.AGENCY, orgIds); |
|
|
|
if (isGrid == true){ |
|
|
|
List<JoinUserCountResultDTO> joinUserCountList = actUserRelationService.selectJoinUserCount(customerId, monthId); |
|
|
|
List<JoinUserCountResultDTO> joinUserCountList = actUserRelationService.selectJoinUserCount(customerId, monthId, ScreenConstant.GRID); |
|
|
|
agencyIdList.forEach(agency -> { |
|
|
|
String agencyId = agency.getAgencyId(); |
|
|
|
Map<String, Object> agencyMap = agencyService.selectAllSubAgencyId(agencyId, customerId); |
|
|
@ -285,14 +288,14 @@ public class PartyGuideServiceImpl implements PartyGuideService { |
|
|
|
joinUserCountList.forEach(join -> { |
|
|
|
if (party.getOrgId().equals(join.getOrgId())){ |
|
|
|
party.setAverageJoinUserCount(join.getJoinUserCount()); |
|
|
|
party.setAverageJoinUserCount(party.getJoinUserCount() / party.getOrganizeCount()); |
|
|
|
party.setAverageJoinUserCount(party.getOrganizeCount()==NumConstant.ZERO ? NumConstant.ZERO : party.getJoinUserCount() / party.getOrganizeCount()); |
|
|
|
party.setYearId(DateUtils.getYearId(monthId)); |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
result.addAll(screenPartyBranchDataList); |
|
|
|
}); |
|
|
|
|
|
|
|
// 社区级别的
|
|
|
|
Map<String, List<ScreenPartyBranchDataFormDTO>> groupByAgency = result.stream().collect(Collectors.groupingBy(ScreenPartyBranchDataFormDTO::getParentId)); |
|
|
|
List<OrgNameResultDTO> orgNameAgencyList = agencyService.selectOrgNameAgency(orgIds); |
|
|
@ -309,18 +312,94 @@ public class PartyGuideServiceImpl implements PartyGuideService { |
|
|
|
form.setOrgId(agencyId); |
|
|
|
form.setCustomerId(customerId); |
|
|
|
form.setOrgType(ScreenConstant.AGENCY); |
|
|
|
form.setMonthId(monthId); |
|
|
|
form.setYearId(DateUtils.getYearId(monthId)); |
|
|
|
form.setOrganizeCount(actList.stream().collect(Collectors.summingInt(ScreenPartyBranchDataFormDTO::getOrganizeCount))); |
|
|
|
form.setJoinUserCount(actList.stream().collect(Collectors.summingInt(ScreenPartyBranchDataFormDTO::getJoinUserCount))); |
|
|
|
form.setAverageJoinUserCount(form.getJoinUserCount() / form.getOrganizeCount()); |
|
|
|
screenPartyBranchDataByAgencyList.forEach(organize -> { |
|
|
|
if (organize.getOrgId().equals(agencyId)){ |
|
|
|
form.setOrganizeCount(calAdd(organize.getOrganizeCount(),actList.stream().collect(Collectors.summingInt(ScreenPartyBranchDataFormDTO::getOrganizeCount)))); |
|
|
|
} |
|
|
|
}); |
|
|
|
joinUserCountByAgencyList.forEach(join -> { |
|
|
|
if (join.getOrgId().equals(agencyId)){ |
|
|
|
form.setJoinUserCount(calAdd(join.getJoinUserCount(),actList.stream().collect(Collectors.summingInt(ScreenPartyBranchDataFormDTO::getJoinUserCount)))); |
|
|
|
} |
|
|
|
}); |
|
|
|
form.setAverageJoinUserCount(form.getOrganizeCount()==NumConstant.ZERO?NumConstant.ZERO : (form.getJoinUserCount() / form.getOrganizeCount())); |
|
|
|
result.add(form); |
|
|
|
}); |
|
|
|
|
|
|
|
delAndInsertOrganize(result,customerId,monthId,orgIds); |
|
|
|
}else { |
|
|
|
|
|
|
|
List<GridInfoResultDTO> directGridIds = gridService.selectDirectGrid(orgIds); |
|
|
|
agencyIdList.forEach(agency -> { |
|
|
|
String agencyId = agency.getAgencyId(); |
|
|
|
List<String> disGridIds = new ArrayList<>(); |
|
|
|
directGridIds.forEach(grid -> { |
|
|
|
if (agencyId.equals(grid.getAgencyId())){ |
|
|
|
disGridIds.add(grid.getGridId()); |
|
|
|
} |
|
|
|
}); |
|
|
|
// 存在直属网格
|
|
|
|
if (!CollectionUtils.isEmpty(disGridIds)){ |
|
|
|
orgIds.addAll(disGridIds); |
|
|
|
List<ScreenPartyBranchDataFormDTO> gridResult = new ArrayList<>(); |
|
|
|
List<JoinUserCountResultDTO> joinUserCountList = actUserRelationService.selectJoinUserCount(customerId, monthId, ScreenConstant.GRID); |
|
|
|
List<ScreenPartyBranchDataFormDTO> screenPartyBranchDataList = actInfoService.selectActInfo(customerId, monthId, ScreenConstant.GRID, disGridIds); |
|
|
|
if (!CollectionUtils.isEmpty(screenPartyBranchDataList)){ |
|
|
|
screenPartyBranchDataList.forEach(party -> { |
|
|
|
joinUserCountList.forEach(join -> { |
|
|
|
if (party.getOrgId().equals(join.getOrgId())){ |
|
|
|
party.setAverageJoinUserCount(join.getJoinUserCount()); |
|
|
|
party.setAverageJoinUserCount(party.getOrganizeCount()==NumConstant.ZERO ? NumConstant.ZERO : party.getJoinUserCount() / party.getOrganizeCount()); |
|
|
|
party.setYearId(DateUtils.getYearId(monthId)); |
|
|
|
} |
|
|
|
}); |
|
|
|
ScreenPartyBranchDataFormDTO copyParty = ConvertUtils.sourceToTarget(party, ScreenPartyBranchDataFormDTO.class); |
|
|
|
gridResult.add(copyParty); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
List<ScreenPartyBranchDataFormDTO> disPartyBranchDataList = partyBranchDataService.selectScreenPartyBranchDataByOrgId(customerId, monthId, disGridIds); |
|
|
|
List<ScreenPartyBranchDataFormDTO> screenPartyBranchDataList = partyBranchDataService.selectScreenPartyBranchDataByParentId(customerId, monthId, agencyId); |
|
|
|
screenPartyBranchDataList.addAll(disPartyBranchDataList); |
|
|
|
if (!CollectionUtils.isEmpty(screenPartyBranchDataList)){ |
|
|
|
ScreenPartyBranchDataFormDTO form = new ScreenPartyBranchDataFormDTO(); |
|
|
|
form.setOrgId(agencyId); |
|
|
|
form.setOrgType(ScreenConstant.AGENCY); |
|
|
|
form.setOrgName(screenPartyBranchDataList.get(NumConstant.ZERO).getOrgName()); |
|
|
|
form.setCustomerId(customerId); |
|
|
|
form.setMonthId(monthId); |
|
|
|
form.setYearId(DateUtils.getYearId(monthId)); |
|
|
|
form.setParentId(screenPartyBranchDataList.get(NumConstant.ZERO).getParentId()); |
|
|
|
form.setJoinUserCount(screenPartyBranchDataList.stream().collect(Collectors.summingInt(ScreenPartyBranchDataFormDTO::getJoinUserCount))); |
|
|
|
form.setOrganizeCount(screenPartyBranchDataList.stream().collect(Collectors.summingInt(ScreenPartyBranchDataFormDTO::getOrganizeCount))); |
|
|
|
screenPartyBranchDataByAgencyList.forEach(organize -> { |
|
|
|
if (organize.getOrgId().equals(agencyId)){ |
|
|
|
form.setOrganizeCount(calAdd(organize.getOrganizeCount(),screenPartyBranchDataList.stream().collect(Collectors.summingInt(ScreenPartyBranchDataFormDTO::getOrganizeCount)))); |
|
|
|
} |
|
|
|
}); |
|
|
|
joinUserCountByAgencyList.forEach(join -> { |
|
|
|
if (join.getOrgId().equals(agencyId)){ |
|
|
|
form.setJoinUserCount(calAdd(join.getJoinUserCount(),screenPartyBranchDataList.stream().collect(Collectors.summingInt(ScreenPartyBranchDataFormDTO::getJoinUserCount)))); |
|
|
|
} |
|
|
|
}); |
|
|
|
form.setAverageJoinUserCount(form.getOrganizeCount()==NumConstant.ZERO?NumConstant.ZERO : (form.getJoinUserCount() / form.getOrganizeCount())); |
|
|
|
result.add(form); |
|
|
|
} |
|
|
|
}); |
|
|
|
delAndInsertOrganize(result,customerId,monthId,orgIds); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public Integer calAdd(Integer a, Integer b){ |
|
|
|
if (null != a && null != b){ |
|
|
|
return a + b; |
|
|
|
} |
|
|
|
return NumConstant.ZERO; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @Description 社区级别的处理 |
|
|
|
* @Param customerId |
|
|
@ -381,7 +460,7 @@ public class PartyGuideServiceImpl implements PartyGuideService { |
|
|
|
} |
|
|
|
Integer delNum; |
|
|
|
do { |
|
|
|
delNum = linkMassesDataService.deleteOldPartyLinkInfo(customerId, monthId, orgIds); |
|
|
|
delNum = linkMassesDataService.deleteOldPartyLinkInfo(customerId, orgIds); |
|
|
|
}while (delNum > NumConstant.ZERO); |
|
|
|
List<List<ScreenPartyLinkMassesDataFormDTO>> partition = ListUtils.partition(finalResult, NumConstant.ONE_HUNDRED); |
|
|
|
partition.forEach(p -> { |
|
|
@ -403,6 +482,31 @@ public class PartyGuideServiceImpl implements PartyGuideService { |
|
|
|
List<ScreenPartyBranchDataFormDTO> screenPartyBranchData = agencyService.selectAllAgencyIdToOrganize(customerId, monthId); |
|
|
|
List<ScreenPartyBranchDataFormDTO> screenPartyBranchDataList = gridService.selectAllGridIdToOrganize(customerId, monthId); |
|
|
|
screenPartyBranchDataList.addAll(screenPartyBranchData); |
|
|
|
List<ScreenPartyBranchDataFormDTO> finalResult = new ArrayList<>(); |
|
|
|
screenPartyBranchDataList.forEach(rl -> { |
|
|
|
orgIds.forEach(orgId -> { |
|
|
|
if (rl.getOrgId().equals(orgId)){ |
|
|
|
finalResult.add(rl); |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
if (!CollectionUtils.isEmpty(result)){ |
|
|
|
finalResult.forEach(fr -> { |
|
|
|
result.forEach(r -> { |
|
|
|
if (fr.getOrgId().equals(r.getOrgId())){ |
|
|
|
BeanUtils.copyProperties(r,fr); |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
Integer delNum; |
|
|
|
do { |
|
|
|
delNum = partyBranchDataService.deleteOldScreenPartyBranchData(customerId, monthId, orgIds); |
|
|
|
}while (delNum > NumConstant.ZERO); |
|
|
|
List<List<ScreenPartyBranchDataFormDTO>> partition = ListUtils.partition(finalResult, NumConstant.ONE_HUNDRED); |
|
|
|
partition.forEach(p -> { |
|
|
|
partyBranchDataService.insertScreenPartyBranchData(p); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|