feat(aititMainLoader): Сделана основная логика загрущки данных из АИХ ИТ в очередь сообщений

This commit is contained in:
Mikhail Kuznetsov
2025-05-19 10:16:09 +10:00
parent b03af638f6
commit 082bc9bf15
16 changed files with 600 additions and 10 deletions

View File

@@ -0,0 +1,71 @@
using Microsoft.Data.SqlClient;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using PARR.AIHITMainLoader.Context;
using PARR.AIHITMainLoader.Models;
namespace PARR.AIHITMainLoader.Services
{
internal class AihitService : IAihitService
{
private readonly AIHITContext context;
private readonly ILogger<AihitService> logger;
public AihitService(
AIHITContext context,
ILogger<AihitService> logger
)
{
this.context = context;
this.logger = logger;
}
public IEnumerable<IMainData> GetPtkData(string respArea)
{
var parameters = new List<SqlParameter>() { new SqlParameter("@зо", respArea) };
try
{
var result = context.Set<PtkData>().FromSqlRaw($"EXEC mao2.dbo.sp_IPP_PARR_PTK_get_EK @зо", parameters.ToArray()).AsEnumerable();
if (result == null || !result.Any())
{
logger.LogWarning($"Процедура sp_IPP_PARR_PTK_get_EK вернула пустой список ЭК");
}
return result;
}
catch (Exception ex)
{
logger.LogError(ex, $"Ошибка при выполнении ХП sp_IPP_PARR_PTK_get_EK({respArea})");
}
return new List<IMainData>();
}
public IEnumerable<IMainData> GetCvkData(string respArea)
{
var parameters = new List<SqlParameter>() { new SqlParameter("@зо", respArea) };
try
{
var result = context.Set<CvkData>().FromSqlRaw($"EXEC mao2.dbo.sp_IPP_PARR_PTK_get_EK_CVK @зо", parameters.ToArray()).AsEnumerable();
if (result == null || !result.Any())
{
logger.LogWarning($"Процедура sp_IPP_PARR_PTK_get_EK_CVK вернула пустой список ЭК");
}
return result;
}
catch (Exception ex)
{
logger.LogError(ex, $"Ошибка при выполнении ХП sp_IPP_PARR_PTK_get_EK_CVK({respArea})");
}
return new List<IMainData>();
}
}
}

View File

@@ -0,0 +1,10 @@
using PARR.AIHITMainLoader.Models;
namespace PARR.AIHITMainLoader.Services
{
internal interface IAihitService
{
IEnumerable<IMainData> GetPtkData(string respArea);
IEnumerable<IMainData> GetCvkData(string respArea);
}
}