From 0563c1217b587d55f6f63efa261c32297a1d741a Mon Sep 17 00:00:00 2001 From: wangjinlei <751475802@qq.com> Date: Fri, 15 Nov 2024 09:29:58 +0800 Subject: [PATCH] 1 --- application/api/controller/Article.php | 156 ++++++++++++++++++++----- application/api/controller/User.php | 38 +++++- 2 files changed, 156 insertions(+), 38 deletions(-) diff --git a/application/api/controller/Article.php b/application/api/controller/Article.php index 16b4aa7..bb9d8b9 100644 --- a/application/api/controller/Article.php +++ b/application/api/controller/Article.php @@ -2906,31 +2906,108 @@ class Article extends Base $p_num = $wp > $np ? $wp : $np; $all_num = $p_num + $tp; - if ($all_num > 3) { - $b_fen = 2; - } elseif ($all_num >= 1) { - $b_fen = 1; - } else { - $b_fen = 0; + if($article_info['type']=="A"){ + if($all_num>=5){ + $b_fen = 2; + }elseif ($all_num>=4){ + $b_fen = 1.5; + }elseif ($all_num>=2){ + $b_fen = 1; + }elseif ($all_num>=1){ + $b_fen = 0.5; + }else{ + $b_fen = 0; + } + }elseif($article_info['type']=="B"){ + if ($all_num>=4){ + $b_fen = 2; + }elseif ($all_num>=3){ + $b_fen = 1.5; + }elseif ($all_num>=2){ + $b_fen = 1; + }elseif($all_num>=1){ + $b_fen = 0.5; + }else{ + $b_fen = 0; + } + }else{ + if($all_num>=2){ + $b_fen = 2; + }elseif($all_num>=1){ + $b_fen = 1; + }else{ + $b_fen = 0; + } } + + +// $all_num = $p_num + $tp; +// if ($all_num > 3) { +// $b_fen = 2; +// } elseif ($all_num >= 1) { +// $b_fen = 1; +// } else { +// $b_fen = 0; +// } + //当h指数为0 并且是编辑填写的 if ($h_fen == 0 && $google_time > 0) { - if ($all_num >= 8) { - $b_fen = 4; - } elseif ($all_num == 7) { - $b_fen = 3.5; - } elseif ($all_num == 6) { - $b_fen = 3; - } elseif ($all_num == 5) { - $b_fen = 2; - } elseif ($all_num == 4) { - $b_fen = 1.5; - } elseif ($all_num >= 1) { - $b_fen = 1; - } else { - $b_fen = 0; + + if($article_info['type']=="A"){ + if($all_num>=6){ + $b_fen = 4; + }elseif ($all_num>=5){ + $b_fen = 3; + }elseif ($all_num>=4){ + $b_fen = 2.5; + }elseif ($all_num>=3){ + $b_fen = 2; + }elseif ($all_num>=2){ + $b_fen = 1; + }elseif ($all_num>=1){ + $b_fen = 0.5; + }else{ + $b_fen = 0; + } + }elseif ($article_info['type']=="B"){ + if ($all_num>=5){ + $b_fen = 4; + }elseif ($all_num>=4){ + $b_fen = 3; + }elseif ($all_num>=3){ + $b_fen = 2; + }elseif ($all_num>=2){ + $b_fen = 1; + }elseif ($all_num>=1){ + $b_fen = 0.5; + }else{ + $b_fen = 0; + } + }else{ + if($all_num>=2){ + $b_fen = 4; + }elseif($all_num>=1){ + $b_fen = 2; + }else{ + $b_fen = 0; + } } +// if ($all_num >= 8) { +// $b_fen = 4; +// } elseif ($all_num == 7) { +// $b_fen = 3.5; +// } elseif ($all_num == 6) { +// $b_fen = 3; +// } elseif ($all_num == 5) { +// $b_fen = 2; +// } elseif ($all_num == 4) { +// $b_fen = 1.5; +// } elseif ($all_num >= 1) { +// $b_fen = 1; +// } else { +// $b_fen = 0; +// } } @@ -2968,7 +3045,6 @@ class Article extends Base $jan_fen1 = 0.5; } } - $b_fen = $b_fen - $jan_fen1; $fen = $fen - $jan_fen1; } @@ -2992,19 +3068,35 @@ class Article extends Base } //单位 $dw_fen = 0; - $report_author = $this->article_author_obj->where('article_id', $article_id)->where('email', $user_info['email'])->find(); - if ($report_author) { - $ca_res = $this->company_top_obj->where('title', $report_author['company'])->find(); - if ($ca_res) { - if ($ca_res['company_id'] <= 100 || ($ca_res['company_id'] > 201 && $ca_res['company_id'] <= 301)) { - $dw_fen = 1.5; - $fen += 1.5; - } else { - $dw_fen = 1; - $fen += 1; + $dw_authors = $this->article_author_obj->where("article_id",$article_id)->where("state",0)->select(); + foreach ($dw_authors as $v){ + $ca_res = $this->company_top_obj->where('title', $v['company'])->find(); + if ($ca_res) { + if ($ca_res['company_id'] <= 100 || ($ca_res['company_id'] > 201 && $ca_res['company_id'] <= 301)) { + $dw_fen = 1.5; + } else { + if($dw_fen<1.5){ + $dw_fen = 1; + } + } } - } } + $fen += $dw_fen; + +// $report_author = $this->article_author_obj->where('article_id', $article_id)->where('state', $user_info['email'])->find(); +// +// if ($report_author) { +// $ca_res = $this->company_top_obj->where('title', $report_author['company'])->find(); +// if ($ca_res) { +// if ($ca_res['company_id'] <= 100 || ($ca_res['company_id'] > 201 && $ca_res['company_id'] <= 301)) { +// $dw_fen = 1.5; +// $fen += 1.5; +// } else { +// $dw_fen = 1; +// $fen += 1; +// } +// } +// } //领域 $ly_fen = 0; diff --git a/application/api/controller/User.php b/application/api/controller/User.php index 866bceb..080f4d0 100644 --- a/application/api/controller/User.php +++ b/application/api/controller/User.php @@ -622,19 +622,23 @@ class User extends Base if($data['type']==0){//wos $user_info['wos_index'] = $data['index']; $user_info['wos_time'] = time(); + $this->user_obj->update($user_info); }elseif ($data['type']==1){//scopus $user_info['scopus_index'] = $data['index']; $user_info['scopus_time'] = time(); $user_info['scopus_website'] = $data['website']; $user_info['scopus_editor'] = $editor_info['realname']; + $this->user_obj->update($user_info); }else{//google - $user_info['google_index'] = $data['index']; - $user_info['google_time'] = time(); - $user_info['g_author'] = $data['g_author']; - $user_info['g_website'] = $data['website']; - $user_info['google_editor'] = $editor_info['realname']; + if(isset($data['g_author'])&&$data['g_author']!=null&&$data['g_author']!=""){ + $this->googleBindAuthorNew($data['user_id'],$data['g_author']); + }else{ + $user_info['google_index'] = $data['index']; + $user_info['google_time'] = time(); + $user_info['google_editor'] = $editor_info['realname']; + $this->user_obj->update($user_info); + } } - $this->user_obj->update($user_info); return jsonSuccess($user_info); } @@ -1624,6 +1628,28 @@ class User extends Base return jsonSuccess($organic_results); } + private function googleBindAuthorNew($user_id,$g_author){ + $this->user_obj->where('user_id',$user_id)->update(['g_author'=>trim($g_author)]); + //绑定完成后自动获取指数 + Loader::import("google.google-search-results"); + Loader::import("google.restclient"); + + $query = [ + "engine" => "google_scholar_author", + "author_id" => trim($g_author) + ]; + + $search = new \GoogleSearch('7651ca6caf949b0ac6ce28a95f3d2e9d8ee51b024ba7fad86f0298fb84290765'); + $result = $search->get_json($query); + $organic_results = object_to_array($result); + $h_index= 0; + $h_index = $organic_results['cited_by']['table'][1]['h_index']['all']; + + $updata['google_index'] = $h_index; + $updata['google_time'] = time(); + $this->user_obj->where('user_id',$user_id)->update($updata); + } + /** * 获取H指数 */