|
|
|
@ -362,7 +362,7 @@ class PassFlow |
|
|
|
$where .= ' and "statTime" >= ' . "'{$start_time}'" . ' and "statTime" <= ' . "'{$end_time}'"; |
|
|
|
$list = $dm->select('bt_passenger_flow',$where); |
|
|
|
$allTimeData = []; |
|
|
|
for ($i = 0; $i < 23; $i++) { |
|
|
|
for ($i = 0; $i <= 23; $i++) { |
|
|
|
$str = strlen($i) == 1 ? '0'.$i.':00' : $i.':00'; |
|
|
|
$allTimeData[$str] = 0; |
|
|
|
} |
|
|
|
@ -480,7 +480,7 @@ class PassFlow |
|
|
|
return $data; |
|
|
|
} |
|
|
|
/** |
|
|
|
* 24小时各场馆数据 |
|
|
|
* 体育 24小时各场馆数据 柱状图 |
|
|
|
* @return array |
|
|
|
*/ |
|
|
|
public static function getPassHoursData($dm = null,$param = []) |
|
|
|
@ -525,6 +525,10 @@ class PassFlow |
|
|
|
return $data; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 获取24小时字段 |
|
|
|
* @return array |
|
|
|
*/ |
|
|
|
protected static function getHoursArr() { |
|
|
|
$hours = array(); // 创建空数组 |
|
|
|
|
|
|
|
@ -543,4 +547,120 @@ class PassFlow |
|
|
|
|
|
|
|
return $hours; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 文化 24小时数据 柱状图 |
|
|
|
* @param $dm |
|
|
|
* @return array |
|
|
|
*/ |
|
|
|
public static function getLibraryHours24List($dm = null) |
|
|
|
{ |
|
|
|
if (empty($dm)) $dm = new Dm(); |
|
|
|
|
|
|
|
# 获取时间参数 |
|
|
|
$start_time = date("Y-m-d\TH",strtotime('-23 hours')) . ':00:00.000+08:00'; |
|
|
|
$end_time = date("Y-m-d\TH") . ':59:59.000+08:00'; |
|
|
|
# 获取文化组id |
|
|
|
$groupRes = $dm->select('bt_passenger_monitor_group',['type' => 2],'"groupId","groupName"'); |
|
|
|
$groupsId = []; |
|
|
|
foreach ($groupRes as $groupRow) $groupsId[] = $groupRow['groupId']; |
|
|
|
# 查询文化组 24小时数据 |
|
|
|
$where = ' "granularity"='."'hourly' " . ' and "statTime" >= ' . "'{$start_time}'" . ' and "statTime" <= ' . "'{$end_time}'"; |
|
|
|
$where .= ' and "groupId" in (' . "'" . implode("','",$groupsId) . "')"; |
|
|
|
$list = $dm->select('bt_passenger_flow',$where); |
|
|
|
# 收集参数 |
|
|
|
$allTimeData = []; |
|
|
|
$returnData = []; |
|
|
|
$hoursArr = self::getHoursArr(); |
|
|
|
foreach ($hoursArr as $hoursVal) { |
|
|
|
$str = $hoursVal . ':00'; |
|
|
|
$allTimeData[$str] = 0; |
|
|
|
if (!isset($returnData[$str])) $returnData[$str] = 0; |
|
|
|
} |
|
|
|
foreach ($list as $value) { |
|
|
|
$date = date('H:00',strtotime($value['statTime'])); // 各时间端进馆人数 |
|
|
|
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}'" |
|
|
|
. ' and "create_time" <= ' . "'{$end_create_time}'" ; |
|
|
|
$hoursRes = $dm->select('bt_library_hours',$hoursWhere); |
|
|
|
foreach ($hoursRes as $hoursRow) { |
|
|
|
$date = $hoursRow['hour_time']; |
|
|
|
if (!isset($allTimeData[$date])) continue; |
|
|
|
$returnData[$date] += $hoursRow['incount']; |
|
|
|
} |
|
|
|
|
|
|
|
$data = []; |
|
|
|
foreach ($returnData as $date => $item) { |
|
|
|
|
|
|
|
$data['dkeys'][] = $date; |
|
|
|
$data['dvalue'][] = $item; |
|
|
|
} |
|
|
|
return $data; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 文化 今日各场馆数据 |
|
|
|
* @param $dm |
|
|
|
* @return array |
|
|
|
* @throws \think\db\exception\DataNotFoundException |
|
|
|
* @throws \think\db\exception\ModelNotFoundException |
|
|
|
* @throws \think\exception\DbException |
|
|
|
*/ |
|
|
|
public static function getLibraryGroupHoursList($dm = null) |
|
|
|
{ |
|
|
|
if (empty($dm)) $dm = new Dm(); |
|
|
|
|
|
|
|
# 获取文化组id |
|
|
|
$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)]); |
|
|
|
|
|
|
|
# 图书、文化馆 |
|
|
|
$start_create_time = date("Y-m-d 00:00:00"); |
|
|
|
$end_create_time = date("Y-m-d 23:59:59"); |
|
|
|
$allTimeData = []; |
|
|
|
for ($i = 0; $i <= 23; $i++) { |
|
|
|
$str = strlen($i) == 1 ? '0'.$i.':00' : $i.':00'; |
|
|
|
$allTimeData[$str] = 0; |
|
|
|
} |
|
|
|
$returnData = []; |
|
|
|
|
|
|
|
# 获取各组初始数值 |
|
|
|
$groupData = [['groupName' => '图书馆'], ['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}'" |
|
|
|
. ' and "create_time" <= ' . "'{$end_create_time}'" ; |
|
|
|
$hoursRes = $dm->select('bt_library_hours',$hoursWhere); |
|
|
|
|
|
|
|
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; |
|
|
|
$returnData[$hoursRow['group_name']][$date] += $hoursRow['incount']; |
|
|
|
} |
|
|
|
|
|
|
|
foreach ($returnData as $groupName => $item) { |
|
|
|
$listData = []; |
|
|
|
foreach ($item as $itemKey => $itemRow) { |
|
|
|
$listData['dkeys'][] = $itemKey; |
|
|
|
$listData['dvalue'][] = $itemRow; |
|
|
|
} |
|
|
|
$data[] = [ |
|
|
|
'groupName' => $groupName, |
|
|
|
'list' => $listData |
|
|
|
]; |
|
|
|
} |
|
|
|
|
|
|
|
return $data; |
|
|
|
} |
|
|
|
} |