user_obj = Db::name('user'); $this->captcha_obj = Db::name('captcha'); $this->article_obj = Db::name('article'); $this->user_act_obj = Db::name('user_act'); $this->admin_obj = Db::name('admin'); $this->user_reviewer_obj = Db::name('user_reviewer_apply'); $this->journal_obj = Db::name('journal'); $this->reviewer_major_obj = Db::name('reviewer_major'); $this->reviewer_to_journal_obj = Db::name('reviewer_to_journal'); $this->user_reviewer_info_obj = Db::name('user_reviewer_info'); $this->user_msg_obj = Db::name('user_msg'); $this->chief_to_journal_obj = Db::name('chief_to_journal'); $this->board_to_journal_obj = Db::name('board_to_journal'); $this->reviewer_from_author_obj = Db::name('reviewer_from_author'); $this->article_author_obj = Db::name('article_author'); $this->user_black_obj = Db::name('user_black'); $this->user_to_special_obj = Db::name('user_to_special'); $this->user_register_check_obj = Db::name('user_register_check'); $this->user_cert_obj = Db::name('user_cert'); $this->apply_board_obj = Db::name('apply_board'); $this->apply_yboard_obj = Db::name('apply_yboard'); $this->user_author_obj = Db::name('user_author'); $this->user_score_log_obj = Db::name('user_score_log'); $this->user_index_log_obj = Db::name('user_index_log'); $this->article_reviewer_obj = Db::name('article_reviewer'); $this->user_ash_obj = Db::name('user_ash'); $this->major_obj = Db::name('major'); $this->user_to_yboard_obj = Db::name('user_to_yboard'); $this->country_obj = Db::name('country'); $this->user_log_obj = Db::name('user_log'); $this->article_reviewer_question_obj = Db::name('article_reviewer_question'); $this->article_msg_obj = Db::name('article_msg'); $this->article_file_obj = Db::name('article_file'); $this->article_transfer_obj = Db::name('article_transfer'); $this->login_auto_obj = Db::name('login_auto'); $this->major_to_journal_obj = Db::name('major_to_journal'); $this->article_dialog_obj = Db::name('article_dialog'); $this->article_proposal_obj = Db::name('article_proposal'); $this->article_response_to_reviewer_obj = Db::name('article_response_to_reviewer'); $this->user_reviewer_recommend_obj = Db::name('user_reviewer_recommend'); $this->email_log_obj = Db::name('email_log'); $this->email_template_obj = Db::name('email_template'); $this->production_article_obj = Db::name('production_article'); $this->company_top_obj = Db::name('company_top'); $this->user_cv_obj = Db::name('user_cv'); $this->ts_obj = Db::name('ts'); $this->ts_refer_obj = Db::name('ts_refer'); $this->ts_frag_obj = Db::name('ts_frag'); $this->online_obj = Db::name('online'); $this->article_reviewer_file_obj = Db::name('article_reviewer_file'); $this->production_article_obj = Db::name('production_article'); $this->production_article_author_obj = Db::name('production_article_author'); $this->production_article_organ_obj = Db::name('production_article_organ'); $this->production_article_refer_obj = Db::name('production_article_refer'); $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->apply_reviewer_obj = Db::name("apply_reviewer"); $this->promotion_obj = Db::name("promotion"); $this->promotion_email_obj = Db::name("promotion_email"); $this->article_reviewer_repeat_obj = Db::name("article_reviewer_repeat"); $this->board_group_obj = Db::name("board_group"); $this->committee_to_journal_obj = Db::name("committee_to_journal"); $this->editor_to_journal_obj = Db::name("editor_to_journal"); } public function pdfAddProof($article_id) { $p_info = $this->production_article_obj->where('article_id', $article_id)->where('state', 0)->find(); vendor('fpdf.fpdf'); vendor('fpdi/fpdi'); $pdf = new \FPDI(); $pageCount = $pdf->setSourceFile(ROOT_PATH . 'public' . DS . $p_info['file_pdf']); for ($pageNo = 1; $pageNo <= $pageCount; $pageNo++) { $templateId = $pdf->importPage($pageNo); $size = $pdf->getTemplateSize($templateId); if ($size['w'] > $size['h']) $pdf->AddPage('L', array($size['w'], $size['h'])); else $pdf->AddPage('P', array($size['w'], $size['h'])); $pdf->image(ROOT_PATH . 'public' . DS . 'pdf' . DS . 'bg2.png', 55, 25, 80); $pdf->image(ROOT_PATH . 'public' . DS . 'pdf' . DS . 'bg2.png', 55, 155, 80); $pdf->useTemplate($templateId); } $pdf->Output(ROOT_PATH . 'public' . DS . 'proofPDF' . DS . $article_id . '.pdf'); if ($p_info['file_sub'] != '' && substr($p_info['file_sub'], strripos($p_info['file_sub'], '.') + 1) == 'pdf') { $pdf1 = new \FPDI(); $pageCount1 = $pdf1->setSourceFile(ROOT_PATH . 'public' . DS . "articleSUB" . DS . $p_info['file_sub']); for ($pageNo = 1; $pageNo <= $pageCount1; $pageNo++) { $templateId1 = $pdf1->importPage($pageNo); $size = $pdf1->getTemplateSize($templateId1); if ($size['w'] > $size['h']) $pdf1->AddPage('L', array($size['w'], $size['h'])); else $pdf1->AddPage('P', array($size['w'], $size['h'])); $pdf1->image(ROOT_PATH . 'public' . DS . 'pdf' . DS . 'bg2.png', 55, 25, 80); $pdf1->image(ROOT_PATH . 'public' . DS . 'pdf' . DS . 'bg2.png', 55, 155, 80); $pdf1->useTemplate($templateId1); } $pdf1->Output(ROOT_PATH . 'public' . DS . 'proofPDF' . DS . $article_id . 'SUB.pdf'); } } public function createYboardCert($user_info, $journal_info, $start_time, $year) { if (!is_dir(ROOT_PATH . 'public' . DS . 'cert' . DS . $journal_info['journal_id'])) { mkdir(ROOT_PATH . 'public' . DS . 'cert' . DS . $journal_info['journal_id']); } $sj_num = rand(1000, 9999); $template = ROOT_PATH . 'public' . DS . 'cert' . DS . 'yboard_template.png'; $ziti = ROOT_PATH . 'public' . DS . 'zhengshu' . DS . 'siyuan.ttf'; $ziti1 = ROOT_PATH . 'public' . DS . 'zhengshu' . DS . 'Georgia0.ttf'; $image = \think\Image::open($template); $ys = date("F Y", $start_time) . " to " . date("F Y", strtotime("+ " . $year . " year", $start_time)); $image->text($user_info['realname'], $ziti, 45, '#000000', [1060, 750]) ->text($ys, $ziti1, 32, '#C49A6C', [1370, 1015]) ->text(date("Y.m.d", $start_time), $ziti, 25, '#000000', [500, 1280]) ->text($journal_info['title'], $ziti1, 36, '#C49A6C', [860, 930]) ->save(ROOT_PATH . 'public' . DS . 'cert' . DS . $journal_info['journal_id'] . DS . $user_info['user_id'] . '_yboard_' . date('Y', $start_time) . $sj_num . '.png'); return $journal_info['journal_id'] . DS . $user_info['user_id'] . '_yboard_' . date('Y', $start_time) . $sj_num . '.png'; } public function majorids($major_id) { $frag[] = $major_id; $list = $this->major_obj->where('pid', $major_id)->select(); foreach ($list as $v) { $cache = self::majorids($v['major_id']); $frag = array_merge($frag, $cache); } return $frag; } public function delOneRefer($p_refer_id) { $refer_info = $this->production_article_refer_obj->where('p_refer_id', $p_refer_id)->find(); if (!$refer_info) { return ""; } $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', $p_refer_id)->update(['state' => 1]); } public function getMajorShu($major) { if ($major == 0) { return ''; } $res = $this->major_obj->where('major_id', $major)->find(); if ($res['pid'] == 1) { return $res['major_id']; } $p = self::getMajorShu($res['pid']); return $p . ',' . $res['major_id']; } public function getMajorStr($major_id) { $frag = ''; $major_info = $this->major_obj->where('major_id', $major_id)->find(); if ($major_info == null) { return ''; } if ($major_info['major_level'] == 1) { return 'Medicine'; } else { $frag = $this->getMajorStr($major_info['pid']) . ' > ' . $major_info['major_title']; } return $frag; } public function getMajorOne($major_id) { $major_info = $this->major_obj->where('major_id', $major_id)->find(); return $major_info['major_title']; } public function save_article_file($article_id, $user_id, $username, $url, $type_name) { //首先确定数据库里面是否存在此数据 $res = $this->article_file_obj->where(['file_url' => $url])->find(); if ($res) { //编辑的时候不能重复存储 return true; } else if ($type_name == 'picturesAndTables' && trim($url) == '') { return true; } else if ($type_name == 'coverLetter' && trim($url) == '') { return true; } else if ($type_name == 'totalpage' && trim($url) == '') { return true; } else if ($type_name == "supplementary" && trim($url) == '') { return true; } $insert_data['article_id'] = $article_id; $insert_data['user_id'] = $user_id; $insert_data['username'] = $username; $insert_data['file_url'] = $url; $insert_data['type_name'] = $type_name; $insert_data['ctime'] = time(); return $this->article_file_obj->insertGetId($insert_data); } public function getArticleAuthors($article_id) { $res = $this->article_author_obj->where('article_id', $article_id)->where('state', 0)->select(); $frag = ''; foreach ($res as $v) { $frag .= $v['firstname'] . $v['lastname'] . ','; } return substr($frag, 0, -1); } public function MyaddEx() { $data = $this->request->post(); $this->addProductionEx($data['article_id']); } public function addProductionEx($article_id) { $check = $this->production_article_obj->where('article_id', $article_id)->where('state', 0)->find(); if ($check) { return 'Instance already exists'; } $article_info = $this->article_obj->where('article_id', $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!"); } $insert['main'] = isset($frag['main']) ? json_encode($frag['main']) : ''; $insert['article_id'] = $article_id; $insert['journal_id'] = $article_info['journal_id']; $insert['ctime'] = time(); $p_article_id = $this->production_article_obj->insertGetId($insert); //将主体内容写入数据库 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([]); } public function getBoardsForJournal($journal_id, $aar = false) { $ca_board = []; $boards = $this->board_to_journal_obj ->field("t_board_to_journal.*,t_board_group.group_name,t_user.account,t_user.email,t_user.realname,t_user.icon,t_user.google_index,t_user.google_time,t_user.wos_index,t_user.wos_time,t_user_reviewer_info.*") ->join("t_board_group", "t_board_group.board_group_id = t_board_to_journal.board_group_id", "left") ->join("t_user", "t_user.user_id = t_board_to_journal.user_id", "left") ->join("t_user_reviewer_info", "t_user_reviewer_info.reviewer_id=t_board_to_journal.user_id", "left") ->where('t_board_to_journal.journal_id', $journal_id) ->where('t_board_to_journal.state', 0) ->select(); foreach ($boards as $val) { if ($aar) { $article1 = $this->article_obj->where('user_id', $val['user_id'])->where('journal_id', $val['journal_id'])->where('state', 5)->where('ctime', ">", strtotime("-1 year"))->select(); $article11 = $this->article_obj->where('user_id', $val['user_id'])->where('journal_id', $val['journal_id'])->where('ctime', ">", strtotime("-1 year"))->select(); $ids = $this->article_author_obj->where('email', $val['email'])->column("article_id"); $article2 = $this->article_obj->where('state', 5)->where('journal_id', $val['journal_id'])->where('article_id', "in", $ids)->select(); $article22 = $this->article_obj->where('journal_id', $val['journal_id'])->where('article_id', "in", $ids)->select(); $articles = my_array_merge($article1, $article2); $articles_all = my_array_merge($article11, $article22); $reviewes = $this->article_reviewer_obj->join("t_article", "t_article.article_id = t_article_reviewer.article_id", "left")->where('t_article_reviewer.reviewer_id', $val['user_id'])->where('t_article.journal_id', $journal_id)->where('t_article_reviewer.ctime', ">", strtotime("-1 year"))->where('t_article_reviewer.state', "in", [1, 2, 3])->select(); $val['articles'] = $articles; $val['articles_all'] = $articles_all; $val['reviewes'] = $reviewes; } if ($val['type'] == 0) {//主编 $ca_board['main'][] = $val; } elseif ($val['type'] == 1) {//副主编 $ca_board['remain'][] = $val; } else {//编委会成员 if ($val['board_group_id'] == 0) { $ca_board['member']['nogroup'][] = $val; } else { $ca_board['member'][$val['group_name']][] = $val; } } } return $ca_board; } public function getCvs($user_id) { $list = $this->user_cv_obj->where('user_id', $user_id)->where('state', 0)->select(); return $list; } /**获取标准化用户库的人 * @return void */ public function getLibraryList($lib, $type, $body, $china_type, $pageIndex, $pageSize) { $frag = []; if ($lib == "user") {//正式库 $where["t_user.state"] = 0; $where["t_user.no_email"] = 0; if ($type == "major") { $where['t_user_reviewer_info.major'] = ["in", $this->majorids($body)]; } else { $where['t_user_reviewer_info.field'] = ["like", "%" . $body . "%"]; } if ($china_type == 1) { $where['t_user_reviewer_info.country'] = "China"; } elseif ($china_type == 2) { $where['t_user_reviewer_info.country'] = ["<>", "China"]; } $list = $this->user_obj ->join("t_user_reviewer_info", "t_user_reviewer_info.reviewer_id = t_user.user_id", 'left') ->where($where) ->page($pageIndex, $pageSize) ->select(); //规整化数据整理 foreach ($list as $v) { $ca['email'] = $v['email']; $ca['name'] = $v['realname'] == "" ? $v['account'] : $v['realname']; $ca['type'] = "user"; $ca['id'] = $v['user_id']; $ca['major'] = $v['major']; $frag[] = $ca; } } elseif ($lib == 'author') {//作者库 $exist = "select * from t_user_author where user_id = t_user.user_id"; $where["t_user.state"] = 0; $where["t_user.no_email"] = 0; if ($type == "major") { $where['t_user_reviewer_info.major'] = ["in", $this->majorids($body)]; } else { $where['t_user_reviewer_info.field'] = ["like", "%" . $body . "%"]; } if ($china_type == 1) { $where['t_user_reviewer_info.country'] = "China"; } elseif ($china_type == 2) { $where['t_user_reviewer_info.country'] = ["<>", "China"]; } $list = $this->user_obj ->join("t_user_reviewer_info", "t_user_reviewer_info.reviewer_id = t_user.user_id", 'left') ->where($where) ->whereExists($exist) ->page($pageIndex, $pageSize) ->select(); //规整化数据整理 foreach ($list as $v) { $ca['email'] = $v['email']; $ca['name'] = $v['realname'] == "" ? $v['account'] : $v['realname']; $ca['type'] = "user"; $ca['id'] = $v['user_id']; $ca['major'] = $v['major']; $frag[] = $ca; } } else {//灰库 $list = []; $where['state'] = 0; $where['no_email'] = 0; if ($type == "major") { $where['major'] = ["in", $this->majorids($body)]; } else { $where['field'] = ["like", "%" . $body . "%"]; } if ($china_type == 1) { $where['country'] = "China"; } elseif ($china_type == 2) { $where['country'] = ["<>", "China"]; } $list = $this->user_ash_obj ->where($where) ->page($pageIndex, $pageSize) ->select(); //规整化数据整理 foreach ($list as $v) { $ca['email'] = $v['email']; $ca['name'] = $v['name']; $ca['type'] = "ash"; $ca['id'] = $v['ash_id']; $ca['major'] = $v['major']; $frag[] = $ca; } } return $frag; } public function getJournalCycle($journal_id) { $journal_info = $this->journal_obj->where('journal_id', $journal_id)->find(); $frag = ""; if ($journal_info['cycle'] == 1) { $frag = "Monthly"; } elseif ($journal_info['cycle'] == 2) { $frag = "Bimonthly"; } elseif ($journal_info['cycle'] == 3) { $frag = "Quarterly"; } else { $frag = "Continuities"; } return $frag; } public function creatUserCode($str) { $hashids = hashids::instance(8, "tmrjournals"); 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 refuseReferIndex($p_article_id) { $p_info = $this->production_article_refer_obj->where('p_article_id', $p_article_id)->where('state', 0)->where('index', ">", 0)->find(); if ($p_info) { return; } $list = $this->production_article_refer_obj->where('p_article_id', $p_article_id)->where('state', 0)->select(); foreach ($list as $k => $v) { $this->production_article_refer_obj->where('p_refer_id', $v['p_refer_id'])->update(['index' => $k]); } } 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; } /**创建空production实例,应对main和refers * @return void */ public function createEmptyProduction($web_article) { $insert['title'] = $web_article['title']; $insert['type'] = $web_article['type']; $ree = explode("/", $web_article['doi']); $insert['doi'] = isset($ree[1]) ? $ree[1] : ''; $insert['w_article_id'] = $web_article['article_id']; $insert['proof_state'] = 2; $insert['state'] = 2; return $this->production_article_obj->insertGetId($insert); } } ?>