This commit is contained in:
Artyom_Yashin 2024-05-27 04:17:24 +04:00
commit 52ce619788
5 changed files with 370 additions and 62 deletions

View File

@ -14,6 +14,7 @@ namespace BankBusinessLogic.OfficePackage
public void CreateCreateTransfersDocDoc(PdfInfo info)
{
CreatePdf(info);
//title
CreateParagraph(new PdfParagraph
{
Text = info.Title,
@ -24,30 +25,162 @@ namespace BankBusinessLogic.OfficePackage
{
Text = $"с{ info.DateFrom.ToShortDateString() } по { info.DateTo.ToShortDateString() }", Style = "Normal", ParagraphAlignment = PdfParagraphAlignmentType.Center
});
CreateTable(new List<string> { "2cm", "3cm", "6cm", "3cm", "3cm" });
//sender transfers
CreateParagraph(new PdfParagraph
{
Text = "Переводы на другие счета",
Style = "NormalTitle",
ParagraphAlignment = PdfParagraphAlignmentType.Left
});
CreateTable(new List<string> { "2cm", "3cm", "6cm", "3cm", "3cm" });
CreateRow(new PdfRowParameters
{
Texts = new List<string> { "Номер", "Дата заказа", "Компьютер", "Сумма", "Статус" },
Texts = new List<string> { "Номер счёта", "Номер перевода", "Время перевода", "Сумма", "Номер счёта получателя" },
Style = "NormalTitle",
ParagraphAlignment = PdfParagraphAlignmentType.Center
});
foreach (var entry in info.OperationsRequests)
foreach (var report in info.TransfersWithdrawals)
{
CreateRow(new PdfRowParameters
{
Texts = new List<string> { entry.CardNumber.ToString(), },
Texts = new List<string>
{
report.AccountNumber.ToString(),
"",
"",
"",
"",
},
Style = "Normal",
ParagraphAlignment = PdfParagraphAlignmentType.Left
});
foreach(var senderTransfer in report.SenderTransfers)
{
CreateRow(new PdfRowParameters
{
Texts = new List<string>
{
"",
senderTransfer.Id.ToString(),
senderTransfer.TransferTime.ToString(),
senderTransfer.Sum.ToString(),
senderTransfer.RecipientAccountNumber.ToString(),
},
Style = "Normal",
ParagraphAlignment = PdfParagraphAlignmentType.Left
});
}
}
CreateParagraph(new PdfParagraph
{
Text = "",
Style = "Normal",
ParagraphAlignment =
PdfParagraphAlignmentType.Right
ParagraphAlignment = PdfParagraphAlignmentType.Right
});
SavePdf(info);
//recipient transfers
CreateParagraph(new PdfParagraph
{
Text = "Переводы с других счетов",
Style = "NormalTitle",
ParagraphAlignment = PdfParagraphAlignmentType.Left
});
CreateTable(new List<string> { "2cm", "3cm", "6cm", "3cm", "3cm" });
CreateRow(new PdfRowParameters
{
Texts = new List<string> { "Номер счёта", "Номер перевода", "Время перевода", "Сумма", "Номер счёта отправителя" },
Style = "NormalTitle",
ParagraphAlignment = PdfParagraphAlignmentType.Center
});
foreach (var report in info.TransfersWithdrawals)
{
CreateRow(new PdfRowParameters
{
Texts = new List<string>
{
report.AccountNumber.ToString(),
"",
"",
"",
"",
},
Style = "Normal",
ParagraphAlignment = PdfParagraphAlignmentType.Left
});
foreach (var recipientTransfer in report.RecipientTransfers)
{
CreateRow(new PdfRowParameters
{
Texts = new List<string>
{
"",
recipientTransfer.Id.ToString(),
recipientTransfer.TransferTime.ToString(),
recipientTransfer.Sum.ToString(),
recipientTransfer.SenderAccountNumber,
},
Style = "Normal",
ParagraphAlignment = PdfParagraphAlignmentType.Left
});
}
}
CreateParagraph(new PdfParagraph
{
Text = "",
Style = "Normal",
ParagraphAlignment = PdfParagraphAlignmentType.Right
});
//withdrawals
CreateParagraph(new PdfParagraph
{
Text = "Выдачи наличных",
Style = "NormalTitle",
ParagraphAlignment = PdfParagraphAlignmentType.Left
});
CreateTable(new List<string> { "2cm", "3cm", "6cm", "3cm", "3cm" });
CreateRow(new PdfRowParameters
{
Texts = new List<string> { "Номер счёта", "Номер выдачи", "Время выдачи", "Сумма" },
Style = "NormalTitle",
ParagraphAlignment = PdfParagraphAlignmentType.Center
});
foreach (var report in info.TransfersWithdrawals)
{
CreateRow(new PdfRowParameters
{
Texts = new List<string>
{
report.AccountNumber.ToString(),
"",
"",
"",
},
Style = "Normal",
ParagraphAlignment = PdfParagraphAlignmentType.Left
});
foreach (var withdrawal in report.Withdrawals)
{
CreateRow(new PdfRowParameters
{
Texts = new List<string>
{
"",
withdrawal.Id.ToString(),
withdrawal.WithdrawalTime.ToString(),
withdrawal.Sum.ToString(),
},
Style = "Normal",
ParagraphAlignment = PdfParagraphAlignmentType.Left
});
}
}
CreateParagraph(new PdfParagraph
{
Text = "",
Style = "Normal",
ParagraphAlignment = PdfParagraphAlignmentType.Right
});
//
SavePdf(info);
}
public void CreateOperationsRequestsDoc(PdfInfo info)
{

View File

@ -137,31 +137,34 @@ namespace BankDatabaseImplement.Implements
{
using var context = new BankDatabase();
return context.Accounts
.Select(a => new ReportTransfersWithdrawalsViewModel()
.Select(account => new ReportTransfersWithdrawalsViewModel()
{
AccountNumber = a.Number,
AccountNumber = account.Number,
SenderTransfers = context.Transfers
.Include(x => x.RecipientAccount)
.Where(t => t.TransferTime <= model.DateTo &&
t.TransferTime >= model.DateFrom &&
t.SenderAccountId == a.Id)
t.SenderAccountId == account.Id)
.Select(t => t.GetViewModel)
.ToList(),
RecipientTransfers = context.Transfers
.Where(t => t.TransferTime <= model.DateTo &&
.Include(x => x.SenderAccount)
.Where(t => t.TransferTime <= model.DateTo &&
t.TransferTime >= model.DateFrom &&
t.RecipientAccountId == a.Id)
t.RecipientAccountId == account.Id)
.Select(t => t.GetViewModel)
.ToList(),
Withdrawals = context.Withdrawals
.Include(w => w.Accounts)
.Where(w => w.WithdrawalTime <= model.DateTo &&
w.WithdrawalTime >= model.DateFrom && w.Accounts
.Select(x => x.AccountId)
.ToList()
.Contains(a.Id))
.Select(w => w.GetViewModel)
.ToList()
})
Withdrawals = context.AccountWithdrawals
.Include(x => x.Withdrawal)
.ThenInclude(x => x.Accounts)
.Where(x => x.AccountId == account.Id)
.Select(x => x.Withdrawal)
.Where(w =>
w.WithdrawalTime <= model.DateTo &&
w.WithdrawalTime >= model.DateFrom)
.Select(w => w.GetViewModel)
.ToList(),
})
.ToList();
}
}

