This commit is contained in:
wangjinlei
2023-07-06 09:12:42 +08:00
parent 66c02137b4
commit b989916102
3 changed files with 190 additions and 102 deletions

View File

@@ -198,9 +198,9 @@ class Article extends Base
$update_data['state'] = 5; $update_data['state'] = 5;
$update_data['rtime'] = time();
$update_data['editor_act'] = 1; $update_data['editor_act'] = 1;
$this->article_obj->where("article_id",$data['article_id'])->update($update_data); $this->article_obj->where("article_id",$data['article_id'])->update($update_data);
//拒稿或者录用 - 发送审稿意见 //拒稿或者录用 - 发送审稿意见
$this->sendEmailToReviewer($data['article_id'], 5); $this->sendEmailToReviewer($data['article_id'], 5);

View File

@@ -20,19 +20,20 @@ class Preaccept extends Base
* @throws \think\db\exception\ModelNotFoundException * @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException * @throws \think\exception\DbException
*/ */
public function getArticleReferences(){ public function getArticleReferences()
{
$data = $this->request->post(); $data = $this->request->post();
$rule = new Validate([ $rule = new Validate([
"article_id"=>"require" "article_id" => "require"
]); ]);
if(!$rule->check($data)){ if (!$rule->check($data)) {
return jsonError($rule->getError()); return jsonError($rule->getError());
} }
$production_info = $this->production_article_obj->where('article_id',$data['article_id'])->find(); $production_info = $this->production_article_obj->where('article_id', $data['article_id'])->find();
if($production_info==null){ if ($production_info == null) {
return jsonError("Object is null"); return jsonError("Object is null");
} }
$list = $this->production_article_refer_obj->where("p_article_id",$production_info['p_article_id'])->where('state',0)->order("index")->select(); $list = $this->production_article_refer_obj->where("p_article_id", $production_info['p_article_id'])->where('state', 0)->order("index")->select();
$re["refers"] = $list; $re["refers"] = $list;
return jsonSuccess($re); return jsonSuccess($re);
@@ -46,16 +47,17 @@ class Preaccept extends Base
* @throws \think\exception\DbException * @throws \think\exception\DbException
* @throws \think\exception\PDOException * @throws \think\exception\PDOException
*/ */
public function discardRefers(){ public function discardRefers()
{
$data = $this->request->post(); $data = $this->request->post();
$rule = new Validate([ $rule = new Validate([
"article_id"=>"require" "article_id" => "require"
]); ]);
if(!$rule->check($data)){ if (!$rule->check($data)) {
return jsonError($rule->getError()); return jsonError($rule->getError());
} }
$production_info = $this->production_article_obj->where('article_id',$data['article_id'])->find(); $production_info = $this->production_article_obj->where('article_id', $data['article_id'])->find();
$this->production_article_refer_obj->where('p_article_id',$production_info['p_article_id'])->update(['state'=>1]); $this->production_article_refer_obj->where('p_article_id', $production_info['p_article_id'])->update(['state' => 1]);
return jsonSuccess([]); return jsonSuccess([]);
} }
@@ -66,56 +68,83 @@ class Preaccept extends Base
* @throws \think\db\exception\ModelNotFoundException * @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException * @throws \think\exception\DbException
*/ */
public function addRefer(){ public function addRefer()
{
$data = $this->request->post(); $data = $this->request->post();
$rule = new Validate([ $rule = new Validate([
"article_id"=>"require", "article_id" => "require",
"pre_p_refer_id"=>"require", "pre_p_refer_id" => "require",
"doi"=>"require" "refer_type"=>"require"
]); ]);
if(!$rule->check($data)){ if (!$rule->check($data)) {
return jsonError($rule->getError()); return jsonError($rule->getError());
} }
$p_info = $this->production_article_obj->where('article_id',$data['article_id'])->where('state',0)->find(); $p_info = $this->production_article_obj->where('article_id', $data['article_id'])->where('state', 0)->find();
$pre_refer = $this->production_article_refer_obj->where('p_refer_id',$data['pre_p_refer_id'])->find(); $pre_refer = $this->production_article_refer_obj->where('p_refer_id', $data['pre_p_refer_id'])->find();
$insert['p_article_id'] = $p_info['p_article_id']; $insert['p_article_id'] = $p_info['p_article_id'];
$insert['refer_doi'] = $data['doi']; $insert['index'] = $pre_refer['index'] + 1;
$insert['index'] = $pre_refer['index']+1;
$insert['ctime'] = time(); $insert['ctime'] = time();
$adId = $this->production_article_refer_obj->insertGetId($insert); $insert['refer_type'] = $data['refer_type'];
my_doiToFrag2($this->production_article_refer_obj->where('p_refer_id',$adId)->find()); if($data['refer_type']=="journal"){
//判断是否合法 $insert['refer_doi'] = isset($data['doi'])?$data['doi']:'';
$check = $this->production_article_refer_obj->where('p_refer_id',$adId)->find(); $insert['author'] = trim($data['author']);
if($check['author']){//合法 $insert['title'] = trim($data['title']);
$this->production_article_refer_obj->where('p_article_id',$p_info['p_article_id'])->where("p_refer_id","<>",$adId)->where("index",">",$pre_refer['index'])->where('state',0)->setInc('index'); $insert['joura'] = trim($data['joura']);
return jsonSuccess([]); $insert['dateno'] = $data['dateno'];
}else{//非法 $insert['doilink'] = $data['doilink'];
$this->production_article_refer_obj->where('p_refer_id',$adId)->update(['state'=>1]); $insert['cs'] = 1;
return jsonError("Doi error"); $insert['is_ja'] = 1;
}elseif($data['refer_type']=="book"){
$insert['author'] = trim($data['author']);
$insert['title'] = trim($data['title']);
$insert['dateno'] = $data['dateno'];
$insert['isbn'] = $data['isbn'];
$insert['cs'] = 1;
$insert['is_ja'] = 1;
}else{
$insert['cs'] = 0;
$insert['refer_frag'] = trim($data['content']);
} }
$adId= $this->production_article_refer_obj->insertGetId($insert);
$this->production_article_refer_obj->where('p_article_id', $p_info['p_article_id'])->where("p_refer_id", "<>", $adId)->where("index", ">", $pre_refer['index'])->where('state', 0)->setInc('index');
return jsonSuccess([]);
// $adId = $this->production_article_refer_obj->insertGetId($insert);
// my_doiToFrag2($this->production_article_refer_obj->where('p_refer_id', $adId)->find());
// //判断是否合法
// $check = $this->production_article_refer_obj->where('p_refer_id', $adId)->find();
// if ($check['author']) {//合法
// $this->production_article_refer_obj->where('p_article_id', $p_info['p_article_id'])->where("p_refer_id", "<>", $adId)->where("index", ">", $pre_refer['index'])->where('state', 0)->setInc('index');
// return jsonSuccess([]);
// } else {//非法
// $this->production_article_refer_obj->where('p_refer_id', $adId)->update(['state' => 1]);
// return jsonError("Doi error");
// }
} }
/**非doi形式添加refer节点 /**非doi形式添加refer节点
* @return void * @return void
*/ */
public function addReferNotdoi(){ public function addReferNotdoi()
{
$data = $this->request->post(); $data = $this->request->post();
$rule = new Validate([ $rule = new Validate([
"article_id"=>"require", "article_id" => "require",
"pre_p_refer_id"=>"require", "pre_p_refer_id" => "require",
"author"=>"require", "author" => "require",
"title"=>"require", "title" => "require",
"joura"=>"require", "joura" => "require",
"dateno"=>"require", "dateno" => "require",
"doilink"=>"require" "doilink" => "require"
]); ]);
if(!$rule->check($data)){ if (!$rule->check($data)) {
return jsonError($rule->getError()); return jsonError($rule->getError());
} }
$p_info = $this->production_article_obj->where('article_id',$data['article_id'])->where('state',0)->find(); $p_info = $this->production_article_obj->where('article_id', $data['article_id'])->where('state', 0)->find();
$pre_refer = $this->production_article_refer_obj->where('p_refer_id',$data['pre_p_refer_id'])->find(); $pre_refer = $this->production_article_refer_obj->where('p_refer_id', $data['pre_p_refer_id'])->find();
$insert['p_article_id'] = $p_info['p_article_id']; $insert['p_article_id'] = $p_info['p_article_id'];
$insert['index'] = $pre_refer['index']+1; $insert['index'] = $pre_refer['index'] + 1;
$insert['author'] = trim($data['author']); $insert['author'] = trim($data['author']);
$insert['title'] = trim($data['title']); $insert['title'] = trim($data['title']);
$insert['joura'] = trim($data['joura']); $insert['joura'] = trim($data['joura']);
@@ -125,21 +154,22 @@ class Preaccept extends Base
$insert['is_web'] = 1; $insert['is_web'] = 1;
$insert['cs'] = 1; $insert['cs'] = 1;
$adId = $this->production_article_refer_obj->insertGetId($insert); $adId = $this->production_article_refer_obj->insertGetId($insert);
$this->production_article_refer_obj->where('p_article_id',$p_info['p_article_id'])->where("p_refer_id","<>",$adId)->where("index",">",$pre_refer['index'])->where('state',0)->setInc('index'); $this->production_article_refer_obj->where('p_article_id', $p_info['p_article_id'])->where("p_refer_id", "<>", $adId)->where("index", ">", $pre_refer['index'])->where('state', 0)->setInc('index');
return jsonSuccess([]); return jsonSuccess([]);
} }
public function editReferNotdoi(){ public function editReferNotdoi()
{
$data = $this->request->post(); $data = $this->request->post();
$rule = new Validate([ $rule = new Validate([
"p_refer_id"=>"require", "p_refer_id" => "require",
"author"=>"require", "author" => "require",
"title"=>"require", "title" => "require",
"joura"=>"require", "joura" => "require",
"dateno"=>"require", "dateno" => "require",
"doilink"=>"require" "doilink" => "require"
]); ]);
if(!$rule->check($data)){ if (!$rule->check($data)) {
return jsonError($rule->getError()); return jsonError($rule->getError());
} }
$update['author'] = trim($data['author']); $update['author'] = trim($data['author']);
@@ -148,7 +178,7 @@ class Preaccept extends Base
$update['dateno'] = trim($data['dateno']); $update['dateno'] = trim($data['dateno']);
$update['doilink'] = trim($data['doilink']); $update['doilink'] = trim($data['doilink']);
$update['refer_doi'] = trim($data['doilink']); $update['refer_doi'] = trim($data['doilink']);
$this->production_article_refer_obj->where('p_refer_id',$data['p_refer_id'])->update($update); $this->production_article_refer_obj->where('p_refer_id', $data['p_refer_id'])->update($update);
return jsonSuccess([]); return jsonSuccess([]);
} }
@@ -165,17 +195,18 @@ class Preaccept extends Base
* @throws \think\exception\DbException * @throws \think\exception\DbException
* @throws \think\exception\PDOException * @throws \think\exception\PDOException
*/ */
public function delRefer(){ public function delRefer()
{
$data = $this->request->post(); $data = $this->request->post();
$rule = new Validate([ $rule = new Validate([
"p_refer_id"=>"require" "p_refer_id" => "require"
]); ]);
if(!$rule->check($data)){ if (!$rule->check($data)) {
return jsonError($rule->getError()); return jsonError($rule->getError());
} }
$refer_info = $this->production_article_refer_obj->where('p_refer_id',$data['p_refer_id'])->find(); $refer_info = $this->production_article_refer_obj->where('p_refer_id', $data['p_refer_id'])->find();
$this->production_article_refer_obj->where('p_article_id',$refer_info['p_article_id'])->where('index',">",$refer_info['index'])->where('state',0)->setDec('index'); $this->production_article_refer_obj->where('p_article_id', $refer_info['p_article_id'])->where('index', ">", $refer_info['index'])->where('state', 0)->setDec('index');
$this->production_article_refer_obj->where('p_refer_id',$data['p_refer_id'])->update(['state'=>1]); $this->production_article_refer_obj->where('p_refer_id', $data['p_refer_id'])->update(['state' => 1]);
return jsonSuccess([]); return jsonSuccess([]);
} }
@@ -187,25 +218,81 @@ class Preaccept extends Base
* @throws \think\exception\DbException * @throws \think\exception\DbException
* @throws \think\exception\PDOException * @throws \think\exception\PDOException
*/ */
public function editRefer(){ public function editRefer()
{
$data = $this->request->post(); $data = $this->request->post();
$rule = new Validate([ $rule = new Validate([
"p_refer_id"=>"require", "p_refer_id" => "require",
"doi"=>"require" "refer_type" => "require"
]); ]);
if(!$rule->check($data)){ if (!$rule->check($data)) {
return jsonError($rule->getError()); return jsonError($rule->getError());
} }
$doi = trim($data['doi']); $old_refer_info = $this->production_article_refer_obj->where('p_refer_id',$data['p_refer_id'])->find();
$updata['refer_type'] = $data['refer_type'];
if($data['refer_type']=="journal"){
$updata['refer_doi'] = isset($data['doi'])?$data['doi']:'';
$updata['author'] = trim($data['author']);
$updata['title'] = trim($data['title']);
$updata['joura'] = trim($data['joura']);
$updata['dateno'] = $data['dateno'];
$updata['doilink'] = $data['doilink'];
$updata['cs'] = 1;
$updata['is_ja'] = 1;
}elseif($data['refer_type']=="book"){
$updata['author'] = trim($data['author']);
$updata['title'] = trim($data['title']);
$updata['dateno'] = $data['dateno'];
$updata['isbn'] = $data['isbn'];
$updata['cs'] = 1;
$updata['is_ja'] = 1;
}else{
$updata['cs'] = 0;
$updata['refer_frag'] = trim($data['content']);
}
$this->production_article_refer_obj->where('p_refer_id',$data['p_refer_id'])->update($updata);
// $doi = trim($data['doi']);
// $url = "https://citation.crosscite.org/format?doi=$doi&style=cancer-translational-medicine&lang=en-US";
// $res = myGet($url);
// $frag = trim(substr($res, strpos($res, '.') + 1));
// if ($frag == "") {
// return jsonError("doi error");
// }
// $this->production_article_refer_obj->where('p_refer_id', $data['p_refer_id'])->update(['refer_doi' => $data['doi']]);
// my_doiToFrag2($this->production_article_refer_obj->where('p_refer_id', $data['p_refer_id'])->find());
return jsonSuccess([]);
}
public function searchDoi()
{
$data = $this->request->post();
$rule = new Validate([
"doi" => "require"
]);
if (!$rule->check($data)) {
return jsonError($rule->getError());
}
$doi = str_replace('/', '%2F', $data['doi']);
$url = "https://citation.crosscite.org/format?doi=$doi&style=cancer-translational-medicine&lang=en-US"; $url = "https://citation.crosscite.org/format?doi=$doi&style=cancer-translational-medicine&lang=en-US";
$res = myGet($url); $res = myGet($url);
$frag = trim(substr($res, strpos($res, '.') + 1)); $frag = trim(substr($res, strpos($res, '.') + 1));
if ($frag == "") { if ($frag == "") {
return jsonError("doi error"); return jsonError("not find");
} }
$this->production_article_refer_obj->where('p_refer_id',$data['p_refer_id'])->update(['refer_doi'=>$data['doi']]); if (mb_substr_count($frag, '.') != 3) {
my_doiToFrag2($this->production_article_refer_obj->where('p_refer_id',$data['p_refer_id'])->find()); return jsonError("formate fail");
return jsonSuccess([]); }
$res = explode('.', $frag);
$f['author'] = prgeAuthor($res[0]);
$f['title'] = trim($res[1]);
$bj = bekjournal($res[2]);
$joura = formateJournal(trim($bj[0]));
$f['joura'] = $joura;
$f['dateno'] = str_replace(' ', '', str_replace('-', '', trim($bj[1])));
$f['doilink'] = strpos($data['doi'], "http") === false ? "http://doi.org/" . $data['doi'] : $data['doi'];
$re['formate'] = $f;
return jsonSuccess($re);
} }
/**调整refer排序 /**调整refer排序
@@ -215,59 +302,60 @@ class Preaccept extends Base
* @throws \think\db\exception\ModelNotFoundException * @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException * @throws \think\exception\DbException
*/ */
public function sortRefer(){ public function sortRefer()
{
$data = $this->request->post(); $data = $this->request->post();
$rule = new Validate([ $rule = new Validate([
"p_refer_id"=>"require", "p_refer_id" => "require",
"act"=>"require" "act" => "require"
]); ]);
if(!$rule->check($data)){ if (!$rule->check($data)) {
return jsonError($rule->getError()); return jsonError($rule->getError());
} }
$refer_info = $this->production_article_refer_obj->where('p_refer_id',$data['p_refer_id'])->find(); $refer_info = $this->production_article_refer_obj->where('p_refer_id', $data['p_refer_id'])->find();
if($data['act']=="up"){ if ($data['act'] == "up") {
$up_info = $this->production_article_refer_obj->where('p_article_id',$refer_info['p_article_id'])->where('index',$refer_info['index']-1)->where('state',0)->find(); $up_info = $this->production_article_refer_obj->where('p_article_id', $refer_info['p_article_id'])->where('index', $refer_info['index'] - 1)->where('state', 0)->find();
if(!$up_info){ if (!$up_info) {
return jsonError("system error"); return jsonError("system error");
} }
$this->production_article_refer_obj->where('p_refer_id',$up_info['p_refer_id'])->setInc("index"); $this->production_article_refer_obj->where('p_refer_id', $up_info['p_refer_id'])->setInc("index");
$this->production_article_refer_obj->where('p_refer_id',$refer_info['p_refer_id'])->setDec("index"); $this->production_article_refer_obj->where('p_refer_id', $refer_info['p_refer_id'])->setDec("index");
}else{ } else {
$down_info = $this->production_article_refer_obj->where('p_article_id',$refer_info['p_article_id'])->where('index',$refer_info['index']+1)->where('state',0)->find(); $down_info = $this->production_article_refer_obj->where('p_article_id', $refer_info['p_article_id'])->where('index', $refer_info['index'] + 1)->where('state', 0)->find();
if(!$down_info){ if (!$down_info) {
return jsonError("system error"); return jsonError("system error");
} }
$this->production_article_refer_obj->where('p_refer_id',$refer_info['p_refer_id'])->setInc("index"); $this->production_article_refer_obj->where('p_refer_id', $refer_info['p_refer_id'])->setInc("index");
$this->production_article_refer_obj->where('p_refer_id',$down_info['p_refer_id'])->setDec("index"); $this->production_article_refer_obj->where('p_refer_id', $down_info['p_refer_id'])->setDec("index");
} }
return jsonSuccess([]); return jsonSuccess([]);
} }
public function addRefersByExcel()
public function addRefersByExcel(){ {
$data = $this->request->post(); $data = $this->request->post();
$rule = new Validate([ $rule = new Validate([
"article_id"=>"require", "article_id" => "require",
"referFile" => "require" "referFile" => "require"
]); ]);
if(!$rule->check($data)){ if (!$rule->check($data)) {
return jsonError($rule->getError()); return jsonError($rule->getError());
} }
$production_info = $this->production_article_obj->where('article_id',$data['article_id'])->where("state",0)->find(); $production_info = $this->production_article_obj->where('article_id', $data['article_id'])->where("state", 0)->find();
if(!$production_info){ if (!$production_info) {
return jsonError("Object is null"); return jsonError("Object is null");
} }
$file = ROOT_PATH . 'public' . DS . "referFile".DS.$data['referFile']; $file = ROOT_PATH . 'public' . DS . "referFile" . DS . $data['referFile'];
$list = $this->readRefersExcel($file); $list = $this->readRefersExcel($file);
foreach ($list as $k=> $v){ foreach ($list as $k => $v) {
$ca['p_article_id'] = $production_info['p_article_id']; $ca['p_article_id'] = $production_info['p_article_id'];
$ca['refer_content'] = $v['content']; $ca['refer_content'] = $v['content'];
$ca['refer_doi'] = $v['doi']; $ca['refer_doi'] = $v['doi'];
$ca['index'] = $k; $ca['index'] = $k;
$ca['ctime'] = time(); $ca['ctime'] = time();
$adId=$this->production_article_refer_obj->insertGetId($ca); $adId = $this->production_article_refer_obj->insertGetId($ca);
my_doiToFrag2($this->production_article_refer_obj->where('p_refer_id',$adId)->find()); my_doiToFrag2($this->production_article_refer_obj->where('p_refer_id', $adId)->find());
} }
return jsonSuccess([]); return jsonSuccess([]);
} }
@@ -278,7 +366,8 @@ class Preaccept extends Base
* @throws \PHPExcel_Exception * @throws \PHPExcel_Exception
* @throws \PHPExcel_Reader_Exception * @throws \PHPExcel_Reader_Exception
*/ */
public function readRefersExcel($afile){ public function readRefersExcel($afile)
{
$extension = substr($afile, strrpos($afile, '.') + 1); $extension = substr($afile, strrpos($afile, '.') + 1);
vendor("PHPExcel.PHPExcel"); vendor("PHPExcel.PHPExcel");
if ($extension == 'xlsx') { if ($extension == 'xlsx') {
@@ -292,8 +381,8 @@ class Preaccept extends Base
$highestRow = $sheet->getHighestRow(); $highestRow = $sheet->getHighestRow();
$frag = []; $frag = [];
for ($i = 2; $i <= $highestRow; $i++) { for ($i = 2; $i <= $highestRow; $i++) {
if($objPHPExcel->getActiveSheet()->getCell("A" . $i)->getValue()==''){ if ($objPHPExcel->getActiveSheet()->getCell("A" . $i)->getValue() == '') {
continue ; continue;
} }
$aa['content'] = $objPHPExcel->getActiveSheet()->getCell("A" . $i)->getValue(); $aa['content'] = $objPHPExcel->getActiveSheet()->getCell("A" . $i)->getValue();
$aa['doi'] = $objPHPExcel->getActiveSheet()->getCell("B" . $i)->getValue(); $aa['doi'] = $objPHPExcel->getActiveSheet()->getCell("B" . $i)->getValue();
@@ -304,19 +393,19 @@ class Preaccept extends Base
} }
/**上传引用文献文件,并返回读取到的内容 /**上传引用文献文件,并返回读取到的内容
* @return \think\response\Json|void * @return \think\response\Json|void
*/ */
public function up_refer_file(){ public function up_refer_file()
{
$file = request()->file("referFile"); $file = request()->file("referFile");
if ($file) { if ($file) {
$info = $file->move(ROOT_PATH . 'public' . DS . "referFile"); $info = $file->move(ROOT_PATH . 'public' . DS . "referFile");
if ($info) { if ($info) {
$file = ROOT_PATH . 'public' . DS . "referFile".DS.str_replace("\\", "/", $info->getSaveName()); $file = ROOT_PATH . 'public' . DS . "referFile" . DS . str_replace("\\", "/", $info->getSaveName());
$re["refers"] = $this->readRefersExcel($file); $re["refers"] = $this->readRefersExcel($file);
$re["upurl"] = str_replace("\\", "/", $info->getSaveName()); $re["upurl"] = str_replace("\\", "/", $info->getSaveName());
$re['code'] =0; $re['code'] = 0;
return json($re); return json($re);
} else { } else {
return json(['code' => 1, 'msg' => $file->getError()]); return json(['code' => 1, 'msg' => $file->getError()]);
@@ -325,5 +414,4 @@ class Preaccept extends Base
} }
} }

View File

@@ -1075,7 +1075,7 @@ class Production extends Base
} }
$typesetInfo['filename'] = "http://api.tmrjournals.com/public/" . $files[0]['file_url']; $typesetInfo['filename'] = "http://api.tmrjournals.com/public/" . $files[0]['file_url'];
$rs = $this->production_article_refer_obj->where('p_article_id', $p_info['p_article_id'])->where('state', 0)->select(); $rs = $this->production_article_refer_obj->where('p_article_id', $p_info['p_article_id'])->where('state', 0)->order("index")->select();
// $refers = []; // $refers = [];
// foreach ($rs as $v) { // foreach ($rs as $v) {
// $refers[] = $v['refer_frag']; // $refers[] = $v['refer_frag'];