作者 赵彬吉

update

@@ -178,7 +178,7 @@ class UpdateSeoTdk extends Command @@ -178,7 +178,7 @@ class UpdateSeoTdk extends Command
178 Cache::put($cache_key, 1, 120); 178 Cache::put($cache_key, 1, 120);
179 179
180 echo date('Y-m-d H:i:s') . '更新--' . $table . ': 项目id' . $project_id . ':id' . $v['id'] . PHP_EOL; 180 echo date('Y-m-d H:i:s') . '更新--' . $table . ': 项目id' . $project_id . ':id' . $v['id'] . PHP_EOL;
181 - 181 +
182 $data = []; 182 $data = [];
183 $json_field = ''; 183 $json_field = '';
184 foreach ($map as $ai_key => $field) { 184 foreach ($map as $ai_key => $field) {
@@ -306,8 +306,6 @@ class UpdateSeoTdk extends Command @@ -306,8 +306,6 @@ class UpdateSeoTdk extends Command
306 } 306 }
307 $prompt .= '.Please answer in ' . ($lang ?: 'English'); 307 $prompt .= '.Please answer in ' . ($lang ?: 'English');
308 308
309 - echo $prompt . PHP_EOL;  
310 -  
311 return $prompt; 309 return $prompt;
312 } 310 }
313 311
@@ -13,6 +13,7 @@ use App\Helper\Arr; @@ -13,6 +13,7 @@ use App\Helper\Arr;
13 use App\Models\Base; 13 use App\Models\Base;
14 use Illuminate\Support\Facades\DB; 14 use Illuminate\Support\Facades\DB;
15 use Illuminate\Support\Facades\Log; 15 use Illuminate\Support\Facades\Log;
  16 +use Illuminate\Support\Facades\Redis;
16 17
17 class ProjectUpdateTdk extends Base 18 class ProjectUpdateTdk extends Base
18 { 19 {
@@ -30,6 +31,7 @@ class ProjectUpdateTdk extends Base @@ -30,6 +31,7 @@ class ProjectUpdateTdk extends Base
30 * @date 2023/11/9 31 * @date 2023/11/9
31 */ 32 */
32 public static function add_task($project_id){ 33 public static function add_task($project_id){
  34 + Redis::lpush('updateSeoTdk', $project_id);
33 $model = new self(); 35 $model = new self();
34 $model->project_id = $project_id; 36 $model->project_id = $project_id;
35 $model->save(); 37 $model->save();
@@ -42,6 +44,15 @@ class ProjectUpdateTdk extends Base @@ -42,6 +44,15 @@ class ProjectUpdateTdk extends Base
42 * @date 2023/11/9 44 * @date 2023/11/9
43 */ 45 */
44 public static function getPendingTask(){ 46 public static function getPendingTask(){
  47 + //有其他任务 就取其他任务 没有其他任务运行未结束的任务
  48 + $project_id = Redis::rpop('updateSeoTdk');
  49 + $data = [];
  50 + if($project_id){
  51 + $data = self::find($project_id);
  52 + }
  53 + if($data){
  54 + return $data;
  55 + }
45 return self::where('status', self::STATUS_PENDING)->orderBy('id', 'asc')->first(); 56 return self::where('status', self::STATUS_PENDING)->orderBy('id', 'asc')->first();
46 } 57 }
47 58