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.
80 lines
2.4 KiB
80 lines
2.4 KiB
<?php
|
|
|
|
namespace task\tasks;
|
|
use task\module\Pass\Pass;
|
|
include 'Base.php';
|
|
|
|
class Group extends Base
|
|
{
|
|
function run()
|
|
{
|
|
$config = $this->config('api_config');
|
|
//var_dump($config);die;
|
|
$token = $this->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 = $this->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 = $this->request_create_data($requestData,'/api/pass.create/createGroup',$config['host_path']);
|
|
|
|
if (!$requestRes['status']) {
|
|
return $requestRes['msg'];
|
|
}
|
|
|
|
return true;
|
|
}
|
|
}
|
|
$aa = new Group();
|
|
echo $aa->run();
|
|
$aa = new Group();
|
|
echo $aa->run();
|
|
|