This commit is contained in:
wangjinlei
2021-07-26 14:26:35 +08:00
parent 55d2b78440
commit 68de3a8fd6
3 changed files with 74 additions and 10 deletions

View File

@@ -3,6 +3,7 @@ namespace app\master\controller;
use think\Controller; use think\Controller;
use think\Db; use think\Db;
use think\Cache;
/** /**
* @title 管理员接口 * @title 管理员接口
@@ -153,6 +154,40 @@ class Admin extends Controller
return json(['code'=>0,'msg'=>'success']); return json(['code'=>0,'msg'=>'success']);
} }
/**
* @title 数据同步
* @description 数据同步
* @author wangjinlei
* @url /master/Admin/synchronization
* @method POST
*
*/
public function synchronization(){
$ptime = Cache::get('synchronization');
if($ptime){
jsonError('Synchronization minimum interval is 10 minute , last update time:'.$ptime);
}
Cache::set('synchronization',date('Y-m-d H:i:s'),10*60);
$url = "http://api.tmrjournals.cn/public/index.php/master/Admin/cn_synchronization";
$res = myPost($url);
return $res;
}
/**
* 触发cn同步方法
*/
public function cn_synchronization(){
$ptime = Cache::get('synchronization');
if($ptime){
return jsonError('Synchronization minimum interval is 10 minute , last update time:'.$ptime);
}
Cache::set('synchronization',date('Y-m-d H:i:s'),10*60);
exec('curl http://journalapi.tmrjournals.com/public/index.php/api/Main/pushImgFile');
exec("sh /etc/mysql/tongbu.sh");
return jsonSuccess([]);
}
/** /**
* @title 添加管理员 * @title 添加管理员
* @description 添加管理员 * @description 添加管理员

View File

@@ -1152,7 +1152,7 @@ http://www.crossref.org/schemas/crossref4.3.7.xsd">' . PHP_EOL . PHP_EOL;
$xml .= '<person_name sequence="additional" contributor_role="author">' . PHP_EOL; $xml .= '<person_name sequence="additional" contributor_role="author">' . PHP_EOL;
} }
$xml .= '<given_name>' . $v['first_name'] . '</given_name>' . PHP_EOL; $xml .= '<given_name>' . $v['first_name'] . '</given_name>' . PHP_EOL;
$xml .= '<surname>' . $v['last_name'] . '</surname>' . PHP_EOL; $xml .= '<surname>' . ($v['last_name']==''?$v['first_name']:$v['last_name']) . '</surname>' . PHP_EOL;
$xml .= '</person_name>' . PHP_EOL; $xml .= '</person_name>' . PHP_EOL;
} }
$xml .= '</contributors>' . PHP_EOL; $xml .= '</contributors>' . PHP_EOL;
@@ -1255,7 +1255,7 @@ http://www.crossref.org/schemas/crossref4.3.7.xsd">' . PHP_EOL . PHP_EOL;
$xml .= '<person_name sequence="additional" contributor_role="author">' . PHP_EOL; $xml .= '<person_name sequence="additional" contributor_role="author">' . PHP_EOL;
} }
$xml .= '<given_name>' . $v['first_name'] . '</given_name>' . PHP_EOL; $xml .= '<given_name>' . $v['first_name'] . '</given_name>' . PHP_EOL;
$xml .= '<surname>' . $v['last_name'] . '</surname>' . PHP_EOL; $xml .= '<surname>' . ($v['last_name']==''?$v['first_name']:$v['last_name']) . '</surname>' . PHP_EOL;
$xml .= '</person_name>' . PHP_EOL; $xml .= '</person_name>' . PHP_EOL;
} }
$xml .= '</contributors>' . PHP_EOL; $xml .= '</contributors>' . PHP_EOL;

View File

@@ -253,9 +253,11 @@ class Publish extends Controller{
* @method POST * @method POST
* *
* @param name:type type:string require:1 desc:类型1.de2.journal_id * @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(){ public function addVisitNum(){
$data = $this->request->post(); $data = $this->request->post();
$data['is_detail'] = isset($data['is_detail'])?$data['is_detail']:0;
$up_id = 0; $up_id = 0;
if($data['type']=='de'){//数据库访问 if($data['type']=='de'){//数据库访问
$res = $this->visit_log_obj->where('type','de')->where('stime',date('Ym'))->find(); $res = $this->visit_log_obj->where('type','de')->where('stime',date('Ym'))->find();
@@ -266,7 +268,18 @@ class Publish extends Controller{
}else{ }else{
$up_id = $res['vlid']; $up_id = $res['vlid'];
} }
}else{//期刊访问 }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('stime',date('Ym'))->find(); $res = $this->visit_log_obj->where('type',$data['type'])->where('stime',date('Ym'))->find();
if($res==null){ if($res==null){
$insert['type']= $data['type']; $insert['type']= $data['type'];
@@ -286,7 +299,6 @@ class Publish extends Controller{
* @author wangjinlei * @author wangjinlei
* @url /super/Publish/getVisit * @url /super/Publish/getVisit
* @method POST * @method POST
*
*/ */
public function getVisit(){ public function getVisit(){
$t = strtotime("-4 month"); $t = strtotime("-4 month");
@@ -298,7 +310,11 @@ class Publish extends Controller{
$frag[$ntime] = []; $frag[$ntime] = [];
foreach ($visits as $v){ foreach ($visits as $v){
if($v['stime']==$ntime){ if($v['stime']==$ntime){
$frag[$ntime][$v['type']]=$v['num']; if($v['is_detail']==0){
$frag[$ntime][$v['type']]=$v['num'];
}else{
$frag[$ntime][$v['type'].'_detail'] = $v['num'];
}
} }
} }
} }
@@ -307,15 +323,28 @@ class Publish extends Controller{
foreach ($frag as $k => $v){ foreach ($frag as $k => $v){
$frag1['de'][$k] = isset($frag[$k]['de'])?$frag[$k]['de']:0; $frag1['de'][$k] = isset($frag[$k]['de'])?$frag[$k]['de']:0;
foreach ($journals as $val){ foreach ($journals as $val){
$frag1[$val['title']][$k] = isset($frag[$k][$val['journal_id']])?$frag[$k][$val['journal_id']]:0; $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 ($frag1 as $k => $v){ foreach ($frag1 as $k => $v){
$num = 0; if($k=='de'){
foreach ($v as $vv){ $num = 0;
$num += $vv; 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;
} }
$frag1[$k]['all'] = $num;
$frag1[$k]['title'] = $k; $frag1[$k]['title'] = $k;
} }
return jsonSuccess(array_values($frag1)); return jsonSuccess(array_values($frag1));