| 
					
				 | 
			
			
				@@ -11,6 +11,7 @@ import com.tzld.piaoquan.longarticle.model.dto.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.tzld.piaoquan.longarticle.model.po.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.tzld.piaoquan.longarticle.model.vo.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.tzld.piaoquan.longarticle.service.local.CoreService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.tzld.piaoquan.longarticle.service.local.PlanAccountService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.tzld.piaoquan.longarticle.service.remote.AigcService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.tzld.piaoquan.longarticle.service.remote.MatchService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.tzld.piaoquan.longarticle.service.remote.VideoService; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -21,12 +22,14 @@ import com.tzld.piaoquan.longarticle.utils.TimeZoneUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import lombok.extern.slf4j.Slf4j; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.apache.commons.lang3.StringUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.beans.factory.annotation.Autowired; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import org.springframework.data.redis.core.RedisTemplate; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.stereotype.Service; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.util.CollectionUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.math.BigDecimal; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.time.LocalTime; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.util.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.util.concurrent.TimeUnit; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.util.stream.Collectors; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 @Slf4j 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -58,7 +61,7 @@ public class CoreServiceImpl implements CoreService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private PlanAccountMapper planAccountMapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    private PlanAccountServiceImpl planAccountService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private PlanAccountService planAccountService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private PublishMiniprogramMapper publishMiniprogramMapper; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -72,16 +75,13 @@ public class CoreServiceImpl implements CoreService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private PublicContentServiceImpl publicContentService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private RedisTemplate<String, Object> redisTemplate; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     public void initPlanAccount() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         List<LongArticleSystemPlan> allLongArticleSystemPlans = aigcService.getAllLongArticleSystemPlan(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         for (LongArticleSystemPlan longArticleSystemPlan : allLongArticleSystemPlans) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            if (longArticleSystemPlan.getPublishRate() == 1) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                List<Integer> weeks = JSON.parseArray(longArticleSystemPlan.getPublishDate(), Integer.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                if (!weeks.contains(TimeZoneUtil.getTodayDayOfWeek(TimeZoneUtil.Timezone.china))) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    continue; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             //获取排序策略 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             Map<String, String> sortStgMap = new HashMap<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             List<GzhArticleSortTaskParam> gzhArticleSortTask = longArticleSystemPlan.getGzhArticleSortTask(); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -130,16 +130,7 @@ public class CoreServiceImpl implements CoreService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     planAccount.setSortStrategy(sortStgMap.get(accountId)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 planAccount.setPushType(longArticleSystemPlan.getPushType()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                PlanAccountExample example = new PlanAccountExample(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                example.createCriteria().andAccountIdEqualTo(account.getId()).andPlanIdEqualTo(longArticleSystemPlan.getId()) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        .andCreateTimeGreaterThan(DateUtil.getThatDayDate()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                List<PlanAccount> planAccounts = planAccountMapper.selectByExample(example); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                if (CollectionUtils.isEmpty(planAccounts)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    planAccountMapper.insertSelective(planAccount); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    planAccount.setId(planAccounts.get(0).getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    planAccountMapper.updateByPrimaryKeySelective(planAccount); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                planAccountService.saveOrUpdatePlanAccount(planAccount); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -147,10 +138,11 @@ public class CoreServiceImpl implements CoreService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     public void matchContent() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         //查询状态为0的请求匹配 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        PlanAccountExample example = new PlanAccountExample(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        example.createCriteria().andCreateTimeGreaterThan(DateUtil.getThatDayDate()).andMatchStatusEqualTo(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        List<PlanAccount> planAccounts = planAccountMapper.selectByExample(example); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        for (PlanAccount planAccount : planAccounts) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<PlanAccount> matchPlanAccounts = planAccountService.getMatchPlanAccount(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (CollectionUtils.isEmpty(matchPlanAccounts)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        for (PlanAccount planAccount : matchPlanAccounts) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             LongArticleSystemGetContentsParam param = new LongArticleSystemGetContentsParam(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             param.setAccountId(planAccount.getAccountId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             param.setPlanId(planAccount.getPlanId()); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -196,7 +188,11 @@ public class CoreServiceImpl implements CoreService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     request.setStrategy("strategy_v2"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     request.setArticleId(contentItemVO.getSourceId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     request.setFlowPoolLevelTag(contentItemVO.getFlowPoolLevelTag()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    matchService.matchMiniprogramVideo(request); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    String traceId = matchService.matchMiniprogramVideo(request); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    if (StringUtils.isNotEmpty(traceId)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        String key = contentItemVO.getSourceId() + "_" + planAccount.getGhId(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        redisTemplate.opsForValue().set(key, traceId, 24, TimeUnit.HOURS); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -208,11 +204,9 @@ public class CoreServiceImpl implements CoreService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         LocalTime currentTime = TimeZoneUtil 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 .currentTime(Optional.ofNullable(timezone).orElse(TimeZoneUtil.Timezone.china)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         if (currentTime.isAfter(LocalTime.parse(startWindow)) && currentTime.isBefore(LocalTime.parse(endWindow))) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             return true; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return false; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 |