正在显示
1 个修改的文件
包含
64 行增加
和
9 行删除
| @@ -9,7 +9,10 @@ use App\Models\Ai\AiCommand; | @@ -9,7 +9,10 @@ use App\Models\Ai\AiCommand; | ||
| 9 | use App\Models\Domain\DomainInfo; | 9 | use App\Models\Domain\DomainInfo; |
| 10 | use App\Models\Industry\ProjectIndustry; | 10 | use App\Models\Industry\ProjectIndustry; |
| 11 | use App\Models\Industry\ProjectIndustryRelated; | 11 | use App\Models\Industry\ProjectIndustryRelated; |
| 12 | +use App\Models\WebSetting\WebSetting; | ||
| 13 | +use App\Services\ProjectServer; | ||
| 12 | use Illuminate\Console\Command; | 14 | use Illuminate\Console\Command; |
| 15 | +use Illuminate\Support\Facades\DB; | ||
| 13 | 16 | ||
| 14 | class CheckProjectIndustry extends Command | 17 | class CheckProjectIndustry extends Command |
| 15 | { | 18 | { |
| @@ -31,7 +34,13 @@ class CheckProjectIndustry extends Command | @@ -31,7 +34,13 @@ class CheckProjectIndustry extends Command | ||
| 31 | { | 34 | { |
| 32 | $ai_command = AiCommand::where('key', 'project_industry')->value('ai'); | 35 | $ai_command = AiCommand::where('key', 'project_industry')->value('ai'); |
| 33 | if (!$ai_command) { | 36 | if (!$ai_command) { |
| 34 | - $this->output('AI指令未配置'); | 37 | + $this->output('project_industry指令未配置'); |
| 38 | + return; | ||
| 39 | + } | ||
| 40 | + | ||
| 41 | + $ai_command_new = AiCommand::where('key', 'project_industry2')->value('ai'); | ||
| 42 | + if (!$ai_command_new) { | ||
| 43 | + $this->output('project_industry2指令未配置'); | ||
| 35 | return; | 44 | return; |
| 36 | } | 45 | } |
| 37 | 46 | ||
| @@ -55,18 +64,43 @@ class CheckProjectIndustry extends Command | @@ -55,18 +64,43 @@ class CheckProjectIndustry extends Command | ||
| 55 | continue; | 64 | continue; |
| 56 | } | 65 | } |
| 57 | 66 | ||
| 58 | - $project_industry = $this->getIndustryByAI($ai_command, $industry_names, $domain); | 67 | + $is_industry = false; |
| 68 | + $project = ProjectServer::useProject($project_id); | ||
| 69 | + if ($project) { | ||
| 70 | + $webSettingModel = new WebSetting(); | ||
| 71 | + $web_setting = $webSettingModel->read(['project_id' => $project_id], ['title', 'keyword']); | ||
| 72 | + if (isset($web_setting['title']) && $web_setting['title'] && isset($web_setting['keyword']) && $web_setting['keyword']) { | ||
| 73 | + $project_industry = $this->getIndustryByAINew($ai_command_new, $industry_names, $web_setting['title'], $web_setting['keyword']); | ||
| 74 | + if ($project_industry) { | ||
| 75 | + $project_industry_name = Arr::splitFilterToArray($project_industry); | ||
| 76 | + | ||
| 77 | + $project_industry_id = ProjectIndustry::where('status', 1)->whereIn('industry_name', $project_industry_name)->pluck('id')->toArray(); | ||
| 78 | + | ||
| 79 | + ProjectIndustryRelated::saveRelated($project_id, $project_industry_id); | ||
| 80 | + | ||
| 81 | + $is_industry = true; | ||
| 82 | + | ||
| 83 | + $this->output('project_id:' . $project_id . ' , domain:' . $domain . ' | success'); | ||
| 84 | + } | ||
| 85 | + } | ||
| 86 | + | ||
| 87 | + DB::disconnect('custom_mysql'); | ||
| 88 | + } | ||
| 89 | + | ||
| 90 | + if (!$is_industry) { | ||
| 91 | + $project_industry = $this->getIndustryByAI($ai_command, $industry_names, $domain); | ||
| 59 | 92 | ||
| 60 | - if ($project_industry) { | ||
| 61 | - $project_industry_name = Arr::splitFilterToArray($project_industry); | 93 | + if ($project_industry) { |
| 94 | + $project_industry_name = Arr::splitFilterToArray($project_industry); | ||
| 62 | 95 | ||
| 63 | - $project_industry_id = ProjectIndustry::where('status', 1)->whereIn('industry_name', $project_industry_name)->pluck('id')->toArray(); | 96 | + $project_industry_id = ProjectIndustry::where('status', 1)->whereIn('industry_name', $project_industry_name)->pluck('id')->toArray(); |
| 64 | 97 | ||
| 65 | - ProjectIndustryRelated::saveRelated($project_id, $project_industry_id); | 98 | + ProjectIndustryRelated::saveRelated($project_id, $project_industry_id); |
| 66 | 99 | ||
| 67 | - $this->output('project_id:' . $project_id . ' , domain:' . $domain . ' | success'); | ||
| 68 | - } else { | ||
| 69 | - $this->output('project_id:' . $project_id . ' , domain:' . $domain . ' | AI分析行业失败'); | 100 | + $this->output('project_id:' . $project_id . ' , domain:' . $domain . ' | success'); |
| 101 | + } else { | ||
| 102 | + $this->output('project_id:' . $project_id . ' , domain:' . $domain . ' | AI分析行业失败'); | ||
| 103 | + } | ||
| 70 | } | 104 | } |
| 71 | } | 105 | } |
| 72 | } | 106 | } |
| @@ -90,6 +124,27 @@ class CheckProjectIndustry extends Command | @@ -90,6 +124,27 @@ class CheckProjectIndustry extends Command | ||
| 90 | return Common::deal_str($text); | 124 | return Common::deal_str($text); |
| 91 | } | 125 | } |
| 92 | 126 | ||
| 127 | + /** | ||
| 128 | + * AI分析行业2.0 | ||
| 129 | + * @param $ai_command | ||
| 130 | + * @param $industry_names | ||
| 131 | + * @param $title | ||
| 132 | + * @param $keyword | ||
| 133 | + * @return string|string[] | ||
| 134 | + * @author Akun | ||
| 135 | + * @date 2025/08/01 10:10 | ||
| 136 | + */ | ||
| 137 | + public function getIndustryByAINew($ai_command, $industry_names, $title, $keyword) | ||
| 138 | + { | ||
| 139 | + $ai_command = str_replace('{industry}', $industry_names, $ai_command); | ||
| 140 | + $ai_command = str_replace('{title}', $title, $ai_command); | ||
| 141 | + $ai_command = str_replace('{keyword}', $keyword, $ai_command); | ||
| 142 | + | ||
| 143 | + $text = Gpt::instance()->openai_chat_qqs($ai_command); | ||
| 144 | + | ||
| 145 | + return Common::deal_str($text); | ||
| 146 | + } | ||
| 147 | + | ||
| 93 | public function output($msg) | 148 | public function output($msg) |
| 94 | { | 149 | { |
| 95 | echo date('Y-m-d H:i:s') . ' | ' . $msg . PHP_EOL; | 150 | echo date('Y-m-d H:i:s') . ' | ' . $msg . PHP_EOL; |
-
请 注册 或 登录 后发表评论