正在显示
1 个修改的文件
包含
11 行增加
和
12 行删除
| @@ -149,7 +149,7 @@ class UpdateSeoTdk extends Command | @@ -149,7 +149,7 @@ class UpdateSeoTdk extends Command | ||
| 149 | echo date('Y-m-d H:i:s') . 'line: '. $e->getLine() .' error: ' . $project_id . '->' . $e->getMessage() . PHP_EOL; | 149 | echo date('Y-m-d H:i:s') . 'line: '. $e->getLine() .' error: ' . $project_id . '->' . $e->getMessage() . PHP_EOL; |
| 150 | ProjectUpdateTdk::retry($task->id, $e->getMessage()); | 150 | ProjectUpdateTdk::retry($task->id, $e->getMessage()); |
| 151 | } | 151 | } |
| 152 | - echo date('Y-m-d H:i:s') . ' end: ' . $project_id . PHP_EOL; | 152 | + echo date('Y-m-d H:i:s') . ' end project_id: ' . $project_id . PHP_EOL; |
| 153 | } | 153 | } |
| 154 | } | 154 | } |
| 155 | 155 | ||
| @@ -162,18 +162,24 @@ class UpdateSeoTdk extends Command | @@ -162,18 +162,24 @@ class UpdateSeoTdk extends Command | ||
| 162 | $ai_commands = Arr::setValueToKey($ai_commands, 'key'); | 162 | $ai_commands = Arr::setValueToKey($ai_commands, 'key'); |
| 163 | foreach ($this->maps as $table => $map) { | 163 | foreach ($this->maps as $table => $map) { |
| 164 | $update[$table] = ['total_page'=>0, 'title'=>0, 'keyword'=>0, 'des'=>0]; | 164 | $update[$table] = ['total_page'=>0, 'title'=>0, 'keyword'=>0, 'des'=>0]; |
| 165 | - echo date('Y-m-d H:i:s') . '更新--' . $table . ': 项目id' . $project_id . PHP_EOL . json_encode($update[$table]); | 165 | + echo date('Y-m-d H:i:s') . '更新--' . $table . ': 项目id' . $project_id . PHP_EOL; |
| 166 | $list = DB::connection('custom_mysql')->table($table)->get(); | 166 | $list = DB::connection('custom_mysql')->table($table)->get(); |
| 167 | if (!empty($list)) { | 167 | if (!empty($list)) { |
| 168 | $list = $list->toArray(); | 168 | $list = $list->toArray(); |
| 169 | foreach ($list as $v) { | 169 | foreach ($list as $v) { |
| 170 | - echo '打印数据:'.date('Y-m-d H:i:s') . $update[$table]['total_page'].PHP_EOL; | ||
| 171 | $update[$table]['total_page']++; | 170 | $update[$table]['total_page']++; |
| 172 | $v = (array)$v; | 171 | $v = (array)$v; |
| 173 | - echo date('Y-m-d H:i:s') . '更新--' . $table . ':id' . $v['id'] . PHP_EOL; | 172 | + echo date('Y-m-d H:i:s') . '更新--' . $table . ': 项目id' . $project_id . ':id' . $v['id'] . PHP_EOL; |
| 173 | + | ||
| 174 | + //缓存 在处理的 项目 数据 id | ||
| 175 | + $cache_key = "seo_tdk_{$project_id}_{$table}_{$v['id']}"; | ||
| 176 | + if(Cache::get($cache_key)){ | ||
| 177 | + echo '其他进程在处理' . PHP_EOL; | ||
| 178 | + continue; | ||
| 179 | + } | ||
| 180 | + | ||
| 174 | $data = []; | 181 | $data = []; |
| 175 | $json_field = ''; | 182 | $json_field = ''; |
| 176 | - echo date('Y-m-d H:i:s') . json_encode($map) . PHP_EOL; | ||
| 177 | foreach ($map as $ai_key => $field) { | 183 | foreach ($map as $ai_key => $field) { |
| 178 | $field_arr = explode('.', $field); | 184 | $field_arr = explode('.', $field); |
| 179 | if (count($field_arr) > 1) { | 185 | if (count($field_arr) > 1) { |
| @@ -188,12 +194,6 @@ class UpdateSeoTdk extends Command | @@ -188,12 +194,6 @@ class UpdateSeoTdk extends Command | ||
| 188 | continue; | 194 | continue; |
| 189 | } | 195 | } |
| 190 | 196 | ||
| 191 | - //缓存 在处理的 项目 数据 id | ||
| 192 | - $cache_key = "seo_tdk_{$project_id}_{$table}_{$v['id']}"; | ||
| 193 | - if(Cache::get($cache_key)){ | ||
| 194 | - echo '其他进程在处理' . PHP_EOL; | ||
| 195 | - continue; | ||
| 196 | - } | ||
| 197 | Cache::put($cache_key, 1, 120); | 197 | Cache::put($cache_key, 1, 120); |
| 198 | 198 | ||
| 199 | //AI生成 | 199 | //AI生成 |
| @@ -375,7 +375,6 @@ class UpdateSeoTdk extends Command | @@ -375,7 +375,6 @@ class UpdateSeoTdk extends Command | ||
| 375 | public function ai_send($prompt) | 375 | public function ai_send($prompt) |
| 376 | { | 376 | { |
| 377 | $text = Gpt::instance()->openai_chat_qqs($prompt); | 377 | $text = Gpt::instance()->openai_chat_qqs($prompt); |
| 378 | - echo 'GPT result:' . $text . PHP_EOL; | ||
| 379 | $text = Common::deal_keywords($text); | 378 | $text = Common::deal_keywords($text); |
| 380 | return Common::deal_str($text); | 379 | return Common::deal_str($text); |
| 381 | } | 380 | } |
-
请 注册 或 登录 后发表评论