20201112
This commit is contained in:
@@ -6,12 +6,14 @@ use think\Db;
|
||||
|
||||
/**
|
||||
* @title 总监Main接口
|
||||
* @description 文章web相关操作
|
||||
* @group 文章web相关
|
||||
* @description 总监Main接口
|
||||
* @group 总监Main接口
|
||||
*/
|
||||
class Publish extends Controller
|
||||
|
||||
{
|
||||
class Publish extends Controller{
|
||||
|
||||
const JURL = 'http://www.tougao.com/api/Article/getArticleForJournal';
|
||||
// const JURL = 'http://journalapi.tmrjournals.com/public/index.php/master/Article/getJournalCites';
|
||||
|
||||
protected $admin_obj = '';
|
||||
protected $journal_obj = '';
|
||||
protected $article_obj = '';
|
||||
@@ -29,7 +31,9 @@ class Publish extends Controller
|
||||
protected $journal_paper_art_obj = '';
|
||||
protected $subscribe_journal_obj = '';
|
||||
protected $subscribe_topic_obj = '';
|
||||
|
||||
protected $super_danger_obj = '';
|
||||
|
||||
|
||||
public function __construct(\think\Request $request = null) {
|
||||
parent::__construct($request);
|
||||
$this->admin_obj = Db::name('admin');
|
||||
@@ -49,19 +53,100 @@ class Publish extends Controller
|
||||
$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');
|
||||
}
|
||||
|
||||
/**
|
||||
* @title 获取期刊列表
|
||||
* @description 获取期刊列表
|
||||
* @author wangjinlei
|
||||
* @url /super/Publish/getMain
|
||||
* @method POST
|
||||
*
|
||||
* @return journals:期刊信息array#
|
||||
*/
|
||||
public function getMain(){
|
||||
$journals = $this->journal_obj->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;
|
||||
$cache_arts = $this->object_to_array(json_decode(myPost(self::JURL,$cs)));
|
||||
$journals[$k]['arts'] = $cache_arts['data'];
|
||||
$journals[$k]['artCount'] = count($cache_arts['data']);
|
||||
}
|
||||
$re['journals'] = $journals;
|
||||
return jsonSuccess($re);
|
||||
}
|
||||
|
||||
/**
|
||||
* 自动任务存储危险值
|
||||
*/
|
||||
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/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);
|
||||
}
|
||||
|
||||
public function test(){
|
||||
echo $this->calMark(1);
|
||||
echo strtotime('2021-02-24');
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo THINK_VERSION;
|
||||
// return '<style type="text/css">*{ padding: 0; margin: 0; } div{ padding: 4px 48px;} a{color:#2E5CD5;cursor: pointer;text-decoration: none} a:hover{text-decoration:underline; } body{ background: #fff; font-family: "Century Gothic","Microsoft yahei"; color: #333;font-size:18px;} h1{ font-size: 100px; font-weight: normal; margin-bottom: 12px; } p{ line-height: 1.6em; font-size: 42px }</style><div style="padding: 24px 48px;"> <h1>:)</h1><p> ThinkPHP V5<br/><span style="font-size:30px">十年磨一剑 - 为API开发设计的高性能框架</span></p><span style="font-size:22px;">[ V5.0 版本由 <a href="http://www.qiniu.com" target="qiniu">七牛云</a> 独家赞助发布 ]</span></div><script type="text/javascript" src="http://tajs.qq.com/stats?sId=9347272" charset="UTF-8"></script><script type="text/javascript" src="http://ad.topthink.com/Public/static/client.js"></script><thinkad id="ad_bd568ce7058a1091"></thinkad>';
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -80,18 +165,38 @@ class Publish extends Controller
|
||||
->order('journal_stage_id desc')
|
||||
->limit(1)
|
||||
->select();
|
||||
$stage_now = $last_stage[0];
|
||||
$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'];
|
||||
|
||||
$frag = [];
|
||||
$frag['count'] = $count;
|
||||
$frag['sy'] = $cycle*30 - $cday;
|
||||
$frag['ntime'] = strtotime($stage_now['issue_date'])+($cycle*30*3600*24);
|
||||
|
||||
if($cday>($cycle*30)){
|
||||
return 100;
|
||||
$frag['mk'] = 100;
|
||||
return $frag;
|
||||
}
|
||||
$lart = intval($cday*$art_num/($cycle*30));
|
||||
if($count>=$lart){
|
||||
return 0;
|
||||
$frag['mk'] = 0;
|
||||
}else{
|
||||
return ($lart - $count)*100/$art_num;
|
||||
$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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user