Ejemplo n.º 1
0
        private void ProcessCreateProduct(NativeActivityContext context)
        {
            #region  .  Checks&Ini  .

            if (_items == null || _items.Count == 0)
            {
                return;
            }

            var iwbId         = IWBId.Get(context);
            var placeCode     = PlaceCode.Get(context);
            var operationCode = OperationCode.Get(context);
            var isMigration   = IsMigration.Get(context) ? 1 : 0;
            var timeOut       = TimeOut.Get(context);
            var wfUow         = BeginTransactionActivity.GetUnitOfWork(context);

            // получаем менеджер приемки
            Min min = null;
            using (var mgr = IoC.Instance.Resolve <IBPProcessManager>())
            {
                if (wfUow != null)
                {
                    mgr.SetUnitOfWork(wfUow);
                }

                var minId = mgr.GetDefaultMIN(iwbId);
                if (minId.HasValue)
                {
                    using (var mgrIn = IoC.Instance.Resolve <IBaseManager <Min> >())
                    {
                        if (wfUow != null)
                        {
                            mgr.SetUnitOfWork(wfUow);
                        }

                        min = mgrIn.Get(minId);
                    }
                }
            }

            // определяем параметры приемки
            var isMinCpvExist     = min != null && min.CustomParamVal != null && min.CustomParamVal.Count != 0;
            var isNeedControlOver = isMinCpvExist &&
                                    min.CustomParamVal.Any(
                i => i.CustomParamCode == MinCpv.MINOverEnableCpvName && i.CPVValue == "1");
            var isNeedConfirmOver = isNeedControlOver &&
                                    min.CustomParamVal.Any(
                i =>
                i.CustomParamCode == MinCpv.MINOverEnableNeedConfirmCpvName &&
                i.CPVValue == "1");
            var isMinLimit     = isMinCpvExist && min.CustomParamVal.Any(i => i.VCustomParamParent == MinCpv.MinLimitL2CpvName);
            var itemsToProcess = new List <IWBPosInput>();

            #endregion

            #region  .  BatchCode&OverCount  .

            foreach (var item in _items)
            {
                var itemKey = item.GetKey();
                if (!item.IsSelected || itemKey == null)
                {
                    _failedItems.Enqueue(item);
                    continue;
                }

                item.ManageFlag = null;

                //Ошибки при распознавании batch-кода
                if (!item.NotCriticalBatchcodeError && !item.IsBpBatchcodeCompleted)
                {
                    var message = string.IsNullOrEmpty(item.BatchcodeErrorMessage)
                        ? "Ошибка не определена."
                        : item.BatchcodeErrorMessage;
                    SkipItem(item, message);
                    continue;
                }

                if (item.RequiredSKUCount < 1)
                {
                    SkipItem(item, "Некорректно введено 'Количество по факту'");
                    continue;
                }

                // если пытаемся принять с избытком
                if (isNeedControlOver)
                {
                    var count     = item.ProductCountSKU + (double)item.RequiredSKUCount;
                    var overCount = count - item.IWBPosCount;
                    if (overCount > 0 && isNeedConfirmOver)
                    {
                        var questionMessage = string.Format(
                            "Позиция '{0}' ед.уч. '{1}'.{4}Фактическое кол-во = '{2}'.{4}Излишек составит '{3}'.{4}Принять излишек?",
                            itemKey, item.SKUNAME, count, overCount, Environment.NewLine);

                        var dr = _viewService.ShowDialog(
                            GetDefaultMessageBoxCaption(iwbId),
                            questionMessage,
                            MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.Yes, 14);

                        if (dr == MessageBoxResult.Yes)
                        {
                            item.ManageFlag += (!string.IsNullOrEmpty(item.ManageFlag) ? "," : string.Empty) +
                                               "OVERASK_OK";
                        }
                        else
                        {
                            var message = string.Format("Пользователь отказался принимать излишек по позиции '{0}'",
                                                        itemKey, item.SKUNAME);
                            SkipItem(item, message);
                            continue;
                        }
                    }
                }

                itemsToProcess.Add(item);
            }

            #endregion

            // группируем по артикулу
            var groupItems = itemsToProcess.GroupBy(i => i.ArtCode).ToArray();

            //обработка сроков годности
            if (isMinLimit)
            {
                var ret = ProccesExpireDate(itemsToProcess, min, groupItems, wfUow, iwbId);
                if (!ret)
                {
                    return;
                }
            }

            var ask = new ConcurrentQueue <IWBPosInput>();

            while (true)
            {
                RunCreateProduct(itemsToProcess, ref ask, timeOut, wfUow, operationCode, iwbId, isMigration, placeCode,
                                 isNeedControlOver);
                if (ask == null || ask.Count <= 0)
                {
                    break;
                }

                itemsToProcess.Clear();
                foreach (var item in ask)
                {
                    var message = string.Format("Принять излишек по позиции '{0}' ед.уч. '{1}' ?", item.GetKey(),
                                                item.SKUNAME);
                    var res = _viewService.ShowDialog(GetDefaultMessageBoxCaption(iwbId), message,
                                                      MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.Yes, 14);

                    if (res != MessageBoxResult.Yes)
                    {
                        SkipItem(item,
                                 string.Format("Пользователь отказался принимать излишек по позиции '{0}'", item.GetKey()));
                        continue;
                    }
                    itemsToProcess.Add(item);
                }

                while (!ask.IsEmpty)
                {
                    IWBPosInput someItem;
                    ask.TryDequeue(out someItem);
                }
            }
        }
