| @@ -44,20 +44,13 @@ class Cars extends CI_Controller | |||||
| ignore_user_abort(); // 接受client斷線, 繼續run | ignore_user_abort(); // 接受client斷線, 繼續run | ||||
| $method_name = $this->router->fetch_method(); | $method_name = $this->router->fetch_method(); | ||||
| if ($method_name == 'ipcam' || $method_name == 'check_lpr_etag') | |||||
| { | |||||
| ob_end_clean(); | |||||
| ignore_user_abort(); | |||||
| ob_start(); | |||||
| echo 'ok'; | |||||
| header('Connection: close'); | |||||
| header('Content-Length: ' . ob_get_length()); | |||||
| ob_end_flush(); | |||||
| flush(); | |||||
| } | |||||
| else if($method_name == 'opendoor' || $method_name == 'temp_opendoors' || $method_name == 'member_opendoors') | |||||
| if(in_array($method_name, array( | |||||
| 'ipcam', 'ipcam_meta', | |||||
| 'check_lpr_etag', | |||||
| 'opendoor', | |||||
| 'temp_opendoors', 'member_opendoors' | |||||
| ))) | |||||
| { | { | ||||
| ob_end_clean(); | ob_end_clean(); | ||||
| ignore_user_abort(); | ignore_user_abort(); | ||||
| @@ -29,6 +29,47 @@ class Cars_model extends CI_Model | |||||
| public function ipcam_meta($parms) | public function ipcam_meta($parms) | ||||
| { | { | ||||
| trigger_error(__FUNCTION__ . '|特殊註記:' . print_r($parms, true)); | trigger_error(__FUNCTION__ . '|特殊註記:' . print_r($parms, true)); | ||||
| if($parms['token'] != 1) | |||||
| { | |||||
| trigger_error(__FUNCTION__ . '|未定義|' . print_r($parms, true)); | |||||
| return false; | |||||
| } | |||||
| // 讀取最近一筆入場資料 | |||||
| $rows_cario = $this->db->select('cario_no, obj_id, in_time, out_before_time') | |||||
| ->from('cario') | |||||
| ->where(array( | |||||
| 'station_no' => $parms['sno'], | |||||
| 'obj_id' => $parms['lpr'], | |||||
| 'err' => 0 | |||||
| )) | |||||
| ->order_by('cario_no', 'desc') | |||||
| ->limit(1) | |||||
| ->get() | |||||
| ->row_array(); | |||||
| if (!isset($rows_cario['cario_no'])) | |||||
| { | |||||
| trigger_error(__FUNCTION__ . '|查無入場記錄|' . print_r($parms, true)); | |||||
| return false; | |||||
| } | |||||
| // 更新入場記錄 | |||||
| $data = array('ticket_type' => 3); | |||||
| $this->db->update('cario', $data, array('cario_no' => $rows_cario['cario_no'])); | |||||
| trigger_error(__FUNCTION__ . '|悠遊卡離場,更新入場記錄|'); | |||||
| $affect_rows = $this->db->affected_rows(); | |||||
| if ($affect_rows > 0) | |||||
| { | |||||
| // 傳送更新記錄 | |||||
| $sync_agent = new AltobSyncAgent(); | |||||
| $sync_agent->init($parms['sno'], $this->now_str); | |||||
| $sync_agent->cario_no = $rows_cario['cario_no']; // 進出編號 | |||||
| $sync_result = $sync_agent->sync_st_io_meta($data); | |||||
| trigger_error( __FUNCTION__ . "..sync_st_io_meta.." . $sync_result); | |||||
| } | |||||
| } | } | ||||
| // 車輛進出傳入車牌號碼 (2016/07/27) | // 車輛進出傳入車牌號碼 (2016/07/27) | ||||
| @@ -158,6 +158,30 @@ class AltobSyncAgent | |||||
| return $oService->ServerPost($this->post_parms); | return $oService->ServerPost($this->post_parms); | ||||
| } | } | ||||
| // 傳送進出更新記錄 | |||||
| public function sync_st_io_meta($meta) | |||||
| { | |||||
| $error_parms_msg = $this->check_init_parms(); | |||||
| if(!empty($error_parms_msg)) { return $error_parms_msg; } | |||||
| if(empty($meta)) | |||||
| return 'meta not found'; | |||||
| if(empty($this->cario_no)) | |||||
| return 'cario_no not found'; | |||||
| $this->post_parms['meta'] = $meta; // 需設定 | |||||
| $this->post_parms['cario_no'] = $this->cario_no; // 需設定 | |||||
| // 初始化網路服務物件。 | |||||
| $oService = new AltobSyncService(); | |||||
| $oService->ServiceURL = AltobSyncAgent::SYNC_CARS_URL; | |||||
| $oService->ServiceCMD = 'st_io_meta'; | |||||
| // 傳遞參數至遠端。 | |||||
| return $oService->ServerPost($this->post_parms); | |||||
| } | |||||
| // =============================================== | // =============================================== | ||||
| // SOS | // SOS | ||||
| // =============================================== | // =============================================== | ||||