Пример #1
0
        //报关审核生效	   流水操作:写入 流水类型:报关 流水状态:已生效    库存操作:更新 库存状态:预报关库存
        public ResultModel Audit(UserModel user, NFMT.WorkFlow.Model.DataSource dataSource, bool isPass)
        {
            ResultModel result = new ResultModel();

            try
            {
                using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
                {
                    result = this.customsclearanceDAL.Get(user, dataSource.RowId);
                    if (result.ResultStatus != 0)
                        return result;

                    Model.CustomsClearance customsClearance = result.ReturnValue as Model.CustomsClearance;
                    if (customsClearance == null || customsClearance.CustomsId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "报关不存在";
                        return result;
                    }

                    //审核,修改数据状态
                    result = this.customsclearanceDAL.Audit(user, customsClearance, isPass);
                    if (result.ResultStatus != 0)
                        return result;

                    //审核通过
                    if (isPass)
                    {
                        //加载已生效明细
                        DAL.CustomsDetailDAL customsDetailDAL = new CustomsDetailDAL();
                        result = customsDetailDAL.Load(user, customsClearance.CustomsId, StatusEnum.已生效);
                        if (result.ResultStatus != 0)
                            return result;

                        List<Model.CustomsDetail> details = result.ReturnValue as List<Model.CustomsDetail>;
                        if (details == null || !details.Any())
                        {
                            result.ResultStatus = -1;
                            result.Message = "获取失败";
                            return result;
                        }

                        DAL.StockDAL stockDAL = new StockDAL();
                        DAL.StockNameDAL stockNameDAL = new StockNameDAL();
                        DAL.StockLogDAL stockLogDAL = new StockLogDAL();
                        Model.Stock stock = null;
                        Model.StockName stockName = null;
                        Model.StockLog stockLog = null;

                        foreach (Model.CustomsDetail detail in details)
                        {
                            //获取库存
                            result = stockDAL.Get(user, detail.StockId);
                            if (result.ResultStatus != 0)
                                return result;

                            stock = result.ReturnValue as Model.Stock;
                            if (stock == null)
                            {
                                result.ResultStatus = -1;
                                result.Message = "获取库存失败";
                                return result;
                            }

                            //获取业务单号
                            result = stockNameDAL.Get(user, stock.StockNameId);
                            if (result.ResultStatus != 0)
                                return result;

                            stockName = result.ReturnValue as Model.StockName;
                            if (stockName == null)
                            {
                                result.ResultStatus = -1;
                                result.Message = "获取业务单号失败";
                                return result;
                            }

                            //创建库存流水
                            stockLog = new StockLog()
                            {
                                StockId = stock.StockId,
                                StockNameId = stock.StockNameId,
                                RefNo = stockName.RefNo,
                                LogDirection = (int)LogDirectionEnum.Out,
                                LogType = (int)LogTypeEnum.报关,
                                //ContractId =
                                //SubContractId =
                                LogDate = DateTime.Now,
                                OpPerson = user.EmpId,
                                Bundles = stock.Bundles,
                                GrossAmount = stock.GrossAmount,
                                NetAmount = stock.NetAmount,
                                MUId = stock.UintId,
                                BrandId = stock.BrandId,
                                DeliverPlaceId = stock.DeliverPlaceId,
                                PaperNo = stock.PaperNo,
                                PaperHolder = stock.PaperHolder,
                                CardNo = stock.CardNo,
                                Memo = stock.Memo,
                                LogStatus = StatusEnum.已生效,
                                LogSourceBase = "NFMT",
                                LogSource = "dbo.St_CustomsClearance",
                                SourceId = customsClearance.CustomsId
                            };

                            result = stockLogDAL.Insert(user, stockLog);
                            if (result.ResultStatus != 0)
                                return result;

                            int stockLogId = 0;
                            if (result.ReturnValue == null || !int.TryParse(result.ReturnValue.ToString(), out stockLogId) || stockLogId <= 0)
                            {
                                result.ResultStatus = -1;
                                result.Message = "流水添加失败";
                                return result;
                            }

                            //将库存流水Id反向更新到明细表中
                            detail.StockLogId = stockLogId;
                            result = customsDetailDAL.Update(user, detail);
                            if (result.ResultStatus != 0)
                                return result;

                            //更新库存状态
                            result = stockDAL.UpdateStockStatus(stock, StockStatusEnum.预报关库存);
                            if (result.ResultStatus != 0)
                                return result;
                        }
                    }

                    scope.Complete();
                }
            }
            catch (Exception e)
            {
                result.Message = e.Message;
                result.ResultStatus = -1;
            }

            return result;
        }
