diff --git a/application/api/controller/Aiarticle.php b/application/api/controller/Aiarticle.php index 520f350..eecd549 100644 --- a/application/api/controller/Aiarticle.php +++ b/application/api/controller/Aiarticle.php @@ -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]); } diff --git a/application/api/controller/Article.php b/application/api/controller/Article.php index 90a7078..a7dc0b5 100644 --- a/application/api/controller/Article.php +++ b/application/api/controller/Article.php @@ -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(); diff --git a/application/api/controller/Finalreview.php b/application/api/controller/Finalreview.php index 6f150d3..f968d6f 100644 --- a/application/api/controller/Finalreview.php +++ b/application/api/controller/Finalreview.php @@ -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},

I hope this message finds you well.

- We would like to invite you to conduct the final review of the manuscript detailed below:
+ We would like to invite you to conduct the final decision of the manuscript detailed below:
Title: [{article_title}]
Manuscript ID: [{accept_sn}]

- 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.

+ 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.

Click here to review the article and kindly submit your final comments within 5 days
Click here to reject the review of this manuscript
Your username: {account}
@@ -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']; diff --git a/application/api/job/ArticleAiCreateContent.php b/application/api/job/ArticleAiCreateContent.php index 6a2863d..314077d 100644 --- a/application/api/job/ArticleAiCreateContent.php +++ b/application/api/job/ArticleAiCreateContent.php @@ -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']; //更新完成标识 diff --git a/application/api/job/ArticleReview.php b/application/api/job/ArticleReview.php index acdfa6a..2838109 100644 --- a/application/api/job/ArticleReview.php +++ b/application/api/job/ArticleReview.php @@ -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']; //更新完成标识 diff --git a/application/api/job/ArticleReviewForQueue.php b/application/api/job/ArticleReviewForQueue.php index 9aea199..d8a2e84 100644 --- a/application/api/job/ArticleReviewForQueue.php +++ b/application/api/job/ArticleReviewForQueue.php @@ -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']; diff --git a/application/api/job/ArticleReviewForQueueChunk.php b/application/api/job/ArticleReviewForQueueChunk.php index 039e3c6..5f7ddc4 100644 --- a/application/api/job/ArticleReviewForQueueChunk.php +++ b/application/api/job/ArticleReviewForQueueChunk.php @@ -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']; diff --git a/application/api/job/ProofRead.php b/application/api/job/ProofRead.php new file mode 100644 index 0000000..ff99882 --- /dev/null +++ b/application/api/job/ProofRead.php @@ -0,0 +1,79 @@ +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(); + } + } +} \ No newline at end of file diff --git a/application/api/job/RecommendArticleField.php b/application/api/job/RecommendArticleField.php index 4226db1..437e63c 100644 --- a/application/api/job/RecommendArticleField.php +++ b/application/api/job/RecommendArticleField.php @@ -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']; diff --git a/application/api/job/RecommendReviewer.php b/application/api/job/RecommendReviewer.php index da8ee74..b9e749c 100644 --- a/application/api/job/RecommendReviewer.php +++ b/application/api/job/RecommendReviewer.php @@ -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']; diff --git a/application/api/job/RelatedArticle.php b/application/api/job/RelatedArticle.php index 59e4c1b..d947f4e 100644 --- a/application/api/job/RelatedArticle.php +++ b/application/api/job/RelatedArticle.php @@ -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']; diff --git a/application/api/job/ReviewerScore.php b/application/api/job/ReviewerScore.php index cbd28ee..ca3950d 100644 --- a/application/api/job/ReviewerScore.php +++ b/application/api/job/ReviewerScore.php @@ -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']; diff --git a/application/api/job/RevisionReviewer.php b/application/api/job/RevisionReviewer.php index ecc1e52..1f38213 100644 --- a/application/api/job/RevisionReviewer.php +++ b/application/api/job/RevisionReviewer.php @@ -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']; diff --git a/application/api/job/WechatDraft.php b/application/api/job/WechatDraft.php index fe2de53..84cfefe 100644 --- a/application/api/job/WechatDraft.php +++ b/application/api/job/WechatDraft.php @@ -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']; diff --git a/application/api/job/WechatDraftPublish.php b/application/api/job/WechatDraftPublish.php index f71563e..ebe94bd 100644 --- a/application/api/job/WechatDraftPublish.php +++ b/application/api/job/WechatDraftPublish.php @@ -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']; diff --git a/application/api/job/WechatMaterial.php b/application/api/job/WechatMaterial.php index 90a3e5d..d676f78 100644 --- a/application/api/job/WechatMaterial.php +++ b/application/api/job/WechatMaterial.php @@ -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']; diff --git a/application/api/job/WechatQueryStatus.php b/application/api/job/WechatQueryStatus.php index ba1291b..3458e87 100644 --- a/application/api/job/WechatQueryStatus.php +++ b/application/api/job/WechatQueryStatus.php @@ -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']; diff --git a/application/api/job/createFieldForQueue.php b/application/api/job/createFieldForQueue.php index 5458880..57f3c23 100644 --- a/application/api/job/createFieldForQueue.php +++ b/application/api/job/createFieldForQueue.php @@ -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']; diff --git a/application/api/job/uploadMaterialStep.php b/application/api/job/uploadMaterialStep.php index 98bbba9..219d0f7 100644 --- a/application/api/job/uploadMaterialStep.php +++ b/application/api/job/uploadMaterialStep.php @@ -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']; diff --git a/application/common/Material.php b/application/common/Material.php index 8847daa..0ed5770 100644 --- a/application/common/Material.php +++ b/application/common/Material.php @@ -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); }