/// <summary>
        /// 结束操作,包括主动提交和长时间未操作界面被动提交
        /// </summary>
        /// <param name="bExit">退出登陆还是回到首页</param>
        /// <param name="bAutoSubmit">是否是主动提交</param>
        private void EndOperation(bool bExit, bool bAutoSubmit = true)
        {
            if (isSuccess)
            {
                LoadingDataEvent(this, true);
                BasePostData <CommodityInventoryChange> bdBasePostData =
                    ConsumingBll.GetInstance().SubmitConsumingChangeWithOrder(bdCommodityCode, fetchParam.bdConsumingOrder.body.objects[0]);
                LoadingDataEvent(this, false);

                //校验是否含有数据
                HttpHelper.GetInstance().ResultCheck(bdBasePostData, out bool isSuccess1);

                if (!isSuccess1 && bAutoSubmit)
                {
                    MessageBox.Show("提交结果失败!" + bdBasePostData.message, "温馨提示", MessageBoxButton.OK);
                }

                ConsumingBll.GetInstance().InsertLocalCommodityCodeInfo(bdCommodityCode, "SurgeryConsumingOrder");
            }

            ApplicationState.SetGoodsInfo(after);

            //主动提交,需要发送退出事件
            if (bAutoSubmit)
            {
                EnterPopCloseEvent(this, bExit);
            }
        }
예제 #2
0
        public void ShelfBllTestMethod()
        {
            BaseData <CommodityCode> baseDataCommodityCode = GetBaseData();


            BaseData <ShelfTask> baseDataShelfTask = ShelfBll.GetInstance().GetShelfTask("OS20190721000052");

            BaseData <ShelfTaskCommodityDetail> baseDataShelfTaskCommodityDetail = ShelfBll.GetInstance().GetShelfTaskCommodityDetail(baseDataShelfTask);

            ShelfBll.GetInstance().GetShelfTaskChange(baseDataCommodityCode, baseDataShelfTask.body.objects[0], baseDataShelfTaskCommodityDetail);

            BasePutData <ShelfTask> putData = ShelfBll.GetInstance().PutShelfTask(baseDataShelfTask.body.objects[0]);
            BasePostData <CommodityInventoryChange> basePostData = ShelfBll.GetInstance().CreateShelfTaskCommodityInventoryChange(baseDataCommodityCode, baseDataShelfTask.body.objects[0], true);

            JsonSerializerSettings jsetting = new JsonSerializerSettings
            {
                NullValueHandling = NullValueHandling.Ignore
            };

            string ret = JsonConvert.SerializeObject(new ShelfTask
            {
                Status           = "上架",
                AbnormalCauses   = "商品缺失",
                AbnormalDescribe = "异常描述"
            }, Formatting.Indented, jsetting);
        }
예제 #3
0
        /// <summary>
        /// 拣货的库存变化
        /// </summary>
        /// <param name="baseDatacommodityCode"></param>
        /// <param name="pickTask"></param>
        /// <param name="bAutoSubmit">是否是主动提交</param>
        /// <returns></returns>
        public BasePostData <CommodityInventoryChange> CreatePickTaskCommodityInventoryChange(BaseData <CommodityCode> baseDataCommodityCode, PickTask pickTask, bool bAutoSubmit)
        {
            BasePostData <CommodityInventoryChange> retBaseSinglePostDataCommodityInventoryChange = null;

            //校验是否含有数据,如果含有数据,有就继续下一步
            baseDataCommodityCode = HttpHelper.GetInstance().ResultCheck(baseDataCommodityCode, out bool isSuccess);

            if (isSuccess)
            {
                var CommodityCodes = baseDataCommodityCode.body.objects;

                var CommodityInventoryChanges = new List <CommodityInventoryChange>(CommodityCodes.Count);

                CommodityCodes.ForEach(it => {
                    CommodityInventoryChange cic = new CommodityInventoryChange()
                    {
                        CommodityCodeId = it.id,           //商品码【扫描】
                        SourceBill      = new SourceBill() //来源单据
                        {
                            object_name = typeof(PickTask).Name,
                            object_id   = pickTask.id
                        }
                    };

                    if (it.operate_type == (int)OperateType.出库)
                    {
                        cic.ChangeStatus = CommodityInventoryChangeStatus.拣货作业.ToString();
                        cic.StoreHouseId = it.StoreHouseId;
                    }
                    else
                    {
                        cic.ChangeStatus    = CommodityInventoryChangeStatus.正常.ToString();
                        cic.EquipmentId     = it.EquipmentId;
                        cic.StoreHouseId    = it.StoreHouseId;
                        cic.GoodsLocationId = it.GoodsLocationId;
                    }

                    if (!bAutoSubmit && it.AbnormalDisplay == AbnormalDisplay.异常.ToString())
                    {
                        cic.AdjustStatus = CommodityInventoryChangeAdjustStatus.是.ToString();
                    }

                    CommodityInventoryChanges.Add(cic);
                });

                retBaseSinglePostDataCommodityInventoryChange = CommodityInventoryChangeBll.GetInstance().CreateCommodityInventoryChange(CommodityInventoryChanges);
            }
            else
            {
                retBaseSinglePostDataCommodityInventoryChange = new BasePostData <CommodityInventoryChange>
                {
                    code    = baseDataCommodityCode.code,
                    message = baseDataCommodityCode.message
                };
            }

            return(retBaseSinglePostDataCommodityInventoryChange);
        }
예제 #4
0
        public void PickBllTestMethod()
        {
            BaseData <CommodityCode> baseDataCommodityCode = GetBaseData();


            BaseData <PickTask> baseDataPickTask = PickBll.GetInstance().GetPickTask("ST20190721000031");

            BaseData <PickCommodity> baseDataPickTaskCommodityDetail = PickBll.GetInstance().GetPickTaskCommodityDetail(baseDataPickTask);

            PickBll.GetInstance().GetPickTaskChange(baseDataCommodityCode, baseDataPickTask.body.objects[0], baseDataPickTaskCommodityDetail);

            BasePutData <PickTask> putData = PickBll.GetInstance().PutPickTask(baseDataPickTask.body.objects[0]);
            BasePostData <CommodityInventoryChange> basePostData = PickBll.GetInstance().CreatePickTaskCommodityInventoryChange(baseDataCommodityCode, baseDataPickTask.body.objects[0], true);
        }
        /// <summary>
        /// 结束操作,包括主动提交和长时间未操作界面被动提交
        /// </summary>
        /// <param name="bExit">退出登陆还是回到首页</param>
        /// <param name="bAutoSubmit">是否是主动提交</param>
        private void EndOperation(bool bExit, bool bAutoSubmit = true)
        {
            if (isSuccess)
            {
                LoadingDataEvent(this, true);
                BasePostData <CommodityInventoryChange> basePostData = PickBll.GetInstance().CreatePickTaskCommodityInventoryChange(bdCommodityCode, pickTask, bAutoSubmit);
                LoadingDataEvent(this, false);

                HttpHelper.GetInstance().ResultCheck(basePostData, out bool isSuccess1);

                if (!isSuccess1)
                {
                    if (bAutoSubmit)
                    {
                        MessageBox.Show("创建取货任务单库存明细失败!" + basePostData.message, "温馨提示", MessageBoxButton.OK);
                    }
                }
                else
                {
                    if (!bAutoSubmit)
                    {
                        pickTask.BillStatus = DocumentStatus.异常.ToString();
                    }

                    pickTask.BillStatus = abnormalOptions.GetAbnormal();

                    LoadingDataEvent(this, true);
                    BasePutData <PickTask> putData = PickBll.GetInstance().PutPickTask(pickTask);
                    LoadingDataEvent(this, false);

                    HttpHelper.GetInstance().ResultCheck(putData, out bool isSuccess2);

                    if (!isSuccess2 && bAutoSubmit)
                    {
                        MessageBox.Show("更新取货任务单失败!" + putData.message, "温馨提示", MessageBoxButton.OK);
                    }
                }

                ConsumingBll.GetInstance().InsertLocalCommodityCodeInfo(bdCommodityCode, "PickTask");
            }

            ApplicationState.SetGoodsInfo(after);
            if (bAutoSubmit)
            {
                EnterPopCloseEvent(this, bExit);
            }
        }
        /// <summary>
        /// 结束操作,包括主动提交和长时间未操作界面被动提交
        /// </summary>
        /// <param name="bExit">退出登陆还是回到首页</param>
        /// <param name="bAutoSubmit">是否是主动提交</param>
        private void EndOperation(bool bExit, bool bAutoSubmit = true)
        {
            if (isSuccess)
            {
                LoadingDataEvent(this, true);
                BasePostData <CommodityInventoryChange> basePostData = AllotShelfBll.GetInstance().SubmitAllotShelfChangeWithOrder(bdCommodityCode, allotShelf, bdCommodityDetail);
                LoadingDataEvent(this, false);

                HttpHelper.GetInstance().ResultCheck(basePostData, out bool isSuccess1);

                if (!isSuccess1)
                {
                    if (bAutoSubmit)
                    {
                        MessageBox.Show("创建调拨上架任务单库存明细失败!" + basePostData.message, "温馨提示", MessageBoxButton.OK);
                    }
                }
                else
                {
                    allotShelf.AbnormalCauses = abnormalOptions.GetAbnormal().ToString();

                    LoadingDataEvent(this, true);
                    BasePutData <AllotShelf> putData = AllotShelfBll.GetInstance().PutAllotShelf(allotShelf);
                    LoadingDataEvent(this, false);

                    HttpHelper.GetInstance().ResultCheck(putData, out bool isSuccess2);

                    if (!isSuccess2 && bAutoSubmit)
                    {
                        MessageBox.Show("更新挑拨上架任务单失败!" + putData.message, "温馨提示", MessageBoxButton.OK);
                    }
                }
            }

            ConsumingBll.GetInstance().InsertLocalCommodityCodeInfo(bdCommodityCode, "AllotShelf");

            ApplicationState.SetGoodsInfo(after);
            if (bAutoSubmit)
            {
                EnterPopCloseEvent(this, bExit);
            }
        }
        /// <summary>
        /// 盘点确认
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void onSubmit(object sender, RoutedEventArgs e)
        {
            LoadingDataEvent(this, true);
            BasePutData <InventoryOrder> bdInventoryOrder = InventoryTaskBll.GetInstance().UpdateInventoryOrderStatus(inventoryOrder);

            LoadingDataEvent(this, false);

            //校验是否含有数据
            HttpHelper.GetInstance().ResultCheck(bdInventoryOrder, out bool isSuccess);

            if (!isSuccess)
            {
                MessageBox.Show("更新盘点任务单失败!" + bdInventoryOrder.message, "温馨提示", MessageBoxButton.OK);
                return;
            }

            LoadingDataEvent(this, true);
            BasePostData <InventoryDetail> bdInventoryDetail = InventoryTaskBll.GetInstance().CreateInventoryDetail(list, inventoryOrder.id);

            LoadingDataEvent(this, false);


            //校验是否含有数据
            HttpHelper.GetInstance().ResultCheck(bdInventoryDetail, out bool isSuccess1);

            if (isSuccess1)
            {
                MessageBox.Show("提交盘点任务单成功!" + bdInventoryDetail.message, "温馨提示", MessageBoxButton.OK);
                BackInventoryEvent(this, null);
            }
            else
            {
                MessageBox.Show("创建盘点商品明细失败!" + bdInventoryDetail.message, "温馨提示", MessageBoxButton.OK);
            }

            return;
        }
        /// <summary>
        /// 结束操作,包括主动提交和长时间未操作界面被动提交
        /// </summary>
        /// <param name="bExit">退出登陆还是回到首页</param>
        /// <param name="bAutoSubmit">是否是主动提交</param>
        private void EndOperation(bool bExit, bool bAutoSubmit = true)
        {
            if (isSuccess)
            {
                if (commodityRecovery == null)
                {
                    LoadingDataEvent(this, true);
                    BasePostData <CommodityInventoryChange> bdCommodityInventoryChange = CommodityInventoryChangeBll.GetInstance().CreateCommodityInventoryChangeInStockChange(bdCommodityCode);
                    LoadingDataEvent(this, false);

                    if (bdCommodityInventoryChange.code != 0)
                    {
                        MessageBox.Show("创建库存调整商品变更明细失败!" + bdCommodityInventoryChange.message, "温馨提示", MessageBoxButton.OK);
                    }

                    ConsumingBll.GetInstance().InsertLocalCommodityCodeInfo(bdCommodityCode, "IntentoryAdjust");
                }
                else
                {
                    LoadingDataEvent(this, true);
                    BasePostData <CommodityInventoryChange> bdCommodityInventoryChange = CommodityInventoryChangeBll.GetInstance().CreateCommodityInventoryChange(bdCommodityCode, commodityRecovery, bAutoSubmit);
                    LoadingDataEvent(this, false);

                    if (bdCommodityInventoryChange.code != 0)
                    {
                        MessageBox.Show("创建库存调整商品变更明细失败!" + bdCommodityInventoryChange.message, "温馨提示", MessageBoxButton.OK);
                    }

                    ConsumingBll.GetInstance().InsertLocalCommodityCodeInfo(bdCommodityCode, "CommodityRecovery");
                }
            }

            ApplicationState.SetGoodsInfo(after);

            EnterPopCloseEvent(this, bExit);
        }
        /// <summary>
        /// 提交变更信息
        /// </summary>
        /// <param name="baseDataCommodityCode"></param>
        /// <param name="allotShelf"></param>
        /// <param name="baseAllotShelfCommodity"></param>
        /// <returns></returns>

        public BasePostData <CommodityInventoryChange> SubmitAllotShelfChangeWithOrder(BaseData <CommodityCode> baseDataCommodityCode, AllotShelf allotShelf, BaseData <AllotShelfCommodity> baseAllotShelfCommodity)
        {
            BasePostData <CommodityInventoryChange> retBaseSinglePostDataCommodityInventoryChange = null;

            //校验是否含有数据,如果含有数据,有就继续下一步
            baseDataCommodityCode = HttpHelper.GetInstance().ResultCheck(baseDataCommodityCode, out bool isSuccess);

            baseAllotShelfCommodity = HttpHelper.GetInstance().ResultCheck(baseAllotShelfCommodity, out bool isSuccess2);
            if (isSuccess && isSuccess2)
            {
                var CommodityCodes            = baseDataCommodityCode.body.objects;
                var CommodityInventoryChanges = new List <CommodityInventoryChange>(CommodityCodes.Count);

                //调拨上架商品明细
                var allotShelfCommodities = baseAllotShelfCommodity.body.objects;
                //获取待上架商品CommodityId列表(去重后)
                var detailCommodityIds = allotShelfCommodities.Select(it => it.CommodityId).Distinct().ToList();

                CommodityCodes.ForEach(it =>
                {
                    CommodityInventoryChange cic = new CommodityInventoryChange()
                    {
                        CommodityCodeId = it.id,           //商品码【扫描】
                        SourceBill      = new SourceBill() //来源单据
                        {
                            object_name = typeof(AllotShelf).Name,
                            object_id   = allotShelf.id
                        },
                        //EquipmentId = ApplicationState.GetEquipId(),
                        //StoreHouseId = ApplicationState.GetHouseId(),
                        //GoodsLocationId = it.GoodsLocationId
                    };

                    //【待确认】出库
                    if (it.operate_type == (int)OperateType.出库)
                    {
                        cic.ChangeStatus = CommodityInventoryChangeStatus.未上架.ToString();
                        cic.StoreHouseId = ApplicationState.GetHouseId();
                        cic.AdjustStatus = CommodityInventoryChangeAdjustStatus.是.ToString();
                    }
                    //入库
                    else
                    {
                        cic.ChangeStatus    = CommodityInventoryChangeStatus.正常.ToString();
                        cic.EquipmentId     = it.EquipmentId;
                        cic.StoreHouseId    = it.StoreHouseId;
                        cic.GoodsLocationId = it.GoodsLocationId;
                        //【待确认】
                        if (!detailCommodityIds.Contains(it.CommodityId))
                        {
                            cic.AdjustStatus = CommodityInventoryChangeAdjustStatus.是.ToString();
                        }
                    }

                    CommodityInventoryChanges.Add(cic);
                });

                retBaseSinglePostDataCommodityInventoryChange = CommodityInventoryChangeBll.GetInstance().CreateCommodityInventoryChange(CommodityInventoryChanges);
            }
            else
            {
                retBaseSinglePostDataCommodityInventoryChange = new BasePostData <CommodityInventoryChange>
                {
                    code    = baseDataCommodityCode.code,
                    message = baseDataCommodityCode.message
                };

                LogUtils.Error("CreateShelfTaskCommodityInventoryChange 失败! " + baseDataCommodityCode.message);
            }
            return(retBaseSinglePostDataCommodityInventoryChange);
        }
        /// <summary>
        /// 【智能柜】 自动盘点更新盘点单管理和其商品明细 ,post请求为admintoken
        /// </summary>
        /// <param name="orders"></param>
        /// <returns></returns>
        public BasePostData <InventoryDetail> CreateInventoryOrderAndDetail(List <CommodityCode> commodityCodes)
        {
            BasePostData <InventoryDetail> inventoryDetailRet;

            if (null == commodityCodes || commodityCodes.Count <= 0)
            {
                inventoryDetailRet = new BasePostData <InventoryDetail>()
                {
                    code    = (int)ResultCode.Parameter_Exception,
                    message = ResultCode.Parameter_Exception.ToString()
                };

                return(inventoryDetailRet);
            }

            //创建盘点任务单
            var inventoryTasks = HttpHelper.GetInstance().PostByAdminToken(new PostParam <InventoryTask>()
            {
                objects = { new InventoryTask {
                                Status = InventoryTaskStatus.待确认.ToString()
                            } }
            });

            HttpHelper.GetInstance().ResultCheck(inventoryTasks, out bool isSuccess);

            if (isSuccess)
            {
                string now = GetDateTimeNow();
                List <InventoryOrder> inventoryOrderList = new List <InventoryOrder>();

                //分柜创建盘点任务
                commodityCodes.Select(it => it.GoodsLocationId).Distinct().ToList().ForEach(goodsLocationId =>
                {
                    inventoryOrderList.Add(new InventoryOrder
                    {
                        ConfirmDate     = now,
                        InventoryTaskId = inventoryTasks.body[0].id,
                        Status          = InventoryOrderStatus.待盘点.ToString(),               //创建盘点单状态为[待盘点]
                        //TODO: 需要当前设备id,货位id和库房id
                        GoodsLocationId = goodsLocationId,
                        EquipmentId     = ApplicationState.GetEquipId(),
                        StoreHouseId    = ApplicationState.GetHouseId(),
                        Type            = "自动创建"
                    });
                });

                //创建盘点单
                var inventoryOrders = HttpHelper.GetInstance().PostByAdminToken(new PostParam <InventoryOrder>()
                {
                    objects = inventoryOrderList
                });

                inventoryDetailRet = HttpHelper.GetInstance().ResultCheck((HttpHelper hh) =>
                {
                    BaseData <CommodityInventoryDetail> CommodityInventoryDetails = null;

                    if (commodityCodes.Count > 0)
                    {
                        var commodityCodeIds = commodityCodes.Select(it => it.id).Distinct().ToList();

                        CommodityInventoryDetails = hh.Get <CommodityInventoryDetail>(new QueryParam
                        {
                            @in =
                            {
                                field   = "CommodityCodeId",
                                in_list = BllHelper.ParamUrlEncode(commodityCodeIds)
                            }
                        });
                    }
                    if (CommodityInventoryDetails != null)
                    {
                        hh.ResultCheck(CommodityInventoryDetails, out bool isSuccessq);

                        if (isSuccessq)
                        {
                            commodityCodes.ForEach(it =>
                            {
                                it.CommodityInventoryId = CommodityInventoryDetails.body.objects.Where(cit => cit.CommodityCodeId == it.id).First().id;
                            });
                        }
                    }

                    List <InventoryDetail> inventoryDetailList = new List <InventoryDetail>();
                    commodityCodes.ForEach(it =>
                    {
                        inventoryDetailList.Add(new InventoryDetail
                        {
                            CommodityInventoryId = it.CommodityInventoryId,
                            InventoryOrderId     = inventoryOrders.body.Where(iit => iit.GoodsLocationId == it.GoodsLocationId).Select(iit => iit.id).First(),
                            CommodityCodeId      = it.id
                        });
                    });
                    //创建盘名单明细列表
                    return(hh.PostByAdminToken(new PostParam <InventoryDetail>()
                    {
                        objects = inventoryDetailList
                    }));
                }, inventoryOrders);

                //更新盘点单状态
                if (inventoryDetailRet != null)
                {
                    var orderIds = inventoryDetailRet.body.Select(it => it.InventoryOrderId).Distinct().ToList();

                    orderIds.ForEach(id =>
                    {
                        var temp = inventoryOrders.body.Where(it => it.id.Equals(id)).First();
                        //temp.Status = InventoryOrderStatus.已完成.ToString();

                        //执行更新操作,异常状态记录日志,详情见方法体内部
                        UpdateInventoryOrderStatus(temp);
                    });
                }
            }
            else
            {
                inventoryDetailRet = new BasePostData <InventoryDetail>()
                {
                    code    = (int)ResultCode.Result_Exception,
                    message = ResultCode.Result_Exception.ToString()
                };
            }

            return(inventoryDetailRet);
        }