作者 刘锟

合并分支 'akun' 到 'master'

Akun



查看合并请求 !2473
... ... @@ -9,7 +9,10 @@ use App\Models\Ai\AiCommand;
use App\Models\Domain\DomainInfo;
use App\Models\Industry\ProjectIndustry;
use App\Models\Industry\ProjectIndustryRelated;
use App\Models\WebSetting\WebSetting;
use App\Services\ProjectServer;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
class CheckProjectIndustry extends Command
{
... ... @@ -31,7 +34,13 @@ class CheckProjectIndustry extends Command
{
$ai_command = AiCommand::where('key', 'project_industry')->value('ai');
if (!$ai_command) {
$this->output('AI指令未配置');
$this->output('project_industry指令未配置');
return;
}
$ai_command_new = AiCommand::where('key', 'project_industry2')->value('ai');
if (!$ai_command_new) {
$this->output('project_industry2指令未配置');
return;
}
... ... @@ -55,18 +64,43 @@ class CheckProjectIndustry extends Command
continue;
}
$project_industry = $this->getIndustryByAI($ai_command, $industry_names, $domain);
$is_industry = false;
$project = ProjectServer::useProject($project_id);
if ($project) {
$webSettingModel = new WebSetting();
$web_setting = $webSettingModel->read(['project_id' => $project_id], ['title', 'keyword']);
if (isset($web_setting['title']) && $web_setting['title'] && isset($web_setting['keyword']) && $web_setting['keyword']) {
$project_industry = $this->getIndustryByAINew($ai_command_new, $industry_names, $web_setting['title'], $web_setting['keyword']);
if ($project_industry) {
$project_industry_name = Arr::splitFilterToArray($project_industry);
$project_industry_id = ProjectIndustry::where('status', 1)->whereIn('industry_name', $project_industry_name)->pluck('id')->toArray();
ProjectIndustryRelated::saveRelated($project_id, $project_industry_id);
$is_industry = true;
$this->output('project_id:' . $project_id . ' , domain:' . $domain . ' | success');
}
}
DB::disconnect('custom_mysql');
}
if (!$is_industry) {
$project_industry = $this->getIndustryByAI($ai_command, $industry_names, $domain);
if ($project_industry) {
$project_industry_name = Arr::splitFilterToArray($project_industry);
if ($project_industry) {
$project_industry_name = Arr::splitFilterToArray($project_industry);
$project_industry_id = ProjectIndustry::where('status', 1)->whereIn('industry_name', $project_industry_name)->pluck('id')->toArray();
$project_industry_id = ProjectIndustry::where('status', 1)->whereIn('industry_name', $project_industry_name)->pluck('id')->toArray();
ProjectIndustryRelated::saveRelated($project_id, $project_industry_id);
ProjectIndustryRelated::saveRelated($project_id, $project_industry_id);
$this->output('project_id:' . $project_id . ' , domain:' . $domain . ' | success');
} else {
$this->output('project_id:' . $project_id . ' , domain:' . $domain . ' | AI分析行业失败');
$this->output('project_id:' . $project_id . ' , domain:' . $domain . ' | success');
} else {
$this->output('project_id:' . $project_id . ' , domain:' . $domain . ' | AI分析行业失败');
}
}
}
}
... ... @@ -90,6 +124,27 @@ class CheckProjectIndustry extends Command
return Common::deal_str($text);
}
/**
* AI分析行业2.0
* @param $ai_command
* @param $industry_names
* @param $title
* @param $keyword
* @return string|string[]
* @author Akun
* @date 2025/08/01 10:10
*/
public function getIndustryByAINew($ai_command, $industry_names, $title, $keyword)
{
$ai_command = str_replace('{industry}', $industry_names, $ai_command);
$ai_command = str_replace('{title}', $title, $ai_command);
$ai_command = str_replace('{keyword}', $keyword, $ai_command);
$text = Gpt::instance()->openai_chat_qqs($ai_command);
return Common::deal_str($text);
}
public function output($msg)
{
echo date('Y-m-d H:i:s') . ' | ' . $msg . PHP_EOL;
... ...