Пример #2
0
        public ResultModel UpdateStockInfo(UserModel user, int stockId, string cardNo, string refNo, int stockType, int stockOperateType, string stockNo)
        {
            ResultModel result = new ResultModel();

            try
            {
                using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
                {
                    result = stockDAL.Get(user, stockId);
                    if (result.ResultStatus != 0)
                        return result;

                    Model.Stock stock = result.ReturnValue as Model.Stock;
                    if (stock == null || stock.StockId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "获取库存失败";
                        return result;
                    }

                    DAL.StockNameDAL stockNameDAL = new StockNameDAL();
                    result = stockNameDAL.Get(user, stock.StockNameId);
                    if (result.ResultStatus != 0)
                        return result;

                    Model.StockName stockName = result.ReturnValue as Model.StockName;
                    if (stockName == null || stockName.StockNameId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "获取业务单号失败";
                        return result;
                    }

                    stockName.RefNo = refNo;

                    result = stockNameDAL.Update(user, stockName);
                    if (result.ResultStatus != 0)
                        return result;

                    stock.StockNo = stockNo;
                    stock.CardNo = cardNo;
                    stock.StockType = stockType;
                    stock.Memo = stockOperateType.ToString();
                    stock.StockStatus = StockStatusEnum.流程中库存;

                    result = stockDAL.Update(user, stock);
                    if (result.ResultStatus != 0)
                        return result;

                    if (result.ResultStatus == 0)
                        result.ReturnValue = stock;

                    scope.Complete();
                }
            }
            catch (Exception e)
            {
                result.ResultStatus = -1;
                result.Message = e.Message;
            }

            return result;
        }
