コード例 #1
0
 /**
  * 所选时间段范围内的每7天WiFi连接数与注册数
  */
 public function wifidataweekAction()
 {
     $data = reqstr('data');
     if (!$data) {
         return;
     }
     $data = urldecode($data);
     $info = array();
     parse_str($data, $info);
     $date = (int) $info['date'] ? (int) $info['date'] : 7;
     //默认是查出7天的数据
     $sdate = trim($info['sdate']) ? trim($info['sdate']) : '';
     $edate = trim($info['edate']) ? trim($info['edate']) : '';
     //默认是青岛南
     $station = empty($info['station']) ? 1 : implode(',', $info['station']);
     if (!$sdate || !$edate) {
         $edate = date('Y-m-d');
         $sdate = date('Y-m-d', strtotime("-{$date} day"));
     }
     if ($sdate < '2015-02-01') {
         $sdate = '2015-02-01';
     }
     $isbaifenbi = reqnum('baifenbi', 0);
     $dates = $this->cutdate($sdate, $edate);
     $nt = new Psys_StationModel();
     foreach ($dates as $v_date) {
         $res[] = $nt->wifidataweek($station, $v_date['sdate'], $v_date['edate']);
     }
     $datas[0]['name'] = 'wifi连接数';
     $datas[1]['name'] = '注册数';
     foreach ($res as $v) {
         $result['x_cat'][] = $v['datearea'];
         $datas[0]['data'][] = (int) $v['wifi'];
         $datas[1]['data'][] = (int) $v['reg'];
         if ($isbaifenbi) {
             $baifenbis[0]['name'] = '周注册连接百分比';
             $b = $v['reg'] / $v['wifi'] * 100;
             $baifenbis[0]['data'][] = (double) round($b, 2);
         }
     }
     $result['y_data'] = $datas;
     if ($isbaifenbi) {
         $result['baifenbi'] = $baifenbis;
     }
     return $result;
 }