Пример #1
0
        /// <summary>
        /// 生成库存异动日志
        /// </summary>
        /// <param name="paramHead">盘库任务</param>
        /// <param name="paramDetail">盘库任务明细</param>
        /// <returns></returns>
        private MDLPIS_InventoryTransLog GenerateInventoryTransLog(MDLPIS_StocktakingTask paramHead, StocktakingTaskManagerDetailUIModel paramDetail)
        {
            MDLPIS_InventoryTransLog newInventoryTransLog = new MDLPIS_InventoryTransLog
            {
                ITL_Org_ID = string.IsNullOrEmpty(paramHead.ST_Org_ID) ? LoginInfoDAX.OrgID : paramHead.ST_Org_ID,
                ITL_WH_ID  = paramDetail.STD_WH_ID,
                ITL_WHB_ID = paramDetail.STD_WHB_ID,
                //业务单号为[盘点单]的单号
                ITL_BusinessNo    = paramHead.ST_No,
                ITL_Barcode       = paramDetail.STD_Barcode,
                ITL_BatchNo       = paramDetail.STD_BatchNo,
                ITL_Name          = paramDetail.STD_Name,
                ITL_Specification = paramDetail.STD_Specification,
                ITL_UnitCostPrice = paramDetail.INV_PurchaseUnitPrice,
                ITL_UnitSalePrice = null,
                ITL_Qty           = (paramDetail.STD_ActualQty ?? 0) - (paramDetail.STD_DueQty ?? 0),
                ITL_TransType     = InventoryTransTypeEnum.Name.PDTZ,
                ITL_Source        = "其他位置",
                ITL_Destination   = paramDetail.WH_Name,
                ITL_IsValid       = true,
                ITL_CreatedBy     = LoginInfoDAX.UserName,
                ITL_UpdatedBy     = LoginInfoDAX.UserName
            };

            newInventoryTransLog.ITL_AfterTransQty = paramDetail.INV_Qty + newInventoryTransLog.ITL_Qty;

            return(newInventoryTransLog);
        }
Пример #2
0
        /// <summary>
        /// 【审核-退货】生成销售退货入库的库存异动日志
        /// </summary>
        /// <param name="paramStockInBill">入库单</param>
        /// <param name="paramReturnStockInDetail">退货入库明细</param>
        /// <param name="paramInventory">库存</param>
        /// <param name="paramSalesReturnOrderManager">销售退货</param>
        /// <returns></returns>
        private MDLPIS_InventoryTransLog GenerateStockInInventoryTransLog(MDLPIS_StockInBill paramStockInBill, ReturnStockInDetailUIModel paramReturnStockInDetail, MDLPIS_Inventory paramInventory, SalesReturnOrderManagerUIModel paramSalesReturnOrderManager)
        {
            MDLPIS_InventoryTransLog newInventoryTransLog = new MDLPIS_InventoryTransLog
            {
                ITL_Org_ID = string.IsNullOrEmpty(paramStockInBill.SIB_Org_ID) ? LoginInfoDAX.OrgID : paramStockInBill.SIB_Org_ID,
                ITL_WH_ID  = paramInventory.INV_WH_ID,
                ITL_WHB_ID = paramReturnStockInDetail.SID_WHB_ID,
                //业务单号为[入库单]的单号
                ITL_BusinessNo    = paramStockInBill.SIB_No,
                ITL_Barcode       = paramInventory.INV_Barcode,
                ITL_BatchNo       = paramInventory.INV_BatchNo,
                ITL_Name          = paramReturnStockInDetail.SID_Name,
                ITL_Specification = paramReturnStockInDetail.SID_Specification,
                ITL_UnitCostPrice = paramInventory.INV_PurchaseUnitPrice,
                ITL_UnitSalePrice = null,
                //入库,数量为正
                ITL_Qty           = paramReturnStockInDetail.SID_Qty,
                ITL_AfterTransQty = paramInventory.INV_Qty,
                ITL_IsValid       = true,
                ITL_CreatedBy     = LoginInfoDAX.UserName,
                ITL_UpdatedBy     = LoginInfoDAX.UserName,
                //异动类型为{销售退货}
                ITL_TransType   = InventoryTransTypeEnum.Name.XSTH,
                ITL_Source      = paramSalesReturnOrderManager.AROrgName,
                ITL_Destination = paramReturnStockInDetail.WH_Name,
            };

            return(newInventoryTransLog);
        }
        /// <summary>
        /// 【审核】生成库存异动日志
        /// </summary>
        /// <param name="paramStockOutBill">出库单</param>
        /// <param name="paramStockOutBillDetail">出库单明细</param>
        /// <param name="paramInventory">库存</param>
        /// <returns></returns>
        private MDLPIS_InventoryTransLog GenerateInventoryTransLogOfApprove(MDLPIS_StockOutBill paramStockOutBill, StockOutBillManagerDetailUIModel paramStockOutBillDetail, MDLPIS_Inventory paramInventory)
        {
            MDLPIS_InventoryTransLog newInventoryTransLog = new MDLPIS_InventoryTransLog
            {
                ITL_Org_ID = string.IsNullOrEmpty(paramStockOutBill.SOB_Org_ID) ? LoginInfoDAX.OrgID : paramStockOutBill.SOB_Org_ID,
                ITL_WH_ID  = paramInventory.INV_WH_ID,
                ITL_WHB_ID = paramStockOutBillDetail.SOBD_WHB_ID,
                //业务单号为[出库单]的单号
                ITL_BusinessNo    = paramStockOutBill.SOB_No,
                ITL_Barcode       = paramInventory.INV_Barcode,
                ITL_BatchNo       = paramInventory.INV_BatchNo,
                ITL_Name          = paramStockOutBillDetail.SOBD_Name,
                ITL_Specification = paramStockOutBillDetail.SOBD_Specification,
                ITL_UnitCostPrice = paramInventory.INV_PurchaseUnitPrice,
                ITL_UnitSalePrice = paramStockOutBillDetail.SOBD_UnitSalePrice,
                //出库,数量为负
                ITL_Qty           = -paramStockOutBillDetail.SOBD_Qty,
                ITL_AfterTransQty = paramInventory.INV_Qty,
                ITL_IsValid       = true,
                ITL_CreatedBy     = LoginInfoDAX.UserName,
                ITL_UpdatedBy     = LoginInfoDAX.UserName
            };

            //异动类型
            switch (paramStockOutBill.SOB_SourceTypeName)
            {
            case StockOutBillSourceTypeEnum.Name.THCK:
                //退货出库
                newInventoryTransLog.ITL_TransType = InventoryTransTypeEnum.Name.THCK;
                break;

            case StockOutBillSourceTypeEnum.Name.XSCK:
                //销售出库
                newInventoryTransLog.ITL_TransType = InventoryTransTypeEnum.Name.XSCK;
                break;
            }

            newInventoryTransLog.ITL_Destination = paramStockOutBillDetail.SUPP_Name;
            newInventoryTransLog.ITL_Source      = paramStockOutBillDetail.WH_Name;

            return(newInventoryTransLog);
        }
Пример #4
0
        /// <summary>
        /// 根据损益表校正库存
        /// </summary>
        /// <param name="paramHead">单头UIModel</param>
        /// <param name="paramDetailList">明细UIModel列表</param>
        /// <param name="paramUpdateInventoryList">待更新的库存列表</param>
        /// <returns></returns>
        public bool CorrectInventoryByProfitAndLoss(StocktakingTaskManagerUIModel paramHead, SkyCarBindingList <StocktakingTaskManagerDetailUIModel, MDLPIS_StocktakingTaskDetail> paramDetailList, List <MDLPIS_Inventory> paramUpdateInventoryList)
        {
            var funcName = "CorrectInventoryByProfitAndLoss";

            LogHelper.WriteBussLogStart(BussID, LoginInfoDAX.UserName, funcName, "", "", null);

            #region 准备数据

            //待新增的[库存异动日志]列表
            List <MDLPIS_InventoryTransLog> newInventoryTransLogList = new List <MDLPIS_InventoryTransLog>();

            #region 更新[盘点任务]

            //将UIModel转为TBModel
            var argsHead = paramHead.ToTBModelForSaveAndDelete <MDLPIS_StocktakingTask>();

            //更新[盘点状态]为[校正完成],记录[结束时间]
            argsHead.ST_StatusName = StocktakingBillStatusEnum.Name.JZWC;
            argsHead.ST_StatusCode = StocktakingBillStatusEnum.Code.JZWC;
            argsHead.ST_EndTime    = BLLCom.GetCurStdDatetime();

            //根据[实际库存量]与[应有库存量]得出[盘点结果]
            if (argsHead.ST_ActualQty > argsHead.ST_DueQty)
            {
                //[实际库存量]>[应有库存量]:盘盈
                argsHead.ST_CheckResultName = StocktakingBillCheckResultEnum.Name.PY;
                argsHead.ST_CheckResultCode = StocktakingBillCheckResultEnum.Code.PY;
            }
            else if (argsHead.ST_ActualQty < argsHead.ST_DueQty)
            {
                //[实际库存量]<[应有库存量]:盘亏
                argsHead.ST_CheckResultName = StocktakingBillCheckResultEnum.Name.PK;
                argsHead.ST_CheckResultCode = StocktakingBillCheckResultEnum.Code.PK;
            }
            else if (argsHead.ST_ActualQty == argsHead.ST_DueQty)
            {
                //[实际库存量]=[应有库存量]:账实相符
                argsHead.ST_CheckResultName = StocktakingBillCheckResultEnum.Name.ZSXF;
                argsHead.ST_CheckResultCode = StocktakingBillCheckResultEnum.Code.ZSXF;
            }
            #endregion

            #region 遍历[盘点明细]列表,生成[库存异动日志]

            foreach (var loopStockTaskDetail in paramDetailList)
            {
                //[应有量]等于[实际量]的配件不进行校正
                if (loopStockTaskDetail.STD_DueQty == loopStockTaskDetail.STD_ActualQty)
                {
                    continue;
                }
                MDLPIS_InventoryTransLog newInventoryTransLog = new MDLPIS_InventoryTransLog();
                newInventoryTransLog = GenerateInventoryTransLog(argsHead, loopStockTaskDetail);
                newInventoryTransLogList.Add(newInventoryTransLog);
            }

            #endregion

            #endregion

            #region 带事务的保存

            try
            {
                DBManager.BeginTransaction(DBCONFIG.Coeus);

                #region 保存库存

                foreach (var loopInventory in paramUpdateInventoryList)
                {
                    loopInventory.INV_UpdatedBy   = LoginInfoDAX.UserName;
                    loopInventory.INV_UpdatedTime = BLLCom.GetCurStdDatetime();
                    bool saveInventoryResult = _bll.Save(loopInventory);
                    if (!saveInventoryResult)
                    {
                        DBManager.RollBackTransaction(DBCONFIG.Coeus);
                        ResultMsg = MsgHelp.GetMsg(MsgCode.E_0010, new object[] { SystemActionEnum.Name.SAVE + SystemTableEnums.Name.PIS_Inventory });
                        LogHelper.WriteBussLogEndNG(BussID, LoginInfoDAX.UserName, funcName, ResultMsg, "", null);
                        return(false);
                    }
                }

                #endregion

                #region 新增[库存异动日志]

                if (newInventoryTransLogList.Count > 0)
                {
                    bool insertInventoryTransLogResult = _bll.InsertByList <MDLPIS_InventoryTransLog, MDLPIS_InventoryTransLog>(newInventoryTransLogList);
                    if (!insertInventoryTransLogResult)
                    {
                        DBManager.RollBackTransaction(DBCONFIG.Coeus);
                        ResultMsg = MsgHelp.GetMsg(MsgCode.E_0010, new object[] { SystemActionEnum.Name.NEW + SystemTableEnums.Name.PIS_InventoryTransLog });
                        LogHelper.WriteBussLogEndNG(BussID, LoginInfoDAX.UserName, funcName, ResultMsg, "", null);
                        return(false);
                    }
                }

                #endregion

                #region 保存[盘点任务]

                bool saveStocktakingTaskResult = _bll.Save(argsHead);
                if (!saveStocktakingTaskResult)
                {
                    DBManager.RollBackTransaction(DBCONFIG.Coeus);
                    ResultMsg = MsgHelp.GetMsg(MsgCode.E_0010, new object[] { SystemActionEnum.Name.SAVE + SystemTableEnums.Name.PIS_StocktakingTask });
                    LogHelper.WriteBussLogEndNG(BussID, LoginInfoDAX.UserName, funcName, ResultMsg, "", null);
                    return(false);
                }

                #endregion

                #region 保存[盘点任务明细]

                //bool saveStocktakingTaskDetailResult = _bll.UnitySave(paramDetailList);
                //if (!saveStocktakingTaskDetailResult)
                //{
                //    DBManager.RollBackTransaction(DBCONFIG.Coeus);
                //    ResultMsg = MsgHelp.GetMsg(MsgCode.E_0010, new object[] { SystemActionEnum.Name.SAVE + SystemTableEnums.Name.PIS_StocktakingTaskDetail });
                //    LogHelper.WriteBussLogEndNG(BussID, LoginInfoDAX.UserName, funcName, ResultMsg, "", null);
                //    return false;
                //}

                #endregion

                DBManager.CommitTransaction(DBCONFIG.Coeus);
            }
            catch (Exception ex)
            {
                DBManager.RollBackTransaction(DBCONFIG.Coeus);
                ResultMsg = MsgHelp.GetMsg(MsgCode.E_0018, new object[] { SystemActionEnum.Name.SAVE, ex.Message });
                LogHelper.WriteBussLogEndNG(BussID, LoginInfoDAX.UserName, funcName, ex.Message, "", null);
                return(false);
            }

            #endregion

            //将最新数据回写给DetailDS
            CopyModel(argsHead, paramHead);

            return(true);
        }