273 lines
11 KiB
C#
273 lines
11 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using BeWo.Data.Access;
|
|
using BeWo.Data.Entities;
|
|
using BeWo.Report;
|
|
using BeWo.Report.ReportObjects;
|
|
using BeWo.Service.DCEntityMapper;
|
|
using BeWo.Service.Plugins;
|
|
using BS.Shared;
|
|
using BS.Shared.Extensions;
|
|
using DevExpress.XtraReports.Design;
|
|
using DevExpress.XtraReports.UI;
|
|
|
|
namespace AkggMid
|
|
{
|
|
public class CustomReportCreator : DefaultReportCreator
|
|
{
|
|
public override XtraReport CreateServiceOverviewReportNew(int month, int year, QBFilterEnum filterType, long? customerOid, long? teamOid, long? empOid, long? orgaOid, long? serviceCategoryOid, int startDay, int endDay, bool nurFehlende)
|
|
{
|
|
return base.CreateServiceOverviewReportNew(month, year, filterType, customerOid, teamOid, empOid, orgaOid, serviceCategoryOid, startDay, endDay, nurFehlende);
|
|
}
|
|
|
|
public override XtraReport CreateServiceOverviewAllCustomersReport(int month, int year, long orgaOid, long empOid, long? serviceCategoryOid, int startDay, int endDay, bool nurFehlende)
|
|
{
|
|
List<ServicesOverviewRO> lROs = ServicesOverviewRO.Create(month, year, orgaOid, empOid, startDay, endDay, serviceCategoryOid, true, nurFehlende);
|
|
|
|
if (lROs.Count > 0)
|
|
{
|
|
|
|
var lServiceOverviewAllCustomersReport = ErstelleReport(lROs[0]);
|
|
lServiceOverviewAllCustomersReport.SetReportDataSource(lROs[0]);
|
|
(lServiceOverviewAllCustomersReport as XtraReport).CreateDocument();
|
|
var Report = lServiceOverviewAllCustomersReport as XtraReport;
|
|
|
|
for (int i = 1; i < lROs.Count; i++)
|
|
{
|
|
var lNext = ErstelleReport(lROs[i]);
|
|
lNext.SetReportDataSource(lROs[i]);
|
|
(lNext as XtraReport).CreateDocument();
|
|
Report.Pages.AddRange((lNext as XtraReport).Pages);
|
|
}
|
|
|
|
return lServiceOverviewAllCustomersReport as XtraReport;
|
|
}
|
|
return new XtraReport();
|
|
}
|
|
|
|
public override XtraReport CreateServiceOverviewSingleCustomerReport(long customerOid, int month, int year, long orgaOid, long empOid, long? serviceCategoryOid, int startDay, int endDay)
|
|
{
|
|
if (customerOid == 0)
|
|
{
|
|
return CreateSbdLeistungsnachweisForSingleCustomerReport(customerOid, month, year, orgaOid, empOid, serviceCategoryOid ?? 0, startDay, endDay, false, "hessen");
|
|
}
|
|
var ro = ServicesOverviewRO.Create(customerOid, month, year, false, orgaOid, empOid, startDay, endDay, serviceCategoryOid);
|
|
var lServiceOverviewSingleCustomerReport = ErstelleReport(ro);
|
|
|
|
lServiceOverviewSingleCustomerReport.SetReportDataSource(ro);
|
|
|
|
return lServiceOverviewSingleCustomerReport as XtraReport;
|
|
}
|
|
|
|
public override XtraReport CreateServiceOverviewReportForCustomers(IList<long> customerOids, int month, int year, long? orgaOid, long? empOid, long? serviceCategoryOid, int startDay, int endDay, bool nurFehlende)
|
|
{
|
|
var roList = new List<ServicesOverviewRO>();
|
|
|
|
foreach (var coid in customerOids)
|
|
{
|
|
var ro = ServicesOverviewRO.Create(coid, month, year, true, orgaOid ?? 0, empOid ?? 0, startDay, endDay, serviceCategoryOid);
|
|
|
|
if (ro != null)
|
|
{
|
|
roList.Add(ro);
|
|
}
|
|
}
|
|
|
|
var sortedList = roList.OrderBy(r => r.CustomerLastName + ", " + r.CustomerFirstName).ToList();
|
|
|
|
if (sortedList.Count > 0)
|
|
{
|
|
var rootReport = CreateReportForServicesOverviewRo(sortedList[0], "");
|
|
if (rootReport.Pages.Count == 0)
|
|
{
|
|
rootReport.CreateDocument();
|
|
}
|
|
|
|
|
|
for (int i = 1; i < sortedList.Count; i++)
|
|
{
|
|
var lNext = CreateReportForServicesOverviewRo(sortedList[i], "");
|
|
if (lNext.Pages.Count == 0)
|
|
{
|
|
lNext.CreateDocument();
|
|
}
|
|
|
|
rootReport.Pages.AddRange(lNext.Pages);
|
|
}
|
|
|
|
return rootReport;
|
|
}
|
|
return new XtraReport();
|
|
}
|
|
|
|
public override XtraReport CreateReportForServicesOverviewRo(ServicesOverviewRO ro, String reportId)
|
|
{
|
|
IBeWoReport<ServicesOverviewRO> report = ErstelleReport(ro);
|
|
|
|
report.SetReportDataSource(ro);
|
|
|
|
|
|
return report as XtraReport;
|
|
}
|
|
|
|
private IBeWoReport<ServicesOverviewRO> ErstelleReport(ServicesOverviewRO ro)
|
|
{
|
|
if (ro.Costbearer == null)
|
|
{
|
|
if (ro.CustomerOid > 0)
|
|
{
|
|
var c = DAOFactory.GenericDAO.LoadByID<Customer>(ro.CustomerOid);
|
|
foreach (var sc in c.SupportConcepts)
|
|
{
|
|
foreach (var c2s in sc.CostBearer2SupportConceptList)
|
|
{
|
|
if (c2s.StartDate <= ro.EndDate && c2s.EndDate >= ro.StartDate)
|
|
{
|
|
ro.Costbearer = c2s.CostBearer.Organisation.Name;
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
if (ro.Costbearer == "SEK -Jugend und Familie-")
|
|
{
|
|
return new LeistungsnachweisJugendamt();
|
|
}
|
|
|
|
bool hatBlutzuckerMessung = false;
|
|
bool hatBlutzuckerPumpe = false;
|
|
|
|
foreach (var item in ro.Services)
|
|
{
|
|
if (!String.IsNullOrEmpty(item.Notice3))
|
|
{
|
|
hatBlutzuckerMessung = true;
|
|
}
|
|
if (!String.IsNullOrEmpty(item.Notice4))
|
|
{
|
|
hatBlutzuckerPumpe = true;
|
|
}
|
|
}
|
|
|
|
if (hatBlutzuckerPumpe)
|
|
{
|
|
return new LeistungsnachweisSozialamtMitBlutzuckerPumpe();
|
|
}
|
|
if (hatBlutzuckerMessung)
|
|
{
|
|
return new LeistungsnachweisSozialamtMitBlutzucker();
|
|
}
|
|
|
|
return new LeistungsnachweisSozialamt();
|
|
}
|
|
|
|
public override XtraReport CreateSbdLeistungsnachweisForAllCustomers(int month, int year, long orgaOid, long empOid, long serviceCategoryOid, int startDay, int endDay, bool checkServiceRecords, string bundesland)
|
|
{
|
|
return CreateReportForStundenaufstellungROs(SbdStundenaufstellungRO.Create(month, year, orgaOid, empOid, serviceCategoryOid, startDay, endDay, true, "hessen"));
|
|
}
|
|
|
|
public override XtraReport CreateSbdLeistungsnachweisForSingleCustomerReport(long customerOid, int month, int year, long orgaOid, long empOid, long serviceCategoryOid, int startDay, int endDay, bool checkServiceRecords, string bundesland)
|
|
{
|
|
return CreateReportForStundenaufstellungROs(SbdStundenaufstellungRO.Create(customerOid, month, year, orgaOid, empOid, serviceCategoryOid, startDay, endDay, true, "hessen", false));
|
|
}
|
|
|
|
|
|
|
|
public override XtraReport CreateEmployeeKilometerauswertung(long employeeOid, List<long> serviceDescriptionOids, DateTime start, DateTime end)
|
|
{
|
|
var report = FindReportImp<EmployeeKilometerauswertungsRO>();
|
|
var qbs = ServicesOverviewRO.Create(start.Month, start.Year, 0, employeeOid, start.Day, end.Day, null, true, false);
|
|
List<ServicesOverviewRO.ServiceDetail> serviceDetails = new List<ServicesOverviewRO.ServiceDetail>();
|
|
|
|
foreach (var so in qbs)
|
|
{
|
|
foreach (var s in so.Services)
|
|
{
|
|
ServicesOverviewRO.CreateGoalList(s);
|
|
if (!s.GoalList.IsNullOrEmpty())
|
|
s.GoalList += "GOAL";
|
|
if (!s.GefahreneKilometer.IsNullOrEmpty())
|
|
serviceDetails.Add(s);
|
|
}
|
|
}
|
|
|
|
var kilometerRO = EmployeeKilometerauswertungsRO.Create(MapperFactory.CompactEmployeeDC_Employee.MapToNewDC(DAOFactory.GenericDAO.LoadByID<Employee>(employeeOid)), serviceDescriptionOids, start, end);
|
|
kilometerRO.CreateDistanceList();
|
|
|
|
foreach (var item in kilometerRO.Entries)
|
|
{
|
|
foreach (var sd in serviceDetails)
|
|
{
|
|
if (item.ServiceRecord.Oid == sd.ServiceRecordOid)
|
|
{
|
|
item.Dokumentation = sd.GoalList;
|
|
}
|
|
}
|
|
}
|
|
|
|
foreach (var item in kilometerRO.Entries)
|
|
{
|
|
if (!String.IsNullOrEmpty(item.Dokumentation) && item.Dokumentation.Contains("GOAL"))
|
|
item.Dokumentation = item.Dokumentation.Remove(item.Dokumentation.Length - 4, 4);
|
|
}
|
|
|
|
report.SetReportDataSource(kilometerRO);
|
|
|
|
return report as XtraReport;
|
|
}
|
|
|
|
public override XtraReport CreateKilometerauswertungForAllEmployees(List<long> employeeOids, List<long> serviceDescriptionOids, DateTime start, DateTime end)
|
|
{
|
|
var report = FindReportImp<EmployeeKilometerauswertungsListRO>();
|
|
var auswertungRO = EmployeeKilometerauswertungsListRO.Create(MapperFactory.CompactEmployeeDC_Employee.MapToNewDCs(DAOFactory.GenericDAO.LoadByIDs<Employee>(employeeOids)), serviceDescriptionOids, start, end);
|
|
|
|
foreach (var e2e in auswertungRO.Employees2Entries)
|
|
{
|
|
var qbs = ServicesOverviewRO.Create(start.Month, start.Year, 0, e2e.Employee.EmployeeOid, start.Day, end.Day, null, true, false);
|
|
List<ServicesOverviewRO.ServiceDetail> serviceDetails = new List<ServicesOverviewRO.ServiceDetail>();
|
|
|
|
foreach (var so in qbs)
|
|
{
|
|
foreach (var s in so.Services)
|
|
{
|
|
ServicesOverviewRO.CreateGoalList(s);
|
|
if (!s.GoalList.IsNullOrEmpty())
|
|
s.GoalList += "GOAL";
|
|
if (!s.GefahreneKilometer.IsNullOrEmpty())
|
|
serviceDetails.Add(s);
|
|
}
|
|
}
|
|
|
|
//var kilometerRO = EmployeeKilometerauswertungsRO.Create(MapperFactory.CompactEmployeeDC_Employee.MapToNewDC(DAOFactory.GenericDAO.LoadByID<Employee>(e2e.Employee.EmployeeOid)), serviceDescriptionOids, start, end);
|
|
//kilometerRO.CreateDistanceList();
|
|
|
|
foreach (var item in e2e.Entries)
|
|
{
|
|
foreach (var sd in serviceDetails)
|
|
{
|
|
if (item.ServiceRecord.Oid == sd.ServiceRecordOid)
|
|
{
|
|
item.Dokumentation = sd.GoalList;
|
|
}
|
|
}
|
|
}
|
|
|
|
foreach (var item in e2e.Entries)
|
|
{
|
|
if (!String.IsNullOrEmpty(item.Dokumentation) && item.Dokumentation.Contains("GOAL"))
|
|
item.Dokumentation = item.Dokumentation.Remove(item.Dokumentation.Length - 4, 4);
|
|
}
|
|
}
|
|
|
|
report.SetReportDataSource(auswertungRO);
|
|
|
|
return report as XtraReport;
|
|
}
|
|
}
|
|
}
|