diff --git a/source/application/api/controller/pass/Passcc.php b/source/application/api/controller/pass/Passcc.php index 2e0a6bf..17d8cc2 100644 --- a/source/application/api/controller/pass/Passcc.php +++ b/source/application/api/controller/pass/Passcc.php @@ -87,4 +87,14 @@ class Passcc extends Controller return $this->renderSuccess(compact('data')); } + /** + * 24小时各场馆数据 + * @return array + */ + public function getPassHoursData() + { + $groupsId = $this->request->param('groupsId') ?: ''; + $data = PassFlow::getPassHoursData(null,['groupsId' => $groupsId]); + return $this->renderSuccess(compact('data')); + } } \ No newline at end of file diff --git a/source/application/common/logic/PassFlow.php b/source/application/common/logic/PassFlow.php index b0073d1..5c46c40 100644 --- a/source/application/common/logic/PassFlow.php +++ b/source/application/common/logic/PassFlow.php @@ -414,4 +414,45 @@ class PassFlow return $data; } + /** + * 24小时各场馆数据 + * @return array + */ + public static function getPassHoursData($dm = null,$param = []) + { + if (empty($dm)) $dm = new Dm(); + + $where = ' "granularity"='."'hourly' "; + if (!empty($param)) { + if (!empty($param['groupsId'])) { + $groupsId = explode("|",$param['groupsId']); + $where .= ' and "groupId" in (' . "'" . implode("','",$groupsId) . "')"; + } + } + $date = self::getDateData('day'); + $start_time = $date['day']['start_time']; + $end_time = $date['day']['end_time']; + $where .= ' and "statTime" >= ' . "'{$start_time}'" . ' and "statTime" <= ' . "'{$end_time}'"; + $list = $dm->select('bt_passenger_flow',$where); + $allTimeData = []; + for ($i = 0; $i < 23; $i++) { + $str = strlen($i) == 1 ? '0'.$i.':00' : $i.':00'; + $allTimeData[$str] = 0; + } + $returnData = []; + foreach ($list as $value) { + $date = date('H:00',strtotime($value['statTime']) + (8*3600)); // 各时间端进馆人数 + if (!isset($allTimeData[$date])) continue; + if (!isset($returnData[$allTimeData[$date]])) $returnData[$allTimeData[$date]] = 0; + $returnData[$allTimeData[$date]] += $value['noRepeatInNum']; + } + + $data = []; + foreach ($returnData as $date => $item) { + + $data['dkeys'][] = $date; + $data['dvalue'][] = $item; + } + return $data; + } } \ No newline at end of file