校对
This commit is contained in:
@@ -129,7 +129,7 @@ class Proofread extends Base
|
|||||||
if(empty($aArticle)){
|
if(empty($aArticle)){
|
||||||
return json_encode(['status' => 3,'msg' => 'The query article does not exist']);
|
return json_encode(['status' => 3,'msg' => 'The query article does not exist']);
|
||||||
}
|
}
|
||||||
if($aArticle['state'] < 5 || $aArticle['state'] == 8){
|
if($aArticle['state'] != 6){
|
||||||
return json_encode(array('status' => 4,'msg' => 'The article has not entered the proofreading stage'));
|
return json_encode(array('status' => 4,'msg' => 'The article has not entered the proofreading stage'));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -326,12 +326,20 @@ class Proofread extends Base
|
|||||||
//数据库更新
|
//数据库更新
|
||||||
$aWhere = ['id' => $iId];
|
$aWhere = ['id' => $iId];
|
||||||
$result_proofread= Db::name('article_proofread')->where($aWhere)->limit(1)->update($aUpdate);
|
$result_proofread= Db::name('article_proofread')->where($aWhere)->limit(1)->update($aUpdate);
|
||||||
if(!$result_proofread || !$result_main){
|
if($result_proofread === false || $result_main === false){
|
||||||
return json_encode(['status' => 7,'msg' => "Update failed"]);
|
return json_encode(['status' => 7,'msg' => "Update failed"]);
|
||||||
}
|
}
|
||||||
Db::commit();
|
Db::commit();
|
||||||
|
//查询未执行的数量
|
||||||
|
$aCount = json_decode($this->getCountByState(['article_id' => $iArticleId,'state' => 2,'am_id' => $iAmId]),true);
|
||||||
|
$aCount = empty($aCount['data']) ? [] : $aCount['data'];
|
||||||
|
|
||||||
//返回结果
|
//返回结果
|
||||||
return json_encode(['status' => 1,'msg' => "Update successful",'data' => $sData]);
|
$aData = [];
|
||||||
|
$aData['sum_count'] = empty($aCount['sum_count']) ? 0 : $aCount['sum_count'];
|
||||||
|
$aData['am_id_count'] = empty($aCount['am_id_count']) ? 0 : $aCount['am_id_count'];
|
||||||
|
$aData['content'] = $sData;
|
||||||
|
return json_encode(['status' => 1,'msg' => "Update successful",'data' => $aData]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -500,4 +508,48 @@ class Proofread extends Base
|
|||||||
//返回结果
|
//返回结果
|
||||||
return json_encode(['status' => 1,'msg' => "Update successful"]);
|
return json_encode(['status' => 1,'msg' => "Update successful"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @title 根据状态统计数量
|
||||||
|
* @param article_id 文章ID
|
||||||
|
* @param am_id 行号
|
||||||
|
* @param state 状态1已执行2未执行3删除
|
||||||
|
*/
|
||||||
|
public function getCountByState($aParam = []){
|
||||||
|
|
||||||
|
//获取参数
|
||||||
|
$aParam = empty($aParam) ? $this->request->post() : $aParam;
|
||||||
|
//参数验证-文章ID
|
||||||
|
$iArticleId = empty($aParam['article_id']) ? 0 : $aParam['article_id'];
|
||||||
|
if(empty($iArticleId)){
|
||||||
|
return json_encode(['status' => 2,'msg' => 'Please select a article']);
|
||||||
|
}
|
||||||
|
//行号
|
||||||
|
$iAmId = empty($aParam['am_id']) ? 0 : $aParam['am_id'];
|
||||||
|
|
||||||
|
//查询文章
|
||||||
|
$aWhere = ['article_id' => $iArticleId];
|
||||||
|
$aArticle = Db::name('article')->field('journal_id,state')->where($aWhere)->find();
|
||||||
|
if(empty($aArticle)){
|
||||||
|
return json_encode(['status' => 3,'msg' => 'The query article does not exist']);
|
||||||
|
}
|
||||||
|
if($aArticle['state'] != 6){
|
||||||
|
return json_encode(array('status' => 4,'msg' => 'The article has not entered the proofreading stage'));
|
||||||
|
}
|
||||||
|
|
||||||
|
//查询校对内容
|
||||||
|
if(!empty($iAmId)){
|
||||||
|
$aWhere['am_id'] = $iAmId;
|
||||||
|
}
|
||||||
|
$iState = empty($aParam['state']) ? 2 : explode(',', $aParam['state']);
|
||||||
|
if(!empty($iState)){
|
||||||
|
$aWhere['state'] = ['in',$iState];
|
||||||
|
}
|
||||||
|
$aCount = Db::name('article_proofread')->field('am_id,count(id) as num')->where($aWhere)->group('am_id')->select();
|
||||||
|
$aCount = empty($aCount) ? [] : array_column($aCount, 'num','am_id');
|
||||||
|
//总数量
|
||||||
|
$iCount = empty($aCount) ? 0 : array_sum(array_values($aCount));
|
||||||
|
$am_id_count = empty($aCount[$iAmId]) ? 0 : $aCount[$iAmId];
|
||||||
|
return json_encode(['status' => 1,'msg' => 'success','data' => ['sum_count' => $iCount,'am_id_count' => $am_id_count]]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user