作者 lyh

gx数据

... ... @@ -42,11 +42,12 @@ class AiBlogTask extends Command
public function handle(){
$aiBlogTaskModel = new AiBlogTaskModel();
while (true){
$list = $aiBlogTaskModel->list(['status'=>1,'type'=>2, 'created_at' => ['<', date('Y-m-d H:i:s')]],'id',['*'],'asc',1000);
$list = $aiBlogTaskModel->formatQuery(['status'=>1,'type'=>2])->inRandomOrder()->limit(1000)->get();
if(empty($list)){
sleep(300);
continue;
}
$list = $list->toArray();
$updateProject = [];
foreach ($list as $item){
echo '开始->任务id:' . $item['task_id'] . PHP_EOL . date('Y-m-d H:i:s');
... ... @@ -58,6 +59,7 @@ class AiBlogTask extends Command
$aiBlogService->task_id = $item['task_id'];
$result = $aiBlogService->getDetail();
if(!isset($result['status']) || $result['status'] != 200){
echo json_encode($result).PHP_EOL;
sleep(5);
continue;
}
... ... @@ -66,6 +68,7 @@ class AiBlogTask extends Command
$aiBlogModel = new AiBlog();
$aiBlogInfo = $aiBlogModel->read(['task_id'=>$item['task_id']],['id']);
if($aiBlogInfo === false){
echo '任务id不存在:'.$item['task_id'].PHP_EOL;
$aiBlogTaskModel->edit(['status'=>2],['id'=>$item['id']]);
continue;
}
... ...
... ... @@ -70,6 +70,28 @@ class Base extends Model
}
/**
* @remark :随机获取数据
* @name :limit_list
* @author :lyh
* @method :post
* @time :2025/3/17 17:26
*/
public function limit_list($map = [],$order = 'id',$fields = ['*'],$sort = 'desc',$row = 0): array
{
$query = $this->formatQuery($map);
if($row != 0){
$query = $query->limit($row);
}
$query = $this->sortOrder($query,$order,$sort);
$lists = $query->select($fields)->get();
if (empty($lists)) {
return [];
}
$lists = $lists->toArray();
return $lists;
}
/**
* @remark :获取数据详情
* @name :read
* @author :lyh
... ...