Репорты готовые

This commit is contained in:
DyCTaTOR 2024-05-02 17:22:43 +04:00
parent f37916070e
commit 3535087e69
12 changed files with 150 additions and 14 deletions

View File

@ -1,10 +1,11 @@
using AbstractLawFirmContracts.ViewModels; using System.Reflection;
using System.Reflection; using University.ViewModels;
using UniversityBusinessLogics.OfficePackage; using UniversityBusinessLogics.OfficePackage;
using UniversityContracts.BindingModels; using UniversityContracts.BindingModels;
using UniversityContracts.BusinessLogicContracts; using UniversityContracts.BusinessLogicContracts;
using UniversityContracts.SearchModels; using UniversityContracts.SearchModels;
using UniversityContracts.StorageContracts; using UniversityContracts.StorageContracts;
using UniversityContracts.ViewModels;
namespace UniversityBusinessLogics.BusinessLogics; namespace UniversityBusinessLogics.BusinessLogics;
@ -125,10 +126,74 @@ private readonly AbstractSaveToPdf _saveToPdf;*/
return reportDisciplineViewModels; return reportDisciplineViewModels;
} }
public List<ReportPlanOfStudyViewModel> GetPlanOfStudyAndDisciplines()
{
var planOfStudies = _planOfStudyStorage.GetFullList();
var reportPlanOfStudyViewModels = new List<ReportPlanOfStudyViewModel>();
foreach (var planOfStudy in planOfStudies)
{
// Получаем список дисциплин для текущего плана обучения
var disciplines = _planOfStudyStorage.GetDisciplineFromStudentsFromPlanOfStudys(new PlanOfStudySearchModel { Id = planOfStudy.Id });
// Создаем ReportPlanOfStudyViewModel и добавляем его в список
reportPlanOfStudyViewModels.Add(new ReportPlanOfStudyViewModel
{
PlanOfStudyName = planOfStudy.Profile,
Disciplines = disciplines.Select(d => d.Name).ToList() // Получаем только имена дисциплин
});
}
return reportPlanOfStudyViewModels;
}
public List<ReportPlanOfStudyAndStudentViewModel> GetPlanOfStudyAndStudents(ReportDateRangeBindingModel model)
{
var planOfStudies = _planOfStudyStorage.GetFullList();
var reportPlanOfStudyAndStudentViewModels = new List<ReportPlanOfStudyAndStudentViewModel>();
foreach (var planOfStudy in planOfStudies)
{
// Получаем список студентов для текущего плана обучения
var students = _studentStorage.GetFilteredList(new StudentSearchModel { Id = planOfStudy.Id });
var studentsAndDisciplines = new List<(string Student, string Discipline)>();
foreach (var student in students)
{
// Получаем список дисциплин для текущего студента
var disciplines = _disciplineStorage.GetFilteredList(new DisciplineSearchModel { Id = student.Id });
foreach (var discipline in disciplines)
{
studentsAndDisciplines.Add((student.Name, discipline.Name));
}
}
// Создаем ReportPlanOfStudyAndStudentViewModel и добавляем его в список
reportPlanOfStudyAndStudentViewModels.Add(new ReportPlanOfStudyAndStudentViewModel
{
PlanOfStudyName = planOfStudy.Profile,
StudentsAndDisciplines = studentsAndDisciplines
});
}
return reportPlanOfStudyAndStudentViewModels;
}
public void SaveTeachersToExcel(ReportBindingModel option) public void SaveTeachersToExcel(ReportBindingModel option)
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
public void SavePlanOfStudyToExcel(ReportBindingModel option)
{
throw new NotImplementedException();
}
public void SavePlanOfStudyToWord(ReportBindingModel option)
{
throw new NotImplementedException();
}
public void SaveTeachersToWord(ReportBindingModel option) public void SaveTeachersToWord(ReportBindingModel option)
{ {
@ -139,4 +204,9 @@ private readonly AbstractSaveToPdf _saveToPdf;*/
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
public void SendPlanOfStudyToEmail(ReportDateRangeBindingModel option, string email)
{
throw new NotImplementedException();
}
} }

View File

@ -1,9 +1,9 @@
using AbstractLawFirmContracts.ViewModels; using System;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using University.ViewModels;
using UniversityContracts.BindingModels; using UniversityContracts.BindingModels;
namespace UniversityContracts.BusinessLogicContracts namespace UniversityContracts.BusinessLogicContracts

View File

@ -11,5 +11,7 @@ namespace UniversityContracts.SearchModels
public int? Id { get; set; } public int? Id { get; set; }
public int UserId { get; set; } public int UserId { get; set; }
public string? Profile { get; set; } public string? Profile { get; set; }
public DateOnly? DateFrom { get; set; }
public DateOnly? DateTo { get; set; }
} }
} }

View File

