作者 lyh

gx ai视频

@@ -79,6 +79,7 @@ class AiBlogAuthorTask extends Command @@ -79,6 +79,7 @@ class AiBlogAuthorTask extends Command
79 ProjectServer::useProject($info['project_id']); 79 ProjectServer::useProject($info['project_id']);
80 $this->saveAiBlogAuthor($result['data'] ?? [],$info['project_id']); 80 $this->saveAiBlogAuthor($result['data'] ?? [],$info['project_id']);
81 RouteMap::setRoute('top-blog',RouteMap::SOURCE_AI_BLOG_LIST,0,$info['project_id']);//写一条列表页路由 81 RouteMap::setRoute('top-blog',RouteMap::SOURCE_AI_BLOG_LIST,0,$info['project_id']);//写一条列表页路由
  82 + RouteMap::setRoute('top-video',RouteMap::SOURCE_AI_VIDEO_LIST,0,$info['project_id']);//写一条列表页路由
82 DB::disconnect('custom_mysql'); 83 DB::disconnect('custom_mysql');
83 //修改任务状态 84 //修改任务状态
84 $aiBlogTaskModel->edit(['status'=>2],['id'=>$info['id']]); 85 $aiBlogTaskModel->edit(['status'=>2],['id'=>$info['id']]);
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :AiBlogTask.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2025/2/14 11:14
  8 + */
  9 +
  10 +namespace App\Console\Commands\Ai;
  11 +
  12 +use App\Models\Ai\AiBlog;
  13 +use App\Models\Ai\AiBlogAuthor;
  14 +use App\Models\Ai\AiBlogList;
  15 +use App\Models\Ai\AiVideoList;
  16 +use App\Models\Domain\DomainInfo;
  17 +use App\Models\Project\ProjectAiSetting;
  18 +use App\Models\RouteMap\RouteMap;
  19 +use App\Services\AiBlogService;
  20 +use App\Services\AiVideoService;
  21 +use App\Services\ProjectServer;
  22 +use Illuminate\Console\Command;
  23 +use App\Models\Project\AiBlogTask as AiBlogTaskModel;
  24 +use Illuminate\Support\Facades\Cache;
  25 +use Illuminate\Support\Facades\DB;
  26 +use function Symfony\Component\String\s;
  27 +
  28 +/***
  29 + * @remark :根据项目更新blog列表
  30 + * @name :AiBlogListTask
  31 + * @author :lyh
  32 + * @method :post
  33 + * @time :2025/3/6 9:45
  34 + */
  35 +class AiVideoListTask extends Command
  36 +{
  37 + /**
  38 + * The name and signature of the console command.
  39 + *
  40 + * @var string
  41 + */
  42 + protected $signature = 'save_ai_video_list {project_id}';
  43 +
  44 + /**
  45 + * The console command description.
  46 + *
  47 + * @var string
  48 + */
  49 + protected $description = '生成video列表';
  50 +
  51 + public function handle(){
  52 + $project_id = $this->argument('project_id');
  53 + @file_put_contents(storage_path('logs/lyh_error.log'), var_export('执行的项目id->'.$project_id, true) . PHP_EOL, FILE_APPEND);
  54 + ProjectServer::useProject($project_id);
  55 + $this->updateBlogList($project_id);
  56 +// $this->curlDelRoute($project_id);
  57 + DB::disconnect('custom_mysql');
  58 + return true;
  59 + }
  60 +
  61 + /**
  62 + * @remark :更新列表页数据
  63 + * @name :updateBlogList
  64 + * @author :lyh
  65 + * @method :post
  66 + * @time :2025/3/5 11:07
  67 + */
  68 + public function updateBlogList($project_id){
  69 + $aiVideoService = new AiVideoService($project_id);
  70 + $page = 1;
  71 + $saveData = [];
  72 + $result = $aiVideoService->getAiVideoList($page,15);
  73 + if(!isset($result['status']) && $result['status'] != 200){
  74 + return true;
  75 + }
  76 + $total_page = $result['data']['total_page'];
  77 + //组装数据保存
  78 + $saveData[] = [
  79 + 'route'=>$page,
  80 + 'text'=>$result['data']['section'],
  81 + ];
  82 + while ($total_page > $page){
  83 + $page++;
  84 + $result = $aiVideoService->getAiVideoList($page,15);
  85 + if(isset($result['status']) && $result['status'] == 200){
  86 + $saveData[] = [
  87 + 'route'=>$page,
  88 + 'text'=>$result['data']['section'],
  89 + ];
  90 + }
  91 + }
  92 + $aiVideoListModel = new AiVideoList();
  93 + if(!empty($saveData)){
  94 + //写一条路由信息
  95 + $aiVideoListModel->truncate();
  96 + $aiVideoListModel->insertAll($saveData);
  97 + }
  98 + return true;
  99 + }
  100 +
  101 + /**
  102 + * @remark :通知C端生成界面
  103 + * @name :sendNotice
  104 + * @author :lyh
  105 + * @method :post
  106 + * @time :2025/3/6 11:51
  107 + */
  108 + public function curlDelRoute($project_id){
  109 + $domainModel = new DomainInfo();
  110 + //获取项目域名
  111 + $domain = $domainModel->getProjectIdDomain($project_id);
  112 + if(!empty($domain)){
  113 + $c_url = $domain.'api/update_page/';
  114 + $param = [
  115 + 'project_id' => $project_id,
  116 + 'type' => 1,
  117 + 'route' => 3,
  118 + 'url' => ['top-blog'],
  119 + 'language'=> [],
  120 + 'is_sitemap' => 0
  121 + ];
  122 + http_post($c_url, json_encode($param));
  123 + }
  124 + return true;
  125 + }
  126 +}
