From e9ab438846536c40c41a08486aa9bcc68a71656b Mon Sep 17 00:00:00 2001 From: "altob.rd" Date: Wed, 22 Nov 2017 14:59:36 +0800 Subject: [PATCH] add ticket_type == 3 --- controllers/Cars.php | 21 +++++++------------ models/Cars_model.php | 41 ++++++++++++++++++++++++++++++++++++++ phplibs/Altob.Sync.Integration.php | 24 ++++++++++++++++++++++ 3 files changed, 72 insertions(+), 14 deletions(-) diff --git a/controllers/Cars.php b/controllers/Cars.php index 58cbbbf..bd8c67b 100644 --- a/controllers/Cars.php +++ b/controllers/Cars.php @@ -44,20 +44,13 @@ class Cars extends CI_Controller ignore_user_abort(); // 接受client斷線, 繼續run $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(); ignore_user_abort(); diff --git a/models/Cars_model.php b/models/Cars_model.php index 8fae381..faf233c 100644 --- a/models/Cars_model.php +++ b/models/Cars_model.php @@ -29,6 +29,47 @@ class Cars_model extends CI_Model public function ipcam_meta($parms) { 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) diff --git a/phplibs/Altob.Sync.Integration.php b/phplibs/Altob.Sync.Integration.php index 9cd83a5..c3d4d31 100644 --- a/phplibs/Altob.Sync.Integration.php +++ b/phplibs/Altob.Sync.Integration.php @@ -158,6 +158,30 @@ class AltobSyncAgent 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 // ===============================================