mirror of
https://github.com/KeymonSoft/Ruteador-NonUI.git
synced 2026-04-22 07:00:22 +00:00
- Se agregaron mas TRY/CATCH y se agregó el parametro "f", para especifiar un punto que debe ser el punto final (destino)
This commit is contained in:
76
Ruteador.bas
76
Ruteador.bas
@@ -88,31 +88,54 @@ Sub generaMatrizRuteoTiempos(r As String, resp As ServletResponse, ruta As Strin
|
||||
Log(ts)
|
||||
Private tempMap As Map
|
||||
tempMap.Initialize
|
||||
Private p As ResultSet = Main.db.ExecQuery($"select * from ${r}_punteo"$)
|
||||
Private listCoords As List
|
||||
listCoords.Initialize
|
||||
'Ponemos el id de la tienda y las coordenadas en una lista para regresarla en un JSON.
|
||||
Do While p.NextRow
|
||||
listCoords.Add(CreateMap("pos":p.GetString("pos"), "id":p.GetString("id"), "lat":p.GetString("lat"), "lon":p.GetString("lon")))
|
||||
Loop
|
||||
Main.db.Close
|
||||
tempMap.Put("api", matriz)
|
||||
If matriz = "" Then tempMap.Put("api", "Local")
|
||||
'Ponemos la ruta, almacen, tiempos, distancias y la lista de las coordenadas en un mapa para regresarla en un JSON.
|
||||
tempMap.Put("code", "OK")
|
||||
tempMap.Put("ruta", ruta)
|
||||
tempMap.Put("almacen", almacen)
|
||||
tempMap.Put("duration", ts.Get("duration"))
|
||||
tempMap.Put("distance", ts.Get("distance"))
|
||||
tempMap.Put("puntos", ts.Get("puntos"))
|
||||
tempMap.Put("coords", listCoords)
|
||||
If tempMap.get("puntos") = 0 Then tempMap.Put("code", "KO")
|
||||
' Log(tempMap)
|
||||
js.Initialize(tempMap)
|
||||
StopMessageLoop
|
||||
'Regresamos en un JSON la info del ruteo.
|
||||
resp.ContentType = "text/html"
|
||||
resp.Write(js.ToString)
|
||||
If checkIfTableExists(r&"_punteo") Then
|
||||
Private p As ResultSet = Main.db.ExecQuery($"select * from ${r}_punteo"$)
|
||||
Private listCoords As List
|
||||
listCoords.Initialize
|
||||
'Ponemos el id de la tienda y las coordenadas en una lista para regresarla en un JSON.
|
||||
Do While p.NextRow
|
||||
listCoords.Add(CreateMap("pos":p.GetString("pos"), "id":p.GetString("id"), "lat":p.GetString("lat"), "lon":p.GetString("lon")))
|
||||
Loop
|
||||
Main.db.Close
|
||||
tempMap.Put("api", matriz)
|
||||
If matriz = "" Then tempMap.Put("api", "Local")
|
||||
'Ponemos la ruta, almacen, tiempos, distancias y la lista de las coordenadas en un mapa para regresarla en un JSON.
|
||||
tempMap.Put("code", "OK")
|
||||
tempMap.Put("ruta", ruta)
|
||||
tempMap.Put("almacen", almacen)
|
||||
tempMap.Put("duration", ts.Get("duration"))
|
||||
tempMap.Put("distance", ts.Get("distance"))
|
||||
tempMap.Put("puntos", ts.Get("puntos"))
|
||||
tempMap.Put("coords", listCoords)
|
||||
tempMap.Put("mensaje", Main.msg)
|
||||
If tempMap.get("puntos") = 0 Then tempMap.Put("code", "KO")
|
||||
' Log(tempMap)
|
||||
js.Initialize(tempMap)
|
||||
StopMessageLoop
|
||||
Main.error = ""
|
||||
Main.msg = ""
|
||||
'Regresamos en un JSON la info del ruteo.
|
||||
resp.ContentType = "text/html"
|
||||
resp.Write(js.ToString)
|
||||
Else
|
||||
tempMap.Put("api", "")
|
||||
tempMap.Put("code", "KO")
|
||||
tempMap.Put("error", Main.error)
|
||||
tempMap.Put("ruta", ruta)
|
||||
tempMap.Put("almacen", almacen)
|
||||
tempMap.Put("duration", 0)
|
||||
tempMap.Put("distance", 0)
|
||||
tempMap.Put("puntos", 0)
|
||||
tempMap.Put("coords", "")
|
||||
tempMap.Put("mensaje", Main.msg)
|
||||
' Log(tempMap)
|
||||
js.Initialize(tempMap)
|
||||
StopMessageLoop
|
||||
Main.error = ""
|
||||
Main.msg = ""
|
||||
resp.ContentType = "text/html"
|
||||
resp.Write(js.ToString)
|
||||
End If
|
||||
Return 1
|
||||
End Sub
|
||||
|
||||
@@ -147,10 +170,13 @@ Sub tiempos(r As String, resp As ServletResponse, ruta As String, almacen As Str
|
||||
tempMap.Put("distance", ts.Get("distance"))
|
||||
tempMap.Put("puntos", ts.Get("puntos"))
|
||||
tempMap.Put("coords", listCoords)
|
||||
tempMap.Put("mensaje", Main.msg)
|
||||
If tempMap.get("puntos") = 0 Then tempMap.Put("code", "KO")
|
||||
' Log(tempMap)
|
||||
js.Initialize(tempMap)
|
||||
StopMessageLoop
|
||||
Main.error = ""
|
||||
Main.msg = ""
|
||||
resp.ContentType = "text/html"
|
||||
resp.Write(js.ToString)
|
||||
Log("###################################################################" & CRLF)
|
||||
|
||||
Reference in New Issue
Block a user