Files
tougao/application/api/controller/Monitor.php
2025-05-21 17:38:12 +08:00

829 lines
34 KiB
PHP

<?php
namespace app\api\controller;
use app\api\controller\Base;
use think\Db;
use think\Queue;
use think\Validate;
class Monitor extends Base
{
public function __construct(\think\Request $request = null)
{
parent::__construct($request);
}
/**获取期刊编委列表
* @return void
*/
public function getJournalBoards(){
$journals = $this->journal_obj->where('state',0)->select();
foreach ($journals as $k => $v){
$boards = $this->board_to_journal_obj
->field("t_board_to_journal.*,t_user.google_index,t_user.google_time,t_user.wos_index,t_user.wos_time")
->join("t_user","t_user.user_id = t_board_to_journal.user_id","left")
->where("t_board_to_journal.journal_id",$v['journal_id'])
->where('t_board_to_journal.state',0)
->select();
$ca_board = $this->getBoardsForJournal($v['journal_id']);
$journals[$k]["boards"] = $ca_board;
$journals[$k]['boards_count'] = count($boards);
$board_index = [];
$sum = 0;
foreach ($boards as $key => $val){
if($val['wos_index']>0){
$board_index[] = $val['wos_index']*1.5;
$sum += $val['wos_index']*1.5;
}elseif($val['google_index']>0){
$board_index[] = $val['google_index'];
$sum += $val['google_index'];
}
}
$journals[$k]['index_num'] = count($board_index);
$journals[$k]['median'] = count($board_index)==0?0:zw_array($board_index);
$journals[$k]['avg'] = count($board_index)==0?0:round($sum/count($board_index),2);
}
$re['journals'] = $journals;
return jsonSuccess($re);
}
/**获取编委
* @return void
*/
public function getboards(){
$data = $this->request->post();
$rule = new Validate([
"journal_id" => "require"
]);
if(!$rule->check($data)){
return jsonError($rule->getError());
}
$ca_board = $this->getBoardsForJournal($data['journal_id'],true);
$re['boards'] = $ca_board;
return jsonSuccess($re);
}
/**获取期刊年度总投稿量
* @return void
*/
public function getArticleNumByYear(){
$year = 2020;
$frag = [];
while ($year<=date("Y")){
$s_time = strtotime($year."-1-1");
$e_time = strtotime($year."-12-31");
$n = $this->article_obj->where("ctime",">",$s_time)->where("state",">",-1)->where("ctime","<",$e_time)->count();
$frag[$year] = $n;
$year++;
}
$re['articles'] = $frag;
return jsonSuccess($re);
}
public function getArticleNumByYearForEditor(){
$data = $this->request->post();
$rule = new Validate([
"user_id"=>"require"
]);
if(!$rule->check($data)){
return jsonError($rule->getError());
}
$journal_list = $this->journal_obj->where("editor_id",$data['user_id'])->where("state",0)->select();
if(count($journal_list)==0){
return jsonError("期刊为空");
}
$j_sql = '';
foreach ($journal_list as $v){
$j_sql .= "accept_sn like '".$v['abbr']."%' or ";
}
$j_sql = substr($j_sql,0,-4);
$year = Date("Y")-5;
$frag = [];
while ($year<=date("Y")){
$s_time = strtotime($year."-1-1");
$e_time = strtotime($year."-12-31");
$n = $this->article_obj->where("ctime",">",$s_time)->where("state",">",-1)->where("ctime","<",$e_time)->where($j_sql)->count();
$frag[$year] = $n;
$year++;
}
$re['articles'] = $frag;
return jsonSuccess($re);
}
/**获取文章数量通过年度分期刊
* @return void
*/
public function getArticleNumByYearForJournal(){
$journals = $this->journal_obj->where("state",0)->select();
$flag = [];
foreach ($journals as $k => $v){
$year = 2020;
$frag = [];
while ($year<=date("Y")){
$s_time = strtotime($year."-1-1");
$e_time = strtotime($year."-12-31");
$abbr = $v['abbr'];
if($abbr=="NTA"&&$year<2024){
$abbr = "MHM";
}
if($abbr=="PD"&&$year<2024){
$abbr = "PR";
}
$n = $this->article_obj->where("ctime",">",$s_time)->where("state",">",-1)->where("ctime","<",$e_time)->where("accept_sn","like",$abbr."%")->count();
$nj = $this->article_obj->where("ctime",">",$s_time)->where("state",">",-1)->where("ctime","<",$e_time)->where("accept_sn","like",$abbr."%")->where("journal_id","<>",$v['journal_id'])->count();
// $frag[$year."-".$month] = $n."/".$nj;
// $n = $this->article_obj->where("ctime",">",$s_time)->where("ctime","<",$e_time)->where("journal_id",$v['journal_id'])->count();
$frag[$year] = $n."/".$nj;
$year++;
}
$f['journal'] = $v;
$f['articles'] = $frag;
$flag[] = $f;
}
$re['data'] = $flag;
return jsonSuccess($re);
}
public function getArticleNumByYearAndJournalForEditor(){
$data = $this->request->post();
$rule = new Validate([
"user_id"=>"require"
]);
if(!$rule->check($data)){
return jsonError($rule->getError());
}
$journals = $this->journal_obj->where("state",0)->where("editor_id",$data['user_id'])->select();
$flag = [];
foreach ($journals as $k => $v){
$year = date("Y")-5;
$frag = [];
while ($year<=date("Y")){
$s_time = strtotime($year."-1-1");
$e_time = strtotime($year."-12-31");
$abbr = $v['abbr'];
if($abbr=="NTA"&&$year<2024){
$abbr = "MHM";
}
if($abbr=="PD"&&$year<2024){
$abbr = "PR";
}
$n = $this->article_obj->where("ctime",">",$s_time)->where("state",">",-1)->where("ctime","<",$e_time)->where("accept_sn","like",$abbr."%")->count();
$nj = $this->article_obj->where("ctime",">",$s_time)->where("state",">",-1)->where("ctime","<",$e_time)->where("accept_sn","like",$abbr."%")->where("journal_id","<>",$v['journal_id'])->count();
$frag[$year] = $n."/".$nj;
$year++;
}
$f['journal'] = $v;
$f['articles'] = $frag;
$flag[] = $f;
}
$re['data'] = $flag;
return jsonSuccess($re);
}
public function getArticleNumByYearAndJournalForChief(){
$journals = $this->journal_obj->field("t_journal.journal_id,t_journal.abbr,t_journal.jabbr")->where("state",0)->select();
$flag = [];
foreach ($journals as $k => $v){
$year = date("Y")-5;
$frag = [];
while ($year<=date("Y")){
$s_time = strtotime($year."-1-1");
$e_time = strtotime($year."-12-31");
$abbr = $v['abbr'];
if($abbr=="NTA"&&$year<2024){
$abbr = "MHM";
}
if($abbr=="PD"&&$year<2024){
$abbr = "PR";
}
$n = $this->article_obj->where("ctime",">",$s_time)->where("ctime","<",$e_time)->where("accept_sn","like",$abbr."%")->where("state",">",-1)->count();
$nj = $this->article_obj->where("ctime",">",$s_time)->where("ctime","<",$e_time)->where("accept_sn","like",$abbr."%")->where("state",">",-1)->where("journal_id","<>",$v['journal_id'])->count();
$frag[$year] = $n."/".$nj;
$year++;
}
$f['journal'] = $v;
$f['articles'] = $frag;
$flag[] = $f;
}
$re['data'] = $flag;
return jsonSuccess($re);
}
/**获取文章数量通过月份分期刊
* @return void
*/
public function getArticleNumByMonthForJournal(){
$journals = $this->journal_obj->where("state",0)->select();
$flag = [];
foreach ($journals as $v){
$year = 2020;
$month = 8;
$frag = [];
while ($year<date("Y")||($year==date("Y")&&$month<=date("m"))){
$s_time = strtotime($year."-".$month."-1");
$e_time = strtotime("+1 month", $s_time) - 1;
$n = $this->article_obj->where("state",">",-1)->where("ctime",">",$s_time)->where("ctime","<",$e_time)->where("accept_sn","like",$v['abbr']."%")->count();
$nj = $this->article_obj->where("state",">",-1)->where("ctime",">",$s_time)->where("ctime","<",$e_time)->where("accept_sn","like",$v['abbr']."%")->where("journal_id","<>",$v['journal_id'])->count();
$frag[$year."-".$month] = $n."/".$nj;
if($month==12){
$year++;
$month =1;
}else{
$month++;
}
}
$f["journal"] = $v;
$f['articles'] = $frag;
$flag[] = $f;
}
$re['data'] = $flag;
return jsonSuccess($re);
}
public function getArticleNumByMonthAndJournalForEditor(){
$data = $this->request->post();
$rule = new Validate([
"user_id"=>"require"
]);
if(!$rule->check($data)){
return jsonError($rule->getError());
}
$journals = $this->journal_obj->where("state",0)->where("editor_id",$data['user_id'])->select();
$flag = [];
foreach ($journals as $v){
$year = date("Y")-1;
$month = 1;
$frag = [];
while ($year<date("Y")||($year==date("Y")&&$month<=date("m"))){
$s_time = strtotime($year."-".$month."-1");
$e_time = strtotime("+1 month", $s_time) - 1;
$n = $this->article_obj->where("ctime",">",$s_time)->where("state",">",-1)->where("ctime","<",$e_time)->where("accept_sn","like",$v['abbr']."%")->count();
$nj = $this->article_obj->where("ctime",">",$s_time)->where("state",">",-1)->where("ctime","<",$e_time)->where("accept_sn","like",$v['abbr']."%")->where("journal_id","<>",$v['journal_id'])->count();
$frag[$year."-".$month] = $n."/".$nj;
if($month==12){
$year++;
$month =1;
}else{
$month++;
}
}
$f["journal"] = $v;
$f['articles'] = $frag;
$flag[] = $f;
}
$re['data'] = $flag;
return jsonSuccess($re);
}
public function getArticleNumByMonthAndJournalForChief(){
$journals = $this->journal_obj->field("t_journal.journal_id,t_journal.abbr,t_journal.jabbr")->where("state",0)->select();
$flag = [];
foreach ($journals as $v){
$year = date("Y")-1;
$month = 1;
$frag = [];
while ($year<date("Y")||($year==date("Y")&&$month<=date("m"))){
$s_time = strtotime($year."-".$month."-1");
$e_time = strtotime("+1 month", $s_time) - 1;
$n = $this->article_obj->where("ctime",">",$s_time)->where("state",">",-1)->where("ctime","<",$e_time)->where("accept_sn","like",$v['abbr']."%")->where("state",">",-1)->count();
$nj = $this->article_obj->where("ctime",">",$s_time)->where("state",">",-1)->where("ctime","<",$e_time)->where("accept_sn","like",$v['abbr']."%")->where("state",">",-1)->where("journal_id","<>",$v['journal_id'])->count();
$frag[$year."-".$month] = $n."/".$nj;
if($month==12){
$year++;
$month =1;
}else{
$month++;
}
}
$f["journal"] = $v;
$f['articles'] = $frag;
$flag[] = $f;
}
$re['data'] = $flag;
return jsonSuccess($re);
}
/**获取期刊月投稿量
* @return bool
*/
public function getArticleNumByMonth()
{
$year = 2020;
$month = 8;
$frag = [];
while ($year<date("Y")||($year==date("Y")&&$month<=date("m"))){
$s_time = strtotime($year."-".$month."-1");
$e_time = strtotime("+1 month", $s_time) - 1;
$n = $this->article_obj->where("ctime",">",$s_time)->where("state",">",-1)->where("ctime","<",$e_time)->count();
// $frag[$year."-".$month."sql"] = $this->article_obj->getLastSql();
$frag[$year."-".$month] = $n;
if($month==12){
$year++;
$month =1;
}else{
$month++;
}
}
$re['articles'] = $frag;
return jsonSuccess($re);
}
public function getArticleNumByMonthForEditor(){
$data = $this->request->post();
$rule = new Validate([
"user_id"=>"require"
]);
if(!$rule->check($data)){
return jsonError($rule->getError());
}
$journal_list = $this->journal_obj->where("editor_id",$data['user_id'])->where("state",0)->select();
if(count($journal_list)==0){
return jsonError("期刊为空");
}
$j_sql = '';
foreach ($journal_list as $v){
$j_sql .= "accept_sn like '".$v['abbr']."%' or ";
}
$j_sql = substr($j_sql,0,-4);
$year = date("Y")-1;
$month = 1;
$frag = [];
while ($year<date("Y")||($year==date("Y")&&$month<=date("m"))){
$s_time = strtotime($year."-".$month."-1");
$e_time = strtotime("+1 month", $s_time) - 1;
$n = $this->article_obj->where("state",">",-1)->where("ctime",">",$s_time)->where("ctime","<",$e_time)->where($j_sql)->count();
$frag[$year."-".$month] = $n;
if($month==12){
$year++;
$month =1;
}else{
$month++;
}
}
$re['articles'] = $frag;
return jsonSuccess($re);
}
public function getArticleNumByMonthForChief(){
$journal_list = $this->journal_obj->where("state",0)->select();
if(count($journal_list)==0){
return jsonError("期刊为空");
}
$j_sql = '';
foreach ($journal_list as $v){
$j_sql .= "accept_sn like '".$v['abbr']."%' or ";
}
$j_sql = substr($j_sql,0,-4);
$year = date("Y")-1;
$month = 1;
$frag = [];
while ($year<date("Y")||($year==date("Y")&&$month<=date("m"))){
$s_time = strtotime($year."-".$month."-1");
$e_time = strtotime("+1 month", $s_time) - 1;
$n = $this->article_obj->where("state",">",-1)->where("ctime",">",$s_time)->where("ctime","<",$e_time)->where($j_sql)->count();
$frag[$year."-".$month] = $n;
if($month==12){
$year++;
$month =1;
}else{
$month++;
}
}
$re['articles'] = $frag;
return jsonSuccess($re);
}
public function getArticleNumByYearForChief(){
// $journal_list = $this->journal_obj->where("state",0)->select();
// if(count($journal_list)==0){
// return jsonError("期刊为空");
// }
// $j_sql = '';
// foreach ($journal_list as $v){
// $j_sql .= "accept_sn like '".$v['abbr']."%' or ";
// }
// $j_sql = substr($j_sql,0,-4);
$year = Date("Y")-5;
$frag = [];
while ($year<=date("Y")){
$s_time = strtotime($year."-1-1");
$e_time = strtotime($year."-12-31");
$n = $this->article_obj
->field("t_article.*")
->join("t_journal","t_journal.journal_id = t_article.journal_id","left")
->where("t_article.ctime",">",$s_time)
->where("t_article.ctime","<",$e_time)
->where("t_journal.state",0)
->count();
$frag[$year] = $n;
$year++;
}
$re['articles'] = $frag;
return jsonSuccess($re);
}
public function getCiteForEditor(){
$data = $this->request->post();
$rule = new Validate([
"user_id"=>"require"
]);
if(!$rule->check($data)){
return jsonError($rule->getError());
}
$journal_list = $this->journal_obj
->field("t_journal.issn,t_journal.abbr,t_journal.title,t_journal.editor_id,t_user.realname")
->join("t_user","t_user.user_id = t_journal.editor_id","left")
->where("t_journal.editor_id",$data['user_id'])
->where("t_journal.state",0)
->select();
$url = "http://journalapi.tmrjournals.com/public/index.php/master/Journal/getCiteDataForSubmission";
$program = [];
$program['journals'] = json_encode($journal_list);
$res = object_to_array(json_decode(myPost($url,$program)));
return jsonSuccess($res);
}
public function getCiteListForEditorMonth(){
$data = $this->request->post();
$rule = new Validate([
"issn"=>"require"
]);
if(!$rule->check($data)){
return jsonError($rule->getError());
}
$url = "http://journalapi.tmrjournals.com/public/index.php/master/Journal/getCiteListForSubmission";
$program = [];
$program['issn'] = $data['issn'];
$res = object_to_array(json_decode(myPost($url,$program)));
//新增邮件发送数量 chengxiaoling 20250520 start
$aData = empty($res['data']) ? [] : $res['data'];
if(!empty($aData['list'])){
$aArticleCiteId = array_column($aData['list'], 'article_cite_id');
//查询邮件发送数量
$aWhere = ['article_cite_id' => ['in',$aArticleCiteId]];
$aEmail = Db::name('email_article_cite')->field('article_cite_id,count(article_cite_id) as num,is_success')->where($aWhere)->group('article_cite_id,is_success')->select();
if(!empty($aEmail)){
$aEmailLog = [];
foreach ($aEmail as $key => $value) {
$aEmailLog[$value['article_cite_id']][$value['is_success']] = $value['num'];
}
}
//数据处理
foreach ($aData['list'] as $key => $value) {
$aEmail = ['email_success' => 0,'email_fail' => 0];
//邮件发送数量
$aEmailInfo = empty($aEmailLog[$value['article_cite_id']]) ? [] : $aEmailLog[$value['article_cite_id']];
if(!empty($aEmailInfo)){
$aEmail['email_success'] = empty($aEmailInfo[1]) ? $aEmail['email_success'] : $aEmailInfo[1];
$aEmail['email_fail'] = empty($aEmailInfo[2]) ? $aEmail['email_fail'] : $aEmailInfo[2];
}
$aData['list'][$key] += $aEmail;
}
$res['data'] = $aData;
}
//新增邮件发送数量 chengxiaoling 20250520 end
return jsonSuccess($res['data']);
}
public function getCiteListForEditorPMonth(){
$data = $this->request->post();
$rule = new Validate([
"issn"=>"require"
]);
if(!$rule->check($data)){
return jsonError($rule->getError());
}
$url = "http://journalapi.tmrjournals.com/public/index.php/master/Journal/getCiteListPForSubmission";
$program = [];
$program['issn'] = $data['issn'];
$res = object_to_array(json_decode(myPost($url,$program)));
//新增邮件发送数量 chengxiaoling 20250520 start
$aData = empty($res['data']) ? [] : $res['data'];
if(!empty($aData['list'])){
$aArticleCiteId = array_column($aData['list'], 'article_cite_id');
//查询邮件发送数量
$aWhere = ['article_cite_id' => ['in',$aArticleCiteId]];
$aEmail = Db::name('email_article_cite')->field('article_cite_id,count(article_cite_id) as num,is_success')->where($aWhere)->group('article_cite_id,is_success')->select();
if(!empty($aEmail)){
$aEmailLog = [];
foreach ($aEmail as $key => $value) {
$aEmailLog[$value['article_cite_id']][$value['is_success']] = $value['num'];
}
}
//数据处理
foreach ($aData['list'] as $key => $value) {
$aEmail = ['email_success' => 0,'email_fail' => 0];
//邮件发送数量
$aEmailInfo = empty($aEmailLog[$value['article_cite_id']]) ? [] : $aEmailLog[$value['article_cite_id']];
if(!empty($aEmailInfo)){
$aEmail['email_success'] = empty($aEmailInfo[1]) ? $aEmail['email_success'] : $aEmailInfo[1];
$aEmail['email_fail'] = empty($aEmailInfo[2]) ? $aEmail['email_fail'] : $aEmailInfo[2];
}
$aData['list'][$key] += $aEmail;
}
$res['data'] = $aData;
}
//新增邮件发送数量 chengxiaoling 20250520 end
return jsonSuccess($res['data']);
}
public function getPublicStagesForEditor(){
$data = $this->request->post();
$rule = new Validate([
"journal_id"=>"require",
"year"=>"require"
]);
if(!$rule->check($data)){
return jsonError($rule->getError());
}
$journal = $this->journal_obj->where("journal_id",$data['journal_id'])->find();
$url = "http://journalapi.tmrjournals.com/public/index.php/master/Journal/getArticleCountForSubmission";
$program['issn'] = $journal['issn'];
$program['year'] = $data['year'];
$res = object_to_array(json_decode(myPost($url,$program)));
$re['list'] = $res['data']['stages'];
return jsonSuccess($re);
}
public function getArticleCountCiteForEditor(){
$data = $this->request->post();
$rule = new Validate([
"article_id"=>"require"
]);
if(!$rule->check($data)){
return jsonError($rule->getError());
}
$url = "http://journalapi.tmrjournals.com/public/index.php/master/Journal/getArticleCountCiteForSubmission";
$program['article_id'] = $data['article_id'];
$res = object_to_array(json_decode(myPost($url,$program)));
$re['list'] = isset($res['data']['cites'])?$res['data']['cites']:null;
return jsonSuccess($re);
}
public function getArticleCountRelatedForEditor(){
$data = $this->request->post();
$rule = new Validate([
"article_id"=>"require"
]);
if(!$rule->check($data)){
return jsonError($rule->getError());
}
$url = "http://journalapi.tmrjournals.com/public/index.php/master/Journal/getArticleCountRelatedForSubmission";
$program['article_id'] = $data['article_id'];
$res = object_to_array(json_decode(myPost($url,$program)));
$re['list'] = isset($res['data']['list'])?$res['data']['list']:null;
return jsonSuccess($re);
}
public function getCiteForChief(){
$journal_list = $this->journal_obj
->field("t_journal.issn,t_journal.abbr,t_journal.title,t_journal.editor_id,t_user.realname")
->join("t_user","t_user.user_id = t_journal.editor_id","left")
->where("t_journal.state",0)
->select();
$url = "http://journalapi.tmrjournals.com/public/index.php/master/Journal/getCiteDataForSubmission";
$program = [];
$program['journals'] = json_encode($journal_list);
$res = object_to_array(json_decode(myPost($url,$program)));
return jsonSuccess($res);
}
/**获取期刊青年编委
* @return void
*/
public function getYboards(){
$data = $this->request->post();
$rule = new Validate([
"journal_id"=>"require",
'pageIndex'=>'require',
'pageSize'=>'require'
]);
if(!$rule->check($data)){
return jsonError($rule->getError());
}
$yboards = $this->user_to_yboard_obj
->field("t_user.account,t_user.realname,t_user.email,t_user.score,t_user.remark,t_user.wos_index,t_user.wos_time,t_user.google_index,t_user.google_time,t_user_reviewer_info.field,t_user_reviewer_info.company,t_user_to_yboard.*")
->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_to_yboard.user_id','left')
->where("t_user_to_yboard.journal_id",$data['journal_id'])
->where("t_user_to_yboard.start_date","<=",time())
->where("t_user_to_yboard.end_date",">=",time())
->where("t_user_to_yboard.state",0)
->page($data['pageIndex'],$data['pageSize'])
->select();
$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_to_yboard.user_id','left')
->where("t_user_to_yboard.journal_id",$data['journal_id'])
->where("t_user_to_yboard.start_date","<=",time())
->where("t_user_to_yboard.end_date",">=",time())
->where("t_user_to_yboard.state",0)->count();
foreach($yboards as $k=>$val){
$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',$data['journal_id'])->where('t_article_reviewer.ctime',">",strtotime("-1 year"))->where('t_article_reviewer.state',"in",[1,2,3])->select();
$yboards[$k]['articles'] = $articles;
$yboards[$k]['articles_all'] = $articles_all;
$yboards[$k]['reviewes'] = $reviewes;
}
$re['yboards'] = $yboards;
$re['count'] = $count;
return jsonSuccess($re);
}
/**获取期刊总结报表
* @return void
*/
public function getJournalForms(){
$journals = $this->journal_obj->where('state',0)->order("editor_id")->select();
foreach ($journals as $k => $v){
//编辑信息
$journals[$k]['editor'] = $this->user_obj->where('user_id',$v['editor_id'])->find();
//当月点数
$aaa = $this->getDY($v['journal_id'],date("Y-m"));
$journals[$k]['DY'] = $aaa['fen'];
$journals[$k]['mx'] = $aaa['mx'];
//获取当月直投量
$are = $this->getZT($v['journal_id'],date("Y-m"));
$journals[$k]['Z'] = $are['z'];
$journals[$k]['ZT'] = $are['zt'];
//当年分数总结
$dn = $this->getDN($v['journal_id'],date("Y"));
$journals[$k]['ZS'] = $dn['zs'];
$journals[$k]['CS'] = $dn['cs'];
//去年投稿情况
$nare = $this->getNZT($v['journal_id'],date("Y")-1);
$journals[$k]['NZ'] = $nare['z'];
$journals[$k]['NZT'] = $nare['zt'];
//今年投稿情况
$dnare = $this->getNZT($v['journal_id'],date("Y"));
$journals[$k]['DNZ'] = $dnare['z'];
$journals[$k]['DNZT'] = $dnare['zt'];
}
$re['journals'] = $journals;
return jsonSuccess($re);
}
/**获取期刊青年科学家列表
* @return void
*/
public function getJournalYBoards(){
$journals = $this->journal_obj->where('state',0)->select();
foreach ($journals as $k => $v){
$yboards = $this->user_to_yboard_obj
->field("t_user.account,t_user.realname,t_user.email,t_user.score,t_user.remark,t_user.wos_index,t_user.wos_time,t_user.google_index,t_user.google_time,t_user_reviewer_info.field,t_user_reviewer_info.company,t_user_to_yboard.*")
->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_to_yboard.user_id','left')
->where("t_user_to_yboard.journal_id",$v['journal_id'])
->where("t_user_to_yboard.start_date","<=",time())
->where("t_user_to_yboard.end_date",">=",time())
->where("t_user_to_yboard.state",0)
->select();
$journals[$k]['yboard_count'] = count($yboards);
$board_index = [];
$sum = 0;
foreach ($yboards as $key => $val){
if($val['wos_index']>0){
$board_index[] = $val['wos_index']*1.5;
$sum += $val['wos_index']*1.5;
}elseif($val['google_index']>0){
$board_index[] = $val['google_index'];
$sum += $val['google_index'];
}
}
$journals[$k]['index_num'] = count($board_index);
$journals[$k]['median'] = count($board_index)==0?0:zw_array($board_index);
$journals[$k]['avg'] = count($board_index)==0?0:round($sum/count($board_index),2);
}
$re['journals'] = $journals;
return jsonSuccess($re);
}
public function ttt(){
$res = $this->getDY(22,date("Y-m"));
echo "<pre>";
var_dump($res);
echo "</pre>";
die;
}
private function getDN($journal_id,$y){
$start = strtotime(date($y.'-01-01 00:00:00'));
$articles = $this->article_obj->where("journal_id",$journal_id)->where("type","<>","T")->where("rtime",">",$start)->where("state",5)->select();
$zs = 0;
$cs = 0;
foreach ($articles as $k => $v){
$revs = $this->article_reviewer_obj
->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',$v['article_id'])->where('t_article_reviewer.state',"in",[1,2,3])->select();
$num = 0;
foreach ($revs as $val){
$num += $val['rated'];
}
$articles[$k]['reviewer_fen'] = count($revs)==0?0:$num/count($revs);
$last_fen = ($v['scoring']+$articles[$k]['reviewer_fen'])/2 ;
$cs += round($v['scoring'],1);
$zs += round($last_fen,1);
}
if(count($articles)>0){
$re['cs'] = round($cs/count($articles),1);
$re['zs'] = round($zs/count($articles),1);
}else{
$re['cs'] = 0;
$re['zs'] = 0;
}
return $re;
}
private function getDY($journal_id,$ym){
$start = strtotime(date($ym.'-01 00:00:00'));
$articles = $this->article_obj->where("journal_id",$journal_id)->where("rtime",">",$start)->where("state",5)->select();
$dy = 0;
$cy = 0;
$mx = [];
foreach ($articles as $k=>$v){
$revs = $this->article_reviewer_obj
->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',$v['article_id'])->where('t_article_reviewer.state',"in",[1,2,3])->select();
$num = 0;
foreach ($revs as $val){
$num += $val['rated'];
}
$articles[$k]['reviewer_fen'] = count($revs)==0?0:$num/count($revs);
$last_fen = ($v['scoring']+$articles[$k]['reviewer_fen'])/2 ;
$mx[] = $v['accept_sn'].":".$v['scoring']."/".$last_fen;
$cy += round($v['scoring'],1);
$dy += round($last_fen,1);
}
$re['fen'] = $cy."/".$dy;
$re['mx'] = $mx;
return $re;
}
private function getZT($journal_id,$ym){
$start = strtotime(date($ym.'-01 00:00:00'));
$journal_info = $this->journal_obj->where('journal_id',$journal_id)->find();
$articles = $this->article_obj->where('accept_sn',"like",$journal_info['abbr']."%")->where('ctime',">",$start)->select();
$zt_articles = $this->article_obj->where('accept_sn',"not like",$journal_info['abbr']."%")->where('ctime',">",$start)->where('journal_id',$journal_id)->select();
$re['zt'] =count($zt_articles);
$re['z'] = count($articles);
return $re;
}
private function getNZT($journal_id,$y){
$start = strtotime(date($y."-01-01 00:00:00"));
$end = strtotime(date($y."-12-31 23:59:59"));
$journal_info = $this->journal_obj->where('journal_id',$journal_id)->find();
if($y==2023&&$journal_info['abbr']=="PD"){
$qabbr = "PR";
}else{
$qabbr = $journal_info['abbr'];
}
$articles = $this->article_obj->where('accept_sn',"like",$qabbr."%")->where('ctime',">",$start)->where("ctime","<",$end)->select();
$zt_articles = $this->article_obj->where('accept_sn',"not like",$journal_info['abbr']."%")->where('ctime',">",$start)->where('journal_id',$journal_id)->where("ctime","<",$end)->select();
$re['zt'] =count($zt_articles);
$re['z'] = count($articles);
return $re;
}
}