2024-05-28 04:18:31 +04:00
|
|
|
|
using BankContracts.BindingModels.Reports;
|
|
|
|
|
using BankContracts.BusinessLogicsContracts.Reports;
|
|
|
|
|
using BankContracts.ViewModels.Reports;
|
|
|
|
|
using BankDataModels.Enums;
|
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
2024-04-30 16:37:32 +04:00
|
|
|
|
|
|
|
|
|
namespace BankRestAPI.Controllers
|
|
|
|
|
{
|
2024-05-28 04:18:31 +04:00
|
|
|
|
[Route("api/[controller]/[action]")]
|
|
|
|
|
[ApiController]
|
|
|
|
|
public class ReportController : Controller
|
2024-04-30 16:37:32 +04:00
|
|
|
|
{
|
2024-05-28 04:18:31 +04:00
|
|
|
|
private readonly ILogger _logger;
|
|
|
|
|
|
|
|
|
|
private readonly IReportClientLogic _reportClientLogic;
|
|
|
|
|
|
|
|
|
|
private readonly IReportCashierLogic _reportCashierLogic;
|
|
|
|
|
|
|
|
|
|
//хранят данные для отображения отчёта на вебе
|
|
|
|
|
private ReportClientViewModelForHTML _reportClientViewModelForHTML;
|
|
|
|
|
|
|
|
|
|
private ReportCashierViewModelForHTML _reportCashierViewModelForHTML;
|
|
|
|
|
|
|
|
|
|
public ReportController(ILogger<ReportController> logger, IReportClientLogic reportClientLogic, IReportCashierLogic reportCashierLogic)
|
|
|
|
|
{
|
|
|
|
|
_logger = logger;
|
|
|
|
|
_reportClientLogic = reportClientLogic;
|
|
|
|
|
_reportCashierLogic = reportCashierLogic;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//метод генерации отчёта за период по картам клиента
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public ReportClientViewModelForHTML CreateClientReport(ReportSupportBindingModel model)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var result = _reportClientLogic.SaveClientReportToPdfFile(new ReportBindingModel
|
|
|
|
|
{
|
|
|
|
|
FileName = "Отчёт_по_картам.pdf",
|
|
|
|
|
DateFrom = model.DateFrom,
|
|
|
|
|
DateTo = model.DateTo,
|
|
|
|
|
Role = MailsEnum.Клиент,
|
|
|
|
|
Email = model.Email
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogError(ex, "Ошибка входа в систему");
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//метод генерации отчёта по всем счетм клиентов
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public ReportCashierViewModelForHTML CreateCashierReport(ReportSupportBindingModel model)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var result = _reportCashierLogic.SaveAccountsToPdfFile(new ReportBindingModel
|
|
|
|
|
{
|
|
|
|
|
FileName = "Отчёт_по_счетам.pdf",
|
|
|
|
|
ClientId = model.ClientId,
|
|
|
|
|
DateFrom = model.DateFrom,
|
|
|
|
|
DateTo = model.DateTo,
|
|
|
|
|
Role = MailsEnum.Кассир,
|
|
|
|
|
Email = model.Email
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogError(ex, "Ошибка входа в систему");
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//отчёт клиента Excel по переводу денег
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public void CreateExcelClient(ReportSupportBindingModel model)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
_reportClientLogic.SaveToExcelFile(new ReportBindingModel
|
|
|
|
|
{
|
|
|
|
|
FileName = "Отчёт по переводам.xlsx",
|
|
|
|
|
CardList = model.CardList,
|
|
|
|
|
Email = model.Email
|
|
|
|
|
}, OfficeOperationEnum.Между_cчетами);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogError(ex, "Ошибка входа в систему");
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//отчёт клиента Excel по переводу денег
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public void CreateExcelCrediting(ReportSupportBindingModel model)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
_reportClientLogic.SaveToExcelFile(new ReportBindingModel
|
|
|
|
|
{
|
|
|
|
|
FileName = "Отчёт по пополнениям.xlsx",
|
|
|
|
|
CardList = model.CardList,
|
|
|
|
|
Email = model.Email
|
|
|
|
|
}, OfficeOperationEnum.Пополнение_карт);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogError(ex, "Ошибка входа в систему");
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//отчёт клиента Excel по выдаче денег
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public void CreateExcelDebiting(ReportSupportBindingModel model)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
_reportClientLogic.SaveToExcelFile(new ReportBindingModel
|
|
|
|
|
{
|
|
|
|
|
FileName = "Отчёт по снятиям.xlsx",
|
|
|
|
|
CardList = model.CardList,
|
|
|
|
|
Email = model.Email
|
|
|
|
|
}, OfficeOperationEnum.Cнятие_с_карты);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogError(ex, "Ошибка входа в систему");
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//отчёт клиента Excel по переводу денег
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public void CreateExcelCashier(ReportSupportBindingModel model)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
_reportCashierLogic.SaveAccountsToExcelFile(new ReportBindingModel
|
|
|
|
|
{
|
|
|
|
|
FileName = "Отчёт по зявкам на снятие.xlsx",
|
|
|
|
|
AccountId = model.AccountId,
|
|
|
|
|
Email = model.Email
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogError(ex, "Ошибка входа в систему");
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//отчёт клиента Word по переводу денег
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public void CreateWordClient(ReportSupportBindingModel model)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
_reportClientLogic.SaveToWordFile(new ReportBindingModel
|
|
|
|
|
{
|
|
|
|
|
FileName = "Отчёт по переводам.docx",
|
|
|
|
|
CardList = model.CardList,
|
|
|
|
|
Email = model.Email
|
|
|
|
|
}, OfficeOperationEnum.Между_cчетами);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogError(ex, "Ошибка входа в систему");
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//отчёт клиента Word по переводу денег
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public void CreateWordCrediting(ReportSupportBindingModel model)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
_reportClientLogic.SaveToWordFile(new ReportBindingModel
|
|
|
|
|
{
|
|
|
|
|
FileName = "Отчёт по пополнениям.docx",
|
|
|
|
|
CardList = model.CardList,
|
|
|
|
|
Email = model.Email
|
|
|
|
|
}, OfficeOperationEnum.Пополнение_карт);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogError(ex, "Ошибка входа в систему");
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//отчёт клиента Word по выдаче денег
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public void CreateWordDebiting(ReportSupportBindingModel model)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
_reportClientLogic.SaveToWordFile(new ReportBindingModel
|
|
|
|
|
{
|
|
|
|
|
FileName = "Отчёт по снятиям.docx",
|
|
|
|
|
CardList = model.CardList,
|
|
|
|
|
Email = model.Email
|
|
|
|
|
}, OfficeOperationEnum.Cнятие_с_карты);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogError(ex, "Ошибка входа в систему");
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//отчёт клиента Word по переводу денег
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public void CreateWordCashier(ReportSupportBindingModel model)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
_reportCashierLogic.SaveAccountsToWordFile(new ReportBindingModel
|
|
|
|
|
{
|
|
|
|
|
FileName = "Отчёт по зявкам на снятие.docx",
|
|
|
|
|
AccountId = model.AccountId,
|
|
|
|
|
Email = model.Email
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogError(ex, "Ошибка входа в систему");
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
2024-04-30 16:37:32 +04:00
|
|
|
|
}
|