Пример #3
0
        public ResultModel Audit(UserModel user, NFMT.WorkFlow.Model.DataSource dataSource, bool isPass)
        {
            ResultModel result = new ResultModel();

            try
            {
                DAL.StockDAL stockDAL = new StockDAL();
                NFMT.WareHouse.DAL.StockNameDAL stockNameDAL = new StockNameDAL();
                DAL.ContractStockInDAL contractStockInDAL = new ContractStockInDAL();

                using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
                {
                    result = this.stockinDAL.Get(user, dataSource.RowId);
                    if (result.ResultStatus != 0)
                        return result;

                    Model.StockIn stockIn = result.ReturnValue as Model.StockIn;
                    if (stockIn == null || stockIn.StockInId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "入库登记不存在";
                        return result;
                    }

                    //审核,修改数据状态
                    result = this.stockinDAL.Audit(user, stockIn, isPass);
                    if (result.ResultStatus != 0)
                        return result;

                    //审核通过
                    if (isPass)
                    {
                        //写入St_StockName表
                        result = stockNameDAL.Insert(user, new Model.StockName() { RefNo = stockIn.RefNo });
                        if (result.ResultStatus != 0)
                            return result;

                        int stockNameId = 0;
                        if (result.ReturnValue == null || !int.TryParse(result.ReturnValue.ToString(), out stockNameId) || stockNameId <= 0)
                        {
                            result.ResultStatus = -1;
                            result.Message = "写库存失败";
                            return result;
                        }

                        //写入St_Stock库存表
                        result = stockDAL.Insert(user, new Model.Stock()
                        {
                            StockNameId = stockNameId,
                            StockDate = stockIn.StockInDate,
                            AssetId = stockIn.AssetId,
                            Bundles = stockIn.Bundles,
                            GrossAmount = stockIn.GrossAmount,
                            NetAmount = stockIn.NetAmount,
                            ReceiptInGap = 0,
                            ReceiptOutGap = 0,
                            CurGrossAmount = stockIn.GrossAmount,
                            CurNetAmount = stockIn.NetAmount,
                            UintId = stockIn.UintId,
                            DeliverPlaceId = stockIn.DeliverPlaceId,
                            BrandId = stockIn.BrandId,
                            CustomsType = stockIn.CustomType,
                            GroupId = stockIn.GroupId,
                            CorpId = stockIn.CorpId,
                            DeptId = stockIn.DeptId,
                            ProducerId = stockIn.ProducerId,
                            PaperNo = stockIn.PaperNo,
                            PaperHolder = stockIn.PaperHolder,
                            PreStatus = StockStatusEnum.预入库存,
                            StockStatus = StockStatusEnum.预入库存,
                            CardNo = stockIn.CardNo,
                            Memo = string.Empty,
                            StockType = stockIn.StockType,
                            OriginPlaceId = stockIn.OriginPlaceId,
                            OriginPlace = stockIn.OriginPlace,
                            Format = stockIn.Format
                        });
                        if (result.ResultStatus != 0)
                            return result;

                        int stockId = 0;
                        if (result.ReturnValue == null || !int.TryParse(result.ReturnValue.ToString(), out stockId) || stockId <= 0)
                        {
                            result.ResultStatus = -1;
                            result.Message = "写库存失败";
                            return result;
                        }

                        int contractId = 0, subId = 0;

                        //获取合约关联
                        result = contractStockInDAL.GetByStockInId(user, stockIn.StockInId);
                        if (result.ResultStatus == 0)
                        {
                            Model.ContractStockIn contractStockIn = result.ReturnValue as Model.ContractStockIn;
                            if (contractStockIn != null && contractStockIn.RefId > 0)
                            {
                                contractId = contractStockIn.ContractId;
                                subId = contractStockIn.ContractSubId;
                            }
                        }

                        //创建stockLog对象
                        NFMT.WareHouse.Model.StockLog stockLog = new StockLog()
                        {
                            StockId = stockId,
                            StockNameId = stockNameId,
                            RefNo = stockIn.RefNo,
                            LogDirection = (int)LogDirectionEnum.In,
                            LogType = (int)LogTypeEnum.入库,
                            ContractId = contractId,
                            SubContractId = subId,
                            LogDate = DateTime.Now,
                            OpPerson = user.EmpId,
                            Bundles = stockIn.Bundles,
                            GrossAmount = stockIn.GrossAmount,
                            NetAmount = stockIn.NetAmount,
                            MUId = stockIn.UintId,
                            BrandId = stockIn.BrandId,
                            DeliverPlaceId = stockIn.DeliverPlaceId,
                            PaperNo = stockIn.PaperNo,
                            PaperHolder = stockIn.PaperHolder,
                            CardNo = stockIn.CardNo,
                            Memo = string.Empty,
                            LogStatus = StatusEnum.已生效,
                            LogSourceBase = "NFMT",
                            LogSource = "dbo.St_StockIn",
                            SourceId = stockIn.StockInId,

                            AssetId = stockIn.AssetId,
                            CorpId = stockIn.CorpId,
                            CustomsType = stockIn.CustomType,
                            DeptId = stockIn.DeptId,
                            ProducerId = stockIn.ProducerId,
                            StockType = stockIn.StockType,
                            OriginPlaceId = stockIn.OriginPlaceId,
                            OriginPlace = stockIn.OriginPlace,
                            Format = stockIn.Format
                        };

                        DAL.StockLogDAL stockLogDAL = new StockLogDAL();
                        result = stockLogDAL.Insert(user, stockLog);
                        if (result.ResultStatus != 0)
                            return result;

                        int stockLogId = 0;
                        if (result.ReturnValue == null || !int.TryParse(result.ReturnValue.ToString(), out stockLogId) || stockLogId == 0)
                        {
                            result.ResultStatus = -1;
                            result.Message = "流水添加失败";
                            return result;
                        }

                        //写入库登记库存关联表
                        DAL.StockInStockDAL stockInStockDAL = new StockInStockDAL();
                        result = stockInStockDAL.Insert(user, new Model.StockInStock()
                        {
                            StockInId = stockIn.StockInId,
                            StockId = stockId,
                            StockLogId = stockLogId,
                            RefStatus = StatusEnum.已生效
                        });

                        if (result.ResultStatus != 0)
                            return result;
                    }

                    scope.Complete();
                }
            }
            catch (Exception ex)
            {
                result.ResultStatus = -1;
                result.Message = ex.Message;
                return result;
            }

            return result;
        }
