четвертая лаба
This commit is contained in:
parent
bf179f797b
commit
ab2fb20214
@ -4,14 +4,21 @@ 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 System.ComponentModel;
|
||||||
|
|
||||||
namespace ProjectSchedule.Entities;
|
namespace ProjectSchedule.Entities;
|
||||||
|
|
||||||
public class Audience
|
public class Audience
|
||||||
{
|
{
|
||||||
public int Id { get; private set; }
|
public int Id { get; private set; }
|
||||||
|
|
||||||
|
[DisplayName("Номер аудитории")]
|
||||||
public string Number { get; private set; } = string.Empty;
|
public string Number { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
[DisplayName("Количество мест")]
|
||||||
public int SeatsCount { get; private set; }
|
public int SeatsCount { get; private set; }
|
||||||
|
|
||||||
|
[DisplayName("Тип аудитории")]
|
||||||
public TypeAudience TypeAudience { get; private set; }
|
public TypeAudience TypeAudience { get; private set; }
|
||||||
|
|
||||||
public static Audience CreateEntity(int id, string number, TypeAudience typeAudience, int seatsCount)
|
public static Audience CreateEntity(int id, string number, TypeAudience typeAudience, int seatsCount)
|
||||||
|
@ -3,12 +3,15 @@ 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 System.ComponentModel;
|
||||||
|
|
||||||
namespace ProjectSchedule.Entities;
|
namespace ProjectSchedule.Entities;
|
||||||
|
|
||||||
public class Discipline
|
public class Discipline
|
||||||
{
|
{
|
||||||
public int Id { get; private set; }
|
public int Id { get; private set; }
|
||||||
|
|
||||||
|
[DisplayName("Название дисциплины")]
|
||||||
public string Name { get; private set; } = string.Empty;
|
public string Name { get; private set; } = string.Empty;
|
||||||
|
|
||||||
public static Discipline CreateEntity(int id, string name)
|
public static Discipline CreateEntity(int id, string name)
|
||||||
|
@ -10,6 +10,7 @@ public class DisciplineStudingPlanSupplement
|
|||||||
{
|
{
|
||||||
public int Id { get; private set; }
|
public int Id { get; private set; }
|
||||||
public int DisciplineId { get; private set; }
|
public int DisciplineId { get; private set; }
|
||||||
|
public string NameDiscipline { get; private set; } = string.Empty;
|
||||||
public int LecturesCount { get; private set; }
|
public int LecturesCount { get; private set; }
|
||||||
public int PracticesCount { get; private set; }
|
public int PracticesCount { get; private set; }
|
||||||
|
|
||||||
|
@ -3,14 +3,23 @@ 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 System.ComponentModel;
|
||||||
|
|
||||||
namespace ProjectSchedule.Entities;
|
namespace ProjectSchedule.Entities;
|
||||||
|
|
||||||
public class Group
|
public class Group
|
||||||
{
|
{
|
||||||
public int Id { get; private set; }
|
public int Id { get; private set; }
|
||||||
|
|
||||||
|
[DisplayName("Название группы")]
|
||||||
public string Name { get; private set; } = string.Empty;
|
public string Name { 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 => $"{Name}-{GroupNumber}";
|
||||||
|
|
||||||
|
[DisplayName("Количество студентов")]
|
||||||
public int StudentsCount { get; private set; }
|
public int StudentsCount { get; private set; }
|
||||||
|
|
||||||
public static Group CreateEntity(int id, string name, string groupNumber, int studentsCount)
|
public static Group CreateEntity(int id, string name, string groupNumber, int studentsCount)
|
||||||
|
@ -4,20 +4,51 @@ 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 System.ComponentModel;
|
||||||
|
|
||||||
namespace ProjectSchedule.Entities;
|
namespace ProjectSchedule.Entities;
|
||||||
|
|
||||||
public class Schedule
|
public class Schedule
|
||||||
{
|
{
|
||||||
public int Id { get; private set; }
|
public int Id { get; private set; }
|
||||||
|
|
||||||
|
[Browsable(false)]
|
||||||
public int TeacherId { get; private set; }
|
public int TeacherId { get; private set; }
|
||||||
|
|
||||||
|
[Browsable(false)]
|
||||||
public int DisciplineId { get; private set; }
|
public int DisciplineId { get; private set; }
|
||||||
|
|
||||||
|
[Browsable(false)]
|
||||||
public int GroupId { get; private set; }
|
public int GroupId { get; private set; }
|
||||||
|
|
||||||
|
[Browsable(false)]
|
||||||
public int AudienceId { get; private set; }
|
public int AudienceId { get; private set; }
|
||||||
|
|
||||||
|
[DisplayName("Преподаватель")]
|
||||||
|
public string TeacherName { 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 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 TypeWeek TypeWeek { get; private set; }
|
public TypeWeek TypeWeek { get; private set; }
|
||||||
|
|
||||||
|
[DisplayName("Тип пары")]
|
||||||
public TypePair TypePair { get; private set; }
|
public TypePair TypePair { get; private set; }
|
||||||
|
|
||||||
public static Schedule CreateOperation(int id, int teacherId, int disciplineId, int groupId, int audienceId,
|
public static Schedule CreateOperation(int id, int teacherId, int disciplineId, int groupId, int audienceId,
|
||||||
|
@ -3,6 +3,7 @@ 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 System.ComponentModel;
|
||||||
|
|
||||||
namespace ProjectSchedule.Entities;
|
namespace ProjectSchedule.Entities;
|
||||||
|
|
||||||
@ -10,14 +11,26 @@ public class StudingPlanSupplement
|
|||||||
{
|
{
|
||||||
public int Id { get; private set; }
|
public int Id { get; private set; }
|
||||||
|
|
||||||
|
[Browsable(false)]
|
||||||
public int GroupId { get; private set; }
|
public int GroupId { get; private set; }
|
||||||
|
|
||||||
|
[DisplayName("Группа студентов")]
|
||||||
|
public string NameGroup { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
[DisplayName("Название учебного плана")]
|
||||||
public string NameStudingPlan { get; private set; } = string.Empty;
|
public string NameStudingPlan { 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 DateApprovePlan { get; private set; }
|
public DateTime DateApprovePlan { get; private set; }
|
||||||
|
|
||||||
|
[DisplayName("Дисциплины")]
|
||||||
|
public string Discipline => DisciplineStudingPlanSupplements != null ?
|
||||||
|
string.Join(", ", DisciplineStudingPlanSupplements.Select(x => $"{x.NameDiscipline} {x.LecturesCount} {x.PracticesCount}")) : string.Empty;
|
||||||
|
|
||||||
|
[Browsable(false)]
|
||||||
public IEnumerable<DisciplineStudingPlanSupplement> DisciplineStudingPlanSupplements { get; private set; } = [];
|
public IEnumerable<DisciplineStudingPlanSupplement> DisciplineStudingPlanSupplements { get; private set; } = [];
|
||||||
|
|
||||||
public static StudingPlanSupplement CreateOperation(int id, int groupId, string nameStudingPlan,
|
public static StudingPlanSupplement CreateOperation(int id, int groupId, string nameStudingPlan,
|
||||||
@ -34,17 +47,11 @@ public class StudingPlanSupplement
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public static StudingPlanSupplement CreateOperation(TempDisciplineStudingPlanSupplement tempDisciplineStudingPlanSupplement,
|
public void SetDisciplineStudingPlanSupplements(IEnumerable<DisciplineStudingPlanSupplement> disciplineStudingPlanSupplements)
|
||||||
IEnumerable<DisciplineStudingPlanSupplement> disciplineStudingPlanSupplements)
|
|
||||||
{
|
{
|
||||||
return new StudingPlanSupplement
|
if (disciplineStudingPlanSupplements != null && disciplineStudingPlanSupplements.Any())
|
||||||
{
|
{
|
||||||
Id = tempDisciplineStudingPlanSupplement.Id,
|
DisciplineStudingPlanSupplements = disciplineStudingPlanSupplements;
|
||||||
GroupId = tempDisciplineStudingPlanSupplement.GroupId,
|
}
|
||||||
NameStudingPlan = tempDisciplineStudingPlanSupplement.NameStudingPlan,
|
|
||||||
Semester = tempDisciplineStudingPlanSupplement.Semester,
|
|
||||||
DateApprovePlan = tempDisciplineStudingPlanSupplement.DateApprovePlan,
|
|
||||||
DisciplineStudingPlanSupplements = disciplineStudingPlanSupplements
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -3,16 +3,24 @@ 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 System.ComponentModel;
|
||||||
|
|
||||||
namespace ProjectSchedule.Entities;
|
namespace ProjectSchedule.Entities;
|
||||||
|
|
||||||
public class Teacher
|
public class Teacher
|
||||||
{
|
{
|
||||||
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 Teacher CreateEntity(int id, string surname, string name, string patronymic)
|
public static Teacher CreateEntity(int id, string surname, string name, string patronymic)
|
||||||
{
|
{
|
||||||
return new Teacher
|
return new Teacher
|
||||||
|
@ -1,20 +0,0 @@
|
|||||||
namespace ProjectSchedule.Entities;
|
|
||||||
|
|
||||||
public class TempDisciplineStudingPlanSupplement
|
|
||||||
{
|
|
||||||
public int Id { get; private set; }
|
|
||||||
|
|
||||||
public int GroupId { get; private set; }
|
|
||||||
|
|
||||||
public string NameStudingPlan { get; private set; } = string.Empty;
|
|
||||||
|
|
||||||
public string Semester { get; private set; } = string.Empty;
|
|
||||||
|
|
||||||
public DateTime DateApprovePlan { get; private set; }
|
|
||||||
|
|
||||||
public int DisciplineId { get; private set; }
|
|
||||||
|
|
||||||
public int LecturesCount { get; private set; }
|
|
||||||
|
|
||||||
public int PracticesCount { 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)
|
||||||
{
|
{
|
||||||
|
@ -15,7 +15,7 @@ namespace ProjectSchedule.Forms
|
|||||||
throw new ArgumentNullException(nameof(container));
|
throw new ArgumentNullException(nameof(container));
|
||||||
|
|
||||||
comboBoxDiscipline.DataSource = disciplineRepository.ReadDisciplines();
|
comboBoxDiscipline.DataSource = disciplineRepository.ReadDisciplines();
|
||||||
comboBoxDiscipline.DisplayMember = "NameDiscipline";
|
comboBoxDiscipline.DisplayMember = "Name";
|
||||||
comboBoxDiscipline.ValueMember = "Id";
|
comboBoxDiscipline.ValueMember = "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 = _groupRepository.ReadGroups();
|
private void LoadList()
|
||||||
|
{
|
||||||
|
dataGridViewData.DataSource = _groupRepository.ReadGroups();
|
||||||
|
dataGridViewData.Columns["Id"].Visible = false;
|
||||||
|
dataGridViewData.Columns["NameGroup"].Visible = false;
|
||||||
|
}
|
||||||
|
|
||||||
private bool TryGetIdentifierFromSelectedRow(out int id)
|
private bool TryGetIdentifierFromSelectedRow(out int id)
|
||||||
{
|
{
|
||||||
|
@ -17,11 +17,11 @@ namespace ProjectSchedule.Forms
|
|||||||
throw new ArgumentNullException(nameof(scheduleRepository));
|
throw new ArgumentNullException(nameof(scheduleRepository));
|
||||||
|
|
||||||
comboBoxTeacher.DataSource = teacherRepository.ReadTeachers();
|
comboBoxTeacher.DataSource = teacherRepository.ReadTeachers();
|
||||||
comboBoxTeacher.DisplayMember = "Surname";
|
comboBoxTeacher.DisplayMember = "FullName";
|
||||||
comboBoxTeacher.ValueMember = "Id";
|
comboBoxTeacher.ValueMember = "Id";
|
||||||
|
|
||||||
comboBoxDiscipline.DataSource = disciplineRepository.ReadDisciplines();
|
comboBoxDiscipline.DataSource = disciplineRepository.ReadDisciplines();
|
||||||
comboBoxDiscipline.DisplayMember = "NameDiscipline";
|
comboBoxDiscipline.DisplayMember = "Name";
|
||||||
comboBoxDiscipline.ValueMember = "Id";
|
comboBoxDiscipline.ValueMember = "Id";
|
||||||
|
|
||||||
comboBoxGroup.DataSource = groupRepository.ReadGroups();
|
comboBoxGroup.DataSource = groupRepository.ReadGroups();
|
||||||
@ -29,7 +29,7 @@ namespace ProjectSchedule.Forms
|
|||||||
comboBoxGroup.ValueMember = "Id";
|
comboBoxGroup.ValueMember = "Id";
|
||||||
|
|
||||||
comboBoxAudience.DataSource = audienceRepository.ReadAudiences();
|
comboBoxAudience.DataSource = audienceRepository.ReadAudiences();
|
||||||
comboBoxAudience.DisplayMember = "NumberAudience";
|
comboBoxAudience.DisplayMember = "Number";
|
||||||
comboBoxAudience.ValueMember = "Id";
|
comboBoxAudience.ValueMember = "Id";
|
||||||
|
|
||||||
comboBoxTypeWeek.DataSource = Enum.GetValues(typeof(TypeWeek));
|
comboBoxTypeWeek.DataSource = Enum.GetValues(typeof(TypeWeek));
|
||||||
|
@ -43,6 +43,11 @@ namespace ProjectSchedule.Forms
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LoadList() => dataGridViewData.DataSource = _scheduleRepository.ReadSchedules();
|
private void LoadList()
|
||||||
|
{
|
||||||
|
dataGridViewData.DataSource = _scheduleRepository.ReadSchedules();
|
||||||
|
dataGridViewData.Columns["Id"].Visible = false;
|
||||||
|
dataGridViewData.Columns["DateDay"].DefaultCellStyle.Format = "dd.MM.yyyy";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -67,8 +67,12 @@ namespace ProjectSchedule.Forms
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LoadList() =>
|
private void LoadList()
|
||||||
|
{
|
||||||
dataGridViewData.DataSource = _studingPlanSupplementRepository.ReadStudingPlanSupplements();
|
dataGridViewData.DataSource = _studingPlanSupplementRepository.ReadStudingPlanSupplements();
|
||||||
|
dataGridViewData.Columns["Id"].Visible = false;
|
||||||
|
dataGridViewData.Columns["DateApprovePlan"].DefaultCellStyle.Format = "dd MMMM yyyy";
|
||||||
|
}
|
||||||
|
|
||||||
private bool TryGetIdentifierFromSelectedRow(out int id)
|
private bool TryGetIdentifierFromSelectedRow(out int id)
|
||||||
{
|
{
|
||||||
|
@ -86,7 +86,12 @@ namespace ProjectSchedule.Forms
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LoadList() => dataGridViewData.DataSource = _teacherRepository.ReadTeachers();
|
private void LoadList()
|
||||||
|
{
|
||||||
|
dataGridViewData.DataSource = _teacherRepository.ReadTeachers();
|
||||||
|
dataGridViewData.Columns["Id"].Visible = false;
|
||||||
|
dataGridViewData.Columns["FullName"].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 _scheduleRepository
|
return _scheduleRepository
|
||||||
.ReadSchedules()
|
.ReadSchedules(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.GroupId, (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([10, 10, 10, 10, 10, 10, 10], GetData(disciplineId, startDate, endDate))
|
.AddTable([10, 10, 10, 10, 10, 10, 10], GetData(disciplineId, startDate, endDate))
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
@ -49,12 +49,11 @@ 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 = _studingPlanSupplementRepository
|
var data = _studingPlanSupplementRepository
|
||||||
.ReadStudingPlanSupplements()
|
.ReadStudingPlanSupplements(dateForm: startDate, disciplineId: disciplineId)
|
||||||
.Where(x => x.DateApprovePlan <= startDate && x.DisciplineStudingPlanSupplements.Any(y => y.DisciplineId == disciplineId))
|
|
||||||
.Select(x => new {
|
.Select(x => new {
|
||||||
Date = x.DateApprovePlan,
|
Date = x.DateApprovePlan,
|
||||||
Discipline = disciplineId,
|
Discipline = x.DisciplineStudingPlanSupplements.FirstOrDefault(y => y.DisciplineId == disciplineId)?.NameDiscipline ?? string.Empty,
|
||||||
x.GroupId,
|
x.NameGroup,
|
||||||
CountLectures = x.DisciplineStudingPlanSupplements.FirstOrDefault(y => y.DisciplineId == disciplineId)?.LecturesCount,
|
CountLectures = x.DisciplineStudingPlanSupplements.FirstOrDefault(y => y.DisciplineId == disciplineId)?.LecturesCount,
|
||||||
CountPractices = x.DisciplineStudingPlanSupplements.FirstOrDefault(y => y.DisciplineId == disciplineId)?.PracticesCount,
|
CountPractices = x.DisciplineStudingPlanSupplements.FirstOrDefault(y => y.DisciplineId == disciplineId)?.PracticesCount,
|
||||||
PastLectures = (int?)null,
|
PastLectures = (int?)null,
|
||||||
@ -62,13 +61,12 @@ internal class TableReport
|
|||||||
})
|
})
|
||||||
.Union(
|
.Union(
|
||||||
_scheduleRepository
|
_scheduleRepository
|
||||||
.ReadSchedules()
|
.ReadSchedules(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.GroupId })
|
|
||||||
.Select(g => new {
|
.Select(g => new {
|
||||||
Date = g.Key.DateDay,
|
Date = g.Key.DateDay,
|
||||||
Discipline = disciplineId,
|
Discipline = g.Key.NameDiscipline ?? string.Empty,
|
||||||
g.Key.GroupId,
|
g.Key.NameGroup,
|
||||||
CountLectures = (int?)null,
|
CountLectures = (int?)null,
|
||||||
CountPractices = (int?)null,
|
CountPractices = (int?)null,
|
||||||
PastLectures = g.Count(s => s.TypePair == TypePair.Lecture) == 0 ? (int?)null : g.Count(s => s.TypePair == TypePair.Lecture),
|
PastLectures = g.Count(s => s.TypePair == TypePair.Lecture) == 0 ? (int?)null : g.Count(s => s.TypePair == TypePair.Lecture),
|
||||||
@ -80,12 +78,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.GroupId.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.PastLectures?.ToString() ?? string.Empty, x.PastPractices?.ToString() ?? string.Empty }))
|
x.PastLectures?.ToString("N0") ?? string.Empty, x.PastPractices?.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.PastLectures ?? 0).ToString(), data.Sum(x => x.PastPractices ?? 0).ToString()]])
|
data.Sum(x => x.PastLectures ?? 0).ToString("N0"), data.Sum(x => x.PastPractices ?? 0).ToString("N0")]])
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -9,7 +9,7 @@ namespace ProjectSchedule.Repositories;
|
|||||||
|
|
||||||
public interface IStudingPlanSupplementRepository
|
public interface IStudingPlanSupplementRepository
|
||||||
{
|
{
|
||||||
IEnumerable<StudingPlanSupplement> ReadStudingPlanSupplements(DateTime? dateForm = null, DateTime? dateTo = null,
|
IEnumerable<StudingPlanSupplement> ReadStudingPlanSupplements(DateTime? dateForm = null,
|
||||||
int? disciplineId = null, int? groupStudentsId = null);
|
int? disciplineId = null, int? groupStudentsId = null);
|
||||||
void CreateStudingPlanSupplement(StudingPlanSupplement studingPlanSupplement);
|
void CreateStudingPlanSupplement(StudingPlanSupplement studingPlanSupplement);
|
||||||
void DeleteStudingPlanSupplement(int id);
|
void DeleteStudingPlanSupplement(int id);
|
||||||
|
@ -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}";
|
||||||
|
}
|
||||||
|
}
|
@ -45,9 +45,47 @@ TypeWeek, NumberDay, NumberPair, TypePair)
|
|||||||
_logger.LogInformation("Получение всех объектов");
|
_logger.LogInformation("Получение всех объектов");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
var builder = new QueryBuilder();
|
||||||
|
if (dateForm.HasValue)
|
||||||
|
{
|
||||||
|
builder.AddCondition("s.DateDay >= @dateForm");
|
||||||
|
}
|
||||||
|
if (dateTo.HasValue)
|
||||||
|
{
|
||||||
|
builder.AddCondition("s.DateDay <= @dateTo");
|
||||||
|
}
|
||||||
|
if (teacherId.HasValue)
|
||||||
|
{
|
||||||
|
builder.AddCondition("s.TeacherId = @teacherId");
|
||||||
|
}
|
||||||
|
if (disciplineId.HasValue)
|
||||||
|
{
|
||||||
|
builder.AddCondition("s.DisciplineId = @disciplineId");
|
||||||
|
}
|
||||||
|
if (groupStudentsId.HasValue)
|
||||||
|
{
|
||||||
|
builder.AddCondition("s.GroupStudentsId = @groupStudentsId");
|
||||||
|
}
|
||||||
|
if (audienceId.HasValue)
|
||||||
|
{
|
||||||
|
builder.AddCondition("s.AudienceId = @audienceId");
|
||||||
|
}
|
||||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
var querySelect = "SELECT * FROM Schedule";
|
var querySelect = $@"
|
||||||
var schedules = connection.Query<Schedule>(querySelect);
|
SELECT
|
||||||
|
s.*,
|
||||||
|
CONCAT(e.Surname, ' ', e.Name, ' ', e.Patronymic) AS TeacherName,
|
||||||
|
d.Name AS NameDiscipline,
|
||||||
|
CONCAT(g.Name, '-', g.GroupNumber) AS NameGroup,
|
||||||
|
a.Number AS NumberAudience
|
||||||
|
FROM Schedule s
|
||||||
|
LEFT JOIN Teacher e ON e.Id = s.TeacherId
|
||||||
|
LEFT JOIN Discipline d ON d.Id = s.DisciplineId
|
||||||
|
LEFT JOIN Groups g ON g.Id = s.GroupId
|
||||||
|
LEFT JOIN Audience a ON a.Id = s.AudienceId
|
||||||
|
{builder.Build()}";
|
||||||
|
var schedules = connection.Query<Schedule>(querySelect,
|
||||||
|
new { dateForm, dateTo, teacherId, disciplineId, groupStudentsId, audienceId });
|
||||||
_logger.LogDebug("Полученные объекты: {json}", JsonConvert.SerializeObject(schedules));
|
_logger.LogDebug("Полученные объекты: {json}", JsonConvert.SerializeObject(schedules));
|
||||||
return schedules;
|
return schedules;
|
||||||
}
|
}
|
||||||
|
@ -69,22 +69,62 @@ public class StudingPlanSupplementRepository : IStudingPlanSupplementRepository
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<StudingPlanSupplement> ReadStudingPlanSupplements(DateTime? dateForm = null, DateTime? dateTo = null,
|
public IEnumerable<StudingPlanSupplement> ReadStudingPlanSupplements(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("sps.DateApprovePlan <= @dateForm");
|
||||||
|
}
|
||||||
|
if (groupStudentsId.HasValue)
|
||||||
|
{
|
||||||
|
builder.AddCondition("sps.GroupId = @groupStudentsId");
|
||||||
|
}
|
||||||
|
if (disciplineId.HasValue)
|
||||||
|
{
|
||||||
|
builder.AddCondition("dsps.DisciplineId = @disciplineId");
|
||||||
|
}
|
||||||
|
|
||||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
var querySelect = @"
|
var querySelect = $@"
|
||||||
SELECT sps.*, dsps.DisciplineId, dsps.LecturesCount, dsps.PracticesCount FROM StudingPlanSupplement sps
|
SELECT
|
||||||
INNER JOIN Discipline_StudingPlanSupplement dsps ON dsps.StudingPlanSupplementId = sps.Id";
|
sps.*,
|
||||||
var studingPlanSupplements = connection.Query<TempDisciplineStudingPlanSupplement>(querySelect);
|
CONCAT(g.Name, '-', g.GroupNumber) AS NameGroup,
|
||||||
|
dsps.DisciplineId,
|
||||||
|
dsps.LecturesCount,
|
||||||
|
dsps.PracticesCount,
|
||||||
|
d.Name AS NameDiscipline
|
||||||
|
FROM StudingPlanSupplement sps
|
||||||
|
LEFT JOIN Groups g ON g.Id = sps.GroupId
|
||||||
|
INNER JOIN Discipline_StudingPlanSupplement dsps ON dsps.StudingPlanSupplementId = sps.Id
|
||||||
|
LEFT JOIN Discipline d ON d.Id = dsps.DisciplineId
|
||||||
|
{builder.Build()}";
|
||||||
|
var supplementDict = new Dictionary<int, List<DisciplineStudingPlanSupplement>>();
|
||||||
|
|
||||||
|
var studingPlanSupplements = connection.Query<StudingPlanSupplement, DisciplineStudingPlanSupplement, StudingPlanSupplement>(querySelect,
|
||||||
|
(supplement, studingPlanSupplements) =>
|
||||||
|
{
|
||||||
|
if (!supplementDict.TryGetValue(supplement.Id, out var dsps))
|
||||||
|
{
|
||||||
|
dsps = [];
|
||||||
|
supplementDict.Add(supplement.Id, dsps);
|
||||||
|
}
|
||||||
|
|
||||||
|
dsps.Add(studingPlanSupplements);
|
||||||
|
return supplement;
|
||||||
|
}, splitOn: "DisciplineId", param: new { dateForm, disciplineId, groupStudentsId });
|
||||||
_logger.LogDebug("Полученные объекты: {json}", JsonConvert.SerializeObject(studingPlanSupplements));
|
_logger.LogDebug("Полученные объекты: {json}", JsonConvert.SerializeObject(studingPlanSupplements));
|
||||||
|
|
||||||
return studingPlanSupplements.GroupBy(x => x.Id, y => y,
|
return supplementDict.Select(x =>
|
||||||
(key, value) => StudingPlanSupplement.CreateOperation(value.First(),
|
{
|
||||||
value.Select(z => DisciplineStudingPlanSupplement.CreateElement(0, z.DisciplineId, z.LecturesCount, z.PracticesCount)))).ToList();
|
var cs = studingPlanSupplements.First(y => y.Id == x.Key);
|
||||||
|
cs.SetDisciplineStudingPlanSupplements(x.Value);
|
||||||
|
return cs;
|
||||||
|
}).ToArray();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user