Esempio n. 1
0
        /// <summary>
        /// 生成拉动单
        /// </summary>
        /// <param name="twdPartBoxInfo"></param>
        /// <param name="twdWindowTimeInfo"></param>
        /// <param name="supplierInfo"></param>
        /// <param name="twdCounterInfos"></param>
        /// <param name="maintainInhouseLogisticStandardInfos"></param>
        /// <returns></returns>
        private string CreateTwdPullOrder(List <TwdCounterInfo> twdCounterInfos, TwdPartBoxInfo twdPartBoxInfo, List <SupplierInfo> supplierInfos, TwdWindowTimeInfo twdWindowTimeInfo,
                                          List <MaintainInhouseLogisticStandardInfo> maintainInhouseLogisticStandardInfos)
        {
            ///
            StringBuilder @string = new StringBuilder();
            ///Create TwdPullOrderInfo
            TwdPullOrderInfo twdPullOrderInfo = null;
            ///Create PcsPullOrderInfo
            PcsPullOrderInfo pcsPullOrderInfo = null;
            ///仓储衔接主表
            MaterialPullingOrderInfo materialPulling = MaterialPullingCommonBLL.CreateMaterialPullingOrderInfo();

            if (twdPartBoxInfo.TwdPullMode.GetValueOrDefault() == (int)TwdPullModeConstants.Pcs)
            {
                pcsPullOrderInfo = PcsPullOrderBLL.CreatePcsPullOrderInfo(loginUser);
                ///TwdWindowTimeInfo -> PcsPullOrderInfo
                PcsPullOrderBLL.GetPcsPullOrderInfo(twdWindowTimeInfo, ref pcsPullOrderInfo);
                ///TwdPartBoxInfo -> PcsPullOrderInfo
                PcsPullOrderBLL.GetPcsPullOrderInfo(twdPartBoxInfo, ref pcsPullOrderInfo);
                ///SupplierInfo -> PcsPullOrderInfo
                SupplierInfo supplierInfo = supplierInfos.FirstOrDefault(d => d.SupplierNum == twdPartBoxInfo.SupplierNum);
                PcsPullOrderBLL.GetPcsPullOrderInfo(supplierInfo, ref pcsPullOrderInfo);
                ///
                @string.AppendLine(PcsPullOrderDAL.GetInsertSql(pcsPullOrderInfo));
                ///PcsPullOrderInfo -> MaterialPullingOrderInfo
                MaterialPullingCommonBLL.GetMaterialPullingOrderInfo(pcsPullOrderInfo, ref materialPulling);
            }
            else
            {
                twdPullOrderInfo = TwdPullOrderBLL.CreateTwdPullOrderInfo(loginUser);
                ///TwdWindowTimeInfo -> TwdPullOrderInfo
                TwdPullOrderBLL.GetTwdPullOrderInfo(twdWindowTimeInfo, ref twdPullOrderInfo);
                ///TwdPartBoxInfo -> TwdPullOrderInfo
                TwdPullOrderBLL.GetTwdPullOrderInfo(twdPartBoxInfo, ref twdPullOrderInfo);
                ///SupplierInfo -> TwdPullOrderInfo
                SupplierInfo supplierInfo = supplierInfos.FirstOrDefault(d => d.SupplierNum == twdPartBoxInfo.SupplierNum);
                TwdPullOrderBLL.GetTwdPullOrderInfo(supplierInfo, ref twdPullOrderInfo);
                ///
                @string.AppendLine(TwdPullOrderDAL.GetInsertSql(twdPullOrderInfo));
                ///TwdPullOrderInfo -> MaterialPullingOrderInfo
                MaterialPullingCommonBLL.GetMaterialPullingOrderInfo(twdPullOrderInfo, ref materialPulling);
            }
            ///行号
            int rowNo = 0;

            ///循环计数器
            foreach (TwdCounterInfo twdCounterInfo in twdCounterInfos)
            {
                ///物料需求数量
                decimal requiredPartQty = 0;
                ///物料需求箱数
                int packageQty = 0;

                #region 圆整方式
                ///向上圆整
                if (twdCounterInfo.RoundnessMode == (int)RoundnessModeConstants.Upward)
                {
                    if (twdCounterInfo.Package.GetValueOrDefault() > 0)
                    {
                        ///根据计数器中的圆整方式⑨,当圆整方式⑨为20.向上时以Math.Ceiling(当前计数⑮/箱内数量⑯)*箱内数量⑯作为本次的物料需求数量
                        requiredPartQty = Math.Ceiling(twdCounterInfo.CurrentQty.GetValueOrDefault() / twdCounterInfo.Package.GetValueOrDefault()) * twdCounterInfo.Package.GetValueOrDefault();
                        packageQty      = Convert.ToInt32(Math.Ceiling(requiredPartQty / twdCounterInfo.Package.GetValueOrDefault()));
                    }
                }
                ///向下圆整
                if (twdCounterInfo.RoundnessMode == (int)RoundnessModeConstants.Downward)
                {
                    if (twdCounterInfo.Package.GetValueOrDefault() > 0)
                    {
                        ///根据计数器中的圆整方式⑨,当圆整方式⑨为20.向上时以Math.Ceiling(当前计数⑮/箱内数量⑯)*箱内数量⑯作为本次的物料需求数量
                        requiredPartQty = Math.Floor(twdCounterInfo.CurrentQty.GetValueOrDefault() / twdCounterInfo.Package.GetValueOrDefault()) * twdCounterInfo.Package.GetValueOrDefault();
                        packageQty      = Convert.ToInt32(Math.Ceiling(requiredPartQty / twdCounterInfo.Package.GetValueOrDefault()));
                    }
                }
                ///按需求数量
                if (twdCounterInfo.RoundnessMode == (int)RoundnessModeConstants.Ondemand)
                {
                    ///当圆整方式⑨为按需时则当前计数⑮直接作为本次的物料需求数量
                    requiredPartQty = twdCounterInfo.CurrentQty.GetValueOrDefault();
                    packageQty      = Convert.ToInt32(Math.Ceiling(requiredPartQty / twdCounterInfo.Package.GetValueOrDefault()));
                }
                #endregion

                ///获取物料拉动信息
                MaintainInhouseLogisticStandardInfo logisticStandardInfo = maintainInhouseLogisticStandardInfos.FirstOrDefault(d => d.Fid == twdCounterInfo.PartPullFid.GetValueOrDefault());
                if (logisticStandardInfo == null)
                {
                    continue;
                }
                ///若计数器对应的物料拉动信息中最小起订包装数为一个大于零的数字,则需要在此处比对物料需求箱数是否大于等于最小起订包装数,若不满足则不产生拉动
                if (logisticStandardInfo.MinPullBox.GetValueOrDefault() > 0 && packageQty < logisticStandardInfo.MinPullBox.GetValueOrDefault())
                {
                    continue;
                }
                ///若计数器对应的物料拉动信息中批量包装数为一个大于零的数字,则需要Math.Floor(物料需求箱数 / 批量包装数) * 批量包装数,作为新的物料需求箱数,同时* 箱内数量⑯获得新的物料需求数量
                if (logisticStandardInfo.BatchPullBox.GetValueOrDefault() > 0 && twdCounterInfo.Package.GetValueOrDefault() > 0)
                {
                    packageQty      = Convert.ToInt32(Math.Ceiling(Convert.ToDecimal(packageQty) / logisticStandardInfo.BatchPullBox.GetValueOrDefault())) * logisticStandardInfo.BatchPullBox.GetValueOrDefault();
                    requiredPartQty = packageQty * twdCounterInfo.Package.GetValueOrDefault();
                }

                ///仓储衔接明细表
                MaterialPullingOrderDetailInfo detailInfo = MaterialPullingCommonBLL.CreateMaterialPullingOrderDetailInfo();
                if (twdPartBoxInfo.TwdPullMode.GetValueOrDefault() == (int)TwdPullModeConstants.Pcs)
                {
                    ///
                    PcsPullOrderDetailInfo pullOrderDetailInfo = PcsPullOrderDetailBLL.CreatePcsPullOrderDetailInfo(loginUser);
                    ///MaintainInhouseLogisticStandardInfo -> TwdPullOrderDetailInfo
                    PcsPullOrderDetailBLL.GetPcsPullOrderDetailInfo(logisticStandardInfo, ref pullOrderDetailInfo);
                    ///TwdPullOrderInfo -> TwdPullOrderDetailInfo
                    PcsPullOrderDetailBLL.GetPcsPullOrderDetailInfo(pcsPullOrderInfo, ref pullOrderDetailInfo);
                    ///ROW_NO,行号
                    pullOrderDetailInfo.RowNo = ++rowNo;
                    ///REQUIRED_PACKAGE_QTY,需求包装数
                    pullOrderDetailInfo.RequiredPackageQty = packageQty;
                    ///REQUIRED_PART_QTY,需求物料数量
                    pullOrderDetailInfo.RequiredPartQty = requiredPartQty;
                    ///
                    @string.AppendLine(PcsPullOrderDetailDAL.GetInsertSql(pullOrderDetailInfo));
                    ///TwdPullOrderDetailInfo -> MaterialPullingOrderDetailInfo
                    MaterialPullingCommonBLL.GetMaterialPullingOrderDetailInfo(pullOrderDetailInfo, ref detailInfo);
                }
                else
                {
                    ///
                    TwdPullOrderDetailInfo pullOrderDetailInfo = TwdPullOrderDetailBLL.CreateTwdPullOrderDetailInfo(loginUser);
                    ///MaintainInhouseLogisticStandardInfo -> TwdPullOrderDetailInfo
                    TwdPullOrderDetailBLL.GetTwdPullOrderDetailInfo(logisticStandardInfo, ref pullOrderDetailInfo);
                    ///TwdPullOrderInfo -> TwdPullOrderDetailInfo
                    TwdPullOrderDetailBLL.GetTwdPullOrderDetailInfo(twdPullOrderInfo, ref pullOrderDetailInfo);
                    ///ROW_NO,行号
                    pullOrderDetailInfo.RowNo = ++rowNo;
                    ///REQUIRED_PACKAGE_QTY,需求包装数
                    pullOrderDetailInfo.RequiredPackageQty = packageQty;
                    ///REQUIRED_PART_QTY,需求物料数量
                    pullOrderDetailInfo.RequiredPartQty = requiredPartQty;
                    ///
                    @string.AppendLine(TwdPullOrderDetailDAL.GetInsertSql(pullOrderDetailInfo));
                    ///TwdPullOrderDetailInfo -> MaterialPullingOrderDetailInfo
                    MaterialPullingCommonBLL.GetMaterialPullingOrderDetailInfo(pullOrderDetailInfo, ref detailInfo);
                }
                ///
                materialPulling.MaterialPullingOrderDetailInfos.Add(detailInfo);

                #region 扣减计数器
                ///最后根据物料需求数量扣减对应的计数器的当前计数⑮
                @string.AppendLine("update [LES].[TT_MPM_TWD_COUNTER] " +
                                   "set [CURRENT_QTY] = isnull([CURRENT_QTY],0) - " + requiredPartQty + "," +
                                   "[MODIFY_DATE] = GETDATE()," +
                                   "[MODIFY_USER] = N'" + loginUser + "' " +
                                   "where [ID]= " + twdCounterInfo.Id + ";");
                ///
                TwdCounterLogInfo twdCounterLogInfo = TwdCounterLogBLL.CreateTwdCounterLogInfo(twdCounterInfo.Fid.GetValueOrDefault(), loginUser);
                ///TwdCounterInfo -> TwdCounterLogInfo
                TwdCounterLogBLL.GetTwdCounterLogInfo(twdCounterInfo, ref twdCounterLogInfo);
                ///PART_QTY,物料数量
                twdCounterLogInfo.PartQty = 0 - requiredPartQty;
                ///SOURCE_DATA,目视来源数据
                twdCounterLogInfo.SourceData = twdPullOrderInfo.OrderCode;
                ///SOURCE_DATA_FID,数据来源外键
                twdCounterLogInfo.SourceDataFid = twdPullOrderInfo.Fid;
                ///SOURCE_DATA_TYPE,数据来源类型
                twdCounterLogInfo.SourceDataType = (int)TwdCounterSourceDataTypeConstants.CreateRunsheet;
                ///
                @string.AppendLine(TwdCounterLogDAL.GetInsertSql(twdCounterLogInfo));
                #endregion
            }
            ///更新时间窗窗口时间为已发单状态
            @string.AppendLine("update [LES].[TT_MPM_TWD_WINDOW_TIME] " +
                               "set [SEND_TIME_STATUS]= " + (int)SendTimeStatusConstants.Sent + "," +
                               "[MODIFY_DATE] = GETDATE()," +
                               "[MODIFY_USER] = N'" + loginUser + "' " +
                               "where [ID]= " + twdWindowTimeInfo.Id + ";");
            ///拉动单生成后需要调用拉动仓储衔接函数获取语句
            @string.AppendLine(MaterialPullingCommonBLL.Handler(materialPulling, loginUser));
            return(@string.ToString());
        }
        /// <summary>
        /// TWD
        /// </summary>
        /// <param name="vehiclePointStatusInfo"></param>
        /// <param name="twdCounterInfos"></param>
        /// <param name="twdMaintainInhouseLogisticStandardInfos"></param>
        /// <returns></returns>
        private string TwdCounterDeal(VehiclePointStatusInfo vehiclePointStatusInfo, List <TwdPartBoxInfo> twdPartBoxInfos, List <MaintainInhouseLogisticStandardInfo> twdMaintainInhouseLogisticStandardInfos)
        {
            ///
            StringBuilder stringBuilder = new StringBuilder();
            ///根据车辆状态信息中的生产订单号①获取到对应的生产订单物料清单、此处为了保障执行效率,需要根据已获取的计数器的物料号⑩过滤获取物料清单
            ///ZORDNO = 生产订单号
            ///ZCOMNO = 物料图号
            List <PullOrderBomInfo> pullOrderBomInfos = new PullOrderBomBLL().GetList("" +
                                                                                      "[ZORDNO] = N'" + vehiclePointStatusInfo.OrderNo + "' and " +
                                                                                      "[ZCOMNO] in ('" + string.Join("','", twdMaintainInhouseLogisticStandardInfos.Select(d => d.PartNo).ToArray()) + "')", string.Empty);

            if (pullOrderBomInfos.Count == 0)
            {
                return(string.Empty);
            }
            ///
            foreach (TwdPartBoxInfo twdPartBoxInfo in twdPartBoxInfos)
            {
                ///不是这个信息点的零件类忽略
                if (vehiclePointStatusInfo.StatusPointCode != twdPartBoxInfo.StatusPointCode)
                {
                    continue;
                }
                ///本零件类对应的物料拉动信息
                List <MaintainInhouseLogisticStandardInfo> maintainInhouseLogisticStandards = twdMaintainInhouseLogisticStandardInfos.Where(d => d.InhousePartClass == twdPartBoxInfo.PartBoxCode).ToList();
                ///若本零件类无物料拉动信息则返回
                if (twdMaintainInhouseLogisticStandardInfos.Count == 0)
                {
                    continue;
                }
                ///零件类过滤后的物料拉动信息对应的物料清单
                List <PullOrderBomInfo> pullOrderBoms = pullOrderBomInfos.Where(d => maintainInhouseLogisticStandards.Select(m => m.PartNo).Contains(d.Zcomno)).ToList();
                ///循环过滤后的物料清单
                foreach (PullOrderBomInfo pullOrderBom in pullOrderBoms)
                {
                    ///匹配物料拉动信息的最小维度是 物料图号+供应商+工位,依次降低维度来获取唯一的物料拉动信息
                    MaintainInhouseLogisticStandardInfo maintainInhouseLogisticStandard = maintainInhouseLogisticStandards.FirstOrDefault(d =>
                                                                                                                                          d.PartNo == pullOrderBom.Zcomno && d.SupplierNum == pullOrderBom.SupplierNum && d.Location == pullOrderBom.Zloc);
                    ///物料图号+供应商
                    if (maintainInhouseLogisticStandard == null)
                    {
                        maintainInhouseLogisticStandard = maintainInhouseLogisticStandards.FirstOrDefault(d => d.PartNo == pullOrderBom.Zcomno && d.SupplierNum == pullOrderBom.SupplierNum);
                    }
                    ///物料图号
                    if (maintainInhouseLogisticStandard == null)
                    {
                        maintainInhouseLogisticStandard = maintainInhouseLogisticStandards.FirstOrDefault(d => d.PartNo == pullOrderBom.Zcomno);
                    }
                    ///未能成功获取到正确的物料拉动信息
                    if (maintainInhouseLogisticStandard == null)
                    {
                        continue;
                    }
                    ///根据物料拉动信息外键获取计数器,未能成功获取时需要创建
                    TwdCounterInfo twdCounterInfo = TwdCounterBLL.GetInfoByPartPullFid(maintainInhouseLogisticStandard.Fid);
                    if (twdCounterInfo == null)
                    {
                        ///创建计数器
                        twdCounterInfo = TwdCounterBLL.CreateTwdCounterInfo(loginUser);
                        ///以物料拉动信息填充计数器
                        TwdCounterBLL.GetTwdCounterInfo(maintainInhouseLogisticStandard, ref twdCounterInfo);
                        ///以零件类信息填充计数器
                        TwdCounterBLL.GetTwdCounterInfo(twdPartBoxInfo, ref twdCounterInfo);
                        ///
                        twdCounterInfo.Id = new TwdCounterBLL().InsertInfo(twdCounterInfo);
                        if (twdCounterInfo.Id == 0)
                        {
                            throw new Exception("MC:0x00000453");///时间窗计数器创建失败
                        }
                    }
                    ///计数器状态未处于启用
                    if (twdCounterInfo.Status != (int)BasicDataStatusConstants.Enable)
                    {
                        continue;
                    }
                    stringBuilder.AppendLine(TwdCounterBLL.UpdateTwdCounter(maintainInhouseLogisticStandard, twdPartBoxInfo, pullOrderBom.Zqty.GetValueOrDefault(), twdCounterInfo.Id, loginUser));
                    ///创建计数器日志
                    TwdCounterLogInfo twdCounterLogInfo = TwdCounterLogBLL.CreateTwdCounterLogInfo(twdCounterInfo.Fid.GetValueOrDefault(), loginUser);
                    ///以车辆过点信息填充计数器日志
                    TwdCounterLogBLL.GetTwdCounterLogInfo(vehiclePointStatusInfo, ref twdCounterLogInfo);
                    ///以物料拉动信息填充计数器日志
                    TwdCounterLogBLL.GetTwdCounterLogInfo(maintainInhouseLogisticStandard, ref twdCounterLogInfo);
                    ///以零件类信息填充计数器日志
                    TwdCounterLogBLL.GetTwdCounterLogInfo(twdPartBoxInfo, ref twdCounterLogInfo);
                    ///PART_QTY
                    twdCounterLogInfo.PartQty = pullOrderBom.Zqty.GetValueOrDefault();
                    ///
                    stringBuilder.AppendLine(TwdCounterLogDAL.GetInsertSql(twdCounterLogInfo));
                    ///触发层级拉动
                    stringBuilder.AppendLine(TwdCounterBLL.LevelPullRequirementCounter(
                                                 maintainInhouseLogisticStandard,
                                                 pullOrderBom.Zqty.GetValueOrDefault(),
                                                 loginUser,
                                                 twdCounterInfo.Fid.GetValueOrDefault(),
                                                 twdCounterInfo.PartBoxCode));
                }
            }
            return(stringBuilder.ToString());
        }
        /// <summary>
        /// 主函数
        /// </summary>
        public void Handler()
        {
            ///获取需求累计方式㉒为库存当量的零件类TM_MPM_TWD_PART_BOX
            List <TwdPartBoxInfo> twdPartBoxInfos = new TwdPartBoxBLL().GetList("" +
                                                                                "[REQUIREMENT_ACCUMULATE_MODE] = " + (int)RequirementAccumulateModeConstants.InventoryEquivalent + " and " +
                                                                                "[STATUS] = " + (int)BasicDataStatusConstants.Enable + "", string.Empty);

            if (twdPartBoxInfos.Count == 0)
            {
                return;
            }
            ///同时获取对应的物料拉动信息
            List <MaintainInhouseLogisticStandardInfo> maintainInhouseLogisticStandardInfos = new MaintainInhouseLogisticStandardBLL().GetList("" +
                                                                                                                                               "[STATUS] = " + (int)BasicDataStatusConstants.Enable + " and " +
                                                                                                                                               "[INHOUSE_SYSTEM_MODE] = N'" + (int)PullModeConstants.Twd + "' and " +
                                                                                                                                               "[INHOUSE_PART_CLASS] in ('" + string.Join("','", twdPartBoxInfos.Select(d => d.PartBoxCode).ToArray()) + "')", string.Empty);

            if (maintainInhouseLogisticStandardInfos.Count == 0)
            {
                return;
            }
            ///根据物料拉动信息中的工厂③目标仓库⑩存储区⑪和物料号获取库存数据
            List <StocksInfo> stocksInfos = new StocksBLL().GetList("" +
                                                                    "[PLANT] in ('" + string.Join("','", maintainInhouseLogisticStandardInfos.Select(d => d.Plant).ToArray()) + "') and " +
                                                                    "[WM_NO] in ('" + string.Join("','", maintainInhouseLogisticStandardInfos.Select(d => d.TWmNo).ToArray()) + "') and " +
                                                                    "[ZONE_NO] in ('" + string.Join("','", maintainInhouseLogisticStandardInfos.Select(d => d.TZoneNo).ToArray()) + "') and " +
                                                                    "[PART_NO] in ('" + string.Join("','", maintainInhouseLogisticStandardInfos.Select(d => d.PartNo).ToArray()) + "')", string.Empty);

            StringBuilder stringBuilder = new StringBuilder();

            ///以零件类进行循环
            foreach (TwdPartBoxInfo twdPartBoxInfo in twdPartBoxInfos)
            {
                ///获取零件类对应的物料拉动信息
                List <MaintainInhouseLogisticStandardInfo> maintainInhouseLogisticStandards = maintainInhouseLogisticStandardInfos.Where(d => d.InhousePartClass == twdPartBoxInfo.PartBoxCode).ToList();
                if (maintainInhouseLogisticStandards.Count == 0)
                {
                    continue;
                }
                ///物料拉动信息
                foreach (MaintainInhouseLogisticStandardInfo maintainInhouseLogisticStandard in maintainInhouseLogisticStandards)
                {
                    ///当系统配置中库存供应商维度标记 = true时,在过滤库存数据时需要考虑供应商
                    ///若物料拉动信息中未维护供应商信息则不考虑,因为两个标记同时符合时才会考虑
                    string supplierNum = string.Empty;
                    if (supplier_stocks_dimension.ToLower() == "true" && !string.IsNullOrEmpty(maintainInhouseLogisticStandard.SupplierNum))
                    {
                        supplierNum = maintainInhouseLogisticStandard.SupplierNum;
                    }
                    ///将工厂③目标仓库⑩存储区⑪物料号或增加供应商维度的过滤完成的库存数据集合中的可用数量进行汇总
                    ///当前库存
                    decimal avaibleQty = new StocksBLL().GetAvailbleQty(
                        maintainInhouseLogisticStandard.PartNo,
                        maintainInhouseLogisticStandard.TWmNo,
                        maintainInhouseLogisticStandard.TZoneNo,
                        supplierNum);
                    ///根据获得的物料拉动信息外键获取计数器
                    TwdCounterInfo twdCounterInfo = TwdCounterBLL.GetInfoByPartPullFid(maintainInhouseLogisticStandard.Fid);
                    if (twdCounterInfo == null)
                    {
                        ///创建计数器
                        twdCounterInfo = TwdCounterBLL.CreateTwdCounterInfo(loginUser);
                        ///以物料拉动信息填充计数器
                        TwdCounterBLL.GetTwdCounterInfo(maintainInhouseLogisticStandard, ref twdCounterInfo);
                        ///以零件类信息填充计数器
                        TwdCounterBLL.GetTwdCounterInfo(twdPartBoxInfo, ref twdCounterInfo);
                        ///
                        twdCounterInfo.Id = new TwdCounterBLL().InsertInfo(twdCounterInfo);
                        if (twdCounterInfo.Id == 0)
                        {
                            throw new Exception("MC:0x00000453");///时间窗计数器创建失败
                        }
                    }
                    ///计数器状态未处于启用
                    if (twdCounterInfo.Status != (int)BasicDataStatusConstants.Enable)
                    {
                        continue;
                    }
                    ///在途库存,已累积 + 已生成未完成TODO:
                    decimal onroadQty = twdCounterInfo.CurrentQty.GetValueOrDefault();
                    ///当可用数量小于等于物料拉动信息中的拉动最小值时,将拉动最大值减去汇总数量得到的则为本次需求数量
                    if (avaibleQty + onroadQty > maintainInhouseLogisticStandard.Min.GetValueOrDefault())
                    {
                        continue;
                    }
                    ///本次需求数量
                    decimal requireQty = maintainInhouseLogisticStandard.Max.GetValueOrDefault() - avaibleQty - onroadQty;
                    ///
                    stringBuilder.AppendLine(TwdCounterBLL.UpdateTwdCounter(maintainInhouseLogisticStandard, twdPartBoxInfo, requireQty, twdCounterInfo.Id, loginUser));
                    ///创建计数器日志
                    TwdCounterLogInfo twdCounterLogInfo = TwdCounterLogBLL.CreateTwdCounterLogInfo(twdCounterInfo.Fid.GetValueOrDefault(), loginUser);
                    ///以物料拉动信息填充计数器日志
                    TwdCounterLogBLL.GetTwdCounterLogInfo(maintainInhouseLogisticStandard, ref twdCounterLogInfo);
                    ///以零件类信息填充计数器日志
                    TwdCounterLogBLL.GetTwdCounterLogInfo(twdPartBoxInfo, ref twdCounterLogInfo);
                    ///PART_QTY
                    twdCounterLogInfo.PartQty = requireQty;
                    ///SOURCE_DATA_FID
                    twdCounterLogInfo.SourceDataFid = Guid.Empty;
                    ///SOURCE_DATA_TYPE
                    twdCounterLogInfo.SourceDataType = (int)TwdCounterSourceDataTypeConstants.Inventory;
                    ///SOURCE_DATA ,供应商|当前可用|在途数量
                    twdCounterLogInfo.SourceData = supplierNum + "|" + avaibleQty + "|" + onroadQty;
                    ///
                    stringBuilder.AppendLine(TwdCounterLogDAL.GetInsertSql(twdCounterLogInfo));
                    ///触发层级拉动
                    stringBuilder.AppendLine(TwdCounterBLL.LevelPullRequirementCounter(
                                                 maintainInhouseLogisticStandard,
                                                 requireQty,
                                                 loginUser,
                                                 twdCounterInfo.Fid.GetValueOrDefault(),
                                                 twdCounterInfo.PartBoxCode));
                }
                ///数据库执行
                using (TransactionScope trans = new TransactionScope())
                {
                    if (stringBuilder.Length > 0)
                    {
                        BLL.LES.CommonBLL.ExecuteNonQueryBySql(stringBuilder.ToString());
                    }
                    trans.Complete();
                }
                stringBuilder.Clear();
            }
        }