Пример #4
0
        public ResultModel Audit(UserModel user, NFMT.WorkFlow.Model.DataSource dataSource, bool isPass)
        {
            ResultModel result = new ResultModel();

            try
            {
                DAL.StockDAL stockDAL = new StockDAL();
                DAL.StockLogDAL stockLogDAL = new StockLogDAL();
                DAL.StockOutDetailDAL detailDAL = new StockOutDetailDAL();
                DAL.StockNameDAL stockNameDAL = new StockNameDAL();
                DAL.StockOutApplyDAL stockOutApplyDAL = new StockOutApplyDAL();

                using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
                {
                    result = this.stockoutDAL.Get(NFMT.Common.DefaultValue.SysUser, dataSource.RowId);
                    if (result.ResultStatus != 0)
                        return result;

                    Model.StockOut stockOut = result.ReturnValue as Model.StockOut;
                    if (stockOut == null || stockOut.StockOutId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "出库不存在";
                        return result;
                    }

                    //审核,修改数据状态
                    result = this.stockoutDAL.Audit(user, stockOut, isPass);
                    if (result.ResultStatus != 0)
                        return result;

                    //审核通过
                    if (isPass)
                    {
                        //流水操作:写入 流水类型:出库 流水状态:已生效    库存操作:更新 库存状态:预售库存

                        //获取出库申请
                        result = stockOutApplyDAL.Get(user,stockOut.StockOutApplyId);
                        if(result.ResultStatus!=0)
                            return result;

                        Model.StockOutApply stockOutApply = result.ReturnValue as Model.StockOutApply;
                        if(stockOutApply == null || stockOutApply.StockOutApplyId<=0)
                        {
                            result.ResultStatus = -1;
                            result.Message = "出库申请获取失败";
                            return result;
                        }

                        //获取出库明细
                        result = detailDAL.Load(user, stockOut.StockOutId);
                        if (result.ResultStatus != 0)
                            return result;

                        List<Model.StockOutDetail> outDetails = result.ReturnValue as List<Model.StockOutDetail>;
                        if (outDetails == null)
                        {
                            result.ResultStatus = -1;
                            result.Message = "出库明细获取失败";
                            return result;
                        }

                        foreach (Model.StockOutDetail outDetail in outDetails)
                        {
                            //获取库存
                            result = stockDAL.Get(user, outDetail.StockId);
                            if (result.ResultStatus != 0)
                                return result;

                            Model.Stock stock = result.ReturnValue as Model.Stock;
                            if (stock == null || stock.StockId <= 0)
                            {
                                result.ResultStatus = -1;
                                result.Message = "出库库存不存在";
                                return result;
                            }

                            //获取业务单
                            result = stockNameDAL.Get(user,stock.StockNameId);
                            if(result.ResultStatus!=0)
                                return result;

                            Model.StockName stockName = result.ReturnValue as Model.StockName;
                            if(stockName == null || stockName.StockNameId <=0)
                            {
                                result.ResultStatus = -1;
                                result.Message = "业务单号获取失败";
                                return result;
                            }

                            //出库净重==当前净重时 库存状态更新至 预售库存
                            if (outDetail.NetAmount == stock.CurNetAmount)
                            {
                                result = stockDAL.UpdateStockStatus(stock, StockStatusEnum.预售库存);
                                if (result.ResultStatus != 0)
                                    return result;
                            }

                            //写出库流水,流水状态为已生效
                            Model.StockLog stockLog = new StockLog()
                            {
                                AssetId = stock.AssetId,
                                BrandId = stock.BrandId,
                                CardNo = stock.CardNo,
                                DeliverPlaceId = stock.DeliverPlaceId,
                                GrossAmount = outDetail.GrossAmount,
                                LogDate = DateTime.Now,
                                LogDirection = (int)LogDirectionEnum.Out,
                                LogSource = "dbo.St_StockOutDetail",
                                LogSourceBase = "NFMT",
                                LogStatus = StatusEnum.已生效,
                                LogType = (int)LogTypeEnum.出库,
                                NetAmount = outDetail.NetAmount,
                                MUId = stock.UintId,
                                OpPerson = user.EmpId,
                                PaperHolder = stock.PaperHolder,
                                PaperNo = stock.PaperNo,
                                RefNo = stockName.RefNo,
                                SourceId = outDetail.DetailId,
                                StockId = stock.StockId,
                                StockNameId = stock.StockNameId,
                                SubContractId = stockOutApply.SubContractId,
                                ContractId = stockOutApply.ContractId,
                                Memo = stockOut.Memo,
                                Bundles = outDetail.Bundles
                            };

                            result = stockLogDAL.Insert(user, stockLog);
                            if (result.ResultStatus != 0)
                                return result;

                            int stockLogId = 0;
                            if (result.ReturnValue == null || !int.TryParse(result.ReturnValue.ToString(), out stockLogId) || stockLogId <= 0)
                            {
                                result.ResultStatus = -1;
                                result.Message = "出库流水写入失败";
                                return result;
                            }

                            //更新出库明细的出库流水
                            outDetail.StockLogId = stockLogId;
                            result = detailDAL.Update(user, outDetail);
                            if (result.ResultStatus != 0)
                                return result;
                        }
                    }

                    scope.Complete();
                }
            }
            catch (Exception ex)
            {
                result.ResultStatus = -1;
                result.Message = ex.Message;
                return result;
            }

            return result;
        }
