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.
96 lines
2.5 KiB
96 lines
2.5 KiB
<?php
|
|
|
|
namespace task\tasks;
|
|
include 'Base.php';
|
|
|
|
class Lib extends Base
|
|
{
|
|
public $libUrl = 'http://balib.cn:8999/CustCount/baoan/stat.json?key=baoan';
|
|
|
|
public $libCameraId = [
|
|
[
|
|
'groupId' => 'baz001', # 分馆代码
|
|
'name' => '宝安图书馆', # 单位名称
|
|
'cameraId' => '9,7,6,4,2,1,67,3', # 客流系统内分馆摄像头
|
|
], [
|
|
'groupId' => 'BAF055',
|
|
'name' => '1990分馆',
|
|
'cameraId' => '134,135',
|
|
]
|
|
];
|
|
|
|
public function run()
|
|
{
|
|
$config = $this->config('api_config');
|
|
|
|
$requestData = [];
|
|
|
|
$allData = $this->getBaoAnLibData();
|
|
|
|
$tempAllArr = [
|
|
'groupId' => 'lib001',
|
|
'groupName' => '图书馆'
|
|
];
|
|
foreach ($allData as $allKey => $allValue) {
|
|
foreach ($allValue as $aKey => $aValue) {
|
|
$tempAllArr[$allKey."_".$aKey] = $aValue;
|
|
}
|
|
}
|
|
$requestData[] = $tempAllArr;
|
|
|
|
|
|
$libData = $this->getBaoAnLibData(true);
|
|
|
|
foreach ($libData as $row) {
|
|
$tempArr = [
|
|
'groupId' => $row['groupId'],
|
|
'groupName' => $row['name']
|
|
];
|
|
foreach ($row['data'] as $key => $value) {
|
|
foreach ($value as $k => $v) {
|
|
$tempArr[$key."_".$k] = $v;
|
|
}
|
|
}
|
|
$requestData[] = $tempArr;
|
|
}
|
|
|
|
$requestRes = $this->request_create_data($requestData,'/api/library.pass/create',$config['host_path']);
|
|
|
|
if (!$requestRes['status']) {
|
|
return $requestRes['msg'];
|
|
}
|
|
|
|
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* @param $is_group
|
|
* @return array|mixed
|
|
*/
|
|
public function getBaoAnLibData($is_group = false)
|
|
{
|
|
if ($is_group) {
|
|
|
|
$data = [];
|
|
foreach ($this->libCameraId as $value) {
|
|
$url = $this->libUrl . '&cameraid=' . $value['cameraId'];
|
|
$result = $this->curl_post($url);
|
|
$result = json_decode($result,true);
|
|
$data[] = [
|
|
'data' => $result,
|
|
'groupId' => $value['groupId'],
|
|
'name' => $value['name']
|
|
];
|
|
}
|
|
return $data;
|
|
} else {
|
|
|
|
$result = $this->curl_post($this->libUrl);
|
|
return json_decode($result,true);
|
|
}
|
|
}
|
|
}
|
|
|
|
$lib = new Lib();
|
|
echo $lib->run();
|