del: Se elimina todo rastro de los vilos ya que no son necesarias.
This commit is contained in:
parent
36bd2ff4f3
commit
bd44537c93
8 changed files with 2 additions and 266 deletions
|
@ -12,16 +12,14 @@ namespace BLL.Integracion_DGA
|
|||
private readonly IConfiguration _configuration;
|
||||
private readonly ApiService _apiService;
|
||||
private readonly JobsDgaRepository _jobs;
|
||||
private readonly JobsDgaVilosRepository _jobsVilos;
|
||||
private readonly JobsDgaSupFlujRepository _jobsSupFluj;
|
||||
private readonly FileLoggerHelper _fileLoggerHelper;
|
||||
|
||||
public BusinessLogic(IConfiguration configuration, ApiService apiService, JobsDgaRepository jobs, JobsDgaVilosRepository jobsVilos, JobsDgaSupFlujRepository jobsSupFluj)
|
||||
public BusinessLogic(IConfiguration configuration, ApiService apiService, JobsDgaRepository jobs, JobsDgaSupFlujRepository jobsSupFluj)
|
||||
{
|
||||
_configuration = configuration;
|
||||
_apiService = apiService;
|
||||
_jobs = jobs;
|
||||
_jobsVilos = jobsVilos;
|
||||
_jobsSupFluj = jobsSupFluj;
|
||||
FileLoggerHelper.ConfigureLogger(_configuration);
|
||||
}
|
||||
|
@ -138,38 +136,6 @@ namespace BLL.Integracion_DGA
|
|||
WriteLineAndLog($"Fin Envio DGA", ConsoleColor.Green);
|
||||
/**************/
|
||||
/**************/
|
||||
WriteLineAndLog($"Inicio Envio DGA Vilos", ConsoleColor.Green);
|
||||
WriteLineAndLog($"\t Descargar datos historian: Insertar InsertarDgaMacroResultadoVilos");
|
||||
List<DgaMacroResultadoVilos> listDgaMacroResultadoVilos = listDgaMacroResultados.Select(item => new DgaMacroResultadoVilos
|
||||
{
|
||||
TagName = item.TagName,
|
||||
TimeStamp = item.TimeStamp,
|
||||
Value = item.Value,
|
||||
Quality = item.Quality
|
||||
}).ToList();
|
||||
|
||||
var resultVilos = await _jobsVilos.InsertarDgaMacroResultadoVilos(listDgaMacroResultadoVilos);
|
||||
|
||||
WriteLineAndLog($"\t Descargar datos historian: Insertar InsertarDgaSensorResultadoVilos");
|
||||
List<DgaSensorResultadoVilos> listDgaSensorResultadoVilos = listDgaMacroResultados.Select(item => new DgaSensorResultadoVilos
|
||||
{
|
||||
TagName = item.TagName,
|
||||
TimeStamp = item.TimeStamp,
|
||||
Value = item.Value,
|
||||
Quality = item.Quality
|
||||
}).ToList();
|
||||
|
||||
var resultSensorVilos = await _jobsVilos.InsertarDgaSensorResultadoVilos(listDgaSensorResultadoVilos);
|
||||
|
||||
WriteLineAndLog($"\t Calculo Suma");
|
||||
var resultCalculoVilos = await _jobsVilos.SpCalculoDgaVilos();
|
||||
|
||||
|
||||
WriteLineAndLog($"\t Traspaso datos achird");
|
||||
var resultAchirdVilos = await _jobsVilos.SpTraspasoDatosAchirdVilos();
|
||||
WriteLineAndLog($"Fin Envio DGA Vilos", ConsoleColor.Green);
|
||||
/**************/
|
||||
/**************/
|
||||
WriteLineAndLog($"Inicio Envio DGA Sup Fluj", ConsoleColor.Green);
|
||||
WriteLineAndLog($"\t Descargar datos historian: Insertar InsertarDgaMacroResultadoSupFluj");
|
||||
List<DgaMacroResultadoSupFluj> listDgaMacroResultadoSupFluj = listDgaMacroResultados.Select(item => new DgaMacroResultadoSupFluj
|
||||
|
|
|
@ -9,14 +9,12 @@ namespace BLL.Recuperacion_DGA
|
|||
public class EnvioDGA
|
||||
{
|
||||
private readonly MedicionScadaRepository _dGAMedicionScadaRepository;
|
||||
private readonly MedicionScadaVilosRepository _dgaMedicionScadaVilosRepository;
|
||||
private readonly RegistrarMedicion _registrarMedicion;
|
||||
|
||||
public EnvioDGA(MedicionScadaRepository dGAMedicionScadaRepository, RegistrarMedicion registrarMedicion, MedicionScadaVilosRepository dgaMedicionScadaVilosRepository)
|
||||
public EnvioDGA(MedicionScadaRepository dGAMedicionScadaRepository, RegistrarMedicion registrarMedicion)
|
||||
{
|
||||
_dGAMedicionScadaRepository = dGAMedicionScadaRepository;
|
||||
_registrarMedicion = registrarMedicion;
|
||||
_dgaMedicionScadaVilosRepository = dgaMedicionScadaVilosRepository;
|
||||
}
|
||||
|
||||
public async Task<bool> RegistrarMedicionesAsync()
|
||||
|
@ -100,82 +98,6 @@ namespace BLL.Recuperacion_DGA
|
|||
}
|
||||
}
|
||||
await WriteLineAndLog("FIN","Fin proceso de recuperación DGA","");
|
||||
|
||||
await WriteLineAndLog("INICIO", "Inicio proceso de recuperación DGA los Vilos", "VILOS");
|
||||
WriteLineAndLog("Obteniendo Mediciones Scada los Vilos", ConsoleColor.Green);
|
||||
var medicionesVilos = await _dgaMedicionScadaVilosRepository.ObtenerMedicionesVilosAsync();
|
||||
foreach (var medicionVilos in medicionesVilos)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!string.IsNullOrEmpty(medicionVilos.Code))
|
||||
{
|
||||
var rutEmpresa = string.Empty;
|
||||
|
||||
if (medicionVilos.tipo_empresa.Equals("AV"))
|
||||
{
|
||||
rutEmpresa = CredencialDGA.RutAv;
|
||||
}
|
||||
else if (medicionVilos.tipo_empresa.Equals("EV"))
|
||||
{
|
||||
rutEmpresa = CredencialDGA.RutEsval;
|
||||
}
|
||||
|
||||
List<string> vacios = new List<string>();
|
||||
if (medicionVilos.Caudal == null || medicionVilos.Caudal.Equals(""))
|
||||
{
|
||||
vacios.Add("caudal");
|
||||
}
|
||||
|
||||
if (medicionVilos.DateOrigen == null)
|
||||
{
|
||||
vacios.Add("fecha origen");
|
||||
}
|
||||
|
||||
if (medicionVilos.nivelFreaticoDelPozo == null || medicionVilos.nivelFreaticoDelPozo.ToString().Equals(""))
|
||||
{
|
||||
vacios.Add("nivel freatico");
|
||||
}
|
||||
|
||||
if (medicionVilos.Totalizador == null || medicionVilos.Totalizador.Equals(""))
|
||||
{
|
||||
vacios.Add("totalizador");
|
||||
}
|
||||
|
||||
if (vacios.Count > 0)
|
||||
{
|
||||
await FileLoggerHelper.InsertarLogsAsync("REGISTRAR", $"Medicion {medicionVilos.Code} no registra {string.Join(", ", vacios)}", "VILOS");
|
||||
}
|
||||
|
||||
var body = new MedicionSubterraneaRequest
|
||||
{
|
||||
Autenticacion = new Autenticacion
|
||||
{
|
||||
Password = CredencialDGA.Password,
|
||||
RutEmpresa = rutEmpresa,
|
||||
RutUsuario = CredencialDGA.RutUsuario
|
||||
},
|
||||
MedicionSubterranea = new Medicion
|
||||
{
|
||||
Caudal = medicionVilos.Caudal.ToString() ?? "",
|
||||
FechaMedicion = medicionVilos.DateOrigen?.ToString("yyyy-MM-dd") ?? "",
|
||||
HoraMedicion = medicionVilos.DateOrigen?.ToString("HH:mm:ss") ?? "",
|
||||
NivelFreaticoDelPozo = medicionVilos.nivelFreaticoDelPozo?.ToString() ?? "",
|
||||
Totalizador = medicionVilos.Totalizador.ToString() ?? "",
|
||||
}
|
||||
};
|
||||
|
||||
//await _registrarMedicion.EnviarMedicionAsync(medicionVilos.Code, body, medicionVilos.Id);
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
FileLoggerHelper.LogError($"[Error] {ex.Message}.", ex);
|
||||
WriteLineAndLog($"Error al enviar la medición vilos con ID {medicionVilos.Code}.", ConsoleColor.Red);
|
||||
}
|
||||
}
|
||||
await WriteLineAndLog("FIN", "Fin proceso de recuperación DGA los Vilos", "VILOS");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
|
@ -1,103 +0,0 @@
|
|||
using System.Data;
|
||||
using Dapper;
|
||||
using Microsoft.Data.SqlClient;
|
||||
using Shared.DTO.Integracion_DGA;
|
||||
using Shared.DTO.VariablesEntorno;
|
||||
|
||||
namespace DAL
|
||||
{
|
||||
public class JobsDgaVilosRepository
|
||||
{
|
||||
|
||||
public async Task<bool> InsertarDgaMacroResultadoVilos(List<DgaMacroResultadoVilos> dgaMacroResultadoVilos)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (var connection = new SqlConnection(BdConexion.StringConnection))
|
||||
{
|
||||
await connection.OpenAsync();
|
||||
|
||||
// 1. Truncar la tabla antes de insertar
|
||||
await connection.ExecuteAsync("TRUNCATE TABLE DGA_MACRO_RESULTADO_VILOS");
|
||||
|
||||
// 2. Llamar al stored procedure
|
||||
await connection.ExecuteAsync("SP_CALCULO_DGA_VILOS", commandType: System.Data.CommandType.StoredProcedure);
|
||||
|
||||
// 3. Insertar todos los datos de la lista usando Dapper
|
||||
string sql = "INSERT INTO DGA_MACRO_RESULTADO_VILOS (TagName, TimeStamp, Value, Quality) VALUES (@TagName, @TimeStamp, @Value, @Quality)";
|
||||
await connection.ExecuteAsync(sql, dgaMacroResultadoVilos);
|
||||
|
||||
return true; // Éxito
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception($"Error: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<bool> InsertarDgaSensorResultadoVilos(List<DgaSensorResultadoVilos> dgaSensorResultadoVilos)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (var connection = new SqlConnection(BdConexion.StringConnection))
|
||||
{
|
||||
await connection.OpenAsync();
|
||||
|
||||
// 1. Truncar la tabla antes de insertar
|
||||
await connection.ExecuteAsync("TRUNCATE TABLE DGA_SENSOR_RESULTADO_VILOS");
|
||||
|
||||
// 2. Insertar todos los datos de la lista usando Dapper
|
||||
string sql = "INSERT INTO DGA_SENSOR_RESULTADO_VILOS (TagName, TimeStamp, Value, Quality) VALUES (@TagName, @TimeStamp, @Value, @Quality)";
|
||||
await connection.ExecuteAsync(sql, dgaSensorResultadoVilos);
|
||||
|
||||
return true; // Éxito
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception($"Error: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<bool> SpCalculoDgaVilos()
|
||||
{
|
||||
try
|
||||
{
|
||||
using (var connection = new SqlConnection(BdConexion.StringConnection))
|
||||
{
|
||||
await connection.OpenAsync();
|
||||
await connection.ExecuteAsync(
|
||||
"SP_CALCULO_DGA_VILOS",
|
||||
commandType: CommandType.StoredProcedure
|
||||
);
|
||||
}
|
||||
return true; // Éxito
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception($"Error: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<bool> SpTraspasoDatosAchirdVilos()
|
||||
{
|
||||
try
|
||||
{
|
||||
using (var connection = new SqlConnection(BdConexion.StringConnection))
|
||||
{
|
||||
await connection.OpenAsync();
|
||||
await connection.ExecuteAsync(
|
||||
"SP_TRASPASO_DATOS_ACHIRD_VILOS",
|
||||
commandType: CommandType.StoredProcedure
|
||||
);
|
||||
}
|
||||
return true; // Éxito
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception($"Error: {ex.Message}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
using System.Data;
|
||||
using Dapper;
|
||||
using Microsoft.Data.SqlClient;
|
||||
using Shared.DTO.Envios_DGA;
|
||||
using Shared.DTO.VariablesEntorno;
|
||||
|
||||
namespace DAL
|
||||
{
|
||||
public class MedicionScadaVilosRepository
|
||||
{
|
||||
public async Task<List<MedicionScada>> ObtenerMedicionesVilosAsync()
|
||||
{
|
||||
await using var connection = new SqlConnection(BdConexion.StringConnection);
|
||||
|
||||
var result = await connection.QueryAsync<MedicionScada>(
|
||||
"SP_OBTENER_MEDICION_SMARTSCADA_OPERACION_VILOS",
|
||||
commandType: CommandType.StoredProcedure);
|
||||
|
||||
return result.ToList();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -42,12 +42,10 @@ namespace Integracion_DGA
|
|||
services.AddScoped<EnvioDGA>();
|
||||
services.AddHttpClient<RegistrarMedicion>();
|
||||
services.AddScoped<JobsDgaRepository>();
|
||||
services.AddScoped<JobsDgaVilosRepository>();
|
||||
services.AddScoped<JobsDgaSupFlujRepository>();
|
||||
services.AddScoped<LogMedicionScadaRepository>();
|
||||
services.AddScoped<ApiService>();
|
||||
services.AddScoped<BusinessLogic>();
|
||||
services.AddScoped<MedicionScadaVilosRepository>();
|
||||
})
|
||||
.Build();
|
||||
|
||||
|
|
|
@ -39,7 +39,6 @@ namespace Recuperacion_DGA
|
|||
services.AddSingleton<IConfiguration>(configuration);
|
||||
|
||||
services.AddScoped<MedicionScadaRepository>();
|
||||
services.AddScoped<MedicionScadaVilosRepository>();
|
||||
services.AddScoped<EnvioDGA>();
|
||||
services.AddHttpClient<RegistrarMedicion>();
|
||||
services.AddScoped<LogMedicionScadaRepository>();
|
||||
|
|
|
@ -1,12 +0,0 @@
|
|||
namespace Shared.DTO.Integracion_DGA;
|
||||
|
||||
public partial class DgaMacroResultadoVilos
|
||||
{
|
||||
public string TagName { get; set; } = null!;
|
||||
|
||||
public DateTime TimeStamp { get; set; }
|
||||
|
||||
public double? Value { get; set; }
|
||||
|
||||
public string? Quality { get; set; }
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
namespace Shared.DTO.Integracion_DGA;
|
||||
|
||||
public partial class DgaSensorResultadoVilos
|
||||
{
|
||||
public string TagName { get; set; } = null!;
|
||||
|
||||
public DateTime TimeStamp { get; set; }
|
||||
|
||||
public double? Value { get; set; }
|
||||
|
||||
public string? Quality { get; set; }
|
||||
}
|
Loading…
Add table
Reference in a new issue