Ai相关调整
This commit is contained in:
@@ -18,9 +18,6 @@ class Aiarticle extends Base
|
||||
{
|
||||
protected $aLogo = ['media_id' => 'Cn8zlXvVB5DwjcA9h40z9fprHDoc3Jqv97SwrInpmyYiilkeRdKvpD63cWqTYHfz','url' => 'http://mmbiz.qpic.cn/mmbiz_jpg/QHFVW13lONaQJxK9QbHU9CtrvTS2ModZnUyeAvuVN67t8XP85DxVJwDJf2YxCTalrsr17jS080xM6xQv5yGiaEQ/0?wx_fmt=jpeg'];//默认头像
|
||||
|
||||
//数据表必填字段[ai_article]
|
||||
protected $aAiFileds = ['article_id','title_english','title_chinese','journal_issn','covered','digest','research_result','content','highlights','discussion','prospect','research_background','discussion_results','research_method','overview','summary'];
|
||||
|
||||
//期刊接口地址
|
||||
protected $sJournalUrl = 'http://journalapi.tmrjournals.com/public/index.php';//'http://zmzm.journal.dev.com'; //
|
||||
//期刊官网
|
||||
@@ -390,118 +387,74 @@ class Aiarticle extends Base
|
||||
//获取参数
|
||||
$aParam = empty($aParam) ? $this->request->post() : $aParam;
|
||||
|
||||
//主键ID
|
||||
$iAiArticleId = empty($aParam['ai_article_id']) ? 0 : $aParam['ai_article_id'];
|
||||
|
||||
//文章ID
|
||||
$iArticleId = empty($aParam['article_id']) ? 0 : $aParam['article_id'];
|
||||
|
||||
//查询内容是否存在
|
||||
$aWhere = ['is_delete' => 2];
|
||||
if(empty($iArticleId) && empty($iArticleId)){
|
||||
return json_encode(['status' => 2,'msg' => 'Please select the article to be modified']);
|
||||
//更新AI文章内容
|
||||
$oArticle = new \app\common\Article;
|
||||
$aResult = json_decode($oArticle->updateAiArticle($aParam),true);
|
||||
$iStatus = empty($aResult['status']) ? 0 : $aResult['status'];
|
||||
if($iStatus != 1){
|
||||
return json_encode($aResult);
|
||||
}
|
||||
if(!empty($iArticleId)){
|
||||
$aWhere['article_id'] = $iArticleId;
|
||||
}
|
||||
if(!empty($iAiArticleId)){
|
||||
$aWhere['ai_article_id'] = $iAiArticleId;
|
||||
}
|
||||
$aAiArticle = Db::name('ai_article')->where($aWhere)->find();
|
||||
if(empty($aAiArticle)){
|
||||
return json_encode(['status' => 3,'msg' => 'he article content of WeChat official account has not been generated']);
|
||||
}
|
||||
|
||||
|
||||
//必填参数验证
|
||||
$aFields = $this->aAiFileds;
|
||||
$sFiled = '';
|
||||
$aUpdateParam = [];
|
||||
foreach($aFields as $val){
|
||||
if(!isset($aParam[$val])){
|
||||
continue;
|
||||
}
|
||||
if(is_array($aParam[$val])){
|
||||
$aParam[$val] = implode(";",$aParam[$val]);
|
||||
}
|
||||
$aUpdateParam[$val] = empty($aParam[$val]) ? '' : addslashes(strip_tags($aParam[$val]));
|
||||
}
|
||||
if(empty($aUpdateParam)){
|
||||
return json_encode(['status' => 1,'msg' => 'No data currently being processed']);
|
||||
}
|
||||
|
||||
Db::startTrans();
|
||||
//执行入库
|
||||
$aUpdateParam['update_time'] = time();
|
||||
$aUpdateParam['is_generate'] = 1;
|
||||
$result = Db::name('ai_article')->where('ai_article_id',$iAiArticleId)->limit(1)->update($aUpdateParam);
|
||||
if($result === false){
|
||||
$aResult = json_encode(['status' => 3,'msg' => 'UPDATEING AI article failed']);
|
||||
}
|
||||
$aResult['data'] = $aUpdateParam;
|
||||
|
||||
//更新作者信息
|
||||
$aAuthorList = empty($aParam['author_list']) ? []: $aParam['author_list'];
|
||||
$aAuthorList = is_array( $aAuthorList) ? $aAuthorList: json_decode($aAuthorList,true);
|
||||
if(!empty($aAuthorList)){
|
||||
|
||||
$aAuthorList = array_column($aAuthorList, null,'email');
|
||||
//根据邮箱查询作者信息
|
||||
$aEmail = array_keys($aAuthorList);
|
||||
if(empty($aAuthorList)){
|
||||
return json_encode($aResult);
|
||||
}
|
||||
|
||||
$aUserInfo = $aUserReviewer = [];
|
||||
if(!empty($aEmail)){
|
||||
$aUserParam = ['email' => ['in',$aEmail]];
|
||||
$aUserInfo = Db::name('user')->field('email,user_id')->where($aUserParam)->select();
|
||||
if(!empty($aUserInfo)){
|
||||
$aUserId = array_column($aUserInfo, 'user_id');
|
||||
//查询用户附表
|
||||
$aWhere = ['reviewer_id' => ['in',$aUserId]];
|
||||
$aUserReviewer = Db::name('user_reviewer_info')->where($aWhere)->column('reviewer_id');
|
||||
//根据邮箱查询作者信息
|
||||
$aAuthorList = array_column($aAuthorList, null,'email');
|
||||
$aEmail = array_keys($aAuthorList);
|
||||
if(empty($aEmail)){
|
||||
return json_encode($aResult);
|
||||
}
|
||||
$aUserParam = ['email' => ['in',$aEmail]];
|
||||
$aUserInfo = Db::name('user')->field('email,user_id')->where($aUserParam)->select();
|
||||
if(empty($aUserInfo)){
|
||||
return json_encode($aResult);
|
||||
}
|
||||
|
||||
//查询用户附表
|
||||
$aUserId = array_column($aUserInfo, 'user_id');
|
||||
$aWhere = ['reviewer_id' => ['in',$aUserId]];
|
||||
$aUserReviewer = Db::name('user_reviewer_info')->where($aWhere)->column('reviewer_id');
|
||||
//更新用户信息
|
||||
Db::startTrans();
|
||||
foreach ($aUserInfo as $key => $value) {
|
||||
|
||||
$aUser = empty($aAuthorList[$value['email']]) ? [] : $aAuthorList[$value['email']];
|
||||
if(empty($aUser)){
|
||||
continue;
|
||||
}
|
||||
//更新作者名字
|
||||
if(isset($aUser['author_name'])){
|
||||
$aUpdate = ['localname' => $aUser['author_name']];
|
||||
Db::name('user')->where('user_id',$value['user_id'])->update($aUpdate);
|
||||
}
|
||||
//更新作者简介和单位
|
||||
$aUpdateReviewer = [];
|
||||
if(isset($aUser['technical'])){
|
||||
$aUpdateReviewer['technical'] = $aUser['technical'];
|
||||
}
|
||||
if(isset($aUser['introduction'])){
|
||||
$aUpdateReviewer['introduction'] = $aUser['introduction'];
|
||||
}
|
||||
if(isset($aUser['company'])){
|
||||
$aUpdateReviewer['company'] = $aUser['company'];
|
||||
}
|
||||
if(isset($aUpdateReviewer)){
|
||||
if(in_array($value['user_id'], $aUserReviewer)){//更新
|
||||
Db::name('user_reviewer_info')->where('reviewer_id',$value['user_id'])->limit(1)->update($aUpdateReviewer);
|
||||
}
|
||||
if(!in_array($value['user_id'], $aUserReviewer)){//插入
|
||||
$aUpdateReviewer['reviewer_id'] = $value['user_id'];
|
||||
Db::name('user_reviewer_info')->insert($aUpdateReviewer);
|
||||
}
|
||||
}
|
||||
|
||||
//更新用户信息
|
||||
if(!empty($aUserInfo)){
|
||||
foreach ($aUserInfo as $key => $value) {
|
||||
|
||||
$aUser = empty($aAuthorList[$value['email']]) ? [] : $aAuthorList[$value['email']];
|
||||
if(empty($aUser)){
|
||||
continue;
|
||||
}
|
||||
//更新作者名字
|
||||
if(isset($aUser['author_name'])){
|
||||
$aUpdate = ['localname' => $aUser['author_name']];
|
||||
Db::name('user')->where('user_id',$value['user_id'])->update($aUpdate);
|
||||
}
|
||||
//更新作者简介和单位
|
||||
$aUpdateReviewer = [];
|
||||
if(isset($aUser['technical'])){
|
||||
$aUpdateReviewer['technical'] = $aUser['technical'];
|
||||
}
|
||||
if(isset($aUser['introduction'])){
|
||||
$aUpdateReviewer['introduction'] = $aUser['introduction'];
|
||||
}
|
||||
if(isset($aUser['company'])){
|
||||
$aUpdateReviewer['company'] = $aUser['company'];
|
||||
}
|
||||
if(isset($aUpdateReviewer)){
|
||||
|
||||
if(in_array($value['user_id'], $aUserReviewer)){//更新
|
||||
Db::name('user_reviewer_info')->where('reviewer_id',$value['user_id'])->limit(1)->update($aUpdateReviewer);
|
||||
}
|
||||
|
||||
if(!in_array($value['user_id'], $aUserReviewer)){//插入
|
||||
$aUpdateReviewer['reviewer_id'] = $value['user_id'];
|
||||
Db::name('user_reviewer_info')->insert($aUpdateReviewer);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Db::commit();
|
||||
$aResult['data'] = $aUpdateParam;
|
||||
$aResult['data'] = $aParam;
|
||||
return json_encode($aResult);
|
||||
}
|
||||
|
||||
@@ -741,12 +694,6 @@ class Aiarticle extends Base
|
||||
}
|
||||
|
||||
$aSearch['{###jabbr###}'] = trim(trim($aSearch['{###jabbr###}'],'.'),'。');
|
||||
// $aSearch['{###free_year###}'] = date('Y');
|
||||
// $aSearch['{###covered###}'] = '内容涵盖'.str_replace('研究涵盖', '', $aSearch['{###covered###}']);
|
||||
if(!empty($aSearch['{###covered###}']) && strpos($aSearch['{###covered###}'], '涵盖') === false){
|
||||
$aSearch['{###covered###}'] = '内容涵盖'.str_replace('研究涵盖', '', $aSearch['{###covered###}']);
|
||||
}
|
||||
|
||||
//期刊封面
|
||||
$aSearch['{###journal_icon_info###}'] = $aSearch['{###journal_icon_details###}'] = '';
|
||||
if(!empty($sJournalIcon)){
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace app\api\controller;
|
||||
use app\api\controller\Base;
|
||||
use think\Db;
|
||||
use app\common\OpenAi;
|
||||
use app\common\Article;
|
||||
/**
|
||||
* @title AI审核文章
|
||||
* @description 对接OPENAI接口
|
||||
@@ -53,7 +54,7 @@ class Aireview extends Base
|
||||
}
|
||||
|
||||
//实例化公共方法
|
||||
$oOpenAi = new OpenAi;
|
||||
$oArticle = new Article;
|
||||
if($aArticle['state'] > 4 ){
|
||||
//查询文章内容
|
||||
$aWhere['type'] = 0;
|
||||
@@ -70,7 +71,7 @@ class Aireview extends Base
|
||||
}
|
||||
}else{
|
||||
|
||||
$aFile = json_decode($oOpenAi->getFileContent(['article_id' => $iArticleId]),true);
|
||||
$aFile = json_decode($oArticle->getFileContent(['article_id' => $iArticleId]),true);
|
||||
$aFile = empty($aFile['data']) ? [] : $aFile['data'];
|
||||
$aArticleMain = empty($aFile['mains']) ? [] : $aFile['mains'];
|
||||
}
|
||||
@@ -92,7 +93,7 @@ class Aireview extends Base
|
||||
$aSearch['{journal_name}'] = '传统医学研究';
|
||||
}
|
||||
//查询期刊内容
|
||||
$aJournalPaperArt = json_decode($oOpenAi->getJournalPaperArt($aJournal),true);
|
||||
$aJournalPaperArt = json_decode($oArticle->getJournalPaperArt($aJournal),true);
|
||||
$sJournalContent = empty($aJournalPaperArt['data']) ? '' : implode('', $aJournalPaperArt['data']);
|
||||
$sJournalContent = empty($sJournalContent) ? $aJournal['scope'] : $sJournalContent;
|
||||
$aSearch['{scope}'] = $sJournalContent;//期刊范围
|
||||
@@ -222,12 +223,14 @@ class Aireview extends Base
|
||||
}
|
||||
|
||||
//查询文章
|
||||
$aArticle = Db::table('t_article')->field('article_id,abstrart,keywords,journal_id,title,state')->where('article_id',$aParam['article_id'])->find();
|
||||
$aArticle = Db::name('article')->field('article_id,abstrart,keywords,journal_id,title,state')->where('article_id',$aParam['article_id'])->find();
|
||||
if(empty($aArticle)){
|
||||
return json_encode(array('status' => 3,'msg' => 'No articles requiring review were found' ));
|
||||
}
|
||||
//查询文章审核内容
|
||||
$aAiReview = Db::table('t_article_ai_review')->where('article_id',$aParam['article_id'])->find();
|
||||
return json_encode(array('status' => 1,'msg' => 'Successfully obtained article review content','data' => $aAiReview,'article_data' => $aArticle));
|
||||
$oAireview = new \app\common\Aireview;
|
||||
$aAireview = $oAireview->get($aParam);
|
||||
$aAireview = empty($aAireview['data']) ? [] : $aAireview['data'];
|
||||
return json_encode(array('status' => 1,'msg' => 'Successfully obtained article review content','data' => $aAireview,'article_data' => $aArticle));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user