| 
						
						
							
								
							
						
						
					 | 
					@ -41,6 +41,7 @@ import com.epmet.service.partymember.PartyMemberService; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import com.epmet.service.stats.DimCustomerPartymemberService; | 
					 | 
					 | 
					import com.epmet.service.stats.DimCustomerPartymemberService; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import com.epmet.service.stats.DimCustomerService; | 
					 | 
					 | 
					import com.epmet.service.stats.DimCustomerService; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import com.epmet.service.stats.DimGridService; | 
					 | 
					 | 
					import com.epmet.service.stats.DimGridService; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					import com.epmet.util.DimIdGenerator; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import lombok.extern.slf4j.Slf4j; | 
					 | 
					 | 
					import lombok.extern.slf4j.Slf4j; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import org.apache.commons.lang3.StringUtils; | 
					 | 
					 | 
					import org.apache.commons.lang3.StringUtils; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import org.springframework.beans.BeanUtils; | 
					 | 
					 | 
					import org.springframework.beans.BeanUtils; | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					@ -49,10 +50,7 @@ import org.springframework.stereotype.Service; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import org.springframework.transaction.annotation.Transactional; | 
					 | 
					 | 
					import org.springframework.transaction.annotation.Transactional; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import org.springframework.util.CollectionUtils; | 
					 | 
					 | 
					import org.springframework.util.CollectionUtils; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					import java.util.ArrayList; | 
					 | 
					 | 
					import java.util.*; | 
				
			
			
				
				
			
		
	
		
		
			
				
					 | 
					 | 
					import java.util.Arrays; | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import java.util.List; | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import java.util.Map; | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					import java.util.stream.Collectors; | 
					 | 
					 | 
					import java.util.stream.Collectors; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					/** | 
					 | 
					 | 
					/** | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
					@ -134,32 +132,45 @@ public class DimCustomerPartymemberServiceImpl extends BaseServiceImpl<DimCustom | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					     */ | 
					 | 
					 | 
					     */ | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    @Override | 
					 | 
					 | 
					    @Override | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    public Boolean statsPartyMember(CustomerIdAndDateIdFormDTO customerIdAndDateIdFormDTO) { | 
					 | 
					 | 
					    public Boolean statsPartyMember(CustomerIdAndDateIdFormDTO customerIdAndDateIdFormDTO) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					
 | 
					 | 
					 | 
					        String customerIdOne = customerIdAndDateIdFormDTO.getCustomerId(); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					        List<String> allCustomerId = dimCustomerService.getAllCustomerId(); | 
					 | 
					 | 
					        List<String> customerIds = new ArrayList<>(); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					        if (CollectionUtils.isEmpty(allCustomerId)){ | 
					 | 
					 | 
					        List<String> dateIds = new ArrayList<>(); | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        if (StringUtils.isNotBlank(customerIdOne)){ | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            customerIds.add(customerIdOne); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        }else { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            customerIds = dimCustomerService.getAllCustomerId(); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        if (CollectionUtils.isEmpty(customerIds)){ | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            throw new RenException(StatsConstant.CUSTOMER_INFO_NULL); | 
					 | 
					 | 
					            throw new RenException(StatsConstant.CUSTOMER_INFO_NULL); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        } | 
					 | 
					 | 
					        } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					        allCustomerId.forEach(customerId -> { | 
					 | 
					 | 
					        if ((StringUtils.isBlank(customerIdAndDateIdFormDTO.getStartDate()) && StringUtils.isBlank(customerIdAndDateIdFormDTO.getEndDate()))){ | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					            String dateId = customerIdAndDateIdFormDTO.getDateId(); | 
					 | 
					 | 
					            dateIds.add(DimIdGenerator.getDateDimId(DateUtils.addDateDays(new Date(), -1))); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					            List<DimCustomerPartyMemberFormDTO> partyMemberList = partyMemberService.selectPartyMemberInfo(customerId, dateId); | 
					 | 
					 | 
					        }else { | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					            if (CollectionUtils.isEmpty(partyMemberList)){ | 
					 | 
					 | 
					            dateIds = DateUtils.getDaysBetween(customerIdAndDateIdFormDTO.getStartDate(), customerIdAndDateIdFormDTO.getEndDate()); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					                log.warn(String.format(StatsConstant.PARTY_INFO_LIST,customerId)); | 
					 | 
					 | 
					        } | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					                return; | 
					 | 
					 | 
					        List<String> finalDateIds = dateIds; | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					            } | 
					 | 
					 | 
					        customerIds.forEach(customerId -> { | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					            List<String> gridIds = partyMemberList.stream().map(party -> party.getGridId()).distinct().collect(Collectors.toList()); | 
					 | 
					 | 
					            finalDateIds.forEach(dateId -> { | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					            List<GridBelongAgencyResultDTO> agencyInfos = dimGridService.selectGridBelongAgencyInfo(gridIds); | 
					 | 
					 | 
					                List<DimCustomerPartyMemberFormDTO> partyMemberList = partyMemberService.selectPartyMemberInfo(customerId, dateId); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					            TimeListResultDTO timeList = DateUtils.getTimeList(dateId); | 
					 | 
					 | 
					                if (CollectionUtils.isEmpty(partyMemberList)){ | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					            partyMemberList.forEach(party -> { | 
					 | 
					 | 
					                    log.warn(String.format(StatsConstant.PARTY_INFO_LIST,customerId)); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					                BeanUtils.copyProperties(timeList,party); | 
					 | 
					 | 
					                    return; | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					                agencyInfos.forEach(agency -> { | 
					 | 
					 | 
					                } | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					                    if (party.getGridId().equals(agency.getGridId())){ | 
					 | 
					 | 
					                List<String> gridIds = partyMemberList.stream().map(party -> party.getGridId()).distinct().collect(Collectors.toList()); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					                        party.setAgencyId(agency.getAgencyId()); | 
					 | 
					 | 
					                List<GridBelongAgencyResultDTO> agencyInfos = dimGridService.selectGridBelongAgencyInfo(gridIds); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					                        party.setParentId(agency.getParentId()); | 
					 | 
					 | 
					                TimeListResultDTO timeList = DateUtils.getTimeList(dateId); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					                        party.setPids(agency.getPids()); | 
					 | 
					 | 
					                partyMemberList.forEach(party -> { | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					                    } | 
					 | 
					 | 
					                    BeanUtils.copyProperties(timeList,party); | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                    agencyInfos.forEach(agency -> { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                        if (party.getGridId().equals(agency.getGridId())){ | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                            party.setAgencyId(agency.getAgencyId()); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                            party.setParentId(agency.getParentId()); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                            party.setPids(agency.getPids()); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                        } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                    }); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                }); | 
					 | 
					 | 
					                }); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                delAndInsertParty(partyMemberList,customerId,dateId); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            }); | 
					 | 
					 | 
					            }); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            delAndInsertParty(partyMemberList,customerId,dateId); | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        }); | 
					 | 
					 | 
					        }); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        return true; | 
					 | 
					 | 
					        return true; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    } | 
					 | 
					 | 
					    } | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
					
  |