| 
					
				 | 
			
			
				@@ -6,10 +6,8 @@ import com.tzld.piaoquan.recommend.server.common.ThreadPoolFactory; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import lombok.extern.slf4j.Slf4j; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.apache.commons.collections4.CollectionUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.apache.commons.collections4.MapUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import org.apache.commons.lang3.math.NumberUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.beans.factory.annotation.Autowired; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.beans.factory.annotation.Qualifier; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import org.springframework.beans.factory.annotation.Value; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.data.redis.core.RedisTemplate; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.stereotype.Service; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -38,13 +36,6 @@ public class FlowPoolService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private ExecutorService pool = ThreadPoolFactory.defaultPool(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    @Value("${flow.pool.upgrade.switch:true}") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    private boolean flowPoolUpgradeSwitch; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    private int[] appTypes = {VLOG.getCode(), LOVE_MOVIE.getCode(), LOVE_LIVE.getCode(), LONG_VIDEO.getCode(), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            SHORT_VIDEO.getCode(), H5.getCode(), APP_SPEED.getCode(), WAN_NENG_VIDEO.getCode(), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            LAO_HAO_KAN_VIDEO.getCode(), ZUI_JING_QI.getCode(), PIAO_QUAN_VIDEO_PLUS.getCode(), JOURNEY.getCode()}; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     public void updateDistributeCountWithLevel(List<Video> videos) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         if (CollectionUtils.isEmpty(videos)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             return; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -56,18 +47,9 @@ public class FlowPoolService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private void asyncDelDistributeCountWithLevel(Map<Long, String> videoFlowPoolMap) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        if (flowPoolUpgradeSwitch) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            asyncDelDistributeCountV2(videoFlowPoolMap, (appType, level, values) -> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                redisTemplate.opsForSet().remove(String.format(KEY_WITH_LEVEL_FORMAT_V2, appType, level), values); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            asyncDelDistributeCount(videoFlowPoolMap, (appType, level, values) -> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                String key = String.format(KEY_WITH_LEVEL_FORMAT, appType, level); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                Long count = redisTemplate.opsForSet().remove(key, values); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        asyncDelDistributeCountV2(videoFlowPoolMap, (appType, level, values) -> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            redisTemplate.opsForSet().remove(String.format(KEY_WITH_LEVEL_FORMAT_V2, appType, level), values); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private Map<Long, String> updateDistributeCount(List<Video> videos) { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -83,34 +65,6 @@ public class FlowPoolService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return removeMap; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    private void asyncDelDistributeCount(Map<Long, String> videoFlowPoolMap, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                         TripleConsumer<Integer, String, String[]> flowPoolRemoveConsumer) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        if (MapUtils.isEmpty(videoFlowPoolMap)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            return; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        pool.execute(() -> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            List<String> keys = videoFlowPoolMap.entrySet().stream() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    .map(v -> String.format(localDistributeCountFormat, v.getKey(), v.getValue())) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    .collect(Collectors.toList()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            redisTemplate.delete(keys); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            Map<String, Double> levelWeight = flowPoolConfigService.getLevelWeight4FlowPoolWithLevel(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            String[] values = new String[videoFlowPoolMap.size()]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            int i = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            for (Map.Entry v : videoFlowPoolMap.entrySet()) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                values[i++] = String.format(valueFormat, v.getKey(), v.getValue()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            // remove 每小程序每层的数据 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            // TODO 现在视频只会出现在一个层级,所以可以做个优化 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            for (String level : levelWeight.keySet()) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                for (int appType : appTypes) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    flowPoolRemoveConsumer.accept(appType, level, values); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private void asyncDelDistributeCountV2(Map<Long, String> videoFlowPoolMap, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                            TripleConsumer<Integer, String, String[]> flowPoolRemoveConsumer) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         if (MapUtils.isEmpty(videoFlowPoolMap)) { 
			 |