latex update

This commit is contained in:
wangjinlei
2026-01-27 11:22:35 +08:00
parent b37060be8f
commit 1d0581e46e
5 changed files with 581 additions and 920 deletions

View File

@@ -2794,196 +2794,196 @@ class Article extends Base
die("Please update your browser cache and resubmit your submission (shortcut key: Ctrl+F5)");
//接受参数,查询信息
$data = $this->request->post();
$user_res = $this->user_obj->where('account', $data['username'])->find();
//确定用户是否属于黑名单
$black_check = $this->user_black_obj->where('user_id', $user_res['user_id'])->where('black_state', 0)->find();
if ($black_check) {
return jsonError("Your account has been blocked. Please contact the publisher for details: publisher@tmrjournals.com.");
}
// if($user_res['account']=='fariba'||$user_res['account']=='zc'||$user_res['account']=='Mohammad Hossein'||$user_res['account']=='xiaoyueyue'||$user_res['account']=='sethlee000'||$user_res['account']=='yuanying9908'){
// return json(['code'=>1,'msg'=>'Your account has been blocked. Please contact the publisher for details: publisher@tmrjournals.com.']);
// }
$journal_info = $this->journal_obj->where('journal_id', $data['journal'])->find();
//首先查重是否重复投稿
$checkArticle = $this->article_obj->where("title", trim($data['title']))->select();
foreach ($checkArticle as $v) {
if ($v['state'] != 3) {
return json(['code' => 1, 'msg' => 'Warning: you are re-submitting the article!']);
}
}
Db::startTrans();
//添加文章基础信息
$inset_data['user_id'] = $user_res['user_id'];
$inset_data['journal_id'] = $data['journal'];
$inset_data['editor_id'] = $journal_info['editor_id'];
$inset_data['title'] = trim($data['title']);
$inset_data['keywords'] = $data['keyWords'];
$inset_data['fund'] = trim($data['fund']);
$inset_data['accept_sn'] = getArticleSN($journal_info['abbr'], $data['type']);
$inset_data['type'] = $data['type'];
$inset_data['major_id'] = $data['major'];
// $inset_data['cmajor_id'] = $data['cmajor'];
$inset_data['approval'] = $data['approval'] == 'true' ? 1 : 0;
$inset_data['abstrart'] = $data['abstrart'];
$inset_data['author_act'] = 1;
$inset_data['ctime'] = time();
$res = $this->article_obj->insertGetId($inset_data);
//上传文章作者信息
$author_email = [];
$authors = [];
$res_add_user = true;
foreach ($data['authorList'] as $v) {
if ($v['firstname'] == '') {
continue;
}
$i['article_id'] = $res;
$i['firstname'] = trim($v['firstname']);
$i['lastname'] = trim($v['lastname']);
$i['orcid'] = trim($v['orcid']);
$i['company'] = trim($v['company']);
$i['department'] = trim($v['department']);
$i['author_title'] = $v['title'];
$i['country'] = $v['country'];
$i['email'] = trim($v['email']);
$i['address'] = trim($v['address']);
$i['is_super'] = $v['isSuper'] == 'true' ? 1 : 0;
$i['is_report'] = $v['isReport'] == 'true' ? 1 : 0;
$authors[] = $i;
$cache['email'] = trim($v['email']);
$cache['name'] = trim($v['firstname']) . ' ' . trim($v['lastname']);
$author_email[] = $cache;
//通讯作者用户添加
if ($v['isReport'] == "true") {
$re_user_check = $this->user_obj->where('account|email', trim($v['email']))->find();
if (!$re_user_check) {
$password = getRandPassword();
$inser_data['account'] = trim($v['email']);
$inser_data['password'] = md5($password);
$inser_data['email'] = trim($v['email']);
$inser_data['realname'] = trim($v['firstname']) . ' ' . trim($v['lastname']);
$inser_data['ctime'] = time();
$c_res_add_user = $this->user_obj->insertGetId($inser_data);
if ($res_add_user) {
$res_add_user = $c_res_add_user;
}
//发送提示邮件给通讯作者
$report_tt = "Dear " . $inser_data['realname'] . ',<br/><br/>';
$report_tt .= "We are delighted to welcome you as a new author for our journal, " . $journal_info['title'] . ". We have received your submission and are excited to review it for potential publication.<br/><br/>";
$report_tt .= "As a next step, we have created an account for you on our journal's website. Your account is [Username: " . trim($v['email']) . " password:$password]";
$report_tt .= "and you can access your account by visiting " . $journal_info['website'] . " and logging in.<br/><br/>";
$report_tt .= "If you have any questions or need assistance with accessing your account, please don't hesitate to contact us. We are here to support you throughout the submission and review process.<br/><br/>";
$report_tt .= "Thank you for choosing to submit your work to our journal. We look forward to working with you.<br/><br/>";
$report_tt .= "Best regards,<br>" . $journal_info['title'];
$maidata['email'] = trim($v['email']);
$maidata['title'] = $journal_info['title'];
$maidata['content'] = $report_tt;
$maidata['tmail'] = $journal_info['email'];
$maidata['tpassword'] = $journal_info['epassword'];
Queue::push('app\api\job\mail@fire', $maidata, "tmail");
}
}
}
$res_author = $this->article_author_obj->insertAll($authors);
//增加转投信息
$transr = true;
if ($data['istransfer'] == 'true') {
foreach ($data['checkedjours'] as $val) {
$trans_insert['article_id'] = $res;
$trans_insert['journal_id'] = $val;
$trans_insert['ctime'] = time();
$transr = $transr ? $this->article_transfer_obj->insert($trans_insert) : false;
}
}
//增加articlefile表的信息
$res_file1 = self::save_article_file($res, $user_res['user_id'], $user_res['account'], $data['coverLetter'], 'coverLetter');
$res_file2 = true;
if (isset($data['picturesAndTables'])) {
foreach ($data['picturesAndTables'] as $v) {
$res_file2 = $res_file2 ? self::save_article_file($res, $user_res['user_id'], $user_res['account'], $v, 'picturesAndTables') : false;
}
}
$res_file4 = self::save_article_file($res, $user_res['user_id'], $user_res['account'], $data['totalpage'], 'totalpage');
$res_file3 = self::save_article_file($res, $user_res['user_id'], $user_res['account'], $data['manuscirpt'], 'manuscirpt');
//发送邮件到编辑,提醒有待审文章
$editor_info = $this->user_obj->where('user_id', $journal_info['editor_id'])->find();
$tt = 'Dear editor,<br>';
$tt .= 'Please check the new manuscript in the submission system.';
sendEmail($editor_info['email'], $journal_info['title'], $journal_info['title'], $tt, $journal_info['email'], $journal_info['epassword']);
$user_rev_info = $this->user_reviewer_info_obj->where("reviewer_id", $user_res['user_id'])->find();
//发送邮件给作者,表示感谢
$tt_t = 'Dear Dr. ' . ($user_res['realname'] == '' ? $user_res['account'] : $user_res['realname']) . ',<br><br>';
$tt1 = 'Thank you for submitting your manuscript entitled "' . $data['title'] . '". Your submission has been assigned the following tracking number:' . $inset_data['accept_sn'] . '. We will be in touch again as soon as we have reached a decision. Please quote the tracking number in any communication. This e-mail simply acknowledges receipt of your submission. If the editors decide for editorial reasons that the paper is unsuitable for publication in ' . $journal_info['title'] . ', you will be informed as soon as possible.<br><br><br>';
if ($journal_info['journal_id'] == 9) { //life research 期刊发送收到文章邮件
$tt1 .= 'Life Research applies the CC BY-NC 4.0 license. Full details of the policy can be found at https://www.tmrjournals.com/notice.html?J_num=14&footer_id=123. Authors should read Guide to Authors carefully before submitting.<br><br>';
$tt1 .= 'You may check on the status of this manuscript in the Submission System. If you encounter any problems, please contact liferes@tmrjournals.com.<br><br>';
$tt1 .= 'Thank you for choosing to submit your manuscript to Life Research.<br><br><br>';
$tt1 .= 'Yours sincerely,<br>Haoran Zhang<br><br>';
$tt1 .= 'Manuscript Administration, Life Research<br>https://www.tmrjournals.com/lr/';
} else { //其他期刊发送邮件
$tt1 .= 'You may check on the status of this manuscript in the Submission System. If you encounter any problems, please contact ' . $journal_info['email'] . '.<br><br>';
$tt1 .= 'Thank you for choosing to submit your manuscript to ' . $journal_info['title'] . '.<br><br><br>';
$tt1 .= 'Sincerely,<br>Editorial Office<br>';
$tt1 .= '<a href="https://www.tmrjournals.com/draw_up.html?issn=' . $journal_info['issn'] . '">Subscribe to this journal</a><br>';
$tt1 .= $journal_info['title'] . '<br>';
$tt1 .= 'Email: ' . $journal_info['email'] . '<br>';
$tt1 .= 'Website: ' . $journal_info['website'] . '<br>';
$tt1 .= '<hr/>If you have any questions, please contact us: <br>';
$tt1 .= 'Head of publication ethics<br>Dr. Dan Chen<br>TMR Publishing Group Limited Company, Auckland, New Zealand<br>Email: publication.ethics@tmrjournals.com';
}
sendEmail($user_res['email'], $journal_info['title'], $journal_info['title'], $tt_t . $tt1, $journal_info['email'], $journal_info['epassword']);
foreach ($author_email as $v) {
$cache_str = 'Dear Dr. ' . $v['name'] . ',<br><br>';
$maidata['email'] = $v['email'];
$maidata['title'] = $journal_info['title'];
$maidata['content'] = $cache_str . $tt1;
$maidata['tmail'] = $journal_info['email'];
$maidata['tpassword'] = $journal_info['epassword'];
Queue::push('app\api\job\mail@fire', $maidata, "tmail");
}
//增加用户操作log
$log_data['user_id'] = $user_res['user_id'];
$log_data['type'] = 0;
$log_data['content'] = $user_res['account'] . "(" . $user_res['realname'] . "),上传了一篇文章:" . $data['title'] . ",上传时间是:" . date('Y-m-d H:i:s', time());
$log_data['ctime'] = time();
$res_log = $this->user_log_obj->insert($log_data);
//增加usermsg
$res_msg = add_usermsg($journal_info['editor_id'], 'New manuscript', '/articleDetailEditor?id=' . $res);
//通讯作者转为审稿人
$this->addReviewerFromArticle($res, $journal_info['journal_id']);
//推荐审稿人
$recommend_res = true;
$reviewers = isset($data['reviewers']) ? $data['reviewers'] : [];
foreach ($reviewers as $v) {
$recommend_res = $this->addRecommentReviewer($v, $journal_info['journal_id'], $user_res['user_id'], $res);
}
if ($res && $res_author && $transr && $res_add_user && $res_file1 && $res_file2 && $res_file3 && $res_file4 && $res_log && $res_msg && $recommend_res) {
Db::commit();
$this->ai_scor($res);
return json(['code' => 0]);
} else {
Db::rollback();
return json(['code' => 1]);
}
// $data = $this->request->post();
//
// $user_res = $this->user_obj->where('account', $data['username'])->find();
//
// //确定用户是否属于黑名单
// $black_check = $this->user_black_obj->where('user_id', $user_res['user_id'])->where('black_state', 0)->find();
// if ($black_check) {
// return jsonError("Your account has been blocked. Please contact the publisher for details: publisher@tmrjournals.com.");
// }
//
// // if($user_res['account']=='fariba'||$user_res['account']=='zc'||$user_res['account']=='Mohammad Hossein'||$user_res['account']=='xiaoyueyue'||$user_res['account']=='sethlee000'||$user_res['account']=='yuanying9908'){
// // return json(['code'=>1,'msg'=>'Your account has been blocked. Please contact the publisher for details: publisher@tmrjournals.com.']);
// // }
//
// $journal_info = $this->journal_obj->where('journal_id', $data['journal'])->find();
// //首先查重是否重复投稿
// $checkArticle = $this->article_obj->where("title", trim($data['title']))->select();
// foreach ($checkArticle as $v) {
// if ($v['state'] != 3) {
// return json(['code' => 1, 'msg' => 'Warning: you are re-submitting the article!']);
// }
// }
// Db::startTrans();
//
// //添加文章基础信息
// $inset_data['user_id'] = $user_res['user_id'];
// $inset_data['journal_id'] = $data['journal'];
// $inset_data['editor_id'] = $journal_info['editor_id'];
// $inset_data['title'] = trim($data['title']);
// $inset_data['keywords'] = $data['keyWords'];
// $inset_data['fund'] = trim($data['fund']);
// $inset_data['accept_sn'] = getArticleSN($journal_info['abbr'], $data['type']);
// $inset_data['type'] = $data['type'];
// $inset_data['major_id'] = $data['major'];
// // $inset_data['cmajor_id'] = $data['cmajor'];
// $inset_data['approval'] = $data['approval'] == 'true' ? 1 : 0;
// $inset_data['abstrart'] = $data['abstrart'];
// $inset_data['author_act'] = 1;
// $inset_data['ctime'] = time();
// $res = $this->article_obj->insertGetId($inset_data);
//
// //上传文章作者信息
// $author_email = [];
// $authors = [];
// $res_add_user = true;
// foreach ($data['authorList'] as $v) {
// if ($v['firstname'] == '') {
// continue;
// }
// $i['article_id'] = $res;
// $i['firstname'] = trim($v['firstname']);
// $i['lastname'] = trim($v['lastname']);
// $i['orcid'] = trim($v['orcid']);
// $i['company'] = trim($v['company']);
// $i['department'] = trim($v['department']);
// $i['author_title'] = $v['title'];
// $i['country'] = $v['country'];
// $i['email'] = trim($v['email']);
// $i['address'] = trim($v['address']);
// $i['is_super'] = $v['isSuper'] == 'true' ? 1 : 0;
// $i['is_report'] = $v['isReport'] == 'true' ? 1 : 0;
// $authors[] = $i;
// $cache['email'] = trim($v['email']);
// $cache['name'] = trim($v['firstname']) . ' ' . trim($v['lastname']);
// $author_email[] = $cache;
//
// //通讯作者用户添加
// if ($v['isReport'] == "true") {
// $re_user_check = $this->user_obj->where('account|email', trim($v['email']))->find();
// if (!$re_user_check) {
// $password = getRandPassword();
// $inser_data['account'] = trim($v['email']);
// $inser_data['password'] = md5($password);
// $inser_data['email'] = trim($v['email']);
// $inser_data['realname'] = trim($v['firstname']) . ' ' . trim($v['lastname']);
// $inser_data['ctime'] = time();
// $c_res_add_user = $this->user_obj->insertGetId($inser_data);
// if ($res_add_user) {
// $res_add_user = $c_res_add_user;
// }
//
// //发送提示邮件给通讯作者
// $report_tt = "Dear " . $inser_data['realname'] . ',<br/><br/>';
// $report_tt .= "We are delighted to welcome you as a new author for our journal, " . $journal_info['title'] . ". We have received your submission and are excited to review it for potential publication.<br/><br/>";
// $report_tt .= "As a next step, we have created an account for you on our journal's website. Your account is [Username: " . trim($v['email']) . " password:$password]";
// $report_tt .= "and you can access your account by visiting " . $journal_info['website'] . " and logging in.<br/><br/>";
// $report_tt .= "If you have any questions or need assistance with accessing your account, please don't hesitate to contact us. We are here to support you throughout the submission and review process.<br/><br/>";
// $report_tt .= "Thank you for choosing to submit your work to our journal. We look forward to working with you.<br/><br/>";
// $report_tt .= "Best regards,<br>" . $journal_info['title'];
// $maidata['email'] = trim($v['email']);
// $maidata['title'] = $journal_info['title'];
// $maidata['content'] = $report_tt;
// $maidata['tmail'] = $journal_info['email'];
// $maidata['tpassword'] = $journal_info['epassword'];
// Queue::push('app\api\job\mail@fire', $maidata, "tmail");
// }
// }
// }
// $res_author = $this->article_author_obj->insertAll($authors);
//
// //增加转投信息
// $transr = true;
// if ($data['istransfer'] == 'true') {
// foreach ($data['checkedjours'] as $val) {
// $trans_insert['article_id'] = $res;
// $trans_insert['journal_id'] = $val;
// $trans_insert['ctime'] = time();
// $transr = $transr ? $this->article_transfer_obj->insert($trans_insert) : false;
// }
// }
//
//
// //增加articlefile表的信息
// $res_file1 = self::save_article_file($res, $user_res['user_id'], $user_res['account'], $data['coverLetter'], 'coverLetter');
// $res_file2 = true;
// if (isset($data['picturesAndTables'])) {
// foreach ($data['picturesAndTables'] as $v) {
// $res_file2 = $res_file2 ? self::save_article_file($res, $user_res['user_id'], $user_res['account'], $v, 'picturesAndTables') : false;
// }
// }
// $res_file4 = self::save_article_file($res, $user_res['user_id'], $user_res['account'], $data['totalpage'], 'totalpage');
// $res_file3 = self::save_article_file($res, $user_res['user_id'], $user_res['account'], $data['manuscirpt'], 'manuscirpt');
//
// //发送邮件到编辑,提醒有待审文章
// $editor_info = $this->user_obj->where('user_id', $journal_info['editor_id'])->find();
// $tt = 'Dear editor,<br>';
// $tt .= 'Please check the new manuscript in the submission system.';
// sendEmail($editor_info['email'], $journal_info['title'], $journal_info['title'], $tt, $journal_info['email'], $journal_info['epassword']);
// $user_rev_info = $this->user_reviewer_info_obj->where("reviewer_id", $user_res['user_id'])->find();
// //发送邮件给作者,表示感谢
// $tt_t = 'Dear Dr. ' . ($user_res['realname'] == '' ? $user_res['account'] : $user_res['realname']) . ',<br><br>';
// $tt1 = 'Thank you for submitting your manuscript entitled "' . $data['title'] . '". Your submission has been assigned the following tracking number:' . $inset_data['accept_sn'] . '. We will be in touch again as soon as we have reached a decision. Please quote the tracking number in any communication. This e-mail simply acknowledges receipt of your submission. If the editors decide for editorial reasons that the paper is unsuitable for publication in ' . $journal_info['title'] . ', you will be informed as soon as possible.<br><br><br>';
// if ($journal_info['journal_id'] == 9) { //life research 期刊发送收到文章邮件
// $tt1 .= 'Life Research applies the CC BY-NC 4.0 license. Full details of the policy can be found at https://www.tmrjournals.com/notice.html?J_num=14&footer_id=123. Authors should read Guide to Authors carefully before submitting.<br><br>';
// $tt1 .= 'You may check on the status of this manuscript in the Submission System. If you encounter any problems, please contact liferes@tmrjournals.com.<br><br>';
// $tt1 .= 'Thank you for choosing to submit your manuscript to Life Research.<br><br><br>';
// $tt1 .= 'Yours sincerely,<br>Haoran Zhang<br><br>';
// $tt1 .= 'Manuscript Administration, Life Research<br>https://www.tmrjournals.com/lr/';
// } else { //其他期刊发送邮件
// $tt1 .= 'You may check on the status of this manuscript in the Submission System. If you encounter any problems, please contact ' . $journal_info['email'] . '.<br><br>';
// $tt1 .= 'Thank you for choosing to submit your manuscript to ' . $journal_info['title'] . '.<br><br><br>';
// $tt1 .= 'Sincerely,<br>Editorial Office<br>';
// $tt1 .= '<a href="https://www.tmrjournals.com/draw_up.html?issn=' . $journal_info['issn'] . '">Subscribe to this journal</a><br>';
// $tt1 .= $journal_info['title'] . '<br>';
// $tt1 .= 'Email: ' . $journal_info['email'] . '<br>';
// $tt1 .= 'Website: ' . $journal_info['website'] . '<br>';
// $tt1 .= '<hr/>If you have any questions, please contact us: <br>';
// $tt1 .= 'Head of publication ethics<br>Dr. Dan Chen<br>TMR Publishing Group Limited Company, Auckland, New Zealand<br>Email: publication.ethics@tmrjournals.com';
// }
//
// sendEmail($user_res['email'], $journal_info['title'], $journal_info['title'], $tt_t . $tt1, $journal_info['email'], $journal_info['epassword']);
//
// foreach ($author_email as $v) {
// $cache_str = 'Dear Dr. ' . $v['name'] . ',<br><br>';
// $maidata['email'] = $v['email'];
// $maidata['title'] = $journal_info['title'];
// $maidata['content'] = $cache_str . $tt1;
// $maidata['tmail'] = $journal_info['email'];
// $maidata['tpassword'] = $journal_info['epassword'];
// Queue::push('app\api\job\mail@fire', $maidata, "tmail");
// }
//
// //增加用户操作log
// $log_data['user_id'] = $user_res['user_id'];
// $log_data['type'] = 0;
// $log_data['content'] = $user_res['account'] . "(" . $user_res['realname'] . "),上传了一篇文章:" . $data['title'] . ",上传时间是:" . date('Y-m-d H:i:s', time());
// $log_data['ctime'] = time();
// $res_log = $this->user_log_obj->insert($log_data);
//
// //增加usermsg
// $res_msg = add_usermsg($journal_info['editor_id'], 'New manuscript', '/articleDetailEditor?id=' . $res);
//
// //通讯作者转为审稿人
// $this->addReviewerFromArticle($res, $journal_info['journal_id']);
//
// //推荐审稿人
// $recommend_res = true;
// $reviewers = isset($data['reviewers']) ? $data['reviewers'] : [];
// foreach ($reviewers as $v) {
// $recommend_res = $this->addRecommentReviewer($v, $journal_info['journal_id'], $user_res['user_id'], $res);
// }
//
// if ($res && $res_author && $transr && $res_add_user && $res_file1 && $res_file2 && $res_file3 && $res_file4 && $res_log && $res_msg && $recommend_res) {
// Db::commit();
// $this->ai_scor($res);
// return json(['code' => 0]);
// } else {
// Db::rollback();
// return json(['code' => 1]);
// }
}

