校对状态数量统计
This commit is contained in:
@@ -49,7 +49,7 @@ class Proofread extends Base
|
||||
$aWhere['type'] = 0;
|
||||
$aWhere['content'] = ['<>',''];
|
||||
$aWhere['state'] = 0;
|
||||
$aArticleMain = Db::table('t_article_main')->field('am_id,content,type,is_h1,is_h2,is_h3,ami_id,amt_id')->where($aWhere)->select();
|
||||
$aArticleMain = Db::table('t_article_main')->field('am_id,content,type,is_h1,is_h2,is_h3,is_proofread')->where($aWhere)->order('sort asc')->select();
|
||||
if(empty($aArticleMain)){
|
||||
return json_encode(array('status' => 5,'msg' => 'The content of the article is empty'));
|
||||
}
|
||||
@@ -58,11 +58,14 @@ class Proofread extends Base
|
||||
$oHelperFunction = new \app\common\HelperFunction;
|
||||
$oProofReadService = new \app\common\ProofReadService;
|
||||
//数据处理
|
||||
$aH = $aTable = [];
|
||||
$aId = [];
|
||||
foreach ($aArticleMain as $key => $value) {
|
||||
if(empty($oHelperFunction->filterAllTags($value['content']))){
|
||||
continue;
|
||||
}
|
||||
if($value['is_proofread'] == 2){
|
||||
$aId[] = $value['am_id'];
|
||||
}
|
||||
$aResult = $oProofReadService->proofread($value['content']);
|
||||
if(empty($aResult)){
|
||||
continue;
|
||||
@@ -71,6 +74,15 @@ class Proofread extends Base
|
||||
$aError[] = $aResult;
|
||||
}
|
||||
if(empty($aError)){
|
||||
//更新文章内容的校对时间及状态
|
||||
$iCount = count($aId);
|
||||
if($iCount > 0){
|
||||
$aUpdateWhere = ['am_id' => ['in',$aId]];
|
||||
$update_result = Db::name('article_main')->where($aUpdateWhere)->limit($iCount)->update(['is_proofread' => 1,'proofread_time' => time()]);
|
||||
if($update_result === false){
|
||||
return json_encode(array('status' => 6,'msg' => 'Failed to update paragraph proofreading status-'.$update_result));
|
||||
}
|
||||
}
|
||||
return json_encode(array('status' => 1,'msg' => 'No errors found'));
|
||||
}
|
||||
//数据处理
|
||||
@@ -90,11 +102,21 @@ class Proofread extends Base
|
||||
if(empty($aData)){
|
||||
return json_encode(array('status' => 1,'msg' => 'Data processing failed'));
|
||||
}
|
||||
|
||||
Db::startTrans();
|
||||
//更新文章内容的校对时间及状态
|
||||
$iCount = count($aId);
|
||||
$update_result = true;
|
||||
if($iCount > 0){
|
||||
$aUpdateWhere = ['am_id' => ['in',$aId]];
|
||||
$update_result = Db::name('article_main')->where($aUpdateWhere)->limit($iCount)->update(['is_proofread' => 1,'proofread_time' => time()]);
|
||||
}
|
||||
//插入
|
||||
$result = Db::name('article_proofread')->insertAll($aData);
|
||||
if(!$result){
|
||||
return json_encode(array('status' => 6,'msg' => 'No errors found'));
|
||||
if(!$result || $update_result === false){
|
||||
return json_encode(array('status' => 6,'msg' => 'Data operation failed:insert-'.$result.';update-'.$update_result));
|
||||
}
|
||||
Db::commit();
|
||||
return json_encode(['status' => 1,'msg' => 'Proofreading successful']);
|
||||
}
|
||||
/**
|
||||
@@ -552,7 +574,13 @@ class Proofread extends Base
|
||||
if(!empty($aCountData[$iAmId])){
|
||||
$am_id_count = empty($aCountData[$iAmId][2]) ? 0 : $aCountData[$iAmId][2];
|
||||
}
|
||||
return json_encode(['status' => 1,'msg' => 'success','data' => ['sum_count' => $iCount,'am_id_count' => $am_id_count]]);
|
||||
$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'];
|
||||
}
|
||||
return json_encode(['status' => 1,'msg' => 'success','data' => ['sum_count' => $iCount,'am_id_count' => $am_id_count,'is_proofread' => $is_proofread]]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -590,7 +618,7 @@ class Proofread extends Base
|
||||
$aWhere['content'] = ['<>',''];
|
||||
$aWhere['state'] = 0;
|
||||
$aWhere['am_id'] = $iAmId;
|
||||
$aArticleMain = Db::table('t_article_main')->field('am_id,content,type,is_h1,is_h2,is_h3,ami_id,amt_id')->where($aWhere)->find();
|
||||
$aArticleMain = Db::table('t_article_main')->field('am_id,content,type,is_h1,is_h2,is_h3,is_proofread')->where($aWhere)->find();
|
||||
if(empty($aArticleMain['content'])){
|
||||
return json_encode(array('status' => 5,'msg' => 'The content of the article is empty'));
|
||||
}
|
||||
@@ -632,7 +660,7 @@ class Proofread extends Base
|
||||
$aWhere['content'] = ['<>',''];
|
||||
$aWhere['state'] = 0;
|
||||
$aWhere['am_id'] = $iAmId;
|
||||
$aArticleMain = Db::table('t_article_main')->field('am_id,content,type,is_h1,is_h2,is_h3,ami_id,amt_id')->where($aWhere)->find();
|
||||
$aArticleMain = Db::table('t_article_main')->field('am_id,content,type,is_h1,is_h2,is_h3,is_proofread')->where($aWhere)->find();
|
||||
if(empty($aArticleMain)){
|
||||
return json_encode(array('status' => 5,'msg' => 'The content of the article is empty'));
|
||||
}
|
||||
@@ -649,6 +677,11 @@ class Proofread extends Base
|
||||
//数据处理
|
||||
$aError = empty($aResult['errors']) ? [] : $aResult['errors'];
|
||||
if(empty($aError)){
|
||||
$aUpdateWhere = ['am_id' => $iAmId];
|
||||
$update_result = Db::name('article_main')->where($aUpdateWhere)->limit(1)->update(['is_proofread' => 1,'proofread_time' => time()]);
|
||||
if($update_result === false){
|
||||
return json_encode(array('status' => 6,'msg' => 'Failed to update paragraph proofreading status-'.$update_result));
|
||||
}
|
||||
return json_encode(array('status' => 1,'msg' => 'No errors found'));
|
||||
}
|
||||
$aData = [];
|
||||
@@ -665,13 +698,15 @@ class Proofread extends Base
|
||||
}
|
||||
|
||||
Db::startTrans();
|
||||
$aUpdateWhere = ['am_id' => $iAmId];
|
||||
$update_result = Db::name('article_main')->where($aUpdateWhere)->limit(1)->update(['is_proofread' => 1,'proofread_time' => time()]);
|
||||
//更新之前未执行的数据
|
||||
$aWhere = ['am_id' => $iAmId,'article_id' => $iArticleId,'is_delete' => 2,'state' => 2];
|
||||
$result_update = Db::name('article_proofread')->where($aWhere)->update(['is_delete' => 1,'update_time' => time()]);
|
||||
//插入
|
||||
$result = Db::name('article_proofread')->insertAll($aData);
|
||||
if(!$result || $result_update === false){
|
||||
return json_encode(array('status' => 6,'msg' => 'No errors found'));
|
||||
if(!$result || $result_update === false || $update_result === false){
|
||||
return json_encode(array('status' => 6,'msg' => 'Data operation failed:insert-'.$result.';result_update-'.$result_update.';update_result-'.$update_result));
|
||||
}
|
||||
Db::commit();
|
||||
return json_encode(['status' => 1,'msg' => 'Proofreading successful']);
|
||||
|
||||
Reference in New Issue
Block a user