MH: Änderungen an Dienst- und Urlaubsplan + Anpassung für Bewolonia
This commit is contained in:
@@ -15,7 +15,7 @@ namespace BeWo.Service.Dienstplanung
|
||||
{
|
||||
internal class DienstplanungsManager
|
||||
{
|
||||
public static DienstplanerRootDC BuildDienstplanerRootObject()
|
||||
public static DienstplanerRootDC BuildDienstplanerRootObject(DateTime date, long wohnheimOid)
|
||||
{
|
||||
DienstplanerRootDC root = new DienstplanerRootDC();
|
||||
|
||||
@@ -24,13 +24,28 @@ namespace BeWo.Service.Dienstplanung
|
||||
|
||||
root.TextBoxForeColor = GetColorForForeground();
|
||||
|
||||
return root;
|
||||
}
|
||||
public static DienstplanerRootDC AddMissingDataToDienstplanerRootObject(DienstplanerRootDC root, DateTime date, long wohnheimOid)
|
||||
{
|
||||
root.AlleDienstEintraege = GetAllDienstEintraegeAsList(wohnheimOid, date.Year, date.Month);
|
||||
root.AlleDienstvertretungen = GetAllDienstvertretungenAsList(wohnheimOid, date.Year, date.Month);
|
||||
foreach (var e in root.AlleDienstEintraege)
|
||||
{
|
||||
if (String.IsNullOrEmpty(e.Startzeit) || String.IsNullOrEmpty(e.Endzeit))
|
||||
{
|
||||
var d = root.AlleDienste.FirstOrDefault(a => a.Oid == e.DienstOid);
|
||||
if (d != null)
|
||||
{
|
||||
if (String.IsNullOrEmpty(e.Startzeit))
|
||||
{
|
||||
e.Startzeit = String.Format("{0:HH:mm}", d.Start);
|
||||
}
|
||||
|
||||
if (String.IsNullOrEmpty(e.Endzeit))
|
||||
{
|
||||
e.Endzeit = String.Format("{0:HH:mm}", d.Ende);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
root.AlleDienstvertretungen = GetAllDienstvertretungenAsList(wohnheimOid, date.Year, date.Month);
|
||||
|
||||
root.DienstDCListe = GetDienstEintraege(wohnheimOid, date.Year, date.Month);
|
||||
root.DienstDCListe.AddRange(GetDienstvertretungen(wohnheimOid, date.Year, date.Month));
|
||||
root.DienstDCListe = root.DienstDCListe.OrderBy(d => d.Employee.LastName).ToList();
|
||||
@@ -80,10 +95,7 @@ namespace BeWo.Service.Dienstplanung
|
||||
{
|
||||
var res = new List<DienstEintragDC>();
|
||||
|
||||
var dienstEintraege = DAOFactory.GenericDAO.GetAllActive<DienstEintrag>().Where(x =>
|
||||
x.WohnheimOid == wOid &&
|
||||
x.Datum.Month == month &&
|
||||
x.Datum.Year == year);
|
||||
var dienstEintraege = DAOFactory.SearchDAO.GetAllDienstEintraege(wOid, new DateTime(year, month, 1), new DateTime(year, month, 1).AddMonths(1).AddMinutes(-1));
|
||||
|
||||
var dienstEintraegeDC = MapperFactory.DienstEintragDC_DienstEintrag.MapToNewDCs(dienstEintraege);
|
||||
res.AddRange(dienstEintraegeDC);
|
||||
@@ -148,6 +160,45 @@ namespace BeWo.Service.Dienstplanung
|
||||
res.Add(zeile);
|
||||
}
|
||||
|
||||
//Frühere Schichten entfernter Mitarbeiter anzeigen lassen
|
||||
List<long?> oids = new List<long?>();
|
||||
foreach (var emp in empsDC)
|
||||
oids.Add(emp.EmployeeOid);
|
||||
|
||||
foreach (var eintrag in dienstEintraegeDC)
|
||||
{
|
||||
if(!oids.Contains(eintrag.EmployeeOid))
|
||||
{
|
||||
var emp = MapperFactory.EmployeeDC_Employee.MapToNewDC(DAOFactory.GenericDAO.GetByID<Employee>(eintrag.EmployeeOid));
|
||||
|
||||
var contracts = emp.Contracts.Where(x => (!x.EntryDate.HasValue || x.EntryDate.Value <= date2) &&
|
||||
(!x.ContractEndDate.HasValue || x.ContractEndDate.Value >= date))
|
||||
.OrderBy(x => x.EntryDate)
|
||||
.ToList();
|
||||
|
||||
var zeile = new DienstBlockDC
|
||||
{
|
||||
Employee = emp,
|
||||
Contracts = contracts,
|
||||
Wohnheim = whDC,
|
||||
DienstDictArray = new Dictionary<int, long>[3]
|
||||
};
|
||||
|
||||
for (int i = 0; i < zeile.DienstDictArray.Length; i++)
|
||||
{
|
||||
var empDienste = dienstEintraegeDC
|
||||
.Where(x => x.EmployeeOid == emp.EmployeeOid && x.Zeile == i);
|
||||
|
||||
zeile.DienstDictArray[i] = empDienste
|
||||
.ToDictionary(x => x.Datum.Day, x => x.DienstOid);
|
||||
}
|
||||
|
||||
oids.Add(eintrag.EmployeeOid);
|
||||
|
||||
res.Add(zeile);
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
|
||||
}
|
||||
|
||||
464
Service/Dienstplanung/Mitarbeiterstundenkonto.cs
Normal file
464
Service/Dienstplanung/Mitarbeiterstundenkonto.cs
Normal file
@@ -0,0 +1,464 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Windows.Ink;
|
||||
using BS.Shared.Core;
|
||||
using BeWo.Data.Access;
|
||||
using BeWo.Data.Entities;
|
||||
using BS.Shared;
|
||||
using BS.Shared.DataContracts;
|
||||
using BS.Shared.Extensions;
|
||||
|
||||
namespace BeWo.Service.Dienstplanung
|
||||
{
|
||||
public class MitarbeiterstundenkontoRO
|
||||
{
|
||||
List<EmployeeDetail> _EmployeeDetailList = new List<EmployeeDetail>();
|
||||
List<TeamDetail> _TeamDetailList = new List<TeamDetail>();
|
||||
|
||||
public DateTime ReportStartDate { get; set; }
|
||||
public DateTime ReportEndDate { get; set; }
|
||||
public decimal SollGesamt { get; set; }
|
||||
|
||||
public decimal FlsSollGesamt { get; set; }
|
||||
|
||||
public decimal FlsIstGesamt { get; set; }
|
||||
|
||||
public decimal FlsDiffGesamt { get; set; }
|
||||
|
||||
public decimal StundenGesamt { get; set; }
|
||||
|
||||
public decimal RelationIstSollGesamt { get; set; }
|
||||
|
||||
public decimal MittelbarIst { get; set; }
|
||||
|
||||
public decimal RelationFlsZuMittelbar { get; set; }
|
||||
|
||||
public List<EmployeeDetail> EmployeeDetailList
|
||||
{
|
||||
get { return this._EmployeeDetailList; }
|
||||
|
||||
set { this._EmployeeDetailList = value; }
|
||||
}
|
||||
|
||||
public List<TeamDetail> TeamDetailList
|
||||
{
|
||||
get { return this._TeamDetailList; }
|
||||
|
||||
set { this._TeamDetailList = value; }
|
||||
}
|
||||
|
||||
public static MitarbeiterstundenkontoRO Create(long? employeeOid, IList<long> teamOids, DateTime startDate, DateTime endDate, IEnumerable<long> employeeOids)
|
||||
{
|
||||
Team team = null;
|
||||
|
||||
Dictionary<long, bool> empOidDict = new Dictionary<long, bool>();
|
||||
|
||||
var ro = new MitarbeiterstundenkontoRO {ReportStartDate = startDate, ReportEndDate = endDate};
|
||||
|
||||
IList<Employee> employees = null;
|
||||
|
||||
if (employeeOid.HasValue)
|
||||
{
|
||||
var emp = DAOFactory.GenericDAO.GetByID<Employee>(employeeOid.Value);
|
||||
employees = new List<Employee> {emp};
|
||||
}
|
||||
else if (teamOids != null)
|
||||
{
|
||||
foreach (var teamOid in teamOids)
|
||||
{
|
||||
team = DAOFactory.GenericDAO.GetByID<Team>(teamOid);
|
||||
if (employees == null)
|
||||
{
|
||||
employees = team.MemberList;
|
||||
}
|
||||
else
|
||||
{
|
||||
employees.AddRange(team.MemberList);
|
||||
team = null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
else if(employeeOids != null)
|
||||
{
|
||||
employees = DAOFactory.GenericDAO.LoadByIDs<Employee>(employeeOids);
|
||||
}
|
||||
else
|
||||
{
|
||||
employees = DAOFactory.GenericDAO.GetAllActiveAndArchived<Employee>();
|
||||
|
||||
}
|
||||
|
||||
if (employees == null)
|
||||
{
|
||||
employees = new List<Employee>();
|
||||
}
|
||||
foreach (var emp in employees)
|
||||
{
|
||||
if (!empOidDict.ContainsKey(emp.Oid.Value))
|
||||
{
|
||||
var empDetail = new EmployeeDetail();
|
||||
|
||||
bool add = true;
|
||||
|
||||
if (emp.IsActive == ActivationTypeId.Archived)
|
||||
{
|
||||
Contract c = emp.GetValidContractForDate(ro.ReportStartDate);
|
||||
|
||||
if (c == null) // Kein Vertrag vom 1. gefunden, gucken, ob es einen gibt, der mitten im Monat beginnt.
|
||||
{
|
||||
var c2 = GetNextValidContractForDate(ro.ReportStartDate, emp);
|
||||
if (c2 != null && c2.EntryDate.HasValue && c2.EntryDate.Value < ro.ReportEndDate)
|
||||
c = c2;
|
||||
}
|
||||
if (c == null)
|
||||
{
|
||||
add = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (add)
|
||||
{
|
||||
ro.EmployeeDetailList.Add(CreateEmployeeDetail(emp, team));
|
||||
}
|
||||
|
||||
if (!empOidDict.ContainsKey(emp.Oid.Value))
|
||||
{
|
||||
empOidDict.Add(emp.Oid.Value, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var teamOid2Details = new Dictionary<long, TeamDetail>();
|
||||
|
||||
foreach (var employee in ro.EmployeeDetailList)
|
||||
{
|
||||
if (employee.Teams.Count > 0)
|
||||
{
|
||||
foreach (var t in employee.Teams)
|
||||
{
|
||||
TeamDetail td;
|
||||
if (!teamOid2Details.ContainsKey(t.Oid.Value))
|
||||
{
|
||||
td = new TeamDetail {TeamName = t.Name, TeamLeader = t.Leader};
|
||||
ro.TeamDetailList.Add(td);
|
||||
teamOid2Details.Add(t.Oid.Value, td);
|
||||
}
|
||||
else
|
||||
{
|
||||
td = teamOid2Details[t.Oid.Value];
|
||||
}
|
||||
td.EmployeeDetailList.Add(employee);
|
||||
}
|
||||
}
|
||||
}
|
||||
ro.TeamDetailList.Sort((t1, t2) => t1.TeamName.CompareTo(t2.TeamName));
|
||||
foreach (var teamDetail in ro.TeamDetailList)
|
||||
{
|
||||
if (teamDetail.EmployeeDetailList != null)
|
||||
{
|
||||
teamDetail.EmployeeDetailList.Sort((e1, e2) => e1.FullName.CompareTo(e2.FullName));
|
||||
}
|
||||
}
|
||||
ro.EmployeeDetailList.Sort((e1, e2) => e1.FullName.CompareTo(e2.FullName));
|
||||
return ro;
|
||||
}
|
||||
|
||||
private static Contract GetNextValidContractForDate(DateTime dt, Employee emp)
|
||||
{
|
||||
Contract contractNextToStartDate = emp.GetValidContractForDate(dt);
|
||||
|
||||
if (contractNextToStartDate == null)
|
||||
{
|
||||
|
||||
foreach (var item in emp.Contracts)
|
||||
{
|
||||
if (item.EntryDate.HasValue && item.EntryDate.Value >= dt)
|
||||
{
|
||||
if (contractNextToStartDate == null || item.EntryDate.Value < contractNextToStartDate.EntryDate.Value)
|
||||
{
|
||||
contractNextToStartDate = item;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
return contractNextToStartDate;
|
||||
}
|
||||
|
||||
public class TeamDetail
|
||||
{
|
||||
private List<EmployeeDetail> _EmployeeDetailList = new List<EmployeeDetail>();
|
||||
|
||||
public string TeamName { get; set; }
|
||||
|
||||
public Employee TeamLeader { get; set; }
|
||||
|
||||
public decimal SollGesamt { get; set; }
|
||||
|
||||
public decimal FlsSollGesamt { get; set; }
|
||||
|
||||
public decimal FlsIstGesamt { get; set; }
|
||||
|
||||
public decimal FlsDiffGesamt { get; set; }
|
||||
|
||||
public decimal StundenGesamt { get; set; }
|
||||
|
||||
public decimal RelationIstSollGesamt { get; set; }
|
||||
|
||||
public decimal MittelbarIst { get; set; }
|
||||
|
||||
public decimal RelationFlsZuMittelbar { get; set; }
|
||||
|
||||
public List<EmployeeDetail> EmployeeDetailList
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._EmployeeDetailList;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
this._EmployeeDetailList = value;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class EmployeeDetail
|
||||
{
|
||||
public IList<Team> Teams { get; set; }
|
||||
|
||||
public IList<DayDetail> Days { get; set; }
|
||||
|
||||
public IList<ServiceRecord> ServiceRecordsInSelectedTimeSpan { get; set; }
|
||||
|
||||
public Employee Employee { get; set; }
|
||||
|
||||
public string FirstName { get; set; }
|
||||
|
||||
public string LastName { get; set; }
|
||||
|
||||
public string FullName { get; set; }
|
||||
|
||||
public bool HasContract { get; set; }
|
||||
|
||||
public decimal FlsIst { get; set; }
|
||||
|
||||
public decimal MittelbarIst { get; set; }
|
||||
|
||||
public decimal Bu { get; set; }
|
||||
|
||||
public decimal StundenSollMax { get; set; }
|
||||
|
||||
//FLS Max - Urlaub/Krankheit und Fortbildung
|
||||
public decimal StundenSollOhneUrlaubKrankheit { get; set; }
|
||||
|
||||
public decimal FlsSoll { get; set; }
|
||||
|
||||
public decimal FlsDiff { get; set; }
|
||||
|
||||
public decimal? Fehlzeiten { get; set; }
|
||||
|
||||
public decimal? TageUrlaub { get; set; }
|
||||
|
||||
public decimal? TageKrankheit { get; set; }
|
||||
|
||||
public decimal? UrlaubUndKrankheit { get; set; }
|
||||
|
||||
public decimal? UrlaubGesamtImAktuellenJahr { get; set; }
|
||||
|
||||
public decimal? UrlaubSoll { get; set; }
|
||||
|
||||
public decimal? UrlaubsKonto { get; set; }
|
||||
|
||||
public decimal StundenMittelbarIst { get; set; }
|
||||
|
||||
public decimal StundenGesamtIst { get; set; }
|
||||
|
||||
public decimal RelationFlsZuMittelbar { get; set; }
|
||||
|
||||
public decimal RelationIstSoll { get; set; }
|
||||
|
||||
public decimal? Ueberstunden { get; set; }
|
||||
|
||||
public decimal? UeberstundenVormonat { get; set; }
|
||||
|
||||
public decimal? UeberstundenGesamt { get; set; }
|
||||
|
||||
public decimal UeberstundenAusbezahlt { get; set; }
|
||||
|
||||
public decimal WorkDaysThisMonth { get; set; }
|
||||
|
||||
public decimal SollProTag { get; set; }
|
||||
|
||||
public decimal SollProWoche { get; set; }
|
||||
|
||||
public decimal Custom1 { get; set; }
|
||||
|
||||
public decimal Custom2 { get; set; }
|
||||
|
||||
public decimal Custom3 { get; set; }
|
||||
|
||||
public decimal Custom4 { get; set; }
|
||||
|
||||
public decimal Custom5 { get; set; }
|
||||
|
||||
public decimal Custom6 { get; set; }
|
||||
|
||||
public decimal Custom7 { get; set; }
|
||||
|
||||
public decimal Custom8 { get; set; }
|
||||
|
||||
public decimal Custom9 { get; set; }
|
||||
|
||||
public decimal Custom10 { get; set; }
|
||||
|
||||
public String Regelarbeitszeit { get; set; }
|
||||
|
||||
public int ArbeitstageProWoche { get; set; }
|
||||
|
||||
public decimal ArbeitstageImBerichtszeitraum { get; set; }
|
||||
|
||||
public AbsenceTimeDays AbsenceTimeDays { get; set; }
|
||||
public decimal? HourlyRate { get; set; }
|
||||
public decimal? WeeklyFLS { get; set; }
|
||||
public decimal? EmployeeSalaryByContract { get; set; }
|
||||
public decimal? EmployeeSalaryByHours { get; set; }
|
||||
public EmploymentType EmploymentType { get; set; }
|
||||
}
|
||||
|
||||
public class DayDetail
|
||||
{
|
||||
public DateTime Date { get; set; }
|
||||
|
||||
public DateTime? StartDateTime1 { get; set; }
|
||||
public DateTime? EndDateTime1 { get; set; }
|
||||
|
||||
public DateTime? StartDateTime2 { get; set; }
|
||||
public DateTime? EndDateTime2 { get; set; }
|
||||
|
||||
public DateTime? StartDateTime3 { get; set; }
|
||||
public DateTime? EndDateTime3 { get; set; }
|
||||
|
||||
public DateTime? StartDateTime4 { get; set; }
|
||||
public DateTime? EndDateTime4 { get; set; }
|
||||
|
||||
public decimal HoursSaturday { get; set; }
|
||||
|
||||
public decimal HoursSunday { get; set; }
|
||||
|
||||
public decimal HoursHoliday { get; set; }
|
||||
|
||||
public decimal HoursHoliday2 { get; set; }
|
||||
|
||||
public IList<AbsenceTime> AbsenceTimes { get; set; }
|
||||
|
||||
public decimal HoursInVacation { get; set; }
|
||||
|
||||
public decimal HoursSick { get; set; }
|
||||
|
||||
public decimal MinutesTotal { get; set; }
|
||||
|
||||
public String Custom1 { get; set; }
|
||||
|
||||
public String Custom2 { get; set; }
|
||||
|
||||
public String Custom3 { get; set; }
|
||||
|
||||
public String Custom4 { get; set; }
|
||||
|
||||
public String Custom5 { get; set; }
|
||||
|
||||
public String Custom6 { get; set; }
|
||||
|
||||
public String Custom7 { get; set; }
|
||||
|
||||
public String Custom8 { get; set; }
|
||||
|
||||
public String Custom9 { get; set; }
|
||||
|
||||
public String Custom10 { get; set; }
|
||||
|
||||
public IList<ServiceRecord> ServiceRecords { get; set; }
|
||||
|
||||
public int? NightStart { get; set; }
|
||||
|
||||
public int? NightEnd { get; set; }
|
||||
|
||||
public int? MaxHoursUntilBreak { get; set; }
|
||||
|
||||
public decimal PauseInMinuten { get; set; }
|
||||
|
||||
public int? BreakMinutes { get; set; }
|
||||
|
||||
public int? MaxHoursUntilBreak2 { get; set; }
|
||||
|
||||
public int? BreakMinutes2 { get; set; }
|
||||
|
||||
public decimal SpecialHours { get; set; }
|
||||
|
||||
public IList<DateTimeSpan> ZusammenhaengendeZeitraeume { get; set; }
|
||||
|
||||
public String ZeitraeumeString
|
||||
{
|
||||
get
|
||||
{
|
||||
String str = "";
|
||||
if (AbsenceTimes != null)
|
||||
{
|
||||
foreach (var at in AbsenceTimes)
|
||||
{
|
||||
if (at.AbsenceReason != null)
|
||||
{
|
||||
if (str.Length > 0)
|
||||
{
|
||||
str += ", ";
|
||||
}
|
||||
|
||||
str += at.AbsenceReason.Description
|
||||
;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
if (ZusammenhaengendeZeitraeume != null)
|
||||
{
|
||||
foreach (var dts in ZusammenhaengendeZeitraeume)
|
||||
{
|
||||
if (dts.StartDateTime != dts.EndDateTime)
|
||||
{
|
||||
if (str.Length > 0)
|
||||
{
|
||||
str += ", ";
|
||||
}
|
||||
|
||||
str += String.Format("{0:HH:mm} - {1:HH:mm}", dts.StartDateTime, dts.EndDateTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static EmployeeDetail CreateEmployeeDetail(Employee employee, Team team)
|
||||
{
|
||||
var employeeDetail = new EmployeeDetail
|
||||
{
|
||||
Teams = team == null ? DAOFactory.SearchDAO.FindTeamsOfEmployee(employee.Oid.Value) : new List<Team> { team },
|
||||
Employee = employee,
|
||||
LastName = employee.Person.LastName,
|
||||
FirstName = employee.Person.FirstName,
|
||||
FullName = $"{employee.Person.LastName}, {employee.Person.FirstName}"
|
||||
};
|
||||
|
||||
return employeeDetail;
|
||||
}
|
||||
}
|
||||
}
|
||||
2663
Service/Dienstplanung/MitarbeiterstundenkontoBerechnung.cs
Normal file
2663
Service/Dienstplanung/MitarbeiterstundenkontoBerechnung.cs
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user