|
|
|
@ -5,6 +5,7 @@ namespace app\api\controller\pass; |
|
|
|
use app\api\controller\Controller; |
|
|
|
|
|
|
|
use app\common\dm\Dm; |
|
|
|
use app\common\model\Pass; |
|
|
|
use think\Db; |
|
|
|
|
|
|
|
class Passcc extends Controller |
|
|
|
@ -184,16 +185,19 @@ class Passcc extends Controller |
|
|
|
$list = $dm->select('bt_passenger_flow_real'); |
|
|
|
$data = []; |
|
|
|
|
|
|
|
$sumAllEnter = 0; |
|
|
|
$configRes = $dm->find("bt_config",' "key" = ' . "'threshold'"); |
|
|
|
$threshold = $configRes['threshold'] ?: 0; |
|
|
|
|
|
|
|
foreach ($list as $value) { |
|
|
|
if (!isset($data[$value['groupId']]['allEnter'])) $data[$value['groupId']]['allEnter'] = 0; |
|
|
|
$data[$value['groupId']]['allEnter'] += $value['allEnter']; |
|
|
|
$sumAllEnter += $value['allEnter']; |
|
|
|
} |
|
|
|
|
|
|
|
$returnData = []; |
|
|
|
foreach ($data as $groupId => $val) { |
|
|
|
$val['proportion'] = $val['allEnter'] > 0 ? (round($val['allEnter']/$sumAllEnter,2) * 100) ."%" : '0%'; |
|
|
|
$proportion = $val['allEnter'] > 0 ? round($val['allEnter']/$threshold,2) : 0; |
|
|
|
$val['proportion'] = ($proportion * 100) . "%"; |
|
|
|
$val['congestion'] = Pass::getPassType($proportion); |
|
|
|
$val['groupId'] = $groupId; |
|
|
|
$returnData[] = $val; |
|
|
|
} |
|
|
|
|