作者 lyh

GX生成白帽报表脚本

... ... @@ -339,7 +339,7 @@ class AiBlogTask extends Command
];
$res = http_post($c_url, json_encode($param,true));
if(empty($res)){
NoticeLog::createLog(NoticeLog::GENERATE_PAGE, json_encode(['c_url'=>$c_url,'c_params'=>$param]),date('Y-m-d H:i:s',time()+300));
NoticeLog::createLog(NoticeLog::GENERATE_PAGE, ['c_url'=>$c_url,'c_params'=>$param],date('Y-m-d H:i:s',time()+300));
}
$this->output('notify: project id: ' . $project_id . ', result: ' . json_encode($res,JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES));
}
... ...
... ... @@ -259,7 +259,7 @@ class KeywordPageAiContent extends Command
'url' => [],
'language' => [],
];
NoticeLog::createLog(NoticeLog::GENERATE_PAGE, json_encode(['c_url' => $url, 'c_params' => $param]), date('Y-m-d H:i:s', time() + 300));
NoticeLog::createLog(NoticeLog::GENERATE_PAGE, ['c_url' => $url, 'c_params' => $param], date('Y-m-d H:i:s', time() + 300));
echo getmypid() . ' ' . '更新中请稍后, 更新完成将会发送站内信通知更新结果!' . PHP_EOL;
}
}
... ...
<?php
/**
* @remark :
* @name :UpdateProjectTdk.php
* @author :lyh
* @method :post
* @time :2025/7/2 11:11
*/
namespace App\Console\Commands\Tdk;
use App\Models\Com\NoticeLog;
use Illuminate\Console\Command;
class UpdateProjectTdk extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'update_project_tdk';
/**
* The console command description.
*
* @var string
*/
protected $description = '根据给定的文件更新项目的tdk';
public function handle(){
$noticeLogModel = new NoticeLog();
while (true){
$task_id = $this->getTaskId();
if(empty($task_id)){
sleep(30);
continue;
}
$info = $noticeLogModel->read(['id'=>$task_id]);
if($info === false){
}
}
return true;
}
/**
* @remark :获取任务id
* @name :getTaskId
* @author :lyh
* @method :post
* @time :2025/7/2 11:19
*/
public function getTaskId()
{
$task_id = Redis::rpop('update_project_tdk_task');
if (empty($task_id)) {
$noticeLogModel = new NoticeLog();
$ids = $noticeLogModel->selectField(['status'=>$noticeLogModel::STATUS_PENDING,'type'=>$noticeLogModel::TYPE_UPDATE_PROJECT_TDK],'id');
if(!empty($ids)){
foreach ($ids as $id) {
Redis::lpush('update_project_tdk_task', $id);
}
}
$task_id = Redis::rpop('update_project_tdk_task');
}
return $task_id;
}
}
... ...
... ... @@ -260,7 +260,7 @@ class UpdateSeoTdk extends Command
'url' => [],
'language'=> [],
];
NoticeLog::createLog(NoticeLog::GENERATE_PAGE, json_encode(['c_url'=>$url,'c_params'=>$param]),date('Y-m-d H:i:s',time()+300));
NoticeLog::createLog(NoticeLog::GENERATE_PAGE, ['c_url'=>$url,'c_params'=>$param],date('Y-m-d H:i:s',time()+300));
// http_post($url, json_encode($param));
echo getmypid() . ' ' . '更新中请稍后, 更新完成将会发送站内信通知更新结果!'. PHP_EOL;
}
... ...
... ... @@ -1259,4 +1259,23 @@ class ProjectController extends BaseController
NoticeLog::createLog(NoticeLog::TYPE_GENERATE_COUNT_CHARTS, ['project_id' => $this->param['project_id']]);
$this->response('success');
}
/**
* @remark :更新项目tdk
* @name :updateTdk
* @author :lyh
* @method :post
* @time :2025/7/2 11:04
*/
public function updateTdk(){
$this->request->validate([
'project_id'=>'required',
'url'=>'required'
],[
'project_id.required' => '项目id不能为空',
'url.required' => '文件路径不为空',
]);
NoticeLog::createLog(NoticeLog::TYPE_UPDATE_PROJECT_TDK, ['project_id' => $this->param['project_id'],'url'=>$this->param['url']]);
$this->response('success',Code::SUCCESS,['url'=>$this->param['url']]);
}
}
... ...
... ... @@ -304,7 +304,7 @@ class CNoticeController extends BaseController
try {
http_post($c_url, json_encode($c_param));
}catch (\Exception $e){
NoticeLog::createLog(NoticeLog::GENERATE_PAGE, json_encode(['c_url'=>$c_url,'c_params'=>$c_param]));
NoticeLog::createLog(NoticeLog::GENERATE_PAGE, ['c_url'=>$c_url,'c_params'=>$c_param]);
}
}
$this->response('更新中请稍后, 更新完成将会发送站内信通知更新结果!');
... ...
... ... @@ -15,6 +15,7 @@ class NoticeLog extends Base
const TYPE_INIT_PROJECT = 'init_project';
const TYPE_INIT_KEYWORD_COMMENT = 'init_keyword_comment';//聚合页关键词评论
const TYPE_GENERATE_COUNT_CHARTS = 'generate_count_charts';//聚合页关键字图表生成
const TYPE_UPDATE_PROJECT_TDK = 'updated_project_tdk';//根据路由更新tdk
const TYPE_COPY_PROJECT = 'copy_project';
const TYPE_INIT_KEYWORD = 'init_keyword';
const DELETE_PRODUCT_CATEGORY = 'delete_product_category';
... ...
... ... @@ -204,6 +204,7 @@ Route::middleware(['aloginauth'])->group(function () {
Route::any('/updateProjectManager', [Aside\Project\ProjectController::class, 'updateProjectManager'])->name('admin.project_updateProjectManager');//更改项目人员配置
Route::any('/setIsParticiple', [Aside\Project\ProjectController::class, 'setIsParticiple'])->name('admin.project_setIsParticiple');//开启/关闭分词
Route::any('/saveSiteStatus', [Aside\Project\ProjectController::class, 'saveSiteStatus'])->name('admin.project_saveSiteStatus');
Route::any('/updateTdk', [Aside\Project\ProjectController::class, 'updateTdk'])->name('admin.project_updateTdk');//更新项目tdk
//获取关键词前缀和后缀
Route::prefix('keyword')->group(function () {
Route::any('/getKeywordPrefix', [Aside\Project\KeywordPrefixController::class, 'getKeywordPrefix'])->name('admin.keyword_getKeywordPrefix');
... ...