作者 lyh

gx视频任务

@@ -65,7 +65,6 @@ class VideoTask extends Command @@ -65,7 +65,6 @@ class VideoTask extends Command
65 Log::info('当月以达到最大视频生成数,任务执行数:' . $number); 65 Log::info('当月以达到最大视频生成数,任务执行数:' . $number);
66 return true; 66 return true;
67 } 67 }
68 -  
69 $this->createSubTask($number); 68 $this->createSubTask($number);
70 $this->sendSubTask(); 69 $this->sendSubTask();
71 Log::info('结束视频推广任务'); 70 Log::info('结束视频推广任务');
@@ -73,31 +72,6 @@ class VideoTask extends Command @@ -73,31 +72,6 @@ class VideoTask extends Command
73 } 72 }
74 73
75 /** 74 /**
76 - * @remark :获取当月的数据总量  
77 - * @name :getVideoNumber  
78 - * @author :lyh  
79 - * @method :post  
80 - * @time :2024/7/12 18:02  
81 - */  
82 - public function getVideoNumber()  
83 - {  
84 - $current_time = date('Y-m-d 00:00:00');  
85 - $number = Cache::get('video_keyword_number');  
86 - if(empty($number) || ($current_time == date('Y-m-13 00:00:00'))){  
87 - if($current_time <= date('Y-m-13 00:00:00')){  
88 - $startOfMonth = Carbon::now()->subMonth()->day(13)->format('Y-m-d 00:00:00');  
89 - $endOfMonth = Carbon::now()->day(13)->format('Y-m-d 00:00:00');  
90 - }else{  
91 - $startOfMonth = Carbon::now()->day(13)->format('Y-m-d 00:00:00');  
92 - $endOfMonth = Carbon::now()->addMonth()->day(13)->format('Y-m-d 00:00:00');  
93 - }  
94 - $taskLogModel = new KeywordVideoTaskLog();  
95 - $number = $taskLogModel->formatQuery(['created_at' => ['between', [$startOfMonth, $endOfMonth]]])->count();  
96 - Cache::put('video_keyword_number',$number);  
97 - }  
98 - return $number;  
99 - }  
100 - /**  
101 * 创建子任务 75 * 创建子任务
102 * TODO 获取需要生成子任务的项目,获取项目中未生成视频的关键词,通过关键词生成初始化子任务 76 * TODO 获取需要生成子任务的项目,获取项目中未生成视频的关键词,通过关键词生成初始化子任务
103 * @return bool 77 * @return bool
@@ -109,6 +83,9 @@ class VideoTask extends Command @@ -109,6 +83,9 @@ class VideoTask extends Command
109 if ($sub_task_num <= 0){ 83 if ($sub_task_num <= 0){
110 break; 84 break;
111 } 85 }
  86 + if($number >= $this->max_num){
  87 + break;
  88 + }
112 $task_project = KeywordVideoTask::where(['status' => KeywordVideoTask::STATUS_OPEN])->orderBy('sort', 'desc')->orderBy('id', 'desc')->first(); 89 $task_project = KeywordVideoTask::where(['status' => KeywordVideoTask::STATUS_OPEN])->orderBy('sort', 'desc')->orderBy('id', 'desc')->first();
113 if (empty($task_project)){ 90 if (empty($task_project)){
114 break; 91 break;
@@ -155,9 +132,9 @@ class VideoTask extends Command @@ -155,9 +132,9 @@ class VideoTask extends Command
155 if($rs && ($sub_task_num > 0)){ 132 if($rs && ($sub_task_num > 0)){
156 $sub_task_num--; 133 $sub_task_num--;
157 } 134 }
158 - Cache::put('video_keyword_number',$number++);  
159 } 135 }
160 } 136 }
  137 + Cache::put('video_keyword_number_month',$number + count($keyword),3600);
161 $task_project->status = KeywordVideoTask::STATUS_CLOSE; 138 $task_project->status = KeywordVideoTask::STATUS_CLOSE;
162 $task_project->save(); 139 $task_project->save();
163 } 140 }
@@ -38,7 +38,7 @@ class KeywordVideoTaskLog extends Base @@ -38,7 +38,7 @@ class KeywordVideoTaskLog extends Base
38 $start_date = Carbon::now()->subMonth()->day(13)->format('Y-m-d 00:00:00'); 38 $start_date = Carbon::now()->subMonth()->day(13)->format('Y-m-d 00:00:00');
39 } 39 }
40 $num = self::where('created_at', '>', $start_date)->count(); 40 $num = self::where('created_at', '>', $start_date)->count();
41 - Cache::put($key, $num, 1800); 41 + Cache::put($key, $num, 3600);
42 return $num; 42 return $num;
43 }); 43 });
44 return $num; 44 return $num;