This commit is contained in:
Pipiaka 2024-12-14 19:11:02 +04:00
parent 37f7893c03
commit e3edb20bb8

View File

@ -1,4 +1,5 @@

using Accounting_Time_It_Company.Entities;
using Accounting_Time_It_Company.Repositories;
using Microsoft.Extensions.Logging;
@ -29,10 +30,9 @@ internal class TableReport
try
{
new ExcelBuilder(filePath)
.AddHeader("Сводка по движению корма", 0, 4)
.AddHeader("Сводка по работе сотрудников", 0, 4)
.AddParagraph("за период", 0)
.AddTable([10, 10, 15, 15], GetData(feedId, startDate,
endDate)).Build();
.AddTable([10, 10, 15, 15], GetData(feedId, startDate, endDate)).Build();
return true;
}
catch (Exception ex)
@ -42,42 +42,42 @@ internal class TableReport
}
}
private List<string[]> GetData(int feedId, DateTime startDate, DateTime endDate)
private List<string[]> GetData(int employeeId, DateTime startDate, DateTime endDate)
{
var data = _feedReplenishmentRepository
.ReadFeedReplenishment()
.Where(x => x.DateReceipt >= startDate && x.DateReceipt <=
endDate && x.FeedFeedReplenishments.Any(y => y.FeedId == feedId))
var data = _typeJobRepositories
.ReadTypeJobs()
.Where(x => x.Date >= startDate && x.Date <= endDate
&& (x.WorkTimesDevelop.Any(y => y.EmployeeId == employeeId)
|| x.WorkTimesManager.Any(y => y.EmployeeId == employeeId)))
.Select(x => new {
x.EmployeeId,
Date = x.DateReceipt,
CountIn
= x.FeedFeedReplenishments.FirstOrDefault(y => y.FeedId == feedId)?.Count,
CountOut = (int?)null
x.ProductId,
x.Date,
CountInManager = x.WorkTimesManager.FirstOrDefault(y => y.EmployeeId == employeeId)?.Hours,
CountOutManager = (int?)null,
CountInDevelop = x.WorkTimesDevelop.FirstOrDefault(y => y.EmployeeId == employeeId)?.Hours,
CountOutDevelop = (int?)null
})
.Union(
_feedingAnimalRepository
.ReadFeedingAnimals()
.Where(x => x.FeedingDate >= startDate &&
x.FeedingDate <= endDate && x.FeedId == feedId)
.Union(_vacationRepositories
.ReadVacations()
.Where(x => x.StartDate >= startDate
&& x.StartDate <= endDate
&& x.EmployeeId == employeeId)
.Select(x => new {
x.EmployeeId,
Date =
x.FeedingDate,
Date = x.StartDate,
CountIn = (int?)null,
CountOut = (int?)x.Ration
}))
.OrderBy(x => x.Date);
return
new List<string[]>() { item }
.Union(
data
.Select(x => new string[] {
x.EmployeeId.ToString(), x.Date.ToString(), x.CountIn?.ToString() ??
string.Empty, x.CountOut?.ToString() ?? string.Empty}))
.Union(data.Select(x => new string[] {
x.EmployeeId.ToString(), x.Date.ToString(), x.CountIn?.ToString() ??
string.Empty, x.CountOut?.ToString() ?? string.Empty}))
.Union(
[["Всего", "", data.Sum(x => x.CountIn ?? 0).ToString(),
data.Sum(x => x.CountOut ?? 0).ToString()]])
data.Sum(x => x.CountOut ?? 0).ToString()]])
.ToList();
}
}