| 
					
				 | 
			
			
				@@ -1,5 +1,6 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 package com.tzld.piaoquan.longarticle.service.impl; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.alibaba.fastjson.JSON; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.tzld.piaoquan.longarticle.dao.mapper.PlanAccountMapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.tzld.piaoquan.longarticle.dao.mapper.PublishMiniprogramMapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.tzld.piaoquan.longarticle.model.dto.*; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -16,10 +17,7 @@ import org.springframework.stereotype.Service; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.util.CollectionUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.math.BigDecimal; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import java.util.ArrayList; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import java.util.HashMap; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import java.util.List; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import java.util.Map; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.util.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 @Service 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 public class CoreServiceImpl implements CoreService { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -54,10 +52,15 @@ public class CoreServiceImpl implements CoreService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private PublishMiniprogramMapper publishMiniprogramMapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    public void init() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public void initPlanAccount() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         List<LongArticleSystemPlan> allLongArticleSystemPlans = planService.getAllLongArticleSystemPlan(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         for (LongArticleSystemPlan longArticleSystemPlan : allLongArticleSystemPlans) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            //TODO 判断计划当天是否需要发送  不发送不记录 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            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(); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -108,7 +111,7 @@ public class CoreServiceImpl implements CoreService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    public void match() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public void matchContent() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         //查询状态为0的请求匹配 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         PlanAccountExample example = new PlanAccountExample(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         example.createCriteria().andCreateTimeGreaterThan(DateUtil.getThatDayDate()).andStatusEqualTo(0); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -123,10 +126,7 @@ public class CoreServiceImpl implements CoreService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             //没有待匹配的文章  更新状态为1  待排序 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             if (longArticleSystemContentVO.getTotalCount() == 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                PlanAccount updatePlanAccount = new PlanAccount(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                updatePlanAccount.setId(planAccount.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                updatePlanAccount.setStatus(1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                planAccountMapper.updateByPrimaryKey(updatePlanAccount); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                planAccountService.updateStatus(1, planAccount.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             for (ContentItemVO contentItemVO : longArticleSystemContentVO.getContentItemList()) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 MatchVideo content = contentService.getContent(planAccount.getGhId(), contentItemVO.getContent()); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -168,25 +168,27 @@ public class CoreServiceImpl implements CoreService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     public void core() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        List<PlanAccount> planAccounts = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        PlanAccount planAccount1 = new PlanAccount(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        planAccount1.setAccountId("20231208111728193795195"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        planAccount1.setAccountName("票圈大事件"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        planAccount1.setGhId("gh_9e559b3b94ca"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        planAccount1.setPlanId("20241012140830436890740"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        planAccount1.setPublishNum(8); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        planAccount1.setMiniStrategy("strategy_v1"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        planAccount1.setSortStrategy("ArticleRankV5"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        planAccount1.setPublishPreMinNum(4); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        planAccount1.setMiniprogramUseType(1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        planAccount1.setPushType(2); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        planAccounts.add(planAccount1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//        List<PlanAccount> planAccounts = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//        PlanAccount planAccount1 = new PlanAccount(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//        planAccount1.setAccountId("20231208111728193795195"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//        planAccount1.setAccountName("票圈大事件"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//        planAccount1.setGhId("gh_9e559b3b94ca"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//        planAccount1.setPlanId("20241012140830436890740"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//        planAccount1.setPublishNum(8); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//        planAccount1.setMiniStrategy("strategy_v1"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//        planAccount1.setSortStrategy("ArticleRankV5"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//        planAccount1.setPublishPreMinNum(4); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//        planAccount1.setMiniprogramUseType(1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//        planAccount1.setPushType(2); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//        planAccounts.add(planAccount1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         //查询状态为1的  开始排序  发布小程序视频  组装 发布文章 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//        PlanAccountExample example = new PlanAccountExample(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//        example.createCriteria().andCreateTimeGreaterThan(DateUtil.getThatDayDate()).andStatusEqualTo(1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//        List<PlanAccount> planAccounts = planAccountMapper.selectByExample(example); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        PlanAccountExample example = new PlanAccountExample(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        //匹配完成和发布失败 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<Integer> status = Arrays.asList(1, 5); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        example.createCriteria().andCreateTimeGreaterThan(DateUtil.getThatDayDate()).andStatusIn(status); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<PlanAccount> planAccounts = planAccountMapper.selectByExample(example); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         for (PlanAccount planAccount : planAccounts) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             ArticleSortRequest articleSortRequest = new ArticleSortRequest(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             articleSortRequest.setAccountId(planAccount.getAccountId()); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -317,11 +319,61 @@ public class CoreServiceImpl implements CoreService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 continue; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             System.out.println(gzhPushParam); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            boolean pushTask = planService.createPushTask(gzhPushParam); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            if (pushTask) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            String pushId = planService.createPushTask(gzhPushParam); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (StringUtils.isNotEmpty(pushId)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 //更新状态  发布完成 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                PlanAccount updatePlanAccount = new PlanAccount(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                updatePlanAccount.setId(planAccount.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                updatePlanAccount.setStatus(3); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                updatePlanAccount.setPushId(pushId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                planAccountMapper.updateByPrimaryKey(updatePlanAccount); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 planAccountService.updateStatus(3, planAccount.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public void getPushStatus() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        PlanAccountExample example = new PlanAccountExample(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        //匹配完成和发布失败 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<Integer> status = Arrays.asList(3); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        example.createCriteria().andCreateTimeGreaterThan(DateUtil.getThatDayDate()).andStatusIn(status); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<PlanAccount> planAccounts = planAccountMapper.selectByExample(example); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (CollectionUtils.isEmpty(planAccounts)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        for (PlanAccount planAccount : planAccounts) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (StringUtils.isNotEmpty(planAccount.getPublishPushTime())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                String dateTimeStr = TimeZoneUtil.todayYMD(TimeZoneUtil.Timezone.china) + " " + planAccount.getPublishPushTime(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                long dateStrTimestamp = TimeZoneUtil.getDateStrTimestamp(dateTimeStr, "yyyy-MM-dd HH:mm:ss", TimeZoneUtil.Timezone.china); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if (dateStrTimestamp < new Date().getTime()) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    continue; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (StringUtils.isEmpty(planAccount.getPushId())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                continue; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            PushStatusParam param = new PushStatusParam(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            param.setPushId(planAccount.getPushId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            PushStatusVO pushStatusVO = planService.queryPushStatus(param); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            int updateStatus = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //推送失败  重新推送 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (pushStatusVO.getPushStatus() == 3) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                updateStatus = 5; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //推送成功 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (pushStatusVO.getPushStatus() == 2) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                //发表失败 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if (pushStatusVO.getPublishStatus() == 3) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    updateStatus = 5; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                //发表成功 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if (pushStatusVO.getPublishStatus() == 2) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    updateStatus = 4; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //更新状态  4成功  5失败 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (updateStatus != 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                planAccountService.updateStatus(updateStatus, planAccount.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 |