|
|
|
@ -191,7 +191,7 @@ class PassFlow |
|
|
|
$groupsIdParamArr = []; |
|
|
|
# 总览-合并文化数据 |
|
|
|
if (empty($groupsId)) { |
|
|
|
$res = $dm->select('bt_library',['group_id' => ['baz001','BAF055']]); |
|
|
|
$res = $dm->select('bt_library',['group_id' => ['baz001']]); |
|
|
|
foreach ($res as $row) { |
|
|
|
if (!isset($groupsData[$row['group_name']]['noRepeatInNum'])) $groupsData[$row['group_name']]['noRepeatInNum'] = 0; |
|
|
|
if ($date_str == 'H:00') { |
|
|
|
@ -207,11 +207,11 @@ class PassFlow |
|
|
|
} |
|
|
|
$whgData = []; |
|
|
|
if ($date_str == 'H:00') { |
|
|
|
$whgData = $dm->select('bt_library_hours',['create_time' => ['>=',date("Y-m-d 00:00:00")],'group_id' => 'lib001']); |
|
|
|
$whgData = $dm->select('bt_library_hours',['create_time' => ['>=',date("Y-m-d 00:00:00")],'group_id' => 'baz001']); |
|
|
|
} elseif ($date_str == 'd') { |
|
|
|
$whgData = $dm->select('bt_library_data',['create_time' => ['>=',date("Y-m-01 00:00:00")],'group_id' => 'lib001','date' => 'day']); |
|
|
|
$whgData = $dm->select('bt_library_data',['create_time' => ['>=',date("Y-m-01 00:00:00")],'group_id' => ['baz001', 'BAF055'],'date' => 'day']); |
|
|
|
} elseif ($date_str == 'm') { |
|
|
|
$whgData = $dm->select('bt_library_data',['create_time' => ['>=',date("Y-01-01 00:00:00")],'group_id' => 'lib001','date' => 'month']); |
|
|
|
$whgData = $dm->select('bt_library_data',['create_time' => ['>=',date("Y-01-01 00:00:00")],'group_id' => ['baz001', 'BAF055'],'date' => 'month']); |
|
|
|
} |
|
|
|
# 文化馆客流柱状图数据 |
|
|
|
foreach ($whgData as $whgRow) { |
|
|
|
@ -318,24 +318,26 @@ class PassFlow |
|
|
|
|
|
|
|
if (empty($groupsId)) { |
|
|
|
# 文化数据 |
|
|
|
$mData = $dm->find('bt_library',['group_id' => 'lib001']); |
|
|
|
if (date('Y') == '2024' && date('m') == '09') { |
|
|
|
$mData = $dm->find('bt_library',['group_id' => 'BAF055']); |
|
|
|
$returnData['month']['noRepeatInNum'] += isset($mData['month_incount']) ? $mData['month_incount'] : 0; |
|
|
|
} |
|
|
|
$mData = $dm->find('bt_library',['group_id' => 'baz001']); |
|
|
|
$returnData['day']['noRepeatInNum'] += isset($mData['today_incount']) ? $mData['today_incount'] : 0; |
|
|
|
$returnData['month']['noRepeatInNum'] += isset($mData['month_incount']) ? $mData['month_incount'] : 0; |
|
|
|
//$returnData['year']['noRepeatInNum'] += isset($mData['year_incount']) ? $mData['year_incount'] : 0; |
|
|
|
|
|
|
|
$start = date("Y-01-01 00:00:00",time()); |
|
|
|
$end = date("Y-12-31 23:59:59",time()); |
|
|
|
$libraryDataYearWhere = ' "date" = ' . "'year'" . ' and "group_id" = ' . "'lib001'" . ' and "create_time" >= ' . "'{$start}'" . ' and "create_time" <= ' . "'{$end}'"; |
|
|
|
$libraryDataYear = $dm->find('bt_library_data',$libraryDataYearWhere); |
|
|
|
$returnData['year']['noRepeatInNum'] += isset($libraryDataYear['incount']) ? $libraryDataYear['incount'] : 0; |
|
|
|
|
|
|
|
// $returnData['sumYear']['noRepeatInNum'] += isset($mData['year_incount']) ? $mData['year_incount'] : 0; |
|
|
|
# 文化总年度 |
|
|
|
# $libraryData = $dm->find('bt_library_data',['group_id' => 'lib001','date' => 'year'],'SUM("incount") as NUM'); |
|
|
|
$returnData['sumYear']['noRepeatInNum'] += isset($libraryDataYear['incount']) ? $libraryDataYear['incount'] : 0; |
|
|
|
$libraryDataYearWhere = ' "date" = ' . "'year'" . ' and "group_id" in (' . "'baz001','BAF055'" . ') and "create_time" >= ' . "'{$start}'" . ' and "create_time" <= ' . "'{$end}'"; |
|
|
|
$libraryDataYearRes = $dm->select('bt_library_data',$libraryDataYearWhere); |
|
|
|
foreach ($libraryDataYearRes as $libraryDataYear) { |
|
|
|
$returnData['year']['noRepeatInNum'] += isset($libraryDataYear['incount']) ? $libraryDataYear['incount'] : 0; |
|
|
|
$returnData['sumYear']['noRepeatInNum'] += isset($libraryDataYear['incount']) ? $libraryDataYear['incount'] : 0; |
|
|
|
} |
|
|
|
|
|
|
|
$week_start = date("Y-m-d 00:00:00",strtotime('this week')); |
|
|
|
$week_end = date("Y-m-d 23:59:59",strtotime("-".(date("w") - 7) . "day")); |
|
|
|
$weekDateWhere = ' "group_id" =' . "'lib001'" . ' and "create_time" >= ' . "'{$week_start}'" . ' and "create_time" <= ' . "'{$week_end}'"; |
|
|
|
$weekDateWhere = ' "group_id" =' . "'baz001'" . ' and "create_time" >= ' . "'{$week_start}'" . ' and "create_time" <= ' . "'{$week_end}'"; |
|
|
|
$weekDate = $dm->find('bt_library_hours',$weekDateWhere,'SUM("incount") as NUM'); |
|
|
|
$returnData['week']['noRepeatInNum'] += isset($weekDate['NUM']) ? $weekDate['NUM'] : 0; |
|
|
|
} |
|
|
|
@ -392,11 +394,11 @@ class PassFlow |
|
|
|
$returnData[] = $val; |
|
|
|
} |
|
|
|
|
|
|
|
$libData = $dm->select('bt_library',['group_id' => ['baz001','BAF055']]); |
|
|
|
$libData = $dm->select('bt_library',['group_id' => ['baz001']]); |
|
|
|
foreach ($libData as $libRow) { |
|
|
|
$holdValue = abs($libRow['today_incount'] - $libRow['today_outcount']); |
|
|
|
$libProportion = $holdValue > 0 ? round($holdValue/$groupThreshold[$libRow['group_id']],4) : 0; |
|
|
|
// 文化馆排 4# 图书馆 2# |
|
|
|
// 图书馆 2# |
|
|
|
$isort = $libRow['group_id']=='baz001'?2:4; |
|
|
|
$returnData[] = [ |
|
|
|
'allEnter' => $libRow['today_incount'] ?: 0, |
|
|
|
@ -561,12 +563,18 @@ class PassFlow |
|
|
|
$dateArr = ['day' => 'daily', 'month' => 'monthly', 'year' => 'yearly']; |
|
|
|
$dateData = self::getDateData(); |
|
|
|
$bw_data = []; |
|
|
|
$wh_data = []; # 文化平台数据 |
|
|
|
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("flowInNum") as NUM'); |
|
|
|
$bw_data[$date] = $museumRes['NUM'] ?: 0; |
|
|
|
|
|
|
|
$whWhere = ' "groupId"='."'610'".' and "granularity" = ' . "'{$granularity}'".' and "date" = ' . "'{$date}'" ; |
|
|
|
$whWhere .= ' and "statTime" >= ' . "'{$dateData[$date]['start_time']}'" . ' and "statTime" <= ' . "'{$dateData[$date]['end_time']}'"; |
|
|
|
$whRes = $dm->find('bt_passenger_flow_all',$whWhere,' SUM("flowInNum") as NUM'); |
|
|
|
$wh_data[$date] = $whRes['NUM'] ?: 0; |
|
|
|
} |
|
|
|
$bw_today_incount = isset($bw_data['day']) ? $bw_data['day'] : 0; |
|
|
|
$bw_month_incount = isset($bw_data['month']) ? $bw_data['month'] : 0; |
|
|
|
@ -574,9 +582,18 @@ class PassFlow |
|
|
|
|
|
|
|
# 文化馆数据 |
|
|
|
$wh_res = $dm->find('bt_library',['group_id' => 'BAF055']); |
|
|
|
$wh_today_incount = isset($wh_res['today_incount']) ? $wh_res['today_incount'] : 0; |
|
|
|
$wh_month_incount = isset($wh_res['month_incount']) ? $wh_res['month_incount'] : 0; |
|
|
|
$wh_year_incount = self::getWhYearData($dm,'BAF055'); |
|
|
|
$wh_month_incount = 0; |
|
|
|
$wh_year_incount = 0; |
|
|
|
if (date('Y') == 2024) { |
|
|
|
$wh_year_incount = self::getWhYearData($dm,'BAF055'); |
|
|
|
if (date('m') == '09') { |
|
|
|
$wh_month_incount = isset($wh_res['month_incount']) ? $wh_res['month_incount'] : 0; |
|
|
|
} |
|
|
|
} |
|
|
|
## 平台新数据 |
|
|
|
$wh_today_incount = isset($wh_data['day']) ? $wh_data['day'] : 0; |
|
|
|
$wh_month_incount += isset($wh_data['month']) ? $wh_data['month'] : 0; |
|
|
|
$wh_year_incount += isset($wh_data['year']) ? $wh_data['year'] : 0; |
|
|
|
|
|
|
|
# 总年、月、日总数 |
|
|
|
$sum_today_incount = $ts_today_incount + $bw_today_incount + $wh_today_incount; |
|
|
|
@ -584,11 +601,11 @@ class PassFlow |
|
|
|
$sum_year_incount = $ts_year_incount + $bw_year_incount + $wh_year_incount; |
|
|
|
|
|
|
|
# 累计进馆人数 - 博物馆 |
|
|
|
$sumAllWhere = ' "granularity" = ' . "'yearly'" . ' and "date" = ' . "'year' " . ' and "groupId"='."'510'"; |
|
|
|
$sumAllWhere = ' "granularity" = ' . "'yearly'" . ' and "date" = ' . "'year' " . ' and "groupId" in'."('510','610')"; |
|
|
|
$sumAllFind = $dm->find('bt_passenger_flow_all', $sumAllWhere,'SUM("flowInNum") as NUM'); |
|
|
|
$sum_all_incount += isset($sumAllFind['NUM']) ? $sumAllFind['NUM'] : 0; |
|
|
|
# 累计进馆人数 - 文化、图书 |
|
|
|
$libData = $dm->find('bt_library_data',['group_id' => 'lib001','date' => 'year'],' SUM("incount") as SUM'); |
|
|
|
$libData = $dm->find('bt_library_data',['group_id' => ['BAF055','baz001'],'date' => 'year'],' SUM("incount") as SUM'); |
|
|
|
$sum_all_incount += $libData ? $libData['SUM'] : 0; |
|
|
|
|
|
|
|
$data = [ |
|
|
|
@ -729,7 +746,7 @@ class PassFlow |
|
|
|
# 图书、文化馆 |
|
|
|
$start_create_time = date("Y-m-d H:00:00",strtotime('-23 hours')); |
|
|
|
$end_create_time = date("Y-m-d H:59:59"); |
|
|
|
$hoursWhere = ' "group_id" in (' . "'baz001','BAF055')" . ' and "create_time" >= ' . "'{$start_create_time}'" |
|
|
|
$hoursWhere = ' "group_id" in (' . "'baz001')" . ' and "create_time" >= ' . "'{$start_create_time}'" |
|
|
|
. ' and "create_time" <= ' . "'{$end_create_time}'" ; |
|
|
|
$hoursRes = $dm->select('bt_library_hours',$hoursWhere); |
|
|
|
foreach ($hoursRes as $hoursRow) { |
|
|
|
@ -777,13 +794,13 @@ class PassFlow |
|
|
|
$returnData = []; |
|
|
|
|
|
|
|
# 获取各组初始数值 |
|
|
|
$groupData = [['groupName' => '图书馆'], ['groupName' => '文化馆']]; |
|
|
|
$groupData = [['groupName' => '图书馆']]; |
|
|
|
foreach ($groupData as $groupDataRow) { |
|
|
|
foreach ($allTimeData as $date => $dateValue) { |
|
|
|
$returnData[$groupDataRow['groupName']][$date] = $dateValue; |
|
|
|
} |
|
|
|
} |
|
|
|
$hoursWhere = ' "group_id" in (' . "'baz001','BAF055')" . ' and "create_time" >= ' . "'{$start_create_time}'" |
|
|
|
$hoursWhere = ' "group_id" in (' . "'baz001')" . ' and "create_time" >= ' . "'{$start_create_time}'" |
|
|
|
. ' and "create_time" <= ' . "'{$end_create_time}'" ; |
|
|
|
$hoursRes = $dm->select('bt_library_hours',$hoursWhere); |
|
|
|
|
|
|
|
|