View File

@@ -67,7 +67,7 @@ class Base extends Controller
protected $production_article_author_to_organ_obj = '';
protected $production_article_frag_obj = '';
protected $production_article_main_obj = '';
protected $production_article_main_img_obj = '';
// protected $production_article_main_img_obj = '';
protected $apply_reviewer_obj = '';
protected $promotion_obj = '';
protected $promotion_email_obj = '';
@@ -150,7 +150,7 @@ class Base extends Controller
$this->production_article_author_to_organ_obj = Db::name('production_article_author_to_organ');
$this->production_article_frag_obj = Db::name('production_article_frag');
$this->production_article_main_obj = Db::name('production_article_main');
$this->production_article_main_img_obj = Db::name("production_article_main_img");
// $this->production_article_main_img_obj = Db::name("production_article_main_img");
$this->apply_reviewer_obj = Db::name("apply_reviewer");
$this->promotion_obj = Db::name("promotion");
$this->promotion_email_obj = Db::name("promotion_email");
@@ -843,95 +843,95 @@ class Base extends Controller
}
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;
}
// 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 = $this->ts_base_url."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);
}
}
// 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 = $this->ts_base_url."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 refuseReferIndex($p_article_id)
{
@@ -946,83 +946,83 @@ class Base extends Controller
}
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 = $this->ts_base_url."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;
}
// 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 = $this->ts_base_url."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;
// }
/**创建空production实例应对main和refers

View File

@@ -21,7 +21,7 @@ class Contribute extends Base
}
/**
* 自动投稿
* 自动投稿,提交存储文章相关信息
* @param file_url 文件地址
*/
public function contribute($aParam = []){

View File

@@ -1,341 +0,0 @@
<?php
namespace app\api\controller;
class Latex extends Base
{
public function __construct(\think\Request $request = null)
{
parent::__construct($request);
}
public function generateLatexPdf()
{
$data = $this->request->post();
$rule = new Validate([
'p_article_id' => 'require|number'
]);
if (!$rule->check($data)) {
return jsonError($rule->getError());
}
try {
// 获取文章信息
$p_info = $this->production_article_obj->where('p_article_id', $data['p_article_id'])->find();
if (!$p_info) {
return jsonError('文章实例不存在');
}
// 获取作者信息
$authors = $this->production_article_author_obj->where('p_article_id', $data['p_article_id'])->where('state', 0)->select();
// 获取机构信息
$organs = $this->production_article_organ_obj->where('p_article_id', $data['p_article_id'])->where('state', 0)->select();
// 获取正文内容
$main_contents = $this->production_article_main_obj->where('p_article_id', $data['p_article_id'])->where('state', 0)->order('p_main_id')->select();
// 获取参考文献
$references = $this->production_article_refer_obj->where('p_article_id', $data['p_article_id'])->where('state', 0)->order('index')->select();
// 构建LaTeX内容
$latex_content = $this->buildLatexContent($p_info, $authors, $organs, $main_contents, $references);
// 创建临时目录
$temp_dir = ROOT_PATH . 'public' . DS . 'temp_latex' . DS;
if (!is_dir($temp_dir)) {
mkdir($temp_dir, 0755, true);
}
// 生成唯一的文件名
$filename = 'article_' . $p_info['p_article_id'] . '_' . time();
$tex_file = $temp_dir . $filename . '.tex';
$pdf_file = $temp_dir . $filename . '.pdf';
// 写入LaTeX文件
file_put_contents($tex_file, $latex_content);
// 执行LaTeX编译命令生成PDF
$command = sprintf(
'cd %s && pdflatex -interaction=nonstopmode -output-directory=%s %s',
escapeshellarg($temp_dir),
escapeshellarg($temp_dir),
escapeshellarg($tex_file)
);
// 执行命令
$output = [];
$return_var = 0;
exec($command, $output, $return_var);
// 检查PDF是否生成成功
if (!file_exists($pdf_file) || filesize($pdf_file) == 0) {
return jsonError('PDF生成失败请检查LaTeX内容或系统环境');
}
// 移动PDF到正式目录
$pdf_dir = ROOT_PATH . 'public' . DS . 'latex_pdfs' . DS;
if (!is_dir($pdf_dir)) {
mkdir($pdf_dir, 0755, true);
}
$final_pdf_path = $pdf_dir . $filename . '.pdf';
rename($pdf_file, $final_pdf_path);
// 清理临时文件
if (file_exists($tex_file)) {
unlink($tex_file);
}
// 清理辅助文件(.aux, .log等)
$aux_file = $temp_dir . $filename . '.aux';
$log_file = $temp_dir . $filename . '.log';
if (file_exists($aux_file)) unlink($aux_file);
if (file_exists($log_file)) unlink($log_file);
// 返回PDF路径
$relative_path = 'latex_pdfs/' . $filename . '.pdf';
return jsonSuccess([
'pdf_url' => $relative_path,
'message' => 'PDF生成成功'
]);
} catch (\Exception $e) {
return jsonError('生成过程中发生错误: ' . $e->getMessage());
}
}
/**
* 构建LaTeX文档内容
* @param $p_info
* @param $authors
* @param $organs
* @param $main_contents
* @param $references
* @return string
*/
private function buildLatexContent($p_info, $authors, $organs, $main_contents, $references)
{
// 构建机构映射
$organ_map = [];
foreach ($organs as $index => $organ) {
$organ_map[$organ['p_article_organ_id']] = $index + 1;
}
// LaTeX文档开始
$latex = '\documentclass[twocolumn]{article}' . "\n";
$latex .= '\usepackage[utf8]{inputenc}' . "\n";
$latex .= '\usepackage[T1]{fontenc}' . "\n";
$latex .= '\usepackage{geometry}' . "\n";
$latex .= '\usepackage{graphicx}' . "\n";
$latex .= '\usepackage{amsmath}' . "\n";
$latex .= '\usepackage{amsfonts}' . "\n";
$latex .= '\usepackage{amssymb}' . "\n";
$latex .= '\usepackage{setspace}' . "\n";
$latex .= '\usepackage{titlesec}' . "\n";
$latex .= '\usepackage{hyperref}' . "\n";
$latex .= '\usepackage{caption}' . "\n";
$latex .= '\usepackage{multicol}' . "\n";
$latex .= '\usepackage{abstract}' . "\n";
$latex .= '\geometry{left=1.5cm,right=1.5cm,top=2.5cm,bottom=2.5cm}' . "\n";
$latex .= '\setstretch{1.5}' . "\n";
$latex .= '\title{' . $this->escapeLatexText($p_info['title']) . '}' . "\n";
// 处理作者和机构
if (!empty($authors)) {
$author_text = '';
$affiliations = [];
foreach ($authors as $author) {
if ($author_text !== '') {
$author_text .= ', ';
}
$author_text .= $this->escapeLatexText($author['first_name'] . ' ' . $author['last_name']);
// 获取作者的机构
$author_organs = $this->production_article_author_to_organ_obj
->where('p_article_author_id', $author['p_article_author_id'])
->where('state', 0)
->select();
foreach ($author_organs as $ao) {
if (isset($organ_map[$ao['p_article_organ_id']])) {
$author_text .= '$^{' . $organ_map[$ao['p_article_organ_id']] . '}$';
}
}
if ($author['is_report'] == 1) {
$author_text .= '$^{*}$';
}
}
$latex .= '\author{' . $author_text . "\n";
// 添加机构信息
foreach ($organs as $index => $organ) {
$latex .= '\\\\$' . ($index + 1) . '$ ' . $this->escapeLatexText($organ['organ_name']) . "\n";
}
if (!empty($authors)) {
// 查找通讯作者
$corresponding_authors = array_filter($authors, function($author) {
return $author['is_report'] == 1;
});
if (!empty($corresponding_authors)) {
$corr_author = reset($corresponding_authors);
$latex .= '\\\\$*$ Corresponding author: ' .
$this->escapeLatexText($corr_author['email']) . "\n";
}
}
$latex .= '}' . "\n";
}
$latex .= '\date{}' . "\n";
$latex .= '\begin{document}' . "\n";
$latex .= '\maketitle' . "\n";
// 摘要
if (!empty($p_info['abstract'])) {
$latex .= '\begin{abstract}' . "\n";
$latex .= $this->escapeLatexText($p_info['abstract']) . "\n";
$latex .= '\end{abstract}' . "\n";
}
// 关键词
if (!empty($p_info['keywords'])) {
$latex .= '\textbf{Keywords:} ' . $this->escapeLatexText($p_info['keywords']) . "\n";
$latex .= '\sectionbreak' . "\n";
}
// 正文内容
$in_section = false;
$section_count = 0;
foreach ($main_contents as $content) {
$text = trim($content['content']);
// 跳过空内容
if (empty($text)) {
continue;
}
// 检查是否是标题
$clean_text = strip_tags($text);
$lower_text = strtolower($clean_text);
// 判断是否为章节标题
if (stripos($lower_text, 'introduction') === 0 ||
stripos($lower_text, 'methods') === 0 ||
stripos($lower_text, 'results') === 0 ||
stripos($lower_text, 'discussion') === 0 ||
stripos($lower_text, 'conclusion') === 0 ||
stripos($lower_text, 'references') === 0) {
// 结束前一节
if ($in_section) {
$latex .= "\n" . '\sectionbreak' . "\n";
}
// 开始新节
$section_count++;
$section_title = $this->escapeLatexText($clean_text);
$latex .= '\section{' . $section_title . '}' . "\n";
$in_section = true;
}
// 检查是否是图片或表格占位符
else if (preg_match('/<img[^>]*imageId=[\'"]([^\'"]+)[\'"][^>]*>/i', $text, $img_matches)) {
$image_id = $img_matches[1];
// 这里可以添加图片处理逻辑
$latex .= '% 图片插入位置 (ID: ' . $image_id . ')' . "\n";
$latex .= '\begin{figure}[htbp]' . "\n";
$latex .= '\centering' . "\n";
$latex .= '\includegraphics[width=0.8\textwidth]{image_' . $image_id . '}' . "\n";
$latex .= '\caption{图片说明}' . "\n";
$latex .= '\end{figure}' . "\n";
}
else if (preg_match('/<table[^>]*tableId=[\'"]([^\'"]+)[\'"][^>]*>/i', $text, $table_matches)) {
$table_id = $table_matches[1];
// 这里可以添加表格处理逻辑
$latex .= '% 表格插入位置 (ID: ' . $table_id . ')' . "\n";
$latex .= '\begin{table}[htbp]' . "\n";
$latex .= '\centering' . "\n";
$latex .= '\caption{表格说明}' . "\n";
$latex .= '\begin{tabular}{|c|c|c|}' . "\n";
$latex .= '\hline' . "\n";
$latex .= '列1 & 列2 & 列3 \\\\' . "\n";
$latex .= '\hline' . "\n";
$latex .= '% 表格数据' . "\n";
$latex .= '\hline' . "\n";
$latex .= '\end{tabular}' . "\n";
$latex .= '\end{table}' . "\n";
}
// 普通段落文本
else {
// 移除HTML标签并转义特殊字符
$plain_text = $this->escapeLatexText(strip_tags($text));
$latex .= $plain_text . "\n\n";
}
}
// 参考文献
if (!empty($references)) {
$latex .= '\section*{References}' . "\n";
$latex .= '\begin{thebibliography}{99}' . "\n";
foreach ($references as $index => $ref) {
$ref_text = isset($ref['refer_frag']) ? $ref['refer_frag'] : $ref['refer_content'];
$latex .= '\bibitem{} ' . $this->escapeLatexText($ref_text) . "\n";
}
$latex .= '\end{thebibliography}' . "\n";
}
$latex .= '\end{document}' . "\n";
return $latex;
}
/**
* 转义LaTeX特殊字符
* @param string $text
* @return string
*/
private function escapeLatexText($text)
{
// 移除HTML标签
$text = strip_tags($text);
// 转义LaTeX特殊字符
$escape_chars = [
'\\' => '\\textbackslash{}',
'&' => '\\&',
'%' => '\\%',
'$' => '\\$',
'#' => '\\#',
'_' => '\\_',
'{' => '\\{',
'}' => '\\}',
'~' => '\\textasciitilde{}',
'^' => '\\textasciicircum{}',
'"' => '\\"{}',
'\'' => '\\\'{}',
'<' => '\\textless{}',
'>' => '\\textgreater{}',
];
foreach ($escape_chars as $char => $replacement) {
$text = str_replace($char, $replacement, $text);
}
return $text;
}
}

View File

@@ -50,57 +50,57 @@ class Production extends Base
}
$article_info = $this->article_obj->where('article_id', $data['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');
}
// $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 = $this->ts_base_url . "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'];
// $url = $this->ts_base_url . "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'];
// return jsonSuccess($file_runs);
//整理信息
$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;
}
// $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!");
}
// if (!isset($frag['main'])) {
// return jsonError("manuscript file error!");
// }
$insert['main'] = isset($frag['main']) ? json_encode($frag['main']) : '';
$insert['main'] = '';//isset($frag['main']) ? json_encode($frag['main']) : '';
$insert['article_id'] = $data['article_id'];
$insert['journal_id'] = $article_info['journal_id'];
$insert['ctime'] = time();
@@ -108,13 +108,13 @@ class Production extends Base
//将主体内容写入数据库
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);
}
// 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);
// }
return jsonSuccess([]);
}
@@ -260,21 +260,22 @@ class Production extends Base
*/
public function getProductionMains()
{
$data = $this->request->post();
$rule = new Validate([
"p_article_id" => "require"
]);
if (!$rule->check($data)) {
return jsonError($rule->getError());
}
$p_info = $this->production_article_obj->where('p_article_id', $data['p_article_id'])->find();
$frag = $this->getProductionMainImgs($data['p_article_id']);
if (count($frag) == 0) {
return jsonError("create error");
}
$re['mains'] = $frag;
$re['production'] = $p_info;
return jsonSuccess($re);
die("stop service!");
// $data = $this->request->post();
// $rule = new Validate([
// "p_article_id" => "require"
// ]);
// if (!$rule->check($data)) {
// return jsonError($rule->getError());
// }
// $p_info = $this->production_article_obj->where('p_article_id', $data['p_article_id'])->find();
// $frag = $this->getProductionMainImgs($data['p_article_id']);
// if (count($frag) == 0) {
// return jsonError("create error");
// }
// $re['mains'] = $frag;
// $re['production'] = $p_info;
// return jsonSuccess($re);
}
/**
@@ -282,30 +283,31 @@ class Production extends Base
*/
public function getProductionMainsByDoi()
{
$data = $this->request->post();
$rule = new Validate([
'doi' => 'require'
]);
if (!$rule->check($data)) {
return jsonError($rule->getError());
}
$a = explode('/', $data['doi']);
$pro_info = $this->production_article_obj->where('doi', $a[1])->where('state', 2)->find();
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");
}
$re['mains'] = $frag;
$re['production'] = $pro_info;
return jsonSuccess($re);
die("stop service");
// $data = $this->request->post();
// $rule = new Validate([
// 'doi' => 'require'
// ]);
// if (!$rule->check($data)) {
// return jsonError($rule->getError());
// }
// $a = explode('/', $data['doi']);
// $pro_info = $this->production_article_obj->where('doi', $a[1])->where('state', 2)->find();
// 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");
// }
// $re['mains'] = $frag;
// $re['production'] = $pro_info;
// return jsonSuccess($re);
}
@@ -314,117 +316,117 @@ class Production extends Base
* @return void
*
*/
public function delProductionMain()
{
$data = $this->request->post();
$rule = new Validate([
'p_main_id' => 'require'
]);
if (!$rule->check($data)) {
return jsonError($rule->getError());
}
$this->production_article_main_obj->where('p_main_id', $data['p_main_id'])->update(['state' => 1]);
return jsonSuccess([]);
}
// public function delProductionMain()
// {
// $data = $this->request->post();
// $rule = new Validate([
// 'p_main_id' => 'require'
// ]);
// if (!$rule->check($data)) {
// return jsonError($rule->getError());
// }
// $this->production_article_main_obj->where('p_main_id', $data['p_main_id'])->update(['state' => 1]);
// return jsonSuccess([]);
// }
/**添加主体文章图片
* @return void
*/
public function addProductionMainImg()
{
$data = $this->request->post();
$rule = new Validate([
'p_article_id' => 'require',
"pre_type" => "require",
"body" => "require",
"content" => "require",
"width" => "require",
"note" => "require"
]);
if (!$rule->check($data)) {
return jsonError($rule->getError());
}
$insert['p_article_id'] = $data['p_article_id'];
if ($data['pre_type'] == "main") {
$insert['p_main_id'] = $data['body'];
} else {
$insert['pre_id'] = $data['body'];
}
$insert['content'] = $data['content'];
$insert['width'] = $data['width'];
$insert['title'] = $data['title'];
$insert['note'] = $data['note'];
$this->production_article_main_img_obj->insert($insert);
return jsonSuccess([]);
}
// public function addProductionMainImg()
// {
// $data = $this->request->post();
// $rule = new Validate([
// 'p_article_id' => 'require',
// "pre_type" => "require",
// "body" => "require",
// "content" => "require",
// "width" => "require",
// "note" => "require"
// ]);
// if (!$rule->check($data)) {
// return jsonError($rule->getError());
// }
// $insert['p_article_id'] = $data['p_article_id'];
// if ($data['pre_type'] == "main") {
// $insert['p_main_id'] = $data['body'];
// } else {
// $insert['pre_id'] = $data['body'];
// }
// $insert['content'] = $data['content'];
// $insert['width'] = $data['width'];
// $insert['title'] = $data['title'];
// $insert['note'] = $data['note'];
// $this->production_article_main_img_obj->insert($insert);
// return jsonSuccess([]);
// }
/**删除mainimg
* @return void
*/
public function delProductionMainImg()
{
$data = $this->request->post();
$rule = new Validate([
'p_main_img_id' => 'require'
]);
if (!$rule->check($data)) {
return jsonError($rule->getError());
}
$p_img_info = $this->production_article_main_img_obj->where('p_main_img_id', $data['p_main_img_id'])->find();
$next_info = $this->production_article_main_img_obj->where('pre_id', $p_img_info['p_main_img_id'])->find();
if ($next_info) {
if ($p_img_info['p_main_id'] == 0) {
$this->production_article_main_img_obj->where('p_main_img_id', $next_info['p_main_img_id'])->update(['pre_id' => $p_img_info['pre_id']]);
} else {
$this->production_article_main_img_obj->where('p_main_img_id', $next_info['p_main_img_id'])->update(['p_main_id' => $p_img_info['p_main_id']]);
}
}
$this->production_article_main_img_obj->where('p_main_img_id', $data['p_main_img_id'])->update(['state' => 1]);
return jsonSuccess([]);
}
// public function delProductionMainImg()
// {
// $data = $this->request->post();
// $rule = new Validate([
// 'p_main_img_id' => 'require'
// ]);
// if (!$rule->check($data)) {
// return jsonError($rule->getError());
// }
// $p_img_info = $this->production_article_main_img_obj->where('p_main_img_id', $data['p_main_img_id'])->find();
// $next_info = $this->production_article_main_img_obj->where('pre_id', $p_img_info['p_main_img_id'])->find();
// if ($next_info) {
// if ($p_img_info['p_main_id'] == 0) {
// $this->production_article_main_img_obj->where('p_main_img_id', $next_info['p_main_img_id'])->update(['pre_id' => $p_img_info['pre_id']]);
// } else {
// $this->production_article_main_img_obj->where('p_main_img_id', $next_info['p_main_img_id'])->update(['p_main_id' => $p_img_info['p_main_id']]);
// }
// }
// $this->production_article_main_img_obj->where('p_main_img_id', $data['p_main_img_id'])->update(['state' => 1]);
// return jsonSuccess([]);
// }
/**编辑mainimg
* @return void
*/
public function editProductionMainImg()
{
$data = $this->request->post();
$rule = new Validate([
'p_main_img_id' => 'require',
"width" => "require",
"content" => "require",
"note" => "require"
]);
if (!$rule->check($data)) {
return jsonError($rule->getError());
}
$update['width'] = $data['width'];
$update['content'] = $data['content'];
$update['title'] = $data['title'];
$update['note'] = $data['note'];
$this->production_article_main_img_obj->where('p_main_img_id', $data['p_main_img_id'])->update($update);
return jsonSuccess([]);
}
// public function editProductionMainImg()
// {
// $data = $this->request->post();
// $rule = new Validate([
// 'p_main_img_id' => 'require',
// "width" => "require",
// "content" => "require",
// "note" => "require"
// ]);
// if (!$rule->check($data)) {
// return jsonError($rule->getError());
// }
// $update['width'] = $data['width'];
// $update['content'] = $data['content'];
// $update['title'] = $data['title'];
// $update['note'] = $data['note'];
// $this->production_article_main_img_obj->where('p_main_img_id', $data['p_main_img_id'])->update($update);
// return jsonSuccess([]);
// }
/**
* 编辑main内容
* @return \think\response\Json|void
*
*/
public function editProductionMain()
{
$data = $this->request->post();
$rule = new Validate([
'p_main_id' => 'require',
'content' => 'require'
]);
if (!$rule->check($data)) {
return jsonError($rule->getError());
}
$update['content'] = trim($data['content']);
$this->production_article_main_obj->where('p_main_id', $data['p_main_id'])->update($update);
return jsonSuccess([]);
}
// public function editProductionMain()
// {
// $data = $this->request->post();
// $rule = new Validate([
// 'p_main_id' => 'require',
// 'content' => 'require'
// ]);
// if (!$rule->check($data)) {
// return jsonError($rule->getError());
// }
// $update['content'] = trim($data['content']);
// $this->production_article_main_obj->where('p_main_id', $data['p_main_id'])->update($update);
// return jsonSuccess([]);
// }
public function pushMainToWeb()
@@ -451,24 +453,24 @@ class Production extends Base
* @return void
*
*/
public function mainGptcheck()
{
$data = $this->request->post();
$rule = new Validate([
'p_main_id' => 'require'
]);
if (!$rule->check($data)) {
return jsonError($rule->getError());
}
$main_info = $this->production_article_main_obj->where('p_main_id', $data['p_main_id'])->find();
if (mb_strlen($main_info['content']) < 20) {
return trim($main_info['content']);
}
$res = object_to_array(json_decode(pushGpt('请将以下内容按照医学期刊的标准校对,不要改变原意,主要是对格式和拼写的校对,将<b></b><i></i>这四个标签保留,将校对好的内容返回 ' . trim($main_info['content']))));
$r = $res['choices'][0]['message']['content'];
$re['content'] = $r;
return jsonSuccess($re);
}
// public function mainGptcheck()
// {
// $data = $this->request->post();
// $rule = new Validate([
// 'p_main_id' => 'require'
// ]);
// if (!$rule->check($data)) {
// return jsonError($rule->getError());
// }
// $main_info = $this->production_article_main_obj->where('p_main_id', $data['p_main_id'])->find();
// if (mb_strlen($main_info['content']) < 20) {
// return trim($main_info['content']);
// }
// $res = object_to_array(json_decode(pushGpt('请将以下内容按照医学期刊的标准校对,不要改变原意,主要是对格式和拼写的校对,将<b></b><i></i>这四个标签保留,将校对好的内容返回 ' . trim($main_info['content']))));
// $r = $res['choices'][0]['message']['content'];
// $re['content'] = $r;
// return jsonSuccess($re);
// }
public function getPublicMains()
{
@@ -1835,26 +1837,26 @@ class Production extends Base
/**
* gpt校对main内容
*/
public function freshMain()
{
$data = $this->request->post();
$rule = new Validate([
'p_article_id' => 'require'
]);
if (!$rule->check($data)) {
return jsonError($rule->getError());
}
$list = $this->production_article_main_obj->where('p_article_id', $data['p_article_id'])->where('state', 0)->select();
foreach ($list as $v) {
if ($v['content'] == '' || strlen($v['content']) < 60) {
$this->production_article_main_obj->where('p_main_id', $v['p_main_id'])->update(['content_g' => $v['content']]);
} else {
Queue::push('app\api\job\gpt@fresh', $v, 'gpt');
}
}
return jsonSuccess([]);
}
// public function freshMain()
// {
// $data = $this->request->post();
// $rule = new Validate([
// 'p_article_id' => 'require'
// ]);
// if (!$rule->check($data)) {
// return jsonError($rule->getError());
// }
// $list = $this->production_article_main_obj->where('p_article_id', $data['p_article_id'])->where('state', 0)->select();
// foreach ($list as $v) {
// if ($v['content'] == '' || strlen($v['content']) < 60) {
// $this->production_article_main_obj->where('p_main_id', $v['p_main_id'])->update(['content_g' => $v['content']]);
// } else {
// Queue::push('app\api\job\gpt@fresh', $v, 'gpt');
// }
// }
//
// return jsonSuccess([]);
// }