| 
						
						
							
								
							
						
						
					 | 
					@ -3,7 +3,6 @@ package com.epmet.service.impl; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import com.epmet.commons.tools.utils.DateUtils; | 
					 | 
					 | 
					import com.epmet.commons.tools.utils.DateUtils; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import com.epmet.dto.stats.ArticleGridPublishedSummaryDTO; | 
					 | 
					 | 
					import com.epmet.dto.stats.ArticleGridPublishedSummaryDTO; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import com.epmet.entity.stats.DimGridEntity; | 
					 | 
					 | 
					import com.epmet.entity.stats.DimGridEntity; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import com.epmet.entity.stats.FactArticlePublishedAgencyDailyEntity; | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import com.epmet.service.StatsPublicityService; | 
					 | 
					 | 
					import com.epmet.service.StatsPublicityService; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import com.epmet.service.stats.*; | 
					 | 
					 | 
					import com.epmet.service.stats.*; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import com.epmet.service.voice.ArticlePublishRangeService; | 
					 | 
					 | 
					import com.epmet.service.voice.ArticlePublishRangeService; | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
					@ -47,52 +46,31 @@ public class StatsPublicityServiceImpl implements StatsPublicityService { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
						private FactArticlePublishedGridDailyService factArticlePublishedGridDailyService; | 
					 | 
					 | 
						private FactArticlePublishedGridDailyService factArticlePublishedGridDailyService; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
						@Override | 
					 | 
					 | 
						@Override | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
						public Boolean publicitySummary() { | 
					 | 
					 | 
						public Boolean publicitySummary(Date statsDate) { | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
							if (statsDate == null) { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
								statsDate = DateUtils.addDateDays(new Date(), -1); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
							} | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
							int pageNo = 1; | 
					 | 
					 | 
							int pageNo = 1; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
							int pageSize = 100; | 
					 | 
					 | 
							int pageSize = 100; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
							List<String> customerIdList = null; | 
					 | 
					 | 
							List<String> customerIdList = null; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
							do { | 
					 | 
					 | 
							do { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
								customerIdList = dimCustomerService.selectCustomerIdPage(pageNo++, pageSize); | 
					 | 
					 | 
								customerIdList = dimCustomerService.selectCustomerIdPage(pageNo++, pageSize); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
								if (!CollectionUtils.isEmpty(customerIdList)) { | 
					 | 
					 | 
								if (!CollectionUtils.isEmpty(customerIdList)) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
									customerIdList.forEach(customerId -> { | 
					 | 
					 | 
									for (String customerId : customerIdList) {//获取所有网格
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					 | 
					 | 
										//获取所有网格
 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
										List<DimGridEntity> gridDTOList = dimGridService.getGridListByCustomerId(customerId); | 
					 | 
					 | 
										List<DimGridEntity> gridDTOList = dimGridService.getGridListByCustomerId(customerId); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
										if (!CollectionUtils.isEmpty(gridDTOList)) { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
											List<ArticleGridPublishedSummaryDTO> publishedArticleCount = articlePublishRangeService.getAllPublishedCount(customerId, statsDate); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
										} | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
									}); | 
					 | 
					 | 
									} | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
								} | 
					 | 
					 | 
								} | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
							} while (!CollectionUtils.isEmpty(customerIdList) || customerIdList.size() >= pageSize); | 
					 | 
					 | 
							} while (!CollectionUtils.isEmpty(customerIdList) || customerIdList.size() >= pageSize); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
							return null; | 
					 | 
					 | 
							return null; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
						} | 
					 | 
					 | 
						} | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
						private List<ArticleGridPublishedSummaryDTO> statsPublishArticle(String customerId, Date statsDate) { | 
					 | 
					 | 
						private List<ArticleGridPublishedSummaryDTO> statsPublishArticle(String customerId, Date statsDate) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
							if (statsDate == null) { | 
					 | 
					 | 
							List<ArticleGridPublishedSummaryDTO> articleCount = articlePublishRangeService.getAllPublishedCount(customerId, statsDate); | 
				
			
			
				
				
			
		
	
		
		
			
				
					 | 
					 | 
								statsDate = DateUtils.addDateDays(new Date(), -1); | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
							} | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
							//昨日的 dateId
 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
							String dateId = DateUtils.format(statsDate, DateUtils.DATE_PATTERN_YYYYMMDD); | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
							//1.先查询昨天的 有没有数据 有则 昨日发布文章总数 = 昨日的发布文章数增量 + 统计表中已有的昨日的网格总数 ;
 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
							// 否则 昨日发布文章总数 = 发布范围表中计算所有发布文章总数
 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
							List<ArticleGridPublishedSummaryDTO> articleCount = null; | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
							List<FactArticlePublishedAgencyDailyEntity> gridBeforeData = factArticlePublishedGridDailyService.getByBeforeDay(customerId, dateId); | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
							boolean selectAll = false; | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
							if (CollectionUtils.isEmpty(gridBeforeData)){ | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
								selectAll = true; | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
							} | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
							if (selectAll) { | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
								articleCount = articlePublishRangeService.getAllPublishedCount(customerId, statsDate); | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
							} else { | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
								Date startDate = DateUtils.integrate(new Date(), DateUtils.DATE_PATTERN); | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
								Date endDate = DateUtils.integrate(DateUtils.addDateDays(startDate, 1), DateUtils.DATE_PATTERN); | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
								articleCount = articlePublishRangeService.getOneDayPublishedCount(customerId, startDate, endDate); | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
								//如果没有查到
 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
								if (CollectionUtils.isEmpty(articleCount)){ | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
								} | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
								//累加昨日的数据
 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
							} | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
							return articleCount; | 
					 | 
					 | 
							return articleCount; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
						} | 
					 | 
					 | 
						} | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
					
  |