1
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace app\master\controller;
|
||||
|
||||
use Exception;
|
||||
use think\Controller;
|
||||
use think\Db;
|
||||
use think\Queue;
|
||||
@@ -398,95 +399,109 @@ class Article extends Controller {
|
||||
$insert['title'] = trim($data['title']);
|
||||
$insert['journal_id'] = $journal_info['journal_id'];
|
||||
$insert['journal_stage_id'] = $data['journal_stage_id'];
|
||||
// $insert['type'] = $data['type'];
|
||||
// if(isset($data['icon'])&&$data['icon']!=''){
|
||||
// $insert['icon'] = $data['icon'];
|
||||
// }
|
||||
// $insert['doi'] = $data['doi'];
|
||||
// $insert['abstract'] = $data['abstract'];
|
||||
// $insert['pub_date'] = $data['pub_date'];
|
||||
// $insert['keywords'] = $data['keywords'];
|
||||
$insert['type'] = $data['type'];
|
||||
if(isset($data['icon'])&&$data['icon']!=''){
|
||||
$insert['icon'] = $data['icon'];
|
||||
}
|
||||
$insert['doi'] = $data['doi'];
|
||||
$insert['abstract'] = $data['abstract'];
|
||||
$insert['pub_date'] = $data['pub_date'];
|
||||
$insert['keywords'] = $data['keywords'];
|
||||
$insert['npp'] = $data['npp'];
|
||||
$insert['file_pdf'] = date('Ymd').DS.$file_name;
|
||||
$insert['is_public'] = 0;
|
||||
$insert['ctime'] = time();
|
||||
|
||||
Db::startTrans();
|
||||
$aid = $this->article_obj->insertGetId($insert);
|
||||
|
||||
//处理作者
|
||||
|
||||
// $authors = object_to_array(json_decode($data['authors']));
|
||||
|
||||
// $o = [];
|
||||
// $orgs = [];
|
||||
// foreach($authors as $k => $v){
|
||||
// if(in_array($v['company'],$orgs)){
|
||||
// continue;
|
||||
// }
|
||||
// $orgs[] = $v['company'];
|
||||
// }
|
||||
// foreach($orgs as $v){
|
||||
// $insert_oo['article_id'] = $aid;
|
||||
// $insert_oo['organ_name'] = $v;
|
||||
// $ca_id = $this->article_organ_obj->insertGetId($insert_oo);
|
||||
// $o[$v] = $ca_id;
|
||||
// }
|
||||
// foreach($authors as $v){
|
||||
// $insert_author['article_id'] = $aid;
|
||||
// $insert_author['author_name'] = $v['firstname'].' '.$v['lastname'];
|
||||
// $insert_author['first_name'] = $v['firstname'];
|
||||
// $insert_author['last_name'] = $v['lastname'];
|
||||
// $insert_author['author_country'] = $v['country'];
|
||||
// $insert_author['is_first'] = $v['is_super'];
|
||||
// $insert_author['is_report'] = $v['is_report'];
|
||||
// $insert_author['email'] = $v['email'];
|
||||
// $ca_au_id = $this->article_author_obj->insertGetId($insert_author);
|
||||
// $insert_orm['article_id'] = $aid;
|
||||
// $insert_orm['article_author_id'] = $ca_au_id;
|
||||
// $insert_orm['article_organ_id'] = $o[$v['company']];
|
||||
// $this->author_to_organ_obj->insert($insert_orm);
|
||||
// }
|
||||
return jsonSuccess([]);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function authortest(){
|
||||
$str = "[{\"art_aut_id\":6474,\"article_id\":2065,\"firstname\":\"Tadele\",\"lastname\":\"Yadesa\",\"orcid\":\"https:\\/\\/orcid.org\\/ 0000-0001-5151-2610\",\"company\":\"Mbarara University of Science and Technology\",\"department\":\"Pharmacy\",\"email\":\"maatiikoo4@gmail.com\",\"author_title\":\"Ph.D.\",\"country\":\"Uganda\",\"address\":\"Mbarara University of Science and Technology P.O.BOX 1410\",\"is_super\":1,\"is_report\":1,\"state\":0},{\"art_aut_id\":6475,\"article_id\":2065,\"firstname\":\"Oliver\",\"lastname\":\"Kushemererwa\",\"orcid\":\"\",\"company\":\"Mbarara University of Science and Technology\",\"department\":\"Pharmacy\",\"email\":\"Kusholiver@gmail.com\",\"author_title\":\"Others\",\"country\":\"Uganda\",\"address\":\"\",\"is_super\":0,\"is_report\":0,\"state\":0},{\"art_aut_id\":6476,\"article_id\":2065,\"firstname\":\"Joshua\",\"lastname\":\"Kiptoo\",\"orcid\":\"\",\"company\":\"Mbarara University of Science and Technology\",\"department\":\"Pharmacy\",\"email\":\"KIPTOOKWALIA@gmail.com\",\"author_title\":\"Others\",\"country\":\"Uganda\",\"address\":\"\",\"is_super\":0,\"is_report\":0,\"state\":0},{\"art_aut_id\":6477,\"article_id\":2065,\"firstname\":\"John\",\"lastname\":\"Isiiko\",\"orcid\":\"\",\"company\":\"Mbarara University of Science and Technology\",\"department\":\"Pharmacy\",\"email\":\"isiikojohn@gmail.com\",\"author_title\":\"Others\",\"country\":\"Uganda\",\"address\":\"\",\"is_super\":0,\"is_report\":0,\"state\":0},{\"art_aut_id\":6478,\"article_id\":2065,\"firstname\":\"Bonny\",\"lastname\":\"Luzze\",\"orcid\":\"\",\"company\":\"Mbarara University of Science and Technology\",\"department\":\"Pharmacy\",\"email\":\"tottojrlz@gmail.com\",\"author_title\":\"Others\",\"country\":\"Uganda\",\"address\":\"\",\"is_super\":0,\"is_report\":0,\"state\":0},{\"art_aut_id\":6479,\"article_id\":2065,\"firstname\":\"Jacinta\",\"lastname\":\"Ojia\",\"orcid\":\"\",\"company\":\"Mbarara University of Science and Technology\",\"department\":\"Internal medicine\",\"email\":\"ambark21@yahoo.com\",\"author_title\":\"Others\",\"country\":\"Uganda\",\"address\":\"\",\"is_super\":0,\"is_report\":0,\"state\":0},{\"art_aut_id\":6480,\"article_id\":2065,\"firstname\":\"Mohamed\",\"lastname\":\"Abdirahman\",\"orcid\":\"\",\"company\":\"Mbarara University of Science and Technology\",\"department\":\"Internal medicine\",\"email\":\"dr.mma001838@gmail.com\",\"author_title\":\"Others\",\"country\":\"Uganda\",\"address\":\"\",\"is_super\":1,\"is_report\":0,\"state\":0}]";
|
||||
$authors = object_to_array(json_decode($str));
|
||||
$o = [];
|
||||
$orgs = [];
|
||||
foreach($authors as $k => $v){
|
||||
if(in_array($v['company'],$orgs)){
|
||||
continue;
|
||||
}
|
||||
$orgs[] = $v['company'];
|
||||
}
|
||||
foreach($orgs as $v){
|
||||
$insert['article_id'] = 8888;
|
||||
$insert['organ_name'] = $v;
|
||||
$ca_id = $this->article_organ_obj->insertGetId($insert);
|
||||
$o[$v] = $ca_id;
|
||||
try{
|
||||
$authors = object_to_array(json_decode($data['authors']));
|
||||
$organs = object_to_array(json_decode($data['organs']));
|
||||
$organ_res = true;
|
||||
foreach($organs as $v){
|
||||
$ca_insert['article_id'] = $aid;
|
||||
$ca_insert['organ_name'] = $v['organ_name'];
|
||||
$organ_res = $this->article_organ_obj->insert($ca_insert);
|
||||
}
|
||||
$author_res = true;
|
||||
$ato_res = true;
|
||||
$ca_au_id = true;
|
||||
foreach($authors as $v){
|
||||
$insert_author['article_id'] = 8888;
|
||||
$insert_author['author_name'] = $v['firstname'].' '.$v['lastname'];
|
||||
$insert_author['first_name'] = $v['firstname'];
|
||||
$insert_author['last_name'] = $v['lastname'];
|
||||
$insert_author['author_country'] = $v['country'];
|
||||
$insert_author['is_first'] = $v['is_super'];
|
||||
$insert_author['article_id'] = $aid;
|
||||
$insert_author['author_name'] = $v['first_name'].' '.$v['last_name'];
|
||||
$insert_author['first_name'] = $v['first_name'];
|
||||
$insert_author['last_name'] = $v['last_name'];
|
||||
$insert_author['author_country'] = $v['author_country'];
|
||||
$insert_author['is_first'] = $v['is_first'];
|
||||
$insert_author['is_report'] = $v['is_report'];
|
||||
$insert_author['email'] = $v['email'];
|
||||
$ca_au_id = $this->article_author_obj->insertGetId($insert_author);
|
||||
$insert_orm['article_id'] = 8888;
|
||||
$insert_orm['article_author_id'] = $ca_au_id;
|
||||
$insert_orm['article_organ_id'] = $o[$v['company']];
|
||||
$this->author_to_organ_obj->insert($insert_orm);
|
||||
$cache_organs = $v['organs'];
|
||||
foreach($cache_organs as $val){
|
||||
$c_organ = $this->article_organ_obj->where('article_id',$aid)->where('organ_name',$val['organ_name'])->find();
|
||||
if($c_organ==null){
|
||||
return jsonError('organ error!');
|
||||
}
|
||||
$insert_orm['article_id'] = $aid;
|
||||
$insert_orm['article_author_id'] = $ca_au_id;
|
||||
$insert_orm['article_organ_id'] = $c_organ['article_organ_id'];
|
||||
$ato_res = $this->author_to_organ_obj->insert($insert_orm);
|
||||
}
|
||||
|
||||
}}catch(Exception $e){
|
||||
|
||||
Db::rollback();
|
||||
return jsonError($e->getMessage());
|
||||
}
|
||||
echo 'ok';
|
||||
|
||||
if($aid&&$organ_res&&$author_res&&$ato_res&&$ca_au_id){
|
||||
Db::commit();
|
||||
return jsonSuccess([]);
|
||||
} else {
|
||||
Db::rollback();
|
||||
return jsonError('system error');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// public function authortest(){
|
||||
// $str = "[{\"art_aut_id\":6474,\"article_id\":2065,\"firstname\":\"Tadele\",\"lastname\":\"Yadesa\",\"orcid\":\"https:\\/\\/orcid.org\\/ 0000-0001-5151-2610\",\"company\":\"Mbarara University of Science and Technology\",\"department\":\"Pharmacy\",\"email\":\"maatiikoo4@gmail.com\",\"author_title\":\"Ph.D.\",\"country\":\"Uganda\",\"address\":\"Mbarara University of Science and Technology P.O.BOX 1410\",\"is_super\":1,\"is_report\":1,\"state\":0},{\"art_aut_id\":6475,\"article_id\":2065,\"firstname\":\"Oliver\",\"lastname\":\"Kushemererwa\",\"orcid\":\"\",\"company\":\"Mbarara University of Science and Technology\",\"department\":\"Pharmacy\",\"email\":\"Kusholiver@gmail.com\",\"author_title\":\"Others\",\"country\":\"Uganda\",\"address\":\"\",\"is_super\":0,\"is_report\":0,\"state\":0},{\"art_aut_id\":6476,\"article_id\":2065,\"firstname\":\"Joshua\",\"lastname\":\"Kiptoo\",\"orcid\":\"\",\"company\":\"Mbarara University of Science and Technology\",\"department\":\"Pharmacy\",\"email\":\"KIPTOOKWALIA@gmail.com\",\"author_title\":\"Others\",\"country\":\"Uganda\",\"address\":\"\",\"is_super\":0,\"is_report\":0,\"state\":0},{\"art_aut_id\":6477,\"article_id\":2065,\"firstname\":\"John\",\"lastname\":\"Isiiko\",\"orcid\":\"\",\"company\":\"Mbarara University of Science and Technology\",\"department\":\"Pharmacy\",\"email\":\"isiikojohn@gmail.com\",\"author_title\":\"Others\",\"country\":\"Uganda\",\"address\":\"\",\"is_super\":0,\"is_report\":0,\"state\":0},{\"art_aut_id\":6478,\"article_id\":2065,\"firstname\":\"Bonny\",\"lastname\":\"Luzze\",\"orcid\":\"\",\"company\":\"Mbarara University of Science and Technology\",\"department\":\"Pharmacy\",\"email\":\"tottojrlz@gmail.com\",\"author_title\":\"Others\",\"country\":\"Uganda\",\"address\":\"\",\"is_super\":0,\"is_report\":0,\"state\":0},{\"art_aut_id\":6479,\"article_id\":2065,\"firstname\":\"Jacinta\",\"lastname\":\"Ojia\",\"orcid\":\"\",\"company\":\"Mbarara University of Science and Technology\",\"department\":\"Internal medicine\",\"email\":\"ambark21@yahoo.com\",\"author_title\":\"Others\",\"country\":\"Uganda\",\"address\":\"\",\"is_super\":0,\"is_report\":0,\"state\":0},{\"art_aut_id\":6480,\"article_id\":2065,\"firstname\":\"Mohamed\",\"lastname\":\"Abdirahman\",\"orcid\":\"\",\"company\":\"Mbarara University of Science and Technology\",\"department\":\"Internal medicine\",\"email\":\"dr.mma001838@gmail.com\",\"author_title\":\"Others\",\"country\":\"Uganda\",\"address\":\"\",\"is_super\":1,\"is_report\":0,\"state\":0}]";
|
||||
// $authors = object_to_array(json_decode($str));
|
||||
// $o = [];
|
||||
// $orgs = [];
|
||||
// foreach($authors as $k => $v){
|
||||
// if(in_array($v['company'],$orgs)){
|
||||
// continue;
|
||||
// }
|
||||
// $orgs[] = $v['company'];
|
||||
// }
|
||||
// foreach($orgs as $v){
|
||||
// $insert['article_id'] = 8888;
|
||||
// $insert['organ_name'] = $v;
|
||||
// $ca_id = $this->article_organ_obj->insertGetId($insert);
|
||||
// $o[$v] = $ca_id;
|
||||
// }
|
||||
// foreach($authors as $v){
|
||||
// $insert_author['article_id'] = 8888;
|
||||
// $insert_author['author_name'] = $v['firstname'].' '.$v['lastname'];
|
||||
// $insert_author['first_name'] = $v['firstname'];
|
||||
// $insert_author['last_name'] = $v['lastname'];
|
||||
// $insert_author['author_country'] = $v['country'];
|
||||
// $insert_author['is_first'] = $v['is_super'];
|
||||
// $insert_author['is_report'] = $v['is_report'];
|
||||
// $insert_author['email'] = $v['email'];
|
||||
// $ca_au_id = $this->article_author_obj->insertGetId($insert_author);
|
||||
// $insert_orm['article_id'] = 8888;
|
||||
// $insert_orm['article_author_id'] = $ca_au_id;
|
||||
// $insert_orm['article_organ_id'] = $o[$v['company']];
|
||||
// $this->author_to_organ_obj->insert($insert_orm);
|
||||
// }
|
||||
// echo 'ok';
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user