队列任务加日志
This commit is contained in:
@@ -9,20 +9,23 @@ class ArticleAiCreateContent
|
|||||||
public function fire(Job $job, $data)
|
public function fire(Job $job, $data)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
// 记录任务开始执行
|
||||||
|
$sLogPath = ROOT_PATH.'public/queue_log/ArticleAiCreateContent_'.date('Ymd').'.log';
|
||||||
|
file_put_contents($sLogPath,'-----------Queue job started-----------' . json_encode($data)."\n",FILE_APPEND);
|
||||||
|
|
||||||
//获取任务ID
|
//获取任务ID
|
||||||
$iLogId = 0;
|
$iLogId = 0;
|
||||||
try {
|
try {
|
||||||
//实例化
|
//实例化
|
||||||
$oQueueJob = new QueueJob;
|
$oQueueJob = new QueueJob;
|
||||||
$sMsg = '文章AI内容生成成功';
|
$sMsg = '文章AI内容生成成功';
|
||||||
if(!empty($job->getRawBody())){
|
$aJob = empty($job->getRawBody()) ? [] : json_decode($job->getRawBody(), true);
|
||||||
$aJob = json_decode($job->getRawBody(), true);
|
|
||||||
$aParam = [
|
$aParam = [
|
||||||
'job_id' => empty($aJob['id']) ? '' : $aJob['id'],
|
'job_id' => empty($aJob['id']) ? 'ArticleAiCreateContent'.rand(100, 999) : $aJob['id'],
|
||||||
'job_class' => get_class($this),
|
'job_class' => get_class($this),
|
||||||
'status' => 0,
|
'status' => 0,
|
||||||
'create_time' => time(),
|
'create_time' => time(),
|
||||||
'params' => json_encode($aJob, JSON_UNESCAPED_UNICODE)
|
'params' => json_encode($data, JSON_UNESCAPED_UNICODE)
|
||||||
];
|
];
|
||||||
$iLogId = $oQueueJob->addLog($aParam);
|
$iLogId = $oQueueJob->addLog($aParam);
|
||||||
// 步骤1:上传素材(图片)
|
// 步骤1:上传素材(图片)
|
||||||
@@ -34,14 +37,13 @@ class ArticleAiCreateContent
|
|||||||
$iStatus = empty($aResult['status']) ? 0 : $aResult['status'];
|
$iStatus = empty($aResult['status']) ? 0 : $aResult['status'];
|
||||||
$sMsg = empty($aResult['msg']) ? '文章AI内容生成失败' : $aResult['msg'];
|
$sMsg = empty($aResult['msg']) ? '文章AI内容生成失败' : $aResult['msg'];
|
||||||
}
|
}
|
||||||
}
|
|
||||||
$job->delete();
|
$job->delete();
|
||||||
|
|
||||||
//更新任务状态
|
//更新任务状态
|
||||||
$aParam = ['log_id' => $iLogId,'status' => 1,'update_time' => time(),'error' => $sMsg];
|
$aParam = ['log_id' => $iLogId,'status' => 1,'update_time' => time(),'error' => $sMsg];
|
||||||
$oQueueJob->updateLog($aParam);
|
$oQueueJob->updateLog($aParam);
|
||||||
// // 记录日志
|
// // 记录日志
|
||||||
// \think\Log::info("ArticleAiCreateContent延迟任务执行成功: ".json_encode($data));
|
file_put_contents($sLogPath,'-----------Queue job end---------'."\n\n\n",FILE_APPEND);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
|
|
||||||
//实例化
|
//实例化
|
||||||
@@ -51,8 +53,7 @@ class ArticleAiCreateContent
|
|||||||
$aParam = ['log_id' => $iLogId,'status' => 2,'update_time' => time(),'error' => $sMsg];
|
$aParam = ['log_id' => $iLogId,'status' => 2,'update_time' => time(),'error' => $sMsg];
|
||||||
$oQueueJob->updateLog($aParam);
|
$oQueueJob->updateLog($aParam);
|
||||||
$job->delete();
|
$job->delete();
|
||||||
// // 记录错误日志
|
|
||||||
// \think\Log::error("ArticleAiCreateContent延迟任务失败: ".$e->getMessage());
|
|
||||||
}finally {
|
}finally {
|
||||||
gc_collect_cycles(); // 强制垃圾回收
|
gc_collect_cycles(); // 强制垃圾回收
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,24 +9,31 @@ class RecommendReviewer
|
|||||||
public function fire(Job $job, $data)
|
public function fire(Job $job, $data)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
// 记录任务开始执行
|
||||||
|
$sLogPath = ROOT_PATH.'public/queue_log/RecommendReviewer_'.date('Ymd').'.log';
|
||||||
|
file_put_contents($sLogPath,'-----------Queue job started-----------' . json_encode($data)."\n",FILE_APPEND);
|
||||||
|
|
||||||
//获取任务ID
|
//获取任务ID
|
||||||
$iLogId = 0;
|
$iLogId = 0;
|
||||||
try {
|
try {
|
||||||
|
|
||||||
//实例化
|
//实例化
|
||||||
$oQueueJob = new QueueJob;
|
$oQueueJob = new QueueJob;
|
||||||
$sMsg = '获取推荐审稿人信息成功';
|
$sMsg = '获取推荐审稿人信息成功';
|
||||||
if(!empty($job->getRawBody())){
|
// 记录异常日志
|
||||||
$aJob = json_decode($job->getRawBody(), true);
|
$aJob = empty($job->getRawBody()) ? [] : json_decode($job->getRawBody(), true);
|
||||||
$aParam = [
|
$aParam = [
|
||||||
'job_id' => empty($aJob['id']) ? '' : $aJob['id'],
|
'job_id' => empty($aJob['id']) ? 'RecommendReviewer'.rand(100, 999) : $aJob['id'],
|
||||||
'job_class' => get_class($this),
|
'job_class' => get_class($this),
|
||||||
'status' => 0,
|
'status' => 0,
|
||||||
'create_time' => time(),
|
'create_time' => time(),
|
||||||
'params' => json_encode($aJob, JSON_UNESCAPED_UNICODE)
|
'params' => json_encode($data, JSON_UNESCAPED_UNICODE)
|
||||||
];
|
];
|
||||||
$iLogId = $oQueueJob->addLog($aParam);
|
$iLogId = $oQueueJob->addLog($aParam);
|
||||||
// 步骤1:上传素材(图片)
|
// 步骤1:上传素材(图片)
|
||||||
$iArticleId = empty($data['article_id']) ? 0 : $data['article_id'];
|
$iArticleId = empty($data['article_id']) ? 0 : $data['article_id'];
|
||||||
|
|
||||||
if (!empty($iArticleId)) {
|
if (!empty($iArticleId)) {
|
||||||
|
|
||||||
$aParam = ['article_id' => $iArticleId,'page' => 1,'size' => empty($data['size']) ? 5 : $data['size']];
|
$aParam = ['article_id' => $iArticleId,'page' => 1,'size' => empty($data['size']) ? 5 : $data['size']];
|
||||||
@@ -66,14 +73,14 @@ class RecommendReviewer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
$job->delete();
|
$job->delete();
|
||||||
|
|
||||||
//更新任务状态
|
//更新任务状态
|
||||||
$aParam = ['log_id' => $iLogId,'status' => 1,'update_time' => time(),'error' => $sMsg];
|
$aParam = ['log_id' => $iLogId,'status' => 1,'update_time' => time(),'error' => $sMsg];
|
||||||
$oQueueJob->updateLog($aParam);
|
$oQueueJob->updateLog($aParam);
|
||||||
// // 记录日志
|
//记录日志
|
||||||
// \think\Log::info("RecommendReviewer延迟任务执行成功: ".json_encode($data));
|
file_put_contents($sLogPath,'-----------Queue job end---------'."\n\n\n",FILE_APPEND);
|
||||||
|
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
|
|
||||||
//实例化
|
//实例化
|
||||||
@@ -83,8 +90,7 @@ class RecommendReviewer
|
|||||||
$aParam = ['log_id' => $iLogId,'status' => 2,'update_time' => time(),'error' => $sMsg];
|
$aParam = ['log_id' => $iLogId,'status' => 2,'update_time' => time(),'error' => $sMsg];
|
||||||
$oQueueJob->updateLog($aParam);
|
$oQueueJob->updateLog($aParam);
|
||||||
$job->delete();
|
$job->delete();
|
||||||
// // 记录错误日志
|
|
||||||
// \think\Log::error("RecommendReviewer延迟任务失败: ".$e->getMessage());
|
|
||||||
}finally {
|
}finally {
|
||||||
gc_collect_cycles(); // 强制垃圾回收
|
gc_collect_cycles(); // 强制垃圾回收
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,20 +9,24 @@ class RelatedArticle
|
|||||||
public function fire(Job $job, $data)
|
public function fire(Job $job, $data)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
// 记录任务开始执行
|
||||||
|
$sLogPath = ROOT_PATH.'public/queue_log/RelatedArticle_'.date('Ymd').'.log';
|
||||||
|
file_put_contents($sLogPath,'-----------Queue job started-----------' . json_encode($data)."\n",FILE_APPEND);
|
||||||
|
|
||||||
//获取任务ID
|
//获取任务ID
|
||||||
$iLogId = 0;
|
$iLogId = 0;
|
||||||
try {
|
try {
|
||||||
//实例化
|
//实例化
|
||||||
$oQueueJob = new QueueJob;
|
$oQueueJob = new QueueJob;
|
||||||
$sMsg = '获取相关文章信息成功';
|
$sMsg = '获取相关文章信息成功';
|
||||||
if(!empty($job->getRawBody())){
|
|
||||||
$aJob = json_decode($job->getRawBody(), true);
|
$aJob = empty($job->getRawBody()) ? [] : json_decode($job->getRawBody(), true);
|
||||||
$aParam = [
|
$aParam = [
|
||||||
'job_id' => empty($aJob['id']) ? '' : $aJob['id'],
|
'job_id' => empty($aJob['id']) ? 'RelatedArticle'.rand(100, 999) : $aJob['id'],
|
||||||
'job_class' => get_class($this),
|
'job_class' => get_class($this),
|
||||||
'status' => 0,
|
'status' => 0,
|
||||||
'create_time' => time(),
|
'create_time' => time(),
|
||||||
'params' => json_encode($aJob, JSON_UNESCAPED_UNICODE)
|
'params' => json_encode($data, JSON_UNESCAPED_UNICODE)
|
||||||
];
|
];
|
||||||
$iLogId = $oQueueJob->addLog($aParam);
|
$iLogId = $oQueueJob->addLog($aParam);
|
||||||
// 步骤1:上传素材(图片)
|
// 步骤1:上传素材(图片)
|
||||||
@@ -34,14 +38,14 @@ class RelatedArticle
|
|||||||
$iStatus = empty($aResult['status']) ? 0 : $aResult['status'];
|
$iStatus = empty($aResult['status']) ? 0 : $aResult['status'];
|
||||||
$sMsg = empty($aResult['msg']) ? '获取相关文章信息失败' : $aResult['msg'];
|
$sMsg = empty($aResult['msg']) ? '获取相关文章信息失败' : $aResult['msg'];
|
||||||
}
|
}
|
||||||
}
|
|
||||||
$job->delete();
|
$job->delete();
|
||||||
|
|
||||||
//更新任务状态
|
//更新任务状态
|
||||||
$aParam = ['log_id' => $iLogId,'status' => 1,'update_time' => time(),'error' => $sMsg];
|
$aParam = ['log_id' => $iLogId,'status' => 1,'update_time' => time(),'error' => $sMsg];
|
||||||
$oQueueJob->updateLog($aParam);
|
$oQueueJob->updateLog($aParam);
|
||||||
// // 记录日志
|
// // 记录日志
|
||||||
// \think\Log::info("RelatedArticle延迟任务执行成功: ".json_encode($data));
|
file_put_contents($sLogPath,'-----------Queue job end---------'."\n\n\n",FILE_APPEND);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
|
|
||||||
//实例化
|
//实例化
|
||||||
@@ -51,8 +55,7 @@ class RelatedArticle
|
|||||||
$aParam = ['log_id' => $iLogId,'status' => 2,'update_time' => time(),'error' => $sMsg];
|
$aParam = ['log_id' => $iLogId,'status' => 2,'update_time' => time(),'error' => $sMsg];
|
||||||
$oQueueJob->updateLog($aParam);
|
$oQueueJob->updateLog($aParam);
|
||||||
$job->delete();
|
$job->delete();
|
||||||
// // 记录错误日志
|
|
||||||
// \think\Log::error("RelatedArticle延迟任务失败: ".$e->getMessage());
|
|
||||||
}finally {
|
}finally {
|
||||||
gc_collect_cycles(); // 强制垃圾回收
|
gc_collect_cycles(); // 强制垃圾回收
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,9 @@ class ReviewerScore
|
|||||||
// 审稿人评分
|
// 审稿人评分
|
||||||
public function fire(Job $job, $data)
|
public function fire(Job $job, $data)
|
||||||
{
|
{
|
||||||
|
// 记录任务开始执行
|
||||||
|
$sLogPath = ROOT_PATH.'public/queue_log/ReviewerScore_'.date('Ymd').'.log';
|
||||||
|
file_put_contents($sLogPath,'-----------Queue job started-----------' . json_encode($data)."\n",FILE_APPEND);
|
||||||
|
|
||||||
//获取任务ID
|
//获取任务ID
|
||||||
$iLogId = 0;
|
$iLogId = 0;
|
||||||
@@ -15,14 +18,14 @@ class ReviewerScore
|
|||||||
//实例化
|
//实例化
|
||||||
$oQueueJob = new QueueJob;
|
$oQueueJob = new QueueJob;
|
||||||
$sMsg = '给审稿人评分处理成功';
|
$sMsg = '给审稿人评分处理成功';
|
||||||
if(!empty($job->getRawBody())){
|
|
||||||
$aJob = json_decode($job->getRawBody(), true);
|
$aJob = empty($job->getRawBody()) ? [] : json_decode($job->getRawBody(), true);
|
||||||
$aParam = [
|
$aParam = [
|
||||||
'job_id' => empty($aJob['id']) ? '' : $aJob['id'],
|
'job_id' => empty($aJob['id']) ? 'ReviewerScore'.rand(100, 999) : $aJob['id'],
|
||||||
'job_class' => get_class($this),
|
'job_class' => get_class($this),
|
||||||
'status' => 0,
|
'status' => 0,
|
||||||
'create_time' => time(),
|
'create_time' => time(),
|
||||||
'params' => json_encode($aJob, JSON_UNESCAPED_UNICODE)
|
'params' => json_encode($data, JSON_UNESCAPED_UNICODE)
|
||||||
];
|
];
|
||||||
$iLogId = $oQueueJob->addLog($aParam);
|
$iLogId = $oQueueJob->addLog($aParam);
|
||||||
|
|
||||||
@@ -36,14 +39,14 @@ class ReviewerScore
|
|||||||
$aResult = json_decode($oReviewer->score($aParam),true);
|
$aResult = json_decode($oReviewer->score($aParam),true);
|
||||||
$sMsg = empty($aResult['msg']) ? '给审稿人评分处理失败' : $aResult['msg'];
|
$sMsg = empty($aResult['msg']) ? '给审稿人评分处理失败' : $aResult['msg'];
|
||||||
}
|
}
|
||||||
}
|
|
||||||
$job->delete();
|
$job->delete();
|
||||||
|
|
||||||
//更新任务状态
|
//更新任务状态
|
||||||
$aParam = ['log_id' => $iLogId,'status' => 1,'update_time' => time(),'error' => $sMsg];
|
$aParam = ['log_id' => $iLogId,'status' => 1,'update_time' => time(),'error' => $sMsg];
|
||||||
$oQueueJob->updateLog($aParam);
|
$oQueueJob->updateLog($aParam);
|
||||||
// // 记录日志
|
// 记录日志
|
||||||
// \think\Log::info("RecommendReviewer延迟任务执行成功: ".json_encode($data));
|
file_put_contents($sLogPath,'-----------Queue job end---------'."\n\n\n",FILE_APPEND);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
|
|
||||||
//实例化
|
//实例化
|
||||||
@@ -53,8 +56,7 @@ class ReviewerScore
|
|||||||
$aParam = ['log_id' => $iLogId,'status' => 2,'update_time' => time(),'error' => $sMsg];
|
$aParam = ['log_id' => $iLogId,'status' => 2,'update_time' => time(),'error' => $sMsg];
|
||||||
$oQueueJob->updateLog($aParam);
|
$oQueueJob->updateLog($aParam);
|
||||||
$job->delete();
|
$job->delete();
|
||||||
// // 记录错误日志
|
|
||||||
// \think\Log::error("RecommendReviewer延迟任务失败: ".$e->getMessage());
|
|
||||||
}finally {
|
}finally {
|
||||||
gc_collect_cycles(); // 强制垃圾回收
|
gc_collect_cycles(); // 强制垃圾回收
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,20 +9,24 @@ class RevisionReviewer
|
|||||||
public function fire(Job $job, $data)
|
public function fire(Job $job, $data)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
// 记录任务开始执行
|
||||||
|
$sLogPath = ROOT_PATH.'public/queue_log/RevisionReviewer_'.date('Ymd').'.log';
|
||||||
|
file_put_contents($sLogPath,'-----------Queue job started-----------' . json_encode($data)."\n",FILE_APPEND);
|
||||||
|
|
||||||
//获取任务ID
|
//获取任务ID
|
||||||
$iLogId = 0;
|
$iLogId = 0;
|
||||||
try {
|
try {
|
||||||
//实例化
|
//实例化
|
||||||
$oQueueJob = new QueueJob;
|
$oQueueJob = new QueueJob;
|
||||||
$sMsg = '处理审稿人同意审稿但超时未审的数据成功';
|
$sMsg = '处理审稿人同意审稿但超时未审的数据成功';
|
||||||
if(!empty($job->getRawBody())){
|
|
||||||
$aJob = json_decode($job->getRawBody(), true);
|
$aJob = empty($job->getRawBody()) ? [] : json_decode($job->getRawBody(), true);
|
||||||
$aParam = [
|
$aParam = [
|
||||||
'job_id' => empty($aJob['id']) ? '' : $aJob['id'],
|
'job_id' => empty($aJob['id']) ? 'RevisionReviewer'.rand(100, 999) : $aJob['id'],
|
||||||
'job_class' => get_class($this),
|
'job_class' => get_class($this),
|
||||||
'status' => 0,
|
'status' => 0,
|
||||||
'create_time' => time(),
|
'create_time' => time(),
|
||||||
'params' => json_encode($aJob, JSON_UNESCAPED_UNICODE)
|
'params' => json_encode($data, JSON_UNESCAPED_UNICODE)
|
||||||
];
|
];
|
||||||
$iLogId = $oQueueJob->addLog($aParam);
|
$iLogId = $oQueueJob->addLog($aParam);
|
||||||
|
|
||||||
@@ -34,14 +38,14 @@ class RevisionReviewer
|
|||||||
$aResult = json_decode($oReviewer->revisionForReviewer($aParam),true);
|
$aResult = json_decode($oReviewer->revisionForReviewer($aParam),true);
|
||||||
$sMsg = empty($aResult['msg']) ? '审稿人同意审稿但超时未审的数据失败' : $aResult['msg'];
|
$sMsg = empty($aResult['msg']) ? '审稿人同意审稿但超时未审的数据失败' : $aResult['msg'];
|
||||||
}
|
}
|
||||||
}
|
|
||||||
$job->delete();
|
$job->delete();
|
||||||
|
|
||||||
//更新任务状态
|
//更新任务状态
|
||||||
$aParam = ['log_id' => $iLogId,'status' => 1,'update_time' => time(),'error' => $sMsg];
|
$aParam = ['log_id' => $iLogId,'status' => 1,'update_time' => time(),'error' => $sMsg];
|
||||||
$oQueueJob->updateLog($aParam);
|
$oQueueJob->updateLog($aParam);
|
||||||
// // 记录日志
|
//记录日志
|
||||||
// \think\Log::info("RecommendReviewer延迟任务执行成功: ".json_encode($data));
|
file_put_contents($sLogPath,'-----------Queue job end---------'."\n\n\n",FILE_APPEND);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
|
|
||||||
//实例化
|
//实例化
|
||||||
@@ -51,8 +55,7 @@ class RevisionReviewer
|
|||||||
$aParam = ['log_id' => $iLogId,'status' => 2,'update_time' => time(),'error' => $sMsg];
|
$aParam = ['log_id' => $iLogId,'status' => 2,'update_time' => time(),'error' => $sMsg];
|
||||||
$oQueueJob->updateLog($aParam);
|
$oQueueJob->updateLog($aParam);
|
||||||
$job->delete();
|
$job->delete();
|
||||||
// // 记录错误日志
|
|
||||||
// \think\Log::error("RecommendReviewer延迟任务失败: ".$e->getMessage());
|
|
||||||
}finally {
|
}finally {
|
||||||
gc_collect_cycles(); // 强制垃圾回收
|
gc_collect_cycles(); // 强制垃圾回收
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,20 +9,24 @@ class SendRelatedArticleEmail
|
|||||||
public function fire(Job $job, $data)
|
public function fire(Job $job, $data)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
// 记录任务开始执行
|
||||||
|
$sLogPath = ROOT_PATH.'public/queue_log/SendRelatedArticleEmail_'.date('Ymd').'.log';
|
||||||
|
file_put_contents($sLogPath,'-----------Queue job started-----------' . json_encode($data)."\n",FILE_APPEND);
|
||||||
|
|
||||||
//获取任务ID
|
//获取任务ID
|
||||||
$iLogId = 0;
|
$iLogId = 0;
|
||||||
try {
|
try {
|
||||||
//实例化
|
//实例化
|
||||||
$oQueueJob = new QueueJob;
|
$oQueueJob = new QueueJob;
|
||||||
$sMsg = '发送邮件成功';
|
$sMsg = '发送邮件成功';
|
||||||
if(!empty($job->getRawBody())){
|
|
||||||
$aJob = json_decode($job->getRawBody(), true);
|
$aJob = empty($job->getRawBody()) ? [] : json_decode($job->getRawBody(), true);
|
||||||
$aParam = [
|
$aParam = [
|
||||||
'job_id' => empty($aJob['id']) ? '' : $aJob['id'],
|
'job_id' => empty($aJob['id']) ? 'SendRelatedArticleEmail'.rand(100, 999) : $aJob['id'],
|
||||||
'job_class' => get_class($this),
|
'job_class' => get_class($this),
|
||||||
'status' => 0,
|
'status' => 0,
|
||||||
'create_time' => time(),
|
'create_time' => time(),
|
||||||
'params' => json_encode($aJob, JSON_UNESCAPED_UNICODE)
|
'params' => json_encode($data, JSON_UNESCAPED_UNICODE)
|
||||||
];
|
];
|
||||||
$iLogId = $oQueueJob->addLog($aParam);
|
$iLogId = $oQueueJob->addLog($aParam);
|
||||||
|
|
||||||
@@ -71,14 +75,14 @@ class SendRelatedArticleEmail
|
|||||||
$iId = JournalArticle::addLog($aEmailLog);
|
$iId = JournalArticle::addLog($aEmailLog);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
$job->delete();
|
$job->delete();
|
||||||
|
|
||||||
//更新任务状态
|
//更新任务状态
|
||||||
$aParam = ['log_id' => $iLogId,'status' => 1,'update_time' => time(),'error' => $sMsg];
|
$aParam = ['log_id' => $iLogId,'status' => 1,'update_time' => time(),'error' => $sMsg];
|
||||||
$oQueueJob->updateLog($aParam);
|
$oQueueJob->updateLog($aParam);
|
||||||
// // 记录日志
|
// // 记录日志
|
||||||
// \think\Log::info("RelatedArticle延迟任务执行成功: ".json_encode($data));
|
file_put_contents($sLogPath,'-----------Queue job end---------'."\n\n\n",FILE_APPEND);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
|
|
||||||
//实例化
|
//实例化
|
||||||
@@ -88,8 +92,7 @@ class SendRelatedArticleEmail
|
|||||||
$aParam = ['log_id' => $iLogId,'status' => 2,'update_time' => time(),'error' => $sMsg];
|
$aParam = ['log_id' => $iLogId,'status' => 2,'update_time' => time(),'error' => $sMsg];
|
||||||
$oQueueJob->updateLog($aParam);
|
$oQueueJob->updateLog($aParam);
|
||||||
$job->delete();
|
$job->delete();
|
||||||
// // 记录错误日志
|
|
||||||
// \think\Log::error("RelatedArticle延迟任务失败: ".$e->getMessage());
|
|
||||||
}finally {
|
}finally {
|
||||||
gc_collect_cycles(); // 强制垃圾回收
|
gc_collect_cycles(); // 强制垃圾回收
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,20 +9,24 @@ class SendReviewEmail
|
|||||||
public function fire(Job $job, $data)
|
public function fire(Job $job, $data)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
// 记录任务开始执行
|
||||||
|
$sLogPath = ROOT_PATH.'public/queue_log/SendReviewEmail_'.date('Ymd').'.log';
|
||||||
|
file_put_contents($sLogPath,'-----------Queue job started-----------'."\n",FILE_APPEND);
|
||||||
|
|
||||||
//获取任务ID
|
//获取任务ID
|
||||||
$iLogId = 0;
|
$iLogId = 0;
|
||||||
try {
|
try {
|
||||||
//实例化
|
//实例化
|
||||||
$oQueueJob = new QueueJob;
|
$oQueueJob = new QueueJob;
|
||||||
$sMsg = '发送邮件成功';
|
$sMsg = '发送邮件成功';
|
||||||
if(!empty($job->getRawBody())){
|
|
||||||
$aJob = json_decode($job->getRawBody(), true);
|
$aJob = empty($job->getRawBody()) ? [] : json_decode($job->getRawBody(), true);
|
||||||
$aParam = [
|
$aParam = [
|
||||||
'job_id' => empty($aJob['id']) ? '' : $aJob['id'],
|
'job_id' => empty($aJob['id']) ? 'SendReviewEmail'.rand(100, 999) : $aJob['id'],
|
||||||
'job_class' => get_class($this),
|
'job_class' => get_class($this),
|
||||||
'status' => 0,
|
'status' => 0,
|
||||||
'create_time' => time(),
|
'create_time' => time(),
|
||||||
'params' => json_encode($aJob, JSON_UNESCAPED_UNICODE)
|
'params' => json_encode($data, JSON_UNESCAPED_UNICODE)
|
||||||
];
|
];
|
||||||
$iLogId = $oQueueJob->addLog($aParam);
|
$iLogId = $oQueueJob->addLog($aParam);
|
||||||
//文章ID
|
//文章ID
|
||||||
@@ -70,14 +74,14 @@ class SendReviewEmail
|
|||||||
$iId = $oReviewer->addLog($aEmailLog);
|
$iId = $oReviewer->addLog($aEmailLog);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
$job->delete();
|
$job->delete();
|
||||||
|
|
||||||
//更新任务状态
|
//更新任务状态
|
||||||
$aParam = ['log_id' => $iLogId,'status' => 1,'update_time' => time(),'error' => $sMsg];
|
$aParam = ['log_id' => $iLogId,'status' => 1,'update_time' => time(),'error' => $sMsg];
|
||||||
$oQueueJob->updateLog($aParam);
|
$oQueueJob->updateLog($aParam);
|
||||||
// // 记录日志
|
// // 记录日志
|
||||||
// \think\Log::info("RelatedArticle延迟任务执行成功: ".json_encode($data));
|
file_put_contents($sLogPath,'-----------Queue job end---------'."\n\n\n",FILE_APPEND);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
|
|
||||||
//实例化
|
//实例化
|
||||||
@@ -87,8 +91,6 @@ class SendReviewEmail
|
|||||||
$aParam = ['log_id' => $iLogId,'status' => 2,'update_time' => time(),'error' => $sMsg];
|
$aParam = ['log_id' => $iLogId,'status' => 2,'update_time' => time(),'error' => $sMsg];
|
||||||
$oQueueJob->updateLog($aParam);
|
$oQueueJob->updateLog($aParam);
|
||||||
$job->delete();
|
$job->delete();
|
||||||
// // 记录错误日志
|
|
||||||
// \think\Log::error("RelatedArticle延迟任务失败: ".$e->getMessage());
|
|
||||||
}finally {
|
}finally {
|
||||||
gc_collect_cycles(); // 强制垃圾回收
|
gc_collect_cycles(); // 强制垃圾回收
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,10 @@ class WechatDraft
|
|||||||
public function fire(Job $job, $data)
|
public function fire(Job $job, $data)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
// 记录任务开始执行
|
||||||
|
$sLogPath = ROOT_PATH.'public/queue_log/WechatDraft_'.date('Ymd').'.log';
|
||||||
|
file_put_contents($sLogPath,'-----------Queue job started-----------' . json_encode($data)."\n",FILE_APPEND);
|
||||||
|
|
||||||
//获取任务ID
|
//获取任务ID
|
||||||
$iLogId = 0;
|
$iLogId = 0;
|
||||||
try {
|
try {
|
||||||
@@ -16,14 +20,14 @@ class WechatDraft
|
|||||||
//实例化
|
//实例化
|
||||||
$oQueueJob = new QueueJob;
|
$oQueueJob = new QueueJob;
|
||||||
$sMsg = '上传草稿箱成功';
|
$sMsg = '上传草稿箱成功';
|
||||||
if(!empty($job->getRawBody())){
|
|
||||||
$aJob = json_decode($job->getRawBody(), true);
|
$aJob = empty($job->getRawBody()) ? [] : json_decode($job->getRawBody(), true);
|
||||||
$aParam = [
|
$aParam = [
|
||||||
'job_id' => empty($aJob['id']) ? '' : $aJob['id'],
|
'job_id' => empty($aJob['id']) ? 'WechatDraft'.rand(100, 999) : $aJob['id'],
|
||||||
'job_class' => get_class($this),
|
'job_class' => get_class($this),
|
||||||
'status' => 0,
|
'status' => 0,
|
||||||
'create_time' => time(),
|
'create_time' => time(),
|
||||||
'params' => json_encode($aJob, JSON_UNESCAPED_UNICODE)
|
'params' => json_encode($data, JSON_UNESCAPED_UNICODE)
|
||||||
];
|
];
|
||||||
$iLogId = $oQueueJob->addLog($aParam);
|
$iLogId = $oQueueJob->addLog($aParam);
|
||||||
// 步骤1:上传素材(图片)
|
// 步骤1:上传素材(图片)
|
||||||
@@ -35,14 +39,14 @@ class WechatDraft
|
|||||||
$iStatus = empty($aResult['status']) ? 0 : $aResult['status'];
|
$iStatus = empty($aResult['status']) ? 0 : $aResult['status'];
|
||||||
$sMsg = empty($aResult['msg']) ? '上传草稿箱失败' : $aResult['msg'];
|
$sMsg = empty($aResult['msg']) ? '上传草稿箱失败' : $aResult['msg'];
|
||||||
}
|
}
|
||||||
}
|
|
||||||
$job->delete();
|
$job->delete();
|
||||||
|
|
||||||
//更新任务状态
|
//更新任务状态
|
||||||
$aParam = ['log_id' => $iLogId,'status' => 1,'update_time' => time(),'error' => $sMsg];
|
$aParam = ['log_id' => $iLogId,'status' => 1,'update_time' => time(),'error' => $sMsg];
|
||||||
$oQueueJob->updateLog($aParam);
|
$oQueueJob->updateLog($aParam);
|
||||||
// // 记录日志
|
// // 记录日志
|
||||||
// \think\Log::info("WechatDraft-延迟任务执行成功: ".json_encode($data));
|
file_put_contents($sLogPath,'-----------Queue job end---------'."\n\n\n",FILE_APPEND);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
|
|
||||||
//实例化
|
//实例化
|
||||||
@@ -52,8 +56,6 @@ class WechatDraft
|
|||||||
$aParam = ['log_id' => $iLogId,'status' => 2,'update_time' => time(),'error' => $sMsg];
|
$aParam = ['log_id' => $iLogId,'status' => 2,'update_time' => time(),'error' => $sMsg];
|
||||||
$oQueueJob->updateLog($aParam);
|
$oQueueJob->updateLog($aParam);
|
||||||
$job->delete();
|
$job->delete();
|
||||||
// // 记录错误日志
|
|
||||||
// \think\Log::error("WechatDraft-延迟任务失败: ".$e->getMessage());
|
|
||||||
}finally {
|
}finally {
|
||||||
gc_collect_cycles(); // 强制垃圾回收
|
gc_collect_cycles(); // 强制垃圾回收
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,10 @@ class WechatDraftPublish
|
|||||||
public function fire(Job $job, $data)
|
public function fire(Job $job, $data)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
// 记录任务开始执行
|
||||||
|
$sLogPath = ROOT_PATH.'public/queue_log/WechatDraftPublish_'.date('Ymd').'.log';
|
||||||
|
file_put_contents($sLogPath,'-----------Queue job started-----------' . json_encode($data)."\n",FILE_APPEND);
|
||||||
|
|
||||||
//获取任务ID
|
//获取任务ID
|
||||||
$iLogId = 0;
|
$iLogId = 0;
|
||||||
try {
|
try {
|
||||||
@@ -16,14 +20,14 @@ class WechatDraftPublish
|
|||||||
//实例化
|
//实例化
|
||||||
$oQueueJob = new QueueJob;
|
$oQueueJob = new QueueJob;
|
||||||
$sMsg = '草稿箱发布成功';
|
$sMsg = '草稿箱发布成功';
|
||||||
if(!empty($job->getRawBody())){
|
|
||||||
$aJob = json_decode($job->getRawBody(), true);
|
$aJob = empty($job->getRawBody()) ? [] : json_decode($job->getRawBody(), true);
|
||||||
$aParam = [
|
$aParam = [
|
||||||
'job_id' => empty($aJob['id']) ? '' : $aJob['id'],
|
'job_id' => empty($aJob['id']) ? 'WechatDraftPublish'.rand(100, 999) : $aJob['id'],
|
||||||
'job_class' => get_class($this),
|
'job_class' => get_class($this),
|
||||||
'status' => 0,
|
'status' => 0,
|
||||||
'create_time' => time(),
|
'create_time' => time(),
|
||||||
'params' => json_encode($aJob, JSON_UNESCAPED_UNICODE)
|
'params' => json_encode($data, JSON_UNESCAPED_UNICODE)
|
||||||
];
|
];
|
||||||
$iLogId = $oQueueJob->addLog($aParam);
|
$iLogId = $oQueueJob->addLog($aParam);
|
||||||
// 步骤1:上传素材(图片)
|
// 步骤1:上传素材(图片)
|
||||||
@@ -35,14 +39,14 @@ class WechatDraftPublish
|
|||||||
$iStatus = empty($aResult['status']) ? 0 : $aResult['status'];
|
$iStatus = empty($aResult['status']) ? 0 : $aResult['status'];
|
||||||
$sMsg = empty($aResult['msg']) ? '草稿箱发布失败' : $aResult['msg'];
|
$sMsg = empty($aResult['msg']) ? '草稿箱发布失败' : $aResult['msg'];
|
||||||
}
|
}
|
||||||
}
|
|
||||||
$job->delete();
|
$job->delete();
|
||||||
|
|
||||||
//更新任务状态
|
//更新任务状态
|
||||||
$aParam = ['log_id' => $iLogId,'status' => 1,'update_time' => time(),'error' => $sMsg];
|
$aParam = ['log_id' => $iLogId,'status' => 1,'update_time' => time(),'error' => $sMsg];
|
||||||
$oQueueJob->updateLog($aParam);
|
$oQueueJob->updateLog($aParam);
|
||||||
// // 记录日志
|
// // 记录日志
|
||||||
// \think\Log::info("WechatDraft-延迟任务执行成功: ".json_encode($data));
|
file_put_contents($sLogPath,'-----------Queue job end-----------' . json_encode($data)."\n\n\n",FILE_APPEND);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
|
|
||||||
//实例化
|
//实例化
|
||||||
@@ -52,8 +56,6 @@ class WechatDraftPublish
|
|||||||
$aParam = ['log_id' => $iLogId,'status' => 2,'update_time' => time(),'error' => $sMsg];
|
$aParam = ['log_id' => $iLogId,'status' => 2,'update_time' => time(),'error' => $sMsg];
|
||||||
$oQueueJob->updateLog($aParam);
|
$oQueueJob->updateLog($aParam);
|
||||||
$job->delete();
|
$job->delete();
|
||||||
// // 记录错误日志
|
|
||||||
// \think\Log::error("WechatDraft-延迟任务失败: ".$e->getMessage());
|
|
||||||
}finally {
|
}finally {
|
||||||
gc_collect_cycles(); // 强制垃圾回收
|
gc_collect_cycles(); // 强制垃圾回收
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,10 @@ class WechatMaterial
|
|||||||
public function fire(Job $job, $data)
|
public function fire(Job $job, $data)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
// 记录任务开始执行
|
||||||
|
$sLogPath = ROOT_PATH.'public/queue_log/WechatMaterial_'.date('Ymd').'.log';
|
||||||
|
file_put_contents($sLogPath,'-----------Queue job started-----------' . json_encode($data)."\n",FILE_APPEND);
|
||||||
|
|
||||||
//获取任务ID
|
//获取任务ID
|
||||||
$iLogId = 0;
|
$iLogId = 0;
|
||||||
try {
|
try {
|
||||||
@@ -16,14 +20,14 @@ class WechatMaterial
|
|||||||
//实例化
|
//实例化
|
||||||
$oQueueJob = new QueueJob;
|
$oQueueJob = new QueueJob;
|
||||||
$sMsg = '上传素材成功';
|
$sMsg = '上传素材成功';
|
||||||
if(!empty($job->getRawBody())){
|
|
||||||
$aJob = json_decode($job->getRawBody(), true);
|
$aJob = empty($job->getRawBody()) ? [] : json_decode($job->getRawBody(), true);
|
||||||
$aParam = [
|
$aParam = [
|
||||||
'job_id' => empty($aJob['id']) ? '' : $aJob['id'],
|
'job_id' => empty($aJob['id']) ? 'WechatMaterial'.rand(100, 999) : $aJob['id'],
|
||||||
'job_class' => get_class($this),
|
'job_class' => get_class($this),
|
||||||
'status' => 0,
|
'status' => 0,
|
||||||
'create_time' => time(),
|
'create_time' => time(),
|
||||||
'params' => json_encode($aJob, JSON_UNESCAPED_UNICODE)
|
'params' => json_encode($data, JSON_UNESCAPED_UNICODE)
|
||||||
];
|
];
|
||||||
$iLogId = $oQueueJob->addLog($aParam);
|
$iLogId = $oQueueJob->addLog($aParam);
|
||||||
// 步骤1:上传素材(图片)
|
// 步骤1:上传素材(图片)
|
||||||
@@ -35,7 +39,7 @@ class WechatMaterial
|
|||||||
$iStatus = empty($aResult['status']) ? 0 : $aResult['status'];
|
$iStatus = empty($aResult['status']) ? 0 : $aResult['status'];
|
||||||
$sMsg = empty($aResult['msg']) ? '上传素材失败' : $aResult['msg'];
|
$sMsg = empty($aResult['msg']) ? '上传素材失败' : $aResult['msg'];
|
||||||
}
|
}
|
||||||
}
|
|
||||||
$job->delete();
|
$job->delete();
|
||||||
|
|
||||||
//更新任务状态
|
//更新任务状态
|
||||||
@@ -43,7 +47,7 @@ class WechatMaterial
|
|||||||
$oQueueJob->updateLog($aParam);
|
$oQueueJob->updateLog($aParam);
|
||||||
|
|
||||||
// // 记录日志
|
// // 记录日志
|
||||||
// \think\Log::info("WechatMaterial-延迟任务执行成功: ".json_encode($data));
|
file_put_contents($sLogPath,'-----------Queue job end-----------' . json_encode($data)."\n\n\n",FILE_APPEND);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
|
|
||||||
//实例化
|
//实例化
|
||||||
@@ -54,8 +58,6 @@ class WechatMaterial
|
|||||||
$oQueueJob->updateLog($aParam);
|
$oQueueJob->updateLog($aParam);
|
||||||
$job->delete();
|
$job->delete();
|
||||||
|
|
||||||
// // 记录错误日志
|
|
||||||
// \think\Log::error("WechatMaterial-延迟任务失败: ".$e->getMessage());
|
|
||||||
}finally {
|
}finally {
|
||||||
gc_collect_cycles(); // 强制垃圾回收
|
gc_collect_cycles(); // 强制垃圾回收
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,20 +9,24 @@ class WechatQueryStatus
|
|||||||
public function fire(Job $job, $data)
|
public function fire(Job $job, $data)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
// 记录任务开始执行
|
||||||
|
$sLogPath = ROOT_PATH.'public/queue_log/WechatQueryStatus_'.date('Ymd').'.log';
|
||||||
|
file_put_contents($sLogPath,'-----------Queue job started-----------' . json_encode($data)."\n",FILE_APPEND);
|
||||||
|
|
||||||
//获取任务ID
|
//获取任务ID
|
||||||
$iLogId = 0;
|
$iLogId = 0;
|
||||||
try {
|
try {
|
||||||
//实例化
|
//实例化
|
||||||
$oQueueJob = new QueueJob;
|
$oQueueJob = new QueueJob;
|
||||||
$sMsg = '查询草稿箱文章发布状态成功';
|
$sMsg = '查询草稿箱文章发布状态成功';
|
||||||
if(!empty($job->getRawBody())){
|
|
||||||
$aJob = json_decode($job->getRawBody(), true);
|
$aJob = empty($job->getRawBody()) ? [] : json_decode($job->getRawBody(), true);
|
||||||
$aParam = [
|
$aParam = [
|
||||||
'job_id' => empty($aJob['id']) ? '' : $aJob['id'],
|
'job_id' => empty($aJob['id']) ? 'WechatQueryStatus'.rand(100, 999) : $aJob['id'],
|
||||||
'job_class' => get_class($this),
|
'job_class' => get_class($this),
|
||||||
'status' => 0,
|
'status' => 0,
|
||||||
'create_time' => time(),
|
'create_time' => time(),
|
||||||
'params' => json_encode($aJob, JSON_UNESCAPED_UNICODE)
|
'params' => json_encode($data, JSON_UNESCAPED_UNICODE)
|
||||||
];
|
];
|
||||||
$iLogId = $oQueueJob->addLog($aParam);
|
$iLogId = $oQueueJob->addLog($aParam);
|
||||||
// 步骤1:上传素材(图片)
|
// 步骤1:上传素材(图片)
|
||||||
@@ -34,14 +38,14 @@ class WechatQueryStatus
|
|||||||
$iStatus = empty($aResult['status']) ? 0 : $aResult['status'];
|
$iStatus = empty($aResult['status']) ? 0 : $aResult['status'];
|
||||||
$sMsg = empty($aResult['msg']) ? '上传草稿箱失败' : $aResult['msg'];
|
$sMsg = empty($aResult['msg']) ? '上传草稿箱失败' : $aResult['msg'];
|
||||||
}
|
}
|
||||||
}
|
|
||||||
$job->delete();
|
$job->delete();
|
||||||
|
|
||||||
//更新任务状态
|
//更新任务状态
|
||||||
$aParam = ['log_id' => $iLogId,'status' => 1,'update_time' => time(),'error' => $sMsg];
|
$aParam = ['log_id' => $iLogId,'status' => 1,'update_time' => time(),'error' => $sMsg];
|
||||||
$oQueueJob->updateLog($aParam);
|
$oQueueJob->updateLog($aParam);
|
||||||
// // 记录日志
|
// // 记录错误日志
|
||||||
// \think\Log::info("WechatQueryStatus延迟任务执行成功: ".json_encode($data));
|
file_put_contents($sLogPath,'-----------Queue job end-----------' . json_encode($data)."\n\n\n",FILE_APPEND);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
|
|
||||||
//实例化
|
//实例化
|
||||||
@@ -51,8 +55,6 @@ class WechatQueryStatus
|
|||||||
$aParam = ['log_id' => $iLogId,'status' => 2,'update_time' => time(),'error' => $sMsg];
|
$aParam = ['log_id' => $iLogId,'status' => 2,'update_time' => time(),'error' => $sMsg];
|
||||||
$oQueueJob->updateLog($aParam);
|
$oQueueJob->updateLog($aParam);
|
||||||
$job->delete();
|
$job->delete();
|
||||||
// // 记录错误日志
|
|
||||||
// \think\Log::error("WechatQueryStatus延迟任务失败: ".$e->getMessage());
|
|
||||||
}finally {
|
}finally {
|
||||||
gc_collect_cycles(); // 强制垃圾回收
|
gc_collect_cycles(); // 强制垃圾回收
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user