Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
a1a7f49996 | |||
f108c6d8f0 | |||
|
7122302b23 | ||
|
ddcca5e821 | ||
acf3f56871 | |||
30a3f088f7 |
@ -1,10 +1,12 @@
|
|||||||
using CaseAccountingBusinessLogic.OfficePackage;
|
using CaseAccountingBusinessLogic.BusinessLogic.OfficePackage;
|
||||||
|
using CaseAccountingBusinessLogic.OfficePackage;
|
||||||
using CaseAccountingBusinessLogic.OfficePackage.HelperModels;
|
using CaseAccountingBusinessLogic.OfficePackage.HelperModels;
|
||||||
using CaseAccountingContracts.BindingModels;
|
using CaseAccountingContracts.BindingModels;
|
||||||
using CaseAccountingContracts.BusinessLogicContracts;
|
using CaseAccountingContracts.BusinessLogicContracts;
|
||||||
using CaseAccountingContracts.SearchModels;
|
using CaseAccountingContracts.SearchModels;
|
||||||
using CaseAccountingContracts.StoragesContracts;
|
using CaseAccountingContracts.StoragesContracts;
|
||||||
using CaseAccountingContracts.ViewModels;
|
using CaseAccountingContracts.ViewModels;
|
||||||
|
using CaseAccountingDataBaseImplement.Models;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@ -21,9 +23,11 @@ namespace CaseAccountingBusinessLogic.BusinessLogics
|
|||||||
private readonly ISpecializationStorage _specializationStorage;
|
private readonly ISpecializationStorage _specializationStorage;
|
||||||
private readonly WordBuilderCustomer _wordBuilder;
|
private readonly WordBuilderCustomer _wordBuilder;
|
||||||
private readonly ExcelBuilderCustomer _excelBuilder;
|
private readonly ExcelBuilderCustomer _excelBuilder;
|
||||||
|
private readonly PdfBuilderCustomer _pdfBuilder;
|
||||||
|
private readonly MailSender _mailSender;
|
||||||
|
|
||||||
public ReportCustomerLogic(ICaseStorage caseStorage, IHearingStorage hearingStorage, ILawyerStorage lawyerStorage, ISpecializationStorage specializationStorage,
|
public ReportCustomerLogic(ICaseStorage caseStorage, IHearingStorage hearingStorage, ILawyerStorage lawyerStorage, ISpecializationStorage specializationStorage,
|
||||||
WordBuilderCustomer wordBuilder, ExcelBuilderCustomer excelBuilder)
|
WordBuilderCustomer wordBuilder, ExcelBuilderCustomer excelBuilder, PdfBuilderCustomer pdfBuilder, MailSender mailSender)
|
||||||
{
|
{
|
||||||
_caseStorage = caseStorage;
|
_caseStorage = caseStorage;
|
||||||
_hearingStorage = hearingStorage;
|
_hearingStorage = hearingStorage;
|
||||||
@ -31,9 +35,16 @@ namespace CaseAccountingBusinessLogic.BusinessLogics
|
|||||||
_specializationStorage = specializationStorage;
|
_specializationStorage = specializationStorage;
|
||||||
_wordBuilder = wordBuilder;
|
_wordBuilder = wordBuilder;
|
||||||
_excelBuilder = excelBuilder;
|
_excelBuilder = excelBuilder;
|
||||||
|
_pdfBuilder = pdfBuilder ?? throw new ArgumentNullException(nameof(pdfBuilder));
|
||||||
|
_mailSender = mailSender ?? throw new ArgumentNullException(nameof(mailSender));
|
||||||
}
|
}
|
||||||
|
|
||||||
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 })
|
||||||
@ -50,40 +61,29 @@ namespace CaseAccountingBusinessLogic.BusinessLogics
|
|||||||
})
|
})
|
||||||
.ToList();
|
.ToList();
|
||||||
return result;
|
return result;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
public List<ReportLawyerHearingViewModel> GetLawyersHearing(List<LawyerViewModel> lawyers)
|
public List<ReportLawyerHearingViewModel> GetLawyersHearing(List<LawyerViewModel> lawyers)
|
||||||
{
|
{
|
||||||
var reportRecords = new List<ReportLawyerHearingViewModel>();
|
List <ReportLawyerHearingViewModel> list = new();
|
||||||
foreach (var lawyer in lawyers)
|
foreach (var lawyer in lawyers)
|
||||||
{
|
{
|
||||||
var hearings = _lawyerStorage.GetLawyerCases(new() { Id = lawyer.Id })
|
ReportLawyerHearingViewModel report = new ReportLawyerHearingViewModel
|
||||||
.SelectMany(_case => _caseStorage.GetCaseHearings(new() { Id = _case.Id }))
|
|
||||||
.Select(hearing => hearing.Information)
|
|
||||||
.ToList();
|
|
||||||
ReportLawyerHearingViewModel reportRecord = new()
|
|
||||||
{
|
{
|
||||||
Lawyer = lawyer.Name + " " + lawyer.Surname + ", " + lawyer.Patronymic,
|
Lawyer = lawyer.Surname + " " + lawyer.Name + " " + lawyer.Patronymic,
|
||||||
Hearings = hearings
|
Hearings = new()
|
||||||
};
|
};
|
||||||
reportRecords.Add(reportRecord);
|
var cases = _caseStorage.GetCaseMTM(lawyer.Id);
|
||||||
}
|
foreach (var caseModel in cases)
|
||||||
return reportRecords;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SaveHearingSpecializationToPdfFile(ReportBindingModel model)
|
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
foreach (var hearing in _hearingStorage.GetFilteredList(new HearingSearchModel { CaseId = caseModel.Id }))
|
||||||
}
|
|
||||||
|
|
||||||
public void SaveLawyerHearingToExcelFile(ReportBindingModel model)
|
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
report.Hearings.Add("Номер слушания: " + hearing.Id.ToString());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
public void SaveLawyerHearingToWordFile(ReportBindingModel model)
|
list.Add(report);
|
||||||
{
|
}
|
||||||
throw new NotImplementedException();
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte[] SaveListFile(LawyerHearingListBindingModel model)
|
public byte[] SaveListFile(LawyerHearingListBindingModel model)
|
||||||
@ -108,5 +108,67 @@ namespace CaseAccountingBusinessLogic.BusinessLogics
|
|||||||
}
|
}
|
||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void SendByMailStatusReport(ReportBindingModel reportModel)
|
||||||
|
{
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
byte[] file = _pdfBuilder.GetHearingSpecializationReportFile(new()
|
||||||
|
{
|
||||||
|
Title = "Отчет по слушаниям",
|
||||||
|
DateFrom = reportModel.DateFrom,
|
||||||
|
DateTo = reportModel.DateTo,
|
||||||
|
Records = GetHearingSpecialization(reportModel)
|
||||||
|
});
|
||||||
|
_mailSender.SendMailAsync(new()
|
||||||
|
{
|
||||||
|
MailAddress = reportModel.UserEmail,
|
||||||
|
Subject = "Отчет по слушаниям",
|
||||||
|
Text = $"За период с {reportModel.DateFrom.ToShortDateString()} " +
|
||||||
|
$"по {reportModel.DateTo.ToShortDateString()}.",
|
||||||
|
File = file
|
||||||
|
});
|
||||||
|
}*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,187 @@
|
|||||||
|
using CaseAccountingBusinessLogic.OfficePackage.HelperEnums;
|
||||||
|
using CaseAccountingBusinessLogic.OfficePackage.HelperModels;
|
||||||
|
using CaseAccountingContracts.ViewModels;
|
||||||
|
using MigraDoc.DocumentObjectModel;
|
||||||
|
using MigraDoc.Rendering;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using MigraDoc.DocumentObjectModel.Tables;
|
||||||
|
|
||||||
|
namespace CaseAccountingBusinessLogic.OfficePackage
|
||||||
|
{
|
||||||
|
public class PdfBuilderCustomer
|
||||||
|
{
|
||||||
|
private readonly string tempFileName = "temp.pdf";
|
||||||
|
private Document? document;
|
||||||
|
private Section? section;
|
||||||
|
private Table? table;
|
||||||
|
|
||||||
|
private static ParagraphAlignment GetParagraphAlignment(PdfParagraphAlignmentType type)
|
||||||
|
{
|
||||||
|
return type switch
|
||||||
|
{
|
||||||
|
PdfParagraphAlignmentType.Center => ParagraphAlignment.Center,
|
||||||
|
PdfParagraphAlignmentType.Left => ParagraphAlignment.Left,
|
||||||
|
_ => ParagraphAlignment.Justify,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DefineStyles(Document document)
|
||||||
|
{
|
||||||
|
var style = document.Styles["Normal"];
|
||||||
|
style.Font.Name = "Times New Roman";
|
||||||
|
style.Font.Size = 14;
|
||||||
|
|
||||||
|
style = document.Styles.AddStyle("NormalTitle", "Normal");
|
||||||
|
style.Font.Bold = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CreateDocument()
|
||||||
|
{
|
||||||
|
document = new Document();
|
||||||
|
DefineStyles(document);
|
||||||
|
section = document.AddSection();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CreateParagraph(PdfParagraph pdfParagraph)
|
||||||
|
{
|
||||||
|
if (section == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var paragraph = section.AddParagraph(pdfParagraph.Text);
|
||||||
|
paragraph.Format.SpaceAfter = "1cm";
|
||||||
|
paragraph.Format.Alignment = GetParagraphAlignment(pdfParagraph.ParagraphAlignment);
|
||||||
|
paragraph.Style = pdfParagraph.Style;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CreateTable(List<string> columns)
|
||||||
|
{
|
||||||
|
if (document == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
table = document.LastSection.AddTable();
|
||||||
|
foreach (var elem in columns)
|
||||||
|
{
|
||||||
|
table.AddColumn(elem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CreateRow(PdfRowParameters rowParameters)
|
||||||
|
{
|
||||||
|
if (table == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var row = table.AddRow();
|
||||||
|
for (int i = 0; i < rowParameters.Texts.Count; ++i)
|
||||||
|
{
|
||||||
|
row.Cells[i].AddParagraph(rowParameters.Texts[i]);
|
||||||
|
if (!string.IsNullOrEmpty(rowParameters.Style))
|
||||||
|
{
|
||||||
|
row.Cells[i].Style = rowParameters.Style;
|
||||||
|
}
|
||||||
|
Unit borderWidth = 0.5;
|
||||||
|
row.Cells[i].Borders.Left.Width = borderWidth;
|
||||||
|
row.Cells[i].Borders.Right.Width = borderWidth;
|
||||||
|
row.Cells[i].Borders.Top.Width = borderWidth;
|
||||||
|
row.Cells[i].Borders.Bottom.Width = borderWidth;
|
||||||
|
row.Cells[i].Format.Alignment = GetParagraphAlignment(rowParameters.ParagraphAlignment);
|
||||||
|
row.Cells[i].VerticalAlignment = VerticalAlignment.Center;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Save()
|
||||||
|
{
|
||||||
|
|
||||||
|
// Регистрация провайдера кодировки для кодировки 1252, без этого ошибОчка была
|
||||||
|
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
|
||||||
|
|
||||||
|
var renderer = new PdfDocumentRenderer(true)
|
||||||
|
{
|
||||||
|
Document = document
|
||||||
|
};
|
||||||
|
renderer.RenderDocument();
|
||||||
|
renderer.PdfDocument.Save(tempFileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte[] GetFile()
|
||||||
|
{
|
||||||
|
Save();
|
||||||
|
byte[] file = File.ReadAllBytes(tempFileName);
|
||||||
|
File.Delete(tempFileName);
|
||||||
|
return file;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*public byte[] GetHearingSpecializationReportFile(PdfData<ReportHearingSpecializationViewModel> data)
|
||||||
|
{
|
||||||
|
CreateDocument();
|
||||||
|
|
||||||
|
CreateParagraph(new PdfParagraph
|
||||||
|
{
|
||||||
|
Text = data.Title,
|
||||||
|
Style = "NormalTitle",
|
||||||
|
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
||||||
|
});
|
||||||
|
|
||||||
|
CreateParagraph(new PdfParagraph
|
||||||
|
{
|
||||||
|
Text = $"за период с {data.DateFrom.ToShortDateString()} " +
|
||||||
|
$"по {data.DateTo.ToShortDateString()}",
|
||||||
|
Style = "Normal",
|
||||||
|
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
||||||
|
});
|
||||||
|
|
||||||
|
CreateTable(new List<string> { "4cm", "2cm", "4cm", "2cm", "4cm" });
|
||||||
|
|
||||||
|
CreateRow(new PdfRowParameters
|
||||||
|
{
|
||||||
|
Texts = new List<string> { "Продукт", "Блюдо", "Дата заказа", "Напиток", "Дата заказа" },
|
||||||
|
Style = "NormalTitle",
|
||||||
|
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
||||||
|
});
|
||||||
|
|
||||||
|
foreach (var record in data.Records)
|
||||||
|
{
|
||||||
|
List<HearingViewModel> hearings = record.hearings;
|
||||||
|
string specialization = record.Specialization;
|
||||||
|
int recordHeight = Math.Max(hearings.Count + 1, 1);
|
||||||
|
for (int i = 0; i < recordHeight; i++)
|
||||||
|
{
|
||||||
|
List<string> cellsData = new() { "", "", "", "", "" };
|
||||||
|
if (i == 0)
|
||||||
|
{
|
||||||
|
cellsData[0] = record.Information;
|
||||||
|
CreateRow(new PdfRowParameters
|
||||||
|
{
|
||||||
|
Texts = cellsData,
|
||||||
|
Style = "Normal",
|
||||||
|
ParagraphAlignment = PdfParagraphAlignmentType.Left
|
||||||
|
});
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
int k = i - 1;
|
||||||
|
if (k < hearings.Count)
|
||||||
|
{
|
||||||
|
cellsData[1] = hearings[k].Id.ToString();
|
||||||
|
cellsData[2] = hearings[k].Date.ToString();
|
||||||
|
}
|
||||||
|
cellsData[3] = specialization;
|
||||||
|
|
||||||
|
CreateRow(new PdfRowParameters
|
||||||
|
{
|
||||||
|
Texts = cellsData,
|
||||||
|
Style = "Normal",
|
||||||
|
ParagraphAlignment = PdfParagraphAlignmentType.Left
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return GetFile();
|
||||||
|
}*/
|
||||||
|
}
|
||||||
|
}
|
@ -16,10 +16,6 @@ namespace CaseAccountingContracts.BusinessLogicContracts
|
|||||||
|
|
||||||
byte[] SaveListFile(LawyerHearingListBindingModel model);
|
byte[] SaveListFile(LawyerHearingListBindingModel model);
|
||||||
|
|
||||||
void SaveLawyerHearingToWordFile(ReportBindingModel model);
|
void SendByMailStatusReport(ReportBindingModel reportModel);
|
||||||
|
|
||||||
void SaveLawyerHearingToExcelFile(ReportBindingModel model);
|
|
||||||
|
|
||||||
void SaveHearingSpecializationToPdfFile(ReportBindingModel model);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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,7 +18,11 @@ namespace CaseAccountingContracts.StoragesContracts
|
|||||||
CaseViewModel? Update(CaseBindingModel model);
|
CaseViewModel? Update(CaseBindingModel model);
|
||||||
CaseViewModel? Delete(CaseBindingModel model);
|
CaseViewModel? Delete(CaseBindingModel model);
|
||||||
|
|
||||||
List<HearingViewModel> GetCaseHearings(CaseSearchModel model);
|
List<HearingViewModel> GetCaseHearing(CaseSearchModel model);
|
||||||
|
|
||||||
|
SpecializationViewModel GetCaseSpecialization(SpecializationSearchModel model);
|
||||||
|
|
||||||
|
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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,10 @@
|
|||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Content Remove="wwwroot\js\Report\reportlist.js~RF3ae78116.TMP" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
@ -102,7 +102,7 @@ namespace CaseAccountingCustomerView.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public int[]? HearingLawyerList([FromBody] LawyerHearingListBindingModel listModel)
|
public int[]? HearingLawyerlist([FromBody] LawyerHearingListBindingModel listModel)
|
||||||
{
|
{
|
||||||
if (APIUser.User == null)
|
if (APIUser.User == null)
|
||||||
{
|
{
|
||||||
@ -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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -0,0 +1,55 @@
|
|||||||
|
@{
|
||||||
|
ViewData["Title"] = "Отчет";
|
||||||
|
}
|
||||||
|
|
||||||
|
<div class="text-center">
|
||||||
|
<h1 class="display-4">Отчет по слушаниям</h1>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="error-div-shell" class="error-div-shell mb-2">
|
||||||
|
<div>
|
||||||
|
<p id="error-p" class="error-p"></p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="d-flex flex-wrap gap-1 align-items-end mb-2">
|
||||||
|
<div class="mb-2">
|
||||||
|
<p class="mb-0">Дата начала:</p>
|
||||||
|
<input id="date-from-input" class="form-control" type="date" />
|
||||||
|
</div>
|
||||||
|
<div class="mb-2">
|
||||||
|
<p class="mb-0">Дата конца:</p>
|
||||||
|
<input id="date-to-input" class="form-control" type="date" />
|
||||||
|
</div>
|
||||||
|
<button id="generate-button" class="btn btn-primary mb-2">
|
||||||
|
Показать
|
||||||
|
</button>
|
||||||
|
<button id="send-by-mail-button" class="btn btn-primary mb-2">
|
||||||
|
На почту
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<p class="mb-0">
|
||||||
|
<span>За период с </span>
|
||||||
|
<span id="date-from-span" class="fw-bold">...</span>
|
||||||
|
<span> по </span>
|
||||||
|
<span id="date-to-span" class="fw-bold">...</span>
|
||||||
|
</p>
|
||||||
|
<div class="table-shell mb-2 border">
|
||||||
|
<table class="table mb-0">
|
||||||
|
<thead class="table-head">
|
||||||
|
<tr>
|
||||||
|
<th>Номер слушания</th>
|
||||||
|
<th>Дело</th>
|
||||||
|
<th>Дата проведения</th>
|
||||||
|
<th>Специализация</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody id="tbody">
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="table"></div>
|
||||||
|
|
||||||
|
<script src="~/js/Report/reportpdf.js" asp-append-version="true"></script>
|
@ -7,15 +7,31 @@ var dataArray = [];
|
|||||||
const wordMIME = "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
|
const wordMIME = "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
|
||||||
const excelMIME = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
|
const excelMIME = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
|
||||||
|
|
||||||
window.addEventListener('load', () => {
|
window.addEventListener('load', async () => {
|
||||||
$.ajax({
|
try {
|
||||||
url: "/lawyers/getallbyuser",
|
await $.ajax({
|
||||||
|
url: `/lawyers/getallbyuser`,
|
||||||
type: "GET",
|
type: "GET",
|
||||||
contentType: "json"
|
contentType: "json"
|
||||||
}).done((result) => {
|
}).done((result) => {
|
||||||
lawyers = result;
|
lawyers = result;
|
||||||
lawyers.forEach((lawyer) => createRowForLawyersTable(lawyer));
|
lawyers.forEach((lawyerModel) => {
|
||||||
|
const { id, name, surname, patronymic, experience, specialization } = lawyerModel;
|
||||||
|
const row = tbody.insertRow();
|
||||||
|
row.setAttribute("data-id", id);
|
||||||
|
|
||||||
|
const cells = [name, surname, patronymic, experience, specialization];
|
||||||
|
cells.forEach((value) => {
|
||||||
|
const cell = row.insertCell();
|
||||||
|
cell.textContent = value;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
row.addEventListener('click', () => addAndRemoveFromList(row));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
createBtn.addEventListener('click', () => {
|
createBtn.addEventListener('click', () => {
|
||||||
@ -23,7 +39,6 @@ createBtn.addEventListener('click', () => {
|
|||||||
"Lawyers": Array.from(dataArray),
|
"Lawyers": Array.from(dataArray),
|
||||||
"FileType": fileType.value
|
"FileType": fileType.value
|
||||||
};
|
};
|
||||||
console.log(listModel);
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: "/home/hearinglawyerlist",
|
url: "/home/hearinglawyerlist",
|
||||||
type: "POST",
|
type: "POST",
|
||||||
@ -61,38 +76,16 @@ const saveFile = async function (bytes, fileType) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const createRowForLawyersTable = (lawyer) => {
|
|
||||||
const { id, name, surname, patronymic, experience, specialization } = lawyer;
|
|
||||||
const row = tbody.insertRow();
|
|
||||||
row.setAttribute("data-id", id);
|
|
||||||
|
|
||||||
const cells = [name, surname, patronymic, experience, specialization ];
|
|
||||||
cells.forEach((value) => {
|
|
||||||
const cell = row.insertCell();
|
|
||||||
cell.textContent = value;
|
|
||||||
});
|
|
||||||
|
|
||||||
row.addEventListener('click', () => addAndRemoveFromList(row));
|
|
||||||
};
|
|
||||||
|
|
||||||
const formatDate = (dateString) => {
|
|
||||||
const date = new Date(dateString);
|
|
||||||
const year = date.getFullYear();
|
|
||||||
const month = ('0' + (date.getMonth() + 1)).slice(-2);
|
|
||||||
const day = ('0' + date.getDate()).slice(-2);
|
|
||||||
return `${year}-${month}-${day}`;
|
|
||||||
};
|
|
||||||
|
|
||||||
const addAndRemoveFromList = (row) => {
|
const addAndRemoveFromList = (row) => {
|
||||||
var id = parseInt(row.dataset.id);
|
var id = parseInt(row.dataset.id);
|
||||||
console.log(lawyers.find(x => x.id === id))
|
console.log(lawyers.find(x => x.id === id))
|
||||||
var index = dataArray.indexOf(lawyers.find(x => x.id === id));
|
var index = dataArray.indexOf(lawyers.find(x => x.id === id));
|
||||||
if (index === -1) {
|
if (index === -1) {
|
||||||
dataArray.push(lawyers.find(x => x.id === id));
|
dataArray.push(lawyers.find(x => x.id === id));
|
||||||
row.classList.add("bg-success");
|
row.classList.add("bg-info");
|
||||||
} else {
|
} else {
|
||||||
dataArray.splice(index, 1);
|
dataArray.splice(index, 1);
|
||||||
row.classList.remove("bg-success");
|
row.classList.remove("bg-info");
|
||||||
}
|
}
|
||||||
console.log(dataArray);
|
console.log(dataArray);
|
||||||
}
|
}
|
@ -0,0 +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);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
@ -18,8 +18,8 @@ namespace CaseAccountingDataBaseImplement
|
|||||||
Host=localhost;
|
Host=localhost;
|
||||||
Port=5432;
|
Port=5432;
|
||||||
Database=CaseAccountingDatabase;
|
Database=CaseAccountingDatabase;
|
||||||
Username=courseuser;
|
Username=postgres;
|
||||||
Password=courseuser");
|
Password=postgres");
|
||||||
}
|
}
|
||||||
base.OnConfiguring(optionsBuilder);
|
base.OnConfiguring(optionsBuilder);
|
||||||
}
|
}
|
||||||
|
@ -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();
|
||||||
@ -171,18 +180,18 @@ namespace CaseAccountingDataBaseImplement.Implements
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<HearingViewModel> GetCaseHearings(CaseSearchModel model)
|
public List<CaseViewModel> GetCaseMTM(int lawyerId)
|
||||||
{
|
{
|
||||||
if (model == null)
|
|
||||||
{
|
|
||||||
return new();
|
|
||||||
}
|
|
||||||
using var context = new CaseAccountingDatabase();
|
using var context = new CaseAccountingDatabase();
|
||||||
var hearings = context.Hearings
|
var lawyersId = context.CaseLawyers
|
||||||
.Where(x => x.CaseId == model.Id)
|
.Where(x => x.LawyerId == lawyerId)
|
||||||
|
.Select(x => x.CaseId).ToList();
|
||||||
|
return context.Cases
|
||||||
|
.Include(x => x.Specialization)
|
||||||
|
.Include(x => x.User)
|
||||||
|
.Where(X => lawyersId.Contains(X.Id))
|
||||||
.Select(x => x.GetViewModel)
|
.Select(x => x.GetViewModel)
|
||||||
.ToList();
|
.ToList();
|
||||||
return hearings;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<SpecializationCasesViewModel>? GetSpecializationCases()
|
public List<SpecializationCasesViewModel>? GetSpecializationCases()
|
||||||
@ -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,25 +0,0 @@
|
|||||||
using CaseAccountingContracts.BindingModels;
|
|
||||||
using CaseAccountingContracts.BusinessLogicContracts;
|
|
||||||
using Microsoft.AspNetCore.Mvc;
|
|
||||||
|
|
||||||
namespace CaseAccountingRestApi.Controllers
|
|
||||||
{
|
|
||||||
[Route("api/[controller]/[action]")]
|
|
||||||
[ApiController]
|
|
||||||
public class ReportCustomerController : Controller
|
|
||||||
{
|
|
||||||
private readonly IReportCustomerLogic _reportCustomerLogic;
|
|
||||||
|
|
||||||
public ReportCustomerController(IReportCustomerLogic reportLogic)
|
|
||||||
{
|
|
||||||
_reportCustomerLogic = reportLogic;
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpPost]
|
|
||||||
public byte[] LawyerHearingList(LawyerHearingListBindingModel listModel)
|
|
||||||
{
|
|
||||||
byte[] file = _reportCustomerLogic.SaveListFile(listModel);
|
|
||||||
return file;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,40 @@
|
|||||||
|
using CaseAccountingContracts.BindingModels;
|
||||||
|
using CaseAccountingContracts.BusinessLogicContracts;
|
||||||
|
using CaseAccountingContracts.ViewModels;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
|
namespace CaseAccountingRestApi.Controllers
|
||||||
|
{
|
||||||
|
[Route("api/[controller]/[action]")]
|
||||||
|
[ApiController]
|
||||||
|
public class ReportCustomerController : Controller
|
||||||
|
{
|
||||||
|
private readonly IReportCustomerLogic reportLogic;
|
||||||
|
|
||||||
|
public ReportCustomerController(IReportCustomerLogic reportLogic)
|
||||||
|
{
|
||||||
|
this.reportLogic = reportLogic;
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public byte[] LawyerHearinglist(LawyerHearingListBindingModel listModel)
|
||||||
|
{
|
||||||
|
byte[] file = reportLogic.SaveListFile(listModel);
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,7 @@
|
|||||||
using CaseAccountingBusinessLogic.BusinessLogic.OfficePackage;
|
using CaseAccountingBusinessLogic.BusinessLogic.OfficePackage;
|
||||||
using CaseAccountingBusinessLogic.BusinessLogics;
|
using CaseAccountingBusinessLogic.BusinessLogics;
|
||||||
using CaseAccountingBusinessLogic.OfficePackage;
|
using CaseAccountingBusinessLogic.OfficePackage;
|
||||||
|
using CaseAccountingBusinessLogic.OfficePackage.HelperModels;
|
||||||
using CaseAccountingContracts.BindingModels;
|
using CaseAccountingContracts.BindingModels;
|
||||||
using CaseAccountingContracts.BusinessLogicContracts;
|
using CaseAccountingContracts.BusinessLogicContracts;
|
||||||
using CaseAccountingContracts.StoragesContracts;
|
using CaseAccountingContracts.StoragesContracts;
|
||||||
@ -30,6 +31,11 @@ builder.Services.AddTransient<ISpecializationLogic, SpecializationLogic>();
|
|||||||
builder.Services.AddTransient<IUserLogic, UserLogic>();
|
builder.Services.AddTransient<IUserLogic, UserLogic>();
|
||||||
|
|
||||||
builder.Services.AddTransient<IReportProviderLogic, ReportProviderLogic>();
|
builder.Services.AddTransient<IReportProviderLogic, ReportProviderLogic>();
|
||||||
|
builder.Services.AddTransient<IReportCustomerLogic, ReportCustomerLogic>();
|
||||||
|
|
||||||
|
builder.Services.AddTransient<WordBuilderCustomer>();
|
||||||
|
builder.Services.AddTransient<ExcelBuilderCustomer>();
|
||||||
|
builder.Services.AddTransient<PdfBuilderCustomer>();
|
||||||
|
|
||||||
builder.Services.AddTransient<WordBuilderProvider>();
|
builder.Services.AddTransient<WordBuilderProvider>();
|
||||||
builder.Services.AddTransient<ExcelBuilderProvider>();
|
builder.Services.AddTransient<ExcelBuilderProvider>();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user