This commit is contained in:
wangjinlei
2021-07-07 10:52:20 +08:00
parent 7f95e7ec98
commit e8862b2807

View File

@@ -1042,19 +1042,19 @@ class Article extends Controller {
public function pushCrossref() {
$data = $this->request->post();
$has = $this->article_obj->where('doi','10.53388/'.$data['doi_num'])->find();
if($has){
$has = $this->article_obj->where('doi', '10.53388/' . $data['doi_num'])->find();
if ($has) {
return jsonError('doi号重复');
}
if(strstr($data['doi_num'],'/')!==false){
if (strstr($data['doi_num'], '/') !== false) {
return jsonError('格式错误');
}
$author = $this->article_author_obj->where('article_id', $data['article_id'])->where('state', 0)->find();
if($author==null){
if ($author == null) {
return jsonError('请先上传作者');
}
$article_info = $this->article_obj->where('article_id', $data['article_id'])->find();
if($article_info['npp']==''){
if ($article_info['npp'] == '') {
return jsonError('请先上传页码');
}
$url = 'https://doi.crossref.org/servlet/deposit';
@@ -1062,7 +1062,7 @@ class Article extends Controller {
$this->crossRef($data);
//存储
$this->article_obj->where('article_id',$data['article_id'])->update(['doi'=>'10.53388/'.$data['doi_num']]);
$this->article_obj->where('article_id', $data['article_id'])->update(['doi' => '10.53388/' . $data['doi_num']]);
//发送请求
$par['login_id'] = 'books@tmrjournals.com/tmrp';
@@ -1096,14 +1096,12 @@ class Article extends Controller {
// die;
}
public function met(){
public function met() {
$s = '11';
$arr = explode('-', $s);
echo $arr[0];
$arr = explode('-', $s);
echo $arr[0];
}
public function crossRef($data) {
$xml = '';
//create xml 头
@@ -1166,7 +1164,7 @@ http://www.crossref.org/schemas/crossref4.3.7.xsd">' . PHP_EOL . PHP_EOL;
$xml .= '<first_page>' . $ca[0] . '</first_page>' . PHP_EOL;
$xml .= '</pages>' . PHP_EOL;
$xml .= '<publisher_item>' . PHP_EOL;
$xml .= '<identifier id_type="pii">'.trim($data['doi_num']).'</identifier>' . PHP_EOL;
$xml .= '<identifier id_type="pii">' . trim($data['doi_num']) . '</identifier>' . PHP_EOL;
$xml .= '</publisher_item>' . PHP_EOL;
$xml .= '<doi_data>' . PHP_EOL;
$xml .= '<doi>10.53388/' . trim($data['doi_num']) . '</doi>' . PHP_EOL;
@@ -1180,6 +1178,111 @@ http://www.crossref.org/schemas/crossref4.3.7.xsd">' . PHP_EOL . PHP_EOL;
file_put_contents($txt, $xml);
}
private function changDOI() {
$list = $this->article_obj->where('journal_id', 14)->where('state', 0)->select();
foreach ($list as $art) {
$ca_doi = explode('/', $art['doi']);
if (!isset($ca_doi[1])) {
continue;
}
$doi = '10.53388/' . $ca_doi[1];
$this->article_obj->where('article_id',$art['article_id'])->update(['doi'=>$doi]);
}
}
/**
* 生成xml文件
*/
private function makeXML() {
$xml = '';
//create xml 头
$xml .= '<?xml version="1.0" encoding="UTF-8"?>' . PHP_EOL;
$xml .= '<doi_batch version="4.3.7" xmlns="http://www.crossref.org/schema/4.3.7" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.crossref.org/schema/4.3.7
http://www.crossref.org/schemas/crossref4.3.7.xsd">' . PHP_EOL . PHP_EOL;
$xml .= '<head>' . PHP_EOL;
$xml .= '<doi_batch_id>' . date('Ymd') . '</doi_batch_id>' . PHP_EOL;
$xml .= '<timestamp>' . date('YmdHis') . '</timestamp>' . PHP_EOL;
$xml .= '<depositor>' . PHP_EOL;
$xml .= '<depositor_name>tmr@tmrjournals.com</depositor_name>' . PHP_EOL;
$xml .= '<email_address>tmr@tmrjournals.com</email_address>' . PHP_EOL;
$xml .= '</depositor>' . PHP_EOL;
$xml .= '<registrant>TMR</registrant>' . PHP_EOL;
$xml .= '</head>' . PHP_EOL;
$xml .= '<body>' . PHP_EOL;
//组装主体信息部分
$journal_info = $this->journal_obj->where('journal_id', 14)->find();
// $article_info = $this->article_obj->where('article_id', $data['article_id'])->find();
$stage_list = $this->journal_stage_obj->where('journal_id', 14)->where('state', 0)->select();
foreach ($stage_list as $stage) {
$xml .= '<journal>' . PHP_EOL;
$xml .= '<journal_metadata language="en">' . PHP_EOL;
$xml .= '<full_title>' . $journal_info['title'] . '</full_title>' . PHP_EOL;
$xml .= '<abbrev_title>' . $journal_info['jabbr'] . '</abbrev_title>' . PHP_EOL;
$xml .= '<issn media_type="print">' . $journal_info['issn'] . '</issn>' . PHP_EOL;
$xml .= '<coden>' . $journal_info['usx'] . '</coden>' . PHP_EOL;
$xml .= '</journal_metadata>' . PHP_EOL;
$xml .= '<journal_issue>' . PHP_EOL;
$xml .= '<publication_date media_type="print">' . PHP_EOL;
$xml .= '<year>' . $stage['stage_year'] . '</year>' . PHP_EOL;
$xml .= '</publication_date>' . PHP_EOL;
$xml .= '<journal_volume>' . PHP_EOL;
$xml .= '<volume>' . $stage['stage_vol'] . '</volume>' . PHP_EOL;
$xml .= '</journal_volume>' . PHP_EOL;
$xml .= '<issue>' . $stage['stage_no'] . '</issue>' . PHP_EOL;
$xml .= '</journal_issue>' . PHP_EOL;
$art_list = $this->article_obj->where('journal_stage_id', $stage['journal_stage_id'])->where('state', 0)->select();
foreach ($art_list as $art) {
$ca_doi = explode('/', $art['doi']);
if (!isset($ca_doi[1])) {
continue;
}
$doi = '10.53388/' . $ca_doi[1];
$xml .= '<journal_article publication_type="full_text">' . PHP_EOL;
$xml .= '<titles>' . PHP_EOL;
$xml .= '<title>' . $art['title'] . '</title>' . PHP_EOL;
$xml .= '</titles>' . PHP_EOL;
$xml .= '<contributors>' . PHP_EOL;
$authors = $this->article_author_obj->where('article_id', $art['article_id'])->where('state', 0)->select();
foreach ($authors as $v) {
if ($v['is_first'] == 1) {
$xml .= '<person_name sequence="first" contributor_role="author">' . PHP_EOL;
} else {
$xml .= '<person_name sequence="additional" contributor_role="author">' . PHP_EOL;
}
$xml .= '<given_name>' . $v['first_name'] . '</given_name>' . PHP_EOL;
$xml .= '<surname>' . $v['last_name'] . '</surname>' . PHP_EOL;
$xml .= '</person_name>' . PHP_EOL;
}
$xml .= '</contributors>' . PHP_EOL;
$xml .= '<publication_date media_type="print">' . PHP_EOL;
$xml .= '<year>' . $stage['stage_year'] . '</year>' . PHP_EOL;
$xml .= '</publication_date>' . PHP_EOL;
$xml .= '<pages>' . PHP_EOL;
$ca = explode('-', $art['npp']);
$xml .= '<first_page>' . $ca[0] . '</first_page>' . PHP_EOL;
$xml .= '</pages>' . PHP_EOL;
$xml .= '<publisher_item>' . PHP_EOL;
$xml .= '<identifier id_type="pii">' . $doi . '</identifier>' . PHP_EOL;
$xml .= '</publisher_item>' . PHP_EOL;
$xml .= '<doi_data>' . PHP_EOL;
$xml .= '<doi>' . $doi . '</doi>' . PHP_EOL;
$xml .= '<resource><![CDATA[https://www.tmrjournals.com/article.html?J_num=' . $journal_info['journal_id'] . '&a_id=' . $art['article_id'] . ']]></resource>' . PHP_EOL;
$xml .= '</doi_data>' . PHP_EOL;
$xml .= '</journal_article>' . PHP_EOL;
}
$xml .= '</journal>' . PHP_EOL;
}
$xml .= '</body>' . PHP_EOL;
$xml .= '</doi_batch>' . PHP_EOL;
$txt = ROOT_PATH . 'public' . DS . 'xml' . DS . 'all_1.xml';
file_put_contents($txt, $xml);
}
/**
* @title 注册doi
* @description 注册doi
@@ -1280,15 +1383,14 @@ http://www.crossref.org/schemas/crossref4.3.7.xsd">' . PHP_EOL . PHP_EOL;
file_put_contents($txt, $xml);
}
public function upXML() {
vendor("chinadoi.UPXML2");
$up_obj = new \UpXml;
$xmlfile = ROOT_PATH . 'public' . DS . 'xml' . DS . '1333.xml';
$result = $up_obj->upload($xmlfile);
echo '<pre>';
var_dump($result);
echo '</pre>';
die;
}
// public function upXML() {
// vendor("chinadoi.UPXML2");
// $up_obj = new \UpXml;
// $xmlfile = ROOT_PATH . 'public' . DS . 'xml' . DS . '1333.xml';
// $result = $up_obj->upload($xmlfile);
// echo '<pre>';
// var_dump($result);
// echo '</pre>';
// die;
// }
}