| 
					
				 | 
			
			
				@@ -1,6 +1,9 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 package com.fs.statis.service.impl; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.fs.common.core.redis.RedisCache; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.fs.company.cache.ICompanyCacheService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.fs.statis.StatisticsRedisConstant; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.fs.statis.cache.IStatisticsCacheService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.fs.statis.dto.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.fs.statis.mapper.ConsumptionBalanceMapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.fs.statis.service.IStatisticsService; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -9,13 +12,20 @@ import com.fs.store.service.cache.IFsUserCourseCacheService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.hc.openapi.tool.util.ObjectUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.hc.openapi.tool.util.StringUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.beans.factory.annotation.Autowired; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import org.springframework.scheduling.annotation.Scheduled; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.stereotype.Service; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.math.BigDecimal; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.math.RoundingMode; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import java.util.Collections; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.time.DayOfWeek; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.time.LocalDate; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.time.LocalDateTime; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.time.format.DateTimeFormatter; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.time.temporal.TemporalAdjusters; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.util.List; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import static com.fs.statis.StatisticsRedisConstant.DATA_OVERVIEW_DEALER_CHARTS; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 @Service 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 public class StatisticsServiceImpl implements IStatisticsService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Autowired 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -27,6 +37,157 @@ public class StatisticsServiceImpl implements IStatisticsService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private ICompanyCacheService companyCacheService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private RedisCache redisCache; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Scheduled(cron = "0 * * * * *") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public void dataOverviewTask() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        DealerAggregatedDTO dealerAggregatedDTO = this.dealerAggregated(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        ConsumptionBalanceDataDTO consumptionBalanceDataDTO = this.rechargeConsumption(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        AuthorizationInfoDTO authorizationInfoDTO = authorizationInfo(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Long smsBalance = this.smsBalance(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        redisCache.setCacheObject(StatisticsRedisConstant.DATA_OVERVIEW_DEALER_AGGREGATED, dealerAggregatedDTO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        redisCache.setCacheObject(StatisticsRedisConstant.DATA_OVERVIEW_DEALER_BALANCE, consumptionBalanceDataDTO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        redisCache.setCacheObject(StatisticsRedisConstant.DATA_OVERVIEW_DEALER_AUTHORIZATION_INFO, authorizationInfoDTO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        redisCache.setCacheObject(StatisticsRedisConstant.DATA_OVERVIEW_DEALER_SMS_BALANCE, smsBalance); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Scheduled(cron = "0 * * * * *") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public void analysisPreviewTask0(){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        analysisPreviewTask(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Scheduled(cron = "0 * * * * *") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public void analysisPreviewTask1(){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        analysisPreviewTask(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        analysisPreviewTask(1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        analysisPreviewTask(2); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        analysisPreviewTask(3); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        analysisPreviewTask(4); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public void analysisPreviewTask(Integer type) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // 根据type计算出时间范围 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        String startDate = ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        String endDate = ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        LocalDate now = LocalDate.now(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if(0 == type){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            startDate = now.format(formatter); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            endDate = now.format(formatter); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } else if(1 == type){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            LocalDate yesterday = now.minusDays(1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            startDate = yesterday.format(formatter); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            endDate = yesterday.format(formatter); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } else if(2 == type) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            LocalDate startOfWeek = now.with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            startDate = startOfWeek.format(formatter); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            endDate = now.format(formatter); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } else if(3 == type) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            LocalDate startOfMonth = now.withDayOfMonth(1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            startDate = startOfMonth.format(formatter); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            endDate = now.format(formatter); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } else if(4 == type) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            LocalDate firstDayOfPreviousMonth = now.minusMonths(1).withDayOfMonth(1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            LocalDate lastDayOfPreviousMonth = now.withDayOfMonth(1).minusDays(1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            startDate = firstDayOfPreviousMonth.format(formatter); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            endDate = lastDayOfPreviousMonth.format(formatter); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        AnalysisPreviewQueryDTO param = new AnalysisPreviewQueryDTO(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        param.setStartTime(startDate); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        param.setEndTime(endDate); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        param.setType(type); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        AnalysisPreviewDTO analysisPreviewDTO = this.analysisPreview(param); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if(0 == type){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            redisCache.setCacheObject(StatisticsRedisConstant.DATA_OVERVIEW_DEALER_ANALYSISPREVIEW_TODAY, analysisPreviewDTO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } else if(1 == type){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            redisCache.setCacheObject(StatisticsRedisConstant.DATA_OVERVIEW_DEALER_ANALYSISPREVIEW_YESTODAY, analysisPreviewDTO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } else if(2 == type) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            redisCache.setCacheObject(StatisticsRedisConstant.DATA_OVERVIEW_DEALER_ANALYSISPREVIEW_THIS_WEEEK, analysisPreviewDTO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } else if(3 == type) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            redisCache.setCacheObject(StatisticsRedisConstant.DATA_OVERVIEW_DEALER_ANALYSISPREVIEW_THIS_MONTH, analysisPreviewDTO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } else if(4 == type) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            redisCache.setCacheObject(StatisticsRedisConstant.DATA_OVERVIEW_DEALER_ANALYSISPREVIEW_BEFORE_MONTH, analysisPreviewDTO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Scheduled(cron = "0 * * * * *") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public void watchEndPlayTrendTask0(){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        this.watchEndPlayTrendTask(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        this.watchEndPlayTrendTask(1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        this.watchEndPlayTrendTask(2); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        this.watchEndPlayTrendTask(3); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        this.watchEndPlayTrendTask(4); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public void watchEndPlayTrendTask(Integer type) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // 根据type计算出时间范围 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        String startDate = ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        String endDate = ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        LocalDateTime now = LocalDateTime.now(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if(0 == type){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            startDate = now.format(formatter); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            endDate = now.format(formatter); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } else if(1 == type){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            LocalDateTime yesterday = now.minusDays(1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            startDate = yesterday.format(formatter); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            endDate = yesterday.format(formatter); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } else if(2 == type) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            LocalDateTime startOfWeek = now.with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            startDate = startOfWeek.format(formatter); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            endDate = now.format(formatter); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } else if(3 == type) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            LocalDateTime startOfMonth = now.withDayOfMonth(1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            startDate = startOfMonth.format(formatter); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            endDate = now.format(formatter); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } else if(4 == type) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            LocalDateTime firstDayOfPreviousMonth = now.minusMonths(1).withDayOfMonth(1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            LocalDateTime lastDayOfPreviousMonth = now.withDayOfMonth(1).minusDays(1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            startDate = firstDayOfPreviousMonth.format(formatter); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            endDate = lastDayOfPreviousMonth.format(formatter); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        AnalysisPreviewQueryDTO param = new AnalysisPreviewQueryDTO(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        param.setStartTime(startDate); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        param.setEndTime(endDate); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        param.setType(type); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<WatchEndPlayTrendDTO> watchEndPlayTrendDTOS = this.watchEndPlayTrend(param); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        redisCache.setCacheObject(String.format("%s::%d",DATA_OVERVIEW_DEALER_CHARTS,type),watchEndPlayTrendDTOS); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public void watchCourseTopTenTask() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public void rewardMoneyTopTenTask() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     public DealerAggregatedDTO dealerAggregated() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return consumptionBalanceMapper.dealerAggregated(); 
			 |