|
|
@ -3,7 +3,8 @@ 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.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 +13,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 +23,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 +49,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 +103,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); |
|
|
|
} |
|
|
|
} |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @Description 处理 |
|
|
|
* @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); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @Description 处理【党员建群数,群成员数】 |
|
|
|
* @Param agencyIdList |
|
|
|
* @Param isGrid |
|
|
|
* @Param customerId |
|
|
@ -96,7 +178,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 +191,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 +259,68 @@ 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()); |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
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.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); |
|
|
|
}); |
|
|
|
|
|
|
|
}else { |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @Description 社区级别的处理 |
|
|
|
* @Param customerId |
|
|
@ -245,9 +389,20 @@ 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); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// TODO 党员志愿服务【参与人数,组织次数】
|
|
|
|
} |
|
|
|