|
|
|
@ -6,6 +6,35 @@ use app\common\dm\Dm; |
|
|
|
|
|
|
|
class PassFlow |
|
|
|
{ |
|
|
|
protected static $groupType = [1,2];# 1 = 体育 2 = 文化 |
|
|
|
protected static $granularity = ['daily','monthly','yearly'];# 1 = 体育 2 = 文化 |
|
|
|
protected static $groupThreshold = [ |
|
|
|
'baz001' => 40000,# 图书馆 |
|
|
|
'BAF055' => 1000,# 文化馆 |
|
|
|
'110' => [ |
|
|
|
'min' => 8000, |
|
|
|
'max' => 12000 |
|
|
|
],# 体育场 |
|
|
|
'210' => [ |
|
|
|
'min' => 8000, |
|
|
|
'max' => 12000 |
|
|
|
],# 体育馆 |
|
|
|
'310' => [ |
|
|
|
'min' => 6000, |
|
|
|
'max' => 10000 |
|
|
|
],# 游泳馆 |
|
|
|
'510' => 1000 # 博物馆 |
|
|
|
]; |
|
|
|
|
|
|
|
protected static function getGroupIds($dm,$type = 1) |
|
|
|
{ |
|
|
|
$groupIdArr = []; |
|
|
|
$result = $dm->select('bt_passenger_monitor_group',['type' => $type]); |
|
|
|
foreach ($result as $row) { |
|
|
|
$groupIdArr[] = $row['groupId']; |
|
|
|
} |
|
|
|
return $groupIdArr; |
|
|
|
} |
|
|
|
/** |
|
|
|
* 分时时间段接口 <首页-客流趋势> |
|
|
|
* @return array |
|
|
|
@ -17,20 +46,23 @@ class PassFlow |
|
|
|
{ |
|
|
|
|
|
|
|
$granularity = $param['granularity']; |
|
|
|
$groupsId = $param['groupsId']; |
|
|
|
$type = isset($param['type']) ?$param['type']:''; |
|
|
|
|
|
|
|
if (empty($granularity)) return ['code' => 0, 'msg' => '缺少参数:granularity']; |
|
|
|
if (!in_array($granularity,self::$granularity)) return ['code' => 0, 'msg' => '参数错误:granularity']; |
|
|
|
$where = ''; |
|
|
|
if (!empty($groupsId)) { |
|
|
|
$garr = explode("|", $groupsId); |
|
|
|
$where .= ' "groupId" in(' . "'" . implode("','", $garr) . "')"; |
|
|
|
|
|
|
|
$groupsId = ''; |
|
|
|
if (empty($dm)) $dm = new Dm(); |
|
|
|
if (!empty($type)) { |
|
|
|
if (!in_array($type,self::$groupType)) return ['code' => 0, 'msg' => 'type字段参数错误']; |
|
|
|
$groupsIdArr = self::getGroupIds($dm,$type); |
|
|
|
$groupsId = implode("|",$groupsIdArr); |
|
|
|
$where .= ' "groupId" in(' . "'" . implode("','", $groupsIdArr) . "')"; |
|
|
|
} |
|
|
|
|
|
|
|
$allTimeData = []; |
|
|
|
$groupsData = []; |
|
|
|
$dkeys = []; |
|
|
|
if (empty($dm)) $dm = new Dm(); |
|
|
|
if ($granularity == 'daily') { |
|
|
|
$date = self::getDateData('day'); |
|
|
|
$start_time = $date['day']['start_time']; |
|
|
|
@ -86,7 +118,7 @@ class PassFlow |
|
|
|
} |
|
|
|
if ($date == 'week' || $date == 'all') { |
|
|
|
$data['week'] = [ |
|
|
|
'start_time' => date("Y-m-d",strtotime('this week')) . 'T00:00:00.000+08:00', |
|
|
|
'start_time' => date("Y-m-d",strtotime("this week")) . 'T00:00:00.000+08:00', |
|
|
|
'end_time' => date("Y-m-d",strtotime("-".(date("w") - 7) . "day")) . 'T23:59:59.000+08:00' |
|
|
|
]; |
|
|
|
} |
|
|
|
@ -116,7 +148,7 @@ class PassFlow |
|
|
|
$groupsData = []; |
|
|
|
$dkey=[]; |
|
|
|
if ($date_str == 'H:00') { |
|
|
|
$hour = (int)date("H"); |
|
|
|
$hour = (int) date('H'); |
|
|
|
for ($i = 0; $i <= $hour; $i++) { |
|
|
|
$str = strlen($i) == 1 ? '0'.$i.':00' : $i.':00'; |
|
|
|
$allTimeData[$str]['num'] = 0; |
|
|
|
@ -142,6 +174,7 @@ class PassFlow |
|
|
|
$dkey[]=$str; |
|
|
|
} |
|
|
|
} |
|
|
|
# 体育 + 博物馆客流柱状图数据 |
|
|
|
$sumNoRepeatInNum = 0; |
|
|
|
$groupsIdArr = []; |
|
|
|
foreach ($list as $value) { |
|
|
|
@ -156,20 +189,40 @@ class PassFlow |
|
|
|
ksort($allTimeData); |
|
|
|
|
|
|
|
$groupsIdParamArr = []; |
|
|
|
# 总览-合并文化数据 |
|
|
|
if (empty($groupsId)) { |
|
|
|
$res = $dm->select('bt_library',['group_id' => ['baz001','BAF055']]); |
|
|
|
foreach ($res as $row) { |
|
|
|
if (!isset($groupsData[$row['group_name']]['noRepeatInNum'])) $groupsData[$row['group_name']]['noRepeatInNum'] = 0; |
|
|
|
if ($date_str == 'H:00') { |
|
|
|
$sumNoRepeatInNum += $row['today_incount']; |
|
|
|
$groupsData[$row['group_name']]['noRepeatInNum'] = $row['today_incount']; |
|
|
|
$groupsData[$row['group_name']]['noRepeatInNum'] = $row['today_incount']?:0; |
|
|
|
} elseif ($date_str == 'd') { |
|
|
|
$sumNoRepeatInNum += $row['month_incount']; |
|
|
|
$groupsData[$row['group_name']]['noRepeatInNum'] = $row['month_incount']; |
|
|
|
$groupsData[$row['group_name']]['noRepeatInNum'] = $row['month_incount']?:0; |
|
|
|
} elseif ($date_str == 'm') { |
|
|
|
$sumNoRepeatInNum += $row['year_incount']; |
|
|
|
$groupsData[$row['group_name']]['noRepeatInNum'] = $row['year_incount']; |
|
|
|
$groupsData[$row['group_name']]['noRepeatInNum'] = $row['year_incount']?:0; |
|
|
|
} |
|
|
|
} |
|
|
|
$whgData = []; |
|
|
|
if ($date_str == 'H:00') { |
|
|
|
$whgData = $dm->select('bt_library_hours',['create_time' => ['>=',date("Y-m-d 00:00:00")],'group_id' => 'lib001']); |
|
|
|
} elseif ($date_str == 'd') { |
|
|
|
$whgData = $dm->select('bt_library_data',['create_time' => ['>=',date("Y-m-01 00:00:00")],'group_id' => 'lib001','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']); |
|
|
|
} |
|
|
|
# 文化馆客流柱状图数据 |
|
|
|
foreach ($whgData as $whgRow) { |
|
|
|
if ($date_str == 'H:00') { |
|
|
|
$date = $whgRow['hour_time']; |
|
|
|
} else { |
|
|
|
$date = date($date_str,strtotime($whgRow['create_time'])); // 各时间端进馆人数 |
|
|
|
} |
|
|
|
if (!isset($allTimeData[$date])) continue; |
|
|
|
$allTimeData[$date]['num'] += $whgRow['incount']; |
|
|
|
} |
|
|
|
} else { |
|
|
|
$groupsIdParamArr = explode("|",$groupsId); |
|
|
|
} |
|
|
|
@ -230,8 +283,9 @@ class PassFlow |
|
|
|
if (empty($dm)) $dm = new Dm(); |
|
|
|
$paramWhere = ''; |
|
|
|
if (!empty($param)) { |
|
|
|
if (!empty($param['groupsId'])) { |
|
|
|
$groupsId = explode("|",$param['groupsId']); |
|
|
|
if (!empty($param['type'])) { |
|
|
|
if (!in_array($param['type'],self::$groupType)) return ['code' => 0, 'msg' => 'type字段参数错误']; |
|
|
|
$groupsId = self::getGroupIds($dm,$param['type']); |
|
|
|
$paramWhere .= ' and "groupId" in (' . "'" . implode("','",$groupsId) . "')"; |
|
|
|
} |
|
|
|
} |
|
|
|
@ -261,20 +315,28 @@ class PassFlow |
|
|
|
$sumFind = $dm->find('bt_passenger_flow_all', $sumWhere,'SUM("flowInNum") as NUM'); |
|
|
|
$returnData['sumYear']['noRepeatInNum'] = isset($sumFind['NUM']) ? $sumFind['NUM'] : 0; |
|
|
|
|
|
|
|
if (empty($param['groupsId'])) { |
|
|
|
if (empty($groupsId)) { |
|
|
|
# 文化数据 |
|
|
|
$mData = $dm->find('bt_library',['group_id' => 'lib001']); |
|
|
|
$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; |
|
|
|
$returnData['sumYear']['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($libraryData['NUM']) ? $libraryData['NUM'] : 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}'"; |
|
|
|
$weekDate = $dm->find('bt_library_hours',$weekDateWhere,'SUM("incount") as NUM'); |
|
|
|
$returnData['week']['noRepeatInNum'] += isset($weekDate['NUM']) ? $weekDate['NUM'] : 0; |
|
|
|
} |
|
|
|
|
|
|
|
foreach ($returnData as &$val) { |
|
|
|
$val['noRepeatInNum'] = formatNumber($val['noRepeatInNum']); |
|
|
|
} |
|
|
|
@ -296,19 +358,30 @@ class PassFlow |
|
|
|
$list = $dm->select('bt_passenger_flow_real'); |
|
|
|
$data = []; |
|
|
|
|
|
|
|
$configRes = $dm->find("bt_config",' "key" = ' . "'threshold'"); |
|
|
|
$threshold = $configRes['value'] ?: 0; |
|
|
|
// $configRes = $dm->find("bt_config",' "key" = ' . "'threshold'"); |
|
|
|
// $threshold = $configRes['value'] ?: 0; |
|
|
|
|
|
|
|
foreach ($list as $value) { |
|
|
|
if (!isset($data[$value['groupId']]['allEnter'])) $data[$value['groupId']]['allEnter'] = 0; |
|
|
|
$data[$value['groupId']]['allEnter'] += $value['allEnter']; |
|
|
|
if (!isset($data[$value['groupId']]['holdValue'])) $data[$value['groupId']]['holdValue'] = 0; |
|
|
|
$data[$value['groupId']]['holdValue'] += $value['holdValue']; |
|
|
|
} |
|
|
|
$groupThreshold = self::getConfig($dm); |
|
|
|
|
|
|
|
$returnData = []; |
|
|
|
foreach ($data as $groupId => $val) { |
|
|
|
$proportion = $val['allEnter'] > 0 ? round($val['allEnter']/$threshold,2) : 0; |
|
|
|
$val['proportion'] = ($proportion * 100) . "%"; |
|
|
|
$val['congestion'] = self::getPassType($proportion); |
|
|
|
if (!isset($groupThreshold[$groupId])) continue; |
|
|
|
$threshold = $groupThreshold[$groupId]; |
|
|
|
if (is_array($threshold)) { |
|
|
|
$interval = self::getIntervalType($val['holdValue'],$threshold['min'],$threshold['max']); |
|
|
|
$val['proportion'] = $interval['rate']; |
|
|
|
$val['congestion'] = $interval['str']; |
|
|
|
} else { |
|
|
|
$proportion = $val['holdValue'] > 0 ? round($val['holdValue']/$threshold,4) : 0; |
|
|
|
$val['proportion'] = ($proportion * 100) . "%"; |
|
|
|
$val['congestion'] = self::getPassType($proportion); |
|
|
|
} |
|
|
|
$val['groupId'] = $groupId; |
|
|
|
|
|
|
|
$getGroup = $dm->find('bt_passenger_monitor_group',' "groupId" = ' . "'{$groupId}'"); |
|
|
|
@ -318,7 +391,8 @@ class PassFlow |
|
|
|
} |
|
|
|
$libData = $dm->select('bt_library',['group_id' => ['baz001','BAF055']]); |
|
|
|
foreach ($libData as $libRow) { |
|
|
|
$libProportion = $libRow['today_incount'] > 0 ? round($libRow['today_incount']/$threshold,2) : 0; |
|
|
|
$holdValue = abs($libRow['today_incount'] - $libRow['today_outcount']); |
|
|
|
$libProportion = $holdValue > 0 ? round($holdValue/$groupThreshold[$libRow['group_id']],4) : 0; |
|
|
|
// 文化馆排 4# 图书馆 2# |
|
|
|
$isort = $libRow['group_id']=='baz001'?2:4; |
|
|
|
$returnData[] = [ |
|
|
|
@ -343,24 +417,40 @@ class PassFlow |
|
|
|
protected static function getPassType($proportion) |
|
|
|
{ |
|
|
|
# 舒适:阈值<80% |
|
|
|
if ($proportion < 0.8) { |
|
|
|
if ($proportion <= 0.5) { |
|
|
|
return '舒适'; |
|
|
|
} |
|
|
|
# 饱和:80%<阈值<100% |
|
|
|
if (0.8 < $proportion || $proportion < 1) { |
|
|
|
return '饱和'; |
|
|
|
} |
|
|
|
// if (0.8 < $proportion || $proportion < 1) { |
|
|
|
// return '饱和'; |
|
|
|
// } |
|
|
|
# 拥挤:阈值=100% |
|
|
|
if ($proportion == 1) { |
|
|
|
if ($proportion > 0.5 && $proportion <= 1) { |
|
|
|
return '拥挤'; |
|
|
|
} |
|
|
|
# 拥挤:阈值=100% |
|
|
|
if ($proportion >= 1.2) { |
|
|
|
if ($proportion > 1) { |
|
|
|
return '爆满'; |
|
|
|
} |
|
|
|
return ''; |
|
|
|
} |
|
|
|
|
|
|
|
protected static function getIntervalType($proportion,$min,$max) |
|
|
|
{ |
|
|
|
|
|
|
|
if ($proportion < $min) { |
|
|
|
return ['str' => '舒适', 'rate' => '49%']; |
|
|
|
} |
|
|
|
if ($proportion > $min && $proportion < $max) { |
|
|
|
return ['str' => '拥挤', 'rate' => '99%']; |
|
|
|
} |
|
|
|
if ($proportion > $max) { |
|
|
|
return ['str' => '爆满', 'rate' => '149%']; |
|
|
|
} |
|
|
|
|
|
|
|
return ['str' => '', 'rate' => '0%']; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 今日各场馆人数趋势 |
|
|
|
* @return array |
|
|
|
@ -374,9 +464,11 @@ class PassFlow |
|
|
|
|
|
|
|
$where = ' "granularity"='."'hourly' "; |
|
|
|
$groupsWhere = null; |
|
|
|
$groupsId = []; |
|
|
|
if (!empty($param)) { |
|
|
|
if (!empty($param['groupsId'])) { |
|
|
|
$groupsId = explode("|",$param['groupsId']); |
|
|
|
if (!empty($param['type'])) { |
|
|
|
if (!in_array($param['type'],self::$groupType)) return ['code' => 0, 'msg' => 'type字段参数错误']; |
|
|
|
$groupsId = self::getGroupIds($dm,$param['type']); |
|
|
|
$groupsWhere = ['groupId' => $groupsId]; |
|
|
|
$where .= ' and "groupId" in (' . "'" . implode("','",$groupsId) . "')"; |
|
|
|
} |
|
|
|
@ -397,15 +489,15 @@ class PassFlow |
|
|
|
$groupData = $dm->select('bt_passenger_monitor_group',$groupsWhere); |
|
|
|
foreach ($groupData as $groupDataRow) { |
|
|
|
foreach ($allTimeData as $date => $dateValue) { |
|
|
|
$returnData[$groupDataRow['groupName']][$date] = $dateValue; |
|
|
|
$returnData[$groupDataRow['groupId']][$date] = $dateValue; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
foreach ($list as $value) { |
|
|
|
$date = date('H:00',ceil($value['createTime'] / 1000)); // 各时间端进馆人数 |
|
|
|
if (!isset($allTimeData[$date])) continue; |
|
|
|
if (!isset($returnData[$value['groupName']][$allTimeData[$date]])) $returnData[$value['groupName']][$date] = 0; |
|
|
|
$returnData[$value['groupName']][$date] += $value['flowInNum']; |
|
|
|
if (!isset($returnData[$value['groupId']][$allTimeData[$date]])) $returnData[$value['groupId']][$date] = 0; |
|
|
|
$returnData[$value['groupId']][$date] += $value['flowInNum']; |
|
|
|
} |
|
|
|
|
|
|
|
$data = []; |
|
|
|
@ -419,16 +511,31 @@ class PassFlow |
|
|
|
$listData['dkeys'][] = $itemKey; |
|
|
|
$listData['dvalue'][] = $itemRow; |
|
|
|
} |
|
|
|
if (is_numeric($groupName)) { |
|
|
|
$groupData = $dm->find('bt_passenger_monitor_group',['groupId' => $groupName]); |
|
|
|
$groupName = isset($groupData['groupName']) ? $groupData['groupName'] : $groupName; |
|
|
|
} |
|
|
|
$data[] = [ |
|
|
|
'groupName' => $groupName, |
|
|
|
'list' => $listData |
|
|
|
]; |
|
|
|
} |
|
|
|
$data = self::getLibraryGroupHoursList($dm,false,$data); |
|
|
|
|
|
|
|
if(empty($groupsId)){ |
|
|
|
$data = self::getLibraryGroupHoursList($dm,false,$data); |
|
|
|
} |
|
|
|
return $data; |
|
|
|
} |
|
|
|
|
|
|
|
protected static function getWhYearData($dm,$group_id) |
|
|
|
{ |
|
|
|
$start = date("Y-01-01 ") ."00:00:00"; |
|
|
|
$end = date("Y-12-31 ") ."23:59:59"; |
|
|
|
$where = ' "date" = ' . "'year'" . ' and "group_id" = ' . "'{$group_id}'" |
|
|
|
. ' and "create_time" >= ' . "'{$start}'" . ' and "create_time" <= ' . "'{$end}'"; |
|
|
|
$libData = $dm->find('bt_library_data',$where,'incount'); |
|
|
|
return $libData['incount'] ?: 0; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 文化-博物-图书-数据接口 总计服务人数 |
|
|
|
* @return array |
|
|
|
@ -442,37 +549,44 @@ class PassFlow |
|
|
|
# 累计进馆人数 |
|
|
|
$sum_all_incount = 0; |
|
|
|
# 宝安图书馆数据 |
|
|
|
$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_all_incount += $sum_year_incount = $year_incount = isset($res['year_incount']) ? $res['year_incount'] : 0; |
|
|
|
$ts_res = $dm->find('bt_library',['group_id' => 'baz001']); |
|
|
|
$ts_today_incount = isset($ts_res['today_incount']) ? $ts_res['today_incount'] : 0; |
|
|
|
$ts_month_incount = isset($ts_res['month_incount']) ? $ts_res['month_incount'] : 0; |
|
|
|
$ts_year_incount = self::getWhYearData($dm,'baz001'); |
|
|
|
|
|
|
|
# 劳务博物馆数据 |
|
|
|
$dateArr = ['day' => 'daily', 'month' => 'monthly', 'year' => 'yearly']; |
|
|
|
$dateData = self::getDateData(); |
|
|
|
$museumData = []; |
|
|
|
$bw_data = []; |
|
|
|
foreach ($dateArr as $date => $granularity) { |
|
|
|
|
|
|
|
$museumWhere = ' "groupId"='."'510'".' and "granularity" = ' . "'{$granularity}'" . ' and "date" = ' . "'{$date}'"; |
|
|
|
$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; |
|
|
|
$museumRes = $dm->find('bt_passenger_flow_all',$museumWhere,' SUM("flowInNum") as NUM'); |
|
|
|
$bw_data[$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; |
|
|
|
$bw_today_incount = isset($bw_data['day']) ? $bw_data['day'] : 0; |
|
|
|
$bw_month_incount = isset($bw_data['month']) ? $bw_data['month'] : 0; |
|
|
|
$bw_year_incount = isset($bw_data['year']) ? $bw_data['year'] : 0; |
|
|
|
|
|
|
|
# 文化馆 |
|
|
|
$res = $dm->find('bt_library',['group_id' => 'BAF055']); |
|
|
|
$culture_today_count = isset($res['today_incount']) ? $res['today_incount'] : 0; |
|
|
|
# 文化馆数据 |
|
|
|
$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'); |
|
|
|
|
|
|
|
# 累计进馆人数 |
|
|
|
# 总年、月、日总数 |
|
|
|
$sum_today_incount = $ts_today_incount + $bw_today_incount + $wh_today_incount; |
|
|
|
$sum_month_incount = $ts_month_incount + $bw_month_incount + $wh_month_incount; |
|
|
|
$sum_year_incount = $ts_year_incount + $bw_year_incount + $wh_year_incount; |
|
|
|
|
|
|
|
# 累计进馆人数 - 博物馆 |
|
|
|
$sumAllWhere = ' "granularity" = ' . "'yearly'" . ' and "date" = ' . "'year' " . ' and "groupId"='."'510'"; |
|
|
|
$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'); |
|
|
|
$sum_all_incount += $libData ? $libData['SUM'] : 0; |
|
|
|
|
|
|
|
$data = [ |
|
|
|
'month' => [ |
|
|
|
@ -490,15 +604,15 @@ class PassFlow |
|
|
|
'hour24' => [ |
|
|
|
[ |
|
|
|
'groupName' => '图书馆', |
|
|
|
'incount' => $today_incount |
|
|
|
'incount' => $ts_today_incount |
|
|
|
], |
|
|
|
[ |
|
|
|
'groupName' => '博物馆', |
|
|
|
'incount' => $museum_today_incount |
|
|
|
'incount' => $bw_today_incount |
|
|
|
], |
|
|
|
[ |
|
|
|
'groupName' => '文化馆', |
|
|
|
'incount' => $culture_today_count |
|
|
|
'incount' => $wh_today_incount |
|
|
|
], |
|
|
|
] |
|
|
|
]; |
|
|
|
@ -515,8 +629,9 @@ class PassFlow |
|
|
|
|
|
|
|
$where = ' "granularity"='."'hourly' "; |
|
|
|
if (!empty($param)) { |
|
|
|
if (!empty($param['groupsId'])) { |
|
|
|
$groupsId = explode("|",$param['groupsId']); |
|
|
|
if (!empty($param['type'])) { |
|
|
|
if (!in_array($param['type'], self::$groupType)) return ['code' => 0, 'msg' => 'type字段参数错误']; |
|
|
|
$groupsId = self::getGroupIds($dm, $param['type']); |
|
|
|
$where .= ' and "groupId" in (' . "'" . implode("','",$groupsId) . "')"; |
|
|
|
} |
|
|
|
} |
|
|
|
@ -604,14 +719,14 @@ class PassFlow |
|
|
|
if (!isset($returnData[$str])) $returnData[$str] = 0; |
|
|
|
} |
|
|
|
foreach ($list as $value) { |
|
|
|
$date = date('H:00',strtotime($value['statTime'])); // 各时间端进馆人数 |
|
|
|
$date = date('H:00',ceil($value['createTime'] / 1000)); // 各时间端进馆人数 |
|
|
|
if (!isset($allTimeData[$date])) continue; |
|
|
|
$returnData[$date] += $value['flowInNum']; |
|
|
|
} |
|
|
|
# 图书、文化馆 |
|
|
|
$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" = ' . "'lib001'" . ' and "create_time" >= ' . "'{$start_create_time}'" |
|
|
|
$hoursWhere = ' "group_id" in (' . "'baz001','BAF055')" . ' and "create_time" >= ' . "'{$start_create_time}'" |
|
|
|
. ' and "create_time" <= ' . "'{$end_create_time}'" ; |
|
|
|
$hoursRes = $dm->select('bt_library_hours',$hoursWhere); |
|
|
|
foreach ($hoursRes as $hoursRow) { |
|
|
|
@ -646,9 +761,8 @@ class PassFlow |
|
|
|
$groupRes = $dm->select('bt_passenger_monitor_group',['type' => 2],'"groupId","groupName"'); |
|
|
|
$groupsId = []; |
|
|
|
foreach ($groupRes as $groupRow) $groupsId[] = $groupRow['groupId']; |
|
|
|
$data = self::toDayGroupsEnterNum($dm,['groupsId' => implode("|",$groupsId)]); |
|
|
|
$data = self::toDayGroupsEnterNum($dm,['type' => 2]); |
|
|
|
} |
|
|
|
|
|
|
|
# 图书、文化馆 |
|
|
|
$start_create_time = date("Y-m-d 00:00:00"); |
|
|
|
$end_create_time = date("Y-m-d 23:59:59"); |
|
|
|
@ -673,7 +787,7 @@ class PassFlow |
|
|
|
foreach ($hoursRes as $hoursRow) { |
|
|
|
$date = $hoursRow['hour_time']; // 各时间端进馆人数 |
|
|
|
if (!isset($allTimeData[$date])) continue; |
|
|
|
if (!isset($returnData[$hoursRow['group_name']][$allTimeData[$date]])) $returnData[$hoursRow['group_name']][$date] = 0; |
|
|
|
if (!isset($returnData[$hoursRow['group_name']][$date])) $returnData[$hoursRow['group_name']][$date] = 0; |
|
|
|
$returnData[$hoursRow['group_name']][$date] += $hoursRow['incount']; |
|
|
|
} |
|
|
|
|
|
|
|
@ -709,10 +823,31 @@ class PassFlow |
|
|
|
'returncount' => 0 |
|
|
|
]; |
|
|
|
if ($LibLeaseRes) { |
|
|
|
$data['newreader'] = $LibLeaseRes['newreader']; # 今日办证人数 |
|
|
|
$data['servcount'] = $LibLeaseRes['servcount']; # 今日借书册数 |
|
|
|
$data['newreader'] = $LibLeaseRes['newreader']; # 今日办证册数 |
|
|
|
$data['servcount'] = $LibLeaseRes['servcount']; # 今日借书人数 |
|
|
|
$data['returncount'] = $LibLeaseRes['returncount']; # 今日还书册数 |
|
|
|
} |
|
|
|
return $data; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static function getConfig($dm) |
|
|
|
{ |
|
|
|
$res = $dm->select('bt_config'); |
|
|
|
$data = []; |
|
|
|
foreach ($res as $row) { |
|
|
|
|
|
|
|
$dataValue = $row['value']; |
|
|
|
if (strpos($row['value'],"-") !== false) { |
|
|
|
$arr = explode("-",$dataValue); |
|
|
|
$dataValue = [ |
|
|
|
'min' => $arr[0], |
|
|
|
'max' => $arr[1] |
|
|
|
]; |
|
|
|
} |
|
|
|
$data[$row['key']] = $dataValue; |
|
|
|
|
|
|
|
} |
|
|
|
return $data; |
|
|
|
} |
|
|
|
} |
|
|
|
|