Пример #5
0
        public ResultModel CompleteCancel(UserModel user, int stockOutId)
        {
            ResultModel result = new ResultModel();

            try
            {
                DAL.StockLogDAL stockLogDAL = new StockLogDAL();
                DAL.StockDAL stockDAL = new StockDAL();
                DAL.StockNameDAL stockNameDAL = new StockNameDAL();
                DAL.StockOutDAL stockOutDAL = new StockOutDAL();
                DAL.StockOutDetailDAL stockOutDetailDAL = new StockOutDetailDAL();
                DAL.StockOutApplyDAL outApplyDAL = new StockOutApplyDAL();
                Operate.DAL.ApplyDAL applyDAL = new Operate.DAL.ApplyDAL();

                using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
                {
                    //验证出库
                    result = stockoutDAL.Get(user, stockOutId);
                    if (result.ResultStatus != 0)
                        return result;
                    StockOut stockOut = result.ReturnValue as StockOut;
                    if (stockOut == null || stockOut.StockOutId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "该数据不存在,不能进行执行完成操作";
                        return result;
                    }

                    //撤销出库
                    result = this.stockoutDAL.CompleteCancel(user, stockOut);
                    if (result.ResultStatus != 0)
                        return result;

                    //验证出库申请
                    result = outApplyDAL.Get(user, stockOut.StockOutApplyId);
                    if (result.ResultStatus != 0)
                        return result;

                    Model.StockOutApply outApply = result.ReturnValue as Model.StockOutApply;
                    if (outApply == null || outApply.StockOutApplyId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "出库申请不存在";
                        return result;
                    }

                    //验证主申请
                    result = applyDAL.Get(user, outApply.ApplyId);
                    if (result.ResultStatus != 0)
                        return result;

                    Operate.Model.Apply apply = result.ReturnValue as Operate.Model.Apply;
                    if (apply == null || apply.ApplyId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "主申请不存在";
                        return result;
                    }

                    //判断主申请状态是否为已生效,
                    if (apply.ApplyStatus != StatusEnum.已生效)
                    {
                        result.ResultStatus = -1;
                        result.Message = "申请状态只有在已生效下才能进行执行完成撤销";
                        return result;
                    }

                    //获取已完成出库明细
                    result = stockOutDetailDAL.Load(user, stockOut.StockOutId, Common.StatusEnum.已完成);
                    if (result.ResultStatus != 0)
                        return result;
                    List<Model.StockOutDetail> details = result.ReturnValue as List<Model.StockOutDetail>;
                    if (details == null)
                    {
                        result.ResultStatus = -1;
                        result.Message = "获取出库明细错误";
                        return result;
                    }

                    //将所有已完成出库明细更新至已生效
                    foreach (Model.StockOutDetail detail in details)
                    {
                        result = stockOutDetailDAL.CompleteCancel(user, detail);
                        if (result.ResultStatus != 0)
                            return result;

                        //获取出库流水
                        result = stockLogDAL.Get(user, detail.StockLogId);
                        if (result.ResultStatus != 0)
                            return result;

                        Model.StockLog stockLog = result.ReturnValue as Model.StockLog;
                        if (stockLog == null || stockLog.StockLogId <= 0)
                        {
                            result.ResultStatus = -1;
                            result.Message = "获取出库流水失败";
                            return result;
                        }

                        //更新出库流水状态为已生效
                        result = stockLogDAL.CompleteCancel(user, stockLog);
                        if (result.ResultStatus != 0)
                            return result;

                        //获取库存
                        result = stockDAL.Get(user,stockLog.StockId);
                        if(result.ResultStatus!=0)
                            return result;

                        Model.Stock stock = result.ReturnValue as Model.Stock;
                        if (stock == null || stock.StockId <= 0)
                        {
                            result.ResultStatus = -1;
                            result.Message = "获取库存错误";
                            return result;
                        }

                        //库存重量添加
                        stock.CurGrossAmount += detail.GrossAmount;
                        stock.CurNetAmount += detail.NetAmount;
                        stock.Bundles += detail.Bundles;

                        //明细关联库存状态更新至前一状态
                        if (stock.StockStatus == StockStatusEnum.已售库存)
                            stock.StockStatus = StockStatusEnum.预售库存;

                        result = stockDAL.Update(user, stock);
                        if (result.ResultStatus != 0)
                            return result;

                    }

                    scope.Complete();
                }
            }
            catch (Exception ex)
            {
                result.ResultStatus = -1;
                result.Message = ex.Message;
            }

            return result;
        }
