|
@@ -30,6 +30,7 @@ class queue_logic
|
|
|
$postData['cabinet_code'] = $params['cabinet_code'];
|
|
|
$postData['box_position_list'] = $params['box_position_list'];
|
|
|
$postData['delay_time'] = $params['delay_time'];
|
|
|
+ $postData['id'] = $params['id'];
|
|
|
|
|
|
return $this->proc_request($params,'/open_box',$postData);
|
|
|
}
|
|
@@ -37,33 +38,47 @@ class queue_logic
|
|
|
public function LockCabinet($params) {
|
|
|
$postData['cabinet_code'] = $params['cabinet_code'];
|
|
|
$postData['delay_time'] = $params['delay_time'];
|
|
|
+ $postData['id'] = $params['id'];
|
|
|
|
|
|
return $this->proc_request($params,'/lock_cabinet',$postData);
|
|
|
}
|
|
|
public function UnLockCabinet($params) {
|
|
|
$postData['cabinet_code'] = $params['cabinet_code'];
|
|
|
- $postData['delay_time'] = $params['delay_time'];
|
|
|
+ $postData['delay_time'] = $params['delay_time'];
|
|
|
+ $postData['id'] = $params['id'];
|
|
|
|
|
|
return $this->proc_request($params,'/unlock_cabinet',$postData);
|
|
|
}
|
|
|
public function ReleaseAlarm($params) {
|
|
|
$postData['cabinet_code'] = $params['cabinet_code'];
|
|
|
$postData['delay_time'] = $params['delay_time'];
|
|
|
+ $postData['id'] = $params['id'];
|
|
|
+
|
|
|
|
|
|
return $this->proc_request($params,'/release_alarm',$postData);
|
|
|
}
|
|
|
public function Reboot($params) {
|
|
|
$postData['cabinet_code'] = $params['cabinet_code'];
|
|
|
$postData['delay_time'] = $params['delay_time'];
|
|
|
+ $postData['id'] = $params['id'];
|
|
|
|
|
|
return $this->proc_request($params,'/reboot',$postData);
|
|
|
}
|
|
|
public function QueryState($params) {
|
|
|
$postData['cabinet_code'] = $params['cabinet_code'];
|
|
|
$postData['delay_time'] = $params['delay_time'];
|
|
|
+ $postData['id'] = $params['id'];
|
|
|
|
|
|
return $this->proc_request($params,'/query_state',$postData);
|
|
|
}
|
|
|
+ public function QueryBoxState($params) {
|
|
|
+ $postData['cabinet_code'] = $params['cabinet_code'];
|
|
|
+ $postData['box_position_list'] = $params['box_position_list'];
|
|
|
+ $postData['delay_time'] = $params['delay_time'];
|
|
|
+ $postData['id'] = $params['id'];
|
|
|
+
|
|
|
+ return $this->proc_request($params,'/query_box_state',$postData);
|
|
|
+ }
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
private function proc_request($params,$api,$postData)
|
|
@@ -84,7 +99,7 @@ class queue_logic
|
|
|
return $resp;
|
|
|
}
|
|
|
|
|
|
- private function sync_result($queue_name, $key, $params){
|
|
|
+ private function sync_result($queue_name, $key, $params) {
|
|
|
global $config;
|
|
|
$host = $config['net_queue']['host'];
|
|
|
$port = $config['net_queue']['port'];
|
|
@@ -96,4 +111,68 @@ class queue_logic
|
|
|
return ['code'=>1 , 'msg' => 'cabinet redis connect error'];
|
|
|
}
|
|
|
}
|
|
|
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
+ public function UpdateAllBoxState()
|
|
|
+ {
|
|
|
+ global $config;
|
|
|
+ $admin_url = $config['admin_url'];
|
|
|
+
|
|
|
+ $result = $this->getCabinets("{$admin_url}/GetCabinetsBoxs");
|
|
|
+ if(empty($result) || $result['code'] != 0) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ $cabinets = $result['data'];
|
|
|
+ foreach ($cabinets as $cabinet)
|
|
|
+ {
|
|
|
+ $params['req_url'] = $cabinet['req_url'];
|
|
|
+ $params['key'] = $cabinet['login_key'];
|
|
|
+ $token = $this->login($params['req_url'],$params['key']);
|
|
|
+ if(empty($token)) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ $boxes = $cabinet['box_data'];
|
|
|
+ $i = 1;
|
|
|
+ foreach ($boxes as $box)
|
|
|
+ {
|
|
|
+ $data['id'] = "{$i}";
|
|
|
+ $data['cabinet_code'] = $cabinet['cabinet_code'];
|
|
|
+ $data['box_position_list'] = [$box['box_number']];
|
|
|
+ $data['delay_time'] = 0;
|
|
|
+
|
|
|
+ $resp = $this->reqest($params['req_url'],'/query_box_state',$data,$token);
|
|
|
+ if($resp['code'] == 0)
|
|
|
+ {
|
|
|
+ $update_url = $admin_url . "/BoxChangeStatus";
|
|
|
+ foreach ($resp['data']['result_list'] as $value) {
|
|
|
+ $data = [];
|
|
|
+ $data['cabinet_code'] = $cabinet['cabinet_code'];
|
|
|
+ $data['box_number'] = $value['box_position'];
|
|
|
+ $data['box_status'] = $value['result'];
|
|
|
+
|
|
|
+ $ret = http_request($update_url,$resp,'POST');
|
|
|
+ if($ret == false || $ret['code'] != 0) {
|
|
|
+ Log::record("update box state error: cabinet={$cabinet['cabinet_code']},box={$box['box_number']}",log::DEBUG);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ Log::record("query state err: cabinet={$cabinet['cabinet_code']},box={$box['box_number']}",log::DEBUG);
|
|
|
+ }
|
|
|
+
|
|
|
+ $i++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public function getCabinets($url) {
|
|
|
+ $resp = http_request($url,[]);
|
|
|
+ if($resp) {
|
|
|
+ $result = json_decode($resp,true);
|
|
|
+ return $result;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|