作者 赵彬吉

update

... ... @@ -149,7 +149,7 @@ class UpdateSeoTdk extends Command
echo date('Y-m-d H:i:s') . 'line: '. $e->getLine() .' error: ' . $project_id . '->' . $e->getMessage() . PHP_EOL;
ProjectUpdateTdk::retry($task->id, $e->getMessage());
}
echo date('Y-m-d H:i:s') . ' end: ' . $project_id . PHP_EOL;
echo date('Y-m-d H:i:s') . ' end project_id: ' . $project_id . PHP_EOL;
}
}
... ... @@ -162,18 +162,24 @@ class UpdateSeoTdk extends Command
$ai_commands = Arr::setValueToKey($ai_commands, 'key');
foreach ($this->maps as $table => $map) {
$update[$table] = ['total_page'=>0, 'title'=>0, 'keyword'=>0, 'des'=>0];
echo date('Y-m-d H:i:s') . '更新--' . $table . ': 项目id' . $project_id . PHP_EOL . json_encode($update[$table]);
echo date('Y-m-d H:i:s') . '更新--' . $table . ': 项目id' . $project_id . PHP_EOL;
$list = DB::connection('custom_mysql')->table($table)->get();
if (!empty($list)) {
$list = $list->toArray();
foreach ($list as $v) {
echo '打印数据:'.date('Y-m-d H:i:s') . $update[$table]['total_page'].PHP_EOL;
$update[$table]['total_page']++;
$v = (array)$v;
echo date('Y-m-d H:i:s') . '更新--' . $table . ':id' . $v['id'] . PHP_EOL;
echo date('Y-m-d H:i:s') . '更新--' . $table . ': 项目id' . $project_id . ':id' . $v['id'] . PHP_EOL;
//缓存 在处理的 项目 数据 id
$cache_key = "seo_tdk_{$project_id}_{$table}_{$v['id']}";
if(Cache::get($cache_key)){
echo '其他进程在处理' . PHP_EOL;
continue;
}
$data = [];
$json_field = '';
echo date('Y-m-d H:i:s') . json_encode($map) . PHP_EOL;
foreach ($map as $ai_key => $field) {
$field_arr = explode('.', $field);
if (count($field_arr) > 1) {
... ... @@ -188,12 +194,6 @@ class UpdateSeoTdk extends Command
continue;
}
//缓存 在处理的 项目 数据 id
$cache_key = "seo_tdk_{$project_id}_{$table}_{$v['id']}";
if(Cache::get($cache_key)){
echo '其他进程在处理' . PHP_EOL;
continue;
}
Cache::put($cache_key, 1, 120);
//AI生成
... ... @@ -375,7 +375,6 @@ class UpdateSeoTdk extends Command
public function ai_send($prompt)
{
$text = Gpt::instance()->openai_chat_qqs($prompt);
echo 'GPT result:' . $text . PHP_EOL;
$text = Common::deal_keywords($text);
return Common::deal_str($text);
}
... ...