diff --git a/application/master/controller/Admin.php b/application/master/controller/Admin.php index 4e5fc06..8e5f586 100644 --- a/application/master/controller/Admin.php +++ b/application/master/controller/Admin.php @@ -3,6 +3,7 @@ namespace app\master\controller; use think\Controller; use think\Db; +use think\Cache; /** * @title 管理员接口 @@ -153,6 +154,40 @@ class Admin extends Controller 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 添加管理员 * @description 添加管理员 diff --git a/application/master/controller/Article.php b/application/master/controller/Article.php index 92d61cb..b83e74f 100644 --- a/application/master/controller/Article.php +++ b/application/master/controller/Article.php @@ -1152,7 +1152,7 @@ http://www.crossref.org/schemas/crossref4.3.7.xsd">' . PHP_EOL . PHP_EOL; $xml .= '' . PHP_EOL; } $xml .= '' . $v['first_name'] . '' . PHP_EOL; - $xml .= '' . $v['last_name'] . '' . PHP_EOL; + $xml .= '' . ($v['last_name']==''?$v['first_name']:$v['last_name']) . '' . PHP_EOL; $xml .= '' . PHP_EOL; } $xml .= '' . PHP_EOL; @@ -1255,7 +1255,7 @@ http://www.crossref.org/schemas/crossref4.3.7.xsd">' . PHP_EOL . PHP_EOL; $xml .= '' . PHP_EOL; } $xml .= '' . $v['first_name'] . '' . PHP_EOL; - $xml .= '' . $v['last_name'] . '' . PHP_EOL; + $xml .= '' . ($v['last_name']==''?$v['first_name']:$v['last_name']) . '' . PHP_EOL; $xml .= '' . PHP_EOL; } $xml .= '' . PHP_EOL; diff --git a/application/super/controller/Publish.php b/application/super/controller/Publish.php index b96ff39..aed29a6 100644 --- a/application/super/controller/Publish.php +++ b/application/super/controller/Publish.php @@ -253,9 +253,11 @@ class Publish extends Controller{ * @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['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(); @@ -266,7 +268,18 @@ class Publish extends Controller{ }else{ $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(); if($res==null){ $insert['type']= $data['type']; @@ -286,7 +299,6 @@ class Publish extends Controller{ * @author wangjinlei * @url /super/Publish/getVisit * @method POST - * */ public function getVisit(){ $t = strtotime("-4 month"); @@ -298,7 +310,11 @@ class Publish extends Controller{ $frag[$ntime] = []; foreach ($visits as $v){ 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){ $frag1['de'][$k] = isset($frag[$k]['de'])?$frag[$k]['de']:0; 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){ - $num = 0; - foreach ($v as $vv){ - $num += $vv; + 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; } - $frag1[$k]['all'] = $num; $frag1[$k]['title'] = $k; } return jsonSuccess(array_values($frag1));