|
|
@ -180,7 +180,7 @@ class PassFlow |
|
|
* @throws \think\db\exception\ModelNotFoundException |
|
|
* @throws \think\db\exception\ModelNotFoundException |
|
|
* @throws \think\exception\DbException |
|
|
* @throws \think\exception\DbException |
|
|
*/ |
|
|
*/ |
|
|
public static function allGroupNum($dm = null) { |
|
|
public static function allGroupNum($dm = null,$param = []) { |
|
|
|
|
|
|
|
|
$dateArr = ['day' => 'daily', 'week' => 'daily', 'month' => 'monthly', 'year' => 'yearly']; |
|
|
$dateArr = ['day' => 'daily', 'week' => 'daily', 'month' => 'monthly', 'year' => 'yearly']; |
|
|
|
|
|
|
|
|
@ -189,9 +189,16 @@ class PassFlow |
|
|
# 总进馆人数 |
|
|
# 总进馆人数 |
|
|
$yearSum = 0; |
|
|
$yearSum = 0; |
|
|
if (empty($dm)) $dm = new Dm(); |
|
|
if (empty($dm)) $dm = new Dm(); |
|
|
|
|
|
$paramWhere = ''; |
|
|
|
|
|
if (!empty($param)) { |
|
|
|
|
|
if (!empty($param['groupsId'])) { |
|
|
|
|
|
$groupsId = explode("|",$param['groupsId']); |
|
|
|
|
|
$paramWhere .= ' and "groupId" in (' . "'" . implode("','",$groupsId) . "'"; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
$dateData = self::getDateData(); |
|
|
$dateData = self::getDateData(); |
|
|
foreach ($dateArr as $date => $granularity) { |
|
|
foreach ($dateArr as $date => $granularity) { |
|
|
$where = ' "granularity" = ' . "'{$granularity}'" . ' and "date" = ' . "'{$date}'"; |
|
|
$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']}'"; |
|
|
$list = $dm->select( |
|
|
$list = $dm->select( |
|
|
'bt_passenger_flow_all', |
|
|
'bt_passenger_flow_all', |
|
|
@ -294,11 +301,17 @@ class PassFlow |
|
|
* @throws \think\db\exception\ModelNotFoundException |
|
|
* @throws \think\db\exception\ModelNotFoundException |
|
|
* @throws \think\exception\DbException |
|
|
* @throws \think\exception\DbException |
|
|
*/ |
|
|
*/ |
|
|
public static function toDayGroupsEnterNum($dm = null) |
|
|
public static function toDayGroupsEnterNum($dm = null,$param = []) |
|
|
{ |
|
|
{ |
|
|
if (empty($dm)) $dm = new Dm(); |
|
|
if (empty($dm)) $dm = new Dm(); |
|
|
|
|
|
|
|
|
$where = ' "granularity"='."'hourly' "; |
|
|
$where = ' "granularity"='."'hourly' "; |
|
|
|
|
|
if (!empty($param)) { |
|
|
|
|
|
if (!empty($param['groupsId'])) { |
|
|
|
|
|
$groupsId = explode("|",$param['groupsId']); |
|
|
|
|
|
$where .= ' and "groupId" in (' . "'" . implode("','",$groupsId) . "'"; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
$date = self::getDateData('day'); |
|
|
$date = self::getDateData('day'); |
|
|
$start_time = $date['day']['start_time']; |
|
|
$start_time = $date['day']['start_time']; |
|
|
$end_time = $date['day']['end_time']; |
|
|
$end_time = $date['day']['end_time']; |
|
|
@ -338,7 +351,7 @@ class PassFlow |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 图书管数据接口 |
|
|
* 文化-博物-图书-数据接口 总计服务人数 |
|
|
* @return array |
|
|
* @return array |
|
|
* 返回数据:today.incount=今天进 month.incount=本月进 year.incount=今年进 day30.incount=近30天近 outcount=出 |
|
|
* 返回数据:today.incount=今天进 month.incount=本月进 year.incount=今年进 day30.incount=近30天近 outcount=出 |
|
|
* 不传参数就是所有摄像头,传cameraid就是按传的摄像头ID |
|
|
* 不传参数就是所有摄像头,传cameraid就是按传的摄像头ID |
|
|
@ -347,25 +360,56 @@ class PassFlow |
|
|
public static function allFlowTrends($dm = null) |
|
|
public static function allFlowTrends($dm = null) |
|
|
{ |
|
|
{ |
|
|
if (empty($dm)) $dm = new Dm(); |
|
|
if (empty($dm)) $dm = new Dm(); |
|
|
|
|
|
# 宝安图书馆数据 |
|
|
$res = $dm->find('bt_library',['group_id' => 'lib001']); |
|
|
$res = $dm->find('bt_library',['group_id' => 'lib001']); |
|
|
|
|
|
$sum_month_incount = $month_incount = isset($res['month_incount']) ? $res['month_incount'] : 0; |
|
|
|
|
|
$sum_today_incount = $today_incount = isset($res['today_incount']) ? $res['today_incount'] : 0; |
|
|
|
|
|
$sum_year_incount = $year_incount = isset($res['year_incount']) ? $res['year_incount'] : 0; |
|
|
|
|
|
|
|
|
|
|
|
# 劳务博物馆数据 |
|
|
|
|
|
$dateArr = ['day' => 'daily', 'month' => 'monthly', 'year' => 'yearly']; |
|
|
|
|
|
$dateData = self::getDateData(); |
|
|
|
|
|
$museumData = []; |
|
|
|
|
|
foreach ($dateArr as $date => $granularity) { |
|
|
|
|
|
|
|
|
|
|
|
$museumWhere = ' "groupId"='."'510'".' and "granularity" = ' . "'{$granularity}'" . ' and "date" = ' . "'{$date}'"; |
|
|
|
|
|
$museumWhere .= ' and "statTime" >= ' . "'{$dateData[$date]['start_time']}'" . ' and "statTime" <= ' . "'{$dateData[$date]['end_time']}'"; |
|
|
|
|
|
$museumRes = $dm->find('bt_passenger_flow_all',$museumWhere,' SUM("noRepeatInNum") as num'); |
|
|
|
|
|
$museumData[$date] = $museumRes['NUM'] ?: 0; |
|
|
|
|
|
} |
|
|
|
|
|
$museum_today_incount = isset($museumData['day']) ? $museumData['day'] : 0; |
|
|
|
|
|
$sum_today_incount += $museum_today_incount; |
|
|
|
|
|
$museum_month_incount = isset($museumData['month']) ? $museumData['month'] : 0; |
|
|
|
|
|
$sum_month_incount += $museum_month_incount; |
|
|
|
|
|
$museum_year_incount = isset($museumData['year']) ? $museumData['year'] : 0; |
|
|
|
|
|
$sum_year_incount += $museum_year_incount; |
|
|
|
|
|
|
|
|
|
|
|
# 文化馆 |
|
|
|
|
|
|
|
|
$data = [ |
|
|
$data = [ |
|
|
'day30' => [ |
|
|
|
|
|
'incount' => isset($res['day30_incount']) ? $res['day30_incount'] : 0, |
|
|
|
|
|
'outcount' => isset($res['day30_outcount']) ? $res['day30_outcount'] : 0 |
|
|
|
|
|
], |
|
|
|
|
|
'month' => [ |
|
|
'month' => [ |
|
|
'incount' => isset($res['month_incount']) ? $res['month_incount'] : 0, |
|
|
'incount' => $sum_month_incount |
|
|
'outcount' => isset($res['month_outcount']) ? $res['month_outcount'] : 0 |
|
|
|
|
|
], |
|
|
], |
|
|
'today' => [ |
|
|
'today' => [ |
|
|
'incount' => isset($res['today_incount']) ? $res['today_incount'] : 0, |
|
|
'incount' => $sum_today_incount |
|
|
'outcount' => isset($res['today_outcount']) ? $res['today_outcount'] : 0 |
|
|
|
|
|
], |
|
|
], |
|
|
'year' => [ |
|
|
'year' => [ |
|
|
'incount' => isset($res['year_incount']) ? $res['year_incount'] : 0, |
|
|
'incount' => $sum_year_incount |
|
|
'outcount' => isset($res['year_outcount']) ? $res['year_outcount'] : 0 |
|
|
], |
|
|
|
|
|
'hour24' => [ |
|
|
|
|
|
[ |
|
|
|
|
|
'groupName' => '图书馆', |
|
|
|
|
|
'incount' => $today_incount |
|
|
|
|
|
], |
|
|
|
|
|
[ |
|
|
|
|
|
'groupName' => '博物馆', |
|
|
|
|
|
'incount' => $museum_today_incount |
|
|
|
|
|
], |
|
|
|
|
|
[ |
|
|
|
|
|
'groupName' => '文化馆', |
|
|
|
|
|
'incount' => 0 |
|
|
], |
|
|
], |
|
|
|
|
|
] |
|
|
]; |
|
|
]; |
|
|
|
|
|
|
|
|
return $data; |
|
|
return $data; |
|
|
|