Merge remote-tracking branch 'origin/master'

This commit is contained in:
wangjinlei
2026-01-18 17:23:31 +08:00
6 changed files with 971 additions and 11 deletions

View File

@@ -4196,4 +4196,72 @@ class Production extends Base
$sContent .= $sReferences;
return ['status' => 1,'msg' => 'success','data' => ['references' => $sContent,'references_list' => $aReferencesLists]];
}
/**
* 生成初稿-处理正文内容表格/图片相关联
* @param p_article_id 生产环境文章信息
*/
public function dealMainFigureOrTable(){
//获取参数
$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,'type' => 0,'state' => 0,'is_h1' => ['<>',1],'is_h2' => ['<>',1],'is_h3' => ['<>',1]];
$aTextMain = Db::name('article_main')->field('am_id,content')->where($aWhere)->order('sort asc')->select();
if(empty($aTextMain)){
return json_encode(array('status' => 3,'msg' => 'The content is empty' ));
}
//查询图片信息
$aWhere = ['article_id' => $iArticleId,'type' => 1,'state' => 0];
$aImageMain = Db::name('article_main')->where($aWhere)->order('sort asc')->column('ami_id');
//查询图片信息
$aWhere = ['article_id' => $iArticleId,'type' => 2,'state' => 0];
$aTableMain = Db::name('article_main')->where($aWhere)->order('sort asc')->column('amt_id');
//数据处理
$aUpdate = [];
$oFigureTagProcessor = new \app\common\FigureTagProcessor;
$oTableTagProcessor = new \app\common\TableTagProcessor;
foreach ($aTextMain as $key => $value) {
$sContent = empty($value['content']) ? '' : trim($value['content']);
if(empty($sContent)){
continue;
}
//处理图片
$aFigureContent = $oFigureTagProcessor->dealFigureStr($sContent,$aImageMain);
$iStatus = empty($aFigureContent['status']) ? 0 : $aFigureContent['status'];
$sData = empty($aFigureContent['data']) ? '' : $aFigureContent['data'];
// var_dump($aFigureContent);
if($iStatus != 1){
$sData = $sContent;
}else{
$aUpdate[$value['am_id']] = ['am_id' => $value['am_id'],'content' => $sData];
}
//处理表格
$aTableContent = $oTableTagProcessor->dealTableStr($sData,$aTableMain);
$iStatus = empty($aTableContent['status']) ? 0 : $aTableContent['status'];
$sData = empty($aTableContent['data']) ? $sContent : $aTableContent['data'];
if($iStatus != 1){
continue;
}
$aUpdate[$value['am_id']] = ['am_id' => $value['am_id'],'content' => $sData];
}
//批量更新入库
if(empty($aUpdate)){
return json_encode(array('status' => 3,'msg' => 'No table or image data to be processed was found' ));
}
$oArticleMain = new \app\common\ArticleMain();
$result = $oArticleMain->saveAll($aUpdate);
if ($result === false) {
return json_encode(array('status' => 4,'msg' => 'Operation failed'.json_encode($aUpdate)));
}
return json_encode(array('status' => 1,'msg' => 'success'));
}
}