Пример #6
0
        public ResultModel Complete(UserModel user, int stockOutId)
        {
            ResultModel result = new ResultModel();

            try
            {
                StockDAL stockDAL = new StockDAL();
                StockLogDAL stockLogDAL = new StockLogDAL();
                StockNameDAL stockNameDAL = new StockNameDAL();
                StockOutDetailDAL stockOutDetailDAL = new StockOutDetailDAL();
                StockOutApplyDAL applyDAL = new StockOutApplyDAL();

                using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
                {
                    //验证出库
                    result = stockoutDAL.Get(user, stockOutId);
                    if (result.ResultStatus != 0)
                        return result;
                    StockOut resultObj = result.ReturnValue as StockOut;
                    if (resultObj == null || resultObj.StockOutId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "该数据不存在,不能进行执行完成操作";
                        return result;
                    }

                    //执行完成
                    result = stockoutDAL.Complete(user, resultObj);
                    if (result.ResultStatus != 0)
                        return result;

                    //加载明细
                    result = stockOutDetailDAL.Load(user, resultObj.StockOutId);
                    if (result.ResultStatus != 0)
                        return result;

                    List<Model.StockOutDetail> details = result.ReturnValue as List<Model.StockOutDetail>;
                    if (details == null)
                    {
                        result.ResultStatus = -1;
                        result.Message = "获取出库明细失败";
                        return result;
                    }

                    //加载对应出库申请
                    result = applyDAL.Get(user, resultObj.StockOutApplyId);
                    if (result.ResultStatus != 0)
                        return result;

                    StockOutApply apply = result.ReturnValue as StockOutApply;
                    if (apply == null || apply.StockOutApplyId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "对应出库申请加载失败";
                        return result;
                    }

                    //明细执行完成
                    foreach(Model.StockOutDetail detail in details)
                    {
                        //出库明细完成
                        result = stockOutDetailDAL.Complete(user,detail);
                        if (result.ResultStatus != 0)
                            return result;

                        //获取出库流水
                        result = stockLogDAL.Get(user, detail.StockLogId);
                        if (result.ResultStatus != 0)
                            return result;

                        Model.StockLog stockLog = result.ReturnValue as Model.StockLog;
                        if (stockLog == null || stockLog.StockLogId <= 0)
                        {
                            result.ResultStatus = -1;
                            result.Message = "出库流水获取失败";
                            return result;
                        }

                        //完成出库流水
                        result = stockLogDAL.Complete(user, stockLog);
                        if (result.ResultStatus != 0)
                            return result;

                        //获取库存
                        result = stockDAL.Get(user, stockLog.StockId);
                        if (result.ResultStatus != 0)
                            return result;

                        Model.Stock stock = result.ReturnValue as Model.Stock;
                        if (stock == null || stock.StockId <= 0)
                        {
                            result.ResultStatus = -1;
                            result.Message = "库存获取失败";
                            return result;
                        }

                        //库存重量捆数减少
                        stock.CurGrossAmount -= detail.GrossAmount;
                        stock.CurNetAmount -= detail.NetAmount;
                        stock.Bundles -= detail.Bundles;

                        //库存状态修改
                        if (stock.StockStatus == StockStatusEnum.预售库存)
                            stock.StockStatus = StockStatusEnum.已售库存;

                        result = stockDAL.Update(user, stock);
                        if (result.ResultStatus != 0)
                            return result;

                    }

                    scope.Complete();
                }
            }
            catch (Exception ex)
            {
                result.ResultStatus = -1;
                result.Message = ex.Message;
            }

            return result;
        }