View File

@ -6,6 +6,7 @@ using BankDataModels.Models;
using BankManagersClientApp.Models;
using Microsoft.AspNetCore.Mvc;
using System.Diagnostics;
using System.Globalization;
namespace BankManagersClientApp.Controllers
{
@ -522,17 +523,158 @@ namespace BankManagersClientApp.Controllers
}
APIClient.PostRequest("api/report/sendtransferswithdrawalstoemail", new ReportBindingModel
{
FileName = "C:\\Users\\pdffile.pdf",
FileName = "C:\\forpdf\\pdffile.pdf",
DateFrom = dateFrom,
DateTo = dateTo,
Email = APIClient.Client.Email,
});
Response.Redirect("TransfersWithdrawalsListReport");
}
#endregion
Response.Redirect("Index");
}
#region//Error
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
[HttpGet]
public string GetTransfersWithdrawals(DateTime dateFrom, DateTime dateTo)
{
if (APIClient.Client == null)
{
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
}
List<ReportTransfersWithdrawalsViewModel> result;
try
{
string dateFromS = dateFrom.ToString("s", CultureInfo.InvariantCulture);
string dateToS = dateTo.ToString("s", CultureInfo.InvariantCulture);
result = APIClient.GetRequest<List<ReportTransfersWithdrawalsViewModel>>
($"api/report/gettransferswithdrawals?datefrom={dateFromS}&dateto={dateToS}")!;
}
catch
{
_logger.LogError("Ошибка создания отчета");
throw;
}
//sender transfers
string senderTransfersTable = "";
senderTransfersTable += "<h2 class=\"text-custom-color-1\">Переводы на другие счета</h2>";
senderTransfersTable += "<div class=\"table-responsive\">";
senderTransfersTable += "<table class=\"table table-striped table-bordered table-hover\">";
senderTransfersTable += "<thead class=\"table-dark\">";
senderTransfersTable += "<tr>";
senderTransfersTable += "<th scope=\"col\">Номер счёта</th>";
senderTransfersTable += "<th scope=\"col\">Номер перевода</th>";
senderTransfersTable += "<th scope=\"col\">Время перевода</th>";
senderTransfersTable += "<th scope=\"col\">Сумма</th>";
senderTransfersTable += "<th scope=\"col\">Номер счёта получателя</th>";
senderTransfersTable += "</tr>";
senderTransfersTable += "</thead>";
senderTransfersTable += "<tbody>";
foreach (var report in result)
{
senderTransfersTable += "<tr>";
senderTransfersTable += $"<td>{report.AccountNumber}</td>";
senderTransfersTable += $"<td></td>";
senderTransfersTable += $"<td></td>";
senderTransfersTable += $"<td></td>";
senderTransfersTable += $"<td></td>";
senderTransfersTable += "</tr>";
foreach (var senderTransfer in report.SenderTransfers)
{
senderTransfersTable += "<tr>";
senderTransfersTable += $"<td></td>";
senderTransfersTable += $"<td>{senderTransfer.Id}</td>";
senderTransfersTable += $"<td>{senderTransfer.TransferTime}</td>";
senderTransfersTable += $"<td>{senderTransfer.Sum}</td>";
senderTransfersTable += $"<td>{senderTransfer.RecipientAccountNumber}</td>";
senderTransfersTable += "</tr>";
}
}
senderTransfersTable += "</tbody>";
senderTransfersTable += "</table>";
senderTransfersTable += "</div>";
//recipient transfers
string recipientTransfersTable = "";
recipientTransfersTable += "<h2 class=\"text-custom-color-1\">Переводы с других счетов</h2>";
recipientTransfersTable += "<div class=\"table-responsive\">";
recipientTransfersTable += "<table class=\"table table-striped table-bordered table-hover\">";
recipientTransfersTable += "<thead class=\"table-dark\">";
recipientTransfersTable += "<tr>";
recipientTransfersTable += "<th scope=\"col\">Номер счёта</th>";
recipientTransfersTable += "<th scope=\"col\">Номер перевода</th>";
recipientTransfersTable += "<th scope=\"col\">Время перевода</th>";
recipientTransfersTable += "<th scope=\"col\">Сумма</th>";
recipientTransfersTable += "<th scope=\"col\">Номер счёта отправителя</th>";
recipientTransfersTable += "</tr>";
recipientTransfersTable += "</thead>";
recipientTransfersTable += "<tbody>";
foreach (var report in result)
{
recipientTransfersTable += "<tr>";
recipientTransfersTable += $"<td>{report.AccountNumber}</td>";
recipientTransfersTable += $"<td></td>";
recipientTransfersTable += $"<td></td>";
recipientTransfersTable += $"<td></td>";
recipientTransfersTable += $"<td></td>";
recipientTransfersTable += "</tr>";
foreach (var recipientTransfer in report.RecipientTransfers)
{
recipientTransfersTable += "<tr>";
recipientTransfersTable += $"<td></td>";
recipientTransfersTable += $"<td>{recipientTransfer.Id}</td>";
recipientTransfersTable += $"<td>{recipientTransfer.TransferTime}</td>";
recipientTransfersTable += $"<td>{recipientTransfer.Sum}</td>";
recipientTransfersTable += $"<td>{recipientTransfer.SenderAccountNumber}</td>";
recipientTransfersTable += "</tr>";
}
}
recipientTransfersTable += "</tbody>";
recipientTransfersTable += "</table>";
recipientTransfersTable += "</div>";
//withdrawals
string withdrawalsTable = "";
withdrawalsTable += "<h2 class=\"text-custom-color-1\">Выдачи наличных</h2>";
withdrawalsTable += "<div class=\"table-responsive\">";
withdrawalsTable += "<table class=\"table table-striped table-bordered table-hover\">";
withdrawalsTable += "<thead class=\"table-dark\">";
withdrawalsTable += "<tr>";
withdrawalsTable += "<th scope=\"col\">Номер счёта</th>";
withdrawalsTable += "<th scope=\"col\">Номер выдачи</th>";
withdrawalsTable += "<th scope=\"col\">Время выдачи</th>";
withdrawalsTable += "<th scope=\"col\">Сумма</th>";
withdrawalsTable += "</tr>";
withdrawalsTable += "</thead>";
withdrawalsTable += "<tbody>";
foreach (var report in result)
{
withdrawalsTable += "<tr>";
withdrawalsTable += $"<td>{report.AccountNumber}</td>";
withdrawalsTable += $"<td></td>";
withdrawalsTable += $"<td></td>";
withdrawalsTable += $"<td></td>";
withdrawalsTable += "</tr>";
foreach (var withdrawal in report.Withdrawals)
{
withdrawalsTable += "<tr>";
withdrawalsTable += $"<td></td>";
withdrawalsTable += $"<td>{withdrawal.Id}</td>";
withdrawalsTable += $"<td>{withdrawal.WithdrawalTime}</td>";
withdrawalsTable += $"<td>{withdrawal.Sum}</td>";
withdrawalsTable += "</tr>";
}
}
withdrawalsTable += "</tbody>";
withdrawalsTable += "</table>";
withdrawalsTable += "</div>";
//title
string tables = "";
tables += "<h2 class=\"text-custom-color-1\">Отчет по счетам</h2>";
tables += $"<div class=\"text-custom-color-1\">с {dateFrom.ToShortDateString()} по {dateTo.ToShortDateString()}</div>";
tables += senderTransfersTable;
tables += recipientTransfersTable;
tables += withdrawalsTable;
return tables;
}
#endregion
#region//Error
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
public IActionResult Error()
{
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });

