From 333bbd70dd0477fbfdc394de5ed12cf576b76968 Mon Sep 17 00:00:00 2001 From: wanghongjun <1445693971@qq,com> Date: Thu, 26 Sep 2024 11:06:05 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=87=E5=8C=96=E7=AE=A1=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=90=88=E5=B9=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/controller/pass/Statistics.php | 53 +++++++++++++++++-- 1 file changed, 48 insertions(+), 5 deletions(-) diff --git a/source/application/api/controller/pass/Statistics.php b/source/application/api/controller/pass/Statistics.php index f6f762c..d5eb268 100644 --- a/source/application/api/controller/pass/Statistics.php +++ b/source/application/api/controller/pass/Statistics.php @@ -10,7 +10,7 @@ class Statistics extends Controller private $password = 'batyg@2023'; - protected function validateUserToken($token) { + private function validateUserToken($token) { $xtToken = md5(base64_encode($this->password)); return $xtToken === $token; } @@ -57,6 +57,9 @@ class Statistics extends Controller 'dataResult' => [] ]; + $whgData = isset($tyData['610']) ? $tyData['610'] : ['sum_year' => 0, 'month' => []]; + unset($tyData['610']); + foreach ($tyData as $groupId => $monthData) { @@ -64,10 +67,12 @@ class Statistics extends Controller $groupName = $getGroup['groupName'] ?: ''; $tempData = [ 'name' => $groupName, - 'year' => $monthData['sum_year'], + 'yearAmount' => $monthData['sum_year'], 'monthDate' => [] ]; + ksort($monthData['month']); + foreach ($monthData['month'] as $month => $value) { $tempData['monthDate'][] = [ 'month' => $month, @@ -97,19 +102,24 @@ class Statistics extends Controller $whData[$groupId]['sum_year'] += $item['incount']; if (!isset($whData[$groupId]['month'][$month])) $whData[$groupId]['month'][$month] = 0; - $whData[$groupId]['month'][$month] += $item['incount']; + $whData[$groupId]['month'][010] += $item['incount']; } + $whg2Data = isset($whData['BAF055']) ? $whData['BAF055'] : ['sum_year' => 0, 'month' => []]; + unset($whData['BAF055']); + foreach ($whData as $groupId => $monthData) { $groupName = isset($whGroupName[$groupId]) ? $whGroupName[$groupId] : ''; $tempData = [ 'name' => $groupName, - 'year' => $monthData['sum_year'], + 'yearAmount' => $monthData['sum_year'], 'monthDate' => [] ]; + ksort($monthData['month']); + foreach ($monthData['month'] as $month => $value) { $tempData['monthDate'][] = [ 'month' => $month, @@ -119,6 +129,39 @@ class Statistics extends Controller $data['dataResult'][] = $tempData; } + // 文化馆两数据合并 + $getGroup = $dm->find('bt_passenger_monitor_group',' "groupId" = ' . "'610'"); + $groupName = $getGroup['groupName'] ?: ''; + + $tempData = [ + 'name' => $groupName, + 'yearAmount' => $whgData['sum_year'] + $whg2Data['sum_year'], + 'monthDate' => [] + ]; + + $whgMonthKeyArr = array_keys($whgData['month']); + foreach ($whg2Data['month'] as $key => $value) { + if (in_array($key, $whgMonthKeyArr)) { + $whgData['month'][$key] += $value; + unset($whg2Data['month'][$key]); + } + } + + if (!empty($whg2Data['month'])) { + $whgData['month'] = array_merge($whgData['month'], $whg2Data['month']); + } + + ksort($whgData['month']); + + foreach ($whgData['month'] as $month => $value) { + $tempData['monthDate'][] = [ + 'month' => $month, + 'value' => $value + ]; + } + + $data['dataResult'][] = $tempData; + return $this->renderSuccess($data); } -} \ No newline at end of file +}