Пример #7
0
        /// <summary>
        /// 数据撤返
        /// </summary>
        /// <param name="user">当前操作用户</param>
        /// <param name="pledge">Pledge对象</param>
        /// <returns></returns>
        public ResultModel GoBack(UserModel user, int pledgeId)
        {
            ResultModel result = new ResultModel();

            try
            {
                using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
                {
                    result = this.Get(user, pledgeId);
                    if (result.ResultStatus != 0)
                        return result;
                    Model.Pledge pledge = result.ReturnValue as Pledge;

                    if (pledge == null)
                    {
                        result.ResultStatus = -1;
                        result.Message = "该数据不存在,不能撤返";
                        return result;
                    }

                    if (pledge.Status != StatusEnum.待审核 && pledge.Status != StatusEnum.已生效)
                    {
                        result.ResultStatus = -1;
                        result.Message = "非待审核或已生效状态的数据不允许撤返";
                        return result;
                    }

                    //获取质押申请实体
                    DAL.PledgeApplyDAL pledgeApplyDAL = new PledgeApplyDAL();
                    result = pledgeApplyDAL.Get(user, pledge.PledgeApplyId);
                    if (result.ResultStatus != 0)
                        return result;

                    Model.PledgeApply pledgeApply = result.ReturnValue as Model.PledgeApply;

                    //获取申请实体
                    NFMT.Operate.DAL.ApplyDAL applyDAl = new Operate.DAL.ApplyDAL();
                    result = applyDAl.Get(user, pledgeApply.ApplyId);
                    if (result.ResultStatus != 0)
                        return result;

                    NFMT.Operate.Model.Apply apply = result.ReturnValue as NFMT.Operate.Model.Apply;
                    if (apply.Status == Common.StatusEnum.已关闭 || apply.Status == Common.StatusEnum.已完成)
                    {
                        result.ResultStatus = -1;
                        result.Message = "质押对应的申请已完成或已关闭,不能进行撤返操作";
                        return result;
                    }

                    result = pledgeDAL.Goback(user, pledge);
                    if (result.ResultStatus != 0)
                        return result;

                    if (pledge.Status == StatusEnum.待审核)
                    {
                        //同步工作流状态
                        NFMT.WorkFlow.BLL.DataSourceBLL dataSourceBLL = new WorkFlow.BLL.DataSourceBLL();
                        result = dataSourceBLL.SynchronousStatus(user, pledge);
                        if (result.ResultStatus != 0)
                            return result;
                    }

                    NFMT.WareHouse.DAL.PledgeDetialDAL pledgeDetialDAL = new DAL.PledgeDetialDAL();
                    result = pledgeDetialDAL.GetStockId(user, pledgeId);
                    if (result.ResultStatus != 0)
                        return result;

                    if (!string.IsNullOrEmpty(result.ReturnValue.ToString()))
                    {
                        NFMT.WareHouse.DAL.StockDAL stockDAL = new StockDAL();
                        NFMT.WareHouse.DAL.StockNameDAL stockNameDAL = new StockNameDAL();
                        NFMT.WareHouse.DAL.StockLogDAL stockLogDAL = new StockLogDAL();

                        NFMT.WareHouse.Model.StockName stockName = new StockName();
                        NFMT.WareHouse.Model.Stock stock = new Stock();
                        NFMT.WareHouse.Model.StockLog stockLog = new StockLog();

                        foreach (string s in result.ReturnValue.ToString().Split(','))
                        {
                            result = stockDAL.Get(user, Convert.ToInt32(s));
                            if (result.ResultStatus != 0)
                                return result;
                            stock = result.ReturnValue as Model.Stock;

                            result = stockNameDAL.Get(user, stock.StockNameId);
                            if (result.ResultStatus != 0)
                                return result;
                            stockName = result.ReturnValue as Model.StockName;

                            ////创建stockLog对象
                            //stockLog = new StockLog()
                            //{
                            //    StockId = stock.StockId,
                            //    StockNameId = stock.StockNameId,
                            //    RefNo = stockName.RefNo,
                            //    //LogDirection =
                            //    LogType = LogEnum.质押冲销,
                            //    //ContractId = ,
                            //    //SubContractId = ,
                            //    LogDate = DateTime.Now,
                            //    OpPerson = user.EmpId,
                            //    Bundles = stock.Bundles,
                            //    GrossAmount = stock.GrossAmount,
                            //    NetAmount = stock.NetAmount,
                            //    MUId = stock.UintId,
                            //    BrandId = stock.BrandId,
                            //    DeliverPlaceId = stock.DeliverPlaceId,
                            //    PaperNo = stock.PaperNo,
                            //    PaperHolder = stock.PaperHolder,
                            //    CardNo = stock.CardNo,
                            //    Memo = stock.Memo,
                            //    LogStatus = StatusEnum.已生效,
                            //    LogSourceBase = "NFMT",
                            //    LogSource = "dbo.St_Pledge",
                            //    SourceId = pledgeId
                            //};

                            //result = stockLogDAL.Insert(user, stockLog);
                            //if (result.ResultStatus != 0)
                            //    return result;

                            result = stockDAL.UpdateStockStatusToPrevious(user, stock);
                            if (result.ResultStatus != 0)
                                return result;
                        }

                        scope.Complete();
                    }
                }
            }
            catch (Exception ex)
            {
                result.Message = ex.Message;
            }
            finally
            {
                if (result.ResultStatus != 0)
                    log.ErrorFormat("{0} {1},类型序号:{2}", user.EmpName, result.Message, result.ReturnValue);
                else if (log.IsInfoEnabled)
                    log.InfoFormat("{0} {1},类型序号:{2}", user.EmpName, result.Message, result.ReturnValue);
            }

            return result;
        }
