admin_obj = Db::name('admin'); $this->journal_obj = Db::name('journal'); $this->article_obj = Db::name('article'); $this->article_author_obj = Db::name('article_author'); $this->article_ltai_obj = Db::name('article_ltai'); $this->journal_topic_obj = Db::name('journal_topic'); $this->journal_stage_obj = Db::name('journal_stage'); $this->journal_notices_obj = Db::name('journal_notices'); $this->journal_abs_obj = Db::name('journal_abstracting'); $this->journal_cfp_obj = Db::name('journal_cfp'); $this->journal_line_obj = Db::name('journal_line'); $this->article_to_topic_obj = Db::name('article_to_topic'); $this->article_to_line_obj = Db::name('article_to_line'); $this->journal_paper_obj = Db::name('journal_paper'); $this->journal_paper_art_obj = Db::name('journal_paper_art'); $this->subscribe_journal_obj = Db::name('subscribe_journal'); $this->subscribe_topic_obj = Db::name('subscribe_topic'); $this->super_danger_obj = Db::name('super_danger'); $this->board_obj = Db::name('board'); $this->board_group_obj = Db::name('board_group'); $this->visit_log_obj = Db::name('visit_log'); $this->article_cite_obj = Db::name('article_cite'); } /** * @title 获取期刊列表(出刊时间) * @description 获取期刊列表(出刊时间) * @author wangjinlei * @url /super/Publish/getMain * @method POST * * @return journals:期刊信息array# */ public function getMain() { $journals = $this->journal_obj->where('journal_id', '<>', 17)->where('state', 0)->select(); foreach ($journals as $k => $v) { $journals[$k]['mark'] = $this->calMark($v['journal_id']); $last_stage = $this->journal_stage_obj ->where('journal_id', $v['journal_id']) ->where('is_publish', 1) ->where('state', 0) ->order('journal_stage_id desc') ->limit(1) ->select(); $stage_now = $last_stage ? $last_stage[0] : ['issue_date' => '2020-05-15']; $ctime = strtotime($stage_now['issue_date']); $cs = []; $cs['issn'] = $v['issn']; $cs['ctime'] = $ctime; $journals[$k]['last_time'] = $ctime; $cache_arts = $this->object_to_array(json_decode(myPost(self::JURL, $cs))); $count = is_array($cache_arts['data']['articles']) ? count($cache_arts['data']['articles']) : 0; $journals[$k]['artCount'] = $count; } //按照危险值排序 for ($i = 0; $i < count($journals); $i++) { for ($j = $i + 1; $j < count($journals); $j++) { if ($journals[$i]['mark']['mk'] < $journals[$j]['mark']['mk']) { $cac = $journals[$i]; $journals[$i] = $journals[$j]; $journals[$j] = $cac; } } } $re['journals'] = $journals; return jsonSuccess($re); } /** * @title 获取单个期刊的统计数据 * @description 获取单个期刊的统计数据 * @author wangjinlei * @url /super/Publish/getAllDateForJournal * @method POST * * @param name:issn type:string require:1 desc:期刊issn号 * @param name:start type:string require:1 desc:开始时间 * @param name:end type:string require:1 desc:结束时间 * */ public function getAllDateForJournal() { $data = $this->request->post(); // $data['issn'] = '2703-4631'; // $data['start'] = '2021-01-01'; // $data['end'] = '2021-09-08'; $info = $this->journal_obj->where('issn', $data['issn'])->find(); //出刊时间 $info['CK'] = []; $info['CK']['mark'] = $this->calMark($info['journal_id']); $last_stage = $this->journal_stage_obj ->where('journal_id', $info['journal_id']) ->where('is_publish', 1) ->where('state', 0) ->order('journal_stage_id desc') ->limit(1) ->select(); $stage_now = $last_stage ? $last_stage[0] : ['issue_date' => '2020-05-15']; $ctime = strtotime($stage_now['issue_date']); $cs = []; $cs['issn'] = $data['issn']; $cs['ctime'] = $ctime; $info['CK']['last_time'] = $ctime; $cache_arts = $this->object_to_array(json_decode(myPost(self::JURL, $cs))); $count = is_array($cache_arts['data']['articles']) ? count($cache_arts['data']['articles']) : 0; $info['CK']['artCount'] = $count; //合规检测 $pa['start'] = $data['start']; $pa['end'] = $data['end']; $res = $this->object_to_array(json_decode(myPost(self::TJ_URL, $pa))); foreach ($res as $k => $v) { if($v['issn'] == $data['issn']){ $info['HG'] = $v; $info['HG']['SUBJOURNAL'] = $this->subscribe_journal_obj->where('journal_id', $info['journal_id'])->where('state', 0)->count(); $topics = $this->journal_topic_obj->where('journal_id', $info['journal_id'])->where('state', 0)->column('journal_topic_id'); $info['HG']['SUBTOPIC'] = $this->subscribe_topic_obj->where('topic_id', 'in', $topics)->where('state', 0)->count(); } } //质量评估 $start = strtotime($data['start']); $end = strtotime($data['end'] . ' 23:59:59'); $pag['start'] = $start; $pag['end'] = $end; $result = $this->object_to_array(json_decode(myPost(self::AL_URL, $pag))); $r = $result['data']; $tg = ''; foreach ($r as $val) { if($val['issn']==$data['issn']){ $tg = $val['SJ']; } } $info['ZL']['YY'] = $this->article_obj->where('journal_id', $info['journal_id'])->where('ctime', '>', $start)->where('ctime', '<=', $end)->where('state', 0)->sum('cited'); $info['ZL']['TGL'] = $tg; $info['ZL']['FWL'] = $this->getFWL($info['journal_id'], $start, $end); $info['ZL']['LX'] = $this->getLX($info['journal_id'], $start, $end); $info['ZL']['GJH'] = $this->getGJH($info['journal_id'], $start, $end); $info['ZL']['GNW'] = $this->getGNW($info['journal_id'], $start, $end); $info['ZL']['CK'] = $this->getCK($info['journal_id']); $info['ZL']['BW'] = $this->getBW($info['journal_id']); $info['ZL']['DY'] = $this->subscribe_journal_obj->where('journal_id', $info['journal_id'])->where('state', 0)->count(); return jsonSuccess($info); } /** * 自动任务存储危险值 */ public function autoDanger() { $journals = $this->journal_obj->where('state', 0)->select(); foreach ($journals as $k => $v) { $cah_res = $this->calMark($v['journal_id']); $insert['journal_id'] = $v['journal_id']; $insert['date'] = date('Ymd'); $insert['danger'] = $cah_res['mk']; $this->super_danger_obj->insert($insert); } } /** * @title 验证登录 * @description 验证登录 * @author wangjinlei * @url /super/Publish/check_login * @method POST * * @param name:account type:string require:1 desc:账户密码 * @param name:password type:string require:1 desc:密码 * */ public function check_login() { $data = $this->request->post(); if ($data['account'] == 'superAdmin' && $data['password'] == 'Wu999999') { return jsonSuccess([]); } else { return jsonError('check error!'); } } /** * @title 获取合规检测 * @description 获取合规检测 * @author wangjinlei * @url /super/Publish/getTjJournal * @method POST * * @param name:start type:string require:1 desc:开始时间 * @param name:end type:string require:1 desc:结束时间 * * @return dates:数据@ * @dates SGRSL:审稿人数量 * @dates SUBJOURNAL:订阅期刊数 * @dates SUBTOPIC:订阅话题数 * @dates LYL:录用率 * @dates JST:接收时间 * @dates CC:查重 * @dates WS:外审 * @dates SJ:时间 */ public function getTjJournal() { $data = $this->request->post(); $pa['start'] = $data['start']; $pa['end'] = $data['end']; $res = $this->object_to_array(json_decode(myPost(self::TJ_URL, $pa))); foreach ($res as $k => $v) { $cache_info = $this->journal_obj->where('issn', $v['issn'])->find(); $res[$k]['SUBJOURNAL'] = $this->subscribe_journal_obj->where('journal_id', $cache_info['journal_id'])->where('state', 0)->count(); $topics = $this->journal_topic_obj->where('journal_id', $cache_info['journal_id'])->where('state', 0)->column('journal_topic_id'); $res[$k]['SUBTOPIC'] = $this->subscribe_topic_obj->where('topic_id', 'in', $topics)->where('state', 0)->count(); } return jsonSuccess($res); } /** * @title 获取查重文章 * @description 获取查重文章 * @author wangjinlei * @url /super/Publish/getCCArticle * @method POST * * @param name:issn type:int require:1 desc:期刊id * @param name:type type:string require:1 desc:重复类型 * @param name:start type:string require:1 desc:开始时间 * @param name:end type:string require:1 desc:结束时间 * */ public function getCCArticle() { $data = $this->request->post(); $pa['issn'] = $data['issn']; $pa['type'] = $data['type']; $pa['start'] = $data['start']; $pa['end'] = $data['end']; $res = myPost(self::CCA_URL, $pa); return $res; } /** * @title 获取质量评估 * @description 获取质量评估 * @author wangjinlei * @url /super/Publish/getQuality * @method POST * * @param name:start type:string require:1 desc:开始时间 * @param name:end type:string require:1 desc:结束 * * @return YY:引用数 * @return TGL:投稿量 * @return FWL:发文量 * @return LX:文章类型 * @return GJH:国际化 * @return CK:创刊时间 * @return BW:编委 * @return DY:订阅 */ public function getQuality() { $data = $this->request->post(); $journals = $this->journal_obj->where('state', 0)->select(); $start = strtotime($data['start']); $end = strtotime($data['end'] . ' 23:59:59'); $pag['start'] = $start; $pag['end'] = $end; $res = $this->object_to_array(json_decode(myPost(self::AL_URL, $pag))); $r = $res['data']; $tg = []; foreach ($r as $val) { $tg[$val['issn']] = $val['SJ']; } foreach ($journals as $k => $v) { $journals[$k]['YY'] = $this->article_obj->where('journal_id', $v['journal_id'])->where('ctime', '>', $start)->where('ctime', '<=', $end)->where('state', 0)->sum('cited'); $journals[$k]['TGL'] = isset($tg[$v['issn']]) ? $tg[$v['issn']] : []; $journals[$k]['FWL'] = $this->getFWL($v['journal_id'], $start, $end); $journals[$k]['LX'] = $this->getLX($v['journal_id'], $start, $end); $journals[$k]['GJH'] = $this->getGJH($v['journal_id'], $start, $end); $journals[$k]['GNW'] = $this->getGNW($v['journal_id'], $start, $end); $journals[$k]['CK'] = $this->getCK($v['journal_id']); $journals[$k]['BW'] = $this->getBW($v['journal_id']); $journals[$k]['DY'] = $this->subscribe_journal_obj->where('journal_id', $v['journal_id'])->where('state', 0)->count(); } return jsonSuccess($journals); } /** * @title 增加访问次数 * @description 增加访问次数 * @author wangjinlei * @url /super/Publish/addVisitNum * @method POST * * @param name:type type:string require:1 desc:类型(1.de2.journal_id) * @param name:is_detail type:int require:0 desc:是否是详情(0否1是) */ public function addVisitNum() { $data = $this->request->post(); // $data['type'] = 1; $data['is_detail'] = isset($data['is_detail']) ? $data['is_detail'] : 0; $up_id = 0; if ($data['type'] == 'de') {//数据库访问 $res = $this->visit_log_obj->where('type', 'de')->where('stime', date('Ym'))->find(); if ($res == null) { $insert['type'] = 'de'; $insert['stime'] = date('Ym'); $up_id = $this->visit_log_obj->insertGetId($insert); } else { $up_id = $res['vlid']; } } else if (is_numeric($data['type']) && $data['is_detail'] == 1) { $res = $this->visit_log_obj->where('type', $data['type'])->where('is_detail', 1)->where('stime', date('Ym'))->find(); if ($res == null) { $insert['type'] = $data['type']; $insert['is_detail'] = 1; $insert['stime'] = date('Ym'); $up_id = $this->visit_log_obj->insertGetId($insert); } else { $up_id = $res['vlid']; } } else {//期刊访问 $res = $this->visit_log_obj->where('type', $data['type'])->where('is_detail', 0)->where('stime', date('Ym'))->find(); if ($res == null) { $insert['type'] = $data['type']; $insert['stime'] = date('Ym'); $up_id = $this->visit_log_obj->insertGetId($insert); } else { $up_id = $res['vlid']; } } $this->visit_log_obj->where('vlid', $up_id)->setInc('num'); return jsonSuccess([]); } /** * @title 获取访问次数 * @description 获取访问次数 * @author wangjinlei * @url /super/Publish/getVisit * @method POST */ public function getVisit() { $t = strtotime("-4 month"); $stime = date('Ym', $t); $visits = $this->visit_log_obj->where('stime', '>=', $stime)->where('state', 0)->select(); $frag = []; for ($i = 0; $i <= 4; $i++) { $ntime = date('Ym', strtotime("-$i month")); $frag[$ntime] = []; foreach ($visits as $v) { if ($v['stime'] == $ntime) { if ($v['is_detail'] == 0) { $frag[$ntime][$v['type']] = $v['num']; } else { $frag[$ntime][$v['type'] . '_detail'] = $v['num']; } } } } $pjarr = []; //算最近三个月平均值 for($i=2;$i>=0;$i--){ $ntime = date('Ym', strtotime("-$i month")); foreach ($visits as $v){ if($v['stime']==$ntime){ if($v['is_detail']==0){ if(isset($pjarr[$v['type']]['tou'])){ $pjarr[$v['type']]['tou'] += $v['num']; }else{ $pjarr[$v['type']]['tou'] = $v['num']; } }else{ if(isset($pjarr[$v['type']]['wei'])){ $pjarr[$v['type']]['wei'] += $v['num']; }else{ $pjarr[$v['type']]['wei'] = $v['num']; } } } } } $journals = $this->journal_obj->where('state', 0)->select(); $frag1 = []; foreach ($frag as $k => $v) { $frag1['de'][$k] = isset($frag[$k]['de']) ? $frag[$k]['de'] : 0; foreach ($journals as $val) { $ca_tou = isset($frag[$k][$val['journal_id']]) ? $frag[$k][$val['journal_id']] : 0; $ca_wei = isset($frag[$k][$val['journal_id'] . '_detail']) ? $frag[$k][$val['journal_id'] . '_detail'] : 0; $frag1[$val['title']][$k] = $ca_tou . '/' . $ca_wei; } } foreach ($journals as $k => $v){ $pjarr[$v['title']] = $pjarr[$v['journal_id']]; } foreach ($frag1 as $k => $v){ $frag1[$k]['pj_tou'] = intval($pjarr[$k]['tou']/3); if($k!='de'){ $frag1[$k]['pj_wei'] = intval(isset($pjarr[$k]['wei'])?$pjarr[$k]['wei']/3:0); } } foreach ($frag1 as $k => $v) { // if ($k == 'de') { // $num = 0; // foreach ($v as $vv) { // $num += $vv; // } // $frag1[$k]['all'] = $num; // } else { // $tou_num = 0; // $wei_num = 0; // foreach ($v as $vv) { // $ca_n = explode('/', $vv); // $tou_num += $ca_n[0]; // $wei_num += $ca_n[1]; // } // $frag1[$k]['all'] = $tou_num . '/' . $wei_num; // } if($k!='de'&&$k!='经典中医研究'){ $frag1[$k]['title'] = $k; }else{ unset($frag1[$k]); } } $f = array_values($frag1); for ($i=0;$ijournal_stage_obj->where('journal_id', $journal_id)->where('state', 0)->order('journal_stage_id')->limit(1)->select(); return $stage ? $stage[0]['issue_date'] : ''; } /** * 获取期刊的发文量 */ private function getFWL($journal_id) { $frag = []; $frag['all'] = 0; for ($i = 2016; $i <= intval(date('Y')); $i++) { $cstages = $this->journal_stage_obj ->where('journal_id', $journal_id) ->where('stage_year', $i) ->where('is_publish', 1) ->where('state', 0) ->column('journal_stage_id'); $frag[$i] = $this->article_obj->where('journal_stage_id', 'in', $cstages)->where('state', 0)->count(); $frag['all'] += $frag[$i]; } return $frag; } private function getLX($journal_id, $start, $end) { $stages = $this->journal_stage_obj ->where('journal_id', $journal_id) ->where('is_publish', 1) ->where('state', 0) ->column('journal_stage_id'); $arts = $this->article_obj->where('journal_id', $journal_id)->where('ctime', '>', $start)->where('ctime', '<=', $end)->where('journal_stage_id', 'in', $stages)->where('state', 0)->select(); $frag = []; foreach ($arts as $v) { if (isset($frag[$v['type']])) { $kk = $v['type'] == '' ? 'Other' : $v['type']; $frag[$kk]++; } else { $kk = $v['type'] == '' ? 'Other' : $v['type']; $frag[$kk] = 1; } } return $frag; } private function getGNW($journal_id, $start, $end) { $stages = $this->journal_stage_obj ->where('journal_id', $journal_id) ->where('is_publish', 1) ->where('state', 0) ->column('journal_stage_id'); $arts = $this->article_obj->where('journal_id', $journal_id)->where('journal_stage_id', 'in', $stages)->where('ctime', '>', $start)->where('ctime', '<=', $end)->where('state', 0)->select(); $frag = []; foreach ($arts as $k => $v) { $ca_aus = $this->article_author_obj->where('article_id', $v['article_id'])->where('state', 0)->where('author_country', '<>', 'China')->find(); if ($ca_aus == null) { if (isset($frag['n'])) { $frag['n'] += 1; } else { $frag['n'] = 1; } } else { if (isset($frag['w'])) { $frag['w'] += 1; } else { $frag['w'] = 1; } } } return $frag; } private function getGJH($journal_id, $start, $end) { $stages = $this->journal_stage_obj ->where('journal_id', $journal_id) ->where('is_publish', 1) ->where('state', 0) ->column('journal_stage_id'); $arts = $this->article_obj->where('journal_id', $journal_id)->where('journal_stage_id', 'in', $stages)->where('ctime', '>', $start)->where('ctime', '<=', $end)->where('state', 0)->column('article_id'); $auts = $this->article_author_obj->where('article_id', 'in', $arts)->where('state', 0)->select(); $frag = []; $frag['list'] = []; $frag['countrys'] = 0; foreach ($auts as $v) { if (isset($frag['list'][$v['author_country']])) { $frag['list'][$v['author_country']]++; } else { $frag['list'][$v['author_country']] = 1; $frag['countrys']++; } } return $frag; } /** * 获取编委信息 */ private function getBW($journal_id) { $list = $this->board_obj->where('journal_id', $journal_id)->where('state', 0)->select(); $frag = []; foreach ($list as $v) { if (isset($frag[$v['country']])) { $frag[$v['country']]++; } else { $frag[$v['country']] = 1; } } $re['count'] = count($list); $re['country'] = $frag; return $re; } /** * @title 获取历史危险值 * @description 获取历史危险值 * @author wangjinlei * @url /super/Publish/getDangerHistory * @method POST * * @return dates:日期数组# * @return journals:期刊信息array# */ public function getDangerHistory() { $dates = []; for ($index = 8; $index > 0; $index--) { $dates[] = date("Ymd", strtotime("-$index week Sunday")); } $re['dates'] = $dates; $journals = $this->journal_obj->where('state', 0)->select(); foreach ($journals as $k => $v) { $fr = []; $cache = $this->super_danger_obj ->where('journal_id', $v['journal_id']) ->where('state', 0) ->order('super_danger_id desc') ->limit(8) ->column('danger'); for ($in = 0; $in < 8 - count($cache); $in++) { $fr[] = 0; } foreach ($cache as $val) { $fr[] = $val; } $journals[$k]['ma'] = $fr; } $re['journals'] = $journals; return jsonSuccess($re); } /** * 计算危险指数 */ private function calMark($journal_id) { $journal_info = $this->journal_obj->where('journal_id', $journal_id)->find(); $stages = $this->journal_stage_obj->where('journal_id', $journal_id)->where('is_publish', 0)->where('state', 0)->column('journal_stage_id'); $count = $this->article_obj->where('journal_stage_id', 'in', $stages) ->where('state', 0) ->count(); $last_stage = $this->journal_stage_obj ->where('journal_id', $journal_id) ->where('is_publish', 1) ->where('state', 0) ->order('journal_stage_id desc') ->limit(1) ->select(); $stage_now = $last_stage ? $last_stage[0] : ['issue_date' => '2020-05-15']; $cday = intval((time() - strtotime($stage_now['issue_date'])) / (3600 * 24)); //过去了多少天 $cycle = $journal_info['cycle'] == 0 ? 2 : $journal_info['cycle']; //出刊期限 $art_num = $journal_info['art_num'] == 0 ? 5 : $journal_info['art_num']; //期刊文章数量 $next_time = strtotime("+$cycle month", strtotime($stage_now['issue_date'])); //下次出刊时间 $all_days = intval(($next_time - strtotime($stage_now['issue_date'])) / (3600 * 24)); //这两次出刊时间差,天数 $frag = []; $frag['count'] = $count; $frag['sy'] = intval(($next_time - time()) / (3600 * 24)); //$cycle*30 - $cday; $frag['ntime'] = $next_time; //strtotime($stage_now['issue_date'])+($cycle*30*3600*24); if (time() > $next_time) { $frag['mk'] = 100; return $frag; } $lart = intval($cday * $art_num / $all_days); if ($count >= $lart) { $frag['mk'] = 0; } else { $frag['mk'] = intval(($lart - $count) * 100 / $art_num); } return $frag; } public function object_to_array($obj) { $_arr = is_object($obj) ? get_object_vars($obj) : $obj; $arr = null; foreach ($_arr as $key => $val) { $val = (is_array($val)) || is_object($val) ? $this->object_to_array($val) : $val; $arr[$key] = $val; } return $arr; } /** * @title 获取全部期刊 * @description 获取全部期刊 * @author wangjinlei * @url /super/Publish/bossLogin * @method POST * * @param name:code type:int require:1 desc:链接特殊码 */ public function bossLogin(){ $data = $this->request->post(); if($data['code']=='eff9be46e027e2094baf29a9c1195129'){ return jsonSuccess([]); }else{ return jsonError([]); } } /** * @title 获取全部期刊 * @description 获取全部期刊 * @author wangjinlei * @url /super/Publish/getAllJournals * @method POST * * @return journals:期刊列表# */ public function getAllJournals() { $list = $this->journal_obj->where('state', 0)->select(); $re['journals'] = $list; return jsonSuccess($re); } /** * @title 获取引用数据统计 * @description 获取引用数据统计 * @author wangjinlei * @url /super/Publish/getCiteDate * @method POST * * @param name:journal_id type:int require:1 desc:期刊id * */ public function getCiteDate() { $data = $this->request->post(); // $data['journal_id'] = 1; $list = $this->article_cite_obj->where('journal_id', $data['journal_id'])->select(); $frag = []; $frag['country'] = []; $frag['topic'] = []; $frag['time'] = []; $frag['type'] = []; $frag['articles'] = []; foreach ($list as $v) { $cache_article = $this->article_obj->where('article_id', $v['article_id'])->find(); //判断国家 $cou_res = $this->checkCountry($cache_article); if ($cou_res == 'n') { isset($frag['country']['n']) ? $frag['country']['n']++ : $frag['country']['n'] = 1; } else { isset($frag['country']['w']) ? $frag['country']['w']++ : $frag['country']['w'] = 1; } //判断领域 $topic_res = $this->checkTopic($cache_article); foreach ($topic_res as $key => $val) { if (isset($frag['topic'][$val['title']])) { $frag['topic'][$val['title']] += 1; } else { $frag['topic'][$val['title']] = 1; } } //关键词 $gjz = explode(',', $cache_article['keywords']); foreach ($gjz as $key => $val) { if (isset($frag['gjz'][$val])) { $frag['gjz'][$val] += 1; } else { $frag['gjz'][$val] = 1; } } //时间 $ca_time = $this->journal_stage_obj->where('journal_stage_id', $cache_article['journal_stage_id'])->find(); if (isset($frag['time'][$ca_time['stage_year']])) { $frag['time'][$ca_time['stage_year']] += 1; } else { $frag['time'][$ca_time['stage_year']] = 1; } //文章类型 if (isset($frag['type'][$cache_article['type']])) { $frag['type'][$cache_article['type']] += 1; } else { $frag['type'][$cache_article['type']] = 1; } //组成文章数组构建 if (isset($frag['articles'][$cache_article['article_id']])) { $frag['articles'][$cache_article['article_id']] += 1; } else { $frag['articles'][$cache_article['article_id']] = 1; } } //阅读和下载量 $articles = $this->article_obj->field('j_article.*,(abs_num+pdf_num+html_num) num') ->where('journal_id', $data['journal_id']) ->where('state', 0) ->order('num desc')->select(); foreach ($frag['articles'] as $k => $v) { $art = $this->article_obj->where('article_id', $k)->find(); $cnum = $v; $frag['articles'][$k] = $art; $frag['articles'][$k]['cite_num'] = $cnum; //阅读和下载数 foreach ($articles as $key => $val) { if ($val['article_id'] == $k) { $frag['articles'][$k]['read_pm'] = $key + 1; //阅读量排名 $frag['articles'][$k]['read_num'] = $val["num"]; //阅读数 } } } $frag['read'] = $this->sort_art($frag['articles']); //标题吸引力 $bty_articles = $this->article_obj->where('journal_id', $data['journal_id'])->where('state', 0)->orderRaw('LENGTH(title) desc')->limit(10)->select(); foreach ($bty_articles as $k => $v) { foreach ($frag['articles'] as $key => $val) { if ($v['article_id'] == $val['article_id']) { $bty_articles[$k]['cite_num'] = $val['cite_num']; break; } else { $bty_articles[$k]['cite_num'] = 0; } } } $frag['zs_title'] = $bty_articles; //标题字数 $btzf_articles = $this->article_obj ->where('journal_id', $data['journal_id']) ->where('state', 0) ->where('title', ['like', '%?%'], ['like', '%!%'], 'or') ->select(); foreach ($btzf_articles as $k => $v) { foreach ($frag['articles'] as $key => $val) { if ($v['article_id'] == $val['article_id']) { $btzf_articles[$k]['cite_num'] = $val['cite_num']; break; } else { $btzf_articles[$k]['cite_num'] = 0; } } } $frag['zf_title'] = $btzf_articles; //摘要吸引力 $ab_articles = $this->article_obj->where('journal_id', $data['journal_id'])->where('state', 0)->orderRaw('LENGTH(abstract) desc')->limit(10)->select(); foreach ($ab_articles as $k => $v) { foreach ($frag['articles'] as $key => $val) { if ($v['article_id'] == $key) { $ab_articles[$k]['cite_num'] = $val['cite_num']; break; } else { $ab_articles[$k]['cite_num'] = 0; } } } $frag['zs_abstract'] = $ab_articles; //摘要字数 $abzf_articles = $this->article_obj ->where('journal_id', $data['journal_id']) ->where('state', 0) ->where('abstract', ['like', '%?%'], ['like', '%!%'], 'or') ->select(); foreach ($abzf_articles as $k => $v) { foreach ($frag['articles'] as $key => $val) { if ($v['article_id'] == $key) { $abzf_articles[$k]['cite_num'] = $val['cite_num']; break; } else { $abzf_articles[$k]['cite_num'] = 0; } } } $frag['zf_abstract'] = $abzf_articles; return jsonSuccess($frag); } private function sort_art($articles) { $arr = array_values($articles); for ($i = 0; $i < count($arr); $i++) { for ($j = $i; $j < count($arr) - 1; $j++) { if ($arr[$i]['read_num'] < $arr[$j + 1]['read_num']) { $data = $arr[$i]; $arr[$i] = $arr[$j + 1]; $arr[$j + 1] = $data; } } } return $arr; } private function checkTopic($article) { $tops = $this->article_to_topic_obj->where('article_id', $article['article_id'])->where('state', 0)->select(); $frag = []; foreach ($tops as $v) { $ca = $this->journal_topic_obj->where('journal_topic_id', $v['topic_id'])->find(); if ($ca['level'] == 3) { $cac = $this->journal_topic_obj->where('journal_topic_id', $ca['parent_id'])->find(); if (isset($frag[$cac['journal_topic_id']])) { $frag[$cac['journal_topic_id']]['num'] += 1; } else { $frag[$cac['journal_topic_id']] = $cac; $frag[$cac['journal_topic_id']]['num'] = 1; } } else { if (isset($frag[$ca['journal_topic_id']])) { $frag[$ca['journal_topic_id']]['num'] += 1; } else { $frag[$ca['journal_topic_id']] = $ca; $frag[$ca['journal_topic_id']]['num'] = 1; } } } return $frag; } private function checkCountry($article) { $res = $this->article_author_obj->where('article_id', $article['article_id'])->where('state', 0)->where('author_country', '<>', 'China')->find(); return $res == null ? 'n' : 'w'; } }