|
@@ -9,9 +9,12 @@ |
|
@@ -9,9 +9,12 @@ |
|
9
|
|
9
|
|
|
10
|
namespace App\Console\Commands\Ai;
|
10
|
namespace App\Console\Commands\Ai;
|
|
11
|
|
11
|
|
|
|
|
12
|
+use App\Models\Ai\AiBlogAuthor;
|
|
12
|
use App\Models\Ai\AiVideo;
|
13
|
use App\Models\Ai\AiVideo;
|
|
|
|
14
|
+use App\Models\Ai\AiVideoList;
|
|
13
|
use App\Models\Project\AiVideoTask as AiVideoTaskModel;
|
15
|
use App\Models\Project\AiVideoTask as AiVideoTaskModel;
|
|
14
|
use App\Models\RouteMap\RouteMap;
|
16
|
use App\Models\RouteMap\RouteMap;
|
|
|
|
17
|
+use App\Services\AiBlogService;
|
|
15
|
use App\Services\AiVideoService;
|
18
|
use App\Services\AiVideoService;
|
|
16
|
use App\Services\DingService;
|
19
|
use App\Services\DingService;
|
|
17
|
use App\Services\ProjectServer;
|
20
|
use App\Services\ProjectServer;
|
|
@@ -64,14 +67,14 @@ class AiVideoTask extends Command |
|
@@ -64,14 +67,14 @@ class AiVideoTask extends Command |
|
64
|
{
|
67
|
{
|
|
65
|
$task_id = Redis::rpop('ai_video_task');
|
68
|
$task_id = Redis::rpop('ai_video_task');
|
|
66
|
if (empty($task_id)) {
|
69
|
if (empty($task_id)) {
|
|
67
|
-// if(!empty($this->updateProject)){
|
|
|
|
68
|
-// $this->updateProject($this->updateProject);
|
|
|
|
69
|
-// $this->updateProject = [];
|
|
|
|
70
|
-// }
|
|
|
|
71
|
-// if(!empty($this->routes)){
|
|
|
|
72
|
-// $this->updateRoutes($this->routes);
|
|
|
|
73
|
-// $this->routes = [];
|
|
|
|
74
|
-// }
|
70
|
+ if(!empty($this->updateProject)){
|
|
|
|
71
|
+ $this->updateProject($this->updateProject);
|
|
|
|
72
|
+ $this->updateProject = [];
|
|
|
|
73
|
+ }
|
|
|
|
74
|
+ if(!empty($this->routes)){
|
|
|
|
75
|
+ $this->updateRoutes($this->routes);
|
|
|
|
76
|
+ $this->routes = [];
|
|
|
|
77
|
+ }
|
|
75
|
$aiVideoTaskModel = new AiVideoTaskModel();
|
78
|
$aiVideoTaskModel = new AiVideoTaskModel();
|
|
76
|
$finish_at = date('Y-m-d H:i:s', strtotime('-' . $finish_at . ' hour'));
|
79
|
$finish_at = date('Y-m-d H:i:s', strtotime('-' . $finish_at . ' hour'));
|
|
77
|
$ids = $aiVideoTaskModel->formatQuery(['status'=>$aiVideoTaskModel::STATUS_RUNNING,'updated_at'=>['<=',$finish_at]])->pluck('id');
|
80
|
$ids = $aiVideoTaskModel->formatQuery(['status'=>$aiVideoTaskModel::STATUS_RUNNING,'updated_at'=>['<=',$finish_at]])->pluck('id');
|
|
@@ -152,6 +155,13 @@ class AiVideoTask extends Command |
|
@@ -152,6 +155,13 @@ class AiVideoTask extends Command |
|
152
|
'status'=>$aiVideoTaskModel::STATUS_FINISH
|
155
|
'status'=>$aiVideoTaskModel::STATUS_FINISH
|
|
153
|
];
|
156
|
];
|
|
154
|
$aiVideoModel->edit($saveData,['task_id'=>$item['task_id']]);
|
157
|
$aiVideoModel->edit($saveData,['task_id'=>$item['task_id']]);
|
|
|
|
158
|
+ //需要更新的路由
|
|
|
|
159
|
+ if (!in_array($result['data']['author_id'], $this->updateProject[$item['project_id']] ?? [])) {
|
|
|
|
160
|
+ $this->updateProject[$item['project_id']][] = $result['data']['author_id'];
|
|
|
|
161
|
+ }
|
|
|
|
162
|
+ if (!in_array($route, $this->routes[$item['project_id']] ?? [])) {
|
|
|
|
163
|
+ $this->routes[$item['project_id']][] = $route;
|
|
|
|
164
|
+ }
|
|
155
|
DB::disconnect('custom_mysql');
|
165
|
DB::disconnect('custom_mysql');
|
|
156
|
$aiVideoTaskModel->edit(['status'=>$aiVideoTaskModel::STATUS_FINISH],['id'=>$item['id']]);
|
166
|
$aiVideoTaskModel->edit(['status'=>$aiVideoTaskModel::STATUS_FINISH],['id'=>$item['id']]);
|
|
157
|
$this->output('success: task id: ' . $task_id);
|
167
|
$this->output('success: task id: ' . $task_id);
|
|
@@ -159,6 +169,102 @@ class AiVideoTask extends Command |
|
@@ -159,6 +169,102 @@ class AiVideoTask extends Command |
|
159
|
}
|
169
|
}
|
|
160
|
|
170
|
|
|
161
|
/**
|
171
|
/**
|
|
|
|
172
|
+ * @remark :更新项目作者页面及列表页
|
|
|
|
173
|
+ * @name :updateProject
|
|
|
|
174
|
+ * @author :lyh
|
|
|
|
175
|
+ * @method :post
|
|
|
|
176
|
+ * @time :2025/4/30 15:43
|
|
|
|
177
|
+ */
|
|
|
|
178
|
+ public function updateProject($updateProject){
|
|
|
|
179
|
+ if(empty($updateProject)){
|
|
|
|
180
|
+ return true;
|
|
|
|
181
|
+ }
|
|
|
|
182
|
+ foreach ($updateProject as $project_id => $author){
|
|
|
|
183
|
+ ProjectServer::useProject($project_id);
|
|
|
|
184
|
+ $this->output('sync: list start, project_id: ' . $project_id);
|
|
|
|
185
|
+ $this->updateBlogList($project_id);
|
|
|
|
186
|
+ $this->output('sync: list end');
|
|
|
|
187
|
+ //更新作者
|
|
|
|
188
|
+ $this->output('sync: author start, project_id: ' . $project_id);
|
|
|
|
189
|
+ foreach ($author as $val){
|
|
|
|
190
|
+ $this->updateAiBlogAuthor($val,$project_id);
|
|
|
|
191
|
+ }
|
|
|
|
192
|
+ $this->output('sync: author end');
|
|
|
|
193
|
+ DB::disconnect('custom_mysql');
|
|
|
|
194
|
+ }
|
|
|
|
195
|
+
|
|
|
|
196
|
+ return true;
|
|
|
|
197
|
+ }
|
|
|
|
198
|
+
|
|
|
|
199
|
+ /**
|
|
|
|
200
|
+ * @remark :更新作者页面
|
|
|
|
201
|
+ * @name :updateAiBlogAuthor
|
|
|
|
202
|
+ * @author :lyh
|
|
|
|
203
|
+ * @method :post
|
|
|
|
204
|
+ * @time :2025/4/30 15:52
|
|
|
|
205
|
+ */
|
|
|
|
206
|
+ public function updateAiBlogAuthor($author_id,$project_id){
|
|
|
|
207
|
+ if(empty($author_id)){
|
|
|
|
208
|
+ return true;
|
|
|
|
209
|
+ }
|
|
|
|
210
|
+ $aiBlogService = new AiBlogService($project_id);
|
|
|
|
211
|
+ $aiBlogService->author_id = $author_id;
|
|
|
|
212
|
+ $result = $aiBlogService->getAuthorDetail();
|
|
|
|
213
|
+ if(isset($result['status']) && $result['status'] == 200){
|
|
|
|
214
|
+ //当前作者的页面
|
|
|
|
215
|
+ $aiBlogAuthorModel = new AiBlogAuthor();
|
|
|
|
216
|
+ $authorInfo = $aiBlogAuthorModel->read(['author_id'=>$author_id],['id','route']);
|
|
|
|
217
|
+ if($authorInfo !== false && !empty($result['data']['section'])){
|
|
|
|
218
|
+ //需要更新的路由
|
|
|
|
219
|
+ if (!in_array($authorInfo['route'], $this->routes[$project_id] ?? [])) {
|
|
|
|
220
|
+ $this->routes[$project_id][] = $authorInfo['route'];
|
|
|
|
221
|
+ }
|
|
|
|
222
|
+ $aiBlogAuthorModel->edit(['text'=>$result['data']['section']],['author_id'=>$author_id]);
|
|
|
|
223
|
+ }
|
|
|
|
224
|
+ }
|
|
|
|
225
|
+ return true;
|
|
|
|
226
|
+ }
|
|
|
|
227
|
+
|
|
|
|
228
|
+ /**
|
|
|
|
229
|
+ * @remark :更新
|
|
|
|
230
|
+ * @name :updateBlogList
|
|
|
|
231
|
+ * @author :lyh
|
|
|
|
232
|
+ * @method :post
|
|
|
|
233
|
+ * @time :2025/4/30 15:45
|
|
|
|
234
|
+ */
|
|
|
|
235
|
+ public function updateBlogList($project_id){
|
|
|
|
236
|
+ $aiVideoService = new AiVideoService($project_id);
|
|
|
|
237
|
+ $page = 1;
|
|
|
|
238
|
+ $saveData = [];
|
|
|
|
239
|
+ $result = $aiVideoService->getAiVideoList($page,15);
|
|
|
|
240
|
+ if(!isset($result['status']) && $result['status'] != 200){
|
|
|
|
241
|
+ return true;
|
|
|
|
242
|
+ }
|
|
|
|
243
|
+ $total_page = $result['data']['total_page'];
|
|
|
|
244
|
+ //组装数据保存
|
|
|
|
245
|
+ $saveData[] = [
|
|
|
|
246
|
+ 'route'=>$page,
|
|
|
|
247
|
+ 'text'=>$result['data']['section'],
|
|
|
|
248
|
+ ];
|
|
|
|
249
|
+ while ($total_page > $page){
|
|
|
|
250
|
+ $page++;
|
|
|
|
251
|
+ $result = $aiVideoService->getAiVideoList($page,15);
|
|
|
|
252
|
+ if(isset($result['status']) && $result['status'] == 200){
|
|
|
|
253
|
+ $saveData[] = [
|
|
|
|
254
|
+ 'route'=>$page,
|
|
|
|
255
|
+ 'text'=>$result['data']['section'],
|
|
|
|
256
|
+ ];
|
|
|
|
257
|
+ }
|
|
|
|
258
|
+ }
|
|
|
|
259
|
+ $aiVideoListModel = new AiVideoList();
|
|
|
|
260
|
+ if(!empty($saveData)){
|
|
|
|
261
|
+ //写一条路由信息
|
|
|
|
262
|
+ $aiVideoListModel->truncate();
|
|
|
|
263
|
+ $aiVideoListModel->insertAll($saveData);
|
|
|
|
264
|
+ }
|
|
|
|
265
|
+ return true;
|
|
|
|
266
|
+ }
|
|
|
|
267
|
+ /**
|
|
162
|
* 输入日志
|
268
|
* 输入日志
|
|
163
|
* @param $message
|
269
|
* @param $message
|
|
164
|
* @return bool
|
270
|
* @return bool
|