Browse Source

固定查询组数据

master
wanghongjun 1 year ago
parent
commit
c79eacb41f
  1. 4
      source/application/api/controller/pass/Statistics.php
  2. 17
      source/application/common/logic/PassFlow.php

4
source/application/api/controller/pass/Statistics.php

@ -29,12 +29,14 @@ class Statistics extends Controller
$dm = new Dm(); $dm = new Dm();
$arr = ['110', '210', '310', '510', '610'];
$start_time = "{$year}-01-01" . 'T00:00:00.000+08:00'; $start_time = "{$year}-01-01" . 'T00:00:00.000+08:00';
$end_time = "{$year}-12-31" . 'T23:59:59.000+08:00'; $end_time = "{$year}-12-31" . 'T23:59:59.000+08:00';
$yearWhere = '"date" =' . "'month'" $yearWhere = '"date" =' . "'month'"
. ' and "granularity"=' . "'monthly'" . ' and "granularity"=' . "'monthly'"
. ' and "statTime">=' . "'{$start_time}'" . ' and "statTime">=' . "'{$start_time}'"
. ' and "statTime"<=' . "'{$end_time}'"; . ' and "statTime"<=' . "'{$end_time}'"
. ' and "groupId" in (' . "'" . implode("','", $arr) . "'" . ')';
# 体育馆 体育场 劳务博物馆 游泳场馆 # 体育馆 体育场 劳务博物馆 游泳场馆
$tyData = []; $tyData = [];

17
source/application/common/logic/PassFlow.php

