作者 lyh

gx

@@ -5,8 +5,12 @@ @@ -5,8 +5,12 @@
5 * Date: 2024/02/26 5 * Date: 2024/02/26
6 * Time: 10:13 6 * Time: 10:13
7 */ 7 */
8 -namespace App\Console\Commands; 8 +namespace App\Console\Commands\KeywordInVideo;
9 9
  10 +use App\Console\Commands\Model;
  11 +use App\Console\Commands\TaskSub;
  12 +use App\Models\Com\KeywordVideoTask;
  13 +use App\Models\Com\KeywordVideoTaskLog;
10 use App\Models\Product\Keyword; 14 use App\Models\Product\Keyword;
11 use App\Services\ProjectServer; 15 use App\Services\ProjectServer;
12 use Illuminate\Console\Command; 16 use Illuminate\Console\Command;
@@ -20,7 +24,7 @@ class VideoTask extends Command @@ -20,7 +24,7 @@ class VideoTask extends Command
20 * 24 *
21 * @var string 25 * @var string
22 */ 26 */
23 - protected $signature = 'VideoTask'; 27 + protected $signature = 'video_task';
24 28
25 /** 29 /**
26 * The console command description. 30 * The console command description.
@@ -65,40 +69,39 @@ class VideoTask extends Command @@ -65,40 +69,39 @@ class VideoTask extends Command
65 { 69 {
66 $sub_task_num = $this->max_sub_task; 70 $sub_task_num = $this->max_sub_task;
67 while (true) { 71 while (true) {
68 - if ($sub_task_num <= 0) 72 + if ($sub_task_num <= 0){
69 break; 73 break;
70 -  
71 - $task_project = Model::where(['status' => Model::STATUS_OPEN])->orderBy('sort', 'desc')->first();  
72 - if (empty($task_project)) 74 + }
  75 + $task_project = KeywordVideoTask::where(['status' => KeywordVideoTask::STATUS_OPEN])->orderBy('sort', 'desc')->first();
  76 + if (empty($task_project)){
73 break; 77 break;
74 -  
75 - $project = ProjectServer::useProject($task_project->project_id); 78 + }
  79 + ProjectServer::useProject($task_project->project_id);
76 $keyword = $this->getProjectKeyword(); 80 $keyword = $this->getProjectKeyword();
77 // 已经没有需要生成视频的关键词 81 // 已经没有需要生成视频的关键词
78 if (FALSE == $keyword->isEmpty()) { 82 if (FALSE == $keyword->isEmpty()) {
79 - $task_project->status = Model::STATUS_CLOSE; 83 + $task_project->status = KeywordVideoTask::STATUS_CLOSE;
80 $task_project->save(); 84 $task_project->save();
81 continue; 85 continue;
82 } 86 }
83 -  
84 foreach ($keyword as $val) { 87 foreach ($keyword as $val) {
85 - $log = TaskSub::where(['project_id' => $task_project->project_id, 'keyword_id' => $val->id])->first();  
86 - if ($log) 88 + $log = KeywordVideoTaskLog::where(['project_id' => $task_project->project_id, 'keyword_id' => $val->id])->first();
  89 + if ($log){
87 continue; 90 continue;
88 - 91 + }
89 $array = [ 92 $array = [
90 'project_id' => $task_project->project_id, 93 'project_id' => $task_project->project_id,
91 'keyword_id' => $val->id, 94 'keyword_id' => $val->id,
92 'keyword' => $val->title, 95 'keyword' => $val->title,
93 'data' => json_encode(['url' => '', 'description' => '', 'images' => [], 'keywords' => []]), 96 'data' => json_encode(['url' => '', 'description' => '', 'images' => [], 'keywords' => []]),
94 - 'status' => TaskSub::STATUS_INIT, 97 + 'status' => KeywordVideoTaskLog::STATUS_INIT,
95 'updated_at' => date('Y-m-d H:i:s'), 98 'updated_at' => date('Y-m-d H:i:s'),
96 'created_at' => date('Y-m-d H:i:s'), 99 'created_at' => date('Y-m-d H:i:s'),
97 ]; 100 ];
98 - TaskSub::insert($array); 101 + KeywordVideoTaskLog::insert($array);
99 $sub_task_num--; 102 $sub_task_num--;
100 } 103 }
101 - $task_project->status = Model::STATUS_CLOSE; 104 + $task_project->status = KeywordVideoTask::STATUS_CLOSE;
102 $task_project->save(); 105 $task_project->save();
103 } 106 }
104 return true; 107 return true;
@@ -110,7 +113,7 @@ class VideoTask extends Command @@ -110,7 +113,7 @@ class VideoTask extends Command
110 */ 113 */
111 public function sendSubTask() 114 public function sendSubTask()
112 { 115 {
113 - $subTask = TaskSub::where(['status' => TaskSub::STATUS_INIT])->orderBy('id', 'asc')->limit($this->max_sub_task)->get(); 116 + $subTask = KeywordVideoTaskLog::where(['status' => TaskSub::STATUS_INIT])->orderBy('id', 'asc')->limit($this->max_sub_task)->get();
114 if ($subTask->isEmpty()) 117 if ($subTask->isEmpty())
115 return true; 118 return true;
116 foreach ($subTask as $val) { 119 foreach ($subTask as $val) {
@@ -129,7 +132,7 @@ class VideoTask extends Command @@ -129,7 +132,7 @@ class VideoTask extends Command
129 $result = Http::post('http://216.250.255.116:7866/create_task', $data); 132 $result = Http::post('http://216.250.255.116:7866/create_task', $data);
130 133
131 $val->task_id = $task_id; 134 $val->task_id = $task_id;
132 - $val->status = TaskSub::STATUS_RUNING; 135 + $val->status = STATUS_RUNING::STATUS_RUNING;
133 $val->request_result = $result; 136 $val->request_result = $result;
134 $val->save(); 137 $val->save();
135 } 138 }
1 <?php 1 <?php
2 /** 2 /**
3 * @remark : 3 * @remark :
4 - * @name :KeywordController.php 4 + * @name :KeywordVideoController.php
5 * @author :lyh 5 * @author :lyh
6 * @method :post 6 * @method :post
7 * @time :2024/2/26 9:23 7 * @time :2024/2/26 9:23
@@ -11,9 +11,9 @@ namespace App\Http\Controllers\Aside\Com; @@ -11,9 +11,9 @@ namespace App\Http\Controllers\Aside\Com;
11 11
12 use App\Enums\Common\Code; 12 use App\Enums\Common\Code;
13 use App\Http\Controllers\Aside\BaseController; 13 use App\Http\Controllers\Aside\BaseController;
14 -use App\Models\Com\PromotionKeyword; 14 +use App\Models\Com\KeywordVideoTask;
15 15
16 -class KeywordController extends BaseController 16 +class KeywordVideoController extends BaseController
17 { 17 {
18 /** 18 /**
19 * @remark :任务列表 19 * @remark :任务列表
@@ -23,7 +23,7 @@ class KeywordController extends BaseController @@ -23,7 +23,7 @@ class KeywordController extends BaseController
23 * @time :2024/2/26 11:36 23 * @time :2024/2/26 11:36
24 */ 24 */
25 public function lists(){ 25 public function lists(){
26 - $keywordModel = new PromotionKeyword(); 26 + $keywordModel = new KeywordVideoTask();
27 $lists = $keywordModel->lists($this->map,$this->page,$this->row); 27 $lists = $keywordModel->lists($this->map,$this->page,$this->row);
28 $this->response('success',Code::SUCCESS,$lists); 28 $this->response('success',Code::SUCCESS,$lists);
29 } 29 }
@@ -43,7 +43,7 @@ class KeywordController extends BaseController @@ -43,7 +43,7 @@ class KeywordController extends BaseController
43 'project_id.required' => '项目唯一标识不为空', 43 'project_id.required' => '项目唯一标识不为空',
44 'number.required' => 'number不为空', 44 'number.required' => 'number不为空',
45 ]); 45 ]);
46 - $keywordModel = new PromotionKeyword(); 46 + $keywordModel = new KeywordVideoTask();
47 $rs = $keywordModel->add($this->param); 47 $rs = $keywordModel->add($this->param);
48 if($rs === false){ 48 if($rs === false){
49 $this->response('添加失败',Code::SYSTEM_ERROR); 49 $this->response('添加失败',Code::SYSTEM_ERROR);
@@ -64,7 +64,7 @@ class KeywordController extends BaseController @@ -64,7 +64,7 @@ class KeywordController extends BaseController
64 ], [ 64 ], [
65 'id.required' => '主键标识不为空', 65 'id.required' => '主键标识不为空',
66 ]); 66 ]);
67 - $keywordModel = new PromotionKeyword(); 67 + $keywordModel = new KeywordVideoTask();
68 $rs = $keywordModel->edit(['sort'=>$this->param['sort']],['id'=>$this->param['id']]); 68 $rs = $keywordModel->edit(['sort'=>$this->param['sort']],['id'=>$this->param['id']]);
69 if($rs === false){ 69 if($rs === false){
70 $this->response('编辑失败',Code::SYSTEM_ERROR); 70 $this->response('编辑失败',Code::SYSTEM_ERROR);
@@ -15,7 +15,7 @@ use App\Rules\Ids; @@ -15,7 +15,7 @@ use App\Rules\Ids;
15 use Illuminate\Http\Request; 15 use Illuminate\Http\Request;
16 16
17 /** 17 /**
18 - * Class KeywordController 18 + * Class KeywordVideoController
19 * @package App\Http\Controllers\Bside 19 * @package App\Http\Controllers\Bside
20 * @author zbj 20 * @author zbj
21 * @date 2023/4/15 21 * @date 2023/4/15
1 <?php 1 <?php
2 /** 2 /**
3 * @remark : 3 * @remark :
4 - * @name :PromotionKeyword.php 4 + * @name :KeywordVideoTask.php
5 * @author :lyh 5 * @author :lyh
6 * @method :post 6 * @method :post
7 * @time :2024/2/26 9:33 7 * @time :2024/2/26 9:33
@@ -11,7 +11,10 @@ namespace App\Models\Com; @@ -11,7 +11,10 @@ namespace App\Models\Com;
11 11
12 use App\Models\Base; 12 use App\Models\Base;
13 13
14 -class PromotionKeyword extends Base 14 +class KeywordVideoTask extends Base
15 { 15 {
16 - protected $table = 'gl_promotion_keyword'; 16 + const STATUS_OPEN = 0;
  17 + const STATUS_CLOSE = 1;//停止
  18 +
  19 + protected $table = 'gl_promotion_keyword_task';
17 } 20 }
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :KeywordVideoTask.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2024/2/26 9:33
  8 + */
  9 +
  10 +namespace App\Models\Com;
  11 +
  12 +use App\Models\Base;
  13 +
  14 +class KeywordVideoTaskLog extends Base
  15 +{
  16 + const STATUS_INIT = 0;
  17 + const STATUS_RUNING = 0;
  18 +
  19 + protected $table = 'gl_keyword_video_task_log';
  20 +}
@@ -329,10 +329,10 @@ Route::middleware(['aloginauth'])->group(function () { @@ -329,10 +329,10 @@ Route::middleware(['aloginauth'])->group(function () {
329 /** 329 /**
330 * 生成视频的项目 330 * 生成视频的项目
331 */ 331 */
332 - Route::prefix('promotion_keyword')->group(function () {  
333 - Route::any('/', [Aside\Com\KeywordController::class, 'lists'])->name('promotion_keyword_lists');  
334 - Route::any('/createKeywordTask', [Aside\Com\KeywordController::class, 'createKeywordTask'])->name('promotion_keyword_createKeywordTask');  
335 - Route::any('/edit', [Aside\Com\KeywordController::class, 'edit'])->name('promotion_keyword_edit'); 332 + Route::prefix('keyword_video')->group(function () {
  333 + Route::any('/', [Aside\Com\KeywordVideoController::class, 'lists'])->name('promotion_keyword_lists');
  334 + Route::any('/createKeywordTask', [Aside\Com\KeywordVideoController::class, 'createKeywordTask'])->name('promotion_keyword_createKeywordTask');
  335 + Route::any('/edit', [Aside\Com\KeywordVideoController::class, 'edit'])->name('promotion_keyword_edit');
336 }); 336 });
337 337
338 // 公共主题模版 338 // 公共主题模版