Пример #8
0
        public ResultModel Complete(UserModel user, int pledgeId)
        {
            ResultModel result = new ResultModel();

            try
            {
                using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
                {
                    //验证质押
                    result = pledgeDAL.Get(user, pledgeId);
                    if (result.ResultStatus != 0)
                        return result;

                    Pledge pledge = result.ReturnValue as Pledge;
                    if (pledge == null || pledge.PledgeId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "该数据不存在,不能进行执行完成操作";
                        return result;
                    }

                    //执行完成
                    result = pledgeDAL.Complete(user, pledge);
                    if (result.ResultStatus != 0)
                        return result;

                    //加载明细
                    PledgeDetialDAL pledgeDetialDAL = new PledgeDetialDAL();
                    result = pledgeDetialDAL.Load(user, pledge.PledgeId);
                    if (result.ResultStatus != 0)
                        return result;

                    List<Model.PledgeDetial> details = result.ReturnValue as List<Model.PledgeDetial>;
                    if (details == null || !details.Any())
                    {
                        result.ResultStatus = -1;
                        result.Message = "获取质押明细失败";
                        return result;
                    }

                    //加载对应质押申请
                    PledgeApplyDAL pledgeApplyDAL = new PledgeApplyDAL();
                    result = pledgeApplyDAL.Get(user, pledge.PledgeApplyId);
                    if (result.ResultStatus != 0)
                        return result;

                    PledgeApply pledgeApply = result.ReturnValue as PledgeApply;
                    if (pledgeApply == null || pledgeApply.PledgeApplyId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "对应质押申请加载失败";
                        return result;
                    }

                    //明细执行完成
                    //更新库存状态至质押库存
                    StockDAL stockDAL = new StockDAL();
                    StockLogDAL stockLogDAL = new StockLogDAL();
                    StockNameDAL stockNameDAL = new StockNameDAL();

                    foreach (Model.PledgeDetial detail in details)
                    {
                        //明细完成
                        result = pledgeDetialDAL.Complete(user, detail);
                        if (result.ResultStatus != 0)
                            return result;

                        //获取质押流水
                        result = stockLogDAL.Get(user, detail.StockLogId);
                        if (result.ResultStatus != 0)
                            return result;

                        Model.StockLog stockLog = result.ReturnValue as Model.StockLog;
                        if (stockLog == null || stockLog.StockLogId <= 0)
                        {
                            result.ResultStatus = -1;
                            result.Message = "质押流水获取失败";
                            return result;
                        }

                        //完成质押流水
                        result = stockLogDAL.Complete(user, stockLog);
                        if (result.ResultStatus != 0)
                            return result;

                        //获取库存
                        result = stockDAL.Get(user, detail.StockId);
                        if (result.ResultStatus != 0)
                            return result;

                        Model.Stock stock = result.ReturnValue as Model.Stock;
                        if (stock == null || stock.StockId <= 0)
                        {
                            result.ResultStatus = -1;
                            result.Message = "库存获取失败";
                            return result;
                        }

                        result = stockDAL.UpdateStockStatusDirect(stock, StockStatusEnum.质押库存);
                        if (result.ResultStatus != 0)
                            return result;
                    }

                    scope.Complete();
                }
            }
            catch (Exception ex)
            {
                result.Message = ex.Message;
            }
            finally
            {
                if (result.ResultStatus != 0)
                    log.ErrorFormat("{0} {1},类型序号:{2}", user.EmpName, result.Message, result.ReturnValue);
                else if (log.IsInfoEnabled)
                    log.InfoFormat("{0} {1},类型序号:{2}", user.EmpName, result.Message, result.ReturnValue);
            }

            return result;
        }