Browse Source

优化累计进馆人数

master
wanghongjun 3 years ago
parent
commit
42c93a4a0c
  1. 22
      source/application/common/logic/PassFlow.php

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

@ -226,8 +226,6 @@ class PassFlow
$returnData = []; $returnData = [];
$y = date("Y"); $y = date("Y");
# 总进馆人数
$yearSum = 0;
if (empty($dm)) $dm = new Dm(); if (empty($dm)) $dm = new Dm();
$paramWhere = ''; $paramWhere = '';
if (!empty($param)) { if (!empty($param)) {
@ -236,6 +234,7 @@ class PassFlow
$paramWhere .= ' and "groupId" in (' . "'" . implode("','",$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}' {$paramWhere}"; $where = ' "granularity" = ' . "'{$granularity}'" . ' and "date" = ' . "'{$date}' {$paramWhere}";
@ -248,7 +247,6 @@ class PassFlow
$returnData[$date]['noRepeatInNum'] = 0; $returnData[$date]['noRepeatInNum'] = 0;
foreach ($list as $value) { foreach ($list as $value) {
if ($date == 'year') { if ($date == 'year') {
$yearSum += $value['flowInNum'];
$yDate = date('Y',ceil($value['createTime'] / 1000)); // 各今年端进馆人数 $yDate = date('Y',ceil($value['createTime'] / 1000)); // 各今年端进馆人数
if ($y == $yDate) $returnData[$date]['noRepeatInNum'] += $value['flowInNum']; if ($y == $yDate) $returnData[$date]['noRepeatInNum'] += $value['flowInNum'];
} else { } else {
@ -256,7 +254,11 @@ class PassFlow
} }
} }
} }
$returnData['sumYear']['noRepeatInNum'] = $yearSum;
#累计进馆人数
$sumWhere = ' "granularity" = ' . "'yearly'" . ' and "date" = ' . "'year' {$paramWhere}";
$sumFind = $dm->find('bt_passenger_flow_all', $sumWhere,'SUM("flowInNum") as NUM');
$returnData['sumYear']['noRepeatInNum'] = isset($sumFind['NUM']) ? $sumFind['NUM'] : 0;
foreach ($returnData as &$val) { foreach ($returnData as &$val) {
$val['noRepeatInNum'] = formatNumber($val['noRepeatInNum']); $val['noRepeatInNum'] = formatNumber($val['noRepeatInNum']);
@ -411,11 +413,13 @@ 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();
# 累计进馆人数
$sum_all_incount = 0;
# 宝安图书馆数据 # 宝安图书馆数据
$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_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_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; $sum_all_incount += $sum_year_incount = $year_incount = isset($res['year_incount']) ? $res['year_incount'] : 0;
# 劳务博物馆数据 # 劳务博物馆数据
$dateArr = ['day' => 'daily', 'month' => 'monthly', 'year' => 'yearly']; $dateArr = ['day' => 'daily', 'month' => 'monthly', 'year' => 'yearly'];
@ -437,6 +441,11 @@ class PassFlow
# 文化馆 # 文化馆
# 累计进馆人数
$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;
$data = [ $data = [
'month' => [ 'month' => [
'incount' => $sum_month_incount 'incount' => $sum_month_incount
@ -447,6 +456,9 @@ class PassFlow
'year' => [ 'year' => [
'incount' => $sum_year_incount 'incount' => $sum_year_incount
], ],
'sum_year' => [
'incount' => $sum_all_incount
],
'hour24' => [ 'hour24' => [
[ [
'groupName' => '图书馆', 'groupName' => '图书馆',

Loading…
Cancel
Save