Browse Source

修改实时占比数据

master
wanghongjun 2 years ago
parent
commit
60766bb6e7
  1. 44
      source/application/common/logic/PassFlow.php

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

@ -11,9 +11,18 @@ class PassFlow
protected static $groupThreshold = [ protected static $groupThreshold = [
'baz001' => 40000,# 图书馆 'baz001' => 40000,# 图书馆
'BAF055' => 1000,# 文化馆 'BAF055' => 1000,# 文化馆
'110' => 10000,# 体育场 '110' => [
'210' => 10000,# 体育馆 'min' => 8000,
'310' => 1000,# 游泳馆 'max' => 12000
],# 体育场
'210' => [
'min' => 8000,
'max' => 12000
],# 体育馆
'310' => [
'min' => 6000,
'max' => 10000
],# 游泳馆
'510' => 1000 # 博物馆 '510' => 1000 # 博物馆
]; ];
@ -356,9 +365,16 @@ class PassFlow
$returnData = []; $returnData = [];
foreach ($data as $groupId => $val) { foreach ($data as $groupId => $val) {
$proportion = $val['holdValue'] > 0 ? round($val['holdValue']/$groupThreshold[$groupId],4) : 0; $threshold = $groupThreshold[$groupId];
$val['proportion'] = ($proportion * 100) . "%"; if (is_array($threshold)) {
$val['congestion'] = self::getPassType($proportion); $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; $val['groupId'] = $groupId;
$getGroup = $dm->find('bt_passenger_monitor_group',' "groupId" = ' . "'{$groupId}'"); $getGroup = $dm->find('bt_passenger_monitor_group',' "groupId" = ' . "'{$groupId}'");
@ -412,6 +428,22 @@ class PassFlow
return ''; 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 * @return array

Loading…
Cancel
Save