переписали запрос, не починили

This commit is contained in:
Артём Алейкин 2023-05-23 01:50:02 +04:00
parent 30a3f088f7
commit acf3f56871
8 changed files with 59 additions and 78 deletions

View File

@ -5,6 +5,7 @@ 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;
@ -54,36 +55,25 @@ namespace CaseAccountingBusinessLogic.BusinessLogics
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)
{
foreach (var hearing in _hearingStorage.GetFilteredList(new HearingSearchModel { CaseId = caseModel.Id }))
{
report.Hearings.Add("Номер слушания: " + hearing.Id.ToString());
}
}
list.Add(report);
} }
return reportRecords; return list;
}
public void SaveHearingSpecializationToPdfFile(ReportBindingModel model)
{
throw new NotImplementedException();
}
public void SaveLawyerHearingToExcelFile(ReportBindingModel model)
{
throw new NotImplementedException();
}
public void SaveLawyerHearingToWordFile(ReportBindingModel model)
{
throw new NotImplementedException();
} }
public byte[] SaveListFile(LawyerHearingListBindingModel model) public byte[] SaveListFile(LawyerHearingListBindingModel model)

View File

@ -15,11 +15,5 @@ namespace CaseAccountingContracts.BusinessLogicContracts
List<ReportHearingSpecializationViewModel> GetHearingSpecialization(ReportBindingModel model); List<ReportHearingSpecializationViewModel> GetHearingSpecialization(ReportBindingModel model);
byte[] SaveListFile(LawyerHearingListBindingModel model); byte[] SaveListFile(LawyerHearingListBindingModel model);
void SaveLawyerHearingToWordFile(ReportBindingModel model);
void SaveLawyerHearingToExcelFile(ReportBindingModel model);
void SaveHearingSpecializationToPdfFile(ReportBindingModel model);
} }
} }

View File

@ -18,7 +18,7 @@ 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<CaseViewModel> GetCaseMTM(int lawyerId);
List<SpecializationCasesViewModel>? GetSpecializationCases(); List<SpecializationCasesViewModel>? GetSpecializationCases();
} }
} }

View File

@ -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>

View File

@ -102,14 +102,14 @@ namespace CaseAccountingCustomerView.Controllers
} }
[HttpPost] [HttpPost]
public int[]? SpecializationCaselist([FromBody] LawyerHearingListBindingModel listModel) public int[]? HearingLawyerlist([FromBody] LawyerHearingListBindingModel listModel)
{ {
if (APIUser.User == null) if (APIUser.User == null)
{ {
return Array.Empty<int>(); return Array.Empty<int>();
} }
byte[]? file = APIUser.PostRequestWithResult<LawyerHearingListBindingModel, byte[]> byte[]? file = APIUser.PostRequestWithResult<LawyerHearingListBindingModel, byte[]>
("api/reportprovider/specializationcaselist", listModel); ("api/reportcustomer/lawyerhearinglist", listModel);
return file!.Select(b => (int)b).ToArray(); return file!.Select(b => (int)b).ToArray();
} }

View File

@ -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({
type: "GET", url: `/lawyers/getallbyuser`,
contentType: "json" type: "GET",
}).done((result) => { contentType: "json"
lawyers = result; }).done((result) => {
lawyers.forEach((lawyer) => createRowForLawyersTable(lawyer)); lawyers = result;
}); 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);
} }

View File

@ -171,18 +171,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()

View File

@ -53,7 +53,7 @@ namespace CaseAccountingProviderView.Controllers
return Array.Empty<int>(); return Array.Empty<int>();
} }
byte[]? file = APIUser.PostRequestWithResult<CaseSpecializationListBindingModel, byte[]> byte[]? file = APIUser.PostRequestWithResult<CaseSpecializationListBindingModel, byte[]>
("api/reportcustomer/lawyerhearinglist", listModel); ("api/reportprovider/specializationcaselist", listModel);
return file!.Select(b => (int)b).ToArray(); return file!.Select(b => (int)b).ToArray();
} }