From 27c819a4407bcb6c108f32dfbfa36c70899737b2 Mon Sep 17 00:00:00 2001 From: wanghongjun <1445693971@qq,com> Date: Wed, 9 Aug 2023 18:52:10 +0800 Subject: [PATCH] =?UTF-8?q?=E9=98=88=E5=80=BC=E8=AE=A1=E7=AE=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/application/common/logic/PassFlow.php | 35 ++++++++++++++------ 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/source/application/common/logic/PassFlow.php b/source/application/common/logic/PassFlow.php index fc10af1..351f6fc 100644 --- a/source/application/common/logic/PassFlow.php +++ b/source/application/common/logic/PassFlow.php @@ -8,6 +8,14 @@ class PassFlow { protected static $groupType = [1,2];# 1 = 体育 2 = 文化 protected static $granularity = ['daily','monthly','yearly'];# 1 = 体育 2 = 文化 + protected static $groupThreshold = [ + 'baz001' => 10000,# 图书馆 + 'BAF055' => 1000,# 文化馆 + '110' => 10000,# 体育场 + '210' => 10000,# 体育馆 + '310' => 1000,# 游泳馆 + '510' => 1000 # 博物馆 + ]; protected static function getGroupIds($dm,$type = 1) { @@ -304,7 +312,10 @@ class PassFlow $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; +// $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}'"; @@ -332,17 +343,18 @@ 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']; } + $groupThreshold = self::$groupThreshold; $returnData = []; foreach ($data as $groupId => $val) { - $proportion = $val['allEnter'] > 0 ? round($val['allEnter']/$threshold,4) : 0; + $proportion = $val['holdValue'] > 0 ? round($val['holdValue']/$groupThreshold[$val['groupId']],4) : 0; $val['proportion'] = ($proportion * 100) . "%"; $val['congestion'] = self::getPassType($proportion); $val['groupId'] = $groupId; @@ -354,7 +366,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,4) : 0; + $holdValue = $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[] = [ @@ -379,19 +392,19 @@ 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 '';