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

107 lines
2.9 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,135,144,145', # 客流系统内分馆摄像头
], [
'groupId' => 'BAF055',
'name' => '文化馆',
'cameraId' => '134,141,142',
]
];
public function run()
{
$config = $this->config('api_config');
$requestData = [];
$allData = $this->getBaoAnLibData();
$tempAllArr = [
'group_id' => 'lib001',
'group_name' => base64_encode('文化')
];
/*foreach ($allData as $allKey => $allValue) {
foreach ($allValue as $aKey => $aValue) {
$tempAllArr[$allKey."_".$aKey] = $aValue;
}
}*/
$libData = $this->getBaoAnLibData(true);
foreach ($libData as $row) {
$tempArr = [
'group_id' => $row['groupId'],
'group_name' => base64_encode($row['name'])
];
foreach ($row['data'] as $key => $value) {
foreach ($value as $k => $v) {
$field = $key."_".$k;
$tempArr[$field] = $v ?: 0;
if (!isset($tempAllArr[$field])) $tempAllArr[$field] = 0;
$tempAllArr[$field] += $tempArr[$field];
}
}
$requestData[] = $tempArr;
}
$requestData[] = $tempAllArr;
$requestRes = $this->request_create_data($requestData,'/api/library.pass/create',$config['host_path'],true);
if (!$requestRes['status']) {
return $requestRes['msg'];
}
return true;
}
// 获取图书馆借阅,办证数据
public function runService()
{
$url = 'http://10.99.57.79:9999/SSBusiness/monitor/getLibraryService?library=044007';
$result = $this->curl_post($url);
$result_data = json_decode($result,true);
var_dump($result);die;
}
/**
* @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);
var_dump($result);
$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();