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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user