@ -17,5 +17,6 @@ namespace UniversityContracts.StorageContracts
PlanOfStudyViewModel? Insert(PlanOfStudyBindingModel model); PlanOfStudyViewModel? Insert(PlanOfStudyBindingModel model);
PlanOfStudyViewModel? Update(PlanOfStudyBindingModel model); PlanOfStudyViewModel? Update(PlanOfStudyBindingModel model);
PlanOfStudyViewModel? Delete(PlanOfStudyBindingModel model); PlanOfStudyViewModel? Delete(PlanOfStudyBindingModel model);
List<DisciplineViewModel> GetDisciplineFromStudentsFromPlanOfStudys(PlanOfStudySearchModel model);
} }
} }

View File

@ -4,7 +4,7 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace AbstractLawFirmContracts.ViewModels namespace University.ViewModels
{ {
public class ReportDisciplineViewModel public class ReportDisciplineViewModel
{ {

View File

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace UniversityContracts.ViewModels
{
public class ReportPlanOfStudyAndStudentViewModel
{
public string PlanOfStudyName { get; set; } = string.Empty;
public List<(string Student, string Discipline)> StudentsAndDisciplines { get; set; } = new();
}
}

View File

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace UniversityContracts.ViewModels
{
public class ReportPlanOfStudyViewModel
{
public string PlanOfStudyName { get; set; } = string.Empty;
public List<string> Disciplines { get; set; } = new();
}
}

View File

@ -4,7 +4,7 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace AbstractLawFirmContracts.ViewModels namespace University.ViewModels
{ {
public class ReportTeacherViewModel public class ReportTeacherViewModel
{ {

View File

@ -21,16 +21,46 @@ namespace UniversityDatabaseImplement.Implements
return context.PlanOfStudys.Select(x => x.GetViewModel).ToList(); return context.PlanOfStudys.Select(x => x.GetViewModel).ToList();
} }
public List<DisciplineViewModel> GetDisciplineFromStudentsFromPlanOfStudys(PlanOfStudySearchModel model)
{
using var context = new UniversityDatabase();
var students = context.Students
.Where(s => s.PlanOfStudyId == model.Id)
.Include(s => s.StudentDiscipline)
.ToList();
if(students == null)
{
return new List<DisciplineViewModel>();
}
// Получаем список дисциплин, которые соответствуют условиям поиска в модели PlanOfStudySearchModel
var disciplines = students
.SelectMany(s => s.StudentDiscipline)
.Distinct()
.ToList();
if (disciplines == null)
{
return new List<DisciplineViewModel>();
}
// Преобразуем список дисциплин в список DisciplineViewModel и возвращаем его
return disciplines
.Select(d => d.Discipline.GetViewModel).ToList();
}
public List<PlanOfStudyViewModel> GetFilteredList(PlanOfStudySearchModel model) public List<PlanOfStudyViewModel> GetFilteredList(PlanOfStudySearchModel model)
{ {
using var context = new UniversityDatabase(); using var context = new UniversityDatabase();
if (model.Id.HasValue) var query = context.PlanOfStudys
{
return context.PlanOfStudys
.Include(x => x.Students) .Include(x => x.Students)
.Where(x => x.Id == model.Id) .Where(x => x.Id == model.Id)
.Select(x => x.GetViewModel) .AsQueryable();
.ToList(); if (model.DateFrom.HasValue && model.DateTo.HasValue)
{
query = query.Where(x => model.DateFrom.Value <= x.Date && x.Date <= model.DateTo.Value);
} }
return new(); return new();
} }

View File

@ -18,6 +18,7 @@ namespace UniversityDatabaseImplement.Models
public int UserId { get; private set; } public int UserId { get; private set; }
[Required] [Required]
public string Profile { get; private set; } = string.Empty; public string Profile { get; private set; } = string.Empty;
public DateOnly Date { get; private set; }
[Required] [Required]
public string FormOfStudy { get; private set; } = string.Empty; public string FormOfStudy { get; private set; } = string.Empty;
private Dictionary<int, ITeacherModel>? _planOfStudyTeachers = null; private Dictionary<int, ITeacherModel>? _planOfStudyTeachers = null;

View File

@ -10,8 +10,8 @@ namespace UniversityDatabaseImplement
{ {
if (optionsBuilder.IsConfigured == false) if (optionsBuilder.IsConfigured == false)
{ {
//Возможно понадобится писать вместо (localdb) название пк, вот пк Егора: DESKTOP-N8BRIPR; other-name: LAPTOP-DYCTATOR //Возможно понадобится писать вместо (localdb) название пк, вот пк Егора: DESKTOP-N8BRIPR; other-name: LAPTOP-DYCTATOR; other-name: DyCTaTOR
optionsBuilder.UseSqlServer(@"Data Source=DESKTOP-N8BRIPR\SQLEXPRESS;Initial Catalog=UniversityDatabaseFull;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True"); optionsBuilder.UseSqlServer(@"Data Source=DyCTaTOR\SQLEXPRESS;Initial Catalog=UniversityDatabaseFull;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
} }
base.OnConfiguring(optionsBuilder); base.OnConfiguring(optionsBuilder);
} }

View File

@ -7,6 +7,10 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.4">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Logging.Log4Net.AspNetCore" Version="6.1.0" /> <PackageReference Include="Microsoft.Extensions.Logging.Log4Net.AspNetCore" Version="6.1.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" /> <PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
</ItemGroup> </ItemGroup>