From 3c7d953d67649fcfd532b7683b929844ea6dda79 Mon Sep 17 00:00:00 2001 From: Rene Evertz Date: Wed, 3 Sep 2025 16:20:58 +0200 Subject: [PATCH] =?UTF-8?q?Weiterer=20Umzugsschritt=20auf=20DCs.=20Muss=20?= =?UTF-8?q?noch=20was=20Fixes=20f=C3=BCrs=20dynamische=20Laden=20der=20DCs?= =?UTF-8?q?=20bauen.=20Wahrscheinlich=20ausprogrammieren=20->=20Bessere=20?= =?UTF-8?q?Kontrolle,=20durch=20welche=20Kundenanpassung=20die=20Funktion?= =?UTF-8?q?=20entsprechend=20gelaufen=20ist.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CustomerNavigationContextEntry.cs | 3 + .../SupportConceptNavigationContextEntry.cs | 4 + .../CustomerNavigationContextEntryMapper.cs | 5 +- .../EmployeeNavigationContextEntryMapper.cs | 3 + ...portConceptNavigationContextEntryMapper.cs | 1 + .../Summary/CustomerDetailContextSummary.cs | 4 +- .../CustomerNavigationContextSummary.cs | 6 +- .../Summary/EmployeeDetailContextSummary.cs | 4 +- .../EmployeeNavigationContextSummary.cs | 6 +- .../OrganisationDetailContextSummary.cs | 4 +- .../OrganisationNavigationContextSummary.cs | 6 +- .../Summary/PersonDetailContextSummary.cs | 4 +- .../Summary/PersonNavigationContextSummary.cs | 6 +- .../ServiceRecordNavigationContextSummary.cs | 4 +- .../SupportConceptDetailContextSummary.cs | 4 +- .../SupportConceptNavigationContextSummary.cs | 6 +- AICore/Facade/LLM/OpenWebApiClient.cs | 2 +- AICore/Prompt/Factories/AiPromptFactory.cs | 131 ++++++++---------- Service/Plugins/AiService2.cs | 2 +- Shared/Shared.csproj | 2 +- 20 files changed, 98 insertions(+), 109 deletions(-) diff --git a/AICore/Context/Entry/Navigation/CustomerNavigationContextEntry.cs b/AICore/Context/Entry/Navigation/CustomerNavigationContextEntry.cs index c5a210f53..428842b7e 100644 --- a/AICore/Context/Entry/Navigation/CustomerNavigationContextEntry.cs +++ b/AICore/Context/Entry/Navigation/CustomerNavigationContextEntry.cs @@ -1,5 +1,6 @@ using BS.Shared.DataContracts.Compact; using System; +using System.Collections.Generic; using System.Text.Json.Serialization; namespace AICore.Context.Entry.Navigation @@ -27,6 +28,8 @@ namespace AICore.Context.Entry.Navigation [JsonPropertyName("Erste Bezugsperson")] public string Bezugspersonen { get; set; } + [JsonPropertyName("CostBearerReferencesNumber")] + public Dictionary CostBearerReferenceNumbers { get; set; } //[JsonPropertyName("Rechnungsadresse")] //public string InvoiceAddressString { get; set; } diff --git a/AICore/Context/Entry/Navigation/SupportConceptNavigationContextEntry.cs b/AICore/Context/Entry/Navigation/SupportConceptNavigationContextEntry.cs index 8fc9cb7f1..8b0d9fc30 100644 --- a/AICore/Context/Entry/Navigation/SupportConceptNavigationContextEntry.cs +++ b/AICore/Context/Entry/Navigation/SupportConceptNavigationContextEntry.cs @@ -1,5 +1,6 @@ using BS.Shared.DataContracts.Compact; using System; +using System.Collections.Generic; using System.Text.Json.Serialization; namespace AICore.Context.Entry.Navigation @@ -26,5 +27,8 @@ namespace AICore.Context.Entry.Navigation [JsonPropertyName("Klient PLZ")] public string CustomerPostcode { get; set; } + + [JsonPropertyName("CustomerReferenceNumbers")] + public List CustomerReferenceNumbers { get; set; } } } diff --git a/AICore/Context/EntryMapper/Navigation/CustomerNavigationContextEntryMapper.cs b/AICore/Context/EntryMapper/Navigation/CustomerNavigationContextEntryMapper.cs index 4d045eec0..aca731d19 100644 --- a/AICore/Context/EntryMapper/Navigation/CustomerNavigationContextEntryMapper.cs +++ b/AICore/Context/EntryMapper/Navigation/CustomerNavigationContextEntryMapper.cs @@ -15,8 +15,9 @@ namespace AICore.Context.EntryMapper.Navigation pContext.CustomerOid = pObject.Oid.Value; pContext.DateOfBirth = pObject.DateOfBirth; pContext.FullName = pObject.GetLastNameFirstName(); - pContext.Teams = "CustomerService"; - pContext.Bezugspersonen = "CustomerService"; + pContext.Teams = pObject.Teams; + pContext.Bezugspersonen = pObject.MainAttendant; + pContext.CostBearerReferenceNumbers = pObject.CostBearerReferenceNumbers; } } } diff --git a/AICore/Context/EntryMapper/Navigation/EmployeeNavigationContextEntryMapper.cs b/AICore/Context/EntryMapper/Navigation/EmployeeNavigationContextEntryMapper.cs index 78ae10004..33fb6acc8 100644 --- a/AICore/Context/EntryMapper/Navigation/EmployeeNavigationContextEntryMapper.cs +++ b/AICore/Context/EntryMapper/Navigation/EmployeeNavigationContextEntryMapper.cs @@ -16,6 +16,9 @@ namespace AICore.Context.EntryMapper.Navigation pContext.EmployeeOid = pObject.EmployeeOid; pContext.PersonnelNumber = pObject.PersonnelNumber; pContext.FirstNameLastName = pObject.GetFirstNameLastName(); + pContext.Details2 = pObject.Details2; + pContext.Details3 = pObject.Details3; + pContext.Teams = pObject.Teams; } } } diff --git a/AICore/Context/EntryMapper/Navigation/SupportConceptNavigationContextEntryMapper.cs b/AICore/Context/EntryMapper/Navigation/SupportConceptNavigationContextEntryMapper.cs index 37ffce623..ce5128ee8 100644 --- a/AICore/Context/EntryMapper/Navigation/SupportConceptNavigationContextEntryMapper.cs +++ b/AICore/Context/EntryMapper/Navigation/SupportConceptNavigationContextEntryMapper.cs @@ -20,6 +20,7 @@ namespace AICore.Context.EntryMapper.Navigation pContext.CustomerAlias = pObject.Customer.CustomerAlias; pContext.CustomerDateOfBirth = pObject.Customer.DateOfBirth; pContext.CustomerPostcode = pObject.Customer.PostalCode; + pContext.CustomerReferenceNumbers = pObject.CustomerReferenceNumbers; } } } diff --git a/AICore/Context/Summary/CustomerDetailContextSummary.cs b/AICore/Context/Summary/CustomerDetailContextSummary.cs index 859a344ec..1f9257c94 100644 --- a/AICore/Context/Summary/CustomerDetailContextSummary.cs +++ b/AICore/Context/Summary/CustomerDetailContextSummary.cs @@ -1,9 +1,9 @@ using AICore.Context.Entry; -using BeWo.Data.Entities; +using BS.Shared.DataContracts; namespace AICore.Context.Summary { - public class CustomerDetailContextSummary : DetailContextSummary + public class CustomerDetailContextSummary : DetailContextSummary { public CustomerDetailContextSummary(CustomerDetailContextEntry customer) : base(customer) { } } diff --git a/AICore/Context/Summary/CustomerNavigationContextSummary.cs b/AICore/Context/Summary/CustomerNavigationContextSummary.cs index c56f31822..17bf0268a 100644 --- a/AICore/Context/Summary/CustomerNavigationContextSummary.cs +++ b/AICore/Context/Summary/CustomerNavigationContextSummary.cs @@ -1,10 +1,10 @@ -using BeWo.Data.Entities; -using System.Collections.Generic; +using System.Collections.Generic; using AICore.Context.Entry.Navigation; +using BS.Shared.DataContracts.Compact; namespace AICore.Context.Summary { - public class CustomerNavigationContextSummary : NavigationContextSummary + public class CustomerNavigationContextSummary : NavigationContextSummary { public CustomerNavigationContextSummary(IEnumerable customers) : base(customers) { } } diff --git a/AICore/Context/Summary/EmployeeDetailContextSummary.cs b/AICore/Context/Summary/EmployeeDetailContextSummary.cs index 614a62973..5970148a8 100644 --- a/AICore/Context/Summary/EmployeeDetailContextSummary.cs +++ b/AICore/Context/Summary/EmployeeDetailContextSummary.cs @@ -1,9 +1,9 @@ using AICore.Context.Entry; -using BeWo.Data.Entities; +using BS.Shared.DataContracts; namespace AICore.Context.Summary { - public class EmployeeDetailContextSummary : DetailContextSummary + public class EmployeeDetailContextSummary : DetailContextSummary { public EmployeeDetailContextSummary(EmployeeDetailContextEntry employee) : base(employee) { } } diff --git a/AICore/Context/Summary/EmployeeNavigationContextSummary.cs b/AICore/Context/Summary/EmployeeNavigationContextSummary.cs index cbda09c88..252629d36 100644 --- a/AICore/Context/Summary/EmployeeNavigationContextSummary.cs +++ b/AICore/Context/Summary/EmployeeNavigationContextSummary.cs @@ -1,10 +1,10 @@ -using BeWo.Data.Entities; -using System.Collections.Generic; +using System.Collections.Generic; using AICore.Context.Entry.Navigation; +using BS.Shared.DataContracts.Compact; namespace AICore.Context.Summary { - public class EmployeeNavigationContextSummary : NavigationContextSummary + public class EmployeeNavigationContextSummary : NavigationContextSummary { public EmployeeNavigationContextSummary(IEnumerable employee) : base(employee) { } } diff --git a/AICore/Context/Summary/OrganisationDetailContextSummary.cs b/AICore/Context/Summary/OrganisationDetailContextSummary.cs index 4ad3aae02..cc42560ef 100644 --- a/AICore/Context/Summary/OrganisationDetailContextSummary.cs +++ b/AICore/Context/Summary/OrganisationDetailContextSummary.cs @@ -1,9 +1,9 @@ using AICore.Context.Entry; -using BeWo.Data.Entities; +using BS.Shared.DataContracts; namespace AICore.Context.Summary { - public class OrganisationDetailContextSummary : DetailContextSummary + public class OrganisationDetailContextSummary : DetailContextSummary { public OrganisationDetailContextSummary(OrganisationDetailContextEntry organisation) : base(organisation) { } } diff --git a/AICore/Context/Summary/OrganisationNavigationContextSummary.cs b/AICore/Context/Summary/OrganisationNavigationContextSummary.cs index fab51e693..4e9566853 100644 --- a/AICore/Context/Summary/OrganisationNavigationContextSummary.cs +++ b/AICore/Context/Summary/OrganisationNavigationContextSummary.cs @@ -1,10 +1,10 @@ -using BeWo.Data.Entities; -using System.Collections.Generic; +using System.Collections.Generic; using AICore.Context.Entry.Navigation; +using BS.Shared.DataContracts.Compact; namespace AICore.Context.Summary { - public class OrganisationNavigationContextSummary : NavigationContextSummary + public class OrganisationNavigationContextSummary : NavigationContextSummary { public OrganisationNavigationContextSummary(IEnumerable organisation) : base(organisation) { } } diff --git a/AICore/Context/Summary/PersonDetailContextSummary.cs b/AICore/Context/Summary/PersonDetailContextSummary.cs index 967a47287..321670a0f 100644 --- a/AICore/Context/Summary/PersonDetailContextSummary.cs +++ b/AICore/Context/Summary/PersonDetailContextSummary.cs @@ -1,9 +1,9 @@ using AICore.Context.Entry; -using BeWo.Data.Entities; +using BS.Shared.DataContracts; namespace AICore.Context.Summary { - public class PersonDetailContextSummary : DetailContextSummary + public class PersonDetailContextSummary : DetailContextSummary { public PersonDetailContextSummary(PersonDetailContextEntry person) : base(person) { } } diff --git a/AICore/Context/Summary/PersonNavigationContextSummary.cs b/AICore/Context/Summary/PersonNavigationContextSummary.cs index ada702668..9f73e5930 100644 --- a/AICore/Context/Summary/PersonNavigationContextSummary.cs +++ b/AICore/Context/Summary/PersonNavigationContextSummary.cs @@ -1,10 +1,10 @@ -using BeWo.Data.Entities; -using System.Collections.Generic; +using System.Collections.Generic; using AICore.Context.Entry.Navigation; +using BS.Shared.DataContracts.Compact; namespace AICore.Context.Summary { - public class PersonNavigationContextSummary : NavigationContextSummary + public class PersonNavigationContextSummary : NavigationContextSummary { public PersonNavigationContextSummary(IEnumerable person) : base(person) { } } diff --git a/AICore/Context/Summary/ServiceRecordNavigationContextSummary.cs b/AICore/Context/Summary/ServiceRecordNavigationContextSummary.cs index 198ea3272..c39edab02 100644 --- a/AICore/Context/Summary/ServiceRecordNavigationContextSummary.cs +++ b/AICore/Context/Summary/ServiceRecordNavigationContextSummary.cs @@ -1,10 +1,10 @@ using AICore.Context.Entry.Navigation; -using BeWo.Data.Entities; +using BS.Shared.DataContracts; using System.Collections.Generic; namespace AICore.Context.Summary { - public class ServiceRecordNavigationContextSummary : NavigationContextSummary + public class ServiceRecordNavigationContextSummary : NavigationContextSummary { public CustomerNavigationContextEntry Customer { get; set; } public string CostBearer { get; set; } diff --git a/AICore/Context/Summary/SupportConceptDetailContextSummary.cs b/AICore/Context/Summary/SupportConceptDetailContextSummary.cs index 2ad64f34a..03075000a 100644 --- a/AICore/Context/Summary/SupportConceptDetailContextSummary.cs +++ b/AICore/Context/Summary/SupportConceptDetailContextSummary.cs @@ -1,9 +1,9 @@ using AICore.Context.Entry; -using BeWo.Data.Entities; +using BS.Shared.DataContracts; namespace AICore.Context.Summary { - public class SupportConceptDetailContextSummary : DetailContextSummary + public class SupportConceptDetailContextSummary : DetailContextSummary { public SupportConceptDetailContextSummary(SupportConceptDetailContextEntry supportConcept) : base(supportConcept) { } } diff --git a/AICore/Context/Summary/SupportConceptNavigationContextSummary.cs b/AICore/Context/Summary/SupportConceptNavigationContextSummary.cs index b8de5623e..c7c527fe1 100644 --- a/AICore/Context/Summary/SupportConceptNavigationContextSummary.cs +++ b/AICore/Context/Summary/SupportConceptNavigationContextSummary.cs @@ -1,10 +1,10 @@ -using BeWo.Data.Entities; -using System.Collections.Generic; +using System.Collections.Generic; using AICore.Context.Entry.Navigation; +using BS.Shared.DataContracts.Compact; namespace AICore.Context.Summary { - public class SupportConceptNavigationContextSummary : NavigationContextSummary + public class SupportConceptNavigationContextSummary : NavigationContextSummary { public SupportConceptNavigationContextSummary(IEnumerable supportConcept) : base(supportConcept) { } } diff --git a/AICore/Facade/LLM/OpenWebApiClient.cs b/AICore/Facade/LLM/OpenWebApiClient.cs index 53d36dabf..8b73517fe 100644 --- a/AICore/Facade/LLM/OpenWebApiClient.cs +++ b/AICore/Facade/LLM/OpenWebApiClient.cs @@ -1,4 +1,4 @@ -using BeWo.Server.ApiFacade.Core; +using BS.Shared.ApiFacade; using BS.Shared.DataContracts; using BS.Shared.DataContracts.Feature.AI; using BS.Shared.Extensions; diff --git a/AICore/Prompt/Factories/AiPromptFactory.cs b/AICore/Prompt/Factories/AiPromptFactory.cs index ebc703e4b..9cd617b1c 100644 --- a/AICore/Prompt/Factories/AiPromptFactory.cs +++ b/AICore/Prompt/Factories/AiPromptFactory.cs @@ -3,16 +3,17 @@ using AICore.Context.Entry.Navigation; using AICore.Context.Summary; using AICore.Context.SummaryMapper; using AICore.Context.SummaryParser; -using BeWo.Data.Access; -using BeWo.Data.Entities; using BeWo.ServiceUtils.Core; using BS.Shared; using BS.Shared.Core; +using BS.Shared.DataContracts; +using BS.Shared.DataContracts.Compact; using BS.Shared.Exceptions; using BS.Shared.Translation; using System; using System.Collections.Generic; using System.IO; +using System.Linq; using System.Reflection; using System.Text; using System.Text.Json; @@ -21,7 +22,7 @@ namespace AICore.Prompt.Factories { public class AiPromptFactory { - public string CreateSystemInstructions(AiContextType uicontext, Dictionary bewoobjects, AiDataContextType aiDataContextType) + public string CreateSystemInstructions(AiContextType uicontext, IEnumerable bewoobjects, AiDataContextType aiDataContextType) { var sb = new StringBuilder(); @@ -36,7 +37,7 @@ namespace AICore.Prompt.Factories sb.AppendLine(); sb.AppendLine("### **Daten**"); - if (bewoobjects is null || bewoobjects.Count == 0) + if (bewoobjects is null || bewoobjects.Count() == 0) { sb.AppendLine("Dir wurden keine Daten bereitgestellt."); } @@ -72,7 +73,7 @@ namespace AICore.Prompt.Factories throw BeWoNotImplementedException.CreateFromEnum(aiDataContextType); } - private string LoadContext(AiContextType uicontext, Dictionary bewoobjects, BaseContextSummaryParser parser) + private string LoadContext(AiContextType uicontext, IEnumerable bewoobjects, BaseContextSummaryParser parser) { var context = GetContext(uicontext, bewoobjects); @@ -81,125 +82,101 @@ namespace AICore.Prompt.Factories return parsed; } - protected BaseContextSummary GetContext(AiContextType uicontext, Dictionary bewoobjects) + protected BaseContextSummary GetContext(AiContextType uicontext, IEnumerable bewoobjects) { switch (uicontext) { case AiContextType.SupportConcept: - return GetNavigationContext(bewoobjects); + return GetNavigationContext(bewoobjects); case AiContextType.Customer: - return GetNavigationContext(bewoobjects); + return GetNavigationContext(bewoobjects); case AiContextType.Person: - return GetNavigationContext(bewoobjects); + return GetNavigationContext(bewoobjects); case AiContextType.Employee: - return GetNavigationContext(bewoobjects); + return GetNavigationContext(bewoobjects); case AiContextType.Organisation: - return GetNavigationContext(bewoobjects); + return GetNavigationContext(bewoobjects); case AiContextType.ServiceRecord: return GetServiceRecordsContext(bewoobjects); case AiContextType.CustomerSingle: - return GetDetailContext(bewoobjects); + return GetDetailContext(bewoobjects); case AiContextType.PersonSingle: - return GetDetailContext(bewoobjects); + return GetDetailContext(bewoobjects); case AiContextType.EmployeeSingle: - return GetDetailContext(bewoobjects); + return GetDetailContext(bewoobjects); default: throw BeWoNotImplementedException.CreateFromEnum(uicontext); } } - private DetailContextSummary GetDetailContext(Dictionary bewoobjects) - where TEntry : DetailContextEntry - where TEntity : BeWoEntityBase, new() + private DetailContextSummary GetDetailContext(IEnumerable bewoobjects) + where TEntry : DetailContextEntry + where TDataContract : IDataContract, new() { - var entity = LoadEntity(bewoobjects); + var entity = LoadDataContract(bewoobjects); - var context = ContextSummaryFactory.CreateDetailContext(entity); + var context = ContextSummaryFactory.CreateDetailContext(entity); return context; } - private NavigationContextSummary GetNavigationContext(Dictionary bewoobjects) - where TEntry : NavigationContextEntry - where TEntity : BeWoEntityBase, new() + private NavigationContextSummary GetNavigationContext(IEnumerable bewoobjects) + where TEntry : NavigationContextEntry + where TDataContract : IDataContract, new() { - var entities = LoadEntities(bewoobjects); + var entities = LoadDataContracts(bewoobjects); - var context = ContextSummaryFactory.CreateNavigationContext(entities); + var context = ContextSummaryFactory.CreateNavigationContext(entities); return context; } - private ServiceRecordNavigationContextSummary GetServiceRecordsContext(Dictionary bewoobjects) + private ServiceRecordNavigationContextSummary GetServiceRecordsContext(IEnumerable bewoobjects) { - var customer = LoadEntity(bewoobjects); - var costbearer = LoadProperty(bewoobjects, dc => dc.Organisation.Name); - var supportconcept = LoadProperty(bewoobjects, dc => $"{dc.StartDate?.Date} - {dc.EndDate?.Date}"); - var records = LoadEntities(bewoobjects); + var customer = LoadDataContract(bewoobjects); + var costbearer = LoadProperty(bewoobjects, dc => dc.Organisation.Name); + var supportconcept = LoadProperty(bewoobjects, dc => $"{dc.StartDate?.Date} - {dc.EndDate?.Date}"); + var records = LoadDataContracts(bewoobjects); var context = ContextSummaryFactory.CreateServiceRecordNavigationContextSummary(records, customer, costbearer, supportconcept); return context; } - private TRet LoadProperty - (Dictionary bewoobjects, Func getPropertyFunc) - where TEntity : BeWoEntityBase, new() + private TRet LoadProperty + (IEnumerable bewoobjects, Func getPropertyFunc) + where TDataContract : IDataContract, new() { - var tid = GetTableId(); + if(LoadDataContract(bewoobjects) is TDataContract dc) + { + return getPropertyFunc(dc); + } - if (!bewoobjects.TryGetValue(tid, out long[] oids) || (oids?.Length ?? 0) == 0) - return default; - - var entity = DAOFactory.GenericDAO.GetByID(oids[0]); - var property = getPropertyFunc(entity); - - return property; + return default; } - private TEntity LoadEntity - (Dictionary bewoobjects) - where TEntity : BeWoEntityBase, new() + private TDataContract LoadDataContract + (IEnumerable bewoobjects) + where TDataContract : IDataContract, new() { - var tid = GetTableId(); + if(bewoobjects?.FirstOrDefault(x => x is TDataContract) is IDataContract dc) + { + return (TDataContract)dc; + } - if (!bewoobjects.TryGetValue(tid, out long[] oids) || (oids?.Length ?? 0) == 0) - return null; - - var entity = DAOFactory.GenericDAO.GetByID(oids[0]); - - return entity; + return default; } - private List LoadEntities - (Dictionary bewoobjects) - where TEntity : BeWoEntityBase, new() + private IEnumerable LoadDataContracts + (IEnumerable bewoobjects) + where TDataContract : IDataContract, new() { - var instance = new TEntity(); - var tid = GetTableId(); + if (bewoobjects?.Where(x => x is TDataContract) is IEnumerable dcs && dcs.Count() > 0) + { + return (IEnumerable)dcs; + } - if (!bewoobjects.TryGetValue(tid, out long[] oids) || (oids?.Length ?? 0) == 0) - return null; - - var entities = DAOFactory.GenericDAO.GetByIDs(oids); - - //if(afterLoad != null) - //{ - // foreach( var entity in entities) - // { - // afterLoad(entity); - // } - //} - - return entities; - } - - private TableID GetTableId(TEntity entity = null) where TEntity : BeWoEntityBase, new() - { - if (entity == null) - entity = new TEntity(); - - return entity.Tid; + return default; } private string getSystemPrompt(int i) diff --git a/Service/Plugins/AiService2.cs b/Service/Plugins/AiService2.cs index e3cce480f..52b785a40 100644 --- a/Service/Plugins/AiService2.cs +++ b/Service/Plugins/AiService2.cs @@ -265,7 +265,7 @@ namespace BeWo.Service.Plugins return models; } - protected virtual AiConversation createAiConversation(AiContextType uicontext, Dictionary context, long modell_oid, AiDataContextType context_Type) + protected virtual AiConversation createAiConversation(AiContextType uicontext, Dictionary context, long modell_oid, AiDataContextType context_Type) { var current_user = UserRightHelper.GetLoggedInUserWithOid(); var factory = new AiPromptFactory(); diff --git a/Shared/Shared.csproj b/Shared/Shared.csproj index 6a003c129..ec32a07c9 100644 --- a/Shared/Shared.csproj +++ b/Shared/Shared.csproj @@ -10,7 +10,7 @@ Properties BS.Shared BS.Shared - v4.5.2 + v4.7.2 512