This commit is contained in:
王金磊
2023-04-23 09:29:55 +08:00
parent fed98c4397
commit 7e8f5d6612
10 changed files with 437 additions and 24 deletions

View File

@@ -183,6 +183,8 @@ class Article extends Base
//增加审稿意见信息
foreach ($res as $key => $val) {
$cache_review = $this->article_reviewer_obj
->field("t_article_reviewer.*,t_article_reviewer_question.rated")
->join("t_article_reviewer_question","t_article_reviewer_question.art_rev_id = t_article_reviewer.art_rev_id",'left')
->where("t_article_reviewer.article_id", $val['article_id'])
->where("t_article_reviewer.state", 'in', [1, 2, 3])
->select();

View File

@@ -2,16 +2,19 @@
namespace app\api\controller;
use think\Controller;
use app\api\controller\Base;
use think\Cache;
use think\Db;
use think\Queue;
use think\Env;
use think\Validate;
/**
* Description of Auto
*
* @author jgll2
*/
class Auto extends Controller
class Auto extends Base
{
//put your code here
@@ -227,6 +230,150 @@ class Auto extends Controller
}
// 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");
$mes['role'] = "user";
$mes['content'] = "hello";
// Request data
$data = array(
'model' => 'gpt-3.5-turbo',
'messages' => [$mes],
'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'
]);
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().$data['message']);
$d['ckey'] = $ckey;
Queue::push('app\api\job\gpt@fire', $d, "gpt");
$re['ckey'] = $ckey;
return jsonSuccess($re);
}
/**
* 获取动态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);
}
/**
* 推送邮件提醒作者修回稿件
@@ -312,6 +459,19 @@ class Auto extends Controller
}
}
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);
}
/**
* 自动审稿主方法
*/
@@ -324,6 +484,7 @@ class Auto extends Controller
}
}
/**
* 处理过期审稿
*/

View File

@@ -64,6 +64,7 @@ class Base extends Controller
protected $production_article_frag_obj = '';
protected $apply_reviewer_obj = '';
public function __construct(\think\Request $request = null)
{
parent::__construct($request);
@@ -253,5 +254,11 @@ class Base extends Controller
}
public function getCvs($user_id){
$list = $this->user_cv_obj->where('user_id',$user_id)->where('state',0)->select();
return $list;
}
}
?>

View File

