Files
BeWoPlaner/Service/Reporting/Straffaelligenhilfe/VgaStatisticCreator.cs

280 lines
10 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BS.Shared;
using BS.Shared.Core;
using BS.Shared.DataContracts;
using BS.Shared.Services;
using BeWo.Data.Access;
using BeWo.Data.Entities;
using BeWo.Service.DCEntityMapper;
using BeWo.Service.Plugins;
using Castle.Components.DictionaryAdapter;
using NHibernate.Linq;
using DevExpress.Office.Utils;
using DevExpress.XtraReports.Serialization;
namespace BeWo.Service.Reporting.Straffaelligenhilfe
{
public class VgaStatisticCreator : StatisticBase
{
protected Dictionary<String, List<CustomerVermittlungArbeit>> CustomerAktenzeichen2Vgas { get; set; } = new Dictionary<string, List<CustomerVermittlungArbeit>>();
public VgaStatisticCreator() : base(VgaTypeEnum.Vga)
{
}
public VgaStatistic VgaStatisticEfs { get; set; } = new VgaStatistic();
public VgaStatistic VgaStatisticAuflage153a { get; set; } = new VgaStatistic();
public VgaStatistic VgaStatisticAuflage153aSteuerstraf { get; set; } = new VgaStatistic();
public VgaStatistic VgaStatisticBewOhne { get; set; } = new VgaStatistic();
public VgaStatistic VgaStatisticBewMit { get; set; } = new VgaStatistic();
public VgaStatistic VgaStatisticGnadenverfahren { get; set; } = new VgaStatistic();
public override void ProcessCustomerVermittlungArbeit(Customer customer, CustomerVermittlungArbeit cva)
{
base.ProcessCustomerVermittlungArbeit(customer, cva);
VgaStatistic statistik = null;
if (cva.Vermittlungsgrundlage.HasValue)
{
switch (cva.Vermittlungsgrundlage.Value)
{
case CustomerVgaVermittlungsGrundlage.UmwandlungVonGeldstrafen:
statistik = VgaStatisticEfs;
break;
case CustomerVgaVermittlungsGrundlage.Einstellung153StPO:
statistik = VgaStatisticAuflage153a;
break;
case CustomerVgaVermittlungsGrundlage.Einstellung153StPOSteuerstrafverfahren:
statistik = VgaStatisticAuflage153aSteuerstraf;
break;
case CustomerVgaVermittlungsGrundlage.Gnadenverfahren:
statistik = VgaStatisticGnadenverfahren;
break;
case CustomerVgaVermittlungsGrundlage.AuflageOhneBWH:
statistik = VgaStatisticBewOhne;
break;
case CustomerVgaVermittlungsGrundlage.AuflageMitBWH:
statistik = VgaStatisticBewMit;
break;
default:
return;
break;
}
}
statistik.StartDate = this.StartDate;
statistik.EndDate = this.EndDate;
statistik.ProcessCustomerVermittlungArbeit(customer, cva);
String key = String.Format("{0}_{1}", cva.EigenesAktenzeichen, customer.Oid);
if (!CustomerAktenzeichen2Vgas.ContainsKey(key))
{
CustomerAktenzeichen2Vgas.Add(key, new List<CustomerVermittlungArbeit>());
}
CustomerAktenzeichen2Vgas[key].Add(cva);
//if (CustomerAktenzeichen2Vgas[key].Count > 1)
if (cva.BesonderheitMehrfacheBeauftragung)
{
statistik.Anzahl1_1++;
}
if (cva.Auftragsherkunft.HasValue)
{
switch (cva.Auftragsherkunft.Value)
{
case CustomerVgaAuftragsherkunft.AmtshilfeInnerhalbBaWu:
statistik.Anzahl1_2++;
break;
case CustomerVgaAuftragsherkunft.AmtshilfeAusserhalbBaWu:
statistik.Anzahl1_3++;
break;
case CustomerVgaAuftragsherkunft.OertlicherAuftraggeber:
break;
default:
break;
}
}
if (customer.Person.Sex.HasValue)
{
if (customer.Person.Sex.Value == Sex.Male)
{
statistik.Anzahl1_4++;
}
else if (customer.Person.Sex.Value == Sex.Female)
{
statistik.Anzahl1_5++;
}
}
statistik.Anzahl2 += cva.ZuLeistendeArbeitsstunden ?? 0;
bool istErledigt = false;
decimal arbeitsstunden = cva.AbgeleisteteStunden ?? 0;
decimal zahlungenGesamt = (cva.RatenHoehe ?? 0) + (cva.GeleisteteEinmalzahlung ?? 0);
if (cva.CustomerVermittlungBearbeitungsstatus.HasValue)
{
switch (cva.CustomerVermittlungBearbeitungsstatus.Value)
{
case CustomerVermittlungBearbeitungsstatus.Negativ:
istErledigt = true;
statistik.Anzahl3_2++;
break;
case CustomerVermittlungBearbeitungsstatus.InProgress:
break;
case CustomerVermittlungBearbeitungsstatus.Positiv:
istErledigt = true;
statistik.Anzahl3_3++;
if (arbeitsstunden > 0 && zahlungenGesamt == 0)
{
statistik.Anzahl3_3_1++;
}
break;
case CustomerVermittlungBearbeitungsstatus.Teilerfolg:
istErledigt = true;
statistik.Anzahl3_1++;
if (arbeitsstunden > 0 && zahlungenGesamt == 0)
{
statistik.Anzahl3_1_1++;
}
break;
default:
break;
}
}
if (istErledigt)
{
if (cva.BesonderheitMehrfacheVermittlung)
{
statistik.Anzahl4_2++;
}
else if (cva.Verlauf.HasValue)
{
switch (cva.Verlauf.Value)
{
case CustomerVgaVerlauf.UebergangTGV:
statistik.Anzahl4_8++;
break;
case CustomerVgaVerlauf.UebergangAufsuchendeSozialarbeit:
statistik.Anzahl4_7++;
break;
case CustomerVgaVerlauf.VermittlungExterneEinsatzstelle:
statistik.Anzahl4_1++;
break;
case CustomerVgaVerlauf.TilgungDurchRatenzahlung:
statistik.Anzahl4_4++;
break;
case CustomerVgaVerlauf.EinsatzEigeneArbeitsgruppe:
statistik.Anzahl4_3++;
break;
case CustomerVgaVerlauf.Mischformen:
statistik.Anzahl4_6++;
break;
case CustomerVgaVerlauf.SonstigeErledigung:
statistik.Anzahl4_5++;
break;
case CustomerVgaVerlauf.Abbruch:
break;
default:
break;
}
}
statistik.Anzahl5 += (int)Math.Round(arbeitsstunden, 0);
statistik.Betrag6 += zahlungenGesamt;
statistik.Anzahl7 += (int)(cva.ErsparteHafttage ?? 0);
if (arbeitsstunden > 0 && zahlungenGesamt == 0)
{
statistik.Anzahl8 += (int)(cva.ErsparteHafttage ?? 0);
}
}
if (cva.GrundKeinKontakt)
{
statistik.Anzahl9_1++;
}
if (cva.GrundNichtAngetreten)
{
statistik.Anzahl9_2++;
}
if (cva.GrundAbbruchDerTatigkeit)
{
statistik.Anzahl9_3++;
}
if (cva.GrundArbeitsunfahig)
{
statistik.Anzahl9_4++;
}
if (cva.GrundSuchtproblem)
{
statistik.Anzahl9_5++;
}
if (cva.GrundPsychischeProbleme)
{
statistik.Anzahl9_6++;
}
if (cva.GrundKeineMotivation)
{
statistik.Anzahl9_7++;
}
if (cva.GrundInHaft)
{
statistik.Anzahl9_8++;
}
if (cva.GrundUnbekannt)
{
statistik.Anzahl9_9++;
}
statistik.Anzahl10 = statistik.AnzahlInsgesamt - statistik.AnzahlErledigt;
if (cva.Auftragseingang.HasValue && cva.Auftragsruckgabe.HasValue)
{
var monate = DateTimeUtils.GetTotalMonths(cva.Auftragseingang.Value, cva.Auftragsruckgabe.Value);
if (monate.AnzahlMonateGesamt <= 3)
{
statistik.Anzahl11_1++;
}
else if (monate.AnzahlMonateGesamt > 3 && monate.AnzahlMonateGesamt <= 6)
{
statistik.Anzahl11_2++;
}
else if (monate.AnzahlMonateGesamt > 6 && monate.AnzahlMonateGesamt <= 12)
{
statistik.Anzahl11_3++;
}
else if (monate.AnzahlMonateGesamt > 12)
{
statistik.Anzahl11_4++;
}
}
if (cva.BesonderheitVermittlungAusHaft)
{
statistik.Anzahl12++;
}
}
}
}