173 lines
4.9 KiB
C#
173 lines
4.9 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
|
|
using BeWo.Data.Entities;
|
|
using BeWo.Data.Access;
|
|
using System.Linq;
|
|
using BS.Shared.DataContracts;
|
|
|
|
namespace BeWo.Report.ReportObjects
|
|
{
|
|
public class RosterRO : AbstractBeWoReportObject<RosterRO>
|
|
{
|
|
public DateTime ReportDateTime { get; set; }
|
|
public string WohnheimName { get; set; }
|
|
public List<RosterReportRow> RosterReportRows { get; set; }
|
|
public int FirstWeekDay { get; set; }
|
|
|
|
public RosterRO()
|
|
{
|
|
RosterReportRows = new List<RosterReportRow>();
|
|
}
|
|
|
|
public static RosterRO Create(List<DienstBlockDC> dienstBlockDCs, List<DienstInfoDC> dienstInfoDCs, BS.Shared.DataContracts.Compact.CompactWohnheimDC compactWohnheimDC, int year, int month)
|
|
{
|
|
var dt = new DateTime(year, month, 1);
|
|
|
|
// Result
|
|
var res = new RosterRO()
|
|
{
|
|
WohnheimName = compactWohnheimDC.WohnheimName,
|
|
ReportDateTime = dt,
|
|
FirstWeekDay = ((int)dt.DayOfWeek - 1) % 7
|
|
};
|
|
|
|
// WD V F Formel
|
|
// Mo 1 0 (tag - 1) / 7
|
|
// Di 2 1 (tag + 0) / 7
|
|
// Mi 3 2 (tag + 1) / 7
|
|
// Do 4 3 (tag + 2) / 7
|
|
// Fr 5 4 (tag + 3) / 7
|
|
// Sa 6 5 (tag + 4) / 7
|
|
// So 0 6 (tag + 5) / 7
|
|
//
|
|
// int week = (day + res.FirstWeekDay - 1) / 7;
|
|
|
|
var infoDict = dienstInfoDCs.ToDictionary(x => x.Oid.Value, x => x);
|
|
|
|
|
|
foreach (var block in dienstBlockDCs)
|
|
{
|
|
RosterReportRow row = null;
|
|
double[] sum = new double[6];
|
|
|
|
for (int i = 0; i < block.DienstDictArray.Length; i++)
|
|
{
|
|
var dict = block.DienstDictArray[i];
|
|
|
|
row = new RosterReportRow()
|
|
{
|
|
Pos = i,
|
|
Title = i == 0 ? block.Employee.LastNameFirstName : null,
|
|
DienstDict = new Dictionary<int, DienstInfoDC>()
|
|
};
|
|
|
|
foreach (var kv in dict)
|
|
{
|
|
var dienst = infoDict[kv.Value];
|
|
var day = kv.Key;
|
|
|
|
row.DienstDict.Add(day, dienst);
|
|
|
|
int week = (day + res.FirstWeekDay - 1) / 7;
|
|
|
|
sum[week] += dienst.DurationHours;
|
|
}
|
|
|
|
res.RosterReportRows.Add(row);
|
|
}
|
|
|
|
row.WeekSum = sum;
|
|
}
|
|
|
|
return res;
|
|
}
|
|
}
|
|
|
|
public class RosterReportRow
|
|
{
|
|
public string Title { get; set; }
|
|
|
|
public int Pos { get; set; }
|
|
|
|
public double[] WeekSum { get; set; }
|
|
|
|
public Dictionary<int, DienstInfoDC> DienstDict { get; set; }
|
|
|
|
public double? Week1 => WeekSum?[0];
|
|
|
|
public double? Week2 => WeekSum?[1];
|
|
|
|
public double? Week3 => WeekSum?[2];
|
|
|
|
public double? Week4 => WeekSum?[3];
|
|
|
|
public double? Week5 => WeekSum?[4];
|
|
|
|
public double? Week6 => WeekSum?[5];
|
|
|
|
public DienstInfoDC Day1 => GetDienst(1);
|
|
|
|
public DienstInfoDC Day2 => GetDienst(2);
|
|
|
|
public DienstInfoDC Day3 => GetDienst(3);
|
|
|
|
public DienstInfoDC Day4 => GetDienst(4);
|
|
|
|
public DienstInfoDC Day5 => GetDienst(5);
|
|
|
|
public DienstInfoDC Day6 => GetDienst(6);
|
|
|
|
public DienstInfoDC Day7 => GetDienst(7);
|
|
|
|
public DienstInfoDC Day8 => GetDienst(8);
|
|
|
|
public DienstInfoDC Day9 => GetDienst(9);
|
|
|
|
public DienstInfoDC Day10 => GetDienst(10);
|
|
|
|
public DienstInfoDC Day11 => GetDienst(11);
|
|
|
|
public DienstInfoDC Day12 => GetDienst(12);
|
|
|
|
public DienstInfoDC Day13 => GetDienst(13);
|
|
|
|
public DienstInfoDC Day14 => GetDienst(14);
|
|
|
|
public DienstInfoDC Day15 => GetDienst(15);
|
|
|
|
public DienstInfoDC Day16 => GetDienst(16);
|
|
|
|
public DienstInfoDC Day17 => GetDienst(17);
|
|
|
|
public DienstInfoDC Day18 => GetDienst(18);
|
|
|
|
public DienstInfoDC Day19 => GetDienst(19);
|
|
|
|
public DienstInfoDC Day20 => GetDienst(20);
|
|
|
|
public DienstInfoDC Day21 => GetDienst(21);
|
|
|
|
public DienstInfoDC Day22 => GetDienst(22);
|
|
|
|
public DienstInfoDC Day23 => GetDienst(23);
|
|
|
|
public DienstInfoDC Day24 => GetDienst(24);
|
|
|
|
public DienstInfoDC Day25 => GetDienst(25);
|
|
|
|
public DienstInfoDC Day26 => GetDienst(26);
|
|
|
|
public DienstInfoDC Day27 => GetDienst(27);
|
|
|
|
public DienstInfoDC Day28 => GetDienst(28);
|
|
|
|
public DienstInfoDC Day29 => GetDienst(29);
|
|
|
|
public DienstInfoDC Day30 => GetDienst(30);
|
|
|
|
public DienstInfoDC Day31 => GetDienst(31);
|
|
|
|
public DienstInfoDC GetDienst(int i) => DienstDict.ContainsKey(i) ? DienstDict[i] : null;
|
|
}
|
|
} |