@@ -90,11 +90,12 @@ class AfterDayCount extends Command @@ -90,11 +90,12 @@ class AfterDayCount extends Command
90 ->whereRaw("FIND_IN_SET('7', gl_project_deploy_optimize.special) = 0 AND FIND_IN_SET('8', gl_project_deploy_optimize.special) = 0") 90 ->whereRaw("FIND_IN_SET('7', gl_project_deploy_optimize.special) = 0 AND FIND_IN_SET('8', gl_project_deploy_optimize.special) = 0")
91 ->count(); 91 ->count();
92 $rate = number_format($qualified_count / $project_count, 2); 92 $rate = number_format($qualified_count / $project_count, 2);
93 - $threeMonthsAgo = date('Y-m-d 00:00:00', strtotime('-3 months')); 93 + $threeMonthsAgo = date('Y-m-d', strtotime('-3 months'));
94 $three_project_count = $projectModel->where('gl_project.extend_type',0) 94 $three_project_count = $projectModel->where('gl_project.extend_type',0)
95 ->where('gl_project.delete_status',0) 95 ->where('gl_project.delete_status',0)
96 ->where('gl_project.old_project_id',0) 96 ->where('gl_project.old_project_id',0)
97 - ->where('gl_project.created_at','<=',$threeMonthsAgo) 97 + ->where('gl_project.created_at','>=',$threeMonthsAgo.' 00:00:00')
  98 + ->where('gl_project.created_at','<=',$threeMonthsAgo.' 23:59:59')
98 ->whereIn('gl_project_deploy_optimize.optimist_mid',$idArr) 99 ->whereIn('gl_project_deploy_optimize.optimist_mid',$idArr)
99 ->whereIn('gl_project.type',[2,4]) 100 ->whereIn('gl_project.type',[2,4])
100 ->leftJoin('gl_project_deploy_optimize', 'gl_project.id', '=', 'gl_project_deploy_optimize.project_id') 101 ->leftJoin('gl_project_deploy_optimize', 'gl_project.id', '=', 'gl_project_deploy_optimize.project_id')
@@ -105,7 +106,8 @@ class AfterDayCount extends Command @@ -105,7 +106,8 @@ class AfterDayCount extends Command
105 ->whereIn('gl_project.id',$projectIdArr) 106 ->whereIn('gl_project.id',$projectIdArr)
106 ->where('gl_project.delete_status',0) 107 ->where('gl_project.delete_status',0)
107 ->where('gl_project.old_project_id',0) 108 ->where('gl_project.old_project_id',0)
108 - ->where('gl_project.created_at','<=',$threeMonthsAgo) 109 + ->where('gl_project.created_at','>=',$threeMonthsAgo.' 00:00:00')
  110 + ->where('gl_project.created_at','<=',$threeMonthsAgo.' 23:59:59')
109 ->whereIn('gl_project_deploy_optimize.optimist_mid',$idArr) 111 ->whereIn('gl_project_deploy_optimize.optimist_mid',$idArr)
110 ->whereIn('gl_project.type',[2,4]) 112 ->whereIn('gl_project.type',[2,4])
111 ->where('gl_project_deploy_build.plan','!=',0) 113 ->where('gl_project_deploy_build.plan','!=',0)
@@ -124,7 +126,7 @@ class AfterDayCount extends Command @@ -124,7 +126,7 @@ class AfterDayCount extends Command
124 ->leftJoin('gl_project_deploy_optimize', 'gl_project.id', '=', 'gl_project_deploy_optimize.project_id') 126 ->leftJoin('gl_project_deploy_optimize', 'gl_project.id', '=', 'gl_project_deploy_optimize.project_id')
125 ->whereRaw("FIND_IN_SET('2', gl_project.level) = 0 AND FIND_IN_SET('3', gl_project.level) = 0") 127 ->whereRaw("FIND_IN_SET('2', gl_project.level) = 0 AND FIND_IN_SET('3', gl_project.level) = 0")
126 ->whereRaw("FIND_IN_SET('7', gl_project_deploy_optimize.special) = 0 AND FIND_IN_SET('8', gl_project_deploy_optimize.special) = 0") 128 ->whereRaw("FIND_IN_SET('7', gl_project_deploy_optimize.special) = 0 AND FIND_IN_SET('8', gl_project_deploy_optimize.special) = 0")
127 - ->pluck('gl_project.title')->toArray(); 129 + ->select(['gl_project.title','gl_project.finish_remain_day','gl_project_deploy_optimize.start_date'])->get()->toArray();
128 $saveData[] = [ 130 $saveData[] = [
129 'date'=>date('Y-m-d', strtotime('yesterday')), 131 'date'=>date('Y-m-d', strtotime('yesterday')),
130 'type'=> $key, 132 'type'=> $key,
@@ -37,6 +37,7 @@ class RouteMap extends Base @@ -37,6 +37,7 @@ class RouteMap extends Base
37 const SOURCE_AI_VIDEO = 'ai_video'; 37 const SOURCE_AI_VIDEO = 'ai_video';
38 const SOURCE_AI_BLOG_AUTHOR = 'ai_blog_author';//ai博客作者 38 const SOURCE_AI_BLOG_AUTHOR = 'ai_blog_author';//ai博客作者
39 const SOURCE_AI_BLOG_LIST = 'ai_blog_list'; 39 const SOURCE_AI_BLOG_LIST = 'ai_blog_list';
  40 + const SOURCE_AI_VIDEO_LIST = 'ai_blog_video';
40 //自定义模块分类 41 //自定义模块分类
41 const SOURCE_MODULE_CATE = 'module_category'; 42 const SOURCE_MODULE_CATE = 'module_category';
42 43