не выводит некоторые поля
This commit is contained in:
parent
240ea12b6b
commit
f923669aa7
@ -1,4 +1,5 @@
|
|||||||
using ProjectPassengerTransportation.Entities.Enums;
|
using ProjectPassengerTransportation.Entities.Enums;
|
||||||
|
using System.ComponentModel;
|
||||||
|
|
||||||
namespace ProjectPassengerTransportation.Entities;
|
namespace ProjectPassengerTransportation.Entities;
|
||||||
|
|
||||||
@ -6,10 +7,14 @@ public class Bus
|
|||||||
{
|
{
|
||||||
public int Id { get; private set; }
|
public int Id { get; private set; }
|
||||||
|
|
||||||
|
[DisplayName("Госномер")]
|
||||||
public string Licence_plate { get; private set; } = string.Empty;
|
public string Licence_plate { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
[DisplayName("Модель автобуса")]
|
||||||
public string Model { get; private set; } = string.Empty;
|
public string Model { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
public string Model_and_plate => $"{Model} {Licence_plate}";
|
||||||
|
|
||||||
public static Bus CreateEntity(int id, string licencePlate, string model)
|
public static Bus CreateEntity(int id, string licencePlate, string model)
|
||||||
{
|
{
|
||||||
return new Bus
|
return new Bus
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
using ProjectPassengerTransportation.Entities.Enums;
|
using DocumentFormat.OpenXml.Wordprocessing;
|
||||||
|
using ProjectPassengerTransportation.Entities.Enums;
|
||||||
|
using System.ComponentModel;
|
||||||
|
|
||||||
namespace ProjectPassengerTransportation.Entities;
|
namespace ProjectPassengerTransportation.Entities;
|
||||||
|
|
||||||
@ -6,10 +8,15 @@ public class Employee
|
|||||||
{
|
{
|
||||||
public int Id { get; private set; }
|
public int Id { get; private set; }
|
||||||
|
|
||||||
|
[DisplayName("Имя")]
|
||||||
public string First_name { get; private set; } = string.Empty;
|
public string First_name { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
[DisplayName("Фамилия")]
|
||||||
public string Last_name { get; private set; } = string.Empty;
|
public string Last_name { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
public string Full_name => $"{Last_name} {First_name}";
|
||||||
|
|
||||||
|
[DisplayName("Должность")]
|
||||||
public EmployeePost Post { get; private set; }
|
public EmployeePost Post { get; private set; }
|
||||||
|
|
||||||
public static Employee CreateEntity(int id, string first, string last, EmployeePost post)
|
public static Employee CreateEntity(int id, string first, string last, EmployeePost post)
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using ProjectPassengerTransportation.Entities.Enums;
|
using ProjectPassengerTransportation.Entities.Enums;
|
||||||
|
using System.ComponentModel;
|
||||||
|
|
||||||
namespace ProjectPassengerTransportation.Entities;
|
namespace ProjectPassengerTransportation.Entities;
|
||||||
|
|
||||||
@ -6,13 +7,20 @@ public class GoToService
|
|||||||
{
|
{
|
||||||
public int Id { get; private set; }
|
public int Id { get; private set; }
|
||||||
|
|
||||||
public DateTime Date { get; private set; }
|
[Browsable(false)]
|
||||||
|
public int Bus_id { get; private set; }
|
||||||
|
|
||||||
|
[DisplayName("Автобус")]
|
||||||
|
public string Bus_name { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
[DisplayName("Сломанные элементы")]
|
||||||
public BrokenElements Broken_elements { get; private set; }
|
public BrokenElements Broken_elements { get; private set; }
|
||||||
|
|
||||||
|
[DisplayName("Стоимость")]
|
||||||
public int Price { get; private set; }
|
public int Price { get; private set; }
|
||||||
|
|
||||||
public int Bus_id { get; private set; }
|
[DisplayName("Дата тех обслуживания")]
|
||||||
|
public DateTime Date { get; private set; }
|
||||||
|
|
||||||
public static GoToService CreateOperation(int id, BrokenElements brokenElements, int price, int busId)
|
public static GoToService CreateOperation(int id, BrokenElements brokenElements, int price, int busId)
|
||||||
{
|
{
|
||||||
|
@ -1,13 +1,19 @@
|
|||||||
namespace ProjectPassengerTransportation.Entities;
|
using System.ComponentModel;
|
||||||
|
|
||||||
|
namespace ProjectPassengerTransportation.Entities;
|
||||||
|
|
||||||
public class RouteList
|
public class RouteList
|
||||||
{
|
{
|
||||||
public int Id { get; private set; }
|
public int Id { get; private set; }
|
||||||
|
|
||||||
|
[DisplayName("Начало маршрута")]
|
||||||
public TimeSpan Route_start { get; private set; }
|
public TimeSpan Route_start { get; private set; }
|
||||||
|
|
||||||
|
[DisplayName("Конец маршрута")]
|
||||||
public TimeSpan Route_finish { get; private set; }
|
public TimeSpan Route_finish { get; private set; }
|
||||||
|
|
||||||
|
public string Route_time => $"{Route_start}-{Route_finish}";
|
||||||
|
|
||||||
public static RouteList CreateEntity(int id, TimeSpan start, TimeSpan finish)
|
public static RouteList CreateEntity(int id, TimeSpan start, TimeSpan finish)
|
||||||
{
|
{
|
||||||
return new RouteList
|
return new RouteList
|
||||||
|
@ -1,15 +1,31 @@
|
|||||||
namespace ProjectPassengerTransportation.Entities;
|
using System.ComponentModel;
|
||||||
|
|
||||||
|
namespace ProjectPassengerTransportation.Entities;
|
||||||
|
|
||||||
public class StartingShift
|
public class StartingShift
|
||||||
{
|
{
|
||||||
public int Id { get; private set; }
|
public int Id { get; private set; }
|
||||||
|
|
||||||
public DateTime Date { get; private set; }
|
[Browsable(false)]
|
||||||
|
|
||||||
public int Route_list_id { get; private set; }
|
public int Route_list_id { get; private set; }
|
||||||
|
|
||||||
|
[Browsable(false)]
|
||||||
public int Bus_id { get; private set; }
|
public int Bus_id { get; private set; }
|
||||||
|
|
||||||
|
[DisplayName("Маршрутный лист")]
|
||||||
|
public string Route_list_name { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
[DisplayName("Автобус")]
|
||||||
|
public string Bus_name { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
[DisplayName("Дата смены")]
|
||||||
|
public DateTime Date { get; private set; }
|
||||||
|
|
||||||
|
[DisplayName("Работники")]
|
||||||
|
public string Employee => Starting_shift_employees != null ?
|
||||||
|
string.Join(", ", Starting_shift_employees.Select(x => $"{x.Employee_name} {x.Work_time}")) : string.Empty;
|
||||||
|
|
||||||
|
[Browsable(false)]
|
||||||
public IEnumerable<StartingShiftEmployee> Starting_shift_employees { get; private set; } = [];
|
public IEnumerable<StartingShiftEmployee> Starting_shift_employees { get; private set; } = [];
|
||||||
|
|
||||||
public static StartingShift CreateOperation(int id, int routeListId, int busId,
|
public static StartingShift CreateOperation(int id, int routeListId, int busId,
|
||||||
@ -25,16 +41,11 @@ public class StartingShift
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public static StartingShift CreateOperation(TempStartingShiftEmployee tempStartingShiftEmployee,
|
public void SetStartingShiftEmployee(IEnumerable<StartingShiftEmployee> startingShiftEmployee)
|
||||||
IEnumerable<StartingShiftEmployee> startingShiftEmployee)
|
|
||||||
{
|
{
|
||||||
return new StartingShift
|
if (startingShiftEmployee != null && startingShiftEmployee.Any())
|
||||||
{
|
{
|
||||||
Id = tempStartingShiftEmployee.Starting_shift_id,
|
Starting_shift_employees = startingShiftEmployee;
|
||||||
Date = tempStartingShiftEmployee.Date,
|
}
|
||||||
Route_list_id = tempStartingShiftEmployee.Route_list_id,
|
|
||||||
Bus_id = tempStartingShiftEmployee.Bus_id,
|
|
||||||
Starting_shift_employees = startingShiftEmployee
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
namespace ProjectPassengerTransportation.Entities;
|
using System.ComponentModel;
|
||||||
|
|
||||||
|
namespace ProjectPassengerTransportation.Entities;
|
||||||
|
|
||||||
public class StartingShiftEmployee
|
public class StartingShiftEmployee
|
||||||
{
|
{
|
||||||
@ -6,6 +8,8 @@ public class StartingShiftEmployee
|
|||||||
|
|
||||||
public int Employee_id { get; private set; }
|
public int Employee_id { get; private set; }
|
||||||
|
|
||||||
|
public string Employee_name { get; private set; } = string.Empty;
|
||||||
|
|
||||||
public int Work_time { get; private set; }
|
public int Work_time { get; private set; }
|
||||||
|
|
||||||
public static StartingShiftEmployee CreateElement(int startingShiftId, int employeeId, int workTime)
|
public static StartingShiftEmployee CreateElement(int startingShiftId, int employeeId, int workTime)
|
||||||
|
@ -13,7 +13,7 @@ namespace ProjectPassengerTransportation.Forms
|
|||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
_goToServiceRepository = goToServiceRepository ?? throw new ArgumentNullException(nameof(goToServiceRepository));
|
_goToServiceRepository = goToServiceRepository ?? throw new ArgumentNullException(nameof(goToServiceRepository));
|
||||||
comboBoxBus.DataSource = busRepository.ReadBuses();
|
comboBoxBus.DataSource = busRepository.ReadBuses();
|
||||||
comboBoxBus.DisplayMember = "Licence_plate";
|
comboBoxBus.DisplayMember = "Model_and_plate";
|
||||||
comboBoxBus.ValueMember = "Id";
|
comboBoxBus.ValueMember = "Id";
|
||||||
foreach (var elem in Enum.GetValues(typeof(BrokenElements)))
|
foreach (var elem in Enum.GetValues(typeof(BrokenElements)))
|
||||||
{
|
{
|
||||||
|
@ -17,10 +17,10 @@ namespace ProjectPassengerTransportation.Forms
|
|||||||
comboBoxRouteList.DisplayMember = "Id";
|
comboBoxRouteList.DisplayMember = "Id";
|
||||||
comboBoxRouteList.ValueMember = "Id";
|
comboBoxRouteList.ValueMember = "Id";
|
||||||
comboBoxBus.DataSource = busRepository.ReadBuses();
|
comboBoxBus.DataSource = busRepository.ReadBuses();
|
||||||
comboBoxBus.DisplayMember = "Licence_plate";
|
comboBoxBus.DisplayMember = "Model_and_plate";
|
||||||
comboBoxBus.ValueMember = "Id";
|
comboBoxBus.ValueMember = "Id";
|
||||||
ColumnEmployees.DataSource = employeeRepository.ReadEmployees();
|
ColumnEmployees.DataSource = employeeRepository.ReadEmployees();
|
||||||
ColumnEmployees.DisplayMember = "First_name";
|
ColumnEmployees.DisplayMember = "Full_name";
|
||||||
ColumnEmployees.ValueMember = "Id";
|
ColumnEmployees.ValueMember = "Id";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,10 +14,10 @@ namespace ProjectPassengerTransportation.Forms
|
|||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
_container = container ?? throw new ArgumentNullException(nameof(container));
|
_container = container ?? throw new ArgumentNullException(nameof(container));
|
||||||
comboBoxEmployee.DataSource = employeeRepository.ReadEmployees();
|
comboBoxEmployee.DataSource = employeeRepository.ReadEmployees();
|
||||||
comboBoxEmployee.DisplayMember = "First_name";
|
comboBoxEmployee.DisplayMember = "Full_name";
|
||||||
comboBoxEmployee.ValueMember = "Id";
|
comboBoxEmployee.ValueMember = "Id";
|
||||||
comboBoxBus.DataSource = busRepository.ReadBuses();
|
comboBoxBus.DataSource = busRepository.ReadBuses();
|
||||||
comboBoxBus.DisplayMember = "Licence_plate";
|
comboBoxBus.DisplayMember = "Model_and_plate";
|
||||||
comboBoxBus.ValueMember = "Id";
|
comboBoxBus.ValueMember = "Id";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,7 +66,12 @@ WHERE id=@id";
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
var querySelect = @"SELECT * FROM go_to_service";
|
var querySelect = @"
|
||||||
|
SELECT
|
||||||
|
gts.*,
|
||||||
|
b.licence_plate as Bus_name
|
||||||
|
FROM go_to_service gts
|
||||||
|
LEFT JOIN bus b on b.id = gts.bus_id";
|
||||||
var services = connection.Query<GoToService>(querySelect);
|
var services = connection.Query<GoToService>(querySelect);
|
||||||
_logger.LogDebug("Полученные объекты: {json}", JsonConvert.SerializeObject(services));
|
_logger.LogDebug("Полученные объекты: {json}", JsonConvert.SerializeObject(services));
|
||||||
return services;
|
return services;
|
||||||
|
@ -57,13 +57,38 @@ VALUES (@Starting_shift_id, @Employee_id, @Work_time)";
|
|||||||
{
|
{
|
||||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
var querySelect = @"
|
var querySelect = @"
|
||||||
SELECT sse.starting_shift_id, ss.date, ss.route_list_id, ss.bus_id, sse.employee_id, sse.work_time FROM starting_shift ss
|
SELECT
|
||||||
|
sse.starting_shift_id,
|
||||||
|
ss.date,
|
||||||
|
CONCAT(rl.route_start, '-', rl.route_finish) as Route_list_name,
|
||||||
|
CONCAT(b.model, ' ', b.licence_plate) as Bus_name,
|
||||||
|
sse.employee_id,
|
||||||
|
sse.work_time
|
||||||
|
FROM starting_shift ss
|
||||||
|
LEFT JOIN route_list rl on rl.id = ss.route_list_id
|
||||||
|
LEFT JOIN bus b on b.id = ss.bus_id
|
||||||
INNER JOIN starting_shift_employee sse ON sse.starting_shift_id = ss.id";
|
INNER JOIN starting_shift_employee sse ON sse.starting_shift_id = ss.id";
|
||||||
var startingShifts = connection.Query<TempStartingShiftEmployee>(querySelect);
|
var startingShiftDict = new Dictionary<int, List<StartingShiftEmployee>>();
|
||||||
|
|
||||||
|
var startingShifts = connection.Query<StartingShift, StartingShiftEmployee, StartingShift>(querySelect, (startingShift, startingShifts) =>
|
||||||
|
{
|
||||||
|
if (!startingShiftDict.TryGetValue(startingShift.Id, out var sse))
|
||||||
|
{
|
||||||
|
sse = [];
|
||||||
|
startingShiftDict.Add(startingShift.Id, sse);
|
||||||
|
}
|
||||||
|
sse.Add(startingShifts);
|
||||||
|
return startingShift;
|
||||||
|
}, splitOn: "Employee_id", param: new { dateFrom, dateTo, routeListId, employeeId, busId });
|
||||||
|
|
||||||
_logger.LogDebug("Полученные объекты: {json}", JsonConvert.SerializeObject(startingShifts));
|
_logger.LogDebug("Полученные объекты: {json}", JsonConvert.SerializeObject(startingShifts));
|
||||||
return startingShifts.GroupBy(x => x.Starting_shift_id, y => y,
|
|
||||||
(key, value) => StartingShift.CreateOperation(value.First(),
|
return startingShiftDict.Select(x =>
|
||||||
value.Select(z => StartingShiftEmployee.CreateElement(0, z.Employee_id, z.Work_time)))).ToList();
|
{
|
||||||
|
var ss = startingShifts.First(y => y.Id == x.Key);
|
||||||
|
ss.SetStartingShiftEmployee(x.Value);
|
||||||
|
return ss;
|
||||||
|
}).ToArray();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user