This commit is contained in:
wangjinlei
2022-06-21 17:24:06 +08:00
parent 7016414402
commit d1e973388a
8 changed files with 633 additions and 283 deletions

View File

@@ -391,151 +391,6 @@ class Admin extends Controller {
return json($res); return json($res);
} }
/**
* 导入reviewer
*/
public function reviewerImport() {
die("server stoped");
//接收信息
$data = $this->request->post();
// $data['journal'] = 5;
// $data['url'] = 'reviewer/import/20210819/beb6de5c69e4878d995fd8de192d17af.xlsx';
$journal = $data['journal'];
$journal_info = $this->journal_obj->where('journal_id', $journal)->find();
//读取excel
$path = ROOT_PATH . 'public' . DS . $data['url'];
$frag = self::readExcel($path);
//check数据分开存储
$su_data = [];
$er_data = [];
foreach ($frag as $v) {
if($v['username']==''){
continue;
}
//验证数据完整性
if ($v['username'] == '' || $v['email'] == '' || $v['realname'] == '' || $v['major'] == '' || $v['username'] == null || $v['email'] == null || $v['realname'] == null || $v['major'] == null) {
$er_data[] = [
'username' => trim($v['username']),
'realname' => trim($v['realname']),
'email' => $v['email'],
'reason' => 'Missing data'
];
continue;
}
//验证major
$major = self::get_major($v['major']);
if ($major === null) {
$er_data[] = [
'username' => trim($v['username']),
'realname' => trim($v['realname']),
'email' => $v['email'],
'reason' => 'major is error'
];
continue;
}
//验证是否存在此用户并且存在对应关系
$this_reviewer = self::get_username(trim($v['username']));
$mme = self::get_userByEmail(trim($v['email']));
if ($this_reviewer == null && $mme != null) {
$er_data[] = [
'username' => trim($v['username']),
'realname' => trim($v['realname']),
'email' => $v['email'],
'reason' => 'Email occupied,and username is:'.$mme['account']
];
continue;
}
if ($this_reviewer != null && $this_reviewer['type'] == 2) {
$er_data[] = [
'username' => $v['username'],
'realname' => $v['realname'],
'email' => $v['email'],
'reason' => "Editor can't become reviewer"
];
continue;
}
if ($this_reviewer != null && self::get_retojo($this_reviewer['user_id'], $journal) != null) {
$su_data[] = [
'username' => trim($v['username']),
'realname' => trim($v['realname']),
'email' => $v['email'],
'reason' => 'success(has register)'
];
continue;
}
//执行存储,按实际逻辑存储
$cache_id = 0;
if ($this_reviewer == null) {
//添加user主体基本信息
$cache_reviewer['account'] = trim($v['username']);
$cache_reviewer['password'] = md5('123456qwe');
$cache_reviewer['email'] = trim($v['email']);
$cache_reviewer['realname'] = trim($v['realname']);
$cache_reviewer['is_reviewer'] = 1;
$cache_reviewer['ctime'] = time();
$cache_id = $this->user_obj->insertGetId($cache_reviewer);
//添加reviewer_info信息
$cache_insert_info['reviewer_id'] = $cache_id;
$cache_insert_info['gender'] = $v['gender'] == '女' ? 2 : 1;
$cache_insert_info['technical'] = $v['technical'] == null ? '' : $v['technical'];
$cache_insert_info['country'] = $v['country'] == null ? '' : $v['country'];
$cache_insert_info['introduction'] = $v['introduction'] == null ? '' : $v['introduction'];
$cache_insert_info['company'] = $v['company'] == null ? '' : $v['company'];
$cache_insert_info['major'] = $major['major_id'];
$cache_insert_info['field'] = $v['field'] == null ? '' : $v['field'];
$this->user_reviewer_info_obj->insert($cache_insert_info);
} else if ($this_reviewer != null && $this_reviewer['is_reviewer'] == 0) {
$this->user_obj->where('user_id', $this_reviewer['user_id'])->update(['is_reviewer' => 1]);
//添加reviewer_info信息
$cache_insert_info['reviewer_id'] = $this_reviewer['user_id'];
$cache_insert_info['gender'] = $v['gender'] == '女' ? 2 : 1;
$cache_insert_info['technical'] = $v['technical'] == null ? '' : $v['technical'];
$cache_insert_info['country'] = $v['country'] == null ? '' : $v['country'];
$cache_insert_info['introduction'] = $v['introduction'] == null ? '' : $v['introduction'];
$cache_insert_info['company'] = $v['company'] == null ? '' : $v['company'];
$cache_insert_info['major'] = $major['major_id'];
$cache_insert_info['field'] = $v['field'] == null ? '' : $v['field'];
$this->user_reviewer_info_obj->insert($cache_insert_info);
}
//存储关系表信息
$cache_insert_rtj['reviewer_id'] = $this_reviewer == null ? $cache_id : $this_reviewer['user_id'];
$cache_insert_rtj['journal_id'] = $journal;
$cache_insert_rtj['account'] = trim($v['username']);
$cache_insert_rtj['journal_title'] = $journal_info['title'];
$cache_insert_rtj['ctime'] = time();
$this->reviewer_to_journal_obj->insert($cache_insert_rtj);
//增加成功信息
$su_data[] = [
'username' => trim($v['username']),
'realname' => trim($v['realname']),
'email' => $v['email'],
'reason' => 'success'
];
//发送邮件提醒审稿人
$content = "Thank you for registering as a " . $journal_info['title'] . " reviewer<br/>". "At present, you have passed our examination<br/>";
$content .= '<a href="https://submission.tmrjournals.com">SubmissionSystem</a><br>';
$content .= '<p>username:' . trim($v['username']) . '</p>';
$content .= '<p>Original Password: 123456qwe</p>';//$has_res ? '' : '<p>password:123456qwe</p>';
$maidata['email'] = $v['email'];
$maidata['title'] = $journal_info['title'];
$maidata['content'] = $content;
$maidata['tmail'] = $journal_info['email'];
$maidata['tpassword'] = $journal_info['epassword'];
Queue::push( 'app\api\job\mail@fire' , $maidata , "tmail" );
}
return json(['sudata' => $su_data, 'erdata' => $er_data]);
}
/** /**
* 获取领域分类 * 获取领域分类

View File

@@ -1478,7 +1478,7 @@ class Article extends Controller {
public function addRecommentReviewer($reivewe,$journal_id,$user_id,$article_id){ public function addRecommentReviewer($reivewe,$journal_id,$user_id,$article_id){
$journal_info = $this->journal_obj->where('journal_id',$journal_id)->find(); $journal_info = $this->journal_obj->where('journal_id',$journal_id)->find();
//判断此用户是否存在 //判断此用户是否存在
$reviewer_info = $this->user_obj->where('email', $reivewe['email'])->where('state', 0)->find(); $reviewer_info = $this->user_obj->where('email', trim($reivewe['email']))->where('state', 0)->find();
if ($reviewer_info == null) { //添加用户 if ($reviewer_info == null) { //添加用户
$insert_user['account'] = $reivewe['email']; $insert_user['account'] = $reivewe['email'];
$insert_user['password'] = md5('123456qwe'); $insert_user['password'] = md5('123456qwe');
@@ -1768,6 +1768,9 @@ class Article extends Controller {
->join('t_user_reviewer_info', 't_article_reviewer.reviewer_id = t_user_reviewer_info.reviewer_id', 'LEFT') ->join('t_user_reviewer_info', 't_article_reviewer.reviewer_id = t_user_reviewer_info.reviewer_id', 'LEFT')
->join('t_reviewer_major', 't_reviewer_major.major_id = t_user_reviewer_info.major', 'LEFT') ->join('t_reviewer_major', 't_reviewer_major.major_id = t_user_reviewer_info.major', 'LEFT')
->where($where)->limit($limit_start, $data['pageSize'])->select(); ->where($where)->limit($limit_start, $data['pageSize'])->select();
$count = $this->article_reviewer_obj->where($where)->count(); $count = $this->article_reviewer_obj->where($where)->count();
if ($res) { if ($res) {
return json(['code' => 0, 'data' => $res, 'totle' => $count]); return json(['code' => 0, 'data' => $res, 'totle' => $count]);

View File

@@ -50,47 +50,47 @@ class Inbox extends Controller{
$insertData=[]; $insertData=[];
foreach ($emailNums as $key=>$value){ // foreach ($emailNums as $key=>$value){
//2.1 获取邮件头部信息 // //2.1 获取邮件头部信息
$head = $server->getHeaders($value); // $head = $server->getHeaders($value);
//2.2 处理邮件附件 // //2.2 处理邮件附件
$files = $server->getAttach($value); // $files = $server->getAttach($value);
// 附件 // // 附件
$head['url'] =[]; // $head['url'] =[];
//2.3 处理正文中的图片 // //2.3 处理正文中的图片
$imageList=array(); // $imageList=array();
$section = 2; // $section = 2;
if($files){ // if($files){
foreach($files as $k => $file) // foreach($files as $k => $file)
{ // {
//type=1为附件,0为邮件内容图片 // //type=1为附件,0为邮件内容图片
if($file['type'] == 0) // if($file['type'] == 0)
{ // {
$imageList[$k]=$file['pathname']; // $imageList[$k]=$file['pathname'];
} // }
if($file['type'] == 1) // if($file['type'] == 1)
{ // {
array_push($head['url'],$file['url']); // array_push($head['url'],$file['url']);
} // }
if(($file['type'] == 0 || $file['type'] == 1) && !empty($file['url'])){ // if(($file['type'] == 0 || $file['type'] == 1) && !empty($file['url'])){
$section = 1.2 ; // $section = 1.2 ;
} // }
} // }
} // }
$webPath = ROOT_PATH.'public' . DS . 'contentImg' . DS . date('Ymd') .DS ; // $webPath = ROOT_PATH.'public' . DS . 'contentImg' . DS . date('Ymd') .DS ;
// 正文内容 // // 正文内容
$head['content'] = $server->getBody($value,$webPath,$imageList,$section); // $head['content'] = $server->getBody($value,$webPath,$imageList,$section);
array_push($insertData,$head); // array_push($insertData,$head);
} // }
$this->insertData($insertData,$journal); $this->insertData($insertData,$journal);
} }

View File

@@ -548,7 +548,7 @@ class Special extends Controller
$journal_info = $this->journal_obj->where('journal_id', $article_info['journal_id'])->find(); $journal_info = $this->journal_obj->where('journal_id', $article_info['journal_id'])->find();
Db::startTrans(); Db::startTrans();
//判断此用户是否存在 //判断此用户是否存在
$reviewer_info = $this->user_obj->where('email', $data['email'])->where('state', 0)->find(); $reviewer_info = $this->user_obj->where('email', trim($data['email']))->where('state', 0)->find();
if ($reviewer_info == null) { //添加用户 if ($reviewer_info == null) { //添加用户
$insert_user['account'] = $data['email']; $insert_user['account'] = $data['email'];
$insert_user['password'] = md5('123456qwe'); $insert_user['password'] = md5('123456qwe');

View File

@@ -11,7 +11,8 @@ use think\Validate;
* @title 公共管理相关 * @title 公共管理相关
* @description 公共管理相关 * @description 公共管理相关
*/ */
class Typeset extends Controller { class Typeset extends Controller
{
protected $article_obj = ''; protected $article_obj = '';
protected $user_obj = ''; protected $user_obj = '';
protected $user_act_obj = ''; protected $user_act_obj = '';
@@ -38,7 +39,8 @@ class Typeset extends Controller {
protected $ts_obj = ''; protected $ts_obj = '';
protected $ts_refer_obj = ''; protected $ts_refer_obj = '';
public function __construct(\think\Request $request = null) { public function __construct(\think\Request $request = null)
{
parent::__construct($request); parent::__construct($request);
$this->user_obj = Db::name('user'); $this->user_obj = Db::name('user');
$this->user_act_obj = Db::name('user_act'); $this->user_act_obj = Db::name('user_act');
@@ -67,8 +69,8 @@ class Typeset extends Controller {
$this->ts_refer_obj = Db::name('ts_refer'); $this->ts_refer_obj = Db::name('ts_refer');
} }
public function getTypeSet()
public function createTypeSet(){ {
$data = $this->request->post(); $data = $this->request->post();
// 验证规则 // 验证规则
$rule = new Validate([ $rule = new Validate([
@@ -78,6 +80,250 @@ class Typeset extends Controller {
return jsonError($rule->getError()); return jsonError($rule->getError());
} }
$article_info = $this->article_obj->where('article_id', $data['article_id'])->find(); $article_info = $this->article_obj->where('article_id', $data['article_id'])->find();
$ts_info = $this->ts_obj->where('article_id', $article_info['article_id'])->where('ts_state', 0)->find();
if (!$ts_info) {
return jsonError('get ts error');
}
$refers = $this->ts_refer_obj->where('ts_id', $ts_info['ts_id'])->where('refer_state', 0)->select();
$ts_info['references'] = $refers;
$re['ts'] = $ts_info;
return jsonSuccess($re);
}
/**
* 获取排版实例列表
*/
public function getTsList()
{
$data = $this->request->post();
// 验证规则
$rule = new Validate([
'editor_id' => 'require|number',
'journal_id' => 'require',
'ts_state' => 'require',
'pageIndex' => 'require',
'pageSize' => 'require'
]);
if (!$rule->check($data)) {
return jsonError($rule->getError());
}
$journals = [];
if ($data['journal_id'] == 0) { //获取全部编辑名下的期刊
$journals = $this->journal_obj->where('editor_id', $data['editor_id'])->where('state', 0)->column('journal_id');
} else {
$journals[] = $data['journal_id'];
}
$limit_start = ($data['pageIndex'] - 1) * $data['pageSize'];
$ts_list = $this->ts_obj->join('t_article', 't_article.article_id = t_ts.article_id', 'left')
->where('t_ts.ts_state', $data['ts_state'])
->where('t_article.journal_id', 'in', $journals)
->limit($limit_start, $data['pageSize'])
->select();
$count = $this->ts_obj->join('t_article', 't_article.article_id = t_ts.article_id', 'left')->where('t_ts.ts_state', $data['ts_state'])->where('t_article.journal_id', 'in', $journals)->count();
$re['ts_list'] = $ts_list;
$re['count'] = $count;
return jsonSuccess($re);
}
/**
* 编辑参考文献
*/
public function editRefer()
{
$data = $this->request->post();
// 验证规则
$rule = new Validate([
'ts_refer_id' => 'require|number',
'refer_content' => 'require'
]);
if (!$rule->check($data)) {
return jsonError($rule->getError());
}
$update['refer_content'] = $data['refer_content'];
if (isset($data['refer_doi']) && $data['refer_doi'] != '') {
$update['refer_doi'] = $data['refer_doi'];
}
if (isset($data['refer_frag']) && $data['refer_frag'] != '') {
$update['refer_frag'] = $data['refer_frag'];
}
$this->ts_refer_obj->where('ts_refer_id', $data['ts_refer_id'])->update($update);
return jsonSuccess([]);
}
/**
* 删除参考文献
*/
public function delRefer()
{
$data = $this->request->post();
// 验证规则
$rule = new Validate([
'ts_refer_id' => 'require|number'
]);
if (!$rule->check($data)) {
return jsonError($rule->getError());
}
$this->ts_refer_obj->where('ts_refer_id', $data['ts_refer_id'])->update(['refer_state' => 1]);
return jsonSuccess([]);
}
/**
* 参考文献识别doi
*/
public function referToDoi()
{
$data = $this->request->post();
// 验证规则
$rule = new Validate([
'article_id' => 'require|number'
]);
if (!$rule->check($data)) {
return jsonError($rule->getError());
}
$ts_info = $this->ts_obj->where('article_id', $data['article_id'])->find();
$refers = $this->ts_refer_obj->where('ts_id', $ts_info['ts_id'])->where('refer_state', 0)->select();
foreach ($refers as $v) { //处理doi
if (strpos($v['refer_content'], 'doi:') == false && strpos($v['refer_content'], 'doi.org/') == false) {
continue;
}
$doi = '';
if (strpos($v['refer_content'], 'doi.org/') != false) {
$cache_arr = explode(' ', trim(substr($v['refer_content'], strpos($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'], strpos($v['refer_content'], 'doi:') + 4)));
if (substr($cache_arr[0], -1) == '.') {
$doi = substr($cache_arr[0], 0, -1);
} else {
$doi = $cache_arr[0];
}
}
$this->ts_refer_obj->where('ts_refer_id', $v['ts_refer_id'])->update(['refer_doi' => $doi]);
}
return jsonSuccess([]);
}
/**
* doi获取格式化的参考文献信息
*/
public function doiTofrag()
{
$data = $this->request->post();
// 验证规则
$rule = new Validate([
'article_id' => 'require|number'
]);
if (!$rule->check($data)) {
return jsonError($rule->getError());
}
$ts_info = $this->ts_obj->where('article_id', $data['article_id'])->find();
$refers = $this->ts_refer_obj->where('ts_id', $ts_info['ts_id'])->where('refer_state', 0)->select();
//清空frag百分比用
$this->ts_refer_obj->where('ts_id', $ts_info['ts_id'])->where('refer_doi', '<>', '')->update(['refer_frag' => '']);
foreach ($refers as $v) {
Queue::push('app\api\job\ts@fire', $v, 'ts');
}
return jsonSuccess([]);
}
public function getFragBF()
{
$data = $this->request->post();
// 验证规则
$rule = new Validate([
'article_id' => 'require|number'
]);
if (!$rule->check($data)) {
return jsonError($rule->getError());
}
$ts_info = $this->ts_obj->where('article_id', $data['article_id'])->find();
$list = $this->ts_refer_obj->where('ts_id', $ts_info['ts_id'])->where('refer_doi', '<>', '')->where('refer_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);
}
public function testdd()
{
$refer = $this->ts_refer_obj->where('ts_refer_id', 410)->find();
my_doiToFrag($refer);
// $d = '10.1152/ajpendo.00039.2012';
// $doi = str_replace('/','%2F',$d);
// $url = "https://citation.crosscite.org/format?doi=$doi&style=american-veterinary-medical-association&lang=en-US";
// $res = myGet($url);
// $frag = trim(substr($res,strpos($res,'.')+1));
// echo $frag;
}
/**
* 排版主方法入口
*/
public function doTypeSetting()
{
$data = $this->request->post();
// 验证规则
$rule = new Validate([
'article_id' => 'require|number'
]);
if (!$rule->check($data)) {
return jsonError($rule->getError());
}
$article_info = $this->article_obj->where('article_id', $data['article_id'])->find();
$journal_info = $this->journal_obj->where('journal_id', $article_info['journal_id'])->find();
$editor_info = $this->user_obj->where('user_id', $journal_info['editor_id'])->find();
$ts_info = $this->ts_obj->where('article_id', $data['article_id'])->find();
$typesetInfo = [];
$typesetInfo['info_title'] = $ts_info['ts_title'];
$typesetInfo['info_type'] = $ts_info['ts_type'];
$typesetInfo['doi'] = $ts_info['ts_doi'];
$typesetInfo['topic'] = $ts_info['ts_topic'];
$typesetInfo['mainText'] = $ts_info['ts_main'];
$typesetInfo['author'] = $ts_info['author'];
$typesetInfo['authorAddress'] = $ts_info['author_address'];
$typesetInfo['authorContribution'] = $ts_info['author_contribution'];
$typesetInfo['authorCorresponding'] = $ts_info['corresponding_author'];
$typesetInfo['authorCorrespondingEmail'] = $ts_info['corresponding_author_email'];
$typesetInfo['traditon'] = $ts_info['trdition'];
$typesetInfo['journal'] = $journal_info['title'];
$typesetInfo['jabbr'] = $journal_info['jabbr'];
$typesetInfo['stage'] = $ts_info['stage'];
$typesetInfo['little_author'] = $ts_info['little_author'];
$typesetInfo['website'] = $journal_info['website'];
$typesetInfo['acknowledgment'] = $ts_info['acknowledgment'];
$typesetInfo['received_date'] = $ts_info['received_date'];
$typesetInfo['accepted_date'] = $ts_info['accepted_date'];
$typesetInfo['online_date'] = $ts_info['online_date'];
$typesetInfo['abbreviation'] = $ts_info['abbreviation'];
$typesetInfo['abstractText'] = $ts_info['ts_abstract'];
$typesetInfo['keywords'] = $ts_info['keywords'];
$typesetInfo['userAccount'] = $editor_info['nickname'];
//获取文件
$files = $this->article_file_obj $files = $this->article_file_obj
->where('article_id', $article_info['article_id']) ->where('article_id', $article_info['article_id'])
->where('type_name', 'manuscirpt') ->where('type_name', 'manuscirpt')
@@ -87,10 +333,119 @@ class Typeset extends Controller {
if (count($files) == 0) { if (count($files) == 0) {
return jsonError('No Manuscript'); return jsonError('No Manuscript');
} }
$typesetInfo['filename'] = "http://api.tmrjournals.com/public/" . $files[0]['file_url'];
$rs = $this->ts_refer_obj->where('ts_id', $ts_info['ts_id'])->where('refer_state', 0)->select();
$refers = [];
foreach ($rs as $v) {
$refers[] = $v['refer_frag'];
}
$typesetInfo['refers'] = json_encode($refers);
$url = "http://localhost:8081/typeset/webGetDocx";
// $url = "http://192.168.110.100:8080/typeset/webGetDocx";
// $url = "http://ts.tmrjournals.com/api/typeset/webGetDocx";
$res = object_to_array(json_decode(myPost1($url, $typesetInfo)));
var_dump($res);die;
$file_res = $res['data']['file'];
$this->ts_obj->where('ts_id', $ts_info['ts_id'])->update(['ts_url' => $file_res]);
return jsonSuccess([]);
}
/**
* 编辑排版实例
*/
public function editTypeSet()
{
$data = $this->request->post();
// 验证规则
$rule = new Validate([
'article_id' => 'require|number',
'ts_title' => 'require',
'ts_type' => 'require',
'author' => 'require',
'author_address' => 'require',
'author_contribution' => 'require',
'corresponding_author' => 'require',
'corresponding_author_email' => 'require',
'accepted_date' => 'require',
'received_date' => 'require',
'keywords' => 'require',
'stage' => 'require',
'little_author' => 'require',
'online_date' => 'require',
'ts_abstract' => 'require',
'acknowledgment' => 'require',
'abbreviation' => 'require',
'ts_doi' => 'require',
'trdition' => 'require',
'ts_topic' => 'require',
]);
if (!$rule->check($data)) {
return jsonError($rule->getError());
}
$insert_ts['ts_title'] = $data['ts_title'];
$insert_ts['ts_type'] = $data['ts_type'];
$insert_ts['author'] = $data['author'];
$insert_ts['author_address'] = $data['author_address'];
$insert_ts['author_contribution'] = $data['author_contribution'];
//获取通讯作者信息
$insert_ts['corresponding_author'] = $data['corresponding_author'];
$insert_ts['corresponding_author_email'] = $data['corresponding_author_email'];
$insert_ts['accepted_date'] = $data['accepted_date'];
$insert_ts['received_date'] = $data['received_date'];
$insert_ts['keywords'] = $data['keywords'];
$insert_ts['stage'] = $data['stage'];
$insert_ts['little_author'] = $data['little_author'];
$insert_ts['online_date'] = $data['online_date'];
$insert_ts['ts_abstract'] = $data['ts_abstract'];
$insert_ts['acknowledgment'] = $data['acknowledgment'];
$insert_ts['abbreviation'] = $data['abbreviation'];
$insert_ts['ts_doi'] = $data['ts_doi'];
$insert_ts['trdition'] = $data['trdition'];
$insert_ts['ts_topic'] = $data['ts_topic'];
$this->ts_obj->where('article_id', $data['article_id'])->update($insert_ts);
return jsonSuccess([]);
}
/**
* 创建排版实例
*/
public function createTypeSet()
{
$data = $this->request->post();
// 验证规则
$rule = new Validate([
'article_id' => 'require|number'
]);
if (!$rule->check($data)) {
return jsonError($rule->getError());
}
$article_info = $this->article_obj->where('article_id', $data['article_id'])->find();
//存在实例不可重复创建
$check_ts = $this->ts_obj->where('article_id', $data['article_id'])->find();
if ($check_ts) {
return jsonError("has created");
}
$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');
}
//调用接口分解word, //调用接口分解word,
$url = "http://localhost:8080/typeset/webReaddoc"; // $url = "http://localhost:8080/typeset/webReaddoc";
$url = "http://ts.tmrjournals.com/api/typeset/webReaddoc";
$program['fileRoute'] = "https://submission.tmrjournals.com/public/" . $files[0]['file_url']; $program['fileRoute'] = "https://submission.tmrjournals.com/public/" . $files[0]['file_url'];
$res = object_to_array(json_decode(myPost($url, $program))); $res = object_to_array(json_decode(myPost($url, $program)));
$file_runs = $res['data']; $file_runs = $res['data'];
//整理信息 //整理信息
$frag = []; $frag = [];
@@ -99,6 +454,11 @@ class Typeset extends Controller {
$start_refer = false; $start_refer = false;
foreach ($file_runs as $k => $v) { foreach ($file_runs as $k => $v) {
if ($start_refer && $v != '') { if ($start_refer && $v != '') {
if (strlen($v) > 500) {
$start_refer = false;
$frag['main'][] = $v;
continue;
}
$frag['references'][] = $v; $frag['references'][] = $v;
continue; continue;
} }
@@ -124,7 +484,7 @@ class Typeset extends Controller {
if (isset($frag['abstract']) && $frag['abstract'] == $v) { if (isset($frag['abstract']) && $frag['abstract'] == $v) {
continue; continue;
} }
if(strtolower($g_val) == 'references'||strtolower($g_val)=='reference'){ if (strtolower($g_val) == 'reference:' || strtolower($g_val) == 'references:' || strtolower($g_val) == 'references' || strtolower($g_val) == 'reference') {
$start_refer = true; $start_refer = true;
continue; continue;
} }
@@ -148,22 +508,35 @@ class Typeset extends Controller {
$insert_ts['received_date'] = date("d F Y", $article_info['ctime']); $insert_ts['received_date'] = date("d F Y", $article_info['ctime']);
$insert_ts['keywords'] = 'Keywords:' . $article_info['keywords']; $insert_ts['keywords'] = 'Keywords:' . $article_info['keywords'];
$insert_ts['ts_abstract'] = isset($frag['abstract']) ? $frag['abstract'] : ''; $insert_ts['ts_abstract'] = isset($frag['abstract']) ? $frag['abstract'] : '';
$insert_ts['ts_main'] = json_encode($frag['main']); $insert_ts['ts_main'] = isset($frag['main']) ? json_encode($frag['main']) : '';
$insert_ts['ts_ctime'] = time(); $insert_ts['ts_ctime'] = time();
var_dump($insert_ts);
Db::startTrans(); //开启事务 Db::startTrans(); //开启事务
$ts_id = $this->ts_obj->insertGetId($insert_ts); $ts_id = $this->ts_obj->insertGetId($insert_ts);
$res_refer = true;
//开始处理引用
if (isset($frag['references']) && is_array($frag['references'])) {
$insert_all = [];
foreach ($frag['references'] as $k => $v) {
$cache_insert['ts_id'] = $ts_id;
$cache_insert['refer_content'] = trim($v);
$cache_insert['refer_ctime'] = time();
$insert_all[] = $cache_insert;
}
$res_refer = $this->ts_refer_obj->insertAll($insert_all);
}
if ($ts_id && $res_refer) {
Db::commit();
return jsonSuccess([]);
} else {
Db::rollback();
return jsonError('system error');
}
} }
private function authorFormate($article_id){ private function authorFormate($article_id)
{
$authors = $this->article_author_obj->where('article_id', $article_id)->where('state', 0)->select(); $authors = $this->article_author_obj->where('article_id', $article_id)->where('state', 0)->select();
//组装地址数组 //组装地址数组
$address = []; $address = [];
@@ -198,11 +571,10 @@ class Typeset extends Controller {
//组装address //组装address
$address_str = ''; $address_str = '';
foreach ($address as $k => $v) { foreach ($address as $k => $v) {
$address_str .= ($k+1).' '.$v.';'; $address_str .= ($k + 1) . ' ' . $v . ';%$%';
} }
$frag['author'] = $author; $frag['author'] = $author;
$frag['address'] = $address_str; $frag['address'] = $address_str;
return $frag; return $frag;
} }
} }

View File

@@ -245,7 +245,7 @@ class User extends Controller
$check = $this->user_obj $check = $this->user_obj
->where('state', 0) ->where('state', 0)
->where('account = "'.$data['account'].'" or email = "'.$data['email'].'"') ->where('account = "' . trim($data['account']) . '" or email = "' . trim($data['email']) . '"')
->find(); ->find();
if ($check) { if ($check) {
return jsonError('用户已经存在'); return jsonError('用户已经存在');
@@ -263,7 +263,8 @@ class User extends Controller
/** /**
* 获取所有编辑 * 获取所有编辑
*/ */
public function getAllEditor(){ public function getAllEditor()
{
$editors = $this->user_obj->where('type', 2)->where('state', 0)->select(); $editors = $this->user_obj->where('type', 2)->where('state', 0)->select();
//获取编辑管理的期刊 //获取编辑管理的期刊
foreach ($editors as $k => $v) { foreach ($editors as $k => $v) {
@@ -277,7 +278,8 @@ class User extends Controller
/** /**
* 修改编辑密码 * 修改编辑密码
*/ */
public function changeEditorPassword(){ public function changeEditorPassword()
{
$data = $this->request->post(); $data = $this->request->post();
// 验证规则 // 验证规则
$rule = new Validate([ $rule = new Validate([
@@ -370,7 +372,8 @@ class User extends Controller
/** /**
* 获取用户详细信息 * 获取用户详细信息
*/ */
public function getUserDetail(){ public function getUserDetail()
{
$data = $this->request->post(); $data = $this->request->post();
$rule = new Validate([ $rule = new Validate([
'user_id' => 'require' 'user_id' => 'require'
@@ -398,7 +401,8 @@ class User extends Controller
/** /**
* 获取用户所有客座专刊 * 获取用户所有客座专刊
*/ */
public function getUserAllSpecials(){ public function getUserAllSpecials()
{
$data = $this->request->post(); $data = $this->request->post();
$rule = new Validate([ $rule = new Validate([
'user_id' => 'require' 'user_id' => 'require'
@@ -419,7 +423,8 @@ class User extends Controller
} }
public function getSpecialDetailById($special_id){ public function getSpecialDetailById($special_id)
{
$base_url = Env::get('journal.base_url'); $base_url = Env::get('journal.base_url');
$api_url = $base_url . "/master/special/getSpecialDetailById"; $api_url = $base_url . "/master/special/getSpecialDetailById";
$res = object_to_array(json_decode(myPost($api_url, ['journal_special_id' => $special_id]))); $res = object_to_array(json_decode(myPost($api_url, ['journal_special_id' => $special_id])));
@@ -431,7 +436,8 @@ class User extends Controller
/** /**
* 添加用户身份 * 添加用户身份
*/ */
public function addUserRole(){ public function addUserRole()
{
$data = $this->request->post(); $data = $this->request->post();
$rule = new Validate([ $rule = new Validate([
'user_id' => 'require', 'user_id' => 'require',
@@ -455,7 +461,6 @@ class User extends Controller
$this->user_to_special_obj->insert($insert_uts); $this->user_to_special_obj->insert($insert_uts);
return jsonSuccess([]); return jsonSuccess([]);
} }
} }
@@ -994,8 +999,12 @@ class User extends Controller
return jsonError("has reviewer"); return jsonError("has reviewer");
} }
$info_check = $this->user_reviewer_info_obj->where('reviewer_id', $user_info['user_id'])->find();
Db::startTrans(); Db::startTrans();
$res = true;
if ($info_check==null) {
$insert_info['reviewer_id'] = $user_info['user_id']; $insert_info['reviewer_id'] = $user_info['user_id'];
$insert_info['gender'] = $data['gender']; $insert_info['gender'] = $data['gender'];
$insert_info['technical'] = $data['author_title']; $insert_info['technical'] = $data['author_title'];
@@ -1006,7 +1015,7 @@ class User extends Controller
$insert_info['field'] = $data['field']; $insert_info['field'] = $data['field'];
$insert_info['qualifications'] = $data['qualifications']; $insert_info['qualifications'] = $data['qualifications'];
$res = $this->user_reviewer_info_obj->insertGetId($insert_info); $res = $this->user_reviewer_info_obj->insertGetId($insert_info);
}
$insert_to['reviewer_id'] = $user_info['user_id']; $insert_to['reviewer_id'] = $user_info['user_id'];
$insert_to['journal_id'] = $rfa_info['journal_id']; $insert_to['journal_id'] = $rfa_info['journal_id'];
$insert_to['account'] = $user_info['account']; $insert_to['account'] = $user_info['account'];

View File

@@ -0,0 +1,35 @@
<?php
namespace app\api\job;
use think\queue\Job;
use think\Db;
class ts {
//put your code here
public function fire(Job $job, $data) {
$job->delete();
my_doiToFrag($data);
}
// public function doFrag($data){
// $ts_refer_obj = Db::name('ts_refer');
// if($data['refer_doi']==''){
// return 0;
// }
// $doi = str_replace('/','%2F',$data['refer_doi']);
// $url = "https://citation.crosscite.org/format?doi=$doi&style=american-veterinary-medical-association&lang=en-US";
// $res = myGet($url);
// $frag = trim(substr($res,strpos($res,'.')+1));
// file_put_contents("D:/1.txt",$frag);
// file_put_contents("D:/2.txt",$ts_refer_obj);
// // $ts_refer_obj->where('ts_refer_id',$data['ts_refer_id'])->update(['refer_frag'=>$frag]);
// return 1;
// }
}

View File

@@ -207,6 +207,44 @@ function search_array_val($arr,$val){
} }
} }
/**
* GET 请求
* @param string $url
*/
function myGet($url){
$oCurl = curl_init();
if(stripos($url,"https://")!==FALSE){
curl_setopt($oCurl, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($oCurl, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($oCurl, CURLOPT_SSLVERSION, 1); //CURL_SSLVERSION_TLSv1
}
curl_setopt($oCurl, CURLOPT_URL, $url);//目标URL
curl_setopt($oCurl, CURLOPT_RETURNTRANSFER, 1 );//设定是否显示头信息,1为显示
curl_setopt($oCurl, CURLOPT_BINARYTRANSFER, true) ;//在启用CURLOPT_RETURNTRANSFER时候将获取数据返回
$sContent = curl_exec($oCurl);
$aStatus = curl_getinfo($oCurl);//获取页面各种信息
curl_close($oCurl);
if(intval($aStatus["http_code"])==200){
return $sContent;
}else{
return false;
}
}
function my_doiToFrag($data){
$ts_refer_obj = Db::name('ts_refer');
if($data['refer_doi']==''){
return 0;
}
$doi = str_replace('/','%2F',$data['refer_doi']);
$url = "https://citation.crosscite.org/format?doi=$doi&style=american-veterinary-medical-association&lang=en-US";
$res = myGet($url);
$frag = trim(substr($res,strpos($res,'.')+1));
$frag1 = $frag==""?"none":$frag;
$ts_refer_obj->where('ts_refer_id',$data['ts_refer_id'])->update(['refer_frag'=>$frag1]);
}
/** /**
* 增加usermsg * 增加usermsg
*/ */
@@ -247,6 +285,10 @@ function choiseJabbr($article_id, $jabbr) {
return $jabbr; return $jabbr;
} }
function myPost($url, $param = array()) { function myPost($url, $param = array()) {
if (!is_array($param)) { if (!is_array($param)) {
@@ -276,3 +318,37 @@ function myPost($url, $param = array()) {
return $rst; return $rst;
} }
function myPost1($url, $param = array()) {
if (!is_array($param)) {
throw new Exception("参数必须为array");
}
$data = json_encode($param);
$httph = curl_init($url);
curl_setopt($httph, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
));
// curl_setopt($httph, CURLOPT_SSL_VERIFYPEER, 0);
// curl_setopt($httph, CURLOPT_SSL_VERIFYHOST, 1);
curl_setopt($httph, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($httph, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)");
curl_setopt($httph, CURLOPT_POST, 1); //设置为POST方式
curl_setopt($httph, CURLOPT_POSTFIELDS, $data);
// curl_setopt($httph, CURLOPT_RETURNTRANSFER,0);
// curl_setopt($httph, CURLOPT_HEADER,1);
$rst = curl_exec($httph);
curl_close($httph);
return $rst;
}