internal static Expression <Func <LotProductionResults, ProductionRecapLot> > SelectProductionRecap(IQueryable <ProductionBatch> productionBatches) { var product = ProductProjectors.SelectChileProductSummary(); var location = LocationProjectors.SelectLocation(); var lotKey = LotProjectors.SelectLotKey <ChileLotProduction>(); var batchPredicate = ProductionBatchPredicates.ByLotKeyEntity <LotProductionResults>(); var batchSelect = PackScheduleProjectors.SelectProductionRecap(); return(Projector <LotProductionResults> .To(p => new ProductionRecapLot { ProductionType = p.Production.ProductionType, LotProductionStatus = p.Production.ResultingChileLot.Lot.ProductionStatus, LotQualityStatus = p.Production.ResultingChileLot.Lot.QualityStatus, OutOfSpec = p.Production.ResultingChileLot.Lot.ProductSpecOutOfRange, ProductionBegin = p.ProductionBegin, ProductionEnd = p.ProductionEnd, ProductionLocation = location.Invoke(p.ProductionLineLocation), ChileProduct = product.Invoke(p.Production.ResultingChileLot.ChileProduct), LotKey = lotKey.Invoke(p.Production), TotalInputWeight = p.Production.PickedInventory.Items.Any() ? p.Production.PickedInventory.Items.Sum(i => i.Quantity *i.PackagingProduct.Weight) : 0.0, TotalOutputWeight = p.ResultItems.Any() ? p.ResultItems.Sum(i => i.Quantity *i.PackagingProduct.Weight) : 0.0, Shift = p.ShiftKey, ProductionBatch = productionBatches.Where(b => batchPredicate.Invoke(p, b)).Select(b => batchSelect.Invoke(b.PackSchedule)).FirstOrDefault(), UnresolvedDefects = p.Production.ResultingChileLot.Lot.LotDefects.Where(d => d.Resolution == null).Select(d => d.Description) })); }
internal static IEnumerable <Expression <Func <PickedInventoryItem, PickSheetItemReturn> > > SplitSelectPickSheetItem() { var key = SelectKey(); var lotKey = LotProjectors.SelectLotKey <Lot>(); var locationKey = LocationProjectors.SelectLocationKey(); var loBac = LotProjectors.SelectLoBac(); var lotProduct = LotProjectors.SelectDerivedProduct(); var packagingProduct = ProductProjectors.SelectPackagingProduct(); var treatment = InventoryTreatmentProjectors.SelectInventoryTreatment(); return(new Projectors <PickedInventoryItem, PickSheetItemReturn> { i => new PickSheetItemReturn { LocationKeyReturn = locationKey.Invoke(i.FromLocation), Description = i.FromLocation.Description, PickedInventoryItemKeyReturn = key.Invoke(i), LotKeyReturn = lotKey.Invoke(i.Lot), Quantity = i.Quantity, LoBac = loBac.Invoke(i.Lot), CustomerProductCode = i.CustomerProductCode }, i => new PickSheetItemReturn { LotProduct = lotProduct.Invoke(i.Lot), InventoryTreatment = treatment.Invoke(i.Treatment) }, i => new PickSheetItemReturn { PackagingProduct = packagingProduct.Invoke(i.PackagingProduct), NetWeight = i.Quantity * i.PackagingProduct.Weight } }); }
private static IEnumerable <Expression <Func <LotProductionResults, ProductionResultReturn> > > SplitSelectReturn() { var productionLocationKey = LocationProjectors.SelectLocationKey(); var lotKey = LotProjectors.SelectLotKey <LotProductionResults>(); var productKey = ProductProjectors.SelectProductKey(); return(new[] { SelectBase().Merge(r => new ProductionResultReturn { LotKeyReturn = lotKey.Invoke(r), DateTimeEntered = r.DateTimeEntered, ProductionStartDate = r.ProductionBegin }).ExpandAll(), Projector <LotProductionResults> .To(r => new ProductionResultReturn { User = r.Employee.UserName, ProductionLocationKeyReturn = productionLocationKey.Invoke(r.ProductionLineLocation) }), Projector <LotProductionResults> .To(r => new ProductionResultReturn { ChileProductName = r.Production.ResultingChileLot.ChileProduct.Product.Name, ChileProductKeyReturn = productKey.Invoke(r.Production.ResultingChileLot.ChileProduct.Product) }) }); }
internal static IEnumerable <Expression <Func <PackSchedule, PackScheduleSummaryReturn> > > SplitSelectSummary() { var productionLocationKey = LocationProjectors.SelectLocationKey(); var workTypeKey = WorkTypeProjectors.SelectWorkTypeKey(); var productKey = ProductProjectors.SelectProductKey(); var company = CustomerProjectors.SelectCompanyHeader(); return(new[] { SelectBaseParameters().Merge(p => new PackScheduleSummaryReturn { DateCreated = p.DateCreated, ScheduledProductionDate = p.ScheduledProductionDate, ProductionDeadline = p.ProductionDeadline, OrderNumber = p.OrderNumber }).ExpandAll(), Projector <PackSchedule> .To(p => new PackScheduleSummaryReturn { WorkTypeKeyReturn = workTypeKey.Invoke(p.WorkType), ChileProductKeyReturn = productKey.Invoke(p.ChileProduct.Product), ChileProductName = p.ChileProduct.Product.Name, }), Projector <PackSchedule> .To(p => new PackScheduleSummaryReturn { ProductionLocationKeyReturn = productionLocationKey.Invoke(p.ProductionLineLocation), Customer = new[] { p.Customer }.Where(c => c != null).Select(c => company.Invoke(c)).FirstOrDefault(), }) }); }
internal static IEnumerable <Expression <Func <Inventory, InventoryItemReturn> > > SplitSelectInventorySummary(IInventoryUnitOfWork inventoryUnitOfWork, DateTime currentDate) { if (inventoryUnitOfWork == null) { throw new ArgumentNullException("inventoryUnitOfWork"); } currentDate = currentDate.Date; var inventoryKey = SelectInventoryKey(); var packagingProduct = ProductProjectors.SelectPackagingProduct(); var warehouseLocation = LocationProjectors.SelectLocation(); var treament = InventoryTreatmentProjectors.SelectInventoryTreatment(); return(LotProjectors.SplitSelectLotSummary(inventoryUnitOfWork, currentDate) .Select(p => p.Merge(Projector <Inventory> .To(n => new InventoryItemReturn { }), n => n.Lot)) .ToListWithModifiedElement(0, p => p.Merge(n => new InventoryItemReturn { InventoryKeyReturn = inventoryKey.Invoke(n), ToteKey = n.ToteKey, Quantity = n.Quantity }).ExpandAll()) .ToAppendedList(Projector <Inventory> .To(i => new InventoryItemReturn { PackagingReceived = packagingProduct.Invoke(i.Lot.ReceivedPackaging), PackagingProduct = packagingProduct.Invoke(i.PackagingProduct), Location = warehouseLocation.Invoke(i.Location), InventoryTreatment = treament.Invoke(i.Treatment) }))); }
internal static Expression <Func <PickedInventoryItem, ProductionBatch, PickedForBatchTransactionReturn> > SelectTransaction(ILotUnitOfWork lotUnitOfWork) { var lotKey = LotProjectors.SelectLotKey <Lot>(); var batchLotKey = LotProjectors.SelectLotKey <ProductionBatch>(); var packScheduleKey = PackScheduleProjectors.SelectKey(); var product = LotProjectors.SelectDerivedProduct(); var location = LocationProjectors.SelectLocation(); var treatment = InventoryTreatmentProjectors.SelectInventoryTreatment(); var packaging = ProductProjectors.SelectPackagingProduct(); return(Projector <PickedInventoryItem, ProductionBatch> .To((i, b) => new PickedForBatchTransactionReturn { EmployeeName = i.PickedInventory.Employee.UserName, TimeStamp = i.PickedInventory.TimeStamp, TransactionType = InventoryTransactionType.PickedForBatch, Quantity = -i.Quantity, Weight = -i.Quantity * i.PackagingProduct.Weight, ToteKey = i.ToteKey, SourceLotVendorName = new[] { i.Lot.Vendor }.Where(v => v != null).Select(v => v.Name).FirstOrDefault(), SourceLotPurchaseOrderNumber = i.Lot.PurchaseOrderNumber, SourceLotShipperNumber = i.Lot.ShipperNumber, Product = product.Invoke(i.Lot), Packaging = packaging.Invoke(i.PackagingProduct), Location = location.Invoke(i.FromLocation), Treatment = treatment.Invoke(i.Treatment), SourceLotKeyReturn = lotKey.Invoke(i.Lot), DestinationLotKeyReturn = batchLotKey.Invoke(b), PackScheduleKeyReturn = packScheduleKey.Invoke(b.PackSchedule) })); }
internal static Expression <Func <InventoryTransaction, InventoryTransactionReturn> > Select(ILotUnitOfWork lotUnitOfWork) { var lotKey = LotProjectors.SelectLotKey <Lot>(); var product = LotProjectors.SelectDerivedProduct(); var location = LocationProjectors.SelectLocation(); var treatment = InventoryTreatmentProjectors.SelectInventoryTreatment(); var packaging = ProductProjectors.SelectPackagingProduct(); return(Projector <InventoryTransaction> .To(t => new InventoryTransactionReturn { EmployeeName = t.Employee.UserName, TimeStamp = t.TimeStamp, TransactionType = t.TransactionType, SourceReference = t.SourceReference, Quantity = t.Quantity, Weight = t.Quantity * t.PackagingProduct.Weight, ToteKey = t.ToteKey, SourceLotVendorName = new [] { t.SourceLot.Vendor }.Where(v => v != null).Select(v => v.Name).FirstOrDefault(), SourceLotPurchaseOrderNumber = t.SourceLot.PurchaseOrderNumber, SourceLotShipperNumber = t.SourceLot.ShipperNumber, SourceLotPackagingReceived = packaging.Invoke(t.SourceLot.ReceivedPackaging), Product = product.Invoke(t.SourceLot), Packaging = packaging.Invoke(t.PackagingProduct), Location = location.Invoke(t.Location), Treatment = treatment.Invoke(t.Treatment), SourceLotKeyReturn = lotKey.Invoke(t.SourceLot), DestinationLotKeyReturn = new[] { t.DestinationLot }.Where(l => l != null).Select(l => lotKey.Invoke(l)).FirstOrDefault() })); }
internal static Expression <Func <PickedInventoryItem, PickedInventoryItemReturn> > SelectMillAndWetdownPickedItem(ILotUnitOfWork lotUnitOfWork) { if (lotUnitOfWork == null) { throw new ArgumentNullException("lotUnitOfWork"); } var pickedInventoryItemKey = SelectKey(); var inventoryKey = SelectInventoryKey(); var lotKey = LotProjectors.SelectLotKey <Lot>(); var lotProduct = LotProjectors.SelectDerivedProduct(); var packagingProduct = ProductProjectors.SelectPackagingProduct(); var location = LocationProjectors.SelectLocation(); return(i => new PickedInventoryItemReturn { PickedInventoryItemKeyReturn = pickedInventoryItemKey.Invoke(i), InventoryKeyReturn = inventoryKey.Invoke(i), LotKeyReturn = lotKey.Invoke(i.Lot), LotDateCreated = i.LotDateCreated, ToteKey = i.ToteKey, QuantityPicked = i.Quantity, CustomerLotCode = i.CustomerLotCode, CustomerProductCode = i.CustomerProductCode, TotalWeightPicked = (int)(i.PackagingProduct.Weight * i.Quantity), LotProduct = lotProduct.Invoke(i.Lot), PackagingProduct = packagingProduct.Invoke(i.PackagingProduct), Location = location.Invoke(i.FromLocation) }); }
internal static Expression <Func <LotProductionResults, ProductionResultBaseReturn> > SelectBase() { var location = LocationProjectors.SelectLocation(); return(r => new ProductionResultBaseReturn { ProductionEndDate = r.ProductionEnd, ProductionShiftKey = r.ShiftKey, ProductionLocation = location.Invoke(r.ProductionLineLocation) }); }
internal static IEnumerable <Expression <Func <PickedInventoryItem, PickedInventoryItemReturn> > > SplitSelect(IInventoryUnitOfWork inventoryUnitOfWork, DateTime currentDate, ISalesUnitOfWork salesUnitOfWork = null) { if (inventoryUnitOfWork == null) { throw new ArgumentNullException("inventoryUnitOfWork"); } var pickedInventoryItemKey = SelectKey(); var inventoryKey = SelectInventoryKey(); var inventoryQuantity = SelectInventoryQuantity(); var treatment = InventoryTreatmentProjectors.SelectInventoryTreatment(); var location = LocationProjectors.SelectLocation(); var packagingProduct = ProductProjectors.SelectPackagingProduct(); var results = LotProjectors.SplitSelectLotSummary(inventoryUnitOfWork, currentDate) .Select(p => p.Merge((Expression <Func <PickedInventoryItem, PickedInventoryItemReturn> >)(n => new PickedInventoryItemReturn { }), n => n.Lot)) .ToListWithModifiedElement(0, p => p.Merge(i => new PickedInventoryItemReturn { PickedInventoryItemKeyReturn = pickedInventoryItemKey.Invoke(i), InventoryKeyReturn = inventoryKey.Invoke(i), ToteKey = i.ToteKey, QuantityPicked = i.Quantity, CustomerLotCode = i.CustomerLotCode, CustomerProductCode = i.CustomerProductCode })) .ToAppendedList(i => new PickedInventoryItemReturn { PackagingProduct = packagingProduct.Invoke(i.PackagingProduct), Location = location.Invoke(i.FromLocation), InventoryTreatment = treatment.Invoke(i.Treatment), }, i => new PickedInventoryItemReturn { PackagingReceived = packagingProduct.Invoke(i.Lot.ReceivedPackaging), Quantity = inventoryQuantity.Invoke(i), CurrentLocation = location.Invoke(i.CurrentLocation), }); if (salesUnitOfWork != null) { var orderItemKey = InventoryPickOrderItemProjectors.SelectKey(); var customerPickedItems = salesUnitOfWork.SalesOrderPickedItemRepository.All(); results.Add(i => new PickedInventoryItemReturn { PickOrderItemKeyReturn = customerPickedItems .Where(c => c.DateCreated == i.DateCreated && c.Sequence == i.Sequence && c.ItemSequence == i.ItemSequence) .Select(c => orderItemKey.Invoke(c.SalesOrderItem.InventoryPickOrderItem)) .FirstOrDefault() }); } return(results.Select(p => p.ExpandAll())); }
internal static Expression <Func <ProductionSchedule, ProductionScheduleSummaryReturn> > SelectSummary() { var key = SelectKey(); var location = LocationProjectors.SelectLocation(); return(Projector <ProductionSchedule> .To(p => new ProductionScheduleSummaryReturn { ProductionScheduleKeyReturn = key.Invoke(p), ProductionDate = p.ProductionDate, ProductionLine = location.Invoke(p.ProductionLineLocation) })); }
internal static Expression <Func <LotProductionResultItem, MillAndWetdownResultItemReturn> > SelectMillAndWetdownResultItem() { var key = SelectProductionResultItemKey(); var warehouseLocation = LocationProjectors.SelectLocation(); var packagingProduct = ProductProjectors.SelectPackagingProduct(); return(r => new MillAndWetdownResultItemReturn { ItemKeyReturn = key.Invoke(r), PackagingProduct = packagingProduct.Invoke(r.PackagingProduct), Location = warehouseLocation.Invoke(r.Location), QuantityProduced = r.Quantity, TotalWeightProduced = (int)(r.Quantity * r.PackagingProduct.Weight) }); }
internal static Expression <Func <LotProductionResultItem, ProductionResultItemReturn> > Select() { var key = SelectProductionResultItemKey(); var packagingProduct = ProductProjectors.SelectPackagingProduct(); var warehouseLocation = LocationProjectors.SelectLocation(); var treatment = InventoryTreatmentProjectors.SelectInventoryTreatment(); return(i => new ProductionResultItemReturn { LotProductionResultItemKeyReturn = key.Invoke(i), PackagingProduct = packagingProduct.Invoke(i.PackagingProduct), Location = warehouseLocation.Invoke(i.Location), Treatment = treatment.Invoke(i.Treatment), Quantity = i.Quantity }); }
internal static Expression <Func <ChileMaterialsReceivedItem, ChileMaterialsReceivedItemReturn> > Select() { var key = SelectKey(); var packagingProduct = ProductProjectors.SelectPackagingProduct(); var location = LocationProjectors.SelectLocation(); return(SelectBase().Merge(i => new ChileMaterialsReceivedItemReturn { ChileMaterialsReceivedItemKeyReturn = key.Invoke(i), Variety = i.ChileVariety, Quantity = i.Quantity, TotalWeight = (int)(i.Quantity * i.PackagingProduct.Weight), PackagingProduct = packagingProduct.Invoke(i.PackagingProduct), Location = location.Invoke(i.Location) })); }
internal static Expression <Func <Facility, FacilityReturn> > Select(bool includeDetails, bool includeShippingInfo) { var key = SelectFacilityKey(); var projector = Projector <Facility> .To(f => new FacilityReturn { FacilityKeyReturn = key.Invoke(f), FacilityName = f.Name, Active = f.Active }); if (includeDetails) { var location = LocationProjectors.SelectLocation(); projector = projector.Merge(f => new FacilityReturn { Locations = f.Locations.Select(l => location.Invoke(l)), FacilityType = f.FacilityType }); } if (includeShippingInfo) { projector = projector.Merge(f => new FacilityReturn { ShippingLabel = new ShippingLabelReturn { Name = f.ShippingLabelName, Phone = f.PhoneNumber, EMail = f.EMailAddress, AddressLine1 = f.Address.AddressLine1, AddressLine2 = f.Address.AddressLine2, AddressLine3 = f.Address.AddressLine3, City = f.Address.City, State = f.Address.State, PostalCode = f.Address.PostalCode, Country = f.Address.Country } }); } return(projector); }
internal static IEnumerable <Expression <Func <ProductionSchedule, ProductionScheduleDetailReturn> > > SelectDetail() { var key = SelectKey(); var location = LocationProjectors.SelectLocation(); var itemSelect = ProductionScheduleItemProjectors.Select(); return(new Projectors <ProductionSchedule, ProductionScheduleDetailReturn> { p => new ProductionScheduleDetailReturn { ProductionScheduleKeyReturn = key.Invoke(p), ProductionDate = p.ProductionDate, ProductionLine = location.Invoke(p.ProductionLineLocation), }, { itemSelect, p => i => new ProductionScheduleDetailReturn { ScheduledItems = i.ScheduledItems.OrderBy(n => n.Index).Select(n => p.Invoke(n)) } } }); }
private static Expression <Func <ChileLotProduction, MillAndWetdownReturn> > SelectBase() { var lotKey = LotProjectors.SelectLotKey <ChileLotProduction>(); var productKey = ProductProjectors.SelectProductKey(); var productionLocationKey = LocationProjectors.SelectLocationKey(); return(m => new MillAndWetdownReturn { OutputChileLotKeyReturn = lotKey.Invoke(m), ChileProductKeyReturn = productKey.Invoke(m.ResultingChileLot.ChileProduct.Product), ProductionLineLocationKeyReturn = productionLocationKey.Invoke(m.Results.ProductionLineLocation), ShiftKey = m.Results.ShiftKey, ProductionLineDescription = m.Results.ProductionLineLocation.Description, ChileProductName = m.ResultingChileLot.ChileProduct.Product.Name, ProductionBegin = m.Results.ProductionBegin, ProductionEnd = m.Results.ProductionEnd, TotalProductionTimeMinutes = EntityFunctions.DiffMinutes(m.Results.ProductionBegin, m.Results.ProductionEnd) ?? 0, TotalWeightProduced = m.Results.ResultItems.Any() ? (int)m.Results.ResultItems.Sum(i => i.PackagingProduct.Weight * i.Quantity) : 0, TotalWeightPicked = m.PickedInventory.Items.Any() ? (int)m.PickedInventory.Items.Sum(i => i.PackagingProduct.Weight * i.Quantity) : 0 }); }
internal static Expression <Func <InventoryAdjustmentItem, InventoryAdjustmentItemReturn> > Select(ILotUnitOfWork lotUnitOfWork) { var key = SelectKey(); var inventoryProduct = LotProjectors.SelectDerivedProduct(); var lotKey = LotProjectors.SelectLotKey <Lot>(); var warehouseLocation = LocationProjectors.SelectLocation(); var packagingProduct = ProductProjectors.SelectPackagingProduct(); var treatment = InventoryTreatmentProjectors.SelectInventoryTreatment(); return(i => new InventoryAdjustmentItemReturn { InventoryAdjustmentItemKeyReturn = key.Invoke(i), AdjustmentQuantity = i.QuantityAdjustment, InventoryProduct = inventoryProduct.Invoke(i.Lot), LotKeyReturn = lotKey.Invoke(i.Lot), Location = warehouseLocation.Invoke(i.Location), PackagingProduct = packagingProduct.Invoke(i.PackagingProduct), InventoryTreatment = treatment.Invoke(i.Treatment), ToteKey = i.ToteKey }); }