自动化审稿相关文件提交
This commit is contained in:
81
application/api/job/RecommendReviewer.php
Normal file
81
application/api/job/RecommendReviewer.php
Normal file
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
namespace app\api\job;
|
||||
use think\queue\Job;
|
||||
use app\common\QueueJob;
|
||||
use app\common\Reviewer;
|
||||
class RecommendReviewer
|
||||
{
|
||||
// 推荐审稿人任务
|
||||
public function fire(Job $job, $data)
|
||||
{
|
||||
|
||||
//获取任务ID
|
||||
$iLogId = 0;
|
||||
try {
|
||||
//实例化
|
||||
$oQueueJob = new QueueJob;
|
||||
$sMsg = '获取推荐审稿人信息成功';
|
||||
if(!empty($job->getRawBody())){
|
||||
$aJob = json_decode($job->getRawBody(), true);
|
||||
$aParam = [
|
||||
'job_id' => empty($aJob['id']) ? '' : $aJob['id'],
|
||||
'job_class' => get_class($this),
|
||||
'status' => 0,
|
||||
'create_time' => time(),
|
||||
'params' => json_encode($aJob, JSON_UNESCAPED_UNICODE)
|
||||
];
|
||||
$iLogId = $oQueueJob->addLog($aParam);
|
||||
// 步骤1:上传素材(图片)
|
||||
$iArticleId = empty($data['article_id']) ? 0 : $data['article_id'];
|
||||
if (!empty($iArticleId)) {
|
||||
|
||||
$aParam = ['article_id' => $iArticleId,'page' => 1,'size' => empty($data['size']) ? 5 : $data['size']];
|
||||
//获取推荐审稿人信息
|
||||
$oReviewer = new Reviewer;
|
||||
$aResult = json_decode($oReviewer->recommend($aParam),true);
|
||||
$iStatus = empty($aResult['status']) ? 0 : $aResult['status'];
|
||||
$sMsg = empty($aResult['msg']) ? '获取推荐审稿人信息失败' : $aResult['msg'];
|
||||
|
||||
//插入审稿人记录表
|
||||
$aResult = empty($aResult['data']['lists']) ? [] : $aResult['data']['lists'];
|
||||
if(empty($aResult)){
|
||||
$sMsg = 'No qualified reviewers were selected';
|
||||
}
|
||||
if(!empty($aResult)){
|
||||
$aParam = ['article_id' => $iArticleId,'reviewer_id' => array_column($aResult, 'reviewer_id')];
|
||||
$aResult = json_decode($oReviewer->add($aParam),true);
|
||||
$iStatus = empty($aResult['status']) ? 0 : $aResult['status'];
|
||||
$sMsg = empty($aResult['msg']) ? 'Reviewer data insertion failed' : $aResult['msg'];
|
||||
//发送邀请审稿人审稿邮件
|
||||
if($iStatus == 1){
|
||||
$aResult = json_decode($oReviewer->email($aParam),true);
|
||||
$iStatus = empty($aResult['status']) ? 0 : $aResult['status'];
|
||||
$sMsg = empty($aResult['msg']) ? 'Reviewer data insertion failed' : $aResult['msg'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$job->delete();
|
||||
|
||||
//更新任务状态
|
||||
$aParam = ['log_id' => $iLogId,'status' => 1,'update_time' => time(),'error' => $sMsg];
|
||||
$oQueueJob->updateLog($aParam);
|
||||
// // 记录日志
|
||||
// \think\Log::info("RecommendReviewer延迟任务执行成功: ".json_encode($data));
|
||||
} catch (\Exception $e) {
|
||||
|
||||
//实例化
|
||||
$oQueueJob = new QueueJob;
|
||||
//更新任务状态
|
||||
$sMsg = empty($e->getMessage()) ? '任务出错' : $e->getMessage();
|
||||
$aParam = ['log_id' => $iLogId,'status' => 2,'update_time' => time(),'error' => $sMsg];
|
||||
$oQueueJob->updateLog($aParam);
|
||||
$job->delete();
|
||||
// // 记录错误日志
|
||||
// \think\Log::error("RecommendReviewer延迟任务失败: ".$e->getMessage());
|
||||
}finally {
|
||||
gc_collect_cycles(); // 强制垃圾回收
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
63
application/api/job/ReviewerScore.php
Normal file
63
application/api/job/ReviewerScore.php
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
namespace app\api\job;
|
||||
use think\queue\Job;
|
||||
use app\common\QueueJob;
|
||||
use app\common\Reviewer;
|
||||
class ReviewerScore
|
||||
{
|
||||
// 审稿人评分
|
||||
public function fire(Job $job, $data)
|
||||
{
|
||||
|
||||
//获取任务ID
|
||||
$iLogId = 0;
|
||||
try {
|
||||
//实例化
|
||||
$oQueueJob = new QueueJob;
|
||||
$sMsg = '给审稿人评分处理成功';
|
||||
if(!empty($job->getRawBody())){
|
||||
$aJob = json_decode($job->getRawBody(), true);
|
||||
$aParam = [
|
||||
'job_id' => empty($aJob['id']) ? '' : $aJob['id'],
|
||||
'job_class' => get_class($this),
|
||||
'status' => 0,
|
||||
'create_time' => time(),
|
||||
'params' => json_encode($aJob, JSON_UNESCAPED_UNICODE)
|
||||
];
|
||||
$iLogId = $oQueueJob->addLog($aParam);
|
||||
|
||||
//审稿人评分
|
||||
$iArticleId = empty($data['article_id']) ? 0 : $data['article_id'];//文章ID
|
||||
$iReviewerId = empty($data['reviewer_id']) ? 0 : $data['reviewer_id'];//审稿人ID
|
||||
$iArtRevId = empty($data['art_rev_id']) ? 0 : $data['art_rev_id'];//主键ID
|
||||
if (!empty($iArticleId) && !empty($iArtRevId) && !empty($iArtRevId)) {
|
||||
$aParam = ['article_id' => $iArticleId,'reviewer_id' => $iReviewerId,'art_rev_id' => $iArtRevId];
|
||||
$oReviewer = new Reviewer;
|
||||
$aResult = json_decode($oReviewer->score($aParam),true);
|
||||
$sMsg = empty($aResult['msg']) ? '给审稿人评分处理失败' : $aResult['msg'];
|
||||
}
|
||||
}
|
||||
$job->delete();
|
||||
|
||||
//更新任务状态
|
||||
$aParam = ['log_id' => $iLogId,'status' => 1,'update_time' => time(),'error' => $sMsg];
|
||||
$oQueueJob->updateLog($aParam);
|
||||
// // 记录日志
|
||||
// \think\Log::info("RecommendReviewer延迟任务执行成功: ".json_encode($data));
|
||||
} catch (\Exception $e) {
|
||||
|
||||
//实例化
|
||||
$oQueueJob = new QueueJob;
|
||||
//更新任务状态
|
||||
$sMsg = empty($e->getMessage()) ? '任务出错' : $e->getMessage();
|
||||
$aParam = ['log_id' => $iLogId,'status' => 2,'update_time' => time(),'error' => $sMsg];
|
||||
$oQueueJob->updateLog($aParam);
|
||||
$job->delete();
|
||||
// // 记录错误日志
|
||||
// \think\Log::error("RecommendReviewer延迟任务失败: ".$e->getMessage());
|
||||
}finally {
|
||||
gc_collect_cycles(); // 强制垃圾回收
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
61
application/api/job/RevisionReviewer.php
Normal file
61
application/api/job/RevisionReviewer.php
Normal file
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
namespace app\api\job;
|
||||
use think\queue\Job;
|
||||
use app\common\QueueJob;
|
||||
use app\common\Reviewer;
|
||||
class RevisionReviewer
|
||||
{
|
||||
// 文章退修任务
|
||||
public function fire(Job $job, $data)
|
||||
{
|
||||
|
||||
//获取任务ID
|
||||
$iLogId = 0;
|
||||
try {
|
||||
//实例化
|
||||
$oQueueJob = new QueueJob;
|
||||
$sMsg = '处理审稿人同意审稿但超时未审的数据成功';
|
||||
if(!empty($job->getRawBody())){
|
||||
$aJob = json_decode($job->getRawBody(), true);
|
||||
$aParam = [
|
||||
'job_id' => empty($aJob['id']) ? '' : $aJob['id'],
|
||||
'job_class' => get_class($this),
|
||||
'status' => 0,
|
||||
'create_time' => time(),
|
||||
'params' => json_encode($aJob, JSON_UNESCAPED_UNICODE)
|
||||
];
|
||||
$iLogId = $oQueueJob->addLog($aParam);
|
||||
|
||||
//获取符合条件的文章审稿人信息
|
||||
$iArticleId = empty($data['article_id']) ? 0 : $data['article_id'];
|
||||
if (!empty($iArticleId)) {
|
||||
$aParam = ['article_id' => $iArticleId];
|
||||
$oReviewer = new Reviewer;
|
||||
$aResult = json_decode($oReviewer->revisionForReviewer($aParam),true);
|
||||
$sMsg = empty($aResult['msg']) ? '审稿人同意审稿但超时未审的数据失败' : $aResult['msg'];
|
||||
}
|
||||
}
|
||||
$job->delete();
|
||||
|
||||
//更新任务状态
|
||||
$aParam = ['log_id' => $iLogId,'status' => 1,'update_time' => time(),'error' => $sMsg];
|
||||
$oQueueJob->updateLog($aParam);
|
||||
// // 记录日志
|
||||
// \think\Log::info("RecommendReviewer延迟任务执行成功: ".json_encode($data));
|
||||
} catch (\Exception $e) {
|
||||
|
||||
//实例化
|
||||
$oQueueJob = new QueueJob;
|
||||
//更新任务状态
|
||||
$sMsg = empty($e->getMessage()) ? '任务出错' : $e->getMessage();
|
||||
$aParam = ['log_id' => $iLogId,'status' => 2,'update_time' => time(),'error' => $sMsg];
|
||||
$oQueueJob->updateLog($aParam);
|
||||
$job->delete();
|
||||
// // 记录错误日志
|
||||
// \think\Log::error("RecommendReviewer延迟任务失败: ".$e->getMessage());
|
||||
}finally {
|
||||
gc_collect_cycles(); // 强制垃圾回收
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
97
application/api/job/SendReviewEmail.php
Normal file
97
application/api/job/SendReviewEmail.php
Normal file
@@ -0,0 +1,97 @@
|
||||
<?php
|
||||
namespace app\api\job;
|
||||
use think\queue\Job;
|
||||
use app\common\QueueJob;
|
||||
use app\common\Reviewer;
|
||||
class SendReviewEmail
|
||||
{
|
||||
// 发送审稿邀请邮件任务
|
||||
public function fire(Job $job, $data)
|
||||
{
|
||||
|
||||
//获取任务ID
|
||||
$iLogId = 0;
|
||||
try {
|
||||
//实例化
|
||||
$oQueueJob = new QueueJob;
|
||||
$sMsg = '发送邮件成功';
|
||||
if(!empty($job->getRawBody())){
|
||||
$aJob = json_decode($job->getRawBody(), true);
|
||||
$aParam = [
|
||||
'job_id' => empty($aJob['id']) ? '' : $aJob['id'],
|
||||
'job_class' => get_class($this),
|
||||
'status' => 0,
|
||||
'create_time' => time(),
|
||||
'params' => json_encode($aJob, JSON_UNESCAPED_UNICODE)
|
||||
];
|
||||
$iLogId = $oQueueJob->addLog($aParam);
|
||||
//文章ID
|
||||
$iArticleId = empty($data['article_id']) ? 0 : $data['article_id'];
|
||||
//作者邮箱
|
||||
$email = empty($data['email']) ? '' : $data['email'];
|
||||
//邮件主题
|
||||
$title = empty($data['title']) ? '' : $data['title'];
|
||||
//发送来源
|
||||
$from_name = empty($data['from_name']) ? '' : $data['from_name'];
|
||||
//邮件内容
|
||||
$content = empty($data['content']) ? '' : $data['content'];
|
||||
//邮箱
|
||||
$memail = empty($data['memail']) ? '' : $data['memail'];
|
||||
//密码
|
||||
$mpassword = empty($data['mpassword']) ? '' : $data['mpassword'];
|
||||
//审稿记录表主键ID
|
||||
$art_rev_id = empty($data['art_rev_id']) ? 0 : $data['art_rev_id'];
|
||||
//审稿人ID
|
||||
$reviewer_id = empty($data['reviewer_id']) ? 0 : $data['reviewer_id'];
|
||||
//邮件类型
|
||||
$type = empty($data['type']) ? 1 : $data['type'];
|
||||
//发送邮件
|
||||
if (!empty($email) && !empty($memail) && !empty($mpassword)) {
|
||||
|
||||
//查询是否发送过邮件
|
||||
$oReviewer = new Reviewer;
|
||||
if($type != 3){
|
||||
$aLog = json_decode($oReviewer->getLog(['article_id' => $iArticleId,'art_rev_id' => $art_rev_id,'reviewer_id' => $reviewer_id,'is_success' => 1,'type' => $type]),true);
|
||||
$aLog = empty($aLog['data']) ? [] : $aLog['data'];
|
||||
$sMsg = '邮件已发送:'.json_encode($aLog);
|
||||
}
|
||||
if(empty($aLog)){
|
||||
$aResult = sendEmail($email,$title,$from_name,$content,$memail,$mpassword);
|
||||
$iStatus = empty($aResult['status']) ? 1 : $aResult['status'];
|
||||
$iIsSuccess = 2;
|
||||
$sMsg = empty($aResult['data']) ? '失败' : $aResult['data'];
|
||||
if($iStatus == 1){
|
||||
$iIsSuccess = 1;
|
||||
$sMsg = '成功';
|
||||
}
|
||||
//记录邮件发送日志
|
||||
$aEmailLog = ['article_id' => $iArticleId,'art_rev_id' => $art_rev_id,'reviewer_id' => $reviewer_id,'type' => $type,'email' => $email,'content' => $content,'create_time' => time(),'is_success' => $iIsSuccess,'msg' => $sMsg];
|
||||
//添加邮件发送日志
|
||||
$iId = $oReviewer->addLog($aEmailLog);
|
||||
}
|
||||
}
|
||||
}
|
||||
$job->delete();
|
||||
|
||||
//更新任务状态
|
||||
$aParam = ['log_id' => $iLogId,'status' => 1,'update_time' => time(),'error' => $sMsg];
|
||||
$oQueueJob->updateLog($aParam);
|
||||
// // 记录日志
|
||||
// \think\Log::info("RelatedArticle延迟任务执行成功: ".json_encode($data));
|
||||
} catch (\Exception $e) {
|
||||
|
||||
//实例化
|
||||
$oQueueJob = new QueueJob;
|
||||
//更新任务状态
|
||||
$sMsg = empty($e->getMessage()) ? '任务出错' : $e->getMessage();
|
||||
$aParam = ['log_id' => $iLogId,'status' => 2,'update_time' => time(),'error' => $sMsg];
|
||||
$oQueueJob->updateLog($aParam);
|
||||
$job->delete();
|
||||
// // 记录错误日志
|
||||
// \think\Log::error("RelatedArticle延迟任务失败: ".$e->getMessage());
|
||||
}finally {
|
||||
gc_collect_cycles(); // 强制垃圾回收
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user