98 lines
3.2 KiB
C#
98 lines
3.2 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using BeWo.Report;
|
|
using BeWo.Report.ReportObjects;
|
|
using BS.Shared.Core;
|
|
using BS.Shared.Extensions;
|
|
|
|
namespace ArcheTecklenburg
|
|
{
|
|
[IDSpecificClass(Identifier = "Teamstundenkonto")]
|
|
public partial class Teamstundenkonto : DevExpress.XtraReports.UI.XtraReport, IBeWoReport<MitarbeiterstundenkontoRO>
|
|
{
|
|
|
|
|
|
public Teamstundenkonto()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
public void SetReportDataSource(MitarbeiterstundenkontoRO pRO)
|
|
{
|
|
var msb = new CustomMitarbeiterstundenkontoBerechnung();
|
|
msb.CreateReport(pRO);
|
|
|
|
decimal samstag = 0;
|
|
decimal sonntag = 0;
|
|
decimal feiertag = 0;
|
|
decimal nacht = 0;
|
|
|
|
// Prüfen, wie oft der MA in allen Teams vorkommt und Stunden da durch teilen, da die Stunden sonst mehrfach gezählt werden
|
|
Dictionary<long, int> employeeZuVorkommenInTeams = new Dictionary<long, int>();
|
|
foreach (var team in pRO.TeamDetailList)
|
|
{
|
|
foreach (var emp in team.EmployeeDetailList)
|
|
{
|
|
if (employeeZuVorkommenInTeams.ContainsKey(emp.Employee.Oid.Value))
|
|
employeeZuVorkommenInTeams[emp.Employee.Oid.Value]++;
|
|
else
|
|
employeeZuVorkommenInTeams.Add(emp.Employee.Oid.Value, 1);
|
|
}
|
|
}
|
|
|
|
foreach (var team in pRO.TeamDetailList)
|
|
{
|
|
foreach (var emp in team.EmployeeDetailList)
|
|
{
|
|
foreach (var day in emp.Days)
|
|
{
|
|
// Custom1 Samstagsarbeit 13-21 Uhr
|
|
if (day.ServiceRecords != null && day.ServiceRecords.Count > 0)
|
|
{
|
|
foreach (var sr in day.ServiceRecords)
|
|
{
|
|
var d1 = sr.Start;
|
|
|
|
var saturday = d1.GetNextDayOfWeek(DayOfWeek.Saturday);
|
|
var unroundedEnd = d1.AddMinutes(sr.DurationMinutes);
|
|
var saturdayStart = new DateTime(saturday.Year, saturday.Month, saturday.Day, 13, 0, 0);
|
|
var saturdayEnd = new DateTime(saturday.Year, saturday.Month, saturday.Day, 21, 0, 0);
|
|
|
|
emp.Custom1 += Math.Round((decimal)d1.GetIntersectingMinutes(unroundedEnd, saturdayStart, saturdayEnd) / 60, 2, MidpointRounding.AwayFromZero) / employeeZuVorkommenInTeams[emp.Employee.Oid.Value];
|
|
samstag += Math.Round((decimal)d1.GetIntersectingMinutes(unroundedEnd, saturdayStart, saturdayEnd) / 60, 2, MidpointRounding.AwayFromZero) / employeeZuVorkommenInTeams[emp.Employee.Oid.Value];
|
|
}
|
|
}
|
|
|
|
//// Custom2 Sonntagsarbeit
|
|
//emp.Custom2 += day.HoursSunday;
|
|
//sonntag += day.HoursSunday;
|
|
|
|
//// Custom3 Feiertagsarbeit
|
|
//emp.Custom3 += day.HoursHoliday;
|
|
//feiertag += day.HoursHoliday;
|
|
}
|
|
// Custom2 Sonntagsarbeit
|
|
emp.Custom2 = emp.Days.Sum(d => d.HoursSunday) / employeeZuVorkommenInTeams[emp.Employee.Oid.Value];
|
|
sonntag += emp.Custom2;
|
|
// Custom3 Feiertagsarbeit
|
|
emp.Custom3 = emp.Days.Sum(d => d.HoursHoliday) / employeeZuVorkommenInTeams[emp.Employee.Oid.Value];
|
|
feiertag += emp.Custom3;
|
|
// Custom4 Nachtarbeit
|
|
emp.Custom4 = emp.Days.Sum(d => d.SpecialHours) / employeeZuVorkommenInTeams[emp.Employee.Oid.Value];
|
|
nacht += emp.Custom4;
|
|
|
|
}
|
|
}
|
|
|
|
pRO.FlsDiffGesamt = samstag;
|
|
pRO.FlsIstGesamt = sonntag;
|
|
pRO.FlsSollGesamt = feiertag;
|
|
pRO.MittelbarIst = nacht;
|
|
|
|
bindingSource1.DataSource = pRO;
|
|
}
|
|
|
|
}
|
|
}
|