接口调整
This commit is contained in:
@@ -47,33 +47,6 @@ class Preaccept extends Base
|
|||||||
return jsonSuccess($re);
|
return jsonSuccess($re);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function spiltContent(){
|
|
||||||
$data = $this->request->post();
|
|
||||||
$rule = new Validate([
|
|
||||||
"content"=>"require"
|
|
||||||
]);
|
|
||||||
if(!$rule->check($data)){
|
|
||||||
return jsonError($rule->getError());
|
|
||||||
}
|
|
||||||
$text = $data['content'];
|
|
||||||
|
|
||||||
$text = preg_replace('/(\d+)([a-zA-Z%℃°]+)/', '$1 $2', $text);
|
|
||||||
|
|
||||||
$text = preg_replace('/\s*%\s*/', '%', $text);
|
|
||||||
|
|
||||||
|
|
||||||
$pattern_en_dash = '/(\d+)–(\d+)/';
|
|
||||||
$text = preg_replace($pattern_en_dash, '$1-$2', $text);
|
|
||||||
|
|
||||||
|
|
||||||
$pattern_em_dash = '/(\d+)—(\d+)/';
|
|
||||||
$text = preg_replace($pattern_em_dash, '$1-$2', $text);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**清空引用文献
|
/**清空引用文献
|
||||||
* @return \think\response\Json
|
* @return \think\response\Json
|
||||||
* @throws \think\Exception
|
* @throws \think\Exception
|
||||||
@@ -1503,5 +1476,97 @@ return null;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getArticleMainsNew(){
|
||||||
|
$data = $this->request->post();
|
||||||
|
$rule = new Validate([
|
||||||
|
"article_id"=>"require"
|
||||||
|
]);
|
||||||
|
if(!$rule->check($data)){
|
||||||
|
return jsonError($rule->getError());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
//定义空数组
|
||||||
|
$re = ['list' => []];
|
||||||
|
//获取数量
|
||||||
|
$aWhere = ['article_id' => $data['article_id'],'state' => ['in',[0,2]]];
|
||||||
|
$iCount = $this->article_main_obj->where($aWhere)->count();
|
||||||
|
if(empty($iCount)){
|
||||||
|
$this->addArticleMainEx($data['article_id']);
|
||||||
|
}
|
||||||
|
|
||||||
|
//获取数据
|
||||||
|
$aArticleMain = Db::name("article_main")->where($aWhere)->order("sort asc")->select();
|
||||||
|
if(empty($aArticleMain)){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
//处理数据
|
||||||
|
$iSize = 300;
|
||||||
|
$aChunk = array_chunk($aArticleMain, $iSize);
|
||||||
|
$mains = [];
|
||||||
|
foreach ($aChunk as $item) {
|
||||||
|
$aMId = array_column($item, 'am_id');
|
||||||
|
//查询article_main_check
|
||||||
|
$aWhere = ['am_id' => ['in',$aMId],'state' => 0];
|
||||||
|
$aMainCheck = Db::name("article_main_check")->where($aWhere)->select();
|
||||||
|
$aMainCheckData = [];
|
||||||
|
if(!empty($aMainCheck)){
|
||||||
|
foreach ($aMainCheck as $value) {
|
||||||
|
if(empty($value['am_id'])){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$aMainCheckData[$value['am_id']][] = $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//获取图片信息
|
||||||
|
$aMiId = array_unique(array_column($item, 'ami_id'));
|
||||||
|
$aWhere = ['ami_id' => ['in',$aMiId],'state' => 0];
|
||||||
|
$aArticleMainImage = Db::name("article_main_image")->where($aWhere)->select();
|
||||||
|
$aArticleMainImage = empty($aArticleMainImage) ? [] : array_column($aArticleMainImage, null,'ami_id');
|
||||||
|
//获取表格信息
|
||||||
|
$aMiId = array_unique(array_column($item, 'amt_id'));
|
||||||
|
$aWhere = ['amt_id' => ['in',$aMiId],'state' => 0];
|
||||||
|
$aArticleMainTable = Db::name("article_main_table")->where($aWhere)->select();
|
||||||
|
$aArticleMainTable = empty($aArticleMainTable) ? [] : array_column($aArticleMainTable, null,'amt_id');
|
||||||
|
|
||||||
|
//查询校对数量 t_article_proofread
|
||||||
|
$aWhere = ['am_id' => ['in',$aMId],'state' => ['between',[1,2]],'is_delete' => 2];
|
||||||
|
$aArticleProofread = Db::name("article_proofread")->field('am_id,count(id) as num,state')->where($aWhere)->group('am_id,state')->select();
|
||||||
|
$aArticleProofreadData = [];
|
||||||
|
if(!empty($aArticleProofread)){
|
||||||
|
foreach ($aArticleProofread as $key => $value) {
|
||||||
|
$aArticleProofreadData[$value['am_id']][$value['state']] = $value['num'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($item as $k => $main) {
|
||||||
|
if($main['is_h1']==1){
|
||||||
|
$main['content'] = "<b><i>".$main['content']."</i></b>";
|
||||||
|
}
|
||||||
|
if($main['is_h2']==1||$main['is_h3']==1){
|
||||||
|
$main['content'] = "<b>".$main['content']."</b>";
|
||||||
|
}
|
||||||
|
$main['checks'] = empty($aMainCheckData[$main['am_id']]) ? [] : $aMainCheckData[$main['am_id']];
|
||||||
|
if($main['type'] == 1){
|
||||||
|
$main['image'] = empty($aArticleMainImage[$main['ami_id']]) ? [] : $aArticleMainImage[$main['ami_id']];
|
||||||
|
}
|
||||||
|
if($main['type'] == 2){
|
||||||
|
$main['table'] = empty($aArticleMainTable[$main['amt_id']]) ? [] : $aArticleMainTable[$main['amt_id']];
|
||||||
|
}
|
||||||
|
if($main['type'] == 0){
|
||||||
|
$aDataInfo = empty($aArticleProofreadData[$main['am_id']]) ? [] : $aArticleProofreadData[$main['am_id']];
|
||||||
|
$main['proof_read_num'] = -1;
|
||||||
|
if(!empty($aDataInfo)){
|
||||||
|
$main['proof_read_num'] = empty($aDataInfo[2]) ? 0 : $aDataInfo[2];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$mains[] = $main;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
$re['list'] = $mains;
|
||||||
|
return jsonSuccess($re);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user