Лабораторная работа №4
This commit is contained in:
parent
6586b6c085
commit
4bec98204d
@ -1,4 +1,5 @@
|
|||||||
using ProjectSchedule.Entities.Enums;
|
using ProjectSchedule.Entities.Enums;
|
||||||
|
using System.ComponentModel;
|
||||||
|
|
||||||
namespace ProjectSchedule.Entities;
|
namespace ProjectSchedule.Entities;
|
||||||
|
|
||||||
@ -6,10 +7,13 @@ public class Audience
|
|||||||
{
|
{
|
||||||
public int Id { get; private set; }
|
public int Id { get; private set; }
|
||||||
|
|
||||||
|
[DisplayName("Номер аудитории")]
|
||||||
public string NumberAudience { get; private set; } = string.Empty;
|
public string NumberAudience { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
[DisplayName("Тип аудитории")]
|
||||||
public TypeAudience TypeAudience { get; private set; }
|
public TypeAudience TypeAudience { get; private set; }
|
||||||
|
|
||||||
|
[DisplayName("Количество мест")]
|
||||||
public int QuantitySeats { get; private set; }
|
public int QuantitySeats { get; private set; }
|
||||||
|
|
||||||
public static Audience CreateEntity(int id, string numberAudience, TypeAudience typeAudience, int quantitySeats)
|
public static Audience CreateEntity(int id, string numberAudience, TypeAudience typeAudience, int quantitySeats)
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using ProjectSchedule.Entities.Enums;
|
using ProjectSchedule.Entities.Enums;
|
||||||
|
using System.ComponentModel;
|
||||||
|
|
||||||
namespace ProjectSchedule.Entities;
|
namespace ProjectSchedule.Entities;
|
||||||
|
|
||||||
@ -6,22 +7,43 @@ public class CompilingSchedule
|
|||||||
{
|
{
|
||||||
public int Id { get; private set; }
|
public int Id { get; private set; }
|
||||||
|
|
||||||
|
[Browsable(false)]
|
||||||
public int EducatorId { get; private set; }
|
public int EducatorId { get; private set; }
|
||||||
|
|
||||||
|
[Browsable(false)]
|
||||||
public int DisciplineId { get; private set; }
|
public int DisciplineId { get; private set; }
|
||||||
|
|
||||||
|
[Browsable(false)]
|
||||||
public int GroupStudentsId { get; private set; }
|
public int GroupStudentsId { get; private set; }
|
||||||
|
|
||||||
|
[Browsable(false)]
|
||||||
public int AudienceId { get; private set; }
|
public int AudienceId { get; private set; }
|
||||||
|
|
||||||
|
[DisplayName("Преподаватель")]
|
||||||
|
public string EducatorName { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
[DisplayName("Название дисциплины")]
|
||||||
|
public string NameDiscipline { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
[DisplayName("Группа студентов")]
|
||||||
|
public string NameGroup { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
[DisplayName("Номер аудитории")]
|
||||||
|
public string NumberAudience { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
[DisplayName("Дата дня")]
|
||||||
public DateTime DateDay { get; private set; }
|
public DateTime DateDay { get; private set; }
|
||||||
|
|
||||||
|
[DisplayName("Номер недели")]
|
||||||
public TypeWeek TypeWeek { get; private set; }
|
public TypeWeek TypeWeek { get; private set; }
|
||||||
|
|
||||||
|
[DisplayName("Номер дня")]
|
||||||
public int NumberDay { get; private set; }
|
public int NumberDay { get; private set; }
|
||||||
|
|
||||||
|
[DisplayName("Номер пары")]
|
||||||
public int NumberPair { get; private set; }
|
public int NumberPair { get; private set; }
|
||||||
|
|
||||||
|
[DisplayName("Тип занятия")]
|
||||||
public TypeActivity TypeActivity { get; private set; }
|
public TypeActivity TypeActivity { get; private set; }
|
||||||
|
|
||||||
public static CompilingSchedule CreateOperation(int id, int educatorId, int disciplineId, int groupStudentsId, int audienceId,
|
public static CompilingSchedule CreateOperation(int id, int educatorId, int disciplineId, int groupStudentsId, int audienceId,
|
||||||
|
@ -1,17 +1,32 @@
|
|||||||
namespace ProjectSchedule.Entities;
|
using System.ComponentModel;
|
||||||
|
|
||||||
|
namespace ProjectSchedule.Entities;
|
||||||
|
|
||||||
public class CurriculumSupplement
|
public class CurriculumSupplement
|
||||||
{
|
{
|
||||||
public int Id { get; private set; }
|
public int Id { get; private set; }
|
||||||
|
|
||||||
|
[Browsable(false)]
|
||||||
public int GroupStudentsId { get; private set; }
|
public int GroupStudentsId { get; private set; }
|
||||||
|
|
||||||
|
[DisplayName("Группа студентов")]
|
||||||
|
public string NameGroup { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
[DisplayName("Название учебного плана")]
|
||||||
public string NameCurriculum { get; private set; } = string.Empty;
|
public string NameCurriculum { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
[DisplayName("Семестр")]
|
||||||
public string Semester { get; private set; } = string.Empty;
|
public string Semester { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
[DisplayName("Дата принятия плана")]
|
||||||
public DateTime DateAdoptionPlan { get; private set; }
|
public DateTime DateAdoptionPlan { get; private set; }
|
||||||
|
|
||||||
|
[DisplayName("Дисциплины")]
|
||||||
|
public string Discipline => DisciplineCurriculumSupplements != null ?
|
||||||
|
string.Join(", ", DisciplineCurriculumSupplements.Select(x => $"{x.NameDiscipline} {x.QuantityLectures} {x.QuantityPractices}")) :
|
||||||
|
string.Empty;
|
||||||
|
|
||||||
|
[Browsable(false)]
|
||||||
public IEnumerable<DisciplineCurriculumSupplement> DisciplineCurriculumSupplements { get; private set; } = [];
|
public IEnumerable<DisciplineCurriculumSupplement> DisciplineCurriculumSupplements { get; private set; } = [];
|
||||||
|
|
||||||
public static CurriculumSupplement CreateOperation(int id, int groupStudentsId, string nameCurriculum,
|
public static CurriculumSupplement CreateOperation(int id, int groupStudentsId, string nameCurriculum,
|
||||||
@ -28,17 +43,11 @@ public class CurriculumSupplement
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public static CurriculumSupplement CreateOpeartion(TempDisciplineCurriculumSupplement tempDisciplineCurriculumSupplement,
|
public void SetDisciplineCurriculumSupplements(IEnumerable<DisciplineCurriculumSupplement> disciplineCurriculumSupplements)
|
||||||
IEnumerable<DisciplineCurriculumSupplement> disciplineCurriculumSupplements)
|
|
||||||
{
|
{
|
||||||
return new CurriculumSupplement
|
if (disciplineCurriculumSupplements != null && disciplineCurriculumSupplements.Any())
|
||||||
{
|
{
|
||||||
Id = tempDisciplineCurriculumSupplement.Id,
|
DisciplineCurriculumSupplements = disciplineCurriculumSupplements;
|
||||||
GroupStudentsId = tempDisciplineCurriculumSupplement.GroupStudentsId,
|
}
|
||||||
NameCurriculum = tempDisciplineCurriculumSupplement.NameCurriculum,
|
|
||||||
Semester = tempDisciplineCurriculumSupplement.Semester,
|
|
||||||
DateAdoptionPlan = tempDisciplineCurriculumSupplement.DateAdoptionPlan,
|
|
||||||
DisciplineCurriculumSupplements = disciplineCurriculumSupplements
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,9 +1,12 @@
|
|||||||
namespace ProjectSchedule.Entities;
|
using System.ComponentModel;
|
||||||
|
|
||||||
|
namespace ProjectSchedule.Entities;
|
||||||
|
|
||||||
public class Discipline
|
public class Discipline
|
||||||
{
|
{
|
||||||
public int Id { get; private set; }
|
public int Id { get; private set; }
|
||||||
|
|
||||||
|
[DisplayName("Название дисциплины")]
|
||||||
public string NameDiscipline { get; private set; } = string.Empty;
|
public string NameDiscipline { get; private set; } = string.Empty;
|
||||||
|
|
||||||
public static Discipline CreateEntity(int id, string nameDiscipline)
|
public static Discipline CreateEntity(int id, string nameDiscipline)
|
||||||
|
@ -6,6 +6,8 @@ public class DisciplineCurriculumSupplement
|
|||||||
|
|
||||||
public int DisciplineId { get; private set; }
|
public int DisciplineId { get; private set; }
|
||||||
|
|
||||||
|
public string NameDiscipline { get; private set; } = string.Empty;
|
||||||
|
|
||||||
public int QuantityLectures { get; private set; }
|
public int QuantityLectures { get; private set; }
|
||||||
|
|
||||||
public int QuantityPractices { get; private set; }
|
public int QuantityPractices { get; private set; }
|
||||||
|
@ -1,15 +1,22 @@
|
|||||||
namespace ProjectSchedule.Entities;
|
using System.ComponentModel;
|
||||||
|
|
||||||
|
namespace ProjectSchedule.Entities;
|
||||||
|
|
||||||
public class Educator
|
public class Educator
|
||||||
{
|
{
|
||||||
public int Id { get; private set; }
|
public int Id { get; private set; }
|
||||||
|
|
||||||
|
[DisplayName("Фамилия")]
|
||||||
public string Surname { get; private set; } = string.Empty;
|
public string Surname { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
[DisplayName("Имя")]
|
||||||
public string Name { get; private set; } = string.Empty;
|
public string Name { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
[DisplayName("Отчество")]
|
||||||
public string Patronymic { get; private set; } = string.Empty;
|
public string Patronymic { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
public string FullName => $"{Surname} {Name} {Patronymic}";
|
||||||
|
|
||||||
public static Educator CreateEntity(int id, string surname, string name, string patronymic)
|
public static Educator CreateEntity(int id, string surname, string name, string patronymic)
|
||||||
{
|
{
|
||||||
return new Educator
|
return new Educator
|
||||||
|
@ -1,13 +1,20 @@
|
|||||||
namespace ProjectSchedule.Entities;
|
using System.ComponentModel;
|
||||||
|
|
||||||
|
namespace ProjectSchedule.Entities;
|
||||||
|
|
||||||
public class GroupStudents
|
public class GroupStudents
|
||||||
{
|
{
|
||||||
public int Id { get; private set; }
|
public int Id { get; private set; }
|
||||||
|
|
||||||
|
[DisplayName("Аббревиатура группы")]
|
||||||
public string AbbreviationGroup { get; private set; } = string.Empty;
|
public string AbbreviationGroup { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
[DisplayName("Номер группы")]
|
||||||
public string GroupNumber { get; private set; } = string.Empty;
|
public string GroupNumber { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
public string NameGroup => $"{AbbreviationGroup}-{GroupNumber}";
|
||||||
|
|
||||||
|
[DisplayName("Количество студентов")]
|
||||||
public int QuantityStudents { get; private set; }
|
public int QuantityStudents { get; private set; }
|
||||||
|
|
||||||
public static GroupStudents CreateEntity(int id, string abbreviationGroup, string groupNumber, int quantityStudents)
|
public static GroupStudents CreateEntity(int id, string abbreviationGroup, string groupNumber, int quantityStudents)
|
||||||
|
@ -1,20 +0,0 @@
|
|||||||
namespace ProjectSchedule.Entities;
|
|
||||||
|
|
||||||
public class TempDisciplineCurriculumSupplement
|
|
||||||
{
|
|
||||||
public int Id { get; private set; }
|
|
||||||
|
|
||||||
public int GroupStudentsId { get; private set; }
|
|
||||||
|
|
||||||
public string NameCurriculum { get; private set; } = string.Empty;
|
|
||||||
|
|
||||||
public string Semester { get; private set; } = string.Empty;
|
|
||||||
|
|
||||||
public DateTime DateAdoptionPlan { get; private set; }
|
|
||||||
|
|
||||||
public int DisciplineId { get; private set; }
|
|
||||||
|
|
||||||
public int QuantityLectures { get; private set; }
|
|
||||||
|
|
||||||
public int QuantityPractices { get; private set; }
|
|
||||||
}
|
|
@ -86,7 +86,11 @@ namespace ProjectSchedule.Forms
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LoadList() => dataGridViewData.DataSource = _audienceRepository.ReadAudiences();
|
private void LoadList()
|
||||||
|
{
|
||||||
|
dataGridViewData.DataSource = _audienceRepository.ReadAudiences();
|
||||||
|
dataGridViewData.Columns["Id"].Visible = false;
|
||||||
|
}
|
||||||
|
|
||||||
private bool TryGetIdentifierFromSelectedRow(out int id)
|
private bool TryGetIdentifierFromSelectedRow(out int id)
|
||||||
{
|
{
|
||||||
|
@ -17,7 +17,7 @@ namespace ProjectSchedule.Forms
|
|||||||
throw new ArgumentNullException(nameof(сompilingScheduleRepository));
|
throw new ArgumentNullException(nameof(сompilingScheduleRepository));
|
||||||
|
|
||||||
comboBoxEducator.DataSource = educatorRepository.ReadEducators();
|
comboBoxEducator.DataSource = educatorRepository.ReadEducators();
|
||||||
comboBoxEducator.DisplayMember = "Surname";
|
comboBoxEducator.DisplayMember = "FullName";
|
||||||
comboBoxEducator.ValueMember = "Id";
|
comboBoxEducator.ValueMember = "Id";
|
||||||
|
|
||||||
comboBoxDiscipline.DataSource = disciplineRepository.ReadDisciplines();
|
comboBoxDiscipline.DataSource = disciplineRepository.ReadDisciplines();
|
||||||
@ -25,7 +25,7 @@ namespace ProjectSchedule.Forms
|
|||||||
comboBoxDiscipline.ValueMember = "Id";
|
comboBoxDiscipline.ValueMember = "Id";
|
||||||
|
|
||||||
comboBoxGroupStudents.DataSource = groupStudentsRepository.ReadGroupsStudents();
|
comboBoxGroupStudents.DataSource = groupStudentsRepository.ReadGroupsStudents();
|
||||||
comboBoxGroupStudents.DisplayMember = "AbbreviationGroup";
|
comboBoxGroupStudents.DisplayMember = "NameGroup";
|
||||||
comboBoxGroupStudents.ValueMember = "Id";
|
comboBoxGroupStudents.ValueMember = "Id";
|
||||||
|
|
||||||
comboBoxAudience.DataSource = audienceRepository.ReadAudiences();
|
comboBoxAudience.DataSource = audienceRepository.ReadAudiences();
|
||||||
|
@ -43,6 +43,11 @@ namespace ProjectSchedule.Forms
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LoadList() => dataGridViewData.DataSource = _сompilingScheduleRepository.ReadCompilingSchedules();
|
private void LoadList()
|
||||||
|
{
|
||||||
|
dataGridViewData.DataSource = _сompilingScheduleRepository.ReadCompilingSchedules();
|
||||||
|
dataGridViewData.Columns["Id"].Visible = false;
|
||||||
|
dataGridViewData.Columns["DateDay"].DefaultCellStyle.Format = "dd.MM.yyyy";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -15,7 +15,7 @@ namespace ProjectSchedule.Forms
|
|||||||
throw new ArgumentNullException(nameof(curriculumSupplementRepository));
|
throw new ArgumentNullException(nameof(curriculumSupplementRepository));
|
||||||
|
|
||||||
comboBoxGroupStudents.DataSource = groupStudentsRepository.ReadGroupsStudents();
|
comboBoxGroupStudents.DataSource = groupStudentsRepository.ReadGroupsStudents();
|
||||||
comboBoxGroupStudents.DisplayMember = "AbbreviationGroup";
|
comboBoxGroupStudents.DisplayMember = "NameGroup";
|
||||||
comboBoxGroupStudents.ValueMember = "Id";
|
comboBoxGroupStudents.ValueMember = "Id";
|
||||||
|
|
||||||
ColumnDiscipline.DataSource = disciplineRepository.ReadDisciplines();
|
ColumnDiscipline.DataSource = disciplineRepository.ReadDisciplines();
|
||||||
|
@ -67,8 +67,12 @@ namespace ProjectSchedule.Forms
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LoadList() =>
|
private void LoadList()
|
||||||
|
{
|
||||||
dataGridViewData.DataSource = _curriculumSupplementRepository.ReadCurriculumSupplements();
|
dataGridViewData.DataSource = _curriculumSupplementRepository.ReadCurriculumSupplements();
|
||||||
|
dataGridViewData.Columns["Id"].Visible = false;
|
||||||
|
dataGridViewData.Columns["DateAdoptionPlan"].DefaultCellStyle.Format = "dd MMMM yyyy";
|
||||||
|
}
|
||||||
|
|
||||||
private bool TryGetIdentifierFromSelectedRow(out int id)
|
private bool TryGetIdentifierFromSelectedRow(out int id)
|
||||||
{
|
{
|
||||||
|
@ -86,7 +86,11 @@ namespace ProjectSchedule.Forms
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LoadList() => dataGridViewData.DataSource = _disciplineRepository.ReadDisciplines();
|
private void LoadList()
|
||||||
|
{
|
||||||
|
dataGridViewData.DataSource = _disciplineRepository.ReadDisciplines();
|
||||||
|
dataGridViewData.Columns["Id"].Visible = false;
|
||||||
|
}
|
||||||
|
|
||||||
private bool TryGetIdentifierFromSelectedRow(out int id)
|
private bool TryGetIdentifierFromSelectedRow(out int id)
|
||||||
{
|
{
|
||||||
|
@ -86,7 +86,12 @@ namespace ProjectSchedule.Forms
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LoadList() => dataGridViewData.DataSource = _educatorRepository.ReadEducators();
|
private void LoadList()
|
||||||
|
{
|
||||||
|
dataGridViewData.DataSource = _educatorRepository.ReadEducators();
|
||||||
|
dataGridViewData.Columns["Id"].Visible = false;
|
||||||
|
dataGridViewData.Columns["FullName"].Visible = false;
|
||||||
|
}
|
||||||
|
|
||||||
private bool TryGetIdentifierFromSelectedRow(out int id)
|
private bool TryGetIdentifierFromSelectedRow(out int id)
|
||||||
{
|
{
|
||||||
|
@ -86,7 +86,12 @@ namespace ProjectSchedule.Forms
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LoadList() => dataGridViewData.DataSource = _groupStudentsRepository.ReadGroupsStudents();
|
private void LoadList()
|
||||||
|
{
|
||||||
|
dataGridViewData.DataSource = _groupStudentsRepository.ReadGroupsStudents();
|
||||||
|
dataGridViewData.Columns["Id"].Visible = false;
|
||||||
|
dataGridViewData.Columns["NameGroup"].Visible = false;
|
||||||
|
}
|
||||||
|
|
||||||
private bool TryGetIdentifierFromSelectedRow(out int id)
|
private bool TryGetIdentifierFromSelectedRow(out int id)
|
||||||
{
|
{
|
||||||
|
@ -22,7 +22,7 @@ internal class ChartReport
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
new PdfBuilder(filePath)
|
new PdfBuilder(filePath)
|
||||||
.AddHeader("Количество пар")
|
.AddHeader($"Количество пар на {dateTime:dd MMMM yyyy}")
|
||||||
.AddPieChart("Группы студентов", GetData(dateTime))
|
.AddPieChart("Группы студентов", GetData(dateTime))
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
@ -38,10 +38,9 @@ internal class ChartReport
|
|||||||
private List<(string Caption, double Value)> GetData(DateTime dateTime)
|
private List<(string Caption, double Value)> GetData(DateTime dateTime)
|
||||||
{
|
{
|
||||||
return _compilingScheduleRepository
|
return _compilingScheduleRepository
|
||||||
.ReadCompilingSchedules()
|
.ReadCompilingSchedules(dateForm: dateTime.Date, dateTo: dateTime.Date.AddDays(1))
|
||||||
.Where(x => x.DateDay.Date == dateTime.Date)
|
.GroupBy(x => x.NameGroup, (key, group) => new { NameGroup = key, Count = group.Count() })
|
||||||
.GroupBy(x => x.GroupStudentsId, (key, group) => new { Id = key, Count = group.Count() })
|
.Select(x => (x.NameGroup, (double)x.Count))
|
||||||
.Select(x => (x.Id.ToString(), (double)x.Count))
|
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -33,7 +33,7 @@ internal class TableReport
|
|||||||
{
|
{
|
||||||
new ExcelBuilder(filePath)
|
new ExcelBuilder(filePath)
|
||||||
.AddHeader("Сводка по прохождению дисциплин", 0, 7)
|
.AddHeader("Сводка по прохождению дисциплин", 0, 7)
|
||||||
.AddParagraph("за период", 0)
|
.AddParagraph($"за период c {startDate:dd.MM.yyyy} по {endDate:dd.MM.yyyy}", 0)
|
||||||
.AddTable([15, 15, 15, 10, 10, 10, 10], GetData(disciplineId, startDate, endDate))
|
.AddTable([15, 15, 15, 10, 10, 10, 10], GetData(disciplineId, startDate, endDate))
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
@ -49,18 +49,17 @@ internal class TableReport
|
|||||||
private List<string[]> GetData(int disciplineId, DateTime startDate, DateTime endDate)
|
private List<string[]> GetData(int disciplineId, DateTime startDate, DateTime endDate)
|
||||||
{
|
{
|
||||||
var data = _curriculumSupplementRepository
|
var data = _curriculumSupplementRepository
|
||||||
.ReadCurriculumSupplements()
|
.ReadCurriculumSupplements(dateForm: startDate, disciplineId: disciplineId)
|
||||||
.Where(x => x.DateAdoptionPlan <= startDate && x.DisciplineCurriculumSupplements.Any(y => y.DisciplineId == disciplineId))
|
.Select(x => new { Date = x.DateAdoptionPlan,
|
||||||
.Select(x => new { Date = x.DateAdoptionPlan, Discipline = disciplineId, x.GroupStudentsId,
|
Discipline = x.DisciplineCurriculumSupplements.FirstOrDefault(y => y.DisciplineId == disciplineId)?.NameDiscipline ?? string.Empty, x.NameGroup,
|
||||||
CountLectures = x.DisciplineCurriculumSupplements.FirstOrDefault(y => y.DisciplineId == disciplineId)?.QuantityLectures,
|
CountLectures = x.DisciplineCurriculumSupplements.FirstOrDefault(y => y.DisciplineId == disciplineId)?.QuantityLectures,
|
||||||
CountPractices = x.DisciplineCurriculumSupplements.FirstOrDefault(y => y.DisciplineId == disciplineId)?.QuantityPractices,
|
CountPractices = x.DisciplineCurriculumSupplements.FirstOrDefault(y => y.DisciplineId == disciplineId)?.QuantityPractices,
|
||||||
ConductedLectures = (int?)null, ConductedPractices = (int?)null })
|
ConductedLectures = (int?)null, ConductedPractices = (int?)null })
|
||||||
.Union(
|
.Union(
|
||||||
_compilingScheduleRepository
|
_compilingScheduleRepository
|
||||||
.ReadCompilingSchedules()
|
.ReadCompilingSchedules(dateForm: startDate, dateTo: endDate, disciplineId: disciplineId)
|
||||||
.Where(x => x.DateDay >= startDate && x.DateDay <= endDate && x.DisciplineId == disciplineId)
|
.GroupBy(x => new { x.DateDay, x.NameDiscipline, x.NameGroup})
|
||||||
.GroupBy(x => new { x.DateDay, x.GroupStudentsId })
|
.Select(g => new { Date = g.Key.DateDay, Discipline = g.Key.NameDiscipline ?? string.Empty, g.Key.NameGroup, CountLectures = (int?)null,
|
||||||
.Select(g => new { Date = g.Key.DateDay, Discipline = disciplineId, g.Key.GroupStudentsId, CountLectures = (int?)null,
|
|
||||||
CountPractices = (int?)null, ConductedLectures = CalculateConductedLectures(g) == 0 ? (int?)null : CalculateConductedLectures(g),
|
CountPractices = (int?)null, ConductedLectures = CalculateConductedLectures(g) == 0 ? (int?)null : CalculateConductedLectures(g),
|
||||||
ConductedPractices = CalculateConductedPractices(g) == 0 ? (int?)null : CalculateConductedPractices(g)}))
|
ConductedPractices = CalculateConductedPractices(g) == 0 ? (int?)null : CalculateConductedPractices(g)}))
|
||||||
.OrderBy(x => x.Date);
|
.OrderBy(x => x.Date);
|
||||||
@ -69,12 +68,12 @@ internal class TableReport
|
|||||||
new List<string[]>() { item }
|
new List<string[]>() { item }
|
||||||
.Union(
|
.Union(
|
||||||
data
|
data
|
||||||
.Select(x => new string[] { x.Date.ToString("dd.MM.yyyy"), x.Discipline.ToString(), x.GroupStudentsId.ToString(),
|
.Select(x => new string[] { x.Date.ToString("dd.MM.yyyy"), x.Discipline, x.NameGroup,
|
||||||
x.CountLectures?.ToString() ?? string.Empty, x.CountPractices?.ToString() ?? string.Empty,
|
x.CountLectures?.ToString("N0") ?? string.Empty, x.CountPractices?.ToString("N0") ?? string.Empty,
|
||||||
x.ConductedLectures?.ToString() ?? string.Empty, x.ConductedPractices?.ToString() ?? string.Empty }))
|
x.ConductedLectures?.ToString("N0") ?? string.Empty, x.ConductedPractices?.ToString("N0") ?? string.Empty }))
|
||||||
.Union(
|
.Union(
|
||||||
[["Всего", "", "", data.Sum(x => x.CountLectures ?? 0).ToString(), data.Sum(x => x.CountPractices ?? 0).ToString(),
|
[["Всего", "", "", data.Sum(x => x.CountLectures ?? 0).ToString("N0"), data.Sum(x => x.CountPractices ?? 0).ToString("N0"),
|
||||||
data.Sum(x => x.ConductedLectures ?? 0).ToString(), data.Sum(x => x.ConductedPractices ?? 0).ToString()]])
|
data.Sum(x => x.ConductedLectures ?? 0).ToString("N0"), data.Sum(x => x.ConductedPractices ?? 0).ToString("N0")]])
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ namespace ProjectSchedule.Repositories;
|
|||||||
|
|
||||||
public interface ICurriculumSupplementRepository
|
public interface ICurriculumSupplementRepository
|
||||||
{
|
{
|
||||||
IEnumerable<CurriculumSupplement> ReadCurriculumSupplements(DateTime? dateForm = null, DateTime? dateTo = null,
|
IEnumerable<CurriculumSupplement> ReadCurriculumSupplements(DateTime? dateForm = null,
|
||||||
int? disciplineId = null, int? groupStudentsId = null);
|
int? disciplineId = null, int? groupStudentsId = null);
|
||||||
|
|
||||||
void CreateCurriculumSupplement(CurriculumSupplement curriculumSupplement);
|
void CreateCurriculumSupplement(CurriculumSupplement curriculumSupplement);
|
||||||
|
@ -45,9 +45,48 @@ TypeWeek, NumberDay, NumberPair, TypeActivity)
|
|||||||
_logger.LogInformation("Получение всех объектов");
|
_logger.LogInformation("Получение всех объектов");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
var builder = new QueryBuilder();
|
||||||
|
if (dateForm.HasValue)
|
||||||
|
{
|
||||||
|
builder.AddCondition("cs.DateDay >= @dateForm");
|
||||||
|
}
|
||||||
|
if (dateTo.HasValue)
|
||||||
|
{
|
||||||
|
builder.AddCondition("cs.DateDay <= @dateTo");
|
||||||
|
}
|
||||||
|
if (educatorId.HasValue)
|
||||||
|
{
|
||||||
|
builder.AddCondition("cs.EducatorId = @educatorId");
|
||||||
|
}
|
||||||
|
if (disciplineId.HasValue)
|
||||||
|
{
|
||||||
|
builder.AddCondition("cs.DisciplineId = @disciplineId");
|
||||||
|
}
|
||||||
|
if (groupStudentsId.HasValue)
|
||||||
|
{
|
||||||
|
builder.AddCondition("cs.GroupStudentsId = @groupStudentsId");
|
||||||
|
}
|
||||||
|
if (audienceId.HasValue)
|
||||||
|
{
|
||||||
|
builder.AddCondition("cs.AudienceId = @audienceId");
|
||||||
|
}
|
||||||
|
|
||||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
var querySelect = "SELECT * FROM CompilingSchedules";
|
var querySelect = $@"
|
||||||
var compilingSchedules = connection.Query<CompilingSchedule>(querySelect);
|
SELECT
|
||||||
|
cs.*,
|
||||||
|
CONCAT(e.Surname, ' ', e.Name, ' ', e.Patronymic) AS EducatorName,
|
||||||
|
d.NameDiscipline AS NameDiscipline,
|
||||||
|
CONCAT(gs.AbbreviationGroup, '-', gs.GroupNumber) AS NameGroup,
|
||||||
|
a.NumberAudience AS NumberAudience
|
||||||
|
FROM CompilingSchedules cs
|
||||||
|
LEFT JOIN Educators e ON e.Id = cs.EducatorId
|
||||||
|
LEFT JOIN Disciplines d ON d.Id = cs.DisciplineId
|
||||||
|
LEFT JOIN GroupsStudents gs ON gs.Id = cs.GroupStudentsId
|
||||||
|
LEFT JOIN Audiences a ON a.Id = cs.AudienceId
|
||||||
|
{builder.Build()}";
|
||||||
|
var compilingSchedules = connection.Query<CompilingSchedule>(querySelect,
|
||||||
|
new {dateForm, dateTo, educatorId, disciplineId, groupStudentsId, audienceId });
|
||||||
_logger.LogDebug("Полученные объекты: {json}", JsonConvert.SerializeObject(compilingSchedules));
|
_logger.LogDebug("Полученные объекты: {json}", JsonConvert.SerializeObject(compilingSchedules));
|
||||||
return compilingSchedules;
|
return compilingSchedules;
|
||||||
}
|
}
|
||||||
|
@ -69,22 +69,62 @@ public class CurriculumSupplementRepository : ICurriculumSupplementRepository
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<CurriculumSupplement> ReadCurriculumSupplements(DateTime? dateForm = null, DateTime? dateTo = null,
|
public IEnumerable<CurriculumSupplement> ReadCurriculumSupplements(DateTime? dateForm = null, int? disciplineId = null,
|
||||||
int? disciplineId = null, int? groupStudentsId = null)
|
int? groupStudentsId = null)
|
||||||
{
|
{
|
||||||
_logger.LogInformation("Получение всех объектов");
|
_logger.LogInformation("Получение всех объектов");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
var builder = new QueryBuilder();
|
||||||
|
if (dateForm.HasValue)
|
||||||
|
{
|
||||||
|
builder.AddCondition("cs.DateAdoptionPlan <= @dateForm");
|
||||||
|
}
|
||||||
|
if (groupStudentsId.HasValue)
|
||||||
|
{
|
||||||
|
builder.AddCondition("cs.GroupStudentsId = @groupStudentsId");
|
||||||
|
}
|
||||||
|
if (disciplineId.HasValue)
|
||||||
|
{
|
||||||
|
builder.AddCondition("dcs.DisciplineId = @disciplineId");
|
||||||
|
}
|
||||||
|
|
||||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
var querySelect = @"
|
var querySelect = $@"
|
||||||
SELECT cs.*, dcs.DisciplineId, dcs.QuantityLectures, dcs.QuantityPractices FROM CurriculumSupplements cs
|
SELECT
|
||||||
INNER JOIN DisciplineCurriculumSupplements dcs ON dcs.CurriculumSupplementId = cs.Id";
|
cs.*,
|
||||||
var curriculumSupplements = connection.Query<TempDisciplineCurriculumSupplement>(querySelect);
|
CONCAT(gs.AbbreviationGroup, '-', gs.GroupNumber) AS NameGroup,
|
||||||
|
dcs.DisciplineId,
|
||||||
|
dcs.QuantityLectures,
|
||||||
|
dcs.QuantityPractices,
|
||||||
|
d.NameDiscipline AS NameDiscipline
|
||||||
|
FROM CurriculumSupplements cs
|
||||||
|
LEFT JOIN GroupsStudents gs ON gs.Id = cs.GroupStudentsId
|
||||||
|
INNER JOIN DisciplineCurriculumSupplements dcs ON dcs.CurriculumSupplementId = cs.Id
|
||||||
|
LEFT JOIN Disciplines d ON d.Id = dcs.DisciplineId
|
||||||
|
{builder.Build()}";
|
||||||
|
var supplementDict = new Dictionary<int, List<DisciplineCurriculumSupplement>>();
|
||||||
|
|
||||||
|
var curriculumSupplements = connection.Query<CurriculumSupplement, DisciplineCurriculumSupplement, CurriculumSupplement>(querySelect,
|
||||||
|
(supplement, curriculumSupplements) =>
|
||||||
|
{
|
||||||
|
if (!supplementDict.TryGetValue(supplement.Id, out var dcs))
|
||||||
|
{
|
||||||
|
dcs = [];
|
||||||
|
supplementDict.Add(supplement.Id, dcs);
|
||||||
|
}
|
||||||
|
|
||||||
|
dcs.Add(curriculumSupplements);
|
||||||
|
return supplement;
|
||||||
|
}, splitOn: "DisciplineId", param: new { dateForm, disciplineId, groupStudentsId });
|
||||||
_logger.LogDebug("Полученные объекты: {json}", JsonConvert.SerializeObject(curriculumSupplements));
|
_logger.LogDebug("Полученные объекты: {json}", JsonConvert.SerializeObject(curriculumSupplements));
|
||||||
|
|
||||||
return curriculumSupplements.GroupBy(x => x.Id, y => y,
|
return supplementDict.Select(x =>
|
||||||
(key, value) => CurriculumSupplement.CreateOpeartion(value.First(),
|
{
|
||||||
value.Select(z => DisciplineCurriculumSupplement.CreateElement(0, z.DisciplineId, z.QuantityLectures, z.QuantityPractices)))).ToList();
|
var cs = curriculumSupplements.First(y => y.Id == x.Key);
|
||||||
|
cs.SetDisciplineCurriculumSupplements(x.Value);
|
||||||
|
return cs;
|
||||||
|
}).ToArray();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
@ -0,0 +1,35 @@
|
|||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace ProjectSchedule.Repositories.Implementations;
|
||||||
|
|
||||||
|
internal class QueryBuilder
|
||||||
|
{
|
||||||
|
private readonly StringBuilder _builder;
|
||||||
|
|
||||||
|
public QueryBuilder()
|
||||||
|
{
|
||||||
|
_builder = new();
|
||||||
|
}
|
||||||
|
|
||||||
|
public QueryBuilder AddCondition(string condition)
|
||||||
|
{
|
||||||
|
if (_builder.Length > 0)
|
||||||
|
{
|
||||||
|
_builder.Append(" AND ");
|
||||||
|
}
|
||||||
|
|
||||||
|
_builder.Append(condition);
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Build()
|
||||||
|
{
|
||||||
|
if (_builder.Length == 0)
|
||||||
|
{
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $"WHERE {_builder}";
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user