diff --git a/source/application/common/logic/PassFlow.php b/source/application/common/logic/PassFlow.php index 3a1225c..e41f497 100644 --- a/source/application/common/logic/PassFlow.php +++ b/source/application/common/logic/PassFlow.php @@ -11,9 +11,18 @@ class PassFlow protected static $groupThreshold = [ 'baz001' => 40000,# 图书馆 'BAF055' => 1000,# 文化馆 - '110' => 10000,# 体育场 - '210' => 10000,# 体育馆 - '310' => 1000,# 游泳馆 + '110' => [ + 'min' => 8000, + 'max' => 12000 + ],# 体育场 + '210' => [ + 'min' => 8000, + 'max' => 12000 + ],# 体育馆 + '310' => [ + 'min' => 6000, + 'max' => 10000 + ],# 游泳馆 '510' => 1000 # 博物馆 ]; @@ -356,9 +365,16 @@ class PassFlow $returnData = []; foreach ($data as $groupId => $val) { - $proportion = $val['holdValue'] > 0 ? round($val['holdValue']/$groupThreshold[$groupId],4) : 0; - $val['proportion'] = ($proportion * 100) . "%"; - $val['congestion'] = self::getPassType($proportion); + $threshold = $groupThreshold[$groupId]; + if (is_array($threshold)) { + $interval = self::getIntervalType($val['holdValue'],$threshold['min'],$threshold['max']); + $val['proportion'] = $interval['rate']; + $val['congestion'] = $interval['str']; + } else { + $proportion = $val['holdValue'] > 0 ? round($val['holdValue']/$threshold,4) : 0; + $val['proportion'] = ($proportion * 100) . "%"; + $val['congestion'] = self::getPassType($proportion); + } $val['groupId'] = $groupId; $getGroup = $dm->find('bt_passenger_monitor_group',' "groupId" = ' . "'{$groupId}'"); @@ -412,6 +428,22 @@ class PassFlow return ''; } + protected static function getIntervalType($proportion,$min,$max) + { + + if ($proportion < $min) { + return ['str' => '舒适', 'rate' => '49%']; + } + if ($proportion > $min && $proportion < $max) { + return ['str' => '拥挤', 'rate' => '99%']; + } + if ($proportion > $max) { + return ['str' => '爆满', 'rate' => '149%']; + } + + return ['str' => '', 'rate' => '0%']; + } + /** * 今日各场馆人数趋势 * @return array