Files
tougao/application/api/controller/Auto.php
2025-04-08 11:40:14 +08:00

840 lines
41 KiB
PHP
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
namespace app\api\controller;
use app\api\controller\Base;
use think\Cache;
use think\Db;
use think\Queue;
use think\Env;
use think\Validate;
use GuzzleHttp\Client;
/**
* Description of Auto
*
* @author jgll2
*/
class Auto extends Base
{
//put your code here
protected $rev_to_jour_obj = '';
protected $reviewer_obj = '';
protected $reviewer_info_obj = '';
public function __construct(\think\Request $request = null)
{
parent::__construct($request);
$this->rev_to_jour_obj = Db::name('reviewer_to_journal');
$this->reviewer_obj = Db::name('article_reviewer');
$this->reviewer_info_obj = Db::name('user_reviewer_info');
}
public function ZQTest(){
$data = $this->request->post();
$rule = new Validate([
"url"=>"require"
]);
if(!$rule->check($data)){
return jsonError($rule->getError());
}
$client = new Client();
$response = $client->request('GET', $data['url']);
$res = self::extractWeChatArticle($response);
return jsonSuccess($res);
// 获取响应内容
}
public function phpInfo(){
phpInfo();
}
private function extractWeChatArticle($htmlContent) {
$dom = new DOMDocument();
@$dom->loadHTML($htmlContent); // 加载HTML内容@是为了抑制加载HTML时的警告
// 通过XPath获取文章内容
$xpath = new DOMXPath($dom);
$nodes = $xpath->query('//div[@class="rich_media_content"]'); // 这个XPath会获取微信文章的主要内容
if ($nodes->length > 0) {
return $nodes->item(0)->nodeValue;
}
return null;
}
/**
* 推送邮件给审稿人提醒审稿人
*/
public function pushEmailForReviewer()
{
//筛选数据
$list = $this->article_reviewer_obj->where("state", "in", [0, 5])->select();
foreach ($list as $v) {
$cache_article = $this->article_obj->where("article_id", $v['article_id'])->find();
if ($cache_article["state"] != 2) {
continue;
}
$cache_t = intval((time() - $v["ctime"]) / 86400);
if ($cache_t == 14 || $cache_t == 21 || $cache_t == 28) {
$cache_journal = $this->journal_obj->where("journal_id", $cache_article['journal_id'])->find();
//查找审稿人信息
$cache_reviewer = $this->user_obj
->join("t_user_reviewer_info", "t_user_reviewer_info.reviewer_id = t_user.user_id", "left")
->where("t_user.user_id", $v['reviewer_id'])->find();
$tt = "Manuscript ID: " . $cache_article['accept_sn'] . "<br>";
$tt .= "Title:" . $cache_article['title'] . "<br>";
$tt .= "Dear Dr. " . ($cache_reviewer["realname"] == "" ? $cache_reviewer["account"] : $cache_reviewer["realname"]) . "<br><br>";
$tt .= "On " . date("d D Y", $v["ctime"]) . " we sent you a request to review a paper title " . $cache_article['title'] . ".<br><br>";
$tt .= "We have not yet received a response from you, possibly because the original invitation went astray. We would be grateful if you could let us know if you can carry out this review.<br><br>";
$tt .= '<a href="' . $this->creatLoginUrlForreviewer($cache_reviewer, $v['art_rev_id']) . '">Click here to review the article</a><br>';
$tt .= '<a href="' . $this->creatRejectUrlForReviewer($cache_reviewer, $v['art_rev_id']) . '">Click on the link to reject the review of this manuscript</a><br>';
$tt .= 'Your username:' . $cache_reviewer['account'] . '<br><br>';
$tt .= 'Your original password:123456qwe, if you have reset the password, please login with the new one or click the "<a href="https://submission.tmrjournals.com/retrieve">forgot password</a>".<br>';
$tt .= 'Sincerely,<br>Editorial Office<br>' . $cache_journal['title'] . '<br>';
$tt .= 'Email: ' . $cache_journal['email'] . '<br>';
$tt .= 'Website:<a href="' . $cache_journal['website'] . '">' . $cache_journal['website'] . '</a>';
$maidata['email'] = $cache_reviewer['email'];
$maidata['title'] = "Invitation to review manuscript for " . $cache_journal['title'] . " - Reminder";
$maidata['content'] = $tt;
$maidata['tmail'] = $cache_journal['email'];
$maidata['tpassword'] = $cache_journal['epassword'];
Queue::push('app\api\job\mail@fire', $maidata, "tmail");
// $sendUser=[
// 'title'=>"Invitation to review manuscript for " . $cache_journal['title'] . " - Reminder", // 邮件标题
// 'content'=>$tt,//邮件内容
// 'user_id'=>$v['reviewer_id'], //收件人ID
// 'email'=>$cache_reviewer['email'],// 收件人邮箱
// 'journal_id'=>$cache_journal['journal_id'], // 期刊ID
// 'sendEmail'=>$cache_journal['email'], // 期刊邮箱
// 'sendPassword'=>$cache_journal['epassword'], // 期刊密码
// 'from_name'=>"Invitation to review manuscript for " . $cache_journal['title'] . " - Reminder"
// ];
// Queue::push('app\api\job\domail@fire',$sendUser,'domail');
}
}
}
public function pushTestEmail()
{
$cache_reviewer = $this->user_obj->where('user_id', 54)->find();
$cache_journal = $this->journal_obj->where('journal_id', 1)->find();
$cache_article = $this->article_obj->where("article_id", 1700)->find();
$tt = "Manuscript ID: " . $cache_article['accept_sn'] . "<br>";
$tt .= "Title:" . $cache_article['title'] . "<br>";
$tt .= "Dear Dr. " . ($cache_reviewer["realname"] == "" ? $cache_reviewer["account"] : $cache_reviewer["realname"]) . "<br><br>";
$tt .= "We have not yet received a response from you, possibly because the original invitation went astray. We would be grateful if you could let us know if you can carry out this review.<br><br>";
$tt .= '<a href="' . $this->creatLoginUrlForreviewer($cache_reviewer, $cache_article['art_rev_id']) . '">Click here to review the article</a><br>';
$tt .= '<a href="' . $this->creatRejectUrlForReviewer($cache_reviewer, $cache_article['art_rev_id']) . '">Click on the link to reject the review of this manuscript</a><br>';
$tt .= 'Sincerely,<br>Editorial Office<br>' . $cache_journal['title'] . '<br>';
$tt .= 'Email: ' . $cache_journal['email'] . '<br>';
$tt .= 'Website:<a href="' . $cache_journal['website'] . '">' . $cache_journal['website'] . '</a>';
$maidata['email'] = $cache_reviewer['email'];
$maidata['title'] = "Invitation to review manuscript for " . $cache_journal['title'] . " - Reminder";
$maidata['content'] = $tt;
$maidata['tmail'] = $cache_journal['email'];
$maidata['tpassword'] = $cache_journal['epassword'];
Queue::push('app\api\job\mail@fire', $maidata, "tmail");
}
public function mypushemail(){
die("service stop");
$data = $this->request->post();
$rule = new Validate([
"num"=>"require"
]);
if(!$rule->check($data)){
return jsonError($rule->getError());
}
$list = $this->user_author_obj
->field("t_user.*")
->join("t_user","t_user.user_id = t_user_author.user_id","left")
->where('t_user_author.journal_title',"Traditional Medicine Research")
->where('t_user_author.stage_year',">","2021")
->page($data['num'],1000)
->select();
// $journal_info = $this->journal_obj->where('journal_id',1)->find();
// $l['email'] = "751475802@qq.com";
// $l['realname'] = "wangjinlei";
// $l1['email'] = "2714044218@qq.com";
// $l1['realname'] = "liuna";
// $list[] = $l;
// $list[] = $l1;
// return jsonSuccess($list);
foreach ($list as $v){
$tt = 'Dear Dr. ' . ($v['realname'] == '' ? $v['account'] : $v['realname']) . ',<br/><br/>';
$tt .= "Congratulations! Our Traditional Medicine Research Journal has achieved its first impact factor of 1.3. Thank you for your valuable contribution. We would like to express our sincere appreciation for your valuable contributions and for choosing our journal as a platform for sharing your groundbreaking research.<br/>Looking forward to your continued contributions in the future.<br/><br/>";
$tt .= "Sincerely,<br/>Editorial Office<br/>Traditional Medicine Research<br/>Email: tmr@tmrjournals.com<br/>Website:https://www.tmrjournals.com/tmr";
$ali['email'] = $v['email'];
$ali['title'] = "Traditional Medicine Research Achieves its First Impact Factor of 1.3";
$ali['content'] = $tt;
$ali['has_hb'] = 1;
// sendEmail($v['email'], $journal_info['title'], $journal_info['title'], $tt, $journal_info['email'], $journal_info['epassword']);
Queue::push('app\api\job\mail@promotion', $ali, "tmail");
}
}
public function changeExchangeRate(){
$res = myGet("https://v6.exchangerate-api.com/v6/575c78ea6173243d6c366814/latest/USD");
$r = object_to_array(json_decode($res));
$update['USD'] = 1;
$update['CNY'] = $r["conversion_rates"]['CNY'];
$update['NZD'] = $r["conversion_rates"]['NZD'];
$update['utime'] = time();
$this->exchange_rate_obj->where("id",1)->update($update);
return jsonSuccess([]);
}
public function reviewerRepeat(){
$repeats = $this->article_reviewer_repeat_obj->where("ctime","<",(time()-24*5*3600))->where("state",0)->delete(true);
// foreach ($repeats as $v){
// $ca_rev_info = $this->article_reviewer_obj->where('art_rev_id',$v['art_rev_id'])->find();
// if($ca_rev_info['state']==2){
// $com = 2;
// }elseif($ca_rev_info['state']==1){//大修的复审不需要做处理
// continue;
// }else{
// $com = 1;
// }
// $this->article_reviewer_repeat_obj->where('art_rev_rep_id',$v['art_rev_rep_id'])->update(["recommend"=>$com,"stime"=>time(),"state"=>1]);
// }
echo "done";
}
// public function cvComit(){
// $list = $this->user_reviewer_info_obj
// ->field('t_user.user_id,t_user.ctime,t_user_reviewer_info.qualifications')
// ->join("t_user","t_user.user_id = t_user_reviewer_info.reviewer_id",'left')
// ->where('t_user_reviewer_info.qualifications','<>','')
// ->select();
// foreach($list as $v){
// $check = $this->user_cv_obj->where('cv',$v['qualifications'])->find();
// if(!$v['user_id']||$check){
// continue;
// }
// $insert['user_id'] = $v['user_id'];
// $insert['cv'] = $v['qualifications'];
// $insert['ctime'] = $v['ctime'];
// $this->user_cv_obj->insert($insert);
// }
// dump($list);
// }
public function getUserqqqq()
{
$num = $this->request->post('num');
$limit_start = ($num - 1) * 1000;
$users = $this->user_obj->join("t_user_reviewer_info", 't_user_reviewer_info.reviewer_id = t_user.user_id', 'left')->limit($limit_start, 1000)->select();
$re['list'] = $users;
return jsonSuccess($re);
}
/**
* 补充doi缺失的全文内容
*/
// public function pushCrossrefForDoiB(){
// $url = "https://doi.crossref.org/servlet/deposit";
// $file = "D://cr396e3d57186c1f28fcb-6cc5.xml";
// $program['operation'] = "doDOICitUpload";
// $program['login_id'] = "books@tmrjournals.com";
// $program['login_passwd'] = "849192806pnX";
// $program['fname'] = $file;
// $res = myPost($url,$program);
// echo $res;
// // return jsonSuccess($res);
// }
private function readExcel($path)
{
$extension = substr($path, strrpos($path, '.') + 1);
vendor("PHPExcel.PHPExcel");
if ($extension == 'xlsx') {
$objReader = new \PHPExcel_Reader_Excel2007();
$objPHPExcel = $objReader->load($path);
} else if ($extension == 'xls') {
$objReader = new \PHPExcel_Reader_Excel5();
$objPHPExcel = $objReader->load($path);
}
$sheet = $objPHPExcel->getSheet(0);
$highestRow = $sheet->getHighestRow();
$frag = [];
$frag1 = [];
for ($i = 0; $i <= $highestRow; $i++) {
$full = $objPHPExcel->getActiveSheet()->getCell("A" . $i)->getValue();
$aa = $objPHPExcel->getActiveSheet()->getCell("B" . $i)->getValue();
if ($aa == '') {
continue;
}
// if(!in_array($aa,$frag1)){
// $frag1[] = $aa;
// $frag[] = ['email'=>$aa];
// }
$ch['full'] = $full;
$ch['aa'] = $aa;
$frag[] = $ch;
}
return $frag;
}
private function creatLoginUrlForreviewer($user, $article_id)
{
$code = md5(time() . rand(1000, 9999) . 'thinkphp');
$insert['user_id'] = $user['user_id'];
$insert['code'] = $code;
$insert['ctime'] = time();
$this->login_auto_obj->insert($insert);
$url = 'https://submission.tmrjournals.com/per_text?Art_id=' . $article_id . '&act=' . $code;
return $url;
}
private function creatRejectUrlForReviewer($user, $article_id)
{
$code = md5(time() . rand(1000, 9999) . 'thinkphp');
$insert['user_id'] = $user['user_id'];
$insert['code'] = $code;
$insert['ctime'] = time();
$this->login_auto_obj->insert($insert);
$url = 'https://submission.tmrjournals.com/per_text_fail?Art_id=' . $article_id . '&act=' . $code;
return $url;
}
// public function testGpt(){
// // die;
// $url = "https://api.openai.com/v1/chat/completions";
// // $url = "https://api.openai.com/v1/edits";
// $data = [];
// $data['model'] = "gpt-3.5-turbo";
// // $data['model'] = "text-davinci-edit-001";
// // $data['input'] = "Homogeneous Time Resolved Fluorescence (HTRF) assay is based on proximity induced fluorescence and can identify candidate compounds that can hinder interaction between hPD-1/hPD-L1 (both proteins need to be tagged). Briefly, this working system is constructed with addition of recombinant proteins, Tag1-PD-L1 and Tag2-PD-1, to 384-well plate. Anti-Tag1-EuK, anti-Tag2-XL665 and diluted solution of small-molecule compounds are added to corresponding wells and incubated at room temperature. Then microplate reader is used to detect the absorbance values at 665 nm and 620 nm at specified time points. The inhibitory ability of the compounds against PD-1/PD-L1 is calculated based on the ratio of readout values of 665nm/620nm at different concentrations.";
// // $data['instruction'] = "请帮我按照学术期刊的校对规则 将以下这段文字进行校对 并且同时逐一单独列出来 那些地方被校对了 目标是校对格式 不要改动文本内容 除非确认有拼写或语法错误";
// $mes['role'] = "user";
// $mes['content'] = "请帮我按照学术期刊的校对规则 将以下这段文字进行校对 并且同时逐一单独列出来 那些地方被校对了 目标是校对格式 不要改动文本内容 除非确认有拼写或语法错误 Background
// Parsley is a shiny green biennial medicinal and aromatic herb belonging to the Apiaceae (Umbelliferae) family [1,2]. It is natural to the Mediterranean region (Türkiye, Algeria, Tunisia) and it is now grown in many parts of the world [1].
// Moreover to its use as a food among the people, it is used against diseases such as urinary tract infections, menstrual pain, diabetes, hemorrhoids and as a diuretic, kidney stone lowering and blood pressure lowering.  In the literature, flavonoids, coumarins, xanthines, vitamins, minerals, and essential oil were reported in P. crispum various parts antioxidant, antibacterial, antifungal, antidiabetic, antihypertensive, The plant had antiplatelet, analgesic, antiinflammatory, antihepatotoxic, antinephrotoxic, anticancer, diuretic, estrogenic and neuroprotective activities.
// In this review, the botanical characteristics, ethnobotanical uses, phytochemical composition, pharmacological activities, clinical studies, drug interactions and toxicity of P. crispum are reported. PubMed, Science Direct, Scopus, SciFinder, and Google Scholar databases were used for the search. The search terms used were “Parsley”, “Petroselinum crispum”, “P. crispum”. In addition, some books from related fields were used as reference sources. Data from 1972 to 2022 were collected. All relevant clinical and preclinical studies were selected. The references of the selected articles were also checked to identify possible new research findings.";
// $data['messages'] = [$mes];
// // $data['prompt'] = "hello chatGpt!";
// $data['max_tokens'] = 2048;
// // $data['temperature'] = 0.2;
// // $data['top_p'] = 1;
// // $data['n'] = 1;
// $res = postGpt($url,$data);
// return jsonSuccess(json_decode($res));
// }
public function GptChar1()
{
// header('Content-Type: text/event-stream'); // 以事件流的形式告知浏览器进行显示
// header('Cache-Control: no-cache'); // 告知浏览器不进行缓存
// header('X-Accel-Buffering: no');
// OpenAI API endpoint
$url = 'https://api.openai.com/v1/chat/completions';
// OpenAI API key
$api_key = Env::get("gpt.api_key");
$mes1['role'] = "user";
$mes1['content'] = "黄瓜可以沾糖吃吗";
$mes2['role'] = "assistant";
$mes2['content'] = "黄瓜可以沾糖吃,但是一般情况下人们更倾向于将黄瓜作为蔬菜来食用,而不是作为水果来食用。如果您想要将黄瓜作为水果来食用,可以将其切成小块,然后沾上适量的糖粉,这样可以增加其甜度。但是需要注意的是,过量食用糖会对健康造成不良影响,建议适量食用。";
$mes3['role'] = "user";
$mes3['content'] = "那可以沾盐吃吗?";
$m[] = $mes1;
$m[] = $mes2;
$m[] = $mes3;
// dump([$m]);
// dump([$mes1,$mes2,$mes3]);
// die;
// Request data
$data = array(
'model' => 'gpt-3.5-turbo',
'messages' => $m,
'temperature' => 0.2,
'max_tokens' => 2048,
'n' => 1,
'stop' => '',
// 'stream' => true ,// Use streaming mode
);
// Create request headers
$headers = array(
'Content-Type: application/json',
'Authorization: Bearer ' . $api_key
);
// Create context for request
$context = stream_context_create(array(
'http' => array(
'method' => 'POST',
'header' => $headers,
'content' => json_encode($data),
'ignore_errors' => true
)
));
// Open connection to API endpoint
$fp = fopen($url, 'r', false, $context);
// Read response data
if ($fp) {
while (!feof($fp)) {
$chunk = fgets($fp);
echo $chunk;
// $cache = object_to_array(json_decode(substr($chunk,6)));
// if(isset($cache['choices'][0]['delta']['content'])){
// $cc = Cache::get("qweqwe")?Cache::get("qweqwe"):'';
// Cache::set("qweqwe",$cc.$cache['choices'][0]['delta']['content']);
// }
// ob_flush();
// flush();
}
fclose($fp);
} else {
return "Error: Unable to connect to OpenAI API";
}
// Display response data
// echo $response;
}
/**
* 创建gpt任务
*/
public function GptCreateChat(){
$data = $this->request->post();
$rule = new Validate([
'message'=>'require|array'
]);
if(!$rule->check($data)){
return jsonError($rule->getError());
}
$d['message'] = $data['message'];
// $mid = isset($data['mid'])?$data['mid']:"";
// $d['mid'] = $mid;
$ckey = md5(rand(1000,9999).time().rand(10000,99999));
$d['ckey'] = $ckey;
Queue::push('app\api\job\gpt@fire', $d, "gpt");
$re['ckey'] = $ckey;
return jsonSuccess($re);
}
/**
* 推送邮件到作者当文章推送到官网时
*/
public function pushEmailToAuthor(){
$data = $this->request->post();
$rule = new Validate([
''=>'require'
]);
if(!$rule->check($data)){
return jsonError($rule->getError());
}
}
/**
* 获取动态gpt内容
*/
public function AjaxForGpt(){
$data = $this->request->post();
$rule = new Validate([
'ckey'=>'require'
]);
if(!$rule->check($data)){
return jsonError($rule->getError());
}
$re['msg'] = Cache::get($data['ckey']);
return jsonSuccess($re);
}
/**
* 获取上下文id
*/
public function getContentMid(){
$data = $this->request->post();
$rule = new Validate([
'ckey'=>'require'
]);
if(!$rule->check($data)){
return jsonError($rule->getError());
}
$re['mid'] = Cache::get($data['ckey']."_id");
return jsonSuccess($re);
}
/**
* 推送邮件提醒作者修回稿件
*/
public function pushEmailForAuthor()
{
//筛选数据
$list = $this->article_obj->where("state", 4)->select();
foreach ($list as $v) {
$cache_t = intval((time() - $v["ttime"]) / 86400);
if ($v['type'] == 'A') {
if ($cache_t == 28 || $cache_t == 42 || $cache_t == 56) {
//查找文章内容
$cache_journal = $this->journal_obj->where("journal_id", $v['journal_id'])->find();
//查找作者信息
$cache_author = $this->user_obj->where("user_id", $v['user_id'])->find();
$tt = "Dear Dr. " . ($cache_author["realname"] == "" ? $cache_author["account"] : $cache_author["realname"]) . ",<br>";
$tt .= "We have send you the email about revision of your manuscript. According to our records you are almost reaching the deadline now. We look forward to receiving your revised article.<br><br>";
$tt .= "When preparing your revised manuscript, you are asked to carefully consider the reviewers' comments which are attached, and submit a revised versionand a list of responses to the comments before deadline. The revised parts in the manuscript should be highlighted with blue color.<br><br>";
$tt .= "If you feel that you will require more time to complete your revision, please let me know and I will update our records accordingly. If I can provide any further advice or assistance, please do not hesitate to contact me.<br><br><br>";
$tt .= 'Sincerely,<br>Editorial Office<br>' . $cache_journal['title'] . '<br>';
$tt .= 'Email: ' . $cache_journal['email'] . '<br>';
$tt .= 'Website:<a href="' . $cache_journal['website'] . '">' . $cache_journal['website'] . '</a>';
$maidata['email'] = $cache_author['email'];
$maidata['title'] = "Revision Due Date-" . $cache_journal['title'];
$maidata['content'] = $tt;
$maidata['tmail'] = $cache_journal['email'];
$maidata['tpassword'] = $cache_journal['epassword'];
Queue::push('app\api\job\mail@fire', $maidata, "tmail");
// $sendUser=[
// 'title'=>"Revision Due Date-" . $cache_journal['title'], // 邮件标题
// 'content'=>$tt,//邮件内容
// 'user_id'=>$cache_author['user_id'], //收件人ID
// 'email'=>$cache_author['email'],// 收件人邮箱
// 'journal_id'=>$cache_journal['journal_id'], // 期刊ID
// 'sendEmail'=>$cache_journal['email'], // 期刊邮箱
// 'sendPassword'=>$cache_journal['epassword'], // 期刊密码
// 'from_name'=>"Revision Due Date-" . $cache_journal['title']
// ];
// Queue::push('app\api\job\domail@fire',$sendUser,'domail');
}
} else {
if ($cache_t == 14 || $cache_t == 21 || $cache_t == 28) {
//查找文章内容
$cache_journal = $this->journal_obj->where("journal_id", $v['journal_id'])->find();
//查找作者信息
$cache_author = $this->user_obj->where("user_id", $v['user_id'])->find();
$tt = "Dear Dr. " . ($cache_author["realname"] == "" ? $cache_author["account"] : $cache_author["realname"]) . ",<br>";
$tt .= "We have send you the email about revision of your manuscript. According to our records you are almost reaching the deadline now. We look forward to receiving your revised article.<br><br>";
$tt .= "When preparing your revised manuscript, you are asked to carefully consider the reviewers' comments which are attached, and submit a revised versionand a list of responses to the comments before deadline. The revised parts in the manuscript should be highlighted with blue color.<br><br>";
$tt .= "If you feel that you will require more time to complete your revision, please let me know and I will update our records accordingly. If I can provide any further advice or assistance, please do not hesitate to contact me.<br><br><br>";
$tt .= 'Sincerely,<br>Editorial Office<br>' . $cache_journal['title'] . '<br>';
$tt .= 'Email: ' . $cache_journal['email'] . '<br>';
$tt .= 'Website:<a href="' . $cache_journal['website'] . '">' . $cache_journal['website'] . '</a>';
$maidata['email'] = $cache_author['email'];
$maidata['title'] = "Revision Due Date-" . $cache_journal['title'];
$maidata['content'] = $tt;
$maidata['tmail'] = $cache_journal['email'];
$maidata['tpassword'] = $cache_journal['epassword'];
Queue::push('app\api\job\mail@fire', $maidata, "tmail");
// $sendUser=[
// 'title'=>"Revision Due Date-" . $cache_journal['title'], // 邮件标题
// 'content'=>$tt,//邮件内容
// 'user_id'=>$cache_author['user_id'], //收件人ID
// 'email'=>$cache_author['email'],// 收件人邮箱
// 'journal_id'=>$cache_journal['journal_id'], // 期刊ID
// 'sendEmail'=>$cache_journal['email'], // 期刊邮箱
// 'sendPassword'=>$cache_journal['epassword'], // 期刊密码
// 'from_name'=>"Revision Due Date-" . $cache_journal['title']
// ];
// Queue::push('app\api\job\domail@fire',$sendUser,'domail');
}
}
}
}
public function ls_addyear()
{
$num = $this->request->post('num');
$url = "http://journalapi.tmrjournals.com/public/index.php/master/Datebase/getaaa";
$p['num'] = $num;
$res = object_to_array(json_decode(myPost($url, $p)));
$list = $res['data']['list'];
foreach ($list as $v) {
$this->user_author_obj->where('w_article_id', $v['article_id'])->update(['stage_year' => $v['stage_year']]);
}
return jsonSuccess($res);
}
/**
* 自动审稿主方法
*/
public function initAutoReview()
{
//查找对应状态的article列表
$alist = $this->article_obj->where('state', 2)->select();
foreach ($alist as $v) {
Queue::push('app\api\job\review@fire', $v, "emailtest");
}
}
/**
* 处理过期审稿
*/
public function overdue_reviewer()
{
die('Temporarily Out of Service');
$where['state'] = 0;
$where['ctime'] = ['lt', time() - 3600 * 24 * 14];
$revs = $this->article_reviewer_obj->where($where)->select();
foreach ($revs as $v) {
//审稿人失败次数+1
$this->user_obj->where('user_id', $v['reviewer_id'])->setInc('rd_num');
//此审稿案例超时
$this->article_reviewer_obj->where('art_rev_id', $v['art_rev_id'])->update(['state' => 4]);
}
}
/**
* 审查文章审稿人状态,返回结果
*/
public function checkrev($data)
{
die;
//查找审稿案例状态
$rev_list = $this->reviewer_obj->where('article_id', $data['article_id'])->where('state', '<>', 4)->select();
$journal_info = $this->journal_obj->where('journal_id', $data['journal_id'])->find();
$user_info = $this->user_obj->where('user_id', $data['user_id'])->find();
$editor_info = $this->user_obj->where('user_id', $data['editor_id'])->find();
//分析审稿人状况
$all = count($rev_list);
$s_num = 0; //初始数量
$p_num = 0; //通过数量
$np_num = 0; //不通过数量
foreach ($rev_list as $v) {
if ($v['state'] == 0) {
$s_num++;
} else if ($v['state'] == 1 || $v['state'] == 3) {
$p_num++;
} else {
$np_num++;
}
}
//分情况执行
if ($all == 0) {
//分配两次审稿人
$this->add_reviewer($data);
$this->add_reviewer($data);
return true;
} elseif ($all == 1) {
//分配一次审稿人
$this->add_reviewer($data);
return true;
} elseif ($all == 2) {
if ($s_num > 0) { //不做任何处理
return true;
}
if ($p_num == 2) { //通过
//更新文章状态
$this->article_obj->where('article_id', $data['article_id'])->update(['state' => 4, 'editor_act' => 1]);
//添加文章msg信息
$insert_data['article_id'] = $data['article_id'];
$insert_data['content'] = 'Review completed';
$insert_data['state_from'] = $data['state'];
$insert_data['state_to'] = 4;
$insert_data['ctime'] = time();
$this->article_msg_obj->insert($insert_data);
//添加通知信息
add_usermsg($data['user_id'], 'Your manuscript has new process', '/articleDetail?id=' . $data['article_id']);
//发送邮件通知编辑
$tt = $data['accept_sn'] . '<br>';
$tt .= 'Dear Dr. ' . ($user_info['realname'] == '' ? $user_info['account'] : $user_info['realname']) . ',<br>';
$tt .= 'Thank you for submitting the manuscript to ' . $journal_info['title'] . '. <br>';
$tt .= 'Please find the new comments in the "<a href="http://submission.tmrjournals.com/submission?journal=' . $journal_info['alias'] . '">AuthorCenter</a>", Please submit your revised manuscript within two weeks.<br><br>';
$tt .= 'If you need more time to revise, you can send E-mial to tell us.<br>';
$tt .= 'Sincerely,<br>Editorial Office<br>';
$tt .= $journal_info['title'] . '<br>';
$tt .= '<a href="https://www.tmrjournals.com/draw_up.html?issn=' . $journal_info['issn'] . '">Subscribe to this journal</a><br>';
$tt .= 'Email: ' . $journal_info['email'] . '<br>';
$tt .= 'Website: ' . $journal_info['website'];
sendEmail($user_info['email'], $journal_info['title'], $journal_info['title'], $tt, $journal_info['email'], $journal_info['epassword']);
} elseif ($np_num == 2) { //不通过
//发送邮件通知编辑
$tt = 'Reviewers final opinions on the manuscript ID' . $data['accept_sn'] . ' are rejection. Please login and deal with the next step of this manuscript manually.';
sendEmail($editor_info['email'], $journal_info['title'], $journal_info['title'], $tt, $journal_info['email'], $journal_info['epassword']);
} else { //一样一个增加一个审稿案例
$this->add_reviewer($data);
return true;
}
} elseif ($all == 3) {
if ($s_num > 0) { //不做任何处理
return true;
}
if ($p_num == 2) { //通过
//更新文章状态
$this->article_obj->where('article_id', $data['article_id'])->update(['state' => 4, 'editor_act' => 1]);
//添加文章msg信息
$insert_data['article_id'] = $data['article_id'];
$insert_data['content'] = 'Review completed';
$insert_data['state_from'] = $data['state'];
$insert_data['state_to'] = 4;
$insert_data['ctime'] = time();
$this->article_msg_obj->insert($insert_data);
//添加通知信息
add_usermsg($data['user_id'], 'Your manuscript has new process', '/articleDetail?id=' . $data['article_id']);
//发送邮件通知编辑
$tt = $data['accept_sn'] . '<br>';
$tt .= 'Dear Dr. ' . ($user_info['realname'] == '' ? $user_info['account'] : $user_info['realname']) . ',<br>';
$tt .= 'Thank you for submitting the manuscript to ' . $journal_info['title'] . '. <br>';
$tt .= 'Please find the new comments in the "<a href="http://submission.tmrjournals.com/submission?journal=' . $journal_info['alias'] . '">AuthorCenter</a>", Please submit your revised manuscript within two weeks.<br><br>';
$tt .= 'If you need more time to revise, you can send E-mial to tell us.<br>';
$tt .= 'Sincerely,<br>Editorial Office<br>';
$tt .= $journal_info['title'] . '<br>';
$tt .= '<a href="https://www.tmrjournals.com/draw_up.html?issn=' . $journal_info['issn'] . '">Subscribe to this journal</a><br>';
$tt .= 'Email: ' . $journal_info['email'] . '<br>';
$tt .= 'Website: ' . $journal_info['website'];
sendEmail($user_info['email'], $journal_info['title'], $journal_info['title'], $tt, $journal_info['email'], $journal_info['epassword']);
} else { //不通过
//发送邮件通知编辑
$tt = 'Reviewers final opinions on the manuscript ID' . $data['accept_sn'] . ' are rejection. Please login and deal with the next step of this manuscript manually.';
sendEmail($editor_info['email'], $journal_info['title'], $journal_info['title'], $tt, $journal_info['email'], $journal_info['epassword']);
}
}
}
/**
* 增加一个审稿人
*/
public function add_reviewer($article)
{
$journal_info = $this->journal_obj->where('journal_id', $article['journal_id'])->find();
$editor_info = $this->user_obj->where('user_id', $journal_info['editor_id'])->find();
//根据文章筛选候选人
$reviewer = $this->chose_reviewer($article);
$sendUser = [
'title' => $journal_info['title'], // 邮件标题
'journal_id' => $article['journal_id'], // 期刊ID
'sendEmail' => $journal_info['email'], // 期刊邮箱
'sendPassword' => $journal_info['epassword'], // 期刊密码
'from_name' => $journal_info['title']
];
if ($reviewer == null) { //没有查询到审稿人,执行提醒操作
//发送邮件到编辑,提醒需要手动添加审稿案例
$tt = 'Dear editor,<br>';
$tt .= 'There are no enough research area related reviewers in the reviewer list for manuscript ID ' . $article['accept_sn'] . ', please add reviewers for your journal or manual deal with this problem.<br><br>';
$tt .= 'TMR Publishing Group';
$sendUser['user_id'] = $editor_info['editor_id'];
$sendUser['email'] = $editor_info['email'];
$sendUser['content'] = $tt;
// Queue::push('app\api\job\domail@fire',$sendUser,'domail');
sendEmail($editor_info['email'], $journal_info['title'], $journal_info['title'], $tt, $journal_info['email'], $journal_info['epassword']);
} else { //查询到审稿人,执行添加操作
//将审稿时间定义至现在
$this->user_obj->where('user_id', $reviewer['user_id'])->update(['rtime' => time()]);
$article_info = $article;
$reviewer_info = $reviewer;
//增加信息到文章审稿表
$insert_data['reviewer_id'] = $reviewer['user_id'];
$insert_data['article_id'] = $article_info['article_id'];
$insert_data['editor_act'] = 1;
$insert_data['ctime'] = time();
$res = $this->article_reviewer_obj->insertGetId($insert_data);
//修改文章状态->审稿中
$this->article_obj->where('article_id', $article_info['article_id'])->update(['state' => 2]);
//添加article_msg信息
$insmsg_data['article_id'] = $article_info['article_id'];
$insmsg_data['content'] = '';
$insmsg_data['state_from'] = $article_info['state'];
$insmsg_data['state_to'] = 2;
$insmsg_data['ctime'] = time();
$this->article_msg_obj->insert($insmsg_data);
//发送email提醒审稿员
$tt = $article_info['accept_sn'] . '<br>';
$tt .= 'Dear Dr. ' . ($reviewer_info['realname'] == '' ? $reviewer_info['account'] : $reviewer_info['realname']) . '<br><br>';
$tt .= 'The manuscript entitled “' . $article_info['title'] . '” has'
. ' been submitted to the journal ' . $journal_info['title'] . '. The Editor-in-Chief would'
. ' be most grateful if you could offer an opinion regarding its suitability for publication'
. ' in the journal ' . $journal_info['title'] . '. <br>';
$tt .= 'Please bring into our knowledge if there is any potential Conflict of Interest. If you agree to review this manuscript, we ask you to complete your review and submit it by submission system within 10 days of receipt of the manuscript.<br><br>';
$tt .= 'Thank you for your consideration.<br> Look forward for your reply.<br>';
$tt .= '<a href="http://submission.tmrjournals.com/submission?journal=' . $journal_info['alias'] . '">ReviewerCenter</a><br>';
$tt .= 'Your username:' . $reviewer_info['account'] . '<br><br>';
$tt .= 'Sincerely,<br>Editorial Office<br>';
$tt .= $journal_info['title'] . '<br>';
$tt .= 'Email:' . $journal_info['email'] . '<br>';
$tt .= 'Website:' . $journal_info['website'];
$sendUser['user_id'] = $reviewer_info['editor_id'];
$sendUser['email'] = $reviewer_info['email'];
$sendUser['content'] = $tt;
// Queue::push('app\api\job\domail@fire',$sendUser,'domail');
sendEmail($reviewer_info['email'], $journal_info['title'], $journal_info['title'], $tt, $journal_info['email'], $journal_info['epassword']);
//记录userlog
$log_data['user_id'] = $article_info['editor_id'];
$log_data['type'] = 2;
$log_data['content'] = $editor_info['account'] . "(" . $editor_info['realname'] . "),添加了一个文章审稿实例:(" . $article_info['title'] . "-----" . $reviewer_info['account'] . "),添加时间是:" . date('Y-m-d H:i:s', time());
$log_data['ctime'] = time();
$this->user_log_obj->insert($log_data);
//添加usermsg
add_usermsg($reviewer['user_id'], 'You have new manuscript to be approved', '/reviewerArticleDetail?id=' . $res);
}
}
/**
* 筛选一个审稿人
*/
public function chose_reviewer($article)
{
//筛选符合期刊
$rev_list = $this->rev_to_jour_obj->where('journal_id', $article['journal_id'])->column('reviewer_id');
$fie_list = $this->reviewer_info_obj->where('major', $article['major_id'])->column('reviewer_id');
$u_list = $this->user_obj
->where('user_id', ['in', $rev_list], ['in', $fie_list]) //审核人属于某期刊,并且属于某个领域
->where('rtime', '<', time() - 3600 * 24 * 15) //审核人间隔时间
->order('rs_num desc')->select();
if ($u_list) {
return $u_list[0];
} else {
return null;
}
}
}