体育管项目脚本
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.

90 lines
3.2 KiB

<?php
namespace task\tasks;
include 'Base.php';
class Passreal extends Base
{
public function run()
{
$config = $this->config('api_config');
$requestData = [];
try{
date_default_timezone_set('Asia/Shanghai');
# $url = $config['host_url'] . "/api/cfas/v3/passenger/realTime";
$url = $config['host_url'] . "/api/cfas/v2/passengerFlow/groups";
$token = $this->get_access_token();
# $dataArr = $this->get_real_group_ids($config,$token,2);
$dataArr = [
'ids' => $this->get_real_group_ids($config,$token,1),
'granularity' => 'daily',
'startTime' => date("c",strtotime('today')),
'endTime' => date('c',time())
];
$json_data = json_encode($dataArr);
$result = $this->post_token($url,$json_data,false,[],$token);
$res_data = json_decode($result,true);
$list = (array) $res_data['data'];
$existsArr = [];
foreach ($list['list'] as $value) {
$existsArr[] = $value['groupId'];
$insert_arr = [
'groupId' => $value['groupId'],
'regionId' => '0',
'statisticsTime' => $value['statTime'],
'enter' => $value['noRepeatOutNum'],
'exit' => $value['flowOutNum'],
'pass' => $value['holdValue'] ?: '',
'holdValue' => $value['netValue'],
'allEnter' => $value['flowInNum'],
'allExit' => $value['noRepeatInNum']
];
#Db::table('bt_passenger_flow_real')->insert($insert_arr);
$requestData[] = $insert_arr;
}
/* $idsArr = explode(",",$dataArr['ids']);
foreach ($idsArr as $id) {
$is_continue = true;
if (in_array($id,$existsArr)) $is_continue = false;
if ($is_continue) {
$requestData[] = [
'groupId' => $id,
'regionId' => '0',
'statisticsTime' => date("Y-m-d\TH") . ':00:00.000+08:00',
'enter' => 0,
'exit' => 0,
'pass' => 0,
'holdValue' => 0,
'allEnter' => 0,
'allExit' => 0
];
}
}*/
} catch (\Exception $e) {
return $e->getMessage();
}
$requestRes = $this->request_create_data($requestData,'/api/pass.create/createPassengerFlowReal', $config['host_path'],true);
if (!$requestRes['status']) {
return $requestRes['msg'];
}
#$file = fopen('/tmp/passreal.txt','a');
#$file_msg = '['.date('Y-m-d H:i:s',time()).']';
#fwrite($file,$file_msg . PHP_EOL);
#fclose($file);
# file_put_contents('/tmp/passreal.txt','['.date('Y-m-d H:i:s',time()).']'.PHP_EOL,FILE_APPEND);
return true;
}
}
$Passall = new Passreal();
echo $Passall->run();