Weiterer Umzugsschritt auf DCs. Muss noch was Fixes fürs dynamische Laden der DCs bauen. Wahrscheinlich ausprogrammieren -> Bessere Kontrolle, durch welche Kundenanpassung die Funktion entsprechend gelaufen ist.

This commit is contained in:
2025-09-03 16:20:58 +02:00
parent 9da8c92ca7
commit 3c7d953d67
20 changed files with 98 additions and 109 deletions

View File

@@ -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<long, string> CostBearerReferenceNumbers { get; set; }
//[JsonPropertyName("Rechnungsadresse")]
//public string InvoiceAddressString { get; set; }

View File

@@ -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<string> CustomerReferenceNumbers { get; set; }
}
}

View File

@@ -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;
}
}
}

View File

@@ -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;
}
}
}

View File

@@ -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;
}
}
}

View File

@@ -1,9 +1,9 @@
using AICore.Context.Entry;
using BeWo.Data.Entities;
using BS.Shared.DataContracts;
namespace AICore.Context.Summary
{
public class CustomerDetailContextSummary : DetailContextSummary<CustomerDetailContextEntry, Customer>
public class CustomerDetailContextSummary : DetailContextSummary<CustomerDetailContextEntry, CustomerDC>
{
public CustomerDetailContextSummary(CustomerDetailContextEntry customer) : base(customer) { }
}

View File

@@ -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<CustomerNavigationContextEntry, Customer>
public class CustomerNavigationContextSummary : NavigationContextSummary<CustomerNavigationContextEntry, CompactCustomerDC>
{
public CustomerNavigationContextSummary(IEnumerable<CustomerNavigationContextEntry> customers) : base(customers) { }
}

View File

@@ -1,9 +1,9 @@
using AICore.Context.Entry;
using BeWo.Data.Entities;
using BS.Shared.DataContracts;
namespace AICore.Context.Summary
{
public class EmployeeDetailContextSummary : DetailContextSummary<EmployeeDetailContextEntry, Employee>
public class EmployeeDetailContextSummary : DetailContextSummary<EmployeeDetailContextEntry, EmployeeDC>
{
public EmployeeDetailContextSummary(EmployeeDetailContextEntry employee) : base(employee) { }
}

View File

@@ -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<EmployeeNavigationContextEntry, Employee>
public class EmployeeNavigationContextSummary : NavigationContextSummary<EmployeeNavigationContextEntry, CompactEmployeeDC>
{
public EmployeeNavigationContextSummary(IEnumerable<EmployeeNavigationContextEntry> employee) : base(employee) { }
}

View File

@@ -1,9 +1,9 @@
using AICore.Context.Entry;
using BeWo.Data.Entities;
using BS.Shared.DataContracts;
namespace AICore.Context.Summary
{
public class OrganisationDetailContextSummary : DetailContextSummary<OrganisationDetailContextEntry, Organisation>
public class OrganisationDetailContextSummary : DetailContextSummary<OrganisationDetailContextEntry, OrganisationDC>
{
public OrganisationDetailContextSummary(OrganisationDetailContextEntry organisation) : base(organisation) { }
}

View File

@@ -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<OrganisationNavigationContextEntry, Organisation>
public class OrganisationNavigationContextSummary : NavigationContextSummary<OrganisationNavigationContextEntry, CompactOrganisationDC>
{
public OrganisationNavigationContextSummary(IEnumerable<OrganisationNavigationContextEntry> organisation) : base(organisation) { }
}

View File

@@ -1,9 +1,9 @@
using AICore.Context.Entry;
using BeWo.Data.Entities;
using BS.Shared.DataContracts;
namespace AICore.Context.Summary
{
public class PersonDetailContextSummary : DetailContextSummary<PersonDetailContextEntry, Person>
public class PersonDetailContextSummary : DetailContextSummary<PersonDetailContextEntry, PersonDC>
{
public PersonDetailContextSummary(PersonDetailContextEntry person) : base(person) { }
}

View File

@@ -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<PersonNavigationContextEntry, Person>
public class PersonNavigationContextSummary : NavigationContextSummary<PersonNavigationContextEntry, CompactPersonDC>
{
public PersonNavigationContextSummary(IEnumerable<PersonNavigationContextEntry> person) : base(person) { }
}

View File

@@ -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<ServiceRecordContextEntry, ServiceRecord>
public class ServiceRecordNavigationContextSummary : NavigationContextSummary<ServiceRecordContextEntry, ServiceRecordDC>
{
public CustomerNavigationContextEntry Customer { get; set; }
public string CostBearer { get; set; }

View File

@@ -1,9 +1,9 @@
using AICore.Context.Entry;
using BeWo.Data.Entities;
using BS.Shared.DataContracts;
namespace AICore.Context.Summary
{
public class SupportConceptDetailContextSummary : DetailContextSummary<SupportConceptDetailContextEntry, SupportConcept>
public class SupportConceptDetailContextSummary : DetailContextSummary<SupportConceptDetailContextEntry, SupportConceptDC>
{
public SupportConceptDetailContextSummary(SupportConceptDetailContextEntry supportConcept) : base(supportConcept) { }
}

View File

@@ -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<SupportConceptNavigationContextEntry, SupportConcept>
public class SupportConceptNavigationContextSummary : NavigationContextSummary<SupportConceptNavigationContextEntry, CompactSupportConceptDC>
{
public SupportConceptNavigationContextSummary(IEnumerable<SupportConceptNavigationContextEntry> supportConcept) : base(supportConcept) { }
}

View File

@@ -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;

View File

@@ -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<TableID, long[]> bewoobjects, AiDataContextType aiDataContextType)
public string CreateSystemInstructions(AiContextType uicontext, IEnumerable<IDataContract> 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<TableID, long[]> bewoobjects, BaseContextSummaryParser parser)
private string LoadContext(AiContextType uicontext, IEnumerable<IDataContract> bewoobjects, BaseContextSummaryParser parser)
{
var context = GetContext(uicontext, bewoobjects);
@@ -81,125 +82,101 @@ namespace AICore.Prompt.Factories
return parsed;
}
protected BaseContextSummary GetContext(AiContextType uicontext, Dictionary<TableID, long[]> bewoobjects)
protected BaseContextSummary GetContext(AiContextType uicontext, IEnumerable<IDataContract> bewoobjects)
{
switch (uicontext)
{
case AiContextType.SupportConcept:
return GetNavigationContext<SupportConceptNavigationContextEntry, SupportConcept>(bewoobjects);
return GetNavigationContext<SupportConceptNavigationContextEntry, CompactSupportConceptDC>(bewoobjects);
case AiContextType.Customer:
return GetNavigationContext<CustomerNavigationContextEntry, Customer>(bewoobjects);
return GetNavigationContext<CustomerNavigationContextEntry, CompactCustomerDC>(bewoobjects);
case AiContextType.Person:
return GetNavigationContext<PersonNavigationContextEntry, Person>(bewoobjects);
return GetNavigationContext<PersonNavigationContextEntry, CompactPersonDC>(bewoobjects);
case AiContextType.Employee:
return GetNavigationContext<EmployeeNavigationContextEntry, Employee>(bewoobjects);
return GetNavigationContext<EmployeeNavigationContextEntry, CompactEmployeeDC>(bewoobjects);
case AiContextType.Organisation:
return GetNavigationContext<OrganisationNavigationContextEntry, Organisation>(bewoobjects);
return GetNavigationContext<OrganisationNavigationContextEntry, CompactOrganisationDC>(bewoobjects);
case AiContextType.ServiceRecord:
return GetServiceRecordsContext(bewoobjects);
case AiContextType.CustomerSingle:
return GetDetailContext<CustomerDetailContextEntry, Customer>(bewoobjects);
return GetDetailContext<CustomerDetailContextEntry, CustomerDC>(bewoobjects);
case AiContextType.PersonSingle:
return GetDetailContext<PersonDetailContextEntry, Person>(bewoobjects);
return GetDetailContext<PersonDetailContextEntry, PersonDC>(bewoobjects);
case AiContextType.EmployeeSingle:
return GetDetailContext<EmployeeDetailContextEntry, Employee>(bewoobjects);
return GetDetailContext<EmployeeDetailContextEntry, EmployeeDC>(bewoobjects);
default:
throw BeWoNotImplementedException.CreateFromEnum(uicontext);
}
}
private DetailContextSummary<TEntry, TEntity> GetDetailContext<TEntry, TEntity>(Dictionary<TableID, long[]> bewoobjects)
where TEntry : DetailContextEntry<TEntity>
where TEntity : BeWoEntityBase, new()
private DetailContextSummary<TEntry, TDataContract> GetDetailContext<TEntry, TDataContract>(IEnumerable<IDataContract> bewoobjects)
where TEntry : DetailContextEntry<TDataContract>
where TDataContract : IDataContract, new()
{
var entity = LoadEntity<TEntity>(bewoobjects);
var entity = LoadDataContract<TDataContract>(bewoobjects);
var context = ContextSummaryFactory.CreateDetailContext<TEntry, TEntity>(entity);
var context = ContextSummaryFactory.CreateDetailContext<TEntry, TDataContract>(entity);
return context;
}
private NavigationContextSummary<TEntry, TEntity> GetNavigationContext<TEntry, TEntity>(Dictionary<TableID, long[]> bewoobjects)
where TEntry : NavigationContextEntry<TEntity>
where TEntity : BeWoEntityBase, new()
private NavigationContextSummary<TEntry, TDataContract> GetNavigationContext<TEntry, TDataContract>(IEnumerable<IDataContract> bewoobjects)
where TEntry : NavigationContextEntry<TDataContract>
where TDataContract : IDataContract, new()
{
var entities = LoadEntities<TEntity>(bewoobjects);
var entities = LoadDataContracts<TDataContract>(bewoobjects);
var context = ContextSummaryFactory.CreateNavigationContext<TEntry, TEntity>(entities);
var context = ContextSummaryFactory.CreateNavigationContext<TEntry, TDataContract>(entities);
return context;
}
private ServiceRecordNavigationContextSummary GetServiceRecordsContext(Dictionary<TableID, long[]> bewoobjects)
private ServiceRecordNavigationContextSummary GetServiceRecordsContext(IEnumerable<IDataContract> bewoobjects)
{
var customer = LoadEntity<Customer>(bewoobjects);
var costbearer = LoadProperty<CostBearer, string>(bewoobjects, dc => dc.Organisation.Name);
var supportconcept = LoadProperty<SupportConcept, string>(bewoobjects, dc => $"{dc.StartDate?.Date} - {dc.EndDate?.Date}");
var records = LoadEntities<ServiceRecord>(bewoobjects);
var customer = LoadDataContract<CompactCustomerDC>(bewoobjects);
var costbearer = LoadProperty<CompactCostBearerDC, string>(bewoobjects, dc => dc.Organisation.Name);
var supportconcept = LoadProperty<CompactSupportConceptDC, string>(bewoobjects, dc => $"{dc.StartDate?.Date} - {dc.EndDate?.Date}");
var records = LoadDataContracts<ServiceRecordDC>(bewoobjects);
var context = ContextSummaryFactory.CreateServiceRecordNavigationContextSummary(records, customer, costbearer, supportconcept);
return context;
}
private TRet LoadProperty<TEntity, TRet>
(Dictionary<TableID, long[]> bewoobjects, Func<TEntity, TRet> getPropertyFunc)
where TEntity : BeWoEntityBase, new()
private TRet LoadProperty<TDataContract, TRet>
(IEnumerable<IDataContract> bewoobjects, Func<TDataContract, TRet> getPropertyFunc)
where TDataContract : IDataContract, new()
{
var tid = GetTableId<TEntity>();
if(LoadDataContract<TDataContract>(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<TEntity>(oids[0]);
var property = getPropertyFunc(entity);
return property;
return default;
}
private TEntity LoadEntity<TEntity>
(Dictionary<TableID, long[]> bewoobjects)
where TEntity : BeWoEntityBase, new()
private TDataContract LoadDataContract<TDataContract>
(IEnumerable<IDataContract> bewoobjects)
where TDataContract : IDataContract, new()
{
var tid = GetTableId<TEntity>();
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<TEntity>(oids[0]);
return entity;
return default;
}
private List<TEntity> LoadEntities<TEntity>
(Dictionary<TableID, long[]> bewoobjects)
where TEntity : BeWoEntityBase, new()
private IEnumerable<TDataContract> LoadDataContracts<TDataContract>
(IEnumerable<IDataContract> bewoobjects)
where TDataContract : IDataContract, new()
{
var instance = new TEntity();
var tid = GetTableId<TEntity>();
if (bewoobjects?.Where(x => x is TDataContract) is IEnumerable<IDataContract> dcs && dcs.Count() > 0)
{
return (IEnumerable<TDataContract>)dcs;
}
if (!bewoobjects.TryGetValue(tid, out long[] oids) || (oids?.Length ?? 0) == 0)
return null;
var entities = DAOFactory.GenericDAO.GetByIDs<TEntity>(oids);
//if(afterLoad != null)
//{
// foreach( var entity in entities)
// {
// afterLoad(entity);
// }
//}
return entities;
}
private TableID GetTableId<TEntity>(TEntity entity = null) where TEntity : BeWoEntityBase, new()
{
if (entity == null)
entity = new TEntity();
return entity.Tid;
return default;
}
private string getSystemPrompt(int i)

View File

@@ -265,7 +265,7 @@ namespace BeWo.Service.Plugins
return models;
}
protected virtual AiConversation createAiConversation(AiContextType uicontext, Dictionary<TableID, long[]> context, long modell_oid, AiDataContextType context_Type)
protected virtual AiConversation createAiConversation(AiContextType uicontext, Dictionary<TableID, IDataContract[]> context, long modell_oid, AiDataContextType context_Type)
{
var current_user = UserRightHelper.GetLoggedInUserWithOid();
var factory = new AiPromptFactory();

View File

@@ -10,7 +10,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>BS.Shared</RootNamespace>
<AssemblyName>BS.Shared</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile>
</TargetFrameworkProfile>