Пытался сделать отчеты
This commit is contained in:
parent
f108c6d8f0
commit
a1a7f49996
@ -40,6 +40,11 @@ namespace CaseAccountingBusinessLogic.BusinessLogics
|
|||||||
}
|
}
|
||||||
|
|
||||||
public List<ReportHearingSpecializationViewModel> GetHearingSpecialization(ReportBindingModel model)
|
public List<ReportHearingSpecializationViewModel> GetHearingSpecialization(ReportBindingModel model)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*public List<ReportHearingSpecializationViewModel> GetHearingSpecialization(ReportBindingModel model)
|
||||||
{
|
{
|
||||||
var result = _hearingStorage
|
var result = _hearingStorage
|
||||||
.GetFilteredList(new HearingSearchModel { UserId = model.UserId })
|
.GetFilteredList(new HearingSearchModel { UserId = model.UserId })
|
||||||
@ -56,7 +61,7 @@ namespace CaseAccountingBusinessLogic.BusinessLogics
|
|||||||
})
|
})
|
||||||
.ToList();
|
.ToList();
|
||||||
return result;
|
return result;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
public List<ReportLawyerHearingViewModel> GetLawyersHearing(List<LawyerViewModel> lawyers)
|
public List<ReportLawyerHearingViewModel> GetLawyersHearing(List<LawyerViewModel> lawyers)
|
||||||
{
|
{
|
||||||
@ -109,6 +114,44 @@ namespace CaseAccountingBusinessLogic.BusinessLogics
|
|||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*public List<ReportHearingSpecializationViewModel> GetHearingSpecialization(ReportBindingModel model)
|
||||||
|
{
|
||||||
|
var hearings = _hearingStorage.GetFilteredList(new HearingSearchModel
|
||||||
|
{
|
||||||
|
DateFrom = model.DateFrom,
|
||||||
|
DateTo = model.DateTo
|
||||||
|
});
|
||||||
|
|
||||||
|
var casesIds = hearings.Select(x => x.CaseId).ToList();
|
||||||
|
|
||||||
|
var cases = _caseStorage.GetFullList().Where(x => casesIds.Contains(x.Id));
|
||||||
|
|
||||||
|
List<SpecializationViewModel> specializations = new List<SpecializationViewModel>();
|
||||||
|
|
||||||
|
foreach (var _case in cases)
|
||||||
|
{
|
||||||
|
specializations.Add(_specializationStorage.GetElement(new SpecializationSearchModel { Id = _case.Id }));
|
||||||
|
}
|
||||||
|
|
||||||
|
*//*var reportRecords = new List<ReportHearingSpecializationViewModel>();
|
||||||
|
|
||||||
|
foreach (var _case in cases)
|
||||||
|
{
|
||||||
|
ReportHearingSpecializationViewModel reportData = new ReportHearingSpecializationViewModel();
|
||||||
|
reportData.Name = _case.Name;
|
||||||
|
|
||||||
|
var hearings = _caseStorage.GetCaseHearing(new() { Id = _case.Id });
|
||||||
|
|
||||||
|
var specialization = _caseStorage.GetCaseSpecialization(new() { Id = _case.Id });
|
||||||
|
|
||||||
|
reportData.hearings = hearings;
|
||||||
|
reportData.Specialization = specialization.Name;
|
||||||
|
reportRecords.Add(reportData);
|
||||||
|
}*//*
|
||||||
|
|
||||||
|
//return reportRecords;
|
||||||
|
}*/
|
||||||
|
|
||||||
/*public void SendByMailStatusReport(ReportBindingModel reportModel)
|
/*public void SendByMailStatusReport(ReportBindingModel reportModel)
|
||||||
{
|
{
|
||||||
byte[] file = _pdfBuilder.GetHearingSpecializationReportFile(new()
|
byte[] file = _pdfBuilder.GetHearingSpecializationReportFile(new()
|
||||||
@ -116,7 +159,7 @@ namespace CaseAccountingBusinessLogic.BusinessLogics
|
|||||||
Title = "Отчет по слушаниям",
|
Title = "Отчет по слушаниям",
|
||||||
DateFrom = reportModel.DateFrom,
|
DateFrom = reportModel.DateFrom,
|
||||||
DateTo = reportModel.DateTo,
|
DateTo = reportModel.DateTo,
|
||||||
//Records = GetHearingLawyer(reportModel)
|
Records = GetHearingSpecialization(reportModel)
|
||||||
});
|
});
|
||||||
_mailSender.SendMailAsync(new()
|
_mailSender.SendMailAsync(new()
|
||||||
{
|
{
|
||||||
|
@ -136,25 +136,26 @@ namespace CaseAccountingBusinessLogic.OfficePackage
|
|||||||
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
||||||
});
|
});
|
||||||
|
|
||||||
CreateTable(new List<string> { "4cm", "5cm", "3cm", "3cm" });
|
CreateTable(new List<string> { "4cm", "2cm", "4cm", "2cm", "4cm" });
|
||||||
|
|
||||||
CreateRow(new PdfRowParameters
|
CreateRow(new PdfRowParameters
|
||||||
{
|
{
|
||||||
Texts = new List<string> { "Номер слушания", "Дело", "Дата проведения", "Юрист" },
|
Texts = new List<string> { "Продукт", "Блюдо", "Дата заказа", "Напиток", "Дата заказа" },
|
||||||
Style = "NormalTitle",
|
Style = "NormalTitle",
|
||||||
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
||||||
});
|
});
|
||||||
|
|
||||||
foreach (var record in data.Records)
|
foreach (var record in data.Records)
|
||||||
{
|
{
|
||||||
List<> casesAndLawyes = record.CaseLawyers;
|
List<HearingViewModel> hearings = record.hearings;
|
||||||
int recordHeight = casesAndLawyes.Count + 1;
|
string specialization = record.Specialization;
|
||||||
|
int recordHeight = Math.Max(hearings.Count + 1, 1);
|
||||||
for (int i = 0; i < recordHeight; i++)
|
for (int i = 0; i < recordHeight; i++)
|
||||||
{
|
{
|
||||||
List<string> cellsData = new() { "", "", "", "" };
|
List<string> cellsData = new() { "", "", "", "", "" };
|
||||||
if (i == 0)
|
if (i == 0)
|
||||||
{
|
{
|
||||||
cellsData[0] = record.Hearing;
|
cellsData[0] = record.Information;
|
||||||
CreateRow(new PdfRowParameters
|
CreateRow(new PdfRowParameters
|
||||||
{
|
{
|
||||||
Texts = cellsData,
|
Texts = cellsData,
|
||||||
@ -164,12 +165,13 @@ namespace CaseAccountingBusinessLogic.OfficePackage
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
int k = i - 1;
|
int k = i - 1;
|
||||||
if (k < casesAndLawyes.Count)
|
if (k < hearings.Count)
|
||||||
{
|
{
|
||||||
cellsData[1] = casesAndLawyes[k].Case;
|
cellsData[1] = hearings[k].Id.ToString();
|
||||||
cellsData[2] = casesAndLawyes[k].Date.ToString("yyyy-MM-dd");
|
cellsData[2] = hearings[k].Date.ToString();
|
||||||
cellsData[3] = casesAndLawyes[k].Lawyer;
|
|
||||||
}
|
}
|
||||||
|
cellsData[3] = specialization;
|
||||||
|
|
||||||
CreateRow(new PdfRowParameters
|
CreateRow(new PdfRowParameters
|
||||||
{
|
{
|
||||||
Texts = cellsData,
|
Texts = cellsData,
|
||||||
|
@ -21,5 +21,9 @@ namespace CaseAccountingContracts.SearchModels
|
|||||||
public int? SpecializationId { get; set; }
|
public int? SpecializationId { get; set; }
|
||||||
|
|
||||||
public int? UserId { get; set; }
|
public int? UserId { get; set; }
|
||||||
|
|
||||||
|
public DateTime? DateFrom { get; set; }
|
||||||
|
|
||||||
|
public DateTime? DateTo { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,5 +15,8 @@ namespace CaseAccountingContracts.SearchModels
|
|||||||
public int? CaseId { get; set; }
|
public int? CaseId { get; set; }
|
||||||
|
|
||||||
public int? UserId { get; set; }
|
public int? UserId { get; set; }
|
||||||
|
|
||||||
|
public DateTime? DateFrom { get; set; }
|
||||||
|
public DateTime? DateTo { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,10 @@ namespace CaseAccountingContracts.StoragesContracts
|
|||||||
CaseViewModel? Update(CaseBindingModel model);
|
CaseViewModel? Update(CaseBindingModel model);
|
||||||
CaseViewModel? Delete(CaseBindingModel model);
|
CaseViewModel? Delete(CaseBindingModel model);
|
||||||
|
|
||||||
|
List<HearingViewModel> GetCaseHearing(CaseSearchModel model);
|
||||||
|
|
||||||
|
SpecializationViewModel GetCaseSpecialization(SpecializationSearchModel model);
|
||||||
|
|
||||||
List<CaseViewModel> GetCaseMTM(int lawyerId);
|
List<CaseViewModel> GetCaseMTM(int lawyerId);
|
||||||
List<SpecializationCasesViewModel>? GetSpecializationCases();
|
List<SpecializationCasesViewModel>? GetSpecializationCases();
|
||||||
}
|
}
|
||||||
|
@ -9,10 +9,10 @@ namespace CaseAccountingContracts.ViewModels
|
|||||||
{
|
{
|
||||||
public class ReportHearingSpecializationViewModel
|
public class ReportHearingSpecializationViewModel
|
||||||
{
|
{
|
||||||
public string Information { get; set; } = string.Empty;
|
|
||||||
|
|
||||||
public DateTime Date { get; set; }
|
|
||||||
|
|
||||||
public string Specialization { get; set; } = string.Empty;
|
public string Specialization { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public string Name { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public List<HearingViewModel> hearings { get; set; } = new();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -117,5 +117,24 @@ namespace CaseAccountingCustomerView.Controllers
|
|||||||
{
|
{
|
||||||
return View();
|
return View();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IActionResult GetReport()
|
||||||
|
{
|
||||||
|
return View();
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public List<ReportHearingSpecializationViewModel>? GetReport([FromBody] ReportBindingModel reportModel)
|
||||||
|
{
|
||||||
|
if (APIUser.User == null)
|
||||||
|
{
|
||||||
|
return new();
|
||||||
|
}
|
||||||
|
reportModel.UserId = APIUser.User.Id;
|
||||||
|
reportModel.UserEmail = APIUser.User.Login;
|
||||||
|
List<ReportHearingSpecializationViewModel>? list = APIUser.PostRequestWithResult<ReportBindingModel, List<ReportHearingSpecializationViewModel>>
|
||||||
|
("api/reportcustomer/getreportdata", reportModel);
|
||||||
|
return list;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1 +1,121 @@
|
|||||||
|
|
||||||
|
const dateFromInput = document.getElementById("date-from-input");
|
||||||
|
const dateToInput = document.getElementById("date-to-input");
|
||||||
|
const generateButton = document.getElementById("generate-button");
|
||||||
|
const sendByMailButton = document.getElementById("send-by-mail-button");
|
||||||
|
const dateToSpan = document.getElementById("date-to-span");
|
||||||
|
const dateFromSpan = document.getElementById("date-from-span");
|
||||||
|
const dateFrom = new Date(dateFromInput.value);
|
||||||
|
const dateTo = new Date(dateToInput.value);
|
||||||
|
const reportModel = {
|
||||||
|
"DateFrom": dateFrom,
|
||||||
|
"DateTo": dateTo
|
||||||
|
};
|
||||||
|
const tbody = document.getElementById("tbody");
|
||||||
|
|
||||||
|
function sendByMail() {
|
||||||
|
$.ajax({
|
||||||
|
url: "/home/sendbymailstatusreport",
|
||||||
|
type: "POST",
|
||||||
|
contentType: "application/json",
|
||||||
|
data: JSON.stringify(reportModel)
|
||||||
|
}).done(() => {
|
||||||
|
alert("Отчет успешно отправлен на вашу почту!")
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
generateButton.addEventListener("click", () => {
|
||||||
|
const dateFrom = new Date(dateFromInput.value);
|
||||||
|
const dateTo = new Date(dateToInput.value);
|
||||||
|
const reportModel = {
|
||||||
|
"DateFrom": dateFrom,
|
||||||
|
"DateTo": dateTo
|
||||||
|
};
|
||||||
|
$.ajax({
|
||||||
|
url: "/home/getreport",
|
||||||
|
type: "POST",
|
||||||
|
contentType: "application/json",
|
||||||
|
data: JSON.stringify(reportModel)
|
||||||
|
}).done((data) => {
|
||||||
|
dateFromSpan.innerHTML = reportModel["DateFrom"].toLocaleDateString();
|
||||||
|
dateToSpan.innerHTML = reportModel["DateTo"].toLocaleDateString();
|
||||||
|
renderTable(data);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
function populateTable(data) {
|
||||||
|
tbody.innerHTML = ""; // Clear the tbody before populating with new data
|
||||||
|
|
||||||
|
// Find the maximum length between dishes and alcohol drinks
|
||||||
|
let maxLength = 0;
|
||||||
|
data.forEach((item) => {
|
||||||
|
maxLength = Math.max(maxLength, item.hearings, 1);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Loop through the data and create table rows
|
||||||
|
data.forEach((item) => {
|
||||||
|
const caseName = item.caseName;
|
||||||
|
const hearings = item.hearings;
|
||||||
|
const specialization = item.specialization;
|
||||||
|
|
||||||
|
for (let i = 0; i < maxLength; i++) {
|
||||||
|
// Create a new row for each product, but without the productNameCell for additional dishes or drinks
|
||||||
|
const row = document.createElement("tr");
|
||||||
|
|
||||||
|
if (i === 0) {
|
||||||
|
// Create the productNameCell and set the rowSpan attribute
|
||||||
|
const caseNameCell = document.createElement("td");
|
||||||
|
caseNameCell.textContent = caseName;
|
||||||
|
caseNameCell.rowSpan = maxLength; // Set the rowSpan to the maximum length
|
||||||
|
row.appendChild(caseNameCell);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (i < hearings.length) {
|
||||||
|
// Create cells for dishes if available
|
||||||
|
const hearing = hearings[i];
|
||||||
|
const hearingId = hearing.hearingId;
|
||||||
|
const hearingDate = new Date(hearing.Date);
|
||||||
|
|
||||||
|
const hearingNumberCell = document.createElement("td");
|
||||||
|
hearingNumberCell.textContent = hearingId;
|
||||||
|
row.appendChild(hearingNumberCell);
|
||||||
|
|
||||||
|
const hearingDateCell = document.createElement("td");
|
||||||
|
if (hearing.dateCreate === null) {
|
||||||
|
hearingDateCell.textContent = ""
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
hearingDateCell.textContent = formatDate(hearingDate); // Format the date
|
||||||
|
} row.appendChild(hearingDateCell);
|
||||||
|
} else {
|
||||||
|
// Create empty cells for dishes if not available
|
||||||
|
const emptyCell = document.createElement("td");
|
||||||
|
row.appendChild(emptyCell);
|
||||||
|
row.appendChild(emptyCell.cloneNode());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (i < 1) {
|
||||||
|
// Create cells for alcohol drinks if available
|
||||||
|
const specialization = specialization;
|
||||||
|
const specializationId = specialization.specializationId;
|
||||||
|
|
||||||
|
const specializationNumberCell = document.createElement("td");
|
||||||
|
specializationNumberCell.textContent = specializationId;
|
||||||
|
row.appendChild(specializationNumberCell);
|
||||||
|
|
||||||
|
const specializationDateCell = document.createElement("td");
|
||||||
|
console.log(drink.dateCreate === null);
|
||||||
|
|
||||||
|
row.appendChild(specializationDateCell);
|
||||||
|
} else {
|
||||||
|
// Create empty cells for alcohol drinks if not available
|
||||||
|
const emptyCell = document.createElement("td");
|
||||||
|
row.appendChild(emptyCell);
|
||||||
|
row.appendChild(emptyCell.cloneNode());
|
||||||
|
}
|
||||||
|
|
||||||
|
tbody.appendChild(row);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
@ -110,6 +110,15 @@ namespace CaseAccountingDataBaseImplement.Implements
|
|||||||
.Select(x => x.GetViewModel)
|
.Select(x => x.GetViewModel)
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
|
else if (model.DateFrom != null && model.DateTo != null)
|
||||||
|
{
|
||||||
|
return context.Cases
|
||||||
|
.Include(x => x.Specialization)
|
||||||
|
.Include(x => x.User)
|
||||||
|
.Where(x => x.Date >= model.DateFrom && x.Date <= model.DateTo)
|
||||||
|
.Select(x => x.GetViewModel)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return new();
|
return new();
|
||||||
@ -202,5 +211,34 @@ namespace CaseAccountingDataBaseImplement.Implements
|
|||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<HearingViewModel> GetCaseHearing(CaseSearchModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return new();
|
||||||
|
}
|
||||||
|
using var context = new CaseAccountingDatabase();
|
||||||
|
var hearing = context.Hearings.
|
||||||
|
Where(x => x.CaseId == model.Id).
|
||||||
|
Select(x => x.GetViewModel).
|
||||||
|
ToList();
|
||||||
|
return hearing;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public SpecializationViewModel GetCaseSpecialization(SpecializationSearchModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return new();
|
||||||
|
}
|
||||||
|
using var context = new CaseAccountingDatabase();
|
||||||
|
var specialization = context.Specializations.
|
||||||
|
FirstOrDefault(x => x.Id == model.Id)?.
|
||||||
|
GetViewModel;
|
||||||
|
return specialization;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -83,6 +83,15 @@ namespace CaseAccountingDataBaseImplement.Implements
|
|||||||
.Select(x => x.GetViewModel)
|
.Select(x => x.GetViewModel)
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
|
else if (model.DateFrom != null && model.DateTo != null)
|
||||||
|
{
|
||||||
|
return context.Hearings
|
||||||
|
.Include(x => x.Case)
|
||||||
|
.Include(x => x.User)
|
||||||
|
.Where(x => x.Date <= model.DateTo && x.Date >= model.DateFrom)
|
||||||
|
.Select(x => x.GetViewModel)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return new();
|
return new();
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using CaseAccountingContracts.BindingModels;
|
using CaseAccountingContracts.BindingModels;
|
||||||
using CaseAccountingContracts.BusinessLogicContracts;
|
using CaseAccountingContracts.BusinessLogicContracts;
|
||||||
|
using CaseAccountingContracts.ViewModels;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
namespace CaseAccountingRestApi.Controllers
|
namespace CaseAccountingRestApi.Controllers
|
||||||
@ -21,5 +22,19 @@ namespace CaseAccountingRestApi.Controllers
|
|||||||
byte[] file = reportLogic.SaveListFile(listModel);
|
byte[] file = reportLogic.SaveListFile(listModel);
|
||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public List<ReportHearingSpecializationViewModel> GetReportData(ReportBindingModel reportModel)
|
||||||
|
{
|
||||||
|
var list = reportLogic.GetHearingSpecialization(reportModel);
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public void SendByMailStatusReport(ReportBindingModel reportModel)
|
||||||
|
{
|
||||||
|
reportLogic.SendByMailStatusReport(reportModel);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user