From 145b0ab8a5ed5ab6fd9c51ce4728a0e53c044f8c Mon Sep 17 00:00:00 2001 From: wangjinlei <751475802@qq.com> Date: Sun, 22 Dec 2024 17:10:15 +0800 Subject: [PATCH] 1 --- application/api/controller/Article.php | 24 +- application/api/controller/Base.php | 18 +- application/api/controller/Preaccept.php | 297 +++++++++++++++++++++- application/api/controller/Production.php | 116 +++++++++ 4 files changed, 429 insertions(+), 26 deletions(-) diff --git a/application/api/controller/Article.php b/application/api/controller/Article.php index 62715d0..385e4a3 100644 --- a/application/api/controller/Article.php +++ b/application/api/controller/Article.php @@ -1961,12 +1961,12 @@ class Article extends Base foreach ($data['list'] as $v){ $insert['article_id'] = $data['article_id']; if($v['type']==0){ - $insert['table'] = $data['table']; - $insert['html_data'] = $data['html_data']; + $insert['table'] = $v['table']; + $insert['html_data'] = $v['html_data']; $insert['type'] = 0; }else{ $insert['type'] = 1; - $insert['url'] = $data['url']; + $insert['url'] = $v['url']; } $insert['ctime'] = time(); $this->article_table_obj->insert($insert); @@ -2250,24 +2250,6 @@ class Article extends Base foreach ($file_runs as $v){ $insert['article_id'] = $article_id; $insert['image'] = $article_id."/".$v; -// if(strtolower(pathinfo($v,PATHINFO_EXTENSION))=="emf"){ -// $imagick = new \Imagick(); -// $formats = $imagick->queryFormats(); -//// var_dump($formats);die; -// $inputPath = ROOT_PATH."public/articleImage/".$article_id."/".$v; -// // 确保文件读取成功 -// $imagick->readImage($inputPath); -// $outputPath = ROOT_PATH."public/articleImage/".$article_id."/".substr($v,0,-3)."jpg";; -// // 确保转换成功并写入文件 -// if ($imagick->setImageFormat('jpg') && $imagick->writeImage($outputPath)) { -// echo "Image successfully written to: " . $outputPath; // Debugging output -// $imagick->clear(); -// $imagick->destroy(); -// $insert['jpg_url'] = $article_id."/".substr($v,0,-3)."jpg"; -// } else { -// echo "Image writing failed!"; // Debugging output -// } -// } $insert['ctime'] = time(); $this->article_image_obj->insert($insert); } diff --git a/application/api/controller/Base.php b/application/api/controller/Base.php index ed6aba7..a684c08 100644 --- a/application/api/controller/Base.php +++ b/application/api/controller/Base.php @@ -428,7 +428,7 @@ class Base extends Controller $insert1['article_id'] = $article_id; $insert1['type'] = 1; $insert1['ami_id'] = $c_id; - $insert1['content'] = $v; + $insert1['content'] = substr($v,0,-2)."imageId='".$c_id."' />"; $insert1['sort'] = $k+1; $insert1['ctime'] = time(); $this->article_main_obj->insert($insert1); @@ -509,7 +509,7 @@ class Base extends Controller // 处理 TIFF 和 EMF 文件并转换为 JPG file_put_contents($base_url . $newFileName, $fileContent); $insert['article_id'] = $article_id; - $insert['url'] = $article_id . "/" . $newFileName; + $insert['url'] = $this->crossTifToPng($article_id . "/" . $newFileName); $insert['ctime'] = time(); $this->article_main_image_obj->insert($insert); } elseif ($extension == "docx") { @@ -528,8 +528,9 @@ class Base extends Controller } $file_runs = $res['data']['list']; foreach ($file_runs as $val) { + $ex = pathinfo($val,PATHINFO_EXTENSION); $insert['article_id'] = $article_id; - $insert['url'] = $val; + $insert['url'] = ($ex=="tif"||$ex=="tiff")?crossTifToPng($val):$val; $insert['ctime'] = time(); $this->article_main_image_obj->insert($insert); } @@ -543,6 +544,17 @@ class Base extends Controller } } + + private function crossTifToPng($tif_url){ + $url = $this->ts_base_url . "api/typeset/crossImage"; + $program['url'] = $tif_url; + $res = object_to_array(json_decode(myPost($url, $program))); + if (!isset($res['data']['file'])) { + return; + } + return $res['data']['file']; + } + public function isImageTag($str) { // 正则表达式匹配 标签,忽略大小写 $pattern = '/^\s*]*\s*src=["\'][^"\']+["\'][^>]*>\s*$/i'; diff --git a/application/api/controller/Preaccept.php b/application/api/controller/Preaccept.php index e31ce41..6139c9c 100644 --- a/application/api/controller/Preaccept.php +++ b/application/api/controller/Preaccept.php @@ -282,6 +282,102 @@ class Preaccept extends Base } + + public function positioningImage(){ + $data = $this->request->post(); + $rule = new Validate([ + "am_id"=>"require", + "ami_id"=>"require" + ]); + if(!$rule->check($data)){ + return jsonError($rule->getError()); + } + $am_info = $this->article_main_obj->where("am_id",$data['am_id'])->find(); + $ami_info = $this->article_main_image_obj->where("ami_id",$data['ami_id'])->find(); + $check = $this->article_main_obj->where("article_id",$am_info['article_id'])->where("ami_id",$data['ami_id'])->whereIn("state",[0,2])->find(); + if($check){ + return jsonError("Repeat operation"); + } + + $sort_check = $this->article_main_obj->where("article_id",$am_info['article_id'])->whereIn("state",[0,2])->where("sort",$am_info['sort']+1)->find(); + if($sort_check){ + $this->article_main_obj->where("article_id",$am_info['article_id'])->whereIn("state",[0,2])->where("sort",">",$am_info['sort'])->inc("sort",1)->update(); + } + $insert['article_id'] = $am_info['article_id']; + $insert['type'] = 1; + $insert['content'] = ""; + $insert['ami_id'] = $data['ami_id']; + $insert['sort'] = $am_info['sort']+1; + $insert['ctime'] = time(); + $this->article_main_obj->insert($insert); + return jsonSuccess([]); + } + + public function removeImage(){ + $data = $this->request->post(); + $rule = new Validate([ + "am_id"=>"require" + ]); + if(!$rule->check($data)){ + return jsonError($rule->getError()); + } + $am_info = $this->article_main_obj->where("am_id",$data['am_id'])->find(); + if($am_info['type']!=1){ + return jsonError("error"); + } + $this->article_main_obj->where("am_id",$data['am_id'])->update(['state'=>1]); + return jsonSuccess([]); + } + + + public function removeTable(){ + $data = $this->request->post(); + $rule = new Validate([ + "am_id"=>"require" + ]); + if(!$rule->check($data)){ + return jsonError($rule->getError()); + } + $am_info = $this->article_main_obj->where("am_id",$data['am_id'])->find(); + if($am_info['type']!=2){ + return jsonError("error"); + } + $this->article_main_obj->where("am_id",$data['am_id'])->update(['state'=>1]); + return jsonSuccess([]); + + } + + public function positioningTable(){ + $data = $this->request->post(); + $rule = new Validate([ + "am_id" => "require", + "amt_id" => "require" + ]); + if(!$rule->check($data)){ + return jsonError($rule->getError()); + } + $am_info = $this->article_main_obj->where("am_id",$data['am_id'])->find(); + $amt_info = $this->article_main_table_obj->where("amt_id",$data['amt_id'])->find(); + $check = $this->article_main_obj->where("article_id",$am_info['article_id'])->where("amt_id",$data['amt_id'])->whereIn('state',[0,2])->find(); + if($check){ + return jsonError("Repeat operation"); + } + $sort_check = $this->article_main_obj->where("article_id",$amt_info['article_id'])->whereIn("state",[0,2])->where("sort",$am_info['sort']+1)->find(); + if ($sort_check){ + $this->article_main_obj->where("article_id",$am_info['article_id'])->whereIn("state",[0,2])->where('sort',">",$am_info['sort'])->inc("sort",1)->update(); + } + $insert['article_id'] = $am_info['article_id']; + $insert['type'] = 2; + $insert['amt_id'] = $data['amt_id']; + $insert["content"] = ""; + $insert['sort'] = $am_info['sort']+1; + $insert['ctime'] = time(); + $this->article_main_obj->insert($insert); + return jsonSuccess([]); + } + + + /**编辑refer * @return \think\response\Json * @throws \think\Exception @@ -337,6 +433,23 @@ class Preaccept extends Base } + + public function addMainsRemark(){ + $data = $this->request->post(); + $rule = new Validate([ + "am_id"=>"require", + "remark"=>"require" + ]); + if(!$rule->check($data)){ + return jsonError($rule->getError()); + } + $update['remark'] = trim($data['remark']); + $update['state'] = 2; + $this->article_main_obj->where("am_id",$data['am_id'])->update($update); + return jsonSuccess([]); + } + + public function searchDoi() { $data = $this->request->post(); @@ -369,6 +482,23 @@ class Preaccept extends Base } + public function mytt(){ + + $ss[] = "this id test this id 3test 55this id test this id test this id test this id test"; + $ss[] = "this id test this id 3test 55this id test this id test this id test this id test"; + $ss[] = ""; + $ss[] = "this id test this id 3test 55this id test this id test this id test this id test"; + $ss[] = "this id test this id 3test 55this id test this id test this id test this id test"; + + + $re['detail'] = json_encode($ss); + + return jsonSuccess($re); + + + } + + public function getArticleMains(){ $data = $this->request->post(); $rule = new Validate([ @@ -401,6 +531,59 @@ class Preaccept extends Base return jsonSuccess($re); } + public function getMainImages(){ + $data = $this->request->post(); + $rule = new Validate([ + "article_id"=>"require" + ]); + if(!$rule->check($data)){ + return jsonError($rule->getError()); + } + $list = $this->article_main_image_obj + ->field("*,if((select am_id from t_article_main where ami_id = t_article_main_image.ami_id and state <>1)>0 ,1,0) as has_selected") + ->where("t_article_main_image.article_id",$data['article_id']) + ->where("t_article_main_image.state",0) + ->select(); + $re['list'] = $list; + return jsonSuccess($re); + } + + public function getNotes(){ + $data = $this->request->post(); + $rule = new Validate([ + "article_id"=>"require" + ]); + if(!$rule->check($data)){ + return jsonError($rule->getError()); + } + $list = $this->article_main_obj->where("article_id",$data['article_id'])->where("state",2)->select(); + $re['list'] = $list; + + return jsonSuccess($re); + } + + + public function getMainTables(){ + $data = $this->request->post(); + $rule = new Validate([ + "article_id"=>"require" + ]); + if(!$rule->check($data)){ + return jsonError($rule->getError()); + } + $list = $this->article_main_table_obj + ->field("*,if((select am_id from t_article_main where amt_id = t_article_main_table.amt_id and state <>1)>0 ,1,0) as has_selected") + ->where("t_article_main_table.article_id",$data['article_id']) + ->where("t_article_main_table.state",0) + ->select(); + + $re['list'] = $list; + + return jsonSuccess($re); + } + + + public function delArticleMains(){ $data = $this->request->post(); $rule = new Validate([ @@ -437,13 +620,123 @@ class Preaccept extends Base if(!$rule->check($data)){ return jsonError($rule->getError()); } - $list = $this->article_main_obj->where("article_id",$data['article_id'])->where("state",1)->select(); + $list = $this->article_main_obj->where("article_id",$data['article_id'])->where("type",0)->where("state",1)->select(); $re['list'] = $list; return jsonSuccess($re); } + public function addMainImage(){ + $data = $this->request->post(); + $rule = new Validate([ + "article_id"=>"require", + "url"=>"require" + ]); + if(!$rule->check($data)){ + return jsonError($rule->getError()); + } + $insert['article_id'] = $data['article_id']; + $insert['url'] = $data['url']; + if(isset($data['note'])){ + $insert['note'] = $data['note']; + } + $insert['ctime'] = time(); + $this->article_main_image_obj->insert($insert); + return jsonSuccess([]); + } + + public function editMainImage(){ + $data = $this->request->post(); + $rule = new Validate([ + "ami_id"=>"require", + "url"=>"require", + "note"=>"require" + ]); + if(!$rule->check($data)){ + return jsonError($rule->getError()); + } + $update['url'] = $data['url']; + $update['note'] = $data['note']; + $this->article_main_image_obj->where("ami_id",$data['ami_id'])->update($update); + return jsonSuccess([]); + } + + public function addMainTable(){ + $data = $this->request->post(); + $rule = new Validate([ + "article_id"=>"require", + "table_data"=>"require", + "title"=>"require", + "note"=>"require" + ]); + if(!$rule->check($data)){ + return jsonError($rule->getError()); + } + + $insert['article_id'] = $data['article_id']; + $insert['type'] = 0; + $insert['table_data'] = $data['table_data']; + if(isset($data['html_data'])){ + $insert['html_data'] = $data['html_data']; + } + $insert['title']=$data['title']; + $insert['note'] = $data['note']; + $insert['ctime'] = time(); + $this->article_main_table_obj->insert($insert); + return jsonSuccess([]); + + } + + + public function editMainTable(){ + $data = $this->request->post(); + $rule = new Validate([ + "amt_id"=>"require", + "table_data"=>"require", + "html_data"=>"require", + "title"=>"require", + "note"=>"require" + ]); + if(!$rule->check($data)){ + return jsonError($rule->getError()); + } + $update['table_data'] = $data['table_data']; + $update['html_data'] = $data['html_data']; + $update['title'] = $data['title']; + $update['note'] = $data['note']; + $this->article_main_table_obj->where("amt_id",$data['amt_id'])->update($update); + return jsonSuccess([]); + } + + + public function up_img_mainImage(){ + $article_id = input('post.article_id'); + $file = request()->file('mainImage'); + // 检查文件是否有效 + if (!$file) { + return jsonError("error"); + } + + // 定义上传目录 + $uploadDir = ROOT_PATH . 'public' . DS . "articleImage".DS.$article_id; + + // 生成自定义文件名,使用 uniqid 生成唯一的文件名 + $fileName = uniqid('file_') . '.' . pathinfo($file->getInfo("name"),PATHINFO_EXTENSION); + + // 移动文件到指定目录,并重命名 + $info = $file->move($uploadDir, $fileName); + + // 检查文件是否上传成功 + if ($info) { + $re['upurl'] = $article_id."/".$fileName; + return jsonSuccess($re); + } else { + return jsonError("error"); + } + } + + public function replyArticleRecycle(){ $data = $this->request->post(); $rule = new Validate([ @@ -455,7 +748,7 @@ class Preaccept extends Base $info = $this->article_main_obj->where("am_id",$data['am_id'])->find(); $check = $this->article_main_obj->where("article_id",$info['article_id'])->where("sort",$info['sort'])->whereIn("state",[0,2])->find(); if($check){ - $this->article_main_obj->where("article_id",$data['article_id'])->where("sort",">=",$info['sort'])->inc('sort',1)->update(); + $this->article_main_obj->where("article_id",$info['article_id'])->where("sort",">=",$info['sort'])->inc('sort',1)->update(); } $this->article_main_obj->where("am_id",$data['am_id'])->update(['state'=>0]); return jsonSuccess([]); diff --git a/application/api/controller/Production.php b/application/api/controller/Production.php index 6409e55..b898e3c 100644 --- a/application/api/controller/Production.php +++ b/application/api/controller/Production.php @@ -1113,6 +1113,122 @@ class Production extends Base return jsonSuccess([]); } + + public function doTypeSettingNew(){ + $data = $this->request->post(); + $rule = new Validate([ + "article_id"=>"require" + ]); + if(!$rule->check($data)){ + return jsonError($rule->getError()); + } + $p_info = $this->production_article_obj->where("article_id",$data['article_id'])->whereIn("state",[0,2])->find(); + if(!$p_info){ + return jsonError("error"); + } + $article_info = $this->article_obj->where('article_id', $p_info['article_id'])->find(); + $journal_info = $this->journal_obj->where('journal_id', $p_info['journal_id'])->find(); + $editor_info = $this->user_obj->where('user_id', $journal_info['editor_id'])->find(); + + $typesetInfo = []; + $typesetInfo['info_title'] = $p_info['title']; + $typesetInfo['info_type'] = $p_info['type']; + $typesetInfo['doi'] = $p_info['doi']; + $typesetInfo['topic'] = ''; +// $typesetInfo['mainText'] = $p_info['main']; + + $au_res = $this->authorFormate($p_info['p_article_id']); + + $typesetInfo['author'] = $au_res['author']; + $typesetInfo['authorAddress'] = $au_res['address']; + $typesetInfo['authorContribution'] = $p_info['author_contribution']; + + //查询通讯作者 + $corr_authors = $this->production_article_author_obj->where('p_article_id', $p_info['p_article_id'])->where('is_report', 1)->where('state', 0)->select(); + $corrauthor = ''; + $corremail = ''; + foreach ($corr_authors as $v) { + $corrauthor .= trim($v['first_name']) . ' ' . trim($v['last_name']) . '. '; + $corremail .= $v['email'] . '. '; + } + $typesetInfo['authorCorresponding'] = substr(trim($corrauthor), 0, -1); + $typesetInfo['authorCorrespondingEmail'] = substr(trim($corremail), 0, -1); + $typesetInfo['traditon'] = $p_info['tradition']; + $typesetInfo['journal'] = $journal_info['title']; + $typesetInfo['jabbr'] = $journal_info['jabbr']; + + //查询分期 + $url = 'http://journalapi.tmrjournals.com/public/index.php/master/Journal/getStageDetail'; + $cs['journal_stage_id'] = $p_info['journal_stage_id']; + $list = object_to_array(json_decode(myPost($url, $cs))); + $stage_re = $list['data']['stage']; + + $typesetInfo['stage'] = $stage_re['stage_year'] . ';' . $stage_re['stage_vol'] . '(' . $stage_re['stage_no'] . '):' . $p_info['npp']; //2022;6(1):17 + $typesetInfo['little_author'] = $p_info['abbr']; + $typesetInfo['website'] = $journal_info['website']; + $typesetInfo['acknowledgment'] = $p_info['acknowledgment']; + $typesetInfo['received_date'] = date("d F Y", $article_info['ctime']);; + $typesetInfo['accepted_date'] = date("d F Y", $article_info['rtime']); + $typesetInfo['online_date'] = $p_info['pub_date']; //这里可能会有问题 + $typesetInfo['abbreviation'] = $p_info['abbreviation']; + $typesetInfo['abstractText'] = $p_info['abstract']; + $typesetInfo['keywords'] = $p_info['keywords']; + $typesetInfo['userAccount'] = $editor_info['nickname']; + + $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'); + } + $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)->order("index")->select(); + $typesetInfo['refers'] = json_encode($rs); + + $main_list = $this->article_main_obj->where("article_id",$data['article_id'])->whereIn("state",[0,2])->order("sort")->select(); + + $mainList = []; + $images = []; + $tables = []; + foreach ($main_list as $k =>$item){ + $main_string = ""; + if($item['type']==1){ + $info = $this->article_main_image_obj->where("ami_id",$item['ami_id'])->find(); + $arr['image'] = $info['url']; + $arr['note'] = $info['note']; + $images[$info['ami_id']] = $arr; + $main_string = ""; + }else if($item['type']==2){ + $info = $this->article_main_table_obj->where("amt_id",$item['amt_id'])->find(); + $arr_table['title'] = $info['title']; + $arr_table['table_data'] = $info['table_data']; + $arr_table['note'] = $info['note']; + $tables[$info['amt_id']] = $arr_table; + $main_string = "
"; + }else{ + $main_string = $item['content']; + } + $mainList[] = $main_string; + } + $typesetInfo['mainText'] = json_encode($mainList); + $typesetInfo['images'] = $images; + $typesetInfo['tables'] = $tables; + $url = $this->ts_base_url."api/typeset/webGetDocx"; +// $url = "http://192.168.110.110:8081/typeset/createDocx"; + $res = object_to_array(json_decode(myPost1($url, $typesetInfo))); + + if (!isset($res['data']['file']) || $res['data']['file'] == '') { + return jsonError('create error'); + } + + return jsonSuccess($res); + + } + + /** * 获取生产实例详情 */