|
@@ -42,11 +42,12 @@ class AiBlogTask extends Command |
|
@@ -42,11 +42,12 @@ class AiBlogTask extends Command |
|
42
|
public function handle(){
|
42
|
public function handle(){
|
|
43
|
$aiBlogTaskModel = new AiBlogTaskModel();
|
43
|
$aiBlogTaskModel = new AiBlogTaskModel();
|
|
44
|
while (true){
|
44
|
while (true){
|
|
45
|
- $list = $aiBlogTaskModel->list(['status'=>1,'type'=>2, 'created_at' => ['<', date('Y-m-d H:i:s')]],'id',['*'],'asc',1000);
|
45
|
+ $list = $aiBlogTaskModel->formatQuery(['status'=>1,'type'=>2])->inRandomOrder()->limit(1000)->get();
|
|
46
|
if(empty($list)){
|
46
|
if(empty($list)){
|
|
47
|
sleep(300);
|
47
|
sleep(300);
|
|
48
|
continue;
|
48
|
continue;
|
|
49
|
}
|
49
|
}
|
|
|
|
50
|
+ $list = $list->toArray();
|
|
50
|
$updateProject = [];
|
51
|
$updateProject = [];
|
|
51
|
foreach ($list as $item){
|
52
|
foreach ($list as $item){
|
|
52
|
echo '开始->任务id:' . $item['task_id'] . PHP_EOL . date('Y-m-d H:i:s');
|
53
|
echo '开始->任务id:' . $item['task_id'] . PHP_EOL . date('Y-m-d H:i:s');
|
|
@@ -58,6 +59,7 @@ class AiBlogTask extends Command |
|
@@ -58,6 +59,7 @@ class AiBlogTask extends Command |
|
58
|
$aiBlogService->task_id = $item['task_id'];
|
59
|
$aiBlogService->task_id = $item['task_id'];
|
|
59
|
$result = $aiBlogService->getDetail();
|
60
|
$result = $aiBlogService->getDetail();
|
|
60
|
if(!isset($result['status']) || $result['status'] != 200){
|
61
|
if(!isset($result['status']) || $result['status'] != 200){
|
|
|
|
62
|
+ echo json_encode($result).PHP_EOL;
|
|
61
|
sleep(5);
|
63
|
sleep(5);
|
|
62
|
continue;
|
64
|
continue;
|
|
63
|
}
|
65
|
}
|
|
@@ -66,6 +68,7 @@ class AiBlogTask extends Command |
|
@@ -66,6 +68,7 @@ class AiBlogTask extends Command |
|
66
|
$aiBlogModel = new AiBlog();
|
68
|
$aiBlogModel = new AiBlog();
|
|
67
|
$aiBlogInfo = $aiBlogModel->read(['task_id'=>$item['task_id']],['id']);
|
69
|
$aiBlogInfo = $aiBlogModel->read(['task_id'=>$item['task_id']],['id']);
|
|
68
|
if($aiBlogInfo === false){
|
70
|
if($aiBlogInfo === false){
|
|
|
|
71
|
+ echo '任务id不存在:'.$item['task_id'].PHP_EOL;
|
|
69
|
$aiBlogTaskModel->edit(['status'=>2],['id'=>$item['id']]);
|
72
|
$aiBlogTaskModel->edit(['status'=>2],['id'=>$item['id']]);
|
|
70
|
continue;
|
73
|
continue;
|
|
71
|
}
|
74
|
}
|