Browse Source

图书馆脚本优化

master
wanghongjun 3 years ago
parent
commit
c5403d774f
  1. 21
      tasks/Lib.php

21
tasks/Lib.php

@ -25,7 +25,7 @@ class Lib extends Base
$requestData = []; $requestData = [];
$allData = $this->getBaoAnLibData(); #$allData = $this->getBaoAnLibData();
$tempAllArr = [ $tempAllArr = [
'group_id' => 'lib001', 'group_id' => 'lib001',
'group_name' => base64_encode('文化') 'group_name' => base64_encode('文化')
@ -45,15 +45,23 @@ class Lib extends Base
]; ];
foreach ($row['data'] as $key => $value) { foreach ($row['data'] as $key => $value) {
foreach ($value as $k => $v) { foreach ($value as $k => $v) {
$field = $key."_".$k; if (is_array($v)) {
$tempArr[$field] = $v ?: 0; foreach ($v as $numKey => $numVal) {
if (!isset($tempAllArr[$field])) $tempAllArr[$field] = 0; if (!isset($tempAllArr[$key][$k][$numKey])) $tempAllArr[$key][$k][$numKey] = 0;
$tempAllArr[$field] += $tempArr[$field]; $tempAllArr[$key][$k][$numKey] += $numVal;
}
$tempArr[$key][$k] = $v;
} else {
$field = $key."_".$k;
$tempArr[$field] = $v ?: 0;
if (!isset($tempAllArr[$field])) $tempAllArr[$field] = 0;
$tempAllArr[$field] += $tempArr[$field];
}
} }
} }
$requestData[] = $tempArr; $requestData[] = $tempArr;
} }
$requestData[] = $tempAllArr; $requestData[] = $tempAllArr;
$requestRes = $this->request_create_data($requestData,'/api/library.pass/create',$config['host_path'],true); $requestRes = $this->request_create_data($requestData,'/api/library.pass/create',$config['host_path'],true);
@ -77,7 +85,6 @@ class Lib extends Base
foreach ($this->libCameraId as $value) { foreach ($this->libCameraId as $value) {
$url = $this->libUrl . '&cameraid=' . $value['cameraId']; $url = $this->libUrl . '&cameraid=' . $value['cameraId'];
$result = $this->curl_post($url); $result = $this->curl_post($url);
var_dump($result);
$result = json_decode($result,true); $result = json_decode($result,true);
$data[] = [ $data[] = [
'data' => $result, 'data' => $result,

Loading…
Cancel
Save