示例#1
0
        private async void CreateOutOrderInfo()
        {
            UserContext.RfidReadProvider.OnDataReceived -= RfidReadProvider_OnDataReceived;
            if (WareOutDetailSource.FirstOrDefault(_ => _.RfidCount > 0) != null)
            {
                MessageBox.Show("请先匹配物料类型并保存");
                return;
            }
            int totalCount = WareOutDetailTypeSource.Sum(_ => _.TotalCount) + WareOutDetailSource.Sum(_ => _.RfidCount);

            if (totalCount == 0)
            {
                MessageBox.Show("请先匹配物料类型");
                return;
            }
            foreach (var wareOutDetailType in WareOutDetailTypeSource)
            {
                foreach (var detail in wareOutDetailType.Details)
                {
                    var exists = WareOutDetailSource.FirstOrDefault(_ => _.WareTypeId == detail.WareTypeId);
                    if (exists != null)
                    {
                        exists.RfidCount += detail.RfidCount;
                    }
                }
            }
            foreach (var ware in WareOutDetailSource)
            {
                if (ware.RfidCount > ware.MaxCount)
                {
                    MessageBox.Show($"{ware.WareTypeName}超出数量");
                    return;
                }
            }
            List <string> rfids = new List <string>();

            foreach (var ware in WareOutDetailTypeSource)
            {
                rfids.AddRange(ware.Rfids);
            }
            var customId = SelectedCustom.Id;
            var result   = await Task.Run(() => UserContext.ApiHelper.CreateOutOrder(customId, rfids));

            if (result.Success)
            {
                ShowCustomList = true;
            }
            else
            {
                MessageBox.Show("出库失败," + result.Msg);
                UserContext.RfidReadProvider.OnDataReceived += RfidReadProvider_OnDataReceived;
            }
        }
示例#2
0
        public void SaveWareType()
        {
            UserContext.RfidReadProvider.OnDataReceived -= RfidReadProvider_OnDataReceived;
            if (WareOutDetailSource.FirstOrDefault(_ => _.RfidCount > 0) == null)
            {
                MessageBox.Show("请先匹配物料类型");
                return;
            }
            var totalCount = WareOutDetailSource.Sum(_ => _.RfidCount);

            if (totalCount != TotalCount || totalCount == 0)
            {
                MessageBox.Show("识别数量与匹配数量不一致,请检查物料绑定情况");
                return;
            }
            WareOutDetailType wareOutDetail = new WareOutDetailType();

            wareOutDetail.Name       = $"第{(WareOutDetailTypeSource.Count + 1).ToString()}车";
            wareOutDetail.TotalCount = totalCount;
            wareOutDetail.Details    = new ObservableCollection <WareOutDetailBaseVM>();
            wareOutDetail.Rfids      = Rfids.ToArray().ToList();
            Rfids.Clear();
            TotalCount = 0;
            foreach (var detail in WareOutDetailSource)
            {
                if (detail.RfidCount == 0)
                {
                    continue;
                }
                WareOutDetailBaseVM vm = new WareOutDetailBaseVM();
                vm.WareTypeName = detail.WareTypeName;
                vm.WareTypeId   = detail.WareTypeId;
                vm.RfidCount    = detail.RfidCount;
                wareOutDetail.Details.Add(vm);
                detail.RfidCount = 0;
            }
            WareOutDetailTypeSource.Add(wareOutDetail);
        }