feat: se actualizan las mediciones una vez se envian y ahora se consideran solo als mediciones que hayan sido creadas durante 7 dias
This commit is contained in:
parent
bd44537c93
commit
fee40a25a4
4 changed files with 32 additions and 7 deletions
|
@ -1,4 +1,5 @@
|
||||||
using DAL;
|
using System.Text.Json;
|
||||||
|
using DAL;
|
||||||
using DAS;
|
using DAS;
|
||||||
using Shared.DTO.Envios_DGA;
|
using Shared.DTO.Envios_DGA;
|
||||||
using Shared.DTO.VariablesEntorno;
|
using Shared.DTO.VariablesEntorno;
|
||||||
|
@ -24,6 +25,7 @@ namespace BLL.Recuperacion_DGA
|
||||||
await WriteLineAndLog("INICIO", "Inicio proceso de recuperación DGA", "");
|
await WriteLineAndLog("INICIO", "Inicio proceso de recuperación DGA", "");
|
||||||
WriteLineAndLog("Obteniendo Mediciones Scada", ConsoleColor.Green);
|
WriteLineAndLog("Obteniendo Mediciones Scada", ConsoleColor.Green);
|
||||||
var mediciones = await _dGAMedicionScadaRepository.ObtenerMedicionesAsync();
|
var mediciones = await _dGAMedicionScadaRepository.ObtenerMedicionesAsync();
|
||||||
|
var listaMediciones = new List<Object>();
|
||||||
foreach (var medicion in mediciones)
|
foreach (var medicion in mediciones)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
@ -69,6 +71,7 @@ namespace BLL.Recuperacion_DGA
|
||||||
{
|
{
|
||||||
await FileLoggerHelper.InsertarLogsAsync("REGISTRAR", $"Medicion {medicion.Code} no registra {string.Join(", ", vacios)}","");
|
await FileLoggerHelper.InsertarLogsAsync("REGISTRAR", $"Medicion {medicion.Code} no registra {string.Join(", ", vacios)}","");
|
||||||
}
|
}
|
||||||
|
var fechaEnvio = DateTime.UtcNow;
|
||||||
|
|
||||||
var body = new MedicionSubterraneaRequest
|
var body = new MedicionSubterraneaRequest
|
||||||
{
|
{
|
||||||
|
@ -87,7 +90,8 @@ namespace BLL.Recuperacion_DGA
|
||||||
Totalizador = medicion.Totalizador.ToString() ?? "",
|
Totalizador = medicion.Totalizador.ToString() ?? "",
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
//await _registrarMedicion.EnviarMedicionAsync(medicion.Code, body, medicion.Id);
|
await _registrarMedicion.EnviarMedicionAsync(medicion, body, fechaEnvio);
|
||||||
|
listaMediciones.Add(new {Id = medicion.Id,FechaEnvio = fechaEnvio.ToString("yyyy-MM-dd HH:mm:ss"), Enviado = medicion.Enviado + 1});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -97,6 +101,12 @@ namespace BLL.Recuperacion_DGA
|
||||||
WriteLineAndLog($"Error al enviar la medición con ID {medicion.Code}.", ConsoleColor.Red);
|
WriteLineAndLog($"Error al enviar la medición con ID {medicion.Code}.", ConsoleColor.Red);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
var listaMedicionesJson = JsonSerializer.Serialize(listaMediciones);
|
||||||
|
|
||||||
|
if (listaMediciones.Count > 0)
|
||||||
|
{
|
||||||
|
await MedicionScadaRepository.ActualizarMedicionesAsync(listaMedicionesJson);
|
||||||
|
}
|
||||||
await WriteLineAndLog("FIN","Fin proceso de recuperación DGA","");
|
await WriteLineAndLog("FIN","Fin proceso de recuperación DGA","");
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
|
|
@ -18,5 +18,19 @@ namespace DAL
|
||||||
|
|
||||||
return result.ToList();
|
return result.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static async Task<bool> ActualizarMedicionesAsync(string medicionesJson)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await using var connection = new SqlConnection(BdConexion.StringConnection);
|
||||||
|
await connection.ExecuteAsync("SP_ACTUALIZAR_MEDICION_SMARTSCADA_OPERACION", new { JsonMediciones = medicionesJson }, commandType: CommandType.StoredProcedure);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
throw new Exception($"Error: {ex.Message}");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,14 +17,14 @@ namespace DAS
|
||||||
_logMedicionScadaRepository = logMedicionScadaRepository;
|
_logMedicionScadaRepository = logMedicionScadaRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<bool> EnviarMedicionAsync(string codigoObra, MedicionSubterraneaRequest request, long idMedicion)
|
public async Task<bool> EnviarMedicionAsync(MedicionScada medicion, MedicionSubterraneaRequest request,DateTime fechaEnvio)
|
||||||
{
|
{
|
||||||
var timeStamp = DateTime.UtcNow.ToString("yyyy-MM-dd'T'HH:mm:ss-0000");
|
var timeStamp = DateTime.UtcNow.ToString("yyyy-MM-dd'T'HH:mm:ss-0000");
|
||||||
|
|
||||||
var json = JsonSerializer.Serialize(request);
|
var json = JsonSerializer.Serialize(request);
|
||||||
var content = new StringContent(json, Encoding.UTF8, "application/json");
|
var content = new StringContent(json, Encoding.UTF8, "application/json");
|
||||||
|
|
||||||
content.Headers.Add("codigoObra", codigoObra);
|
content.Headers.Add("codigoObra", medicion.Code);
|
||||||
content.Headers.Add("timeStampOrigen", timeStamp);
|
content.Headers.Add("timeStampOrigen", timeStamp);
|
||||||
|
|
||||||
var response = await _httpClient.PostAsync($"{SubterraneaApiUrl.BaseUrl}{SubterraneaApiUrl.EndPoint}SSSSSSSSSSSSSSSSS", content);
|
var response = await _httpClient.PostAsync($"{SubterraneaApiUrl.BaseUrl}{SubterraneaApiUrl.EndPoint}SSSSSSSSSSSSSSSSS", content);
|
||||||
|
@ -54,8 +54,8 @@ namespace DAS
|
||||||
JsonEnviado = json,
|
JsonEnviado = json,
|
||||||
JsonRecibido = jsonRecibido,
|
JsonRecibido = jsonRecibido,
|
||||||
Comprobante = comprobante,
|
Comprobante = comprobante,
|
||||||
FechaEnvio = DateTime.UtcNow,
|
FechaEnvio = fechaEnvio,
|
||||||
IdMedicionSmartscadaOperacion = idMedicion
|
IdMedicionSmartscadaOperacion = medicion.Id
|
||||||
};
|
};
|
||||||
|
|
||||||
await _logMedicionScadaRepository.InsertarLogMedicionScadaAsync(logMedicionScada);
|
await _logMedicionScadaRepository.InsertarLogMedicionScadaAsync(logMedicionScada);
|
||||||
|
|
|
@ -20,7 +20,8 @@
|
||||||
public decimal? Caudalsub { get; set; }
|
public decimal? Caudalsub { get; set; }
|
||||||
|
|
||||||
public decimal? Nivel { get; set; }
|
public decimal? Nivel { get; set; }
|
||||||
|
public DateTime? FechaEnvio { get; set; }
|
||||||
|
public int Enviado { get; set; }
|
||||||
public string? tipo_empresa { get; set; }
|
public string? tipo_empresa { get; set; }
|
||||||
public string? nivelFreaticoDelPozo { get; set; }
|
public string? nivelFreaticoDelPozo { get; set; }
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue