diff --git a/source/application/common/logic/PassFlow.php b/source/application/common/logic/PassFlow.php index 3ac03ee..3859445 100644 --- a/source/application/common/logic/PassFlow.php +++ b/source/application/common/logic/PassFlow.php @@ -226,8 +226,6 @@ class PassFlow $returnData = []; $y = date("Y"); - # 总进馆人数 - $yearSum = 0; if (empty($dm)) $dm = new Dm(); $paramWhere = ''; if (!empty($param)) { @@ -236,6 +234,7 @@ class PassFlow $paramWhere .= ' and "groupId" in (' . "'" . implode("','",$groupsId) . "')"; } } + # 日 周 月 年 $dateData = self::getDateData(); foreach ($dateArr as $date => $granularity) { $where = ' "granularity" = ' . "'{$granularity}'" . ' and "date" = ' . "'{$date}' {$paramWhere}"; @@ -248,7 +247,6 @@ class PassFlow $returnData[$date]['noRepeatInNum'] = 0; foreach ($list as $value) { if ($date == 'year') { - $yearSum += $value['flowInNum']; $yDate = date('Y',ceil($value['createTime'] / 1000)); // 各今年端进馆人数 if ($y == $yDate) $returnData[$date]['noRepeatInNum'] += $value['flowInNum']; } 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) { $val['noRepeatInNum'] = formatNumber($val['noRepeatInNum']); @@ -411,11 +413,13 @@ class PassFlow public static function allFlowTrends($dm = null) { if (empty($dm)) $dm = new Dm(); + # 累计进馆人数 + $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_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']; @@ -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 = [ 'month' => [ 'incount' => $sum_month_incount @@ -447,6 +456,9 @@ class PassFlow 'year' => [ 'incount' => $sum_year_incount ], + 'sum_year' => [ + 'incount' => $sum_all_incount + ], 'hour24' => [ [ 'groupName' => '图书馆',