1
This commit is contained in:
@@ -98,7 +98,55 @@ class Production extends Controller
|
||||
if($check){
|
||||
return jsonError($rule->getError());
|
||||
}
|
||||
|
||||
$article_info = $this->article_obj->where('article_id',$data['article_id'])->find();
|
||||
$files = $this->article_file_obj
|
||||
->where('article_id', $article_info['article_id'])
|
||||
->where('type_name', 'manuscirpt')
|
||||
->order('ctime desc')
|
||||
->limit(1)
|
||||
->select();
|
||||
if (count($files) == 0) {
|
||||
return jsonError('No Manuscript');
|
||||
}
|
||||
$url = "http://ts.tmrjournals.com/api/typeset/webReaddoc";
|
||||
$program['fileRoute'] = "https://submission.tmrjournals.com/public/" . $files[0]['file_url'];
|
||||
$res = object_to_array(json_decode(myPost($url, $program)));
|
||||
|
||||
$file_runs = $res['data'];
|
||||
|
||||
//整理信息
|
||||
$frag = [];
|
||||
$aa = [];
|
||||
$frag['title'] = $article_info['title'];
|
||||
$start_refer = false;
|
||||
foreach ($file_runs as $k => $v) {
|
||||
if ($start_refer && $v != '') {
|
||||
if (strlen($v) > 500) {
|
||||
$start_refer = false;
|
||||
$frag['main'][] = $v;
|
||||
continue;
|
||||
}
|
||||
$frag['references'][] = $v;
|
||||
continue;
|
||||
}
|
||||
$g_val = trim(preg_replace('/\<.*?\>/', '', $v));
|
||||
$aa[] = $g_val;
|
||||
|
||||
if ((strpos(strtolower(trim($g_val)), "keyword") == 0 || strpos(strtolower(trim($g_val)), "keyword") == 1) && !isset($frag['keywords'])) {
|
||||
$frag['keywords'] = $v;
|
||||
continue;
|
||||
}
|
||||
if (strtolower($g_val) == 'reference:' || strtolower($g_val) == 'references:' || strtolower($g_val) == 'references' || strtolower($g_val) == 'reference') {
|
||||
$start_refer = true;
|
||||
continue;
|
||||
}
|
||||
$frag['main'][] = $v;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
$insert['article_id'] = $data['article_id'];
|
||||
$insert['journal_id'] = $article_info['journal_id'];
|
||||
$insert['ctime'] = time();
|
||||
@@ -129,7 +177,6 @@ class Production extends Controller
|
||||
$rule = new Validate([
|
||||
'p_article_id'=>'require|number',
|
||||
'title'=>'require',
|
||||
'subtitle'=>'require',
|
||||
'type'=>'require',
|
||||
'icon'=>'require',
|
||||
'tradition_tag'=>'require',
|
||||
@@ -145,13 +192,13 @@ class Production extends Controller
|
||||
return jsonError($rule->getError());
|
||||
}
|
||||
$update['title'] = trim($data['title']);
|
||||
$update['subtitle'] = trim($data['subtitle']);
|
||||
$update['type'] = trim($data['type']);
|
||||
$update['icon'] = trim($data['icon']);
|
||||
$update['tradition_tag'] = trim($data['tradition_tag']);
|
||||
$update['tradition'] = trim($data['tradition']);
|
||||
$update['mhoo'] = isset($data['mhoo'])?trim($data['mhoo']):'';
|
||||
$update['doi'] = trim($data['doi']);
|
||||
$update['ltai'] = isset($data['ltai'])?trim($data['ltai']):'';
|
||||
$update['abstract'] = trim($data['abstract']);
|
||||
$update['keywords'] = trim($data['keywords']);
|
||||
$update['fund'] = trim($data['fund']);
|
||||
@@ -190,7 +237,7 @@ class Production extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取生产实例列表
|
||||
* 获取生产实例详情
|
||||
*/
|
||||
public function getProductionDetail(){
|
||||
$data = $this->request->post();
|
||||
@@ -201,13 +248,20 @@ class Production extends Controller
|
||||
return jsonError($rule->getError());
|
||||
}
|
||||
$p_info = $this->production_article_obj->where('p_article_id',$data['p_article_id'])->find();
|
||||
|
||||
|
||||
|
||||
|
||||
$list = $this->production_article_author_obj->where('p_article_id',$data['p_article_id'])->where('state',0)->select();
|
||||
foreach($list as $k => $v){
|
||||
$list[$k]['organs'] = $this->production_article_author_to_organ_obj
|
||||
->field("t_production_article_organ.*")
|
||||
->join("t_production_article_organ",'t_production_article_organ.p_article_organ_id = t_production_article_author_to_organ.p_article_organ_id','left')
|
||||
->where('p_article_author_id',$v['p_article_author_id'])
|
||||
->select();
|
||||
}
|
||||
$re['production'] = $p_info;
|
||||
$re['author'] = $list;
|
||||
return jsonSuccess($re);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 添加作者机构
|
||||
*/
|
||||
@@ -299,7 +353,7 @@ class Production extends Controller
|
||||
$insert['article_id'] = $p_info['article_id'];
|
||||
$insert['author_name'] = $data['first_name'].' '.$data['last_name'];
|
||||
$insert['first_name'] = $data['first_name'];
|
||||
$insert['last_name'] = $data['las_name'];
|
||||
$insert['last_name'] = $data['last_name'];
|
||||
$insert['orcid'] = isset($data['orcid'])?$data['orcid']:'';
|
||||
$insert['author_country'] = $data['author_country'];
|
||||
$insert['is_first'] = $data['is_first'];
|
||||
@@ -327,6 +381,142 @@ class Production extends Controller
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新引用条目
|
||||
*/
|
||||
public function freshRefers()
|
||||
{
|
||||
$data = $this->request->post();
|
||||
$rule = new Validate([
|
||||
'p_article_id' => 'require',
|
||||
'refers' => 'require|array'
|
||||
]);
|
||||
if (!$rule->check($data)) {
|
||||
return jsonError($rule->getError());
|
||||
}
|
||||
|
||||
$p_info = $this->production_article_obj->where('p_article_id', $data['p_article_id'])->where('state', 0)->find();
|
||||
//清空之前的引用条目
|
||||
$this->production_article_refer_obj->where('p_article_id', $p_info['p_article_id'])->update(['state' => 1]);
|
||||
|
||||
foreach ($data['refers'] as $k => $v) {
|
||||
$cache_insert['p_article_id'] = $p_info['p_article_id'];
|
||||
$cache_insert['refer_content'] = $v;
|
||||
$cache_insert['ctime'] = time();
|
||||
$this->production_article_refer_obj->insert($cache_insert);
|
||||
}
|
||||
|
||||
$this->referToDoi($data['p_article_id']);
|
||||
$this->doiTofrag($data['p_article_id']);
|
||||
return jsonSuccess([]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 参考文献识别doi
|
||||
*/
|
||||
public function referToDoi($p_article_id)
|
||||
{
|
||||
$p_info = $this->production_article_obj->where('p_article_id',$p_article_id)->find();
|
||||
$refers = $this->production_article_refer_obj->where('p_article_id', $p_info['p_article_id'])->where('state', 0)->select();
|
||||
foreach ($refers as $v) { //处理doi
|
||||
if (strripos($v['refer_content'], 'doi:') == false && strripos($v['refer_content'], 'doi.org/') == false) {
|
||||
continue;
|
||||
}
|
||||
$doi = '';
|
||||
if (strripos($v['refer_content'], 'doi.org/') != false) {
|
||||
$cache_arr = explode(' ', trim(substr($v['refer_content'], strripos($v['refer_content'], 'doi.org/') + 8)));
|
||||
if (substr($cache_arr[0], -1) == '.') {
|
||||
$doi = substr($cache_arr[0], 0, -1);
|
||||
} else {
|
||||
$doi = $cache_arr[0];
|
||||
}
|
||||
} else {
|
||||
$cache_arr = explode(' ', trim(substr($v['refer_content'], strripos($v['refer_content'], 'doi:') + 4)));
|
||||
if (substr($cache_arr[0], -1) == '.') {
|
||||
$doi = substr($cache_arr[0], 0, -1);
|
||||
} else {
|
||||
$doi = $cache_arr[0];
|
||||
}
|
||||
}
|
||||
$this->production_article_refer_obj->where('p_refer_id', $v['p_refer_id'])->update(['refer_doi' => $doi]);
|
||||
}
|
||||
return jsonSuccess([]);
|
||||
}
|
||||
|
||||
public function doiTofrag($p_article_id)
|
||||
{
|
||||
$p_info = $this->production_article_obj->where('p_article_id',$p_article_id)->find();
|
||||
$refers = $this->production_article_refer_obj->where('p_article_id', $p_info['p_article_id'])->where('state', 0)->select();
|
||||
foreach ($refers as $v) {
|
||||
if ($v['refer_doi'] == '') {
|
||||
$this->production_article_refer_obj->where('p_refer_id', $v['p_refer_id'])->update(['refer_frag' => $v['refer_content']]);
|
||||
} else {
|
||||
Queue::push('app\api\job\ts@fire1', $v, 'ts');
|
||||
}
|
||||
}
|
||||
return jsonSuccess([]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证参考文献是否全部通过
|
||||
*/
|
||||
public function checkRefer()
|
||||
{
|
||||
$data = $this->request->post();
|
||||
$rule = new Validate([
|
||||
'p_article_id' => 'require'
|
||||
]);
|
||||
if (!$rule->check($data)) {
|
||||
return jsonError($rule->getError());
|
||||
}
|
||||
$list = $this->production_article_refer_obj->where('p_article_id',$data['p_article_id'])->where('state',0)->select();
|
||||
if (!$list) {
|
||||
return jsonError('references error');
|
||||
}
|
||||
$frag = 1;
|
||||
foreach ($list as $v) {
|
||||
if ($v['cs'] == 0) {
|
||||
$frag = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ($frag == 0) {
|
||||
return jsonError('references check error');
|
||||
} else {
|
||||
return jsonSuccess([]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function getFragBF()
|
||||
{
|
||||
$data = $this->request->post();
|
||||
// 验证规则
|
||||
$rule = new Validate([
|
||||
'p_article_id' => 'require|number'
|
||||
]);
|
||||
if (!$rule->check($data)) {
|
||||
return jsonError($rule->getError());
|
||||
}
|
||||
$list = $this->production_article_refer_obj->where('p_article_id',$data['p_article_id'])->where('state',0)->select();
|
||||
$z = count($list);
|
||||
$m = 0;
|
||||
foreach ($list as $v) {
|
||||
if ($v['refer_frag'] != '') {
|
||||
$m++;
|
||||
}
|
||||
}
|
||||
|
||||
if ($z == 0) {
|
||||
return jsonError('system error!');
|
||||
}
|
||||
|
||||
$f = intval($m * 100 / $z);
|
||||
|
||||
$re['bf'] = $f;
|
||||
return jsonSuccess($re);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除作者
|
||||
*/
|
||||
@@ -338,7 +528,7 @@ class Production extends Controller
|
||||
if(!$rule->check($data)){
|
||||
return jsonError($rule->getError());
|
||||
}
|
||||
$this->production_article_author_obj->where('p_article_author_id',$data['p_artice_author_id'])->update(['state'=>1]);
|
||||
$this->production_article_author_obj->where('p_article_author_id',$data['p_article_author_id'])->update(['state'=>1]);
|
||||
return jsonSuccess([]);
|
||||
}
|
||||
|
||||
@@ -365,14 +555,44 @@ class Production extends Controller
|
||||
return jsonSuccess($re);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更改附加文件
|
||||
*/
|
||||
public function editArticleFile() {
|
||||
$data = $this->request->post();
|
||||
$rule = new Validate([
|
||||
'p_article_id'=>'require',
|
||||
'filetype'=>'require'
|
||||
]);
|
||||
if(!$rule->check($data)){
|
||||
return jsonError($rule->getError());
|
||||
}
|
||||
if ($data['filetype'] == 'PDF') {
|
||||
$updata['file_pdf'] = $data['fileURL'];
|
||||
} elseif ($data['filetype'] == 'HTML') {
|
||||
$updata['file_html'] = $data['fileURL'];
|
||||
} elseif ($data['filetype'] == 'SUB') {
|
||||
$updata['file_sub'] = $data['fileURL'];
|
||||
} elseif ($data['filetype'] == 'SUB2') {
|
||||
$updata['file_sub2'] = $data['fileURL'];
|
||||
} elseif ($data['filetype'] == 'endNote') {
|
||||
$updata['endnote'] = $data['fileURL'];
|
||||
} elseif ($data['filetype'] == 'bibTex') {
|
||||
$updata['bibtex'] = $data['fileURL'];
|
||||
}elseif($data['filetype'] == 'CDF'){
|
||||
$updata['file_cdf'] = $data['fileURL'];
|
||||
}
|
||||
$this->production_article_obj->where('p_article_id',$data['p_article_id'])->update($updata);
|
||||
return jsonSuccess([]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传文件
|
||||
* 上传文章图片文件
|
||||
*/
|
||||
public function up_file(){
|
||||
$file = request()->file('pdf');
|
||||
public function up_articlepic_file(){
|
||||
$file = request()->file('articleicon');
|
||||
if ($file) {
|
||||
$info = $file->move(ROOT_PATH . 'public' . DS . 'pdf');
|
||||
$info = $file->move(ROOT_PATH . 'public' . DS . 'articleicon');
|
||||
if ($info) {
|
||||
return json(['code' => 0, 'upurl' => str_replace("\\", "/", $info->getSaveName())]);
|
||||
} else {
|
||||
@@ -381,5 +601,25 @@ class Production extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @title 文章文件上传
|
||||
*
|
||||
* @param name:name type:string require:1 desc:文件域名称(articleSUB/articleSUB2/bibTex/endNote/articleCDF)
|
||||
* @param name:type type:string require:1 desc:pathinfo(articleSUB/articleSUB2/bibTex/endNote/articleCDF)
|
||||
*
|
||||
* @return upurl:图片地址
|
||||
*/
|
||||
public function up_article_file($type) {
|
||||
$file = request()->file($type);
|
||||
if ($file) {
|
||||
$info = $file->move(ROOT_PATH . 'public' . DS . $type);
|
||||
if ($info) {
|
||||
return json(['code' => 0, 'msg' => 'success', 'upurl' => str_replace("\\", "/", $info->getSaveName())]);
|
||||
} else {
|
||||
return json(['code' => 1, 'msg' => $file->getError()]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ class User extends Controller
|
||||
}
|
||||
|
||||
public function pstest(){
|
||||
echo md5('TMR893533');
|
||||
echo md5('tmrmhm!');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -13,6 +13,11 @@ class ts {
|
||||
$job->delete();
|
||||
}
|
||||
|
||||
public function fire1(Job $job, $data) {
|
||||
my_doiToFrag1($data);
|
||||
$job->delete();
|
||||
}
|
||||
|
||||
|
||||
// public function doFrag($data){
|
||||
// $ts_refer_obj = Db::name('ts_refer');
|
||||
|
||||
Reference in New Issue
Block a user