|
|
|
@ -2,8 +2,10 @@ 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.PartyBaseInfoFormDTO; |
|
|
|
import com.epmet.dto.extract.form.ScreenExtractFormDTO; |
|
|
|
import com.epmet.dto.extract.form.ScreenPartyBranchDataFormDTO; |
|
|
|
import com.epmet.dto.extract.form.ScreenPartyLinkMassesDataFormDTO; |
|
|
|
import com.epmet.dto.extract.result.*; |
|
|
|
import com.epmet.service.evaluationindex.extract.todata.FactOriginGroupMainDailyService; |
|
|
|
@ -12,6 +14,9 @@ import com.epmet.service.evaluationindex.screen.ScreenCustomerAgencyService; |
|
|
|
import com.epmet.service.evaluationindex.screen.ScreenCustomerGridService; |
|
|
|
import com.epmet.service.evaluationindex.screen.ScreenPartyBranchDataService; |
|
|
|
import com.epmet.service.evaluationindex.screen.ScreenPartyLinkMassesDataService; |
|
|
|
import com.epmet.service.heart.ActInfoService; |
|
|
|
import com.epmet.service.heart.ActUserRelationService; |
|
|
|
import com.epmet.service.stats.DimCustomerService; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.apache.commons.collections4.ListUtils; |
|
|
|
import org.springframework.beans.BeanUtils; |
|
|
|
@ -19,7 +24,9 @@ import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
import org.springframework.util.CollectionUtils; |
|
|
|
import org.springframework.util.StringUtils; |
|
|
|
|
|
|
|
import java.time.LocalDate; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
@ -43,16 +50,52 @@ public class PartyGuideServiceImpl implements PartyGuideService { |
|
|
|
private ScreenCustomerAgencyService agencyService; |
|
|
|
@Autowired |
|
|
|
private ScreenCustomerGridService gridService; |
|
|
|
@Autowired |
|
|
|
private ActInfoService actInfoService; |
|
|
|
@Autowired |
|
|
|
private DimCustomerService dimCustomerService; |
|
|
|
@Autowired |
|
|
|
private ActUserRelationService actUserRelationService; |
|
|
|
|
|
|
|
/** |
|
|
|
* @Description 党建引领抽取 |
|
|
|
* @param customerId |
|
|
|
* @param monthId |
|
|
|
* @param screenExtractFormDTO |
|
|
|
* @author zxc |
|
|
|
* @date 2020/9/24 5:10 下午 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public Boolean partyGuideExtract(String customerId, String monthId) { |
|
|
|
public Boolean partyGuideExtract(ScreenExtractFormDTO screenExtractFormDTO) { |
|
|
|
int pageNo = NumConstant.ONE; |
|
|
|
int pageSize = NumConstant.ONE_HUNDRED; |
|
|
|
List<String> customerIds = new ArrayList<>(); |
|
|
|
String customerId = screenExtractFormDTO.getCustomerId(); |
|
|
|
if (!StringUtils.isEmpty(customerId)){ |
|
|
|
customerIds.add(customerId); |
|
|
|
}else { |
|
|
|
customerIds = dimCustomerService.selectCustomerIdPage(pageNo, pageSize); |
|
|
|
} |
|
|
|
String monthId = screenExtractFormDTO.getMonthId(); |
|
|
|
if (StringUtils.isEmpty(monthId)){ |
|
|
|
monthId = LocalDate.now().toString().replace("-","").substring(NumConstant.ZERO,NumConstant.SIX); |
|
|
|
} |
|
|
|
if (!CollectionUtils.isEmpty(customerIds)){ |
|
|
|
String finalMonthId = monthId; |
|
|
|
customerIds.forEach(oneCustomerId -> { |
|
|
|
partyGuideExtractParty(oneCustomerId, finalMonthId); |
|
|
|
partyGuideExtractOrganize(oneCustomerId,finalMonthId); |
|
|
|
}); |
|
|
|
} |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @Description 【党员建群数,群成员数】 |
|
|
|
* @Param customerId |
|
|
|
* @Param monthId |
|
|
|
* @author zxc |
|
|
|
* @date 2020/9/25 4:26 下午 |
|
|
|
*/ |
|
|
|
public void partyGuideExtractParty(String customerId, String monthId){ |
|
|
|
//【党员建群数,群成员数】
|
|
|
|
List<CustomerAgencyInfoResultDTO> agencyIdList = agencyService.selectAllAgencyId(customerId); |
|
|
|
if (!CollectionUtils.isEmpty(agencyIdList)){ |
|
|
|
@ -61,34 +104,74 @@ public class PartyGuideServiceImpl implements PartyGuideService { |
|
|
|
if (groupByLevel.containsKey(ScreenConstant.COMMUNITY)){ |
|
|
|
// 社区级别
|
|
|
|
List<CustomerAgencyInfoResultDTO> customerGridInfoList = groupByLevel.get(ScreenConstant.COMMUNITY); |
|
|
|
disPose(customerGridInfoList,true,customerId,monthId); |
|
|
|
disPoseParty(customerGridInfoList,true,customerId,monthId); |
|
|
|
} |
|
|
|
if (groupByLevel.containsKey(ScreenConstant.STREET)){ |
|
|
|
// 街道级别
|
|
|
|
List<CustomerAgencyInfoResultDTO> customerGridInfoList = groupByLevel.get(ScreenConstant.STREET); |
|
|
|
disPose(customerGridInfoList,false,customerId,monthId); |
|
|
|
disPoseParty(customerGridInfoList,false,customerId,monthId); |
|
|
|
} |
|
|
|
if (groupByLevel.containsKey(ScreenConstant.DISTRICT)){ |
|
|
|
// 区级
|
|
|
|
List<CustomerAgencyInfoResultDTO> customerGridInfoList = groupByLevel.get(ScreenConstant.DISTRICT); |
|
|
|
disPose(customerGridInfoList,false,customerId,monthId); |
|
|
|
disPoseParty(customerGridInfoList,false,customerId,monthId); |
|
|
|
} |
|
|
|
if (groupByLevel.containsKey(ScreenConstant.CITY)){ |
|
|
|
// 市级
|
|
|
|
List<CustomerAgencyInfoResultDTO> customerGridInfoList = groupByLevel.get(ScreenConstant.CITY); |
|
|
|
disPose(customerGridInfoList,false,customerId,monthId); |
|
|
|
disPoseParty(customerGridInfoList,false,customerId,monthId); |
|
|
|
} |
|
|
|
if (groupByLevel.containsKey(ScreenConstant.PROVINCE)){ |
|
|
|
// 省级
|
|
|
|
List<CustomerAgencyInfoResultDTO> customerGridInfoList = groupByLevel.get(ScreenConstant.PROVINCE); |
|
|
|
disPose(customerGridInfoList,false,customerId,monthId); |
|
|
|
disPoseParty(customerGridInfoList,false,customerId,monthId); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @Description 【参与人数,组织次数】 |
|
|
|
* @Param customerId |
|
|
|
* @Param monthId |
|
|
|
* @author zxc |
|
|
|
* @date 2020/9/25 4:26 下午 |
|
|
|
*/ |
|
|
|
public void partyGuideExtractOrganize(String customerId, String monthId){ |
|
|
|
//【参与人数,组织次数】
|
|
|
|
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); |
|
|
|
disPoseOrganize(customerGridInfoList,true,customerId,monthId); |
|
|
|
} |
|
|
|
if (groupByLevel.containsKey(ScreenConstant.STREET)){ |
|
|
|
// 街道级别
|
|
|
|
List<CustomerAgencyInfoResultDTO> customerGridInfoList = groupByLevel.get(ScreenConstant.STREET); |
|
|
|
disPoseOrganize(customerGridInfoList,false,customerId,monthId); |
|
|
|
} |
|
|
|
if (groupByLevel.containsKey(ScreenConstant.DISTRICT)){ |
|
|
|
// 区级
|
|
|
|
List<CustomerAgencyInfoResultDTO> customerGridInfoList = groupByLevel.get(ScreenConstant.DISTRICT); |
|
|
|
disPoseOrganize(customerGridInfoList,false,customerId,monthId); |
|
|
|
} |
|
|
|
if (groupByLevel.containsKey(ScreenConstant.CITY)){ |
|
|
|
// 市级
|
|
|
|
List<CustomerAgencyInfoResultDTO> customerGridInfoList = groupByLevel.get(ScreenConstant.CITY); |
|
|
|
disPoseOrganize(customerGridInfoList,false,customerId,monthId); |
|
|
|
} |
|
|
|
if (groupByLevel.containsKey(ScreenConstant.PROVINCE)){ |
|
|
|
// 省级
|
|
|
|
List<CustomerAgencyInfoResultDTO> customerGridInfoList = groupByLevel.get(ScreenConstant.PROVINCE); |
|
|
|
disPoseOrganize(customerGridInfoList,false,customerId,monthId); |
|
|
|
} |
|
|
|
} |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @Description 处理 |
|
|
|
* @Description 处理【党员建群数,群成员数】 |
|
|
|
* @Param agencyIdList |
|
|
|
* @Param isGrid |
|
|
|
* @Param customerId |
|
|
|
@ -96,7 +179,7 @@ public class PartyGuideServiceImpl implements PartyGuideService { |
|
|
|
* @author zxc |
|
|
|
* @date 2020/9/25 2:57 下午 |
|
|
|
*/ |
|
|
|
public void disPose(List<CustomerAgencyInfoResultDTO> agencyIdList, Boolean isGrid, String customerId, String monthId) { |
|
|
|
public void disPoseParty(List<CustomerAgencyInfoResultDTO> agencyIdList, Boolean isGrid, String customerId, String monthId) { |
|
|
|
List<ScreenPartyLinkMassesDataFormDTO> result = new ArrayList<>(); |
|
|
|
if (!CollectionUtils.isEmpty(agencyIdList)){ |
|
|
|
List<String> orgIds = agencyIdList.stream().map(m -> m.getAgencyId()).collect(Collectors.toList()); |
|
|
|
@ -109,7 +192,7 @@ public class PartyGuideServiceImpl implements PartyGuideService { |
|
|
|
Map<String, List<ScreenPartyLinkMassesDataFormDTO>> groupByAgency = result.stream().collect(Collectors.groupingBy(ScreenPartyLinkMassesDataFormDTO::getParentId)); |
|
|
|
groupByAgency.forEach((agencyId,gridList) -> { |
|
|
|
ScreenPartyLinkMassesDataFormDTO form = new ScreenPartyLinkMassesDataFormDTO(); |
|
|
|
List<OrgNameResultDTO> orgNameAgencyList = agencyService.selectOrgNameAgency(result.stream().map(m -> m.getParentId()).distinct().collect(Collectors.toList())); |
|
|
|
List<OrgNameResultDTO> orgNameAgencyList = agencyService.selectOrgNameAgency(orgIds); |
|
|
|
if (!CollectionUtils.isEmpty(orgNameAgencyList)){ |
|
|
|
orgNameAgencyList.forEach(name -> { |
|
|
|
if (agencyId.equals(name.getAgencyId())){ |
|
|
|
@ -177,6 +260,115 @@ public class PartyGuideServiceImpl implements PartyGuideService { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @Description 处理【参与人数,组织次数】 |
|
|
|
* @Param agencyIdList |
|
|
|
* @Param isGrid |
|
|
|
* @Param customerId |
|
|
|
* @Param monthId |
|
|
|
* @author zxc |
|
|
|
* @date 2020/9/25 4:28 下午 |
|
|
|
*/ |
|
|
|
public void disPoseOrganize(List<CustomerAgencyInfoResultDTO> agencyIdList, Boolean isGrid, String customerId, String monthId){ |
|
|
|
if (!CollectionUtils.isEmpty(agencyIdList)){ |
|
|
|
List<ScreenPartyBranchDataFormDTO> result = new ArrayList<>(); |
|
|
|
List<String> orgIds = agencyIdList.stream().map(m -> m.getAgencyId()).collect(Collectors.toList()); |
|
|
|
if (isGrid == true){ |
|
|
|
List<JoinUserCountResultDTO> joinUserCountList = actUserRelationService.selectJoinUserCount(customerId, monthId); |
|
|
|
agencyIdList.forEach(agency -> { |
|
|
|
String agencyId = agency.getAgencyId(); |
|
|
|
Map<String, Object> agencyMap = agencyService.selectAllSubAgencyId(agencyId, customerId); |
|
|
|
List<String> gridIds = (List<String>) agencyMap.get(agencyId); |
|
|
|
orgIds.addAll(gridIds); |
|
|
|
List<ScreenPartyBranchDataFormDTO> screenPartyBranchDataList = actInfoService.selectActInfo(customerId, monthId, ScreenConstant.GRID, gridIds); |
|
|
|
if (!CollectionUtils.isEmpty(screenPartyBranchDataList)){ |
|
|
|
screenPartyBranchDataList.forEach(party -> { |
|
|
|
joinUserCountList.forEach(join -> { |
|
|
|
if (party.getOrgId().equals(join.getOrgId())){ |
|
|
|
party.setAverageJoinUserCount(join.getJoinUserCount()); |
|
|
|
party.setAverageJoinUserCount(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); |
|
|
|
groupByAgency.forEach((agencyId,actList) -> { |
|
|
|
ScreenPartyBranchDataFormDTO form = new ScreenPartyBranchDataFormDTO(); |
|
|
|
if (!CollectionUtils.isEmpty(orgNameAgencyList)){ |
|
|
|
orgNameAgencyList.forEach(name -> { |
|
|
|
if (agencyId.equals(name.getAgencyId())){ |
|
|
|
form.setOrgName(name.getAgencyName()); |
|
|
|
form.setParentId(name.getParentId()); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
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()); |
|
|
|
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)){ |
|
|
|
List<ScreenPartyBranchDataFormDTO> gridResult = new ArrayList<>(); |
|
|
|
List<JoinUserCountResultDTO> joinUserCountList = actUserRelationService.selectJoinUserCount(customerId, monthId); |
|
|
|
List<OrgNameResultDTO> orgNameList = agencyService.selectOrgNameGrid(disGridIds); |
|
|
|
List<ScreenPartyBranchDataFormDTO> screenPartyBranchDataList = actInfoService.selectActInfo(customerId, monthId, ScreenConstant.GRID, disGridIds); |
|
|
|
if (!CollectionUtils.isEmpty(screenPartyBranchDataList)){ |
|
|
|
screenPartyBranchDataList.forEach(party -> { |
|
|
|
orgNameList.forEach(org -> { |
|
|
|
if (party.getOrgId().equals(org.getGridId())){ |
|
|
|
party.setOrgName(org.getGridName()); |
|
|
|
} |
|
|
|
}); |
|
|
|
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))); |
|
|
|
form.setAverageJoinUserCount(form.getJoinUserCount() / form.getOrganizeCount()); |
|
|
|
result.add(form); |
|
|
|
} |
|
|
|
}); |
|
|
|
delAndInsertOrganize(result,customerId,monthId,orgIds); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @Description 社区级别的处理 |
|
|
|
* @Param customerId |
|
|
|
@ -237,7 +429,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 -> { |
|
|
|
@ -245,9 +437,45 @@ public class PartyGuideServiceImpl implements PartyGuideService { |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @Description |
|
|
|
* @Param result |
|
|
|
* @Param customerId |
|
|
|
* @Param monthId |
|
|
|
* @Param orgIds |
|
|
|
* @author zxc |
|
|
|
* @date 2020/9/25 5:50 下午 |
|
|
|
*/ |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void delAndInsertOrganize(List<ScreenPartyBranchDataFormDTO> result,String customerId, String monthId, List<String> orgIds){ |
|
|
|
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); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// TODO 党员志愿服务【参与人数,组织次数】
|
|
|
|
} |
|
|
|
|