using GB5Shared.DTO.Framework.Login; using GB5Shared.QueryExecutor; using WiDAL.DTOs; using WiDAL.Query.Wi; namespace WiDAL.CustomCode.LineProductionPlanAllocation; public class LineProductionPlanAllocationDAL : ILineProductionPlanAllocationDAL { private readonly IQueryExecutor _qe; public LineProductionPlanAllocationDAL(IQueryExecutor qe) => _qe = qe; public async Task> GetByLineDateShift( int productionLineId, DateOnly allocationDate, int shiftId, LoginDTO login, CancellationToken ct) { return await _qe.QueryAsync(login, LineProductionPlanAllocationQB.GET_BY_LINE_DATE_SHIFT, new { ProductionLineId = productionLineId, AllocationDate = allocationDate, ShiftId = shiftId, TenantId = login.ClientId }, cancellationToken: ct).ConfigureAwait(false); } public async Task> GetByPlanDetail( int productionPlanDetailId, LoginDTO login, CancellationToken ct) { return await _qe.QueryAsync(login, LineProductionPlanAllocationQB.GET_BY_PLAN_DETAIL, new { ProductionPlanDetailId = productionPlanDetailId, TenantId = login.ClientId }, cancellationToken: ct).ConfigureAwait(false); } public async Task InsertAllocation(LineProductionPlanAllocationDTO dto, LoginDTO login, CancellationToken ct) { return await _qe.ExecuteAsync(login, LineProductionPlanAllocationQB.INSERT_ALLOCATION, new { dto.LineAllocationId, dto.ProductionPlanDetailId, dto.ProductionLineId, dto.ShiftId, dto.AllocationDate, dto.WorkStationId, dto.StartMinutes, dto.EndMinutes, dto.AllocatedQuantity, dto.Remarks, dto.Status, dto.CreatedById, dto.ModifiedById, dto.SourceType, dto.TenantId }, cancellationToken: ct).ConfigureAwait(false); } public async Task UpdateAllocation(LineProductionPlanAllocationDTO dto, LoginDTO login, CancellationToken ct) { return await _qe.ExecuteAsync(login, LineProductionPlanAllocationQB.UPDATE_ALLOCATION, new { dto.LineAllocationId, dto.ProductionLineId, dto.ShiftId, dto.AllocationDate, dto.WorkStationId, dto.StartMinutes, dto.EndMinutes, dto.AllocatedQuantity, dto.Remarks, dto.ModifiedById, dto.TenantId }, cancellationToken: ct).ConfigureAwait(false); } public async Task DeleteAllocation(int lineAllocationId, LoginDTO login, CancellationToken ct) { return await _qe.ExecuteAsync(login, LineProductionPlanAllocationQB.DELETE_ALLOCATION, new { LineAllocationId = lineAllocationId, TenantId = login.ClientId }, cancellationToken: ct).ConfigureAwait(false); } public async Task GetLineDateShiftForAllocation(int lineAllocationId, LoginDTO login, CancellationToken ct) { var rows = await _qe.QueryAsync(login, LineProductionPlanAllocationQB.GET_LINE_DATE_SHIFT_FOR_ALLOCATION, new { LineAllocationId = lineAllocationId, TenantId = login.ClientId }, cancellationToken: ct).ConfigureAwait(false); return rows.FirstOrDefault(); } }