1
This commit is contained in:
@@ -470,6 +470,174 @@ class Base extends Controller
|
||||
return $hashids->encode($str);
|
||||
}
|
||||
|
||||
|
||||
public function getProductionMainImgs($p_article_id){
|
||||
$mains = $this->production_article_main_obj->where('p_article_id',$p_article_id)->where('state',0)->select();
|
||||
if(count($mains)==0){
|
||||
$this->creatMainData($p_article_id);
|
||||
$mains = $this->production_article_main_obj->where('p_article_id',$p_article_id)->where('state',0)->select();
|
||||
}
|
||||
$frag = [];
|
||||
foreach ($mains as $v){
|
||||
$frag[] = $v;
|
||||
$ca = $this->production_article_main_img_obj->where('p_main_id',$v['p_main_id'])->where("state",0)->find();
|
||||
if($ca){
|
||||
$frag[] = $ca;
|
||||
$pre_id = $ca['p_main_img_id'];
|
||||
while ($pre_id!=0){
|
||||
$cac = $this->production_article_main_img_obj->where('pre_id',$pre_id)->where('state',0)->find();
|
||||
if($cac){
|
||||
$frag[] = $cac;
|
||||
$pre_id = $cac['p_main_img_id'];
|
||||
}else{
|
||||
$pre_id = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $frag;
|
||||
}
|
||||
|
||||
private function creatMainData($p_article_id){
|
||||
$p_info = $this->production_article_obj->where('p_article_id',$p_article_id)->find();
|
||||
$article_info = $this->article_obj->where('article_id', $p_info['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;
|
||||
}
|
||||
if(!isset($frag['main'])){
|
||||
return jsonError("manuscript file error!");
|
||||
}
|
||||
|
||||
|
||||
//将主体内容写入数据库
|
||||
foreach($frag['main'] as $v){
|
||||
$ca['p_article_id'] = $p_article_id;
|
||||
$ca['content'] = $v;
|
||||
$ca['content_g'] = '';
|
||||
$ca['ctime'] = time();
|
||||
$this->production_article_main_obj->insert($ca);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function getProductionMainImgsByNew($p_article_id,$file){
|
||||
$p_info = $this->production_article_obj->where('p_article_id',$p_article_id)->find();
|
||||
$article_info = $this->article_obj->where('article_id', $p_info['article_id'])->find();
|
||||
$url = "http://ts.tmrjournals.com/api/typeset/webReaddoc";
|
||||
$program['fileRoute'] = "https://submission.tmrjournals.com/public/completedManuscirpt/" . $file;
|
||||
// $program['fileRoute'] = "https://submission.tmrjournals.com/public/completedManuscirpt/20230706/87628e769c4ee8a8414219b05c72a028.docx" ;
|
||||
$res = object_to_array(json_decode(myPost($url, $program)));
|
||||
$file_runs = $res['data'];
|
||||
if (count($file_runs)==0){
|
||||
return jsonError("File crawl failed");
|
||||
}
|
||||
//清空之前的
|
||||
$this->production_article_main_obj->where('p_article_id',$p_article_id)->update(['state'=>1]);
|
||||
|
||||
//整理信息
|
||||
$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;
|
||||
}
|
||||
if(!isset($frag['main'])){
|
||||
return jsonError("manuscript file error!");
|
||||
}
|
||||
|
||||
//将主体内容写入数据库
|
||||
foreach($frag['main'] as $v){
|
||||
$ca['p_article_id'] = $p_article_id;
|
||||
$ca['content'] = $v;
|
||||
$ca['content_g'] = '';
|
||||
$ca['ctime'] = time();
|
||||
$this->production_article_main_obj->insert($ca);
|
||||
}
|
||||
|
||||
$mains = $this->production_article_main_obj->where('p_article_id',$p_article_id)->where('state',0)->select();
|
||||
$f = [];
|
||||
foreach ($mains as $v){
|
||||
$f[] = $v;
|
||||
$ca = $this->production_article_main_img_obj->where('p_main_id',$v['p_main_id'])->where("state",0)->find();
|
||||
if($ca){
|
||||
$f[] = $ca;
|
||||
$pre_id = $ca['p_main_img_id'];
|
||||
while ($pre_id!=0){
|
||||
$cac = $this->production_article_main_img_obj->where('pre_id',$pre_id)->where('state',0)->find();
|
||||
if($cac){
|
||||
$f[] = $cac;
|
||||
$pre_id = $cac['p_main_img_id'];
|
||||
}else{
|
||||
$pre_id = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $f;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -206,7 +206,15 @@ class Production extends Base
|
||||
}
|
||||
$a = explode('/',$data['doi']);
|
||||
$pro_info = $this->production_article_obj->where('doi',$a[1])->where('state',2)->find();
|
||||
$frag = $this->getProductionMainImgs($pro_info['p_article_id']);
|
||||
if(!$pro_info){
|
||||
return jsonError("production error");
|
||||
}
|
||||
|
||||
if(isset($data['file'])&&$data['file']!=""){
|
||||
$frag = $this->getProductionMainImgsByNew($pro_info['p_article_id'],$data['file']);
|
||||
}else{
|
||||
$frag = $this->getProductionMainImgs($pro_info['p_article_id']);
|
||||
}
|
||||
if(count($frag)==0){
|
||||
return jsonError("create error");
|
||||
}
|
||||
@@ -215,93 +223,6 @@ class Production extends Base
|
||||
return jsonSuccess($re);
|
||||
}
|
||||
|
||||
private function getProductionMainImgs($p_article_id){
|
||||
$mains = $this->production_article_main_obj->where('p_article_id',$p_article_id)->where('state',0)->select();
|
||||
if(count($mains)==0){
|
||||
$this->creatMainData($p_article_id);
|
||||
$mains = $this->production_article_main_obj->where('p_article_id',$p_article_id)->where('state',0)->select();
|
||||
}
|
||||
$frag = [];
|
||||
foreach ($mains as $v){
|
||||
$frag[] = $v;
|
||||
$ca = $this->production_article_main_img_obj->where('p_main_id',$v['p_main_id'])->where("state",0)->find();
|
||||
if($ca){
|
||||
$frag[] = $ca;
|
||||
$pre_id = $ca['p_main_img_id'];
|
||||
while ($pre_id!=0){
|
||||
$cac = $this->production_article_main_img_obj->where('pre_id',$pre_id)->where('state',0)->find();
|
||||
if($cac){
|
||||
$frag[] = $cac;
|
||||
$pre_id = $cac['p_main_img_id'];
|
||||
}else{
|
||||
$pre_id = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $frag;
|
||||
}
|
||||
|
||||
private function creatMainData($p_article_id){
|
||||
$p_info = $this->production_article_obj->where('p_article_id',$p_article_id)->find();
|
||||
$article_info = $this->article_obj->where('article_id', $p_info['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;
|
||||
}
|
||||
if(!isset($frag['main'])){
|
||||
return jsonError("manuscript file error!");
|
||||
}
|
||||
|
||||
|
||||
//将主体内容写入数据库
|
||||
foreach($frag['main'] as $v){
|
||||
$ca['p_article_id'] = $p_article_id;
|
||||
$ca['content'] = $v;
|
||||
$ca['content_g'] = '';
|
||||
$ca['ctime'] = time();
|
||||
$this->production_article_main_obj->insert($ca);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除main内容的某一行
|
||||
@@ -1893,6 +1814,22 @@ class Production extends Base
|
||||
}
|
||||
|
||||
|
||||
/**上传最终版文章word文件
|
||||
* @return \think\response\Json|void
|
||||
*/
|
||||
public function up_last_artFile(){
|
||||
$file = request()->file('completedManuscirpt');
|
||||
if ($file) {
|
||||
$info = $file->move(ROOT_PATH . 'public' . DS . 'completedManuscirpt');
|
||||
if ($info) {
|
||||
return json(['code' => 0, 'upurl' => str_replace("\\", "/", $info->getSaveName())]);
|
||||
} else {
|
||||
return json(['code' => 1, 'msg' => $file->getError()]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 上传pdf文件
|
||||
*/
|
||||
|
||||
@@ -59,7 +59,26 @@ class Publish extends Base
|
||||
$pra['pageIndex'] = $data['pageIndex'];
|
||||
$pra['pageSize'] = $data['pageSize'];
|
||||
$res = object_to_array(json_decode(myPost($url, $pra)));
|
||||
return jsonSuccess($res['data']);
|
||||
|
||||
$articles = $res['data']["articleList"];
|
||||
|
||||
foreach ($articles as $k => $v){
|
||||
$a = explode('/',$v['doi']);
|
||||
if(!isset($a[1])){
|
||||
$articles[$k]['refers'] = [];
|
||||
continue;
|
||||
}
|
||||
$pro_info = $this->production_article_obj->where('doi',$a[1])->where('state',2)->find();
|
||||
if (!$pro_info){
|
||||
$articles[$k]['refers'] = [];
|
||||
continue;
|
||||
}
|
||||
$articles[$k]['refers'] = $this->production_article_refer_obj->where("p_article_id",$pro_info['p_article_id'])->where('state',0)->order("index")->select();
|
||||
}
|
||||
|
||||
$re['count'] = $res['data']["count"];
|
||||
$re['articleList'] = $articles;
|
||||
return jsonSuccess($re);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user