Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -1536,7 +1536,7 @@ class Aiarticle extends Base
|
||||
$sTitle = empty($aMainImageInfo['title']) ? strip_tags($aMainImageInfo['note']) : strip_tags($aMainImageInfo['title']);
|
||||
$aImageSerach['{###image_title###}'] = '';
|
||||
if(!empty($sTitle)){
|
||||
$sTitle = preg_replace('/Figure \d+.*?/i', '', $sTitle);
|
||||
$sTitle = preg_replace('/Figure \d+\s*/i', '', $sTitle);
|
||||
$aTitle = explode('.', $sTitle);
|
||||
$aImageSerach['{###image_title###}'] = empty($aTitle[0]) ? $sTitle : strip_tags($aTitle[0]);
|
||||
}
|
||||
|
||||
@@ -1266,7 +1266,7 @@ class Article extends Base
|
||||
}
|
||||
//添加文章状态信息(如果状态未更新可做通话用,并结束操作)
|
||||
$insert_data['article_id'] = $iId;
|
||||
$insert_data['content'] = 'The article enters the final review stage';
|
||||
$insert_data['content'] = 'final decision';
|
||||
$insert_data['state_from'] = $article_info['state'];
|
||||
$insert_data['state_to'] = 8;
|
||||
$insert_data['ctime'] = time();
|
||||
|
||||
@@ -15,14 +15,14 @@ class Finalreview extends Base
|
||||
private $aEmailConfig = [
|
||||
|
||||
'reviewer' => [
|
||||
'email_subject' => 'Invitation for Final Review of Manuscript - {journal_title} [{accept_sn}]',
|
||||
'email_subject' => 'Invitation for Final Decision of Manuscript - {journal_title} [{accept_sn}]',
|
||||
'email_content' => '
|
||||
Dear Prof. {realname},<br><br>
|
||||
I hope this message finds you well.<br><br>
|
||||
We would like to invite you to conduct the final review of the manuscript detailed below:<br>
|
||||
We would like to invite you to conduct the final decision of the manuscript detailed below:<br>
|
||||
Title: [{article_title}]<br>
|
||||
Manuscript ID: [{accept_sn}]<br><br>
|
||||
The manuscript has passed the peer review, and revisions have been made based on the external reviewer\'s comments. We would be honored if you could conduct the final review of the manuscript. Your expert opinion is crucial in ensuring the academic quality of the manuscript and determining its final acceptance for publication.<br><br>
|
||||
The manuscript has passed the peer review, and revisions have been made based on the external reviewer\'s comments. We would be honored if you could conduct the final decision of the manuscript. Your expert opinion is crucial in ensuring the academic quality of the manuscript and determining its final acceptance for publication.<br><br>
|
||||
<a href="{accept_url}">Click here to review the article and kindly submit your final comments within 5 days</a><br>
|
||||
<a href="{reject_url}">Click here to reject the review of this manuscript</a><br>
|
||||
Your username: {account}<br>
|
||||
@@ -276,7 +276,7 @@ class Finalreview extends Base
|
||||
];
|
||||
|
||||
//邮箱
|
||||
$email = 'tmr@tmrjournals.com';//$aUser['email'];
|
||||
$email = $aUser['email'];//'tmr@tmrjournals.com';//
|
||||
//用户名
|
||||
$realname = empty($aUser['account']) ? '' : $aUser['account'];
|
||||
$realname = empty($aUser['realname']) ? $realname : $aUser['realname'];
|
||||
|
||||
@@ -53,12 +53,12 @@ class ArticleAiCreateContent
|
||||
$response = $oAiarticle->create($data);
|
||||
// 验证API响应
|
||||
if (empty($response)) {
|
||||
throw new RuntimeException("OpenAI API返回空结果");
|
||||
throw new \RuntimeException("OpenAI API返回空结果");
|
||||
}
|
||||
// 检查JSON解析错误
|
||||
$aResult = json_decode($response, true);
|
||||
if (json_last_error() !== JSON_ERROR_NONE) {
|
||||
throw new RuntimeException("解析OpenAI响应失败: " . json_last_error_msg() . " | 原始响应: {$response}");
|
||||
throw new \RuntimeException("解析OpenAI响应失败: " . json_last_error_msg() . " | 原始响应: {$response}");
|
||||
}
|
||||
$sMsg = empty($aResult['msg']) ? 'success' : $aResult['msg'];
|
||||
//更新完成标识
|
||||
|
||||
@@ -56,12 +56,12 @@ class ArticleReview
|
||||
$response = $oAireview->review($data);
|
||||
// 验证API响应
|
||||
if (empty($response)) {
|
||||
throw new RuntimeException("OpenAI API返回空结果");
|
||||
throw new \RuntimeException("OpenAI API返回空结果");
|
||||
}
|
||||
// 检查JSON解析错误
|
||||
$aResult = json_decode($response, true);
|
||||
if (json_last_error() !== JSON_ERROR_NONE) {
|
||||
throw new RuntimeException("解析OpenAI响应失败: " . json_last_error_msg() . " | 原始响应: {$response}");
|
||||
throw new \RuntimeException("解析OpenAI响应失败: " . json_last_error_msg() . " | 原始响应: {$response}");
|
||||
}
|
||||
$sMsg = empty($aResult['msg']) ? 'success' : $aResult['msg'];
|
||||
//更新完成标识
|
||||
|
||||
@@ -54,12 +54,12 @@ class ArticleReviewForQueue
|
||||
$response = $oOpenAi->articleReviewForQueue($data);
|
||||
// 验证API响应
|
||||
if (empty($response)) {
|
||||
throw new RuntimeException("OpenAI API返回空结果");
|
||||
throw new \RuntimeException("OpenAI API返回空结果");
|
||||
}
|
||||
// 检查JSON解析错误
|
||||
$aResult = json_decode($response, true);
|
||||
if (json_last_error() !== JSON_ERROR_NONE) {
|
||||
throw new RuntimeException("解析OpenAI响应失败: " . json_last_error_msg() . " | 原始响应: {$response}");
|
||||
throw new \RuntimeException("解析OpenAI响应失败: " . json_last_error_msg() . " | 原始响应: {$response}");
|
||||
}
|
||||
$sMsg = empty($aResult['msg']) ? '内容生成成功' : $aResult['msg'];
|
||||
|
||||
|
||||
@@ -54,12 +54,12 @@ class ArticleReviewForQueueChunk
|
||||
$response = $oOpenAi->articleReviewForQueueChunk($data);
|
||||
// 验证API响应
|
||||
if (empty($response)) {
|
||||
throw new RuntimeException("OpenAI API返回空结果");
|
||||
throw new \RuntimeException("OpenAI API返回空结果");
|
||||
}
|
||||
// 检查JSON解析错误
|
||||
$aResult = json_decode($response, true);
|
||||
if (json_last_error() !== JSON_ERROR_NONE) {
|
||||
throw new RuntimeException("解析OpenAI响应失败: " . json_last_error_msg() . " | 原始响应: {$response}");
|
||||
throw new \RuntimeException("解析OpenAI响应失败: " . json_last_error_msg() . " | 原始响应: {$response}");
|
||||
}
|
||||
$sMsg = empty($aResult['msg']) ? '内容生成成功' : $aResult['msg'];
|
||||
|
||||
|
||||
79
application/api/job/ProofRead.php
Normal file
79
application/api/job/ProofRead.php
Normal file
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
namespace app\api\job;
|
||||
|
||||
use think\queue\Job;
|
||||
use app\common\QueueJob;
|
||||
use app\common\QueueRedis;
|
||||
use app\api\controller\Aireview;
|
||||
class ProofRead
|
||||
{
|
||||
private $oQueueJob;
|
||||
private $QueueRedis;
|
||||
private $completedExprie = 3600;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->oQueueJob = new QueueJob;
|
||||
$this->QueueRedis = QueueRedis::getInstance();
|
||||
}
|
||||
|
||||
public function fire(Job $job, $data)
|
||||
{
|
||||
//任务开始判断
|
||||
$this->oQueueJob->init($job);
|
||||
|
||||
// 获取 Redis 任务的原始数据
|
||||
$rawBody = empty($job->getRawBody()) ? '' : $job->getRawBody();
|
||||
$jobData = empty($rawBody) ? [] : json_decode($rawBody, true);
|
||||
$jobId = empty($jobData['id']) ? 'unknown' : $jobData['id'];
|
||||
|
||||
$this->oQueueJob->log("-----------队列任务开始-----------");
|
||||
$this->oQueueJob->log("当前任务ID: {$jobId}, 尝试次数: {$job->attempts()}");
|
||||
|
||||
// 获取文章ID
|
||||
$iArticleId = empty($data['article_id']) ? 0 : $data['article_id'];
|
||||
if (empty($iArticleId)) {
|
||||
$this->oQueueJob->log("无效的article_id,删除任务");
|
||||
$job->delete();
|
||||
return;
|
||||
}
|
||||
try {
|
||||
|
||||
// 生成Redis键并尝试获取锁
|
||||
$sClassName = get_class($this);
|
||||
$sRedisKey = "queue_job:{$sClassName}:{$iArticleId}";
|
||||
$sRedisValue = uniqid() . '_' . getmypid();
|
||||
if (!$this->oQueueJob->acquireLock($sRedisKey, $sRedisValue, $job)) {
|
||||
return; // 未获取到锁,已处理
|
||||
}
|
||||
|
||||
//生成内容
|
||||
$oAireview = new Aireview;
|
||||
$response = $oAireview->proofRead($data);
|
||||
var_dump($response);
|
||||
// // 验证API响应
|
||||
// if (empty($response)) {
|
||||
// throw new \RuntimeException("OpenAI API返回空结果");
|
||||
// }
|
||||
// // 检查JSON解析错误
|
||||
// $aResult = json_decode($response, true);
|
||||
// if (json_last_error() !== JSON_ERROR_NONE) {
|
||||
// throw new \RuntimeException("解析OpenAI响应失败: " . json_last_error_msg() . " | 原始响应: {$response}");
|
||||
// }
|
||||
$sMsg = empty($aResult['msg']) ? 'success' : $aResult['msg'];
|
||||
//更新完成标识
|
||||
$this->QueueRedis->finishJob($sRedisKey, 'completed', $this->completedExprie,$sRedisValue);
|
||||
$job->delete();
|
||||
$this->oQueueJob->log("任务执行成功 | 日志ID: {$sRedisKey} | 执行日志:{$sMsg}");
|
||||
|
||||
} catch (\RuntimeException $e) {
|
||||
$this->oQueueJob->handleRetryableException($e,$sRedisKey,$sRedisValue, $job);
|
||||
} catch (\LogicException $e) {
|
||||
$this->oQueueJob->handleNonRetryableException($e,$sRedisKey,$sRedisValue, $job);
|
||||
} catch (\Exception $e) {
|
||||
$this->oQueueJob->handleRetryableException($e,$sRedisKey,$sRedisValue, $job);
|
||||
} finally {
|
||||
$this->oQueueJob->finnal();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -52,12 +52,12 @@ class RecommendArticleField
|
||||
$response = $oArticle->getAiField($data);
|
||||
// 验证API响应
|
||||
if (empty($response)) {
|
||||
throw new RuntimeException("OpenAI API返回空结果");
|
||||
throw new \RuntimeException("OpenAI API返回空结果");
|
||||
}
|
||||
// 检查JSON解析错误
|
||||
$aResult = json_decode($response, true);
|
||||
if (json_last_error() !== JSON_ERROR_NONE) {
|
||||
throw new RuntimeException("解析OpenAI响应失败: " . json_last_error_msg() . " | 原始响应: {$response}");
|
||||
throw new \RuntimeException("解析OpenAI响应失败: " . json_last_error_msg() . " | 原始响应: {$response}");
|
||||
}
|
||||
$sMsg = empty($aResult['msg']) ? 'success' : $aResult['msg'];
|
||||
|
||||
|
||||
@@ -54,12 +54,12 @@ class RecommendReviewer
|
||||
$response = $oReviewer->recommend($aParam);
|
||||
// 验证API响应
|
||||
if (empty($response)) {
|
||||
throw new RuntimeException("OpenAI API返回空结果");
|
||||
throw new \RuntimeException("OpenAI API返回空结果");
|
||||
}
|
||||
// 检查JSON解析错误
|
||||
$aResult = json_decode($response, true);
|
||||
if (json_last_error() !== JSON_ERROR_NONE) {
|
||||
throw new RuntimeException("解析OpenAI响应失败: " . json_last_error_msg() . " | 原始响应: {$response}");
|
||||
throw new \RuntimeException("解析OpenAI响应失败: " . json_last_error_msg() . " | 原始响应: {$response}");
|
||||
}
|
||||
$iStatus = empty($aResult['status']) ? 0 : $aResult['status'];
|
||||
$sMsg = empty($aResult['msg']) ? '' : $aResult['msg'];
|
||||
|
||||
@@ -52,12 +52,12 @@ class RelatedArticle
|
||||
$response = JournalArticle::get($data);
|
||||
// 验证API响应
|
||||
if (empty($response)) {
|
||||
throw new RuntimeException("OpenAI API返回空结果");
|
||||
throw new \RuntimeException("OpenAI API返回空结果");
|
||||
}
|
||||
// 检查JSON解析错误
|
||||
$aResult = json_decode($response, true);
|
||||
if (json_last_error() !== JSON_ERROR_NONE) {
|
||||
throw new RuntimeException("解析OpenAI响应失败: " . json_last_error_msg() . " | 原始响应: {$response}");
|
||||
throw new \RuntimeException("解析OpenAI响应失败: " . json_last_error_msg() . " | 原始响应: {$response}");
|
||||
}
|
||||
$sMsg = empty($aResult['msg']) ? '获取相关文章信息失败' : $aResult['msg'];
|
||||
|
||||
|
||||
@@ -57,12 +57,12 @@ class ReviewerScore
|
||||
$response = $oReviewer->score($aParam);
|
||||
// 验证API响应
|
||||
if (empty($response)) {
|
||||
throw new RuntimeException("OpenAI API返回空结果");
|
||||
throw new \RuntimeException("OpenAI API返回空结果");
|
||||
}
|
||||
// 检查JSON解析错误
|
||||
$aResult = json_decode($response, true);
|
||||
if (json_last_error() !== JSON_ERROR_NONE) {
|
||||
throw new RuntimeException("解析OpenAI响应失败: " . json_last_error_msg() . " | 原始响应: {$response}");
|
||||
throw new \RuntimeException("解析OpenAI响应失败: " . json_last_error_msg() . " | 原始响应: {$response}");
|
||||
}
|
||||
$sMsg = empty($aResult['msg']) ? '给审稿人评分处理失败' : $aResult['msg'];
|
||||
|
||||
|
||||
@@ -54,12 +54,12 @@ class RevisionReviewer
|
||||
$response = $oReviewer->revisionForReviewer($aParam);
|
||||
// 验证API响应
|
||||
if (empty($response)) {
|
||||
throw new RuntimeException("OpenAI API返回空结果");
|
||||
throw new \RuntimeException("OpenAI API返回空结果");
|
||||
}
|
||||
// 检查JSON解析错误
|
||||
$aResult = json_decode($response, true);
|
||||
if (json_last_error() !== JSON_ERROR_NONE) {
|
||||
throw new RuntimeException("解析OpenAI响应失败: " . json_last_error_msg() . " | 原始响应: {$response}");
|
||||
throw new \RuntimeException("解析OpenAI响应失败: " . json_last_error_msg() . " | 原始响应: {$response}");
|
||||
}
|
||||
$sMsg = empty($aResult['msg']) ? '审稿人同意审稿但超时未审的数据失败' : $aResult['msg'];
|
||||
|
||||
|
||||
@@ -52,12 +52,12 @@ class WechatDraft
|
||||
$response = $oAiarticle->syncWechat($data);
|
||||
// 验证API响应
|
||||
if (empty($response)) {
|
||||
throw new RuntimeException("OpenAI API返回空结果");
|
||||
throw new \RuntimeException("OpenAI API返回空结果");
|
||||
}
|
||||
// 检查JSON解析错误
|
||||
$aResult = json_decode($response, true);
|
||||
if (json_last_error() !== JSON_ERROR_NONE) {
|
||||
throw new RuntimeException("解析OpenAI响应失败: " . json_last_error_msg() . " | 原始响应: {$response}");
|
||||
throw new \RuntimeException("解析OpenAI响应失败: " . json_last_error_msg() . " | 原始响应: {$response}");
|
||||
}
|
||||
$sMsg = empty($aResult['msg']) ? '上传草稿箱失败' : $aResult['msg'];
|
||||
|
||||
|
||||
@@ -52,12 +52,12 @@ class WechatDraftPublish
|
||||
$response = $oAiarticle->publishDraft($data);
|
||||
// 验证API响应
|
||||
if (empty($response)) {
|
||||
throw new RuntimeException("OpenAI API返回空结果");
|
||||
throw new \RuntimeException("OpenAI API返回空结果");
|
||||
}
|
||||
// 检查JSON解析错误
|
||||
$aResult = json_decode($response, true);
|
||||
if (json_last_error() !== JSON_ERROR_NONE) {
|
||||
throw new RuntimeException("解析OpenAI响应失败: " . json_last_error_msg() . " | 原始响应: {$response}");
|
||||
throw new \RuntimeException("解析OpenAI响应失败: " . json_last_error_msg() . " | 原始响应: {$response}");
|
||||
}
|
||||
$sMsg = empty($aResult['msg']) ? '草稿箱发布失败' : $aResult['msg'];
|
||||
|
||||
|
||||
@@ -52,12 +52,12 @@ class WechatMaterial
|
||||
$response = $oAiarticle->uploadMaterial($data);
|
||||
// 验证API响应
|
||||
if (empty($response)) {
|
||||
throw new RuntimeException("OpenAI API返回空结果");
|
||||
throw new \RuntimeException("OpenAI API返回空结果");
|
||||
}
|
||||
// 检查JSON解析错误
|
||||
$aResult = json_decode($response, true);
|
||||
if (json_last_error() !== JSON_ERROR_NONE) {
|
||||
throw new RuntimeException("解析OpenAI响应失败: " . json_last_error_msg() . " | 原始响应: {$response}");
|
||||
throw new \RuntimeException("解析OpenAI响应失败: " . json_last_error_msg() . " | 原始响应: {$response}");
|
||||
}
|
||||
$sMsg = empty($aResult['msg']) ? '上传素材失败' : $aResult['msg'];
|
||||
|
||||
|
||||
@@ -52,12 +52,12 @@ class WechatQueryStatus
|
||||
$response = $oAiarticle->queryStatus($data);
|
||||
// 验证API响应
|
||||
if (empty($response)) {
|
||||
throw new RuntimeException("OpenAI API返回空结果");
|
||||
throw new \RuntimeException("OpenAI API返回空结果");
|
||||
}
|
||||
// 检查JSON解析错误
|
||||
$aResult = json_decode($response, true);
|
||||
if (json_last_error() !== JSON_ERROR_NONE) {
|
||||
throw new RuntimeException("解析OpenAI响应失败: " . json_last_error_msg() . " | 原始响应: {$response}");
|
||||
throw new \RuntimeException("解析OpenAI响应失败: " . json_last_error_msg() . " | 原始响应: {$response}");
|
||||
}
|
||||
$sMsg = empty($aResult['msg']) ? '查询草稿箱文章是否发布失败' : $aResult['msg'];
|
||||
|
||||
|
||||
@@ -54,12 +54,12 @@ class CreateFieldForQueue
|
||||
$response = $oOpenAi->createFieldForQueue($data);
|
||||
// 验证API响应
|
||||
if (empty($response)) {
|
||||
throw new RuntimeException("OpenAI API返回空结果");
|
||||
throw new \RuntimeException("OpenAI API返回空结果");
|
||||
}
|
||||
// 检查JSON解析错误
|
||||
$aResult = json_decode($response, true);
|
||||
if (json_last_error() !== JSON_ERROR_NONE) {
|
||||
throw new RuntimeException("解析OpenAI响应失败: " . json_last_error_msg() . " | 原始响应: {$response}");
|
||||
throw new \RuntimeException("解析OpenAI响应失败: " . json_last_error_msg() . " | 原始响应: {$response}");
|
||||
}
|
||||
$sMsg = empty($aResult['msg']) ? '内容生成成功' : $aResult['msg'];
|
||||
|
||||
|
||||
@@ -56,12 +56,12 @@ class uploadMaterialStep
|
||||
$response = $oMaterial->uploadMaterialStep($data);
|
||||
// 验证API响应
|
||||
if (empty($response)) {
|
||||
throw new RuntimeException("OpenAI API返回空结果");
|
||||
throw new \RuntimeException("OpenAI API返回空结果");
|
||||
}
|
||||
// 检查JSON解析错误
|
||||
$aResult = json_decode($response, true);
|
||||
if (json_last_error() !== JSON_ERROR_NONE) {
|
||||
throw new RuntimeException("解析OpenAI响应失败: " . json_last_error_msg() . " | 原始响应: {$response}");
|
||||
throw new \RuntimeException("解析OpenAI响应失败: " . json_last_error_msg() . " | 原始响应: {$response}");
|
||||
}
|
||||
$sMsg = empty($aResult['msg']) ? '素材上传失败' : $aResult['msg'];
|
||||
|
||||
|
||||
@@ -658,7 +658,7 @@ class Material
|
||||
}
|
||||
if($iProgress >= 100){//上传素材完成后【1分钟后推送草稿箱】
|
||||
$iDelaySeconds = 60;// 1分钟的秒数
|
||||
Queue::later($iDelaySeconds,'app\api\job\WechatDraft@fire', ['article_id' => $iId], 'WechatDraft')
|
||||
Queue::later($iDelaySeconds,'app\api\job\WechatDraft@fire', ['article_id' => $iId], 'WechatDraft');
|
||||
}
|
||||
return json_encode($aResult);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user