正在显示
1 个修改的文件
包含
24 行增加
和
1 行删除
| @@ -51,11 +51,12 @@ class GeneratePage extends Command | @@ -51,11 +51,12 @@ class GeneratePage extends Command | ||
| 51 | { | 51 | { |
| 52 | $noticeModel = new NoticeLog(); | 52 | $noticeModel = new NoticeLog(); |
| 53 | while (true){ | 53 | while (true){ |
| 54 | - $noticeInfo = $noticeModel->read(['status'=>0,'type'=>$noticeModel::GENERATE_PAGE,'start_at'=>['<=',date('Y-m-d H:i:s')]]); | 54 | + $task_id = $this->getTaskId(); |
| 55 | if (empty($noticeInfo)) { | 55 | if (empty($noticeInfo)) { |
| 56 | sleep(10); | 56 | sleep(10); |
| 57 | continue; | 57 | continue; |
| 58 | } | 58 | } |
| 59 | + $noticeInfo = $noticeModel->read(['id'=>$task_id]); | ||
| 59 | try { | 60 | try { |
| 60 | $this->output(' taskID: ' . $noticeInfo['id'] . ' start'); | 61 | $this->output(' taskID: ' . $noticeInfo['id'] . ' start'); |
| 61 | $notice_data = json_decode($noticeInfo['data'],true); | 62 | $notice_data = json_decode($noticeInfo['data'],true); |
| @@ -80,6 +81,28 @@ class GeneratePage extends Command | @@ -80,6 +81,28 @@ class GeneratePage extends Command | ||
| 80 | return true; | 81 | return true; |
| 81 | } | 82 | } |
| 82 | 83 | ||
| 84 | + /** | ||
| 85 | + * @remark :获取任务id | ||
| 86 | + * @name :getTaskId | ||
| 87 | + * @author :lyh | ||
| 88 | + * @method :post | ||
| 89 | + * @time :2025/6/19 10:02 | ||
| 90 | + */ | ||
| 91 | + public function getTaskId() | ||
| 92 | + { | ||
| 93 | + $task_id = Redis::rpop('generate_page_id'); | ||
| 94 | + if (empty($task_id)) { | ||
| 95 | + $noticeModel = new NoticeLog(); | ||
| 96 | + $ids = $noticeModel->selectField(['status'=>0],'id'); | ||
| 97 | + if(!empty($ids)){ | ||
| 98 | + foreach ($ids as $id) { | ||
| 99 | + Redis::lpush('generate_page_id', $id); | ||
| 100 | + } | ||
| 101 | + } | ||
| 102 | + $task_id = Redis::rpop('generate_page_id'); | ||
| 103 | + } | ||
| 104 | + return $task_id; | ||
| 105 | + } | ||
| 83 | 106 | ||
| 84 | /** | 107 | /** |
| 85 | * 输出message | 108 | * 输出message |
-
请 注册 或 登录 后发表评论