mirror of
https://github.com/KeymonSoft/DBCheck.git
synced 2026-04-20 12:49:35 +00:00
VERSION 6.03.19
- Correcion en envio de datos de venta y reparto
This commit is contained in:
@@ -13,6 +13,9 @@ Sub Class_Globals
|
||||
Dim foto1(), foto2(), foto3(), foto4() As Byte
|
||||
Dim PORCENTAJE, PASO, PERFIL, NUMERO_PEDIDO, l_ruta As String
|
||||
Dim contador_env, contador_strem, reqTotales As Int
|
||||
Dim enviando As Boolean = False
|
||||
Dim validando As Boolean = False
|
||||
Dim datos_iguales As String
|
||||
End Sub
|
||||
|
||||
' Initializes the object.
|
||||
@@ -37,13 +40,14 @@ Public Sub ConfigurarYEnviar(ServidorURL As String)
|
||||
reqTotales = reqManager.reqsList.Size
|
||||
If reqTotales > 0 Then
|
||||
Dim t1 As Timer
|
||||
t1.Initialize("T1", 20000)
|
||||
t1.Enabled = True
|
||||
' t1.Initialize("T1", 20000)
|
||||
' t1.Enabled = True
|
||||
End If
|
||||
End Sub
|
||||
|
||||
' **FUNCIÓN ESTANDARIZADA:** Ejecuta la subida de datos (equivalente a Subir_Click -> SUBIR_INFO_PEDIDO)
|
||||
Public Sub envia
|
||||
enviando = True
|
||||
' 1. Limpieza y preparación inicial (lógica de Subir_Click)
|
||||
SUBIR_INFO_PREPARACION
|
||||
|
||||
@@ -291,88 +295,73 @@ Private Sub enviaPedido(filtro As String)
|
||||
End If
|
||||
|
||||
reqManager.ExecuteCommand(cmd , $"ins_pedido_${cPed.GetString("PE_CLIENTE")}"$)
|
||||
contador_env = contador_env + 1
|
||||
Next
|
||||
cPed.Close
|
||||
End If
|
||||
contador_env = contador_env + 1
|
||||
Next
|
||||
cPed.Close
|
||||
End If
|
||||
End Sub
|
||||
|
||||
' El callback se maneja aquí, ya que 'Me' fue C_Kelloggs en la inicialización del reqManager
|
||||
Sub JobDone(Job As HttpJob)
|
||||
Log("JOBDONE KELLOGGS")
|
||||
' Lógica para manejar errores y remover de reqsList
|
||||
' reqManager.trackNext(Job)
|
||||
|
||||
If Not(Job.Success) Then
|
||||
LogColor("Error: " & Job.tag & " : " & Subs.parseHTTPError(Job.ErrorMessage), Colors.red)
|
||||
Else ' Si Job.Success es True
|
||||
Dim RESULT As DBResult = reqManager.HandleJob(Job)
|
||||
|
||||
LogColor("JobDone: '" & RESULT.tag & "' - Registros: " & RESULT.Rows.Size, Colors.Green)
|
||||
Log("JOBDONE - " & almacen)
|
||||
|
||||
' 1. Tachamos el request de la lista
|
||||
If reqManager.reqsList.IsInitialized Then
|
||||
Dim index As Int = reqManager.reqsList.IndexOf(Job.tag)
|
||||
If index <> -1 Then reqManager.reqsList.RemoveAt(index)
|
||||
End If
|
||||
|
||||
If Job.JobName = "DBRequest" Then
|
||||
|
||||
' Manejo de comandos de INSERCIÓN (Actualización de estados en DB local)
|
||||
If RESULT.Tag.As(String).StartsWith("ins_pedido_") Then ' Procesa insert_pedido_KELL
|
||||
Private temp() As String = Regex.Split("_", RESULT.Tag)
|
||||
If temp.Length > 1 Then
|
||||
B4XPages.MainPage.skmt.ExecNonQuery($"update pedido set pe_enviado = 1 where pe_cliente = '${temp(2)}'"$)
|
||||
End If
|
||||
|
||||
Else If RESULT.Tag.As(String).StartsWith("ins_pedidos_") Then ' Procesa insert_pedidos_KELL (Cabeceras)
|
||||
Private temp() As String = Regex.Split("_", RESULT.Tag)
|
||||
If temp.Length > 1 Then
|
||||
B4XPages.MainPage.skmt.ExecNonQuery($"update pedido_cliente set pc_enviado = 1 where pc_cliente = '${temp(2)}'"$)
|
||||
End If
|
||||
|
||||
Else If RESULT.Tag = "valida_pedido" Then ' Procesa select_cuantos_pedido_KELL
|
||||
' Lógica de validación de pedidos (productos)
|
||||
For Each records() As Object In RESULT.Rows
|
||||
Dim CUANTOSP As Int = records(RESULT.Columns.Get("CUANTOSP"))
|
||||
If cuantos_pedido <= CUANTOSP Then
|
||||
Log($"Validación Pedidos OK: ${CUANTOSP}/${cuantos_pedido}"$)
|
||||
Else
|
||||
LogColor($"Validación Pedidos FALLÓ: ${CUANTOSP}/${cuantos_pedido}. Se requiere reenvío."$, Colors.Red)
|
||||
End If
|
||||
Next
|
||||
|
||||
Else If RESULT.Tag = "valida_pedidoc" Then ' Procesa select_cuantos_pedidoc_KELL
|
||||
' Lógica de validación de pedidos cliente (cabeceras)
|
||||
For Each records() As Object In RESULT.Rows
|
||||
Dim CUANTOSC As Int = records(RESULT.Columns.Get("CUANTOSC"))
|
||||
If cuantos_pedidosc = CUANTOSC Then
|
||||
Log($"Validación Pedidos Cliente OK: ${CUANTOSC}/${cuantos_pedidosc}"$)
|
||||
Else
|
||||
LogColor($"Validación Pedidos Cliente FALLÓ: ${CUANTOSC}/${cuantos_pedidosc}. Se requiere reenvío."$, Colors.Red)
|
||||
End If
|
||||
Next
|
||||
|
||||
Else If RESULT.Tag = "valida_noventa" Then ' Procesa select_cuantos_noventa_KELL
|
||||
' Lógica de validación de no venta
|
||||
For Each records() As Object In RESULT.Rows
|
||||
Dim CUANTOSN As Int = records(RESULT.Columns.Get("CUANTOSN"))
|
||||
If cuantos_noventa = CUANTOSN Then
|
||||
Log($"Validación NoVenta OK: ${CUANTOSN}/${cuantos_noventa}"$)
|
||||
Else
|
||||
LogColor($"Validación NoVenta FALLÓ: ${CUANTOSN}/${cuantos_noventa}. Se requiere reenvío."$, Colors.Red)
|
||||
End If
|
||||
Next
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
|
||||
Job.Release
|
||||
|
||||
' Lógica de finalización: Inicia la validación al terminar todos los envíos
|
||||
If reqManager.reqsList.Size = 0 Then
|
||||
If PASO = "1" Then ' Si terminamos la fase de envío
|
||||
PASO = "2"
|
||||
Dim t1 As Timer
|
||||
t1.Initialize("T1", 2000)
|
||||
t1.Enabled = True
|
||||
Log("Envío finalizado. Se inicia TIMER T1 para validación.")
|
||||
End If
|
||||
End If
|
||||
If Not(Job.Success) Then
|
||||
LogColor("Error en red: " & Job.tag & " : " & Subs.parseHTTPError(Job.ErrorMessage), Colors.Red)
|
||||
Else
|
||||
' 2. Procesamos validaciones
|
||||
Dim RESULT As DBResult = reqManager.HandleJob(Job)
|
||||
|
||||
If Job.JobName = "DBRequest" Then
|
||||
If RESULT.Tag = "valida_pedido" Then
|
||||
Subs.logJobDoneResultados(RESULT)
|
||||
For Each records() As Object In RESULT.Rows
|
||||
Dim CUANTOSP As Int = records(RESULT.Columns.Get("CUANTOSP"))
|
||||
B4XPages.MainPage.l_vProds2.Text = $"${CUANTOSP}/${cuantos_pedido}"$
|
||||
' Mantenemos tu lógica permisiva
|
||||
If cuantos_pedido <= CUANTOSP Then
|
||||
datos_iguales = "ok"
|
||||
Else
|
||||
LogColor("Faltan pedidos. Envíe nuevamente: " & CUANTOSP & "/" & cuantos_pedido, Colors.Red)
|
||||
End If
|
||||
Next
|
||||
Else If RESULT.Tag = "valida_pedidoc" Then
|
||||
Subs.logJobDoneResultados(RESULT)
|
||||
For Each records() As Object In RESULT.Rows
|
||||
Dim CUANTOSC As Int = records(RESULT.Columns.Get("CUANTOSC"))
|
||||
B4XPages.MainPage.l_vPedidos2.Text = $"${CUANTOSC}/${cuantos_pedidosc}"$
|
||||
Next
|
||||
Else If RESULT.Tag = "valida_noventa" Then
|
||||
Subs.logJobDoneResultados(RESULT)
|
||||
For Each records() As Object In RESULT.Rows
|
||||
Dim CUANTOSN As Int = records(RESULT.Columns.Get("CUANTOSN"))
|
||||
B4XPages.MainPage.l_vNoVenta2.Text = $"${CUANTOSN}/${cuantos_noventa}"$
|
||||
Next
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
|
||||
Job.Release
|
||||
|
||||
' 3. Control de flujo seguro
|
||||
If reqManager.reqsList.size = 0 Then
|
||||
B4XPages.MainPage.p_progressDialog.Visible = False
|
||||
If enviando Then
|
||||
enviando = False
|
||||
B4XPages.MainPage.l_progressDialog.Text = "Validando "
|
||||
B4XPages.MainPage.p_progressDialog.Visible = True
|
||||
Sleep(200)
|
||||
valida
|
||||
Else If validando Then
|
||||
validando = False
|
||||
Sleep(300)
|
||||
B4XPages.MainPage.p_validacion.Visible = True
|
||||
End If
|
||||
End If
|
||||
End Sub
|
||||
|
||||
' Lógica de validación forzada (simula T1_Tick)
|
||||
|
||||
Reference in New Issue
Block a user