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'];//默认头像
|
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'; //
|
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;
|
$aParam = empty($aParam) ? $this->request->post() : $aParam;
|
||||||
|
|
||||||
//主键ID
|
//更新AI文章内容
|
||||||
$iAiArticleId = empty($aParam['ai_article_id']) ? 0 : $aParam['ai_article_id'];
|
$oArticle = new \app\common\Article;
|
||||||
|
$aResult = json_decode($oArticle->updateAiArticle($aParam),true);
|
||||||
//文章ID
|
$iStatus = empty($aResult['status']) ? 0 : $aResult['status'];
|
||||||
$iArticleId = empty($aParam['article_id']) ? 0 : $aParam['article_id'];
|
if($iStatus != 1){
|
||||||
|
return json_encode($aResult);
|
||||||
//查询内容是否存在
|
|
||||||
$aWhere = ['is_delete' => 2];
|
|
||||||
if(empty($iArticleId) && empty($iArticleId)){
|
|
||||||
return json_encode(['status' => 2,'msg' => 'Please select the article to be modified']);
|
|
||||||
}
|
}
|
||||||
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 = empty($aParam['author_list']) ? []: $aParam['author_list'];
|
||||||
$aAuthorList = is_array( $aAuthorList) ? $aAuthorList: json_decode($aAuthorList,true);
|
$aAuthorList = is_array( $aAuthorList) ? $aAuthorList: json_decode($aAuthorList,true);
|
||||||
if(!empty($aAuthorList)){
|
|
||||||
|
|
||||||
$aAuthorList = array_column($aAuthorList, null,'email');
|
if(empty($aAuthorList)){
|
||||||
//根据邮箱查询作者信息
|
return json_encode($aResult);
|
||||||
$aEmail = array_keys($aAuthorList);
|
}
|
||||||
|
|
||||||
$aUserInfo = $aUserReviewer = [];
|
//根据邮箱查询作者信息
|
||||||
if(!empty($aEmail)){
|
$aAuthorList = array_column($aAuthorList, null,'email');
|
||||||
$aUserParam = ['email' => ['in',$aEmail]];
|
$aEmail = array_keys($aAuthorList);
|
||||||
$aUserInfo = Db::name('user')->field('email,user_id')->where($aUserParam)->select();
|
if(empty($aEmail)){
|
||||||
if(!empty($aUserInfo)){
|
return json_encode($aResult);
|
||||||
$aUserId = array_column($aUserInfo, 'user_id');
|
}
|
||||||
//查询用户附表
|
$aUserParam = ['email' => ['in',$aEmail]];
|
||||||
$aWhere = ['reviewer_id' => ['in',$aUserId]];
|
$aUserInfo = Db::name('user')->field('email,user_id')->where($aUserParam)->select();
|
||||||
$aUserReviewer = Db::name('user_reviewer_info')->where($aWhere)->column('reviewer_id');
|
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();
|
Db::commit();
|
||||||
$aResult['data'] = $aUpdateParam;
|
$aResult['data'] = $aParam;
|
||||||
return json_encode($aResult);
|
return json_encode($aResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -741,12 +694,6 @@ class Aiarticle extends Base
|
|||||||
}
|
}
|
||||||
|
|
||||||
$aSearch['{###jabbr###}'] = trim(trim($aSearch['{###jabbr###}'],'.'),'。');
|
$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###}'] = '';
|
$aSearch['{###journal_icon_info###}'] = $aSearch['{###journal_icon_details###}'] = '';
|
||||||
if(!empty($sJournalIcon)){
|
if(!empty($sJournalIcon)){
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ namespace app\api\controller;
|
|||||||
use app\api\controller\Base;
|
use app\api\controller\Base;
|
||||||
use think\Db;
|
use think\Db;
|
||||||
use app\common\OpenAi;
|
use app\common\OpenAi;
|
||||||
|
use app\common\Article;
|
||||||
/**
|
/**
|
||||||
* @title AI审核文章
|
* @title AI审核文章
|
||||||
* @description 对接OPENAI接口
|
* @description 对接OPENAI接口
|
||||||
@@ -53,7 +54,7 @@ class Aireview extends Base
|
|||||||
}
|
}
|
||||||
|
|
||||||
//实例化公共方法
|
//实例化公共方法
|
||||||
$oOpenAi = new OpenAi;
|
$oArticle = new Article;
|
||||||
if($aArticle['state'] > 4 ){
|
if($aArticle['state'] > 4 ){
|
||||||
//查询文章内容
|
//查询文章内容
|
||||||
$aWhere['type'] = 0;
|
$aWhere['type'] = 0;
|
||||||
@@ -70,7 +71,7 @@ class Aireview extends Base
|
|||||||
}
|
}
|
||||||
}else{
|
}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'];
|
$aFile = empty($aFile['data']) ? [] : $aFile['data'];
|
||||||
$aArticleMain = empty($aFile['mains']) ? [] : $aFile['mains'];
|
$aArticleMain = empty($aFile['mains']) ? [] : $aFile['mains'];
|
||||||
}
|
}
|
||||||
@@ -92,7 +93,7 @@ class Aireview extends Base
|
|||||||
$aSearch['{journal_name}'] = '传统医学研究';
|
$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($aJournalPaperArt['data']) ? '' : implode('', $aJournalPaperArt['data']);
|
||||||
$sJournalContent = empty($sJournalContent) ? $aJournal['scope'] : $sJournalContent;
|
$sJournalContent = empty($sJournalContent) ? $aJournal['scope'] : $sJournalContent;
|
||||||
$aSearch['{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)){
|
if(empty($aArticle)){
|
||||||
return json_encode(array('status' => 3,'msg' => 'No articles requiring review were found' ));
|
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();
|
$oAireview = new \app\common\Aireview;
|
||||||
return json_encode(array('status' => 1,'msg' => 'Successfully obtained article review content','data' => $aAiReview,'article_data' => $aArticle));
|
$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