|
|
@ -9,10 +9,13 @@ import com.epmet.dto.extract.result.UserCountResultDTO; |
|
|
|
import com.epmet.service.evaluationindex.extract.toscreen.PartyBaseInfoService; |
|
|
|
import com.epmet.service.evaluationindex.screen.ScreenCpcBaseDataService; |
|
|
|
import com.epmet.service.evaluationindex.screen.ScreenCustomerAgencyService; |
|
|
|
import com.epmet.service.evaluationindex.screen.ScreenCustomerGridService; |
|
|
|
import com.epmet.service.stats.DimCustomerPartymemberService; |
|
|
|
import com.epmet.service.stats.user.FactParticipationUserAgencyDailyService; |
|
|
|
import com.epmet.service.stats.user.FactParticipationUserGridDailyService; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.apache.commons.collections4.ListUtils; |
|
|
|
import org.springframework.beans.BeanUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
@ -39,6 +42,8 @@ public class PartyBaseInfoServiceImpl implements PartyBaseInfoService { |
|
|
|
@Autowired |
|
|
|
private ScreenCustomerAgencyService agencyService; |
|
|
|
@Autowired |
|
|
|
private ScreenCustomerGridService gridService; |
|
|
|
@Autowired |
|
|
|
private DimCustomerPartymemberService partyMemberService; |
|
|
|
@Autowired |
|
|
|
private FactParticipationUserGridDailyService userGridDailyService; |
|
|
@ -62,20 +67,22 @@ public class PartyBaseInfoServiceImpl implements PartyBaseInfoService { |
|
|
|
if (groupByLevel.containsKey(ScreenConstant.COMMUNITY)){ |
|
|
|
List<CustomerAgencyInfoResultDTO> customerGridInfoList = groupByLevel.get(ScreenConstant.COMMUNITY); |
|
|
|
disPose(customerGridInfoList,true,customerId,dateId); |
|
|
|
}else if (groupByLevel.containsKey(ScreenConstant.STREET)){ |
|
|
|
} |
|
|
|
if (groupByLevel.containsKey(ScreenConstant.STREET)){ |
|
|
|
List<CustomerAgencyInfoResultDTO> customerGridInfoList = groupByLevel.get(ScreenConstant.STREET); |
|
|
|
disPose(customerGridInfoList,false,customerId,dateId); |
|
|
|
}else if (groupByLevel.containsKey(ScreenConstant.DISTRICT)){ |
|
|
|
} |
|
|
|
if (groupByLevel.containsKey(ScreenConstant.DISTRICT)){ |
|
|
|
List<CustomerAgencyInfoResultDTO> customerGridInfoList = groupByLevel.get(ScreenConstant.DISTRICT); |
|
|
|
disPose(customerGridInfoList,false,customerId,dateId); |
|
|
|
}else if (groupByLevel.containsKey(ScreenConstant.CITY)){ |
|
|
|
} |
|
|
|
if (groupByLevel.containsKey(ScreenConstant.CITY)){ |
|
|
|
List<CustomerAgencyInfoResultDTO> customerGridInfoList = groupByLevel.get(ScreenConstant.CITY); |
|
|
|
disPose(customerGridInfoList,false,customerId,dateId); |
|
|
|
}else if (groupByLevel.containsKey(ScreenConstant.PROVINCE)){ |
|
|
|
} |
|
|
|
if (groupByLevel.containsKey(ScreenConstant.PROVINCE)){ |
|
|
|
List<CustomerAgencyInfoResultDTO> customerGridInfoList = groupByLevel.get(ScreenConstant.PROVINCE); |
|
|
|
disPose(customerGridInfoList,false,customerId,dateId); |
|
|
|
}else { |
|
|
|
// TODO 干啥
|
|
|
|
} |
|
|
|
} |
|
|
|
return true; |
|
|
@ -89,6 +96,7 @@ public class PartyBaseInfoServiceImpl implements PartyBaseInfoService { |
|
|
|
*/ |
|
|
|
public void disPose(List<CustomerAgencyInfoResultDTO> agencyIdList, Boolean isGrid, String customerId, String dateId){ |
|
|
|
if (!CollectionUtils.isEmpty(agencyIdList)){ |
|
|
|
List<String> orgIds = agencyIdList.stream().map(m -> m.getAgencyId()).collect(Collectors.toList()); |
|
|
|
List<PartyBaseInfoFormDTO> result = new ArrayList<>(); |
|
|
|
if (isGrid == true){ |
|
|
|
List<UserCountResultDTO> userCountList = userGridDailyService.selectUserCount(customerId, dateId); |
|
|
@ -97,6 +105,7 @@ public class PartyBaseInfoServiceImpl implements PartyBaseInfoService { |
|
|
|
String agencyId = agency.getAgencyId(); |
|
|
|
Map<String, Object> agencyMap = agencyService.selectAllSubAgencyId(agencyId, customerId); |
|
|
|
List<String> gridIds = (List<String>) agencyMap.get(agencyId); |
|
|
|
orgIds.addAll(gridIds); |
|
|
|
List<PartyMemberInfoResultDTO> partyMemberInfoList = partyMemberService.selectPartyMemberInfo(customerId, gridIds); |
|
|
|
if (!CollectionUtils.isEmpty(partyMemberInfoList)){ |
|
|
|
// 为每个人赋值年龄
|
|
|
@ -137,6 +146,8 @@ public class PartyBaseInfoServiceImpl implements PartyBaseInfoService { |
|
|
|
PartyBaseInfoFormDTO form = new PartyBaseInfoFormDTO(); |
|
|
|
form.setOrgName(party.get(NumConstant.ZERO).getOrgName()); |
|
|
|
form.setOrgId(commAgencyId); |
|
|
|
form.setCustomerId(customerId); |
|
|
|
form.setDataEndTime(dateId); |
|
|
|
form.setOrgType(ScreenConstant.AGENCY); |
|
|
|
form.setParentId(party.get(NumConstant.ZERO).getParentId()); |
|
|
|
form.setAgeLevel1(party.stream().collect(Collectors.summingInt(PartyBaseInfoFormDTO::getAgeLevel1))); |
|
|
@ -150,16 +161,17 @@ public class PartyBaseInfoServiceImpl implements PartyBaseInfoService { |
|
|
|
form.setRegisterUserCount(party.stream().collect(Collectors.summingInt(PartyBaseInfoFormDTO::getRegisterUserCount))); |
|
|
|
result.add(form); |
|
|
|
}); |
|
|
|
delAndInsert(result,customerId,dateId); |
|
|
|
delAndInsert(result,customerId,dateId,orgIds); |
|
|
|
}else { |
|
|
|
List<UserCountResultDTO> userCountRList = userAgencyDailyService.selectUserCount(customerId, dateId); |
|
|
|
agencyIdList.forEach(agency -> { |
|
|
|
String agencyId = agency.getAgencyId(); |
|
|
|
// todo
|
|
|
|
List<PartyInfoResultDTO> partyInfoList = cpcBaseDataService.selectPartyInfo(customerId, dateId, agencyId); |
|
|
|
if (!CollectionUtils.isEmpty(partyInfoList)){ |
|
|
|
PartyBaseInfoFormDTO form = new PartyBaseInfoFormDTO(); |
|
|
|
form.setOrgName(partyInfoList.get(NumConstant.ZERO).getOrgName()); |
|
|
|
form.setOrgId(agencyId); |
|
|
|
form.setCustomerId(customerId); |
|
|
|
form.setDataEndTime(dateId); |
|
|
|
form.setOrgType(ScreenConstant.AGENCY); |
|
|
|
form.setParentId(partyInfoList.get(NumConstant.ZERO).getParentId()); |
|
|
|
form.setAgeLevel1(partyInfoList.stream().collect(Collectors.summingInt(PartyInfoResultDTO::getAgeLevel1))); |
|
|
@ -172,8 +184,9 @@ public class PartyBaseInfoServiceImpl implements PartyBaseInfoService { |
|
|
|
form.setResiTotal(partyInfoList.stream().collect(Collectors.summingInt(PartyInfoResultDTO::getResiTotal))); |
|
|
|
form.setRegisterUserCount(partyInfoList.stream().collect(Collectors.summingInt(PartyInfoResultDTO::getRegisterUserCount))); |
|
|
|
result.add(form); |
|
|
|
} |
|
|
|
}); |
|
|
|
delAndInsert(result,customerId,dateId); |
|
|
|
delAndInsert(result,customerId,dateId,orgIds); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -246,14 +259,34 @@ public class PartyBaseInfoServiceImpl implements PartyBaseInfoService { |
|
|
|
* @date 2020/9/23 10:13 上午 |
|
|
|
*/ |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void delAndInsert(List<PartyBaseInfoFormDTO> result, String customerId, String dateId){ |
|
|
|
public void delAndInsert(List<PartyBaseInfoFormDTO> result, String customerId, String dateId, List<String> orgIds){ |
|
|
|
List<PartyBaseInfoFormDTO> partyBaseInfoList = agencyService.selectAllAgencyIdToParty(customerId,dateId); |
|
|
|
List<PartyBaseInfoFormDTO> resultList = gridService.selectAllGridIdToParty(customerId, dateId); |
|
|
|
resultList.addAll(partyBaseInfoList); |
|
|
|
List<PartyBaseInfoFormDTO> finalResult = new ArrayList<>(); |
|
|
|
resultList.forEach(rl -> { |
|
|
|
orgIds.forEach(orgId -> { |
|
|
|
if (rl.getOrgId().equals(orgId)){ |
|
|
|
finalResult.add(rl); |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
if (!CollectionUtils.isEmpty(result)){ |
|
|
|
List<String> orgIds = result.stream().map(m -> m.getOrgId()).collect(Collectors.toList()); |
|
|
|
finalResult.forEach(fr -> { |
|
|
|
result.forEach(r -> { |
|
|
|
if (fr.getOrgId().equals(r.getOrgId())){ |
|
|
|
BeanUtils.copyProperties(r,fr); |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
Integer delNum; |
|
|
|
do { |
|
|
|
delNum = cpcBaseDataService.deleteOldPartyBaseInfo(customerId, dateId, orgIds); |
|
|
|
}while (delNum > NumConstant.ZERO); |
|
|
|
cpcBaseDataService.insertPartyBaseInfo(result); |
|
|
|
} |
|
|
|
List<List<PartyBaseInfoFormDTO>> partition = ListUtils.partition(finalResult, NumConstant.ONE_HUNDRED); |
|
|
|
partition.forEach(p -> { |
|
|
|
cpcBaseDataService.insertPartyBaseInfo(p); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|