コード例 #1
0
        /// <summary>
        /// The posted ScanText is ucc1281d.
        /// We try to keep every scanned box on the same temporary pallet. If the criteria does not match
        /// we ask user to scan a new pallet and transfer the temp pallet contents to the scanned pallet.
        /// If a box is scanned which is already on some pallet, we treat it as a pallet scan.
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        /// <remarks>
        /// Posted values expected:
        ///   model.ScanText: The box scanned by the user
        ///   model.PalletId: The pallet on which we wish to place the box
        ///   model.CustomerId, PoId, CustomerDcId, BucketId: The the box must qualify this criteria before we allow it to be placed on the pallet
        /// </remarks>
        private ActionResult DoHandleBoxScan(ScanToPalletViewModel model)
        {
            //TC7: When model state is not valid.
            if (!ModelState.IsValid)
            {
                return(View(Views.ScanToPallet, model));
            }

            var box = _service.GetBox(model.ScanText, _uiType == UiType.Vas);

            //TC8: If any invalid box is scanned.[For eg: not verified,shipped]
            if (box == null)
            {
                // Not a valid box
                ModelState.AddModelError("", string.Format("Box {0} does not exist.", model.ScanText));
                return(RedirectToAction(this.Actions.ActivatePallet(model.PalletId, model.ScanText, Sound.Error)));
            }

            //TC9: if box is not marked for VAS and trying to palletize for VAS
            if (_uiType == UiType.Vas)
            {
                if (!box.IsVasRequired)
                {
                    ModelState.AddModelError("box.IsVasRequired", string.Format("VAS is not required for the box {0}.", box.Ucc128Id));
                    return(RedirectToAction(this.Actions.ActivatePallet(model.PalletId, model.ScanText, Sound.Error)));
                }
                if (box.IsVasCompleted)
                {
                    AddStatusMessage(string.Format("VAS is already completed on box {0}.", model.ScanText));
                    return(RedirectToAction(this.Actions.ActivatePallet(model.PalletId, model.ScanText, Sound.Error)));
                }
                if (string.Compare(box.IaId, _service.GetBadPitchArea()) == 0)
                {
                    ModelState.AddModelError("", "Scanned box is not valid for VAS as it is not pitched successfully.");
                    return(RedirectToAction(this.Actions.ActivatePallet(model.PalletId, model.ScanText, Sound.Error)));
                }
            }

            //Handling those Boxes which are already on pallet, that was assigned by any other module
            if (box.ScanToPalletDate == null)
            {
                //If box is on any pallet which was not assigned by ScanToPallet, we will not entertain here.
                box.PalletId = null;
            }

            //TC10: Box is not valid.[i.e box is not verified or shipped].
            if (!TryValidateModel(new BoxModel(box)) || (_uiType == UiType.ScanToPallet && box.VerifyDate == null) ||
                (_uiType == UiType.ScanToPallet && !string.IsNullOrWhiteSpace(box.SmallShipmentFlag)))
            {
                if (_uiType == UiType.ScanToPallet && box.VerifyDate == null)
                {
                    ModelState.AddModelError("box.VerifyDate", "Box has not been verified yet.");
                }
                if (_uiType == UiType.ScanToPallet && !string.IsNullOrWhiteSpace(box.SmallShipmentFlag))
                {
                    ModelState.AddModelError("box.SmallShipmentFlag", "Boxes of small shipments cannot be palletized.");
                }
                // Box is not appropriate for palletizing. Not Verified, shipped, etc.
                return(RedirectToAction(this.Actions.ActivatePallet(model.PalletId, model.ScanText, Sound.Error)));
            }
            // Redirecting to activate Pallet since this box is already on a pallet and currently no pallet is active.
            //In case if there is an active pallet and the scanned box is on a pallet then box will leave its old pallet
            //and become part of the active pallet.
            //TODO:If the active pallet is same as the box pallet then no need to try to put box on pallet again. Due to this qualifying box count is also getting disturbed (MBisht 6 July 2012)
            //TC8: when box pallet is not null and pallet passed as null from the model.
            if (!string.IsNullOrEmpty(box.PalletId) && string.IsNullOrEmpty(model.PalletId))
            {
                this.AddStatusMessage(string.Format("This box is already on pallet {0}. Start scanning boxes to keep them on this pallet.", box.PalletId));
                return(RedirectToAction(this.Actions.ActivatePallet(box.PalletId, model.ScanText)));
            }
            //TC9: When either bucket or customer distribution centre or purchase order or customer of box and model are not equal.
            if (!WildEqual(box.BucketId, model.BucketId) || !WildEqual(box.CustomerDcId, model.CustomerDcId) ||
                !WildEqual(box.PoId, model.PoId) || !WildEqual(box.CustomerId, model.CustomerId))
            {
                ModelState.AddModelError("", "Criteria mismatch, if you have a staging pallet then scan a new or suggested pallet and put the current boxes on it.");
                return(RedirectToAction(this.Actions.ActivatePallet(model.PalletId, model.ScanText, Sound.Error)));
            }

            model.PalletId = _service.PutBoxOnPallet(model.PalletId, model.ScanText, _uiType == UiType.Vas);

            if (_uiType == UiType.Vas)
            {
                //Here box required VAS, Mark VAS completed for the scanned Box.
                _service.MarkVasComplete(model.ScanText);
                AddStatusMessage(string.Format("VAS completed on box {0}.", model.ScanText));
            }

            // Sharad 6 Jul 2012: Not redirecting to optimize performance on ring scanners
            //return RedirectToAction(this.Actions.ActivatePallet(model.PalletId, model.ScanText));
            return(ActivatePallet(model.PalletId, model.ScanText));
        }
コード例 #2
0
        /// <summary>
        ///  Returns source pallet information. If a box is scanned which is on a pallet
        ///  we consider it as equivalent to pallet scan.
        /// </summary>
        /// <returns>
        /// Returns source pallet information.
        /// </returns>
        public virtual ActionResult SourcePallet(IndexViewModel model)
        {
            //TC1: If the model state is not valid.[For eg: when no pallet is passed and press enter].
            if (!ModelState.IsValid)
            {
                return(View(Views.Index, model));
            }
            //TC2: If the entered value is a box.
            if (__regexUcc.IsMatch(model.ScanText))
            {
                // Box is on a pallet. Consider it equivalent to pallet scan.
                var box = _service.GetBox(model.ScanText, false);
                //TC3: If the entered box is not on any pallet.
                if (box == null || string.IsNullOrEmpty(box.PalletId))
                {
                    ModelState.AddModelError("", string.Format("Scanned Box {0} is not on any pallet.", model.ScanText));
                    return(View(Views.Index, model));
                }
                else
                {
                    //TC: Box is not valid.[i.e box is not verified or shipped].
                    if (!TryValidateModel(new BoxModel(box)) || box.VerifyDate == null || !string.IsNullOrWhiteSpace(box.SmallShipmentFlag))
                    {
                        if (box.VerifyDate == null)
                        {
                            ModelState.AddModelError("box.VerifyDate", "Box has not been verified yet.");
                        }
                        if (!string.IsNullOrWhiteSpace(box.SmallShipmentFlag))
                        {
                            ModelState.AddModelError("box.SmallShipmentFlag", "Boxes of small shipments cannot be palletized.");
                        }
                        // Box is not appropriate for palletizing. Not Verified, shipped, etc.
                        return(RedirectToAction(this.Actions.Index(Sound.Error)));
                    }
                }
                model.PalletId = box.PalletId;
            }
            //TC4: If the entered value is a pallet.
            else if (__regexPallet.IsMatch(model.ScanText))
            {
                model.PalletId = model.ScanText;
            }
            else
            {
                ModelState.AddModelError("", string.Format("Scan text {0} is not recognized.", model.ScanText));
                return(View(Views.Index, model));
            }
            var boxesOfPallet = _service.GetBoxesOfPallet(model.PalletId);

            //TC5: If an empty pallet is scanned.
            if (boxesOfPallet != null && !boxesOfPallet.Any())
            {
                //Pallet is empty,Can't move or merge.
                ModelState.AddModelError("", string.Format("Pallet {0} does not contain any boxes.", model.PalletId));
                return(View(Views.Index, model));
            }
            else
            {
                //Validate boxes of pallet.
                foreach (var box in boxesOfPallet)
                {
                    //TC: Boxes are not valid.[i.e box is not verified or shipped].
                    if (!TryValidateModel(new BoxModel(box)) || box.VerifyDate == null || !string.IsNullOrWhiteSpace(box.SmallShipmentFlag))
                    {
                        if (box.VerifyDate == null)
                        {
                            ModelState.AddModelError("box.VerifyDate", string.Format("Boxes of pallet {0} have not been verified yet.", model.PalletId));
                        }
                        if (!string.IsNullOrWhiteSpace(box.SmallShipmentFlag))
                        {
                            ModelState.AddModelError("box.SmallShipmentFlag", "Boxes of small shipments cannot be palletized.");
                        }
                        // Boxes are not appropriate for palletizing. Not Verified, shipped, etc.
                        return(RedirectToAction(this.Actions.Index(Sound.Error)));
                    }
                }
            }
            try
            {
                _service.EnsureCriteriaPure(boxesOfPallet, false);
            }
            catch (BoxManagerServiceException ex)
            {
                switch (ex.ErrorCode)
                {
                case BoxManagerServiceErrorCode.MultipleBucketPallet:
                    ModelState.AddModelError("", string.Format("Pallet {0} does not satisfy criteria because it contains boxes of multiple buckets {1}.",
                                                               model.PalletId, ex.Data["Data"]));
                    break;

                case BoxManagerServiceErrorCode.MultipleCustomerPallet:
                    ModelState.AddModelError("", string.Format("Pallet {0} does not satisfy criteria because it contains boxes of multiple customers {1}.",
                                                               model.PalletId, ex.Data["Data"]));
                    break;

                case BoxManagerServiceErrorCode.MultipleDcPallet:
                    ModelState.AddModelError("", string.Format("Pallet {0} does not satisfy criteria because it contains boxes of multiple DCs {1}.",
                                                               model.PalletId, ex.Data["Data"]));
                    break;

                case BoxManagerServiceErrorCode.MultiplePoPallet:
                    ModelState.AddModelError("", string.Format("Pallet {0} does not satisfy criteria because it contains boxes of multiple POs {1}.",
                                                               model.PalletId, ex.Data["Data"]));
                    break;
                }
                return(RedirectToAction(this.Actions.Index(Sound.Error)));
            }
            // Now ask for validation
            return(RedirectToAction(this.Actions.ValidatePallet(model.PalletId)));
        }