Merge remote-tracking branch 'origin/master'
This commit is contained in:
File diff suppressed because it is too large
Load Diff
359
application/api/controller/Contribute.php
Normal file
359
application/api/controller/Contribute.php
Normal file
@@ -0,0 +1,359 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\api\controller\Base;
|
||||
use think\Db;
|
||||
use PhpOffice\PhpWord\IOFactory;
|
||||
use think\Exception;
|
||||
use \app\common\ArticleParserService;
|
||||
/**
|
||||
* @title 自动投稿控制器
|
||||
* @description 所有的测试方法汇总
|
||||
*/
|
||||
class Contribute extends Base
|
||||
{
|
||||
|
||||
private $phpWord; // PhpWord实例
|
||||
private $sections; // 文档段落集合
|
||||
public function __construct(\think\Request $request = null) {
|
||||
parent::__construct($request);
|
||||
}
|
||||
|
||||
/**
|
||||
* 自动投稿
|
||||
* @param file_url 文件地址
|
||||
*/
|
||||
public function contribute($aParam = []){
|
||||
|
||||
//获取参数
|
||||
$aParam = empty($aParam) ? $this->request->post() : $aParam;
|
||||
|
||||
//必填值验证
|
||||
$sFileUrl = empty($aParam['file_url']) ? '' : $aParam['file_url'];
|
||||
$sOriginalFileUrl = $sFileUrl;
|
||||
if(empty($sFileUrl)){
|
||||
return json_encode(['status' => 2,'msg' => 'Please upload the submission file']);
|
||||
}
|
||||
// //文章类型
|
||||
// $sType = empty($aParam['type']) ? '' : $aParam['type'];
|
||||
// if(empty($sType)){
|
||||
// return json_encode(['status' => 2,'msg' => 'Please select the article type']);
|
||||
// }
|
||||
// //期刊ID
|
||||
// $iJournalId = empty($aParam['journal_id']) ? '' : $aParam['journal_id'];
|
||||
// if(empty($iJournalId)){
|
||||
// return json_encode(['status' => 2,'msg' => 'Please select the journal to which you belong']);
|
||||
// }
|
||||
//用户ID
|
||||
$iUserId = empty($aParam['user_id']) ? '' : $aParam['user_id'];
|
||||
if(empty($iUserId)){
|
||||
return json_encode(['status' => 2,'msg' => 'Please select author']);
|
||||
}
|
||||
|
||||
//判断文件是否执行
|
||||
$sFileUrl = rtrim(ROOT_PATH,'/').'/public/'.ltrim(ltrim($sFileUrl,'/'),'public');
|
||||
if (!file_exists($sFileUrl)) {
|
||||
return json_encode(['status' => 3, 'msg' => 'The uploaded file does not exist']);
|
||||
}
|
||||
if (!is_readable($sFileUrl)) {
|
||||
return json_encode(['status' => 4, 'msg' => 'The uploaded file is unreadable']);
|
||||
}
|
||||
//文章ID
|
||||
$iArticleId = empty($aParam['article_id']) ? 0 : $aParam['article_id'];
|
||||
$aWhere = [];
|
||||
if(!empty($iArticleId)){//更新文章内容
|
||||
$aWhere['article_id'] = $iArticleId;
|
||||
$aArticle = Db::name('article')->field('state,user_id,manuscirpt_url')->where($aWhere)->find();
|
||||
if(empty($aArticle)){
|
||||
return json_encode(['status' => 7,'msg' => 'The article does not exist']);
|
||||
}
|
||||
if($aArticle['state'] != -1 && $aArticle['state'] != 3){
|
||||
return json_encode(['status' => 8,'msg' => 'Article cannot be edited']);
|
||||
}
|
||||
if($aArticle['user_id'] != $iUserId){
|
||||
return json_encode(['status' => 9,'msg' => 'Not modified by the author themselves']);
|
||||
}
|
||||
if($aArticle['manuscirpt_url'] == trim($sOriginalFileUrl,'/')){
|
||||
return json_encode(['status' => 9,'msg' => 'The content of the article has not changed']);
|
||||
}
|
||||
$aWhere['article_id'] = ['<>',$iArticleId];
|
||||
}
|
||||
//获取数据
|
||||
$aDealData = json_decode(ArticleParserService::uploadAndParse($sFileUrl),true);
|
||||
$iStatus = empty($aDealData['status']) ? 0 : $aDealData['status'];
|
||||
$sMsg = empty($aDealData['msg']) ? 'fail' : $aDealData['msg'];
|
||||
if($iStatus != 1){
|
||||
return json_encode(['status' => 5, 'msg' => $sMsg]);
|
||||
}
|
||||
$aData = empty($aDealData['data']) ? '' : $aDealData['data'];
|
||||
if(empty($aData['title'])){
|
||||
return json_encode(['status' => 6,'msg' => 'The article title is empty']);
|
||||
}
|
||||
//查询标题是否存在
|
||||
$aWhere += ['title' => trim($aData['title']),'state' => ['<>',3]];
|
||||
$aArticle = Db::name('article')->field('article_id')->where($aWhere)->find();
|
||||
if(!empty($aArticle)){
|
||||
return json_encode(['code' => 7, 'msg' => 'Warning: you are re-submitting the article!']);
|
||||
}
|
||||
|
||||
//数据入库
|
||||
$aData += $aParam;
|
||||
$result = $this->_addData($aData);
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 组装数据插入相关数据表
|
||||
* @param array $aParam
|
||||
*/
|
||||
private function _addData($aParam = []){
|
||||
if(empty($aParam)){
|
||||
return json_encode(['status' => 2,'msg' => 'Data is empty']);
|
||||
}
|
||||
|
||||
//获取文章ID
|
||||
$iUpdateArticleId = empty($aParam['article_id']) ? 0 : $aParam['article_id'];
|
||||
if(!empty($iUpdateArticleId)){
|
||||
$aWhere = ['article_id' => $iUpdateArticleId];
|
||||
$aArticle = Db::name('article')->field('title,keywords,abstrart,fund,journal_id')->where($aWhere)->find();
|
||||
}
|
||||
//插入基础表 t_article
|
||||
$aInsert = [];
|
||||
//标题
|
||||
if(empty($aArticle['title'])){
|
||||
$sTitile = empty($aParam['title']) ? '' : $aParam['title'];
|
||||
if(!empty($sTitile)){
|
||||
$aInsert['title'] = $sTitile;
|
||||
}
|
||||
}
|
||||
|
||||
//关键词
|
||||
if(empty($aArticle['keywords'])){
|
||||
$sKeyWords = empty($aParam['keywords']) ? '' : $aParam['keywords'];
|
||||
if(!empty($sKeyWords)){
|
||||
$aInsert['keywords'] = is_array($sKeyWords) ? implode(',', $sKeyWords) : $sKeyWords;
|
||||
}
|
||||
}
|
||||
//摘要
|
||||
if(empty($aArticle['abstrart'])){
|
||||
$sAbstrart = empty($aParam['abstrart']) ? '' : $aParam['abstrart'];
|
||||
if(!empty($sAbstrart)){
|
||||
$aInsert['abstrart'] = $sAbstrart;
|
||||
}
|
||||
}
|
||||
//基金
|
||||
if(empty($aArticle['fund'])){
|
||||
$sFund = empty($aParam['fund']) ? '' : $aParam['fund'];
|
||||
if(!empty($sAbstrart)){
|
||||
$aInsert['fund'] = $sFund;
|
||||
}
|
||||
}
|
||||
//期刊ID
|
||||
$iJournalId = empty($aParam['journal_id']) ? 0 : $aParam['journal_id'];
|
||||
if(!empty($iJournalId)){
|
||||
$aInsert['journal_id'] = $iJournalId;
|
||||
//查询期刊信息
|
||||
$aJournalWhere = ['journal_id' => $iJournalId,'state' => 0];
|
||||
$aJournal = DB::name('journal')->field('editor_id')->where($aJournalWhere)->find();
|
||||
$aInsert['editor_id'] = empty($aJournal['editor_id']) ? 0 : $aJournal['editor_id'];
|
||||
}
|
||||
//类型
|
||||
$sType = empty($aParam['type']) ? '' : $aParam['type'];
|
||||
if(!empty($sType)){
|
||||
$aInsert['type'] = $sType;
|
||||
}
|
||||
//上传文件地址
|
||||
$sFileUrl = empty($aParam['file_url']) ? '' : $aParam['file_url'];
|
||||
if(!empty($sFileUrl)){
|
||||
$aInsert['manuscirpt_url'] = trim(trim($sFileUrl,'/'),'public/');
|
||||
}
|
||||
//用户ID
|
||||
$iUserId = empty($aParam['user_id']) ? 0 : $aParam['user_id'];
|
||||
if(!empty($iUserId)){
|
||||
$aInsert['user_id'] = $iUserId;
|
||||
//查询用户信息
|
||||
$aUser = Db::name('user')->field('account')->where(['user_id' => $iUserId,'state' => 0])->find();
|
||||
}
|
||||
Db::startTrans();
|
||||
//插入article
|
||||
if(empty($aArticle) && !empty($aInsert)){//新插入
|
||||
$aInsert['ctime'] = time();
|
||||
$aInsert['state'] = -1;
|
||||
$aInsert['is_use_ai'] = 3;
|
||||
$aInsert['is_figure_copyright'] = 3;
|
||||
$aInsert['is_transfer'] = 3;
|
||||
$aInsert['is_become_reviewer'] = 3;
|
||||
$iArticleId = Db::name('article')->insertGetId($aInsert);
|
||||
if(empty($iArticleId)){
|
||||
return json_encode(['status' => 3,'msg' => 'Article added successfully']);
|
||||
}
|
||||
//获取accept_sn并更新
|
||||
$sAcceptSn = $this->getArticleAcceptSn(['article_id' => $iArticleId]);
|
||||
if(!empty($sAcceptSn)){
|
||||
$aWhere = ['article_id' => $iArticleId];
|
||||
$aUpdate = ['accept_sn' => $sAcceptSn];
|
||||
$update_result = Db::name('article')->where($aWhere)->limit(1)->update($aUpdate);
|
||||
}
|
||||
}
|
||||
if(!empty($aArticle) && !empty($aInsert)){//更新
|
||||
$aWhere = ['article_id' => $iUpdateArticleId,'state' => ['in',[-1,3]]];
|
||||
$update_result = Db::name('article')->where($aWhere)->limit(1)->update($aInsert);
|
||||
if($update_result === false){
|
||||
return json_encode(['status' => 3,'msg' => 'Article update failed']);
|
||||
}
|
||||
//更新作者为逻辑删除
|
||||
$aWhere['state'] = 0;
|
||||
$update_author_result = DB::name('article_author')->where($aWhere)->update(['state' => 1]);
|
||||
if($update_author_result === false){
|
||||
return json_encode(['status' => 4,'msg' => 'Article author update failed']);
|
||||
}
|
||||
}
|
||||
|
||||
//作者单位
|
||||
$iArticleId = empty($iArticleId) ? $iUpdateArticleId : $iArticleId;
|
||||
$aCompany = empty($aParam['company']) ? [] : $aParam['company'];
|
||||
|
||||
if(!empty($aCompany)){
|
||||
$aWhere = ['article_id' => $iArticleId,'state' => 0];
|
||||
$aOrgan = Db::name('article_organ')->field('organ_id,organ_name,sort')->where($aWhere)->select();
|
||||
$aOrganName = empty($aOrgan) ? [] : array_column($aOrgan, 'organ_name');
|
||||
$iMaxSort = empty($aOrgan) ? 0 : max(array_column($aOrgan, 'sort'));
|
||||
//查询文章
|
||||
$aCompanyInsert = $aSort = [];
|
||||
foreach ($aCompany as $key => $value) {
|
||||
if(empty($value)){
|
||||
continue;
|
||||
}
|
||||
$sName = trim(trim(trim($value,'*'),'#'));
|
||||
if(in_array($sName, $aOrganName)){
|
||||
continue;
|
||||
}
|
||||
if(empty($iMaxSort)){
|
||||
$iSort = $key;
|
||||
$aSort[$key] = $key;
|
||||
}else{
|
||||
$iMaxSort++;
|
||||
$iSort = $iMaxSort;
|
||||
$aSort[$key] = $iMaxSort;
|
||||
}
|
||||
$aCompanyInsert[] = ['article_id' => $iArticleId,'organ_name' =>$sName,'create_time' => time(),'sort' => $iSort];
|
||||
}
|
||||
}
|
||||
if(!empty($aCompanyInsert)){
|
||||
$company_result = Db::name('article_organ')->insertAll($aCompanyInsert);
|
||||
if(empty($company_result)){
|
||||
return json_encode(['status' => 3,'msg' => 'Article institution insertion failed']);
|
||||
}
|
||||
$aWhere = ['article_id' => $iArticleId,'state' => 0];
|
||||
$aCompanyData = Db::name('article_organ')->where($aWhere)->column('sort,organ_id');
|
||||
}
|
||||
//处理作者
|
||||
$aAuthorData = $aAuthorOrgn = [];
|
||||
if(!empty($aParam['author'])){
|
||||
$aAuthor = $aParam['author'];
|
||||
//通讯作者
|
||||
$aCorresponding = empty($aParam['corresponding']) ? [] : array_column($aParam['corresponding'], null,'name');
|
||||
//查询文章作者
|
||||
$aWhere = ['article_id' => $iArticleId,'state' => 0];
|
||||
$aAuthorList = Db::name('article_author')->field('art_aut_id,firstname')->where($aWhere)->select();
|
||||
$aAuthorNameList = empty($aAuthorList) ? [] : array_column($aAuthorList, 'firstname');
|
||||
foreach ($aAuthor as $key => $value) {
|
||||
if(empty($iArticleId)){
|
||||
break;
|
||||
}
|
||||
//处理作者机构单位关联
|
||||
if(!empty($value['company_id'])){
|
||||
foreach ($value['company_id'] as $k => $v) {
|
||||
$iNewSort = empty($aSort[$v]) ? $v : $aSort[$v];
|
||||
$iOrgnId = empty($aCompanyData[$iNewSort]) ? 0 : $aCompanyData[$iNewSort];
|
||||
if(empty($iOrgnId)){
|
||||
continue;
|
||||
}
|
||||
$aAuthorOrgn[] = ['article_id' => $iArticleId,'organ_id' => $iOrgnId,'art_aut_id' => $value['name']];
|
||||
}
|
||||
}
|
||||
$value['firstname'] = empty($value['name']) ? '' : trim($value['name']);
|
||||
//已添加
|
||||
if(!empty($value['firstname']) && in_array($value['firstname'], $aAuthorList)){
|
||||
continue;
|
||||
}
|
||||
$value['email'] = empty($aCorresponding[$value['name']]['email']) ? '' : $aCorresponding[$value['name']]['email'];
|
||||
$value['article_id'] = $iArticleId;
|
||||
unset($value['name'],$value['company_id']);
|
||||
$aAuthorData[$key] = $value;
|
||||
}
|
||||
}
|
||||
if(!empty($aAuthorData)){
|
||||
$author_result = DB::name('article_author')->insertAll($aAuthorData);
|
||||
if(empty($author_result)){
|
||||
return json_encode(['status' => 3,'msg' => 'Adding article author failed']);
|
||||
}
|
||||
$aWhere = ['article_id' => $iArticleId,'state' => 0];
|
||||
$aAuthorResult = DB::name('article_author')->where($aWhere)->select();
|
||||
}
|
||||
|
||||
//作者所属机构
|
||||
$aAuthorOrgnInsert = [];
|
||||
if(!empty($aAuthorOrgn)){
|
||||
//查询文章作者所属机构
|
||||
$aWhere = ['article_id' => $iArticleId,'state' => 0];
|
||||
$aAuthorOrganList = Db::name('article_author_organ')->field('art_aut_id,organ_id')->where($aWhere)->select();
|
||||
$aAuthorOrganIdList = [];
|
||||
if(!empty($aAuthorOrganList)){
|
||||
foreach ($aAuthorOrganList as $key => $value) {
|
||||
$aAuthorOrganIdList[$value['art_aut_id']][] = $value['organ_id'];
|
||||
}
|
||||
}
|
||||
$aAuthorName = empty($aAuthorResult) ? [] : array_column($aAuthorResult, 'art_aut_id','firstname');
|
||||
foreach ($aAuthorOrgn as $key => $value) {
|
||||
if(empty($value['art_aut_id'])){
|
||||
continue;
|
||||
}
|
||||
$iAuthorId = empty($aAuthorName[$value['art_aut_id']]) ? 0 : $aAuthorName[$value['art_aut_id']];
|
||||
if(empty($iAuthorId)){
|
||||
continue;
|
||||
}
|
||||
if(!empty($aAuthorOrganIdList[$iAuthorId]) && in_array($value['organ_id'], $aAuthorOrganIdList[$iAuthorId])){
|
||||
continue;
|
||||
}
|
||||
$value['art_aut_id'] = $iAuthorId;
|
||||
$aAuthorOrgnInsert[] = $value;
|
||||
}
|
||||
}
|
||||
if(!empty($aAuthorOrgnInsert)){
|
||||
$author_orgn_result = DB::name('article_author_organ')->insertAll($aAuthorOrgnInsert);
|
||||
if(empty($author_orgn_result)){
|
||||
return json_encode(['status' => 3,'msg' => 'Adding article author orgn failed']);
|
||||
}
|
||||
}
|
||||
// //处理上传文件
|
||||
// if(!empty($sFileUrl) && !empty($iUserId)){
|
||||
// $aInsertFile['article_id'] = $iArticleId;
|
||||
// $aInsertFile['user_id'] = $iUserId;
|
||||
// $aInsertFile['username'] = empty($aUser['account']) ? '' : $aUser['account'];
|
||||
// $aInsertFile['file_url'] = trim($sFileUrl,'/');
|
||||
// $aInsertFile['type_name'] = 'manuscirpt';
|
||||
// $aInsertFile['ctime'] = time();
|
||||
// $iFileId = Db::name('article_file')->insertGetId($aInsertFile);
|
||||
// }
|
||||
|
||||
Db::commit();
|
||||
$aInsert['article_id'] = $iArticleId;
|
||||
return json_encode(['status' => 1,'msg' => 'Successfully added article','article' => $aInsert]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成文章sn号
|
||||
*/
|
||||
private function getArticleAcceptSn($aParam = [],$sFlag = 'Draft')
|
||||
{
|
||||
$iArticleId = empty($aParam['article_id']) ? 0 : $aParam['article_id'];
|
||||
if(empty($iArticleId)){
|
||||
return '';
|
||||
}
|
||||
$sDate = date('Y');
|
||||
$sType = $sDate;
|
||||
return $sFlag.$sType.str_pad($iArticleId,6,'0',STR_PAD_LEFT).rand(100,999);
|
||||
}
|
||||
}
|
||||
@@ -1054,12 +1054,12 @@ class Finalreview extends Base
|
||||
}
|
||||
//查询文章审稿记录
|
||||
$aWhere = ['article_id' => $iArticleId,'state' => ['between',[1,3]]];
|
||||
$aArticleReviewer = Db::name('article_reviewer')->field('art_rev_id,state,ctime')->where($aWhere)->select();
|
||||
$aArticleReviewer = Db::name('article_reviewer')->field('art_rev_id,state,ctime,reviewer_id')->where($aWhere)->select();
|
||||
if(!empty($aArticleReviewer)){
|
||||
$aArtRevId = array_column($aArticleReviewer, 'art_rev_id');
|
||||
$aWhere = ['art_rev_id' => ['in',$aArtRevId],'state' => 0];
|
||||
//查询初审问卷
|
||||
$aQuestion = Db::name('article_reviewer_question')->field('art_rev_id,ctime,score,rated')->where($aWhere)->order('ctime asc')->select();
|
||||
$aQuestion = Db::name('article_reviewer_question')->field('art_rev_id,ctime,score,rated,recommend')->where($aWhere)->order('ctime asc')->select();
|
||||
$aQuestion = empty($aQuestion) ? [] : array_column($aQuestion, null,'art_rev_id');
|
||||
|
||||
//查询复审
|
||||
@@ -1071,12 +1071,20 @@ class Finalreview extends Base
|
||||
$aReviewerRepeatLists[$value['art_rev_id']][] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
//查询作者信息
|
||||
$aUserId = array_unique(array_column($aArticleReviewer, 'reviewer_id'));
|
||||
$aWhere = ['user_id' => ['in',$aUserId],'state' => 0];
|
||||
$aUser = Db::name('user')->where($aWhere)->column('user_id,realname');
|
||||
|
||||
foreach ($aArticleReviewer as $key => $value) {
|
||||
$aQuestionData = empty($aQuestion[$value['art_rev_id']]) ? [] : $aQuestion[$value['art_rev_id']];
|
||||
$value['ctime'] = empty($aQuestionData['ctime']) ? $value['ctime'] : $aQuestionData['ctime'];
|
||||
$value['score'] = empty($aQuestionData['score']) ? 0 : $aQuestionData['score'];
|
||||
$value['repeat'] = empty($aReviewerRepeatLists[$value['art_rev_id']]) ? [] : $aReviewerRepeatLists[$value['art_rev_id']];
|
||||
$value['rated'] = empty($aQuestionData['rated']) ? 0 : $aQuestionData['rated'];
|
||||
$value['realname'] = empty($aUser[$value['reviewer_id']]) ? '' : $aUser[$value['reviewer_id']];
|
||||
$value['recommend'] = empty($aQuestionData['recommend']) ? 0 : $aQuestionData['recommend'];
|
||||
$aArticleReviewer[$key] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
218
application/api/controller/Organ.php
Normal file
218
application/api/controller/Organ.php
Normal file
@@ -0,0 +1,218 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller;
|
||||
use app\api\controller\Base;
|
||||
use think\Db;
|
||||
/**
|
||||
* @title 文章机构管理
|
||||
*/
|
||||
class Organ extends Base
|
||||
{
|
||||
|
||||
public function __construct(\think\Request $request = null) {
|
||||
parent::__construct($request);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取文章机构
|
||||
* @param file_url 文件地址
|
||||
*/
|
||||
public function lists(){
|
||||
//获取参数
|
||||
$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 the article']);
|
||||
}
|
||||
//用户ID
|
||||
$iUserId = empty($aParam['user_id']) ? 0 : $aParam['user_id'];
|
||||
if(empty($iUserId)){
|
||||
return json_encode(['status' => 2,'msg' => 'Please select author']);
|
||||
}
|
||||
$aWhere = ['article_id' => $iArticleId,'user_id' => $iUserId,'state' => ['in',[-1,3]]];
|
||||
$aArticle = Db::name('article')->field('article_id')->where($aWhere)->find();
|
||||
if(empty($aArticle)){
|
||||
return json_encode(['status' => 2,'msg' => 'The article does not exist']);
|
||||
}
|
||||
if(empty($aArticle)){
|
||||
return json_encode(['status' => 2,'msg' => 'The article does not exist']);
|
||||
}
|
||||
//查询文章机构
|
||||
$aWhere = ['article_id' => $iArticleId,'state' => 0];
|
||||
$aOragn = Db::name('article_organ')->field('organ_id,article_id,organ_name,sort')->where($aWhere)->select();
|
||||
return json_encode(['status' => 1,'data' => $aOragn]);
|
||||
}
|
||||
/**
|
||||
* 添加文章机构
|
||||
* @param file_url 文件地址
|
||||
*/
|
||||
public function add(){
|
||||
//获取参数
|
||||
$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 the article']);
|
||||
}
|
||||
//用户ID
|
||||
$iUserId = empty($aParam['user_id']) ? '' : $aParam['user_id'];
|
||||
if(empty($iUserId)){
|
||||
return json_encode(['status' => 2,'msg' => 'Please select author']);
|
||||
}
|
||||
//机构名称
|
||||
$sOrganName = empty($aParam['organ_name']) ? '' : $aParam['organ_name'];
|
||||
if(empty($sOrganName)){
|
||||
return json_encode(['status' => 2,'msg' => 'Please enter the name of the institution']);
|
||||
}
|
||||
|
||||
$aWhere = ['article_id' => $iArticleId,'user_id' => $iUserId,'state' => ['in',[-1,3]]];
|
||||
$aArticle = Db::name('article')->field('article_id')->where($aWhere)->find();
|
||||
if(empty($aArticle)){
|
||||
return json_encode(['status' => 2,'msg' => 'The article does not exist']);
|
||||
}
|
||||
//查询文章机构
|
||||
$aWhere = ['article_id' => $iArticleId,'state' => 0,'organ_name' => trim($sOrganName)];
|
||||
$aOragn = Db::name('article_organ')->field('organ_id,article_id,organ_name,sort')->where($aWhere)->find();
|
||||
if(!empty($aOragn)){
|
||||
return json_encode(['status' => 1,'msg' => 'Article organization already exists','data' => $aOragn]);
|
||||
}
|
||||
|
||||
//插入机构表
|
||||
$aWhere = ['article_id' => $iArticleId,'state' => 0];
|
||||
$aOragn = Db::name('article_organ')->field('max(sort) as sort')->where($aWhere)->find();
|
||||
$iSort = empty($aOragn['sort']) ? 0 : $aOragn['sort'];
|
||||
$iSort += 1;
|
||||
$aInsert = ['article_id' => $iArticleId,'organ_name' => $sOrganName,'create_time' => time(),'sort' => $iSort];
|
||||
$iId = Db::name('article_organ')->insertGetId($aInsert);
|
||||
if(empty($iId)){
|
||||
return json_encode(['status' => 3,'msg' => 'Failed to add article organization']);
|
||||
}
|
||||
$aInsert['organ_id'] = $iId;
|
||||
return json_encode(['status' => 1,'msg' => 'success','data' => $aInsert]);
|
||||
}
|
||||
/**
|
||||
* 修改文章机构
|
||||
* @param file_url 文件地址
|
||||
*/
|
||||
public function modify(){
|
||||
//获取参数
|
||||
$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 the article']);
|
||||
}
|
||||
//用户ID
|
||||
$iUserId = empty($aParam['user_id']) ? '' : $aParam['user_id'];
|
||||
if(empty($iUserId)){
|
||||
return json_encode(['status' => 2,'msg' => 'Please select author']);
|
||||
}
|
||||
|
||||
//机构名称
|
||||
$sOrganName = empty($aParam['organ_name']) ? '' : $aParam['organ_name'];
|
||||
if(empty($sOrganName)){
|
||||
return json_encode(['status' => 2,'msg' => 'Please enter the name of the institution']);
|
||||
}
|
||||
|
||||
//获取机构ID
|
||||
$iOrganId = empty($aParam['organ_id']) ? 0 : $aParam['organ_id'];
|
||||
if(empty($iOrganId)){
|
||||
return json_encode(['status' => 2,'msg' => 'Please select the institution to modify']);
|
||||
}
|
||||
|
||||
//查询文章
|
||||
$aWhere = ['article_id' => $iArticleId,'user_id' => $iUserId,'state' => ['in',[-1,3]]];
|
||||
$aArticle = Db::name('article')->field('article_id')->where($aWhere)->find();
|
||||
if(empty($aArticle)){
|
||||
return json_encode(['status' => 2,'msg' => 'The article does not exist']);
|
||||
}
|
||||
//查询文章机构
|
||||
$aWhere = ['article_id' => $iArticleId,'state' => 0,'organ_id' => $iOrganId];
|
||||
$aOragn = Db::name('article_organ')->field('organ_id,article_id,organ_name,sort')->where($aWhere)->find();
|
||||
if(empty($aOragn)){
|
||||
return json_encode(['status' => 3,'msg' => 'Article organization does not exist','data' => $aOragn]);
|
||||
}
|
||||
//查询是否有重名
|
||||
$aWhere = ['article_id' => $iArticleId,'state' => 0,'organ_id' => ['<>',$iOrganId],'organ_name' => trim($sOrganName)];
|
||||
$aOragn = Db::name('article_organ')->field('organ_id')->where($aWhere)->find();
|
||||
if(!empty($aOragn)){
|
||||
return json_encode(['status' => 1,'msg' => 'Article organization already exists','data' => $aOragn]);
|
||||
}
|
||||
|
||||
//更新机构
|
||||
$aWhere = ['organ_id' => $iOrganId];
|
||||
$aUpdate = ['organ_name' => $sOrganName,'update_time' => time()];
|
||||
$result = Db::name('article_organ')->where($aWhere)->limit(1)->update($aUpdate);
|
||||
if($result === false){
|
||||
return json_encode(['status' => 3,'msg' => 'Failed to update article organization']);
|
||||
}
|
||||
return json_encode(['status' => 1,'msg' => 'success']);
|
||||
}
|
||||
/**
|
||||
* 删除文章机构
|
||||
* @param file_url 文件地址
|
||||
*/
|
||||
public function remove(){
|
||||
//获取参数
|
||||
$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 the article']);
|
||||
}
|
||||
//用户ID
|
||||
$iUserId = empty($aParam['user_id']) ? '' : $aParam['user_id'];
|
||||
if(empty($iUserId)){
|
||||
return json_encode(['status' => 2,'msg' => 'Please select author']);
|
||||
}
|
||||
|
||||
//获取机构ID
|
||||
$iOrganId = empty($aParam['organ_id']) ? 0 : $aParam['organ_id'];
|
||||
if(empty($iOrganId)){
|
||||
return json_encode(['status' => 2,'msg' => 'Please select the institution to modify']);
|
||||
}
|
||||
|
||||
//查询文章
|
||||
$aWhere = ['article_id' => $iArticleId,'user_id' => $iUserId,'state' => ['in',[-1,3]]];
|
||||
$aArticle = Db::name('article')->field('article_id')->where($aWhere)->find();
|
||||
if(empty($aArticle)){
|
||||
return json_encode(['status' => 2,'msg' => 'The article does not exist']);
|
||||
}
|
||||
//查询文章机构
|
||||
$aWhere = ['article_id' => $iArticleId,'state' => 0,'organ_id' => $iOrganId];
|
||||
$aOragn = Db::name('article_organ')->field('organ_id,article_id,organ_name,sort')->where($aWhere)->find();
|
||||
if(empty($aOragn)){
|
||||
return json_encode(['status' => 3,'msg' => 'Article organization does not exist','data' => $aOragn]);
|
||||
}
|
||||
|
||||
//作者关联的机构
|
||||
$aWhere = ['organ_id' => $iOrganId,'article_id' => $iArticleId,'state' => 0];
|
||||
$aId = Db::name('article_author_organ')->where($aWhere)->column('id');
|
||||
|
||||
//删除机构
|
||||
Db::startTrans();
|
||||
//更新机构状态
|
||||
$aWhere = ['organ_id' => $iOrganId];
|
||||
$aUpdate = ['state' => 1,'update_time' => time()];
|
||||
$result = Db::name('article_organ')->where($aWhere)->limit(1)->update($aUpdate);
|
||||
if($result === false){
|
||||
return json_encode(['status' => 3,'msg' => 'Failed to update article organization']);
|
||||
}
|
||||
//更新作者关联的机构
|
||||
if(!empty($aId)){
|
||||
$aWhere = ['id' => ['in',$aId],'state' => 0];
|
||||
$aUpdate = ['state' => 1,'update_time' => time()];
|
||||
$author_organ_result = Db::name('article_author_organ')->where($aWhere)->limit(count($aId))->update($aUpdate);
|
||||
if($author_organ_result === false){
|
||||
return json_encode(['status' => 3,'msg' => 'Failed to unbind the relationship between the institution and the author']);
|
||||
}
|
||||
}
|
||||
Db::commit();
|
||||
return json_encode(['status' => 1,'msg' => 'success']);
|
||||
}
|
||||
}
|
||||
@@ -617,7 +617,7 @@ class Reviewer extends Base
|
||||
$data = $this->request->post();
|
||||
|
||||
//查询实例数据
|
||||
$res = $this->article_reviewer_obj->field('t_journal.*,t_article_reviewer.*,t_article.abstrart,t_article.title article_title,t_article.type atype,t_article.state astate,t_article.accept_sn accept_sn,t_user.account account')
|
||||
$res = $this->article_reviewer_obj->field('t_journal.*,t_article_reviewer.*,t_article.abstrart,t_article.title article_title,t_article.type atype,t_article.state astate,t_article.accept_sn accept_sn,t_user.account account,t_user.email as user_email')
|
||||
->join('t_article', 't_article.article_id = t_article_reviewer.article_id', 'LEFT')
|
||||
->join('t_user', 't_user.user_id = t_article_reviewer.reviewer_id', 'LEFT')
|
||||
->join('t_journal', 't_journal.journal_id = t_article.journal_id', 'left')
|
||||
|
||||
@@ -198,6 +198,8 @@ class Ucenter extends Base{
|
||||
//发送邮件给编辑
|
||||
$vv = "Dear editor,<br/><br/>";
|
||||
$vv .= "Please check the new application for Young Scientist Board Member for ".$journal_info['title']." Journal.";
|
||||
$sUserEmail = empty($user_info['email']) ? '' : $user_info['email'];
|
||||
$vv .= "<br/>please check applied email:".$sUserEmail;
|
||||
$mai['email'] = $editor_info['email'];
|
||||
$mai['title'] = $journal_info['title'];
|
||||
$mai['content'] = $vv;
|
||||
|
||||
@@ -1083,7 +1083,7 @@ class User extends Base
|
||||
->join("t_journal",'t_journal.journal_id = t_apply_yboard.journal_id','left')
|
||||
->join("t_user","t_user.user_id = t_apply_yboard.user_id",'left')
|
||||
->join("t_user_reviewer_info","t_user_reviewer_info.reviewer_id = t_user.user_id",'left')
|
||||
->where('t_apply_yboard.journal_id','in',$ids)->where('t_apply_yboard.state',0)->select();
|
||||
->where('t_apply_yboard.journal_id','in',$ids)->where('t_apply_yboard.state',0)->order('t_apply_yboard.ctime desc')->select();
|
||||
foreach($list as $k => $v){//补充简历信息
|
||||
$cac = $this->user_cv_obj->where('user_id',$v['user_id'])->where('state',0)->select();
|
||||
$list[$k]['cvs'] = $cac;
|
||||
|
||||
@@ -407,7 +407,7 @@ class Web extends Base
|
||||
{
|
||||
$ca_board = [];
|
||||
$boards = $this->board_to_journal_obj
|
||||
->field("t_board_to_journal.*,t_board_group.group_name,t_user.account,t_user.email,t_user.realname,t_user.icon,t_user.google_index,t_user.google_time,t_user.wos_index,t_user.wos_time,t_user_reviewer_info.*")
|
||||
->field("t_board_to_journal.btj_id,t_board_to_journal.user_id,t_board_to_journal.board_group_id,t_board_to_journal.journal_id,t_board_to_journal.type,t_board_to_journal.research_areas,t_board_to_journal.realname as board_realname,t_board_to_journal.email as board_email,t_board_to_journal.website as board_website,t_board_to_journal.affiliation as board_affiliation,t_board_to_journal.icon as board_icon,t_board_to_journal.technical as board_technical,t_board_to_journal.remark,t_board_to_journal.state,t_board_group.group_name,t_user.account,t_user.email,t_user.realname,t_user.icon,t_user.google_index,t_user.google_time,t_user.wos_index,t_user.wos_time,t_user_reviewer_info.*")
|
||||
->join("t_board_group", "t_board_group.board_group_id = t_board_to_journal.board_group_id", "left")
|
||||
->join("t_user", "t_user.user_id = t_board_to_journal.user_id", "left")
|
||||
->join("t_user_reviewer_info", "t_user_reviewer_info.reviewer_id=t_board_to_journal.user_id", "left")
|
||||
@@ -415,7 +415,6 @@ class Web extends Base
|
||||
->where('t_board_to_journal.state', 0)
|
||||
->order("t_board_group.board_group_id asc,t_user.realname")
|
||||
->select();
|
||||
|
||||
foreach ($boards as $val) {
|
||||
if ($aar) {
|
||||
$article1 = $this->article_obj->where('user_id', $val['user_id'])->where('journal_id', $val['journal_id'])->where('state', 5)->where('ctime', ">", strtotime("-1 year"))->select();
|
||||
@@ -431,6 +430,15 @@ class Web extends Base
|
||||
$val['reviewes'] = $reviewes;
|
||||
}
|
||||
|
||||
//编委数据隔离加默认数据 chengxiaoling 20251022 start
|
||||
$val['realname'] = empty($val['board_realname']) ? $val['realname'] : $val['board_realname'];
|
||||
$val['email'] = empty($val['board_email']) ? $val['email'] : $val['board_email'];
|
||||
$val['technical'] = empty($val['board_technical']) ? $val['technical'] : $val['board_technical'];
|
||||
$val['website'] = empty($val['board_website']) ? $val['website'] : $val['board_website'];
|
||||
$val['icon'] = empty($val['board_icon']) ? $val['icon'] : $val['board_icon'];
|
||||
$val['company'] = empty($val['board_affiliation']) ? $val['company'] : $val['board_affiliation'];
|
||||
//编委数据隔离加默认数据 chengxiaoling 20251022 end
|
||||
|
||||
if ($val['type'] == 0) {//主编
|
||||
$ca_board['main'][] = $val;
|
||||
} elseif ($val['type'] == 1) {//副主编
|
||||
|
||||
Reference in New Issue
Block a user