From 03840ae75997d47554bcab8ae19ad581612f9e51 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Fri, 24 Sep 2021 20:27:20 +0000 Subject: [PATCH] --- server/AyaNova/DataList/PartDataList.cs | 11 ++++++++++- server/AyaNova/biz/PartBiz.cs | 11 ++++++++++- server/AyaNova/models/Part.cs | 2 ++ 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/server/AyaNova/DataList/PartDataList.cs b/server/AyaNova/DataList/PartDataList.cs index 177a154e..02c18bb2 100644 --- a/server/AyaNova/DataList/PartDataList.cs +++ b/server/AyaNova/DataList/PartDataList.cs @@ -10,7 +10,8 @@ namespace AyaNova.DataList SQLFrom = "from apart " + "left join avendor as aman on (apart.manufacturerid=aman.id) " + "left join avendor as awhole on (apart.wholesalerid=awhole.id) " - + "left join avendor as aaltwhole on (apart.alternativewholesalerid=aaltwhole.id)"; + + "left join avendor as aaltwhole on (apart.alternativewholesalerid=aaltwhole.id) "; + //+ "left join apartserial on apartserial.partid=apart.id"; var RoleSet = BizRoles.GetRoleSet(DefaultListAType); AllowedRoles = RoleSet.ReadFullRecord | RoleSet.Change; DefaultColumns = new List() { "PartPartNumber", "PartName", "PartManufacturerID", "PartWholesalerID", "Tags" }; @@ -146,6 +147,14 @@ namespace AyaNova.DataList SqlValueColumnName = "apart.upc" }); + FieldDefinitions.Add(new DataListFieldDefinition + { + TKey = "PartSerialNumbersAvailable", + FieldKey = "PartSerialNumbersAvailable", + UiFieldDataType = (int)UiFieldDataType.Text, + SqlValueColumnName = "(select array_agg(serial) from apartserial where partid=apart.id group by partid) as sub_serials" + }); + FieldDefinitions.Add(new DataListFieldDefinition { TKey = "PartCustom1", FieldKey = "partcustom1", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "apart.customfields" }); FieldDefinitions.Add(new DataListFieldDefinition { TKey = "PartCustom2", FieldKey = "partcustom2", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "apart.customfields" }); FieldDefinitions.Add(new DataListFieldDefinition { TKey = "PartCustom3", FieldKey = "partcustom3", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "apart.customfields" }); diff --git a/server/AyaNova/biz/PartBiz.cs b/server/AyaNova/biz/PartBiz.cs index 2caed511..610f2f05 100644 --- a/server/AyaNova/biz/PartBiz.cs +++ b/server/AyaNova/biz/PartBiz.cs @@ -524,6 +524,15 @@ namespace AyaNova.Biz o.ManufacturerViz = await ct.Vendor.AsNoTracking().Where(x => x.Id == o.ManufacturerId).Select(x => x.Name).FirstOrDefaultAsync(); if (o.AlternativeWholeSalerId != null) o.AlternativeWholeSalerViz = await ct.Vendor.AsNoTracking().Where(x => x.Id == o.AlternativeWholeSalerId).Select(x => x.Name).FirstOrDefaultAsync(); + + //Ok, this one I'm not comfortable with but it was insisted upon + //so if there turns out to be a situation where there are just too many serials slowing down the reporting always + //can look at tying this to the report data list column selection to check if serials are selected to display or not + o.PartSerialsViz = $"[{string.Join(',', (await ct.PartSerial.Where(z => z.PartId == o.Id).OrderBy(z => z.Serial).Select(z => $"'{z.Serial}'").ToListAsync()))}]"; + + + + } //////////////////////////////////////////////////////////////////////////////////////////////// @@ -659,7 +668,7 @@ namespace AyaNova.Biz public async Task HandlePotentialNotificationEvent(AyaEvent ayaEvent, ICoreBizObjectModel proposedObj, ICoreBizObjectModel currentObj = null) { ILogger log = AyaNova.Util.ApplicationLogging.CreateLogger(); - if(ServerBootConfig.SEEDING || ServerBootConfig.MIGRATING) return; + if (ServerBootConfig.SEEDING || ServerBootConfig.MIGRATING) return; log.LogDebug($"HandlePotentialNotificationEvent processing: [AyaType:{this.BizType}, AyaEvent:{ayaEvent}]"); bool isNew = currentObj == null; diff --git a/server/AyaNova/models/Part.cs b/server/AyaNova/models/Part.cs index dda534aa..8ec16e70 100644 --- a/server/AyaNova/models/Part.cs +++ b/server/AyaNova/models/Part.cs @@ -44,6 +44,8 @@ namespace AyaNova.Models public string UnitOfMeasure { get; set; } public string UPC { get; set; } + [NotMapped] + public string PartSerialsViz { get; set; } public Part()