Beispiel #1
0
 public function stationinfoAction()
 {
     $date = reqstr('date');
     $page = reqnum('page', 1);
     $pagesize = reqnum('rp', 50);
     $isgrahp = reqnum('isgrahp');
     if (!$date) {
         $date = date('Y-m-d', strtotime('-1 day'));
     }
     $nt = new Psys_StationModel();
     //获取全部车站信息
     $allstation = $nt->StationInfo($date);
     if ($allstation['keyval']['ad1']) {
         array_unshift($allstation['keyval'], 'ALL');
     }
     //每个车站信息
     $singerstation = $nt->StationInfo($date, false);
     $stations = $nt->station();
     foreach ($singerstation as &$v) {
         $v['station'] = $this->getstationname($stations, $v['station']);
     }
     array_unshift($singerstation, $allstation['keyval']);
     //拼接数据格式
     $offset = ($page - 1) * $pagesize;
     $data['total'] = count($singerstation);
     $result = array_slice($singerstation, $offset, $pagesize);
     $data['page'] = $page;
     $data['rows'] = $result;
     //拼接返回的数据格式
     $graph = array();
     foreach ($data['rows'] as &$v) {
         $graph[] = $v['cell'] = array_values($v);
         array_splice($v, 0, 7);
     }
     //统计图数据格式
     if ($isgrahp) {
         $res['x_cat'] = array('连接数', '广告1', '注册页', '注册数', '首页数');
         $i = 0;
         foreach ($graph as $k => $v) {
             //拼接分类
             $datas[$k]['name'] = $v[0];
             if ($i > 0) {
                 $datas[$k]['visible'] = false;
             }
             //拼接数据
             array_shift($v);
             foreach ($v as $v1) {
                 $datas[$k]['data'][] = (int) $v1;
             }
             array_pop($datas[$k]['data']);
             $res['y_data'] = $datas;
             $i++;
         }
         return $res;
     }
     return $data;
 }