GPS. Puntos de recoleecion en rutas

This commit is contained in:
2022-05-27 19:24:59 -07:00
parent 116c031f4b
commit 073c2304e0
2 changed files with 85 additions and 0 deletions

View File

@@ -2201,6 +2201,21 @@ Public Class ClsGPS
OnError("Ocurrió un error al obtener la ruta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo())
End Try
Return Retorno
End Function
Public Function GetRutasPuntosRecoleecion(CveRuta As Integer) As Boolean
Dim Retorno As Boolean = False
DataAdapter("PA_GPS_RutasPuntosRecoleecionGet")
With SqlAdapter.SelectCommand.Parameters
.Add("@CveRuta", SqlDbType.Int).Value = CveRuta
End With
Try
SqlAdapter.Fill(Data)
Retorno = True
Catch ex As Exception
OnError("Ocurrió un error al obtener los puntos de recoleecion.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo())
End Try
Return Retorno
End Function
Public Function UpdateRuta(CveRuta As Integer, Ruta As String, CveCliente As Integer) As Boolean
Dim Retorno As Boolean = False

View File

@@ -1150,6 +1150,54 @@ Public Class WSGPSApp
End Function
<WebMethod>
Public Function GetRutas(CveCliente As Integer, CveRuta As Integer, MostrarPuntos As Boolean) As String
Dim DtRutas As DataTable = Nothing
Using ObjGPS As New ClsGPS
If ObjGPS.GetRutas(CveRuta, CveCliente) Then
DtRutas = ObjGPS.DtResultados.Copy()
End If
End Using
Dim Rutas As New List(Of Object)
If DtRutas IsNot Nothing Then
For Each Row As DataRow In DtRutas.Rows
Dim Coordenadas As List(Of MWSGeolocation2) = Nothing
If MostrarPuntos Then
Coordenadas = SQLToGmapsPolyline(Row("Poligono").ToString())
End If
Rutas.Add(New With {
.CveRuta = Row("CveRuta").ToString().ToEntero(),
.Ruta = Row("Ruta").ToString(),
.Folio = Row("Folio").ToString(),
.Fecha = Row("FechaIng").ToString(),
.CveDispositivo = Row("CveDispositivo").ToString().ToEntero(),
.CveUsuarioIngreso = Row("CveUsuarioIngreso").ToString().ToEntero(),
.Coordenadas = Coordenadas
})
Next
End If
Return JsonConvert.SerializeObject(Rutas)
End Function
<WebMethod>
Public Function GetRutaPuntosRecoleecion(CveRuta As Integer) As String
Dim Retorno As String = "[]"
Using ObjGPS As New ClsGPS
If ObjGPS.GetRutasPuntosRecoleecion(CveRuta) Then
Retorno = ObjGPS.DtResultados.DataTableToJSONIPP()
End If
End Using
Return Retorno
End Function
#Region "F U N C I O N E S"
Private Function CargarEventos(CveCliente As Integer, FechaI As DateTime, FechaF As DateTime) As MWSDashboard2
Dim ObjGPS As New ClsGPS
@@ -1225,6 +1273,28 @@ Public Class WSGPSApp
Next
Return Var
End Function
Private Function SQLToGmapsPolyline(CoordsSQL As String) As List(Of MWSGeolocation2)
Dim CoordsPoligono As String = CoordsSQL.Replace($"LINESTRING", "").Replace(")", "").Replace("(", "")
Dim CoordsPuntos() As String = CoordsPoligono.Split(","c)
Dim puntos As New List(Of MWSGeolocation2)
For Each coordenada As String In CoordsPuntos
Dim Var As New MWSGeolocation2
If coordenada Is CoordsPuntos.Last Then
Dim latlng() As String = coordenada.Trim.Split(" "c)
Var.Latitud = latlng(1).ToDouble()
Var.Longitud = latlng(0).ToDouble()
Else
Dim latlng() As String = coordenada.Trim.Split(" "c)
Var.Latitud = latlng(1).ToDouble()
Var.Longitud = latlng(0).ToDouble()
End If
puntos.Add(Var)
Next
Return puntos
End Function
Private Function GetJson(ByVal dt As DataTable) As String
Dim serializer As New System.Web.Script.Serialization.JavaScriptSerializer()
Dim rows As New List(Of Dictionary(Of String, Object))()