宝体数据调用接口
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

59 lines
1.6 KiB

<?php
namespace app\task\behavior\passengerFlow;
use think\Db;
class PassengerFlowReal
{
/**
* 执行函数
* @return bool
* @throws \think\Exception
* @throws \think\exception\PDOException
*/
public function run()
{
$config = config('api_config');
$delete = Db::table('bt_passenger_flow_real')->where('id','>',1)->delete();
try{
$url = $config['host_url'] . "/api/cfas/v3/passenger/realTime";
$dataArr = [
'01' // --- <replace> --- //
];
$token = getAccessToken();
$json_data = json_encode($dataArr);
$result = postToken($url,$json_data,false,[],$token);
$res_data = json_decode($result,true);
$list = (array) $res_data['data'];
foreach ($list as $value) {
$insert_arr = [
'groupId' => $value['groupId'],
'regionId' => $value['regionId'],
'statisticsTime' => $value['statisticsTime'],
'enter' => $value['enter'],
'exit' => $value['exit'],
'pass' => $value['pass'],
'holdValue' => $value['holdValue'],
'allEnter' => $value['allEnter'],
'allExit' => $value['allExit']
];
Db::table('bt_passenger_flow_real')->insert($insert_arr);
}
} catch (\Exception $e) {
}
return true;
}
}