@@ -1562,13 +1562,9 @@ class Reviewer extends Base
->select();
$count = $this->reviewer_to_journal_obj->where('t_reviewer_to_journal.journal_id', 'in', $jous)->where($gradewhere)->where('t_reviewer_to_journal.state', 0)->count();
}
foreach($res as $k => $v){
$res[$k]['major_title'] = getMajorStr($v['major']);
// $major_res = $this->reviewer_major_obj->where('major_id', $v['major'])->column('title');
// $res[$k]['major_title'] = $major_res ? $major_res[0] : '';
// $cmajor_res = $this->reviewer_major_obj->where('major_id', $v['cmajor'])->column('title');
// $res[$k]['cmajor_title'] = $cmajor_res ? $cmajor_res[0] : '';
$res[$k]['cvs'] = $this->getCvs($v['user_id']);
}
return json(['code' => 0, 'data' => $res, 'total' => $count]);
}
@@ -1673,7 +1669,7 @@ class Reviewer extends Base
$where['t_reviewer_to_journal.reviewer_id'] = ['not in',$noids];
$where['t_reviewer_to_journal.state'] = 0;
if(isset($data['keywords'])&&$data['keywords']!=''){
$where['t_user_reviewer_info.introduction|t_user_reviewer_info.field|t_user.account|t_user.email|t_user.realname'] = ['like',"%" . $data["keywords"] . "%"];
$where['t_user_reviewer_info.field|t_user.account|t_user.email|t_user.realname'] = ['like',"%" . $data["keywords"] . "%"];
}
if(isset($data['major_id'])&&$data['major_id']!=0){
$where['t_user_reviewer_info.major'] = $data['major_id'];

View File

@@ -4,6 +4,7 @@ namespace app\api\controller;
use app\api\controller\Base;
use think\Validate;
use think\Queue;
class Ucenter extends Base{
@@ -122,7 +123,7 @@ class Ucenter extends Base{
}
// $ids = $this->reviewer_to_journal_obj->where('reviewer_id',$data['user_id'])->where('state',0)->where('is_yboard',0)->column('journal_id');
$ids = $this->user_to_yboard_obj->where('user_id',$data['user_id'])->where('start_date','<=',time())->where('end_date',">=",time())->where('state',0)->column("journal_id");
$journals = $this->journal_obj->where('journal_id','in',$ids)->where('state',0)->select();
$journals = $this->journal_obj->where('journal_id','not in',$ids)->where('state',0)->select();
$re['journals'] = $journals;
return jsonSuccess($re);
}
@@ -143,7 +144,46 @@ class Ucenter extends Base{
$insert['user_id'] = $data['user_id'];
$insert['journal_id'] = $data['journal_id'];
$insert['ctime'] = time();
$this->apply_yboard_obj->insert($insert);
$id = $this->apply_yboard_obj->insertGetId($insert);
$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',$journal_info['editor_id'])->find();
//发送邮件给用户
$dd = "Dear Dr. ".$user_info['realname'].",<br/><br/>";
$dd .= "We are writing to inform you that the Editorial Office has received your application for the position of Young Scientist Board Member of <i>".$journal_info['title']."</i> journal. Your application is currently under review and has been assigned the application number TMR-".$journal_info['abbr']."-".$id.".<br/><br/>";
$dd .= "We would like to take this opportunity to briefly introduce you to the rights and obligations of a Youth Scientist Board Member.<br/><br/>";
$dd .= "Rights:<br/><br/>";
$dd .= "1. Electronic Certificate: As a Young Scientist Board Member, you will receive an electronic certificate to acknowledge your position in our publication.<br/>";
$dd .= "2. Opportunity for Advancement: Outstanding Young Scientist Board Member may be considered as potential candidates for the Editorial Board.<br/>";
$dd .= "3. Special Issues: You will have the opportunity to apply for a special Issue to expand your influence and that of your team.<br/><br/>";
$dd .= "Obligations:<br/><br/>";
$dd .= "1. Peer Review: As a Young Scientist Board Member, you will be required to review and assess 3-5 manuscripts per year, based on your area of research.<br/>";
$dd .= "2. Active Promotion: You should actively promote our publication in your academic and professional circles and recommend quality manuscripts to scholars in your network.<br/>";
$dd .= "3. Provide Feedback: You should provide constructive feedback and suggestions to improve the direction and style of our publication. If feasible, you may also attend small forums or conferences to represent our publication.<br/><br/>";
$dd .= "We appreciate your interest in becoming a Young Scientist Board Member and we will inform you of the outcome of your application as soon as possible. If you have any questions or concerns, please do not hesitate to contact us.<br/><br/><br/>";
$dd .= 'Sincerely,<br>Editorial Office<br>';
$dd .= $journal_info['title'] . '<br>';
$dd .= 'Email: ' . $journal_info['email'] . '<br>';
$dd .= 'Website: ' . $journal_info['website'] . '<br>';
$maidata['email'] = $user_info['email'];
$maidata['title'] = $journal_info['title'];
$maidata['content'] = $dd;
$maidata['tmail'] = $journal_info['email'];
$maidata['tpassword'] = $journal_info['epassword'];
Queue::push('app\api\job\mail@fire', $maidata, "tmail");
//发送邮件给编辑
$vv = "Dear editor,<br/><br/>";
$vv .= "Please check the new application for Young Scientist Board Member for ".$journal_info['title']." Journal.";
$mai['email'] = $editor_info['email'];
$mai['title'] = $journal_info['title'];
$mai['content'] = $vv;
$mai['tmail'] = $journal_info['email'];
$mai['tpassword'] = $journal_info['epassword'];
Queue::push('app\api\job\mail@fire', $mai, "tmail");
return jsonSuccess([]);
}
@@ -155,6 +195,13 @@ class Ucenter extends Base{
$journal = $this->journal_obj->where('journal_id',$v['journal_id'])->find();
$cl = $this->user_to_yboard_obj->where('user_id',$user_id)->where('journal_id',$v['journal_id'])->select();
$journal['sd'] = $cl;
$journal['article_num'] = $this->article_obj->where('user_id',$user_id)->where('state',5)->where('journal_id',$v['journal_id'])->count();
$journal['reviewer_num'] = $this->article_reviewer_obj
->join("t_article","t_article.article_id = t_article_reviewer.article_id","left")
->where('t_article_reviewer.reviewer_id',$user_id)
->where('t_article.journal_id',$v['journal_id'])
->where('t_article_reviewer.state','in',[1,2,3])
->count();
$frag[] = $journal;
}
return $frag;

View File

@@ -247,6 +247,9 @@ class User extends Base
$ca_arr[] = $c;
}
$list[$k]['sd'] = $ca_arr;
//增加发文量和审稿量字段
// $this->article_obj->where('user_id',$v['user_id'])->where('state')
}
$count = $this->user_to_yboard_obj->join("t_user",'t_user.user_id = t_user_to_yboard.user_id','left')->join("t_user_reviewer_info",'t_user_reviewer_info.reviewer_id = t_user.user_id','left')->where($where)->count();
$re['yboards'] = $list;
@@ -418,6 +421,9 @@ class User extends Base
if(isset($data['keywords'])&&trim($data['keywords'])!=''){
$where['t_user.account|t_user.email|t_user.realname'] = ['like',"%".trim($data['keywords'])."%"];
}
if(isset($data['year'])&&$data['year']!=0){
$where['t_user_author.stage_year'] = $data['year'];
}
$list = $this->user_author_obj
->join([['t_user','t_user.user_id = t_user_author.user_id','left'],['t_user_reviewer_info','t_user_reviewer_info.reviewer_id=t_user.user_id','left']])
->where($where)
@@ -834,13 +840,24 @@ class User extends Base
public function getUserBlackList()
{
$data = $this->request->post();
$rule = new Validate([
'pageIndex'=>'require',
'pageSize'=>'require'
]);
if(!$rule->check($data)){
return jsonError($rule->getError());
}
$where['t_user_black.black_state'] = 0;
if(isset($data['keywords'])&&trim($data['keywords'])!=''){
$where["t_user.account|t_user.realname|t_user.email"] = ["like","%".trim($data['keywords'])."%"];
}
$limit_start = ($data['pageIndex'] - 1) * $data['pageSize'];
$list = $this->user_black_obj
->field("t_user.account,t_user.email,t_user.realname,t_user_black.*")
->join('t_user', 't_user.user_id = t_user_black.user_id', 'left')
->where('t_user_black.black_state', 0)
->where($where)
->limit($limit_start, $data['pageSize'])->select();
$count = $this->user_black_obj->where('black_state', 0)->count();
$count = $this->user_black_obj->join('t_user', 't_user.user_id = t_user_black.user_id', 'left')->where($where)->count();
$re['blacks'] = $list;
$re['count'] = $count;
return jsonSuccess($re);
@@ -886,14 +903,37 @@ class User extends Base
}
$ids = $this->journal_obj->where('editor_id',$data['editor_id'])->column('journal_id');
$list = $this->apply_yboard_obj
->field("t_journal.title,t_apply_yboard.*,t_user.account,t_user.email,t_user.realname")
->field("t_journal.title ,t_apply_yboard.*,t_apply_yboard.ctime ap_time,t_user.*,t_user_reviewer_info.*")
->join("t_journal",'t_journal.journal_id = t_apply_yboard.journal_id','left')
->join("t_user","t_user.user_id = t_apply_yboard.user_id",'left')
->join("t_user_reviewer_info","t_user_reviewer_info.reviewer_id = t_user.user_id",'left')
->where('t_apply_yboard.journal_id','in',$ids)->where('t_apply_yboard.state',0)->select();
foreach($list as $k => $v){//补充简历信息
$cac = $this->user_cv_obj->where('user_id',$v['user_id'])->where('state',0)->select();
$list[$k]['cvs'] = $cac;
}
$re['applys'] = $list;
return jsonSuccess($re);
}
/**
* 获取用户列表为了发送邮件
*/
public function getUserForPushEmail(){
$num = $this->request->post('num');
$list = $this->user_obj->join("t_user_reviewer_info","t_user_reviewer_info.reviewer_id = t_user.user_id",'left')->where('t_user.state',0)->page($num,1000)->select();
$re['list'] = $list;
return jsonSuccess($re);
}
public function getAshUserForPushEmail(){
$num = $this->request->post('num');
$list = $this->user_ash_obj->where('major',52)->page($num,1000)->select();
// $list = $this->user_ash_obj->where("ash_id",">",3635)->where('major',52)->page($num,1000)->select();
$re['list'] = $list;
return jsonSuccess($re);
}
// public function delYboardApply(){
// $data = $this->request->post();
// $rules = new Validate([
@@ -935,6 +975,44 @@ class User extends Base
$insert['ctime'] = $start_time;
$this->user_to_yboard_obj->insert($insert);
$this->apply_yboard_obj->where('ap_yboard_id',$data['ap_yboard_id'])->update(['state'=>1]);
//同意成为青年科学家后,将其添加到审稿人
$check_reviewer = $this->reviewer_to_journal_obj->where('journal_id',$app_info['journal_id'])->where('reviewer_id',$app_info['user_id'])->find();
if(!$check_reviewer){//如果不存在那么添加审稿人到对应期刊下面
$insert_reviewer['reviewer_id'] = $app_info['user_id'];
$insert_reviewer['journal_id'] = $app_info['journal_id'];
$insert_reviewer['account'] = $user_info['account'];
$insert_reviewer['journal_title'] = $journal_info['title'];
$insert_reviewer['ctime'] = time();
$this->reviewer_to_journal_obj->insert($insert_reviewer);
}
//发送邮件提醒用户//发送邮件给用户
$dd = "Dear Dr. ".$user_info['realname'].",<br/><br/>";
$dd .= "It is my great pleasure to extend my warmest congratulations to you on being selected as a Young Scientist Board Member for <i>".$journal_info['title']."</i> Journal.<br/><br/>";
$dd .= "As a member of the Young Scientist Board, you will be an integral part of the peer-review process and will play a crucial role in ensuring the quality and rigor of the journal's content. Your contributions will be invaluable in shaping the direction of the journal and advancing scholarship in your field.<br/><br/>";
$dd .= "You can download the Young Scientist Board certificate from the personal center system: https://submission.tmrjournals.com/<br/><br/>";
$dd .= "The rights and duties of the members of the Young Scientist Board are as follows:<br/><br/>";
$dd .= "Rights:<br/><br/>";
$dd .= "1. Electronic Certificate: As a Young Scientist Board Member, you will receive an electronic certificate to acknowledge your position in our publication.<br/>";
$dd .= "2. Opportunity for Advancement: Outstanding Youth Editorial Board Members may be considered as potential candidates for the Editorial Board.<br/>";
$dd .= "3. Special Issues: You will have the opportunity to apply for a special Issue to expand your influence and that of your team.<br/><br/>";
$dd .= "Obligations:<br/><br/>";
$dd .= "1. Peer Review: As a Youth Scientist Board Member, you will be required to review and assess 3-5 manuscripts per year, based on your area of research.<br/>";
$dd .= "2. Active Promotion: You should actively promote our publication in your academic and professional circles and recommend quality manuscripts to scholars in your network.<br/>";
$dd .= "3. Provide Feedback: You should provide constructive feedback and suggestions to improve the direction and style of our publication. If feasible, you may also attend small forums or conferences to represent our publication.<br/><br/>";
$dd .= "We look forward to working with you and benefiting from your insights, expertise, and dedication. We are confident that your contributions will make a significant impact on the journal and the academic community as a whole.<br/><br/>";
$dd .= "Once again, congratulations on your appointment as a Young Scientist Board Member for <i>".$journal_info['title']."</i>. We are honored to have you on board and look forward to collaborating with you.<br/><br/>";
$dd .= 'Sincerely,<br>Editorial Office<br>';
$dd .= $journal_info['title'] . '<br>';
$dd .= 'Email: ' . $journal_info['email'] . '<br>';
$dd .= 'Website: ' . $journal_info['website'] . '<br>';
$maidata['email'] = $user_info['email'];
$maidata['title'] = $journal_info['title'];
$maidata['content'] = $dd;
$maidata['tmail'] = $journal_info['email'];
$maidata['tpassword'] = $journal_info['epassword'];
Queue::push('app\api\job\mail@fire', $maidata, "tmail");
return jsonSuccess([]);
}
@@ -990,7 +1068,30 @@ class User extends Base
if (!$rules->check($data)) {
return jsonError($rules->getError());
}
$app_info = $this->apply_yboard_obj->where('ap_yboard_id',$data['ap_yboard_id'])->find();
$user_info = $this->user_obj->where('user_id',$app_info['user_id'])->find();
$journal_info = $this->journal_obj->where('journal_id',$app_info['journal_id'])->find();
$this->apply_yboard_obj->where('ap_yboard_id',$data['ap_yboard_id'])->update(['state'=>1]);
//发送邮件给用户
$dd = "Dear Dr. ".$user_info['realname'].",<br/><br/>";
$dd .= "Thank you for your interest in serving as a Young Scientist Board Member for <i>".$journal_info['title']."</i>. After careful consideration of your application and a thorough review of your qualifications and experience, we regret to inform you that your application has been denied.<br/><br/>";
$dd .= "Please note that this decision was not a reflection of your skills or qualifications. We received many strong applications, and the selection process was highly competitive. The decision was based on a number of factors, including the qualifications of other candidates, the needs of the journal, and our assessment of how you would fit into the journal's goals and objectives.<br/><br/>";
$dd .= "We appreciate the time and effort you put into your application, and we encourage you to continue pursuing your academic and professional goals. We also welcome you to apply for future opportunities with <i>".$journal_info['title']."</i> or other publications as they become available.<br/><br/>";
$dd .= "Once again, we regret that we are unable to offer you a position as a Young Scientist Board Member at this time. We wish you all the best in your academic and professional pursuits.<br/><br/>";
$dd .= 'Sincerely,<br>Editorial Office<br>';
$dd .= $journal_info['title'] . '<br>';
$dd .= 'Email: ' . $journal_info['email'] . '<br>';
$dd .= 'Website: ' . $journal_info['website'] . '<br>';
$maidata['email'] = $user_info['email'];
$maidata['title'] = $journal_info['title'];
$maidata['content'] = $dd;
$maidata['tmail'] = $journal_info['email'];
$maidata['tpassword'] = $journal_info['epassword'];
Queue::push('app\api\job\mail@fire', $maidata, "tmail");
return jsonSuccess([]);
}