View File

@ -4,39 +4,49 @@
<div class="text-center">
<h3 class="display-4">Список счетов с расшифровкой по переводам и выдачам по периоду</h3>
</div>
<div class="text-center">
@{
<div class="row mb-5">
<div class="col-4">Начальная дата:</div>
<div class="col-8">
<input type="date" id="dateFrom" name="dateFrom" class="form-control">
</div>
<form method="post">
<div class="row mb-5">
<div class="col-4">Начальная дата:</div>
<div class="col-8">
<input type="date" id="dateFrom" name="dateFrom" class="form-control">
</div>
<div class="row mb-5">
<div class="col-4">Конечная дата:</div>
<div class="col-8">
<input type="date" id="dateTo" name="dateTo" class="form-control">
</div>
</div>
<div class="row mb-5">
<div class="col-4">Конечная дата:</div>
<div class="col-8">
<input type="date" id="dateTo" name="dateTo" class="form-control">
</div>
<div class="row">
<div class="col-8"></div>
<div class="col-4"><input value="Создать отчет" class="btn btn-primary" /></div>
</div>
<div class="row">
<div class="col-8"></div>
<div class="col-4"><input type="submit" value="Отправить на почту" class="btn btn-primary" /></div>
</div>
<table class="table">
<thead>
<tr>
<th>Номер</th>
<th>Дата/th>
<th>Счёт</th>
<th>Перевод</th>
<th>Выдача</th>
</tr>
</thead>
<tbody></tbody>
</table>
}
</div>
</div>
<div class="row mb-2">
<div class="col-8"></div>
<div class="col-4"><input id="demonstrate" value="Создать отчет" class="btn btn-primary" /></div>
</div>
<div class="row">
<div class="col-8"></div>
<div class="col-4"><input type="submit" value="Отправить на почту" class="btn btn-primary" /></div>
</div>
<div id="report"></div>
</form>
@section Scripts {
<script>
function check() {
var dateFrom = $('#dateFrom').val();
var dateTo = $('#dateTo').val();
if (dateFrom && dateTo) {
$.ajax({
method: "GET",
url: "/Home/GetTransfersWithdrawals",
data: { dateFrom: dateFrom, dateTo: dateTo },
success: function (result) {
if (result != null) {
$('#report').html(result);
}
}
});
};
}
check();
$('#demonstrate').on('click', (e) => check());
</script>
}

View File

@ -1,6 +1,7 @@
using BankBusinessLogic.MailWorker;
using BankContracts.BindingModels;
using BankContracts.BusinessLogicsContracts;
using BankContracts.SearchModels;
using BankContracts.ViewModels;
using Microsoft.AspNetCore.Mvc;
@ -112,6 +113,25 @@ namespace BankRestApi.Controllers
throw;
}
}
[HttpGet]
public List<ReportTransfersWithdrawalsViewModel> GetTransfersWithdrawals(string dateFrom, string dateTo)
{
try
{
DateTime DateFrom = DateTime.Parse(dateFrom);
DateTime DateTo = DateTime.Parse(dateTo);
return _logic.CreateReportTransfersWithdrawals(new AccountSearchModel
{
DateFrom = DateFrom,
DateTo = DateTo,
});
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка сохранения счетов в pdf");
throw;
}
}
[HttpGet]
public List<ReportOperationsRequestsViewModel> GetOperationsRequests(string dateFromS, string dateToS)