From 4f517e6e569037d3f11c93e4f94dbbd143399934 Mon Sep 17 00:00:00 2001 From: chengxl Date: Fri, 17 Oct 2025 13:32:41 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A0=A1=E5=AF=B9=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/api/controller/Proofread.php | 69 +++++++++++++++++++++--- 1 file changed, 61 insertions(+), 8 deletions(-) diff --git a/application/api/controller/Proofread.php b/application/api/controller/Proofread.php index deedae5..46e4aa3 100644 --- a/application/api/controller/Proofread.php +++ b/application/api/controller/Proofread.php @@ -32,7 +32,8 @@ class Proofread extends Base if(empty($aArticle)){ return json_encode(array('status' => 3,'msg' => 'No articles requiring review were found' )); } - if($aArticle['state'] != 6){ + + if($aArticle['state'] != 6 && $aArticle['state'] != 5){ return json_encode(array('status' => 4,'msg' => 'The article has not entered the proofreading stage')); } @@ -143,7 +144,7 @@ class Proofread extends Base if(empty($aArticle)){ return json_encode(['status' => 3,'msg' => 'The query article does not exist']); } - if($aArticle['state'] != 6){ + if($aArticle['state'] != 6 && $aArticle['state'] != 5){ return json_encode(array('status' => 4,'msg' => 'The article has not entered the proofreading stage')); } @@ -549,7 +550,7 @@ class Proofread extends Base if(empty($aArticle)){ return json_encode(['status' => 3,'msg' => 'The query article does not exist']); } - if($aArticle['state'] != 6){ + if($aArticle['state'] != 6 && $aArticle['state'] != 5){ return json_encode(array('status' => 4,'msg' => 'The article has not entered the proofreading stage')); } @@ -575,10 +576,20 @@ class Proofread extends Base $am_id_count = empty($aCountData[$iAmId][2]) ? 0 : $aCountData[$iAmId][2]; } $is_proofread = -1; + //查询是否校对 + $aWhere = ['state' => 0,'is_proofread' => 1]; if(!empty($iAmId)){ - $aWhere = ['state' => 0,'am_id' => $iAmId]; - $aArticleMain = Db::name('article_main')->field('is_proofread')->where($aWhere)->find(); - $is_proofread = empty($aArticleMain['is_proofread']) ? $is_proofread : $aArticleMain['is_proofread']; + $aWhere['am_id'] = $iAmId; + } + $iProofCount = Db::name('article_main')->where($aWhere)->count(); + $is_proofread = $iProofCount > 0 ? 1 : 2; + + //总数量统计 + if($iCount == -1 && $iProofCount > 0){ + $iCount = 0; + } + if($am_id_count == -1 && $iProofCount > 0){ + $am_id_count = 0; } return json_encode(['status' => 1,'msg' => 'success','data' => ['sum_count' => $iCount,'am_id_count' => $am_id_count,'is_proofread' => $is_proofread]]); } @@ -609,7 +620,7 @@ class Proofread extends Base if(empty($aArticle)){ return json_encode(array('status' => 3,'msg' => 'No articles requiring review were found' )); } - if($aArticle['state'] != 6){ + if($aArticle['state'] != 6 && $aArticle['state'] != 5){ return json_encode(array('status' => 4,'msg' => 'The article has not entered the proofreading stage')); } @@ -651,7 +662,7 @@ class Proofread extends Base if(empty($aArticle)){ return json_encode(array('status' => 3,'msg' => 'No articles requiring review were found' )); } - if($aArticle['state'] != 6){ + if($aArticle['state'] != 6 && $aArticle['state'] != 5){ return json_encode(array('status' => 4,'msg' => 'The article has not entered the proofreading stage')); } @@ -711,4 +722,46 @@ class Proofread extends Base Db::commit(); return json_encode(['status' => 1,'msg' => 'Proofreading successful']); } + /** + * @title AI文章校对-全文章 + * @param article_id 文章ID + */ + public function proofReadByArticle(){ + + //获取参数 + $aParam = empty($aParam) ? $this->request->post() : $aParam; + $iArticleId = empty($aParam['article_id']) ? '' : $aParam['article_id']; + if(empty($iArticleId)){ + return json_encode(array('status' => 2,'msg' => 'Please select an article' )); + } + //查询文章 + $aWhere = ['article_id' => $iArticleId]; + $oArticle = new Article; + $aArticle = json_decode($oArticle->get($aWhere),true); + $aArticle = empty($aArticle['data']) ? [] : $aArticle['data']; + if(empty($aArticle)){ + return json_encode(array('status' => 3,'msg' => 'No articles requiring review were found' )); + } + if($aArticle['state'] != 6 && $aArticle['state'] != 5){ + return json_encode(array('status' => 4,'msg' => 'The article has not entered the proofreading stage')); + } + + //查询文章内容 + $aWhere['type'] = 0; + $aWhere['content'] = ['<>','']; + $aWhere['state'] = 0; + $iCount = Db::table('t_article_main')->where($aWhere)->count(); + if(empty($iCount)){ + return json_encode(array('status' => 5,'msg' => 'The content of the article is empty')); + } + //查询是否进行过校对 + $aProofReadWhere = ['article_id' => $iArticleId,'state' => 2,'is_delete' => 2]; + $iCount = Db::name('article_proofread')->where($aProofReadWhere)->count(); + if(!empty($iCount)){ + return json_encode(array('status' => 6,'msg' => 'The article or paragraph has been proofread')); + } + //写入校对行队列 + $sQueue = \think\Queue::push('app\api\job\ArticleProofReadedi@fire',$aParam,'ArticleProofReadedi'); + return json_encode(array('status' => 1,'msg' => 'Proofreading in progress, check the results in one minute')); + } }