Ejemplo n.º 2
0
        protected override void Execute(NativeActivityContext context)
        {
            var width         = DialogWidth.Get(context);
            var height        = DialogHeight.Get(context);
            var placeFilter   = PlaceFilter.Get(context);
            var operationCode = OperationCode.Get(context);
            var place         = InvoicePlace.Get(context);
            var obj           = (IWBPosInputWithPlaceListViewModel)IoC.Instance.Resolve(typeof(IWBPosInputWithPlaceListViewModel));
            var mandantId     = MandantID.Get(context);

            obj.PrintTE       = CheckPrintTE(mandantId);
            obj.PlaceFilter   = placeFilter;
            obj.OperationCode = operationCode;
            obj.MandantId     = mandantId;
            var isMigration = IsMigration.Get(context);

            obj.IsMigration = isMigration;

            obj.BatchcodeWorkflowCode   = BatchcodeWorkflowCode.Get(context);
            obj.SkuChangeMpWorkflowCode = SkuChangeMpWorkflowCode.Get(context);

            var model = obj as ICustomListViewModel <IWBPosInput>;

            if (model == null)
            {
                throw new DeveloperException("ViewModel doesn't implement ICustomListViewModel.");
            }
            model.PanelCaption = Title;
            var source = Source.Get(context).Select(p => new IwbPosInputErrorInfo(p)
            {
                IsSelected = false
            });

            model.SetSource(new ObservableCollection <IWBPosInput>(source));
            obj.CurrentPlace = place;
            var viewService = IoC.Instance.Resolve <IViewService>();

            if (viewService.ShowDialogWindow(model, true, false, width, height) == true)
            {
                var result = model.GetSource() as IEnumerable <IWBPosInput>;
                if (result == null)
                {
                    throw new DeveloperException("Source type is not IEnumerable.");
                }

                if (obj.SelectedItems != null && obj.SelectedItems.Any())
                {
                    // пометим выбранные записи
                    foreach (var r in result)
                    {
                        r.IsSelected = obj.SelectedItems.Contains(r);
                    }
                }

                Result.Set(context, result.ToArray());
                InvoicePlace.Set(context, obj.SelectedPlace);
                DialogResult.Set(context, true);
            }
            else
            {
                DialogResult.Set(context, false);
            }
            PrintTE.Set(context, ((IWBPosInputWithPlaceListViewModel)model).PrintTE);
            var disposable = model as IDisposable;

            if (disposable != null)
            {
                disposable.Dispose();
            }
        }
Ejemplo n.º 3
0
        protected override void Execute(NativeActivityContext context)
        {
            var width         = DialogWidth.Get(context);
            var height        = DialogHeight.Get(context);
            var placeFilter   = PlaceFilter.Get(context);
            var operationCode = OperationCode.Get(context);
            var place         = InvoicePlace.Get(context);
            var iwb           = IWB.Get(context);
            var mandantId     = MandantID.Get(context);

            using (var viewModel = (AcceptanceViewModel)IoC.Instance.Resolve(typeof(AcceptanceViewModel)))
            {
                viewModel.PrintTE                 = CheckPrintTE(mandantId);
                viewModel.PlaceFilter             = placeFilter;
                viewModel.OperationCode           = operationCode;
                viewModel.MandantId               = mandantId;
                viewModel.CurrentIWB              = iwb;
                viewModel.IsMigration             = IsMigration.Get(context);
                viewModel.BatchcodeWorkflowCode   = BatchcodeWorkflowCode.Get(context);
                viewModel.SkuChangeMpWorkflowCode = SkuChangeMpWorkflowCode.Get(context);
                viewModel.PanelCaption            = Title;
                viewModel.IsProductsShown         = IsNeedShowProducts.Get(context);
                viewModel.DisplayFieldsFormat     = DisplayFieldsFormat.Get(context);
                if (place != null)
                {
                    viewModel.AcceptancePlace = new EntityReference(place.PlaceCode, Place.EntityType,
                                                                    new[]
                    {
                        new EntityReferenceFieldValue("PlaceCode", place.PlaceCode),
                        new EntityReferenceFieldValue("PlaceName", place.PlaceName)
                    });
                }

                ((IModelHandler)viewModel).SetSource(Source.Get(context));
                var viewService = IoC.Instance.Resolve <IViewService>();
                if (viewService.ShowDialogWindow(viewModel, true, false, width, height, noButtons: true) == true && viewModel.IsAllowAccept == true)
                {
                    if (viewModel.SelectedItems != null && viewModel.SelectedItems.Any())
                    {
                        // пометим выбранные записи
                        foreach (var r in viewModel.Source)
                        {
                            r.IsSelected = viewModel.SelectedItems.Contains(r);
                        }
                    }

                    Result.Set(context, viewModel.Source.Cast <IWBPosInput>().ToArray());

                    var acceptancePlace = GetAcceptancePlace(viewModel);
                    InvoicePlace.Set(context, acceptancePlace);
                    IsNeedShowProducts.Set(context, viewModel.IsProductsShown);
                    DialogResult.Set(context, true);
                }
                else
                {
                    DialogResult.Set(context, false);
                }

                PrintTE.Set(context, viewModel.PrintTE);
            }
        }