示例#1
0
        public Int64 getTrailerDoorSuggestion(Int64 ixFacility)
        {
            List <InventoryLocationsPost> putAwaySuggestions = new List <InventoryLocationsPost>();
            //Receiving RC
            //Reserve Storage RV
            //Let Down Storage    LD
            //Forward Pick Storage    FP
            //Consolidation   CN
            //Shipping    SH
            //Staging ST
            //Trailer Doors TR
            //Person PE
            var allowedLocationFunctions = _locationfunctionsService.IndexDb().Where(x =>
                                                                                     x.sLocationFunctionCode == "CN" ||
                                                                                     x.sLocationFunctionCode == "SH" ||
                                                                                     x.sLocationFunctionCode == "ST" ||
                                                                                     x.sLocationFunctionCode == "TR"
                                                                                     ).Select(x => x.ixLocationFunction).ToList();

            //We implemenent a basic strategy we see if we a trailer door not currently assigned to a carrier manifest - if not we get the TR with the lowest sequence number

            var allocatedTrailerDoors = _outboundcarriermanifestsService.IndexDb().Where(x => x.ixStatus == _commonLookUps.getStatuses().Where(s => s.sStatus == "Active").Select(s => s.ixStatus).FirstOrDefault()).Select(x => x.ixPickupInventoryLocation).Distinct().ToList();

            if (_inventorylocationsService.IndexDb().Where(x =>
                                                           x.ixFacility == ixFacility &&
                                                           x.LocationFunctions.sLocationFunctionCode == "TR" &&
                                                           !allocatedTrailerDoors.Contains(x.ixInventoryLocation)
                                                           ).Any()
                )
            {
                return(_inventorylocationsService.IndexDb().Where(x =>
                                                                  x.ixFacility == ixFacility &&
                                                                  x.LocationFunctions.sLocationFunctionCode == "TR" &&
                                                                  !allocatedTrailerDoors.Contains(x.ixInventoryLocation)
                                                                  ).Select(x => x.ixInventoryLocation).FirstOrDefault());
            }
            else
            {
                return(_inventorylocationsService.IndexDb().Where(x =>
                                                                  x.ixFacility == ixFacility &&
                                                                  x.LocationFunctions.sLocationFunctionCode == "TR"
                                                                  ).Select(x => x.ixInventoryLocation).FirstOrDefault());
            }
        }
示例#2
0
        public Task Edit(PickBatchesPost pickbatchesPost)
        {
            // Additional validations

            // Pre-process

            // Process
            this._pickbatchesRepository.RegisterEdit(pickbatchesPost);
            try
            {
                this._pickbatchesRepository.Commit();
            }
            catch (Exception ex)
            {
                this._pickbatchesRepository.Rollback();
                // Log exception
                throw;
            }

            // Post-process
            //Custom Code Start | Added Code Block

            if (pickbatchesPost.ixStatus == _commonLookUps.getStatuses().Where(s => s.sStatus == "Complete").Select(s => s.ixStatus).FirstOrDefault())
            {
                // We check if the shipment associated with the orders on the batch has been manifested. If not we try and find an active manifest else we create a new one and add the shipment to it
                var outboundShipments = _outboundordersRepository.IndexDb().Where(x => x.ixPickBatch == pickbatchesPost.ixPickBatch).Select(x => x.ixOutboundShipment).ToList();
                var outboundShipmentsNotManifested = _outboundshipmentsService.IndexDb().Where(x => x.ixOutboundCarrierManifest == null)
                                                     .Join(outboundShipments, os => os.ixOutboundShipment, o => o, (os, o) => new { Os = os, O = o })
                                                     .Select(s => s.Os.ixOutboundShipment).ToList();

                outboundShipmentsNotManifested.ForEach(x =>
                {
                    var outboundShipment = _outboundshipmentsService.GetPost(x);
                    if (
                        _outboundcarriermanifestsService.IndexDb().Where(m =>
                                                                         m.ixFacility == outboundShipment.ixFacility &&
                                                                         m.ixCarrier == outboundShipment.ixCarrier &&
                                                                         m.ixStatus == _commonLookUps.getStatuses().Where(s => s.sStatus == "Active").Select(s => s.ixStatus).FirstOrDefault()
                                                                         ).Any())
                    {
                        var ixOutboundCarrierManifest = _outboundcarriermanifestsService.IndexDb().Where(m =>
                                                                                                         m.ixFacility == outboundShipment.ixFacility &&
                                                                                                         m.ixCarrier == outboundShipment.ixCarrier &&
                                                                                                         m.ixStatus == _commonLookUps.getStatuses().Where(s => s.sStatus == "Active").Select(s => s.ixStatus).FirstOrDefault()
                                                                                                         ).Select(m => m.ixOutboundCarrierManifest).FirstOrDefault();
                        outboundShipment.ixOutboundCarrierManifest = ixOutboundCarrierManifest;
                        outboundShipment.UserName = pickbatchesPost.UserName;
                        _outboundshipmentsService.Edit(outboundShipment);
                    }
                    else
                    {
                        OutboundCarrierManifestsPost outboundCarrierManifestsPost = new OutboundCarrierManifestsPost();
                        outboundCarrierManifestsPost.ixFacility = outboundShipment.ixFacility;
                        outboundCarrierManifestsPost.ixCarrier  = outboundShipment.ixCarrier;
                        outboundCarrierManifestsPost.ixPickupInventoryLocation = _shipping.getTrailerDoorSuggestion(outboundShipment.ixFacility);
                        outboundCarrierManifestsPost.ixStatus            = _commonLookUps.getStatuses().Where(s => s.sStatus == "Active").Select(s => s.ixStatus).FirstOrDefault();
                        outboundCarrierManifestsPost.dtScheduledPickupAt = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day) + _outboundshipmentsService.CarriersDb().Where(c => c.ixCarrier == outboundShipment.ixCarrier).Select(c => c.dtScheduledPickupTime).FirstOrDefault();
                        outboundCarrierManifestsPost.UserName            = pickbatchesPost.UserName;
                        var ixOutboundCarrierManifest = _outboundcarriermanifestsService.Create(outboundCarrierManifestsPost).Result;
                        outboundShipment.ixOutboundCarrierManifest = ixOutboundCarrierManifest;
                        outboundShipment.UserName = pickbatchesPost.UserName;
                        _outboundshipmentsService.Edit(outboundShipment);
                    }
                }
                                                       );
            }
            //Custom Code End



            return(Task.CompletedTask);
        }