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.
63 lines
1.9 KiB
63 lines
1.9 KiB
<?php
|
|
namespace app\command;
|
|
|
|
use think\console\Command;
|
|
use think\console\Input;
|
|
use think\console\input\Argument;
|
|
use think\console\input\Option;
|
|
use think\console\Output;
|
|
use think\facade\Db;
|
|
|
|
class passengerFlowReal extends Command
|
|
{
|
|
|
|
protected function configure()
|
|
{
|
|
$this->setName('passengerFlow')
|
|
->addArgument('name', Argument::OPTIONAL, "your name")
|
|
->addOption('city', null, Option::VALUE_REQUIRED, 'city name')
|
|
->setDescription('Say Hello');
|
|
}
|
|
|
|
protected function execute(Input $input, Output $output)
|
|
{
|
|
$config = config('app');
|
|
|
|
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('tp_passenger_flow_real')->insert($insert_arr);
|
|
}
|
|
|
|
$output->writeln('完成');
|
|
} catch (\Exception $e) {
|
|
$output->writeln($e->getMessage());
|
|
}
|
|
}
|
|
}
|