|
|
|
@ -4,6 +4,7 @@ namespace app\api\controller\pass; |
|
|
|
|
|
|
|
use app\api\controller\Controller; |
|
|
|
|
|
|
|
use app\common\dm\Dm; |
|
|
|
use think\Db; |
|
|
|
|
|
|
|
class Passcc extends Controller |
|
|
|
@ -26,28 +27,35 @@ class Passcc extends Controller |
|
|
|
$groupsId = $this->request->param('groupsId'); |
|
|
|
|
|
|
|
if (empty($granularity)) return $this->renderError('date参数不能为空'); |
|
|
|
$where = []; |
|
|
|
if (!empty($groupsId)) $where['groups_id'] = implode(",",$groupsId); |
|
|
|
$where = ''; |
|
|
|
if (!empty($groupsId)) $where .= ' "groups_id" in(' . "'" . implode("','",$groupsId) . "')"; |
|
|
|
$allTimeData = []; |
|
|
|
$groupsData = []; |
|
|
|
$dkeys=[]; |
|
|
|
$dm = new Dm(); |
|
|
|
if ($granularity == 'daily') { |
|
|
|
$where['granularity'] = 'hourly'; |
|
|
|
$list = Db::table('bt_passenger_flow')->where($where)->select()->toArray(); |
|
|
|
// $where['granularity'] = 'hourly'; |
|
|
|
// $list = Db::table('bt_passenger_flow')->where($where)->select()->toArray(); |
|
|
|
$where .= $where ? ' and "granularity" = ' . "'hourly'" : ' "granularity" = ' . "'hourly'"; |
|
|
|
$list = $dm->select('bt_passenger_flow',$where); |
|
|
|
$data = $this->handleGroupData($list); |
|
|
|
$allTimeData = $data['allTimeData']; |
|
|
|
$groupsData = $data['groupsData']; |
|
|
|
$dkeys = $data['dkeys']; |
|
|
|
} elseif ($granularity == 'monthly') { |
|
|
|
$where['granularity'] = 'daily'; |
|
|
|
$list = Db::table('bt_passenger_flow')->where($where)->select()->toArray(); |
|
|
|
// $where['granularity'] = 'daily'; |
|
|
|
// $list = Db::table('bt_passenger_flow')->where($where)->select()->toArray(); |
|
|
|
$where .= $where ? ' and "granularity" = ' . "'daily'" : ' "granularity" = ' . "'daily'"; |
|
|
|
$list = $dm->select('bt_passenger_flow',$where); |
|
|
|
$data = $this->handleGroupData($list,'d'); |
|
|
|
$allTimeData = $data['allTimeData']; |
|
|
|
$groupsData = $data['groupsData']; |
|
|
|
$dkeys = $data['dkeys']; |
|
|
|
} elseif ($granularity == 'yearly') { |
|
|
|
$where['granularity'] = 'monthly'; |
|
|
|
$list = Db::table('bt_passenger_flow')->where($where)->select()->toArray(); |
|
|
|
// $where['granularity'] = 'monthly'; |
|
|
|
// $list = Db::table('bt_passenger_flow')->where($where)->select()->toArray(); |
|
|
|
$where .= $where ? ' and "granularity" = ' . "'monthly'" : ' "granularity" = ' . "'monthly'"; |
|
|
|
$list = $dm->select('bt_passenger_flow',$where); |
|
|
|
$data = $this->handleGroupData($list,'m'); |
|
|
|
$allTimeData = $data['allTimeData']; |
|
|
|
$groupsData = $data['groupsData']; |
|
|
|
@ -132,10 +140,15 @@ class Passcc extends Controller |
|
|
|
$y = date("Y"); |
|
|
|
# 总进馆人数 |
|
|
|
$yearSum = 0; |
|
|
|
$dm = new Dm(); |
|
|
|
foreach ($dateArr as $date => $granularity) { |
|
|
|
|
|
|
|
$list = Db::table('bt_passenger_flow_all') |
|
|
|
->where(['granularity' => $granularity, 'date' => $date])->select()->toArray(); |
|
|
|
// $list = Db::table('bt_passenger_flow_all') |
|
|
|
// ->where(['granularity' => $granularity, 'date' => $date])->select()->toArray(); |
|
|
|
$list = $dm->select( |
|
|
|
'bt_passenger_flow_all', |
|
|
|
' "granularity" = ' . "'{$granularity}'" . ' and "date" = ' . "'{$date}'" |
|
|
|
); |
|
|
|
|
|
|
|
$returnData[$date]['noRepeatInNum'] = 0; |
|
|
|
foreach ($list as $value) { |
|
|
|
@ -164,9 +177,11 @@ class Passcc extends Controller |
|
|
|
* @throws \think\db\exception\ModelNotFoundException |
|
|
|
* @throws \think\exception\DbException |
|
|
|
*/ |
|
|
|
public function realTimeData() { |
|
|
|
|
|
|
|
$list = Db::table('bt_passenger_flow_real')->select()->toArray(); |
|
|
|
public function realTimeData() |
|
|
|
{ |
|
|
|
$dm = new Dm(); |
|
|
|
// $list = Db::table('bt_passenger_flow_real')->select()->toArray(); |
|
|
|
$list = $dm->select('bt_passenger_flow_real'); |
|
|
|
$data = []; |
|
|
|
|
|
|
|
$sumAllEnter = 0; |
|
|
|
@ -195,7 +210,9 @@ class Passcc extends Controller |
|
|
|
*/ |
|
|
|
public function toDayGroupsEnterNum() |
|
|
|
{ |
|
|
|
$list = Db::table('bt_passenger_flow')->where(['granularity' => 'hourly'])->select()->toArray(); |
|
|
|
$dm = new Dm(); |
|
|
|
// $list = Db::table('bt_passenger_flow')->where(['granularity' => 'hourly'])->select()->toArray(); |
|
|
|
$list = $dm->select('bt_passenger_flow',' "granularity"='."'hourly'"); |
|
|
|
$allTimeData = []; |
|
|
|
for ($i = 9; $i < 23; $i++) { |
|
|
|
$str = strlen($i) == 1 ? '0'.$i.':00' : $i.':00'; |
|
|
|
|