@ -35,6 +35,12 @@ class PassFlow
} }
return $groupIdArr; return $groupIdArr;
} }
protected static function getGroupIdArr() {
$arr = ['110', '210', '310', '510', '610'];
return "'" . implode("','", $arr) . "'";
}
/** /**
* 分时时间段接口 <首页-客流趋势> * 分时时间段接口 <首页-客流趋势>
* @return array * @return array
@ -69,6 +75,7 @@ class PassFlow
$end_time = $date['day']['end_time']; $end_time = $date['day']['end_time'];
$where .= $where ? ' and "granularity" = ' . "'hourly'" : ' "granularity" = ' . "'hourly'"; $where .= $where ? ' and "granularity" = ' . "'hourly'" : ' "granularity" = ' . "'hourly'";
$where .= ' and "statTime" >= ' . "'{$start_time}'" . ' and "statTime" <= ' . "'{$end_time}'"; $where .= ' and "statTime" >= ' . "'{$start_time}'" . ' and "statTime" <= ' . "'{$end_time}'";
$where .= ' and "groupId" in (' . self::getGroupIdArr() . ')';
$list = $dm->select('bt_passenger_flow', $where); $list = $dm->select('bt_passenger_flow', $where);
$data = self::handleGroupData($list,'H:00',$dm,$groupsId); $data = self::handleGroupData($list,'H:00',$dm,$groupsId);
$allTimeData = $data['allTimeData']; $allTimeData = $data['allTimeData'];
@ -80,6 +87,7 @@ class PassFlow
$end_time = $date['month']['end_time']; $end_time = $date['month']['end_time'];
$where .= $where ? ' and "granularity" = ' . "'daily'" : ' "granularity" = ' . "'daily'"; $where .= $where ? ' and "granularity" = ' . "'daily'" : ' "granularity" = ' . "'daily'";
$where .= ' and "statTime" >= ' . "'{$start_time}'" . ' and "statTime" <= ' . "'{$end_time}'"; $where .= ' and "statTime" >= ' . "'{$start_time}'" . ' and "statTime" <= ' . "'{$end_time}'";
$where .= ' and "groupId" in (' . self::getGroupIdArr() . ')';
$list = $dm->select('bt_passenger_flow', $where); $list = $dm->select('bt_passenger_flow', $where);
$data = self::handleGroupData($list, 'd',$dm,$groupsId); $data = self::handleGroupData($list, 'd',$dm,$groupsId);
$allTimeData = $data['allTimeData']; $allTimeData = $data['allTimeData'];
@ -91,6 +99,7 @@ class PassFlow
$end_time = $date['year']['end_time']; $end_time = $date['year']['end_time'];
$where .= $where ? ' and "granularity" = ' . "'monthly'" : ' "granularity" = ' . "'monthly'"; $where .= $where ? ' and "granularity" = ' . "'monthly'" : ' "granularity" = ' . "'monthly'";
$where .= ' and "statTime" >= ' . "'{$start_time}'" . ' and "statTime" <= ' . "'{$end_time}'"; $where .= ' and "statTime" >= ' . "'{$start_time}'" . ' and "statTime" <= ' . "'{$end_time}'";
$where .= ' and "groupId" in (' . self::getGroupIdArr() . ')';
$list = $dm->select('bt_passenger_flow', $where); $list = $dm->select('bt_passenger_flow', $where);
$data = self::handleGroupData($list, 'm',$dm,$groupsId); $data = self::handleGroupData($list, 'm',$dm,$groupsId);
$allTimeData = $data['allTimeData']; $allTimeData = $data['allTimeData'];
@ -294,6 +303,7 @@ class PassFlow
foreach ($dateArr as $date => $granularity) { foreach ($dateArr as $date => $granularity) {
$where = ' "granularity" = ' . "'{$granularity}'" . ' and "date" = ' . "'{$date}' {$paramWhere}"; $where = ' "granularity" = ' . "'{$granularity}'" . ' and "date" = ' . "'{$date}' {$paramWhere}";
$where .= ' and "statTime" >= ' . "'{$dateData[$date]['start_time']}'" . ' and "statTime" <= ' . "'{$dateData[$date]['end_time']}'"; $where .= ' and "statTime" >= ' . "'{$dateData[$date]['start_time']}'" . ' and "statTime" <= ' . "'{$dateData[$date]['end_time']}'";
$where .= ' and "groupId" in (' . self::getGroupIdArr() . ')';
$list = $dm->select( $list = $dm->select(
'bt_passenger_flow_all', 'bt_passenger_flow_all',
$where $where
@ -313,6 +323,7 @@ class PassFlow
#累计进馆人数 #累计进馆人数
$sumWhere = ' "granularity" = ' . "'yearly'" . ' and "date" = ' . "'year' {$paramWhere}" $sumWhere = ' "granularity" = ' . "'yearly'" . ' and "date" = ' . "'year' {$paramWhere}"
. ' and "statTime" >= ' . "'{$dateData['year']['start_time']}'" . ' and "statTime" <= ' . "'{$dateData['year']['end_time']}'"; . ' and "statTime" >= ' . "'{$dateData['year']['start_time']}'" . ' and "statTime" <= ' . "'{$dateData['year']['end_time']}'";
$sumWhere .= ' and "groupId" in (' . self::getGroupIdArr() . ')';
$sumFind = $dm->find('bt_passenger_flow_all', $sumWhere,'SUM("flowInNum") as NUM'); $sumFind = $dm->find('bt_passenger_flow_all', $sumWhere,'SUM("flowInNum") as NUM');
$returnData['sumYear']['noRepeatInNum'] = isset($sumFind['NUM']) ? $sumFind['NUM'] : 0; $returnData['sumYear']['noRepeatInNum'] = isset($sumFind['NUM']) ? $sumFind['NUM'] : 0;
@ -358,8 +369,8 @@ class PassFlow
public static function realTimeData($dm = null) public static function realTimeData($dm = null)
{ {
if (empty($dm)) $dm = new Dm(); if (empty($dm)) $dm = new Dm();
$where = ' "groupId" in (' . self::getGroupIdArr() . ')';
$list = $dm->select('bt_passenger_flow_real'); $list = $dm->select('bt_passenger_flow_real', $where);
$data = []; $data = [];
// $configRes = $dm->find("bt_config",' "key" = ' . "'threshold'"); // $configRes = $dm->find("bt_config",' "key" = ' . "'threshold'");
@ -482,6 +493,7 @@ class PassFlow
$start_time = $date['day']['start_time']; $start_time = $date['day']['start_time'];
$end_time = $date['day']['end_time']; $end_time = $date['day']['end_time'];
$where .= ' and "statTime" >= ' . "'{$start_time}'" . ' and "statTime" <= ' . "'{$end_time}'"; $where .= ' and "statTime" >= ' . "'{$start_time}'" . ' and "statTime" <= ' . "'{$end_time}'";
$where .= ' and "groupId" in (' . self::getGroupIdArr() . ')';
$list = $dm->select('bt_passenger_flow',$where); $list = $dm->select('bt_passenger_flow',$where);
$allTimeData = []; $allTimeData = [];
for ($i = 0; $i <= 23; $i++) { for ($i = 0; $i <= 23; $i++) {
@ -661,6 +673,7 @@ class PassFlow
$end_time = date("Y-m-d\TH") . ':59:59.000+08:00'; $end_time = date("Y-m-d\TH") . ':59:59.000+08:00';
$where .= ' and "statTime" >= ' . "'{$start_time}'" . ' and "statTime" <= ' . "'{$end_time}'"; $where .= ' and "statTime" >= ' . "'{$start_time}'" . ' and "statTime" <= ' . "'{$end_time}'";
$where .= ' and "groupId" in (' . self::getGroupIdArr() . ')';
$list = $dm->select('bt_passenger_flow',$where); $list = $dm->select('bt_passenger_flow',$where);
$allTimeData = []; $allTimeData = [];
$returnData = []; $returnData = [];

Loading…
Cancel
Save