осталось внести небольшие правки
This commit is contained in:
parent
9f612adf6a
commit
46cb767fb0
@ -1,6 +1,8 @@
|
|||||||
using ProjectPeopleTransportation.Entities.Enums;
|
using DocumentFormat.OpenXml.EMMA;
|
||||||
|
using ProjectPeopleTransportation.Entities.Enums;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
@ -11,10 +13,13 @@ public class Bus
|
|||||||
{
|
{
|
||||||
public int ID { get; private set; }
|
public int ID { get; private set; }
|
||||||
|
|
||||||
|
[DisplayName("Модель автобуса")]
|
||||||
public string Bus_Name { get; private set; } = string.Empty;
|
public string Bus_Name { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
[DisplayName("Госномер")]
|
||||||
public string Licence_Plate { get; private set; } = string.Empty;
|
public string Licence_Plate { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
public string Model_and_plate => $"{Bus_Name} {Licence_Plate}";
|
||||||
public static Bus CreateEntity(int id, string busName, string licensePlate)
|
public static Bus CreateEntity(int id, string busName, string licensePlate)
|
||||||
{
|
{
|
||||||
return new Bus
|
return new Bus
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using ProjectPeopleTransportation.Entities.Enums;
|
using ProjectPeopleTransportation.Entities.Enums;
|
||||||
|
using System.ComponentModel;
|
||||||
|
|
||||||
namespace ProjectPeopleTransportation.Entities;
|
namespace ProjectPeopleTransportation.Entities;
|
||||||
|
|
||||||
@ -6,12 +7,21 @@ public class BusCheck
|
|||||||
{
|
{
|
||||||
public int ID { get; private set; }
|
public int ID { get; private set; }
|
||||||
|
|
||||||
|
[Browsable(false)]
|
||||||
public int Bus_ID { get; private set; }
|
public int Bus_ID { get; private set; }
|
||||||
|
|
||||||
|
[DisplayName("Автобус")]
|
||||||
|
public string Bus_Name { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
|
||||||
|
[DisplayName("Стоимость")]
|
||||||
public int Price { get; private set; }
|
public int Price { get; private set; }
|
||||||
|
|
||||||
|
[DisplayName("Дата проверки автобуса")]
|
||||||
public DateTime Date { get; private set; }
|
public DateTime Date { get; private set; }
|
||||||
|
|
||||||
|
|
||||||
|
[DisplayName("Тип элемента")]
|
||||||
public BusElementType Bus_Element_Type { get; private set; }
|
public BusElementType Bus_Element_Type { get; private set; }
|
||||||
|
|
||||||
public static BusCheck CreateOperation(int id, int busID, int price, BusElementType busElementType)
|
public static BusCheck CreateOperation(int id, int busID, int price, BusElementType busElementType)
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using ProjectPeopleTransportation.Entities.Enums;
|
using ProjectPeopleTransportation.Entities.Enums;
|
||||||
|
using System.ComponentModel;
|
||||||
|
|
||||||
namespace ProjectPeopleTransportation.Entities;
|
namespace ProjectPeopleTransportation.Entities;
|
||||||
|
|
||||||
@ -6,11 +7,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 employeePost)
|
public static Employee CreateEntity(int id, string first, string last, EmployeePost employeePost)
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
@ -13,10 +14,14 @@ public class RouteList
|
|||||||
{
|
{
|
||||||
public int Id { get; private set; }
|
public int Id { get; private set; }
|
||||||
|
|
||||||
|
[DisplayName("Название маршрута")]
|
||||||
public string Route_Name { get; private set; } = string.Empty;
|
public string Route_Name { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
[DisplayName("Описание маршрута")]
|
||||||
public string Route_Description { get; private set; } = string.Empty;
|
public string Route_Description { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
public string Route_desc_name => $"{Route_Name}-{Route_Description}";
|
||||||
|
|
||||||
public static RouteList CreateEntity(int id, string name, string description)
|
public static RouteList CreateEntity(int id, string name, string description)
|
||||||
{
|
{
|
||||||
return new RouteList
|
return new RouteList
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
using ProjectPeopleTransportation.Entities.Enums;
|
using ProjectPeopleTransportation.Entities.Enums;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
@ -12,12 +13,27 @@ public class StartingShift
|
|||||||
{
|
{
|
||||||
public int ID { get; private set; }
|
public int ID { get; private set; }
|
||||||
|
|
||||||
|
[Browsable(false)]
|
||||||
public int Route_List_ID { get; private set; }
|
public int Route_List_ID { get; private set; }
|
||||||
|
|
||||||
|
[DisplayName("Маршрутный лист")]
|
||||||
|
public string Route_List_Name { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
[Browsable(false)]
|
||||||
public int Bus_ID { get; private set; }
|
public int Bus_ID { get; private set; }
|
||||||
|
|
||||||
|
[DisplayName("Автобус")]
|
||||||
|
public string Bus_Name { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
|
||||||
|
[DisplayName("Дата смены")]
|
||||||
public DateTime Starting_Shift_Date { get; private set; }
|
public DateTime Starting_Shift_Date { get; private set; }
|
||||||
|
|
||||||
|
[DisplayName("Работники")]
|
||||||
|
public string Employee => StartingShiftEmployees != null ?
|
||||||
|
string.Join(", ", StartingShiftEmployees.Select(x => $"{x.Employee_name} {x.Shift_Duration}")) : string.Empty;
|
||||||
|
|
||||||
|
[Browsable(false)]
|
||||||
public IEnumerable<StartingShift_Employee> StartingShiftEmployees { get; private set; } = [];
|
public IEnumerable<StartingShift_Employee> StartingShiftEmployees { get; private set; } = [];
|
||||||
|
|
||||||
public static StartingShift CreateOperation(int id, int routeListID, int busID, IEnumerable<StartingShift_Employee> startingShiftEmployees)
|
public static StartingShift CreateOperation(int id, int routeListID, int busID, IEnumerable<StartingShift_Employee> startingShiftEmployees)
|
||||||
@ -32,16 +48,11 @@ public class StartingShift
|
|||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
public static StartingShift CreateOperation(TempStartingShift_Employee tempStartingShiftEmployee,
|
public void SetStartingShiftEmployee(IEnumerable<StartingShift_Employee> startingShiftEmployee)
|
||||||
IEnumerable<StartingShift_Employee> startingShiftEmployee)
|
|
||||||
{
|
{
|
||||||
return new StartingShift
|
if (startingShiftEmployee != null && startingShiftEmployee.Any())
|
||||||
{
|
{
|
||||||
ID = tempStartingShiftEmployee.Starting_shift_ID,
|
StartingShiftEmployees = startingShiftEmployee;
|
||||||
Starting_Shift_Date = tempStartingShiftEmployee.Starting_Shift_Date,
|
}
|
||||||
Route_List_ID = tempStartingShiftEmployee.Route_List_ID,
|
|
||||||
Bus_ID = tempStartingShiftEmployee.Bus_ID,
|
|
||||||
StartingShiftEmployees = startingShiftEmployee
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -6,6 +6,8 @@ public class StartingShift_Employee
|
|||||||
|
|
||||||
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 Shift_Duration { get; private set; }
|
public int Shift_Duration { get; private set; }
|
||||||
|
|
||||||
public static StartingShift_Employee CreateElement(int id, int employeeID, int shiftDuration)
|
public static StartingShift_Employee CreateElement(int id, int employeeID, int shiftDuration)
|
||||||
|
@ -26,7 +26,7 @@ namespace ProjectPeopleTransportation.Forms
|
|||||||
throw new ArgumentNullException(nameof(busCheckRepository));
|
throw new ArgumentNullException(nameof(busCheckRepository));
|
||||||
|
|
||||||
comboBoxBus.DataSource = busRepository.ReadBuses();
|
comboBoxBus.DataSource = busRepository.ReadBuses();
|
||||||
comboBoxBus.DisplayMember = "BusName";
|
comboBoxBus.DisplayMember = "Model_and_plate";
|
||||||
comboBoxBus.ValueMember = "Id";
|
comboBoxBus.ValueMember = "Id";
|
||||||
|
|
||||||
foreach (var elem in Enum.GetValues(typeof(BusElementType)))
|
foreach (var elem in Enum.GetValues(typeof(BusElementType)))
|
||||||
|
@ -71,7 +71,12 @@ namespace ProjectPeopleTransportation.Forms
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LoadList() => dataGridViewCheck.DataSource = _busCheckRepository.ReadBusCheck();
|
private void LoadList()
|
||||||
|
{
|
||||||
|
dataGridViewCheck.DataSource = _busCheckRepository.ReadBusCheck();
|
||||||
|
dataGridViewCheck.Columns["ID"].Visible = false;
|
||||||
|
dataGridViewCheck.Columns["Date"].DefaultCellStyle.Format = "dd.MM.yyyy";
|
||||||
|
}
|
||||||
|
|
||||||
private bool TryGetIdentifierFromSelectedRow(out int id)
|
private bool TryGetIdentifierFromSelectedRow(out int id)
|
||||||
{
|
{
|
||||||
|
@ -16,11 +16,11 @@ namespace ProjectPeopleTransportation.Forms
|
|||||||
throw new ArgumentNullException(nameof(startingShiftRepository));
|
throw new ArgumentNullException(nameof(startingShiftRepository));
|
||||||
|
|
||||||
ColumnEmployees.DataSource = employeeRepository.ReadEmployees();
|
ColumnEmployees.DataSource = employeeRepository.ReadEmployees();
|
||||||
ColumnEmployees.DisplayMember = "First_Name";
|
ColumnEmployees.DisplayMember = "Full_name";
|
||||||
ColumnEmployees.ValueMember = "Id";
|
ColumnEmployees.ValueMember = "Id";
|
||||||
|
|
||||||
comboBoxBus.DataSource = busRepository.ReadBuses();
|
comboBoxBus.DataSource = busRepository.ReadBuses();
|
||||||
comboBoxBus.DisplayMember = "Bus_Name";
|
comboBoxBus.DisplayMember = "Model_and_plate";
|
||||||
comboBoxBus.ValueMember = "Id";
|
comboBoxBus.ValueMember = "Id";
|
||||||
|
|
||||||
comboBoxRoute.DataSource = routeListRepository.ReadRouteLists();
|
comboBoxRoute.DataSource = routeListRepository.ReadRouteLists();
|
||||||
@ -69,7 +69,8 @@ namespace ProjectPeopleTransportation.Forms
|
|||||||
Convert.ToInt32(row.Cells["ColumnEmployees"].Value),
|
Convert.ToInt32(row.Cells["ColumnEmployees"].Value),
|
||||||
Convert.ToInt32(row.Cells["ColumnShiftDuration"].Value)));
|
Convert.ToInt32(row.Cells["ColumnShiftDuration"].Value)));
|
||||||
}
|
}
|
||||||
return list;
|
return list.GroupBy(x => x.Employee_ID, x => x.Shift_Duration, (employeeId, shiftduration) =>
|
||||||
|
StartingShift_Employee.CreateElement(0, employeeId, shiftduration.Sum())).ToList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -50,6 +50,11 @@ namespace ProjectPeopleTransportation.Forms
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LoadList() => dataGridViewData.DataSource = _startingShiftRepository.ReadStartingShifts();
|
private void LoadList()
|
||||||
}
|
{
|
||||||
|
dataGridViewData.DataSource = _startingShiftRepository.ReadStartingShifts();
|
||||||
|
dataGridViewData.Columns["ID"].Visible = false;
|
||||||
|
dataGridViewData.Columns["Starting_Shift_Date"].DefaultCellStyle.Format = "dd MMMM yyyy hh:mm";
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -64,7 +64,11 @@ WHERE id=@id";
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
var querySelect = @"SELECT * FROM bus_check";
|
var querySelect = @"SELECT
|
||||||
|
gts.*,
|
||||||
|
b.licence_plate as Bus_name
|
||||||
|
FROM bus_check gts
|
||||||
|
LEFT JOIN bus b on b.id = gts.bus_id";
|
||||||
var services = connection.Query<BusCheck>(querySelect);
|
var services = connection.Query<BusCheck>(querySelect);
|
||||||
_logger.LogDebug("Полученные объекты: {json}", JsonConvert.SerializeObject(services));
|
_logger.LogDebug("Полученные объекты: {json}", JsonConvert.SerializeObject(services));
|
||||||
return services;
|
return services;
|
||||||
|
@ -56,10 +56,37 @@ VALUES (@Starting_shift_id, @Employee_id, @Shift_Duration)";
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
var querySelect = @"SELECT * FROM starting_shift";
|
var querySelect = @"SELECT
|
||||||
var startingShifts = connection.Query<StartingShift>(querySelect);
|
sse.starting_shift_id,
|
||||||
|
ss.starting_shift_date,
|
||||||
|
CONCAT(rl.route_name, '-', rl.route_description) as Route_Name,
|
||||||
|
CONCAT(b.bus_name, ' ', b.licence_plate) as Bus_name,
|
||||||
|
sse.employee_id,
|
||||||
|
sse.shift_duration
|
||||||
|
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";
|
||||||
|
var startingShiftDict = new Dictionary<int, List<StartingShift_Employee>>();
|
||||||
|
|
||||||
|
var startingShifts = connection.Query<StartingShift, StartingShift_Employee, 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 { routelistId, employeeId, dateForm, dateTo, busId });
|
||||||
|
|
||||||
_logger.LogDebug("Полученные объекты: {json}", JsonConvert.SerializeObject(startingShifts));
|
_logger.LogDebug("Полученные объекты: {json}", JsonConvert.SerializeObject(startingShifts));
|
||||||
return startingShifts;
|
return startingShiftDict.Select(x =>
|
||||||
|
{
|
||||||
|
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