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

78 lines
2.3 KiB

<?php
namespace task\tasks;
use task\module\Pass\Pass;
$aa = new Group();
echo $aa->run();
class Group
{
function run()
{
include_once '../common.php';
include_once '../module/Pass/Pass.php';
$config = config('api_config');
$token = get_access_token();
$url = $config['host_url'] . "/api/cfas/v2/countGroup/groups/page";
$pageNo = 1;
$pageSize = 1;
$requestData = [];
while (1) {
$dataArr = [
"regionId"=> "root000000",
"isCascade"=> 1,
"groupType"=> 0,
"statType"=> 0,
"pageNo"=> $pageNo,
"pageSize"=> $pageSize
];
$json_data = json_encode($dataArr);
$result = post_token($url,$json_data,false,[],$token);
$res_data = json_decode($result,true);
# 存在错误结束循环
if ($res_data['code'] != 0) break;
# 数据不存在结束循环
$list = (array)$res_data['data']['list'];
if (empty($list)) break;
foreach ($list as $value) {
$insert = [
'groupId' => $value['groupId'],
'groupName' => $value['groupName'],
'groupType' => $value['groupType'],
'statType' => $value['statType'],
'regionId' => $value['regionId'],
'thirdPartCode' => $value['thirdPartCode'],
'workStartTime' => $value['workStartTime'],
'workEndTime' => $value['workEndTime'],
'holdBase' => $value['holdBase'],
'earlyWarningValue' => $value['earlyWarningValue'],
'warningValue' => $value['warningValue'],
'warningSwitch' => $value['warningSwitch']
];
$requestData[] = $insert;
}
# 总条数不够结束循环
if (count($list) < $pageSize) break;
++$pageNo;
}
$requestRes = Pass::requestCreateData($requestData,'/api/pass.create/createGroup',$config['host_path']);
if (!$requestRes['status']) {
return $requestRes['msg'];
}
return true;
}
}