Processing Call ke GPS API & Fleet Location Upate
Apabila gagal maka update table fleet
column last_gps_update_data
dengan :
Affected Table
- fleet
QUERY
fleet
Parameters:
:fleet_id => (int) fleet id
:string_error_data => (string) "Http-Code: (int) Error Code"
SQL :
UPDATE fleet
SET
`last_gps_update_data` = :string_error_data
WHERE id=:fleet_id
Apabila sukses maka update table fleet
column last_gps_update_data
dan fleet_location_history
fleet_location_history
akan di update apabila latitude
& longitude
exists saja.
apabila kosong fleet_location_history
tidak akan ada perubahan
Affected Table
- fleet
- fleet_location_history
QUERY
fleet
Parameters :
:fleet_id => (int) fleet id
:json_data => (string) Hasil result dari response gps
SQL :
UPDATE fleet
SET
last_gps_update_data = :json_data,
last_gps_update_success = now() -- current time
WHERE id=:fleet_id
QUERY
ms_city
(di eksekusi apabila responsecity
tidak kosong), apabila queried city
Parameters :
:city_name => (string) data lower address city
SQL: (for city_id
if found integer id
otherwise null
)
SELECT id, `name`
FROM ms_city
WHERE lower(`name`) LIKE CONCAT('%', :city_name, '%')
ORDER BY LENGTH(`name`)
DESC LIMIT 1
QUERY
fleet_location_history
Parameters :
:fleet_id => (int) fleet id
:latitude => (float) Latitude
:longitude => (float) Longitude
:address => (string) Address (Even Empty Update)
:city_id => (int|null) `ms_city`.`id` from city queried search by gps city address
:driver_name => (string|null) string from driver if exists, or null if empty null
:gsm_number => (string|null) string from gsm if exists, or null if empty null
SQL :
UPDATE fleet_location_history
SET
fleet_id = :fleet_d,
latitude = :latitude,
longitude = :longitude,
address = :address,
city_id = :city_id,
driver_name = :driver_name,
gsm_no = :gsm_number,
source = 1, -- 1 if is on truck
created_at = now() -- current time
See file Sampe Response.md