| @@ -129,6 +129,7 @@ define("MEMBER_LOG_TITLE", 'member-log://'); // 會員資料記錄 | |||
| define("TX_LOG_TITLE", 'tx-log://'); // 交易資料記錄 | |||
| define("ADMIN_LOG_TITLE", 'admin-log://'); // 管理操作記錄 | |||
| define("EXPORT_LOG_TITLE", 'export-log://'); // 檔案匯出記錄 | |||
| define("PARKTRON_LOG_TITLE", 'parktron-log://'); // 博辰資料記錄 | |||
| /* | |||
| |-------------------------------------------------------------------------- | |||
| @@ -70,6 +70,42 @@ class Carpark extends CC_Controller | |||
| // ------------------------------------------------ | |||
| // | |||
| // 博辰 (START) | |||
| // | |||
| // ------------------------------------------------ | |||
| // 同步 博辰 888 | |||
| function sync_parktron_888() | |||
| { | |||
| try{ | |||
| $ch = curl_init(); | |||
| curl_setopt($ch, CURLOPT_URL, 'http://192.168.10.80:5477/parktron/ipms/services/areaCount/findAll'); | |||
| curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); | |||
| curl_setopt($ch, CURLOPT_POST, TRUE); | |||
| curl_setopt($ch, CURLOPT_CONNECTTIMEOUT ,5); | |||
| curl_setopt($ch, CURLOPT_TIMEOUT, 5); //timeout in seconds | |||
| curl_setopt($ch, CURLOPT_POSTFIELDS, '{}'); | |||
| curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json')); | |||
| $result = curl_exec($ch); | |||
| $parktron_result = json_decode($result); | |||
| trigger_error(PARKTRON_LOG_TITLE . '..' . __FUNCTION__ . '..' . print_r($parktron_result, true)); | |||
| $this->data_model()->sync_parktron_888($parktron_result); | |||
| if(curl_errno($ch)) | |||
| { | |||
| trigger_error(PARKTRON_LOG_TITLE . '..' . __FUNCTION__ . '..' . ', curl error: '. curl_error($ch)); | |||
| } | |||
| curl_close($ch); | |||
| }catch (Exception $e){ | |||
| trigger_error(PARKTRON_LOG_TITLE . '..' . __FUNCTION__ . '..' . 'error:'.$e->getMessage()); | |||
| } | |||
| } | |||
| // ------------------------------------------------ | |||
| // | |||
| // CRM (START) | |||
| // | |||
| // ------------------------------------------------ | |||
| @@ -416,6 +452,8 @@ class Carpark extends CC_Controller | |||
| // 同步 (由排程呼叫) | |||
| public function sync_minutely() | |||
| { | |||
| $this->sync_parktron_888(); // 同步博辰 888 | |||
| $this->data_model()->sync_pks_groups(); // 同步在席現況 | |||
| } | |||
| @@ -35,6 +35,75 @@ class Sync_data_model extends CI_Model | |||
| // ------------------------------------------------ | |||
| // | |||
| // 博辰 (START) | |||
| // | |||
| // ------------------------------------------------ | |||
| // 博辰 888 同步 | |||
| public function sync_parktron_888($parktron_result) | |||
| { | |||
| if(empty($parktron_result)) | |||
| return 'empty'; | |||
| // 解析資料 | |||
| $pks_groups_arr = array(); | |||
| foreach($parktron_result as $content_result_list) | |||
| { | |||
| foreach ($content_result_list as $item_result_list) | |||
| { | |||
| $area_id = 0; | |||
| $space_count = 0; | |||
| $parking_count = 0; | |||
| $blanking_count = 0; | |||
| foreach ($item_result_list as $key => $value) | |||
| { | |||
| switch($key) | |||
| { | |||
| case 'areaId': $area_id = $value; break; | |||
| case 'spaceCount': $space_count = $value; break; | |||
| case 'parkingCount': $parking_count = $value; break; | |||
| case 'blankingCount': $blanking_count = $value; break; | |||
| default: trigger_error(__FUNCTION__ . "..unknown..{$key}|{$value}.."); | |||
| } | |||
| } | |||
| if($area_id > 0) | |||
| { | |||
| //trigger_error(__FUNCTION__ . "..$area_id, $space_count, $parking_count, $blanking_count.."); | |||
| $pks_groups_arr["P{$area_id}"] = array('tot' => $space_count, 'parked' => $parking_count, 'availables' => $blanking_count); | |||
| } | |||
| } | |||
| } | |||
| if(empty($pks_groups_arr)) | |||
| { | |||
| trigger_error(__FUNCTION__ . "..empty pks_groups_arr.."); | |||
| return 'empty'; | |||
| } | |||
| // 取得場站編號 | |||
| $station_setting = $this->station_setting_query(); | |||
| $station_no_arr = explode(SYNC_DELIMITER_ST_NO, $station_setting['station_no']); | |||
| $station_no = $station_no_arr[0]; | |||
| trigger_error(__FUNCTION__ . "..$station_no.." . print_r($pks_groups_arr, true)); | |||
| // 更新博辰資料 | |||
| $this->db->trans_start(); | |||
| foreach($pks_groups_arr as $key => $data) | |||
| { | |||
| $data['renum'] = 0; | |||
| $this->db->where(array('group_id' => $key, 'station_no' => $station_no))->update('pks_groups', $data); | |||
| } | |||
| $this->db->trans_complete(); | |||
| return 'ok'; | |||
| } | |||
| // ------------------------------------------------ | |||
| // | |||
| // 在席系統同步 (START) | |||
| // | |||
| // ------------------------------------------------ | |||