示例#1
0
    protected string RenderingLanguage(string content, string userCode, params string[] parameters)
    {
        try
        {
            content = ProcessMessage(content, parameters);
            if (userCode != null && userCode.Trim() != string.Empty)
            {
                User user = TheUserMgr.LoadUser(userCode, true, false);

                if (user != null && user.UserLanguage != null && user.UserLanguage != string.Empty)
                {
                    content = TheLanguageMgr.ProcessLanguage(content, user.UserLanguage);
                }
                else
                {
                    EntityPreference defaultLanguage = TheEntityPreferenceMgr.LoadEntityPreference(BusinessConstants.ENTITY_PREFERENCE_CODE_DEFAULT_LANGUAGE);
                    content = TheLanguageMgr.ProcessLanguage(content, defaultLanguage.Value);
                }
            }
            else
            {
                EntityPreference defaultLanguage = TheEntityPreferenceMgr.LoadEntityPreference(BusinessConstants.ENTITY_PREFERENCE_CODE_DEFAULT_LANGUAGE);
                content = TheLanguageMgr.ProcessLanguage(content, defaultLanguage.Value);
            }
        }
        catch (Exception ex)
        {
            return(content);
        }
        return(content);
    }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         EntityPreference entityPreference = TheEntityPreferenceMgr.LoadEntityPreference(BusinessConstants.ENTITY_PREFERENCE_CODE_AMOUNT_DECIMAL_LENGTH);
         DecimalLength = int.Parse(entityPreference.Value);
     }
 }
        public string GenerateNumber(string code)
        {
            string numberSuffix = GetNextSequence(code);

            EntityPreference entityPreference = entityPreferenceMgr.LoadEntityPreference(BusinessConstants.ENTITY_PREFERENCE_CODE_ORDER_LENGTH);
            int orderLength = int.Parse(entityPreference.Value);

            numberSuffix = numberSuffix.PadLeft(orderLength - code.Length, '0');


            return(code + numberSuffix);
        }
示例#4
0
 /*
  * 用于反射调用,参见GridView
  *
  */
 public string Render(String content)
 {
     if (CurrentUser != null && CurrentUser.UserLanguage != null && CurrentUser.UserLanguage != string.Empty)
     {
         content = TheLanguageMgr.ProcessLanguage(content, CurrentUser.UserLanguage);
     }
     else
     {
         EntityPreference defaultLanguage = TheEntityPreferenceMgr.LoadEntityPreference(BusinessConstants.ENTITY_PREFERENCE_CODE_DEFAULT_LANGUAGE);
         content = TheLanguageMgr.ProcessLanguage(content, defaultLanguage.Value);
     }
     return(content);
 }
示例#5
0
    protected void ODS_GV_EntityOpt_OnUpdating(object source, ObjectDataSourceMethodEventArgs e)
    {
        EntityPreference entityPreference = (EntityPreference)e.InputParameters[0];

        if (entityPreference.Value == null || entityPreference.Value == string.Empty)
        {
            e.Cancel = true;
            ShowErrorMessage("Common.String.Empty");
        }
        else
        {
            entityPreference.Value = entityPreference.Value.Trim();
        }
    }
示例#6
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (this.ModuleType == BusinessConstants.BILL_TRANS_TYPE_PO)
            {
                this.GV_List.Columns[3].Visible = false;
            }
            else if (this.ModuleType == BusinessConstants.BILL_TRANS_TYPE_SO)
            {
                this.GV_List.Columns[1].HeaderText = "${MasterData.ActingBill.Customer}";
                this.GV_List.Columns[2].Visible    = false;
            }

            EntityPreference entityPreference = TheEntityPreferenceMgr.LoadEntityPreference(BusinessConstants.ENTITY_PREFERENCE_CODE_AMOUNT_DECIMAL_LENGTH);
            DecimalLength = int.Parse(entityPreference.Value);
        }
    }
示例#7
0
        protected override void Render(HtmlTextWriter writer)
        {
            StringBuilder  sb       = new StringBuilder();
            StringWriter   sw       = new StringWriter(sb);
            HtmlTextWriter mywriter = new HtmlTextWriter(sw);

            base.Render(mywriter);
            string content = sb.ToString();

            if (CurrentUser != null && CurrentUser.UserLanguage != null && CurrentUser.UserLanguage != string.Empty)
            {
                content = LanguageMgr.ProcessLanguage(content, CurrentUser.UserLanguage);
            }
            else
            {
                EntityPreference defaultLanguage = EntityPreferenceMgr.LoadEntityPreference(BusinessConstants.ENTITY_PREFERENCE_CODE_DEFAULT_LANGUAGE);
                content = LanguageMgr.ProcessLanguage(content, defaultLanguage.Value);
            }
            writer.Write(content);
        }
示例#8
0
        public ActionResult update(int?id, string value, GridCommand command, EntityPreferenceSearchModel searchModel)
        {
            if (id.HasValue)
            {
                EntityPreference entityPreference = base.genericMgr.FindById <EntityPreference>((int)id);
                entityPreference.Value = value;
                base.genericMgr.Update(entityPreference);
                //SaveSuccessMessage(Resources.SYS.EntityPreference.EntityPreference_Updated);
            }

            SearchStatementModel         searchStatementModel = this.PrepareSearchStatement(command, searchModel);
            GridModel <EntityPreference> gridmodel            = GetAjaxPageData <EntityPreference>(searchStatementModel, command);

            foreach (var item in gridmodel.Data)
            {
                item.EntityPreferenceDesc = this.systemMgr.TranslateEntityPreferenceDescription(item.Description.ToString());
            }

            return(PartialView(gridmodel));
        }
示例#9
0
        public string TranslateMessage(string content, User user, params string[] parameters)
        {
            try
            {
                content = ProcessMessage(content, parameters);

                if (user != null && user.UserLanguage != null && user.UserLanguage != string.Empty)
                {
                    content = this.ProcessLanguage(content, user.UserLanguage);
                }
                else
                {
                    EntityPreference defaultLanguage = entityPreferenceMgr.LoadEntityPreference(BusinessConstants.ENTITY_PREFERENCE_CODE_DEFAULT_LANGUAGE);
                    content = this.ProcessLanguage(content, defaultLanguage.Value);
                }
            }
            catch (Exception ex)
            {
                throw new TechnicalException("翻译时出现异常:" + ex.Message);
            }
            return(content);
        }
示例#10
0
        public BillDetail TransferAtingBill2BillDetail(ActingBill actingBill)
        {
            EntityPreference entityPreference = this.entityPreferenceMgr.LoadEntityPreference(
                BusinessConstants.ENTITY_PREFERENCE_CODE_AMOUNT_DECIMAL_LENGTH);
            int        amountDecimalLength = int.Parse(entityPreference.Value);
            BillDetail billDetail          = new BillDetail();

            billDetail.ActingBill = actingBill;

            billDetail.Currency          = actingBill.Currency;
            billDetail.IsIncludeTax      = actingBill.IsIncludeTax;
            billDetail.TaxCode           = actingBill.TaxCode;
            billDetail.UnitPrice         = actingBill.UnitPrice;
            billDetail.BilledQty         = actingBill.CurrentBillQty;
            billDetail.Discount          = actingBill.CurrentDiscount;
            billDetail.LocationFrom      = actingBill.LocationFrom;
            billDetail.IpNo              = actingBill.IpNo;
            billDetail.ReferenceItemCode = actingBill.ReferenceItemCode;
            billDetail.IsProvEst         = actingBill.IsProvisionalEstimate;
            if (actingBill.CurrentBillQty != (actingBill.BillQty - actingBill.BilledQty))
            {
                //本次开票数量大于剩余数量
                if (Math.Abs(actingBill.CurrentBillQty) > Math.Abs(actingBill.BillQty - actingBill.BilledQty))
                {
                    throw new BusinessErrorException("ActingBill.Error.CurrentBillQtyGeRemainQty");
                }

                //本次开票数量小于剩余数量
                billDetail.OrderAmount = Math.Round((actingBill.BillAmount / actingBill.BillQty * actingBill.CurrentBillQty), amountDecimalLength, MidpointRounding.AwayFromZero);
            }
            else
            {
                //本次开票数量等于剩余数量
                billDetail.OrderAmount = actingBill.BillAmount - actingBill.BilledAmount;
            }

            return(billDetail);
        }
 public virtual void DeleteEntityPreference(EntityPreference entity)
 {
     entityDao.DeleteEntityPreference(entity);
 }
 public virtual void CreateEntityPreference(EntityPreference entity)
 {
     entityDao.CreateEntityPreference(entity);
 }
示例#13
0
        public ActingBill CreateActingBill(PlannedBill plannedBill, LocationLotDetail locationLotDetail, User user)
        {
            PlannedBill oldPlannedBill = plannedBillMgr.LoadPlannedBill(plannedBill.Id);

            oldPlannedBill.CurrentActingQty = plannedBill.CurrentActingQty;

            //检验,已结算数+本次结算数不能大于总结算数量,可能有负数结算,所以要用绝对值比较
            if (!oldPlannedBill.ActingQty.HasValue)
            {
                oldPlannedBill.ActingQty = 0;
            }
            if (Math.Abs(oldPlannedBill.ActingQty.Value + oldPlannedBill.CurrentActingQty) > Math.Abs(oldPlannedBill.PlannedQty))
            {
                throw new BusinessErrorException("PlannedBill.Error.ActingQtyExceed");
            }

            DateTime dateTimeNow = DateTime.Now;

            ActingBill actingBill = this.RetriveActingBill(oldPlannedBill, dateTimeNow, user);

            #region 计算结算金额
            decimal currentBillAmount = 0;
            if (Math.Abs(oldPlannedBill.ActingQty.Value + oldPlannedBill.CurrentActingQty) < Math.Abs(oldPlannedBill.PlannedQty))
            {
                //总结算数小于计划数,用实际单价计算待开票金额

                #region 计算实际单价
                EntityPreference entityPreference = entityPreferenceMgr.LoadEntityPreference(BusinessConstants.ENTITY_PREFERENCE_CODE_AMOUNT_DECIMAL_LENGTH);
                int     decimalLength             = int.Parse(entityPreference.Value);
                decimal actualUnitPrice           = Math.Round((oldPlannedBill.PlannedAmount / oldPlannedBill.PlannedQty), decimalLength, MidpointRounding.AwayFromZero);
                #endregion

                currentBillAmount = actualUnitPrice * oldPlannedBill.CurrentActingQty;
            }
            else
            {
                //总结算数等于计划数,先用剩余金额作为待开票金额
                if (!oldPlannedBill.ActingAmount.HasValue)
                {
                    oldPlannedBill.ActingAmount = 0;
                }
                currentBillAmount = oldPlannedBill.PlannedAmount - oldPlannedBill.ActingAmount.Value;
            }
            actingBill.BillAmount += currentBillAmount;
            #endregion

            #region 更新Planed Bill的已结算数量和金额
            if (!oldPlannedBill.ActingQty.HasValue)
            {
                oldPlannedBill.ActingQty = 0;
            }
            oldPlannedBill.ActingQty += oldPlannedBill.CurrentActingQty;

            if (!oldPlannedBill.ActingAmount.HasValue)
            {
                oldPlannedBill.ActingAmount = 0;
            }
            oldPlannedBill.ActingAmount  += currentBillAmount;
            oldPlannedBill.LastModifyDate = dateTimeNow;
            oldPlannedBill.LastModifyUser = user;

            this.plannedBillMgr.UpdatePlannedBill(oldPlannedBill);
            #endregion

            if (actingBill.Id == 0)
            {
                actingBillMgr.CreateActingBill(actingBill);
            }
            else
            {
                actingBillMgr.UpdateActingBill(actingBill);
            }

            #region 记BillTransaction
            billTransactionMgr.RecordBillTransaction(plannedBill, actingBill, locationLotDetail, user);
            #endregion

            return(actingBill);
        }
示例#14
0
        /// <summary>
        /// 导出数据函数
        /// </summary>
        /// <param name="FileType">导出文件MIME类型</param>
        /// <param name="FileName">导出文件的名称</param>
        protected void Export(GridView gridview, String FileType, String FileName)
        {
            /*
             * gridview.AllowPaging = false;
             * gridview.AllowSorting = false;
             */
            if (gridview.Rows.Count > 5000)
            {
                ShowWarningMessage("Common.Export.Warning.GreatThan5000", gridview.Rows.Count.ToString());
            }
            else if (gridview.Rows.Count == 0)
            {
                ShowWarningMessage("Common.GridView.NoRecordFound");
                return;
            }

            //gridview.DataBind();

            System.Globalization.CultureInfo cultureInfo = new System.Globalization.CultureInfo("ZH-CN", true);
            StringBuilder  sb  = new StringBuilder();
            StringWriter   sw  = new StringWriter(cultureInfo);
            HtmlTextWriter htw = new HtmlTextWriter(sw);

            Page     page = new Page();
            HtmlForm form = new HtmlForm();

            gridview.EnableViewState = false;

            // Deshabilitar la validación de eventos, sólo asp.net 2
            page.EnableEventValidation = false;

            // Realiza las inicializaciones de la instancia de la clase Page que requieran los diseñadores RAD.
            page.DesignerInitialize();

            page.Controls.Add(form);

            form.Controls.Add(gridview);

            page.RenderControl(htw);

            Response.Clear();
            Response.Buffer = true;

            //      Response.ContentType = "application/vnd.ms-excel";
            //Response.AddHeader("Content-Disposition", "attachment;filename=data.xls");
            Response.AppendHeader("Content-Disposition", "attachment;filename="
                                  + HttpUtility.UrlEncode(FileName, System.Text.Encoding.UTF8));

            //设置输出流HttpMiME类型(导出文件格式)
            Response.ContentType = FileType;
            //Response.Charset = "UTF-8";
            //设定输出字符集
            Response.Charset = "GB2312";
            //Response.ContentEncoding = Encoding.Default;
            Response.ContentEncoding = System.Text.Encoding.UTF8;

            string content = sw.ToString();

            if (CurrentUser != null && CurrentUser.UserLanguage != null && CurrentUser.UserLanguage != string.Empty)
            {
                content = TheLanguageMgr.ProcessLanguage(content, CurrentUser.UserLanguage);
            }
            else
            {
                EntityPreference defaultLanguage = TheEntityPreferenceMgr.LoadEntityPreference(BusinessConstants.ENTITY_PREFERENCE_CODE_DEFAULT_LANGUAGE);
                content = TheLanguageMgr.ProcessLanguage(content, defaultLanguage.Value);
            }

            Response.Write(content);
            Response.End();
            Response.Flush();

            /*
             *          gridview.AllowPaging = true;
             *          gridview.AllowSorting = true;
             */
            //gridview.DataBind();
        }
示例#15
0
 public void UpdateEntityPreference(EntityPreference entityPreference)
 {
     EntityPreferenceMgr.UpdateEntityPreference(entityPreference);
 }
示例#16
0
        public TransportationBillDetail TransferTransportationActBill2TransportationBillDetail(TransportationActBill transportationActBill)
        {
            EntityPreference entityPreference = this.entityPreferenceMgr.LoadEntityPreference(
                BusinessConstants.ENTITY_PREFERENCE_CODE_AMOUNT_DECIMAL_LENGTH);
            int amountDecimalLength = int.Parse(entityPreference.Value);
            TransportationBillDetail transportationBillDetail = new TransportationBillDetail();

            transportationBillDetail.ActBill = transportationActBill;

            transportationBillDetail.TransType    = transportationActBill.TransType;
            transportationBillDetail.Currency     = transportationActBill.Currency;
            transportationBillDetail.IsIncludeTax = transportationActBill.IsIncludeTax;
            transportationBillDetail.TaxCode      = transportationActBill.TaxCode;

            /*
             *
             * 1.TransType=Transportation 价格单明细(承运商) 或  短拨费(区域)时
             * a.PricingMethod=M3或KG  按数量
             * b.SHIPT   按金额
             * 2.TransType=WarehouseLease(固定费用) 按金额
             * 3.TransType=Operation(操作费) 按数量
             */
            if (transportationActBill.TransType == BusinessConstants.TRANSPORTATION_PRICELIST_DETAIL_TYPE_OPERATION
                ||
                (transportationActBill.TransType == BusinessConstants.TRANSPORTATION_PRICELIST_DETAIL_TYPE_TRANSPORTATION &&
                 (transportationActBill.PricingMethod == BusinessConstants.TRANSPORTATION_PRICING_METHOD_M3 || transportationActBill.PricingMethod == BusinessConstants.TRANSPORTATION_PRICING_METHOD_KG)
                )
                )
            {
                transportationBillDetail.UnitPrice = transportationActBill.UnitPrice;
                transportationBillDetail.BilledQty = transportationActBill.CurrentBillQty;
                transportationBillDetail.Discount  = transportationActBill.CurrentDiscount;
                if (transportationActBill.CurrentBillQty != (transportationActBill.BillQty - transportationActBill.BilledQty))
                {
                    //本次开票数量大于剩余数量
                    if (transportationActBill.CurrentBillQty > (transportationActBill.BillQty - transportationActBill.BilledQty))
                    {
                        throw new BusinessErrorException("TransportationActBill.Error.CurrentBillQtyGeRemainQty");
                    }

                    //本次开票数量小于剩余数量
                    transportationBillDetail.Amount = Math.Round((transportationActBill.BillAmount / transportationActBill.BillQty * transportationActBill.CurrentBillQty), amountDecimalLength, MidpointRounding.AwayFromZero);
                }
                else
                {
                    //本次开票数量等于剩余数量
                    transportationBillDetail.Amount = transportationActBill.BillAmount - transportationActBill.BilledAmount;
                }
            }
            else
            {
                transportationBillDetail.UnitPrice = transportationActBill.CurrentBillAmount;
                transportationBillDetail.BilledQty = 1;
                transportationBillDetail.Discount  = transportationActBill.CurrentDiscount;
                if (transportationActBill.CurrentBillAmount != (transportationActBill.BillAmount - transportationActBill.BilledAmount))
                {
                    //本次开票金额大于剩余金额
                    if (transportationActBill.CurrentBillAmount > (transportationActBill.BillAmount - transportationActBill.BilledAmount))
                    {
                        throw new BusinessErrorException("TransportationActBill.Error.CurrentBillAmountGeRemainAmount");
                    }

                    //本次开票金额小于剩余金额
                    transportationBillDetail.Amount = transportationActBill.CurrentBillAmount;
                }
                else
                {
                    //本次开票金额等于剩余金额
                    transportationBillDetail.Amount = transportationActBill.BillAmount - transportationActBill.BilledAmount;
                }
            }

            return(transportationBillDetail);
        }
示例#17
0
        public void GenerateOrderDetailSubsidiary(OrderDetail orderDetail)
        {
            OrderHead orderHead = orderDetail.OrderHead;
            int       maxOp     = 0; //记录最大工序号,给成品收货时用
            int       minOp     = 0; //记录最小工序号,给返工成品用

            #region 把OrderDetail的收货单位和单位用量转换为BOM单位和单位用量
            //fgUom,fgUnityQty代表接收一个orderDetail.Uom单位(等于订单的收货单位)的FG,等于单位(fgUom)有多少(fgUnityQty)值
            Uom     fgUom      = orderDetail.Uom;
            decimal fgUnityQty = 1;     //运输物品和生产的成品UnitQty默认为1
            //如果和Bom上的单位不一致,转化为Bom上的单位,不然会导致物料回冲不正确。
            if (orderDetail.Bom != null && orderDetail.Uom.Code.ToUpper() != orderDetail.Bom.Uom.Code.ToUpper())
            {
                fgUom      = orderDetail.Bom.Uom;
                fgUnityQty = this.uomConversionMgr.ConvertUomQty(orderDetail.Item, orderDetail.Uom, fgUnityQty, fgUom);
            }
            #endregion

            #region 创建OrderLocTrans

            if (orderDetail.Item.Type == BusinessConstants.CODE_MASTER_ITEM_TYPE_VALUE_K)
            {
                //程序一般不会运行到这里,套件的拆分都在前台进行
                //用户在下订单的时候已经拆分了套件
                //2010-1-19 dingxin
                throw new BusinessErrorException("Order.Error.CreateOrder.ItemTypeK", orderDetail.Item.Code);
            }
            else
            {
                if (orderHead.Type == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_PROCUREMENT ||
                    orderHead.Type == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_CUSTOMERGOODS ||
                    orderHead.Type == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_SUBCONCTRACTING)
                {
                    #region 采购,只需要记录入库事务RCT-PO
                    this.orderLocationTransactionMgr.GenerateOrderLocationTransaction(orderDetail, orderDetail.Item, null,
                                                                                      fgUom, maxOp, BusinessConstants.IO_TYPE_OUT, null,
                                                                                      fgUnityQty, orderDetail.DefaultLocationFrom,
                                                                                      false, orderDetail.HuLotSize, true, null, orderDetail.ItemVersion, this.locationMgr.GetRejectLocation());

                    this.orderLocationTransactionMgr.GenerateOrderLocationTransaction(orderDetail, orderDetail.Item, null,
                                                                                      fgUom, maxOp, BusinessConstants.IO_TYPE_IN, BusinessConstants.CODE_MASTER_LOCATION_TRANSACTION_TYPE_VALUE_RCT_PO,
                                                                                      fgUnityQty, orderDetail.DefaultLocationTo,
                                                                                      false, orderDetail.HuLotSize, true, null, orderDetail.ItemVersion, this.locationMgr.GetRejectLocation());
                    #endregion
                }
                else if (orderHead.Type == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_DISTRIBUTION)
                {
                    #region 销售,只需要记录出库事务ISS-SO
                    this.orderLocationTransactionMgr.GenerateOrderLocationTransaction(orderDetail, orderDetail.Item, null,
                                                                                      fgUom, maxOp, BusinessConstants.IO_TYPE_OUT, BusinessConstants.CODE_MASTER_LOCATION_TRANSACTION_TYPE_VALUE_ISS_SO,
                                                                                      fgUnityQty, orderDetail.DefaultLocationFrom,
                                                                                      false, orderDetail.HuLotSize, true, null, null, this.locationMgr.GetRejectLocation());

                    this.orderLocationTransactionMgr.GenerateOrderLocationTransaction(orderDetail, orderDetail.Item, null,
                                                                                      fgUom, maxOp, BusinessConstants.IO_TYPE_IN, null,
                                                                                      fgUnityQty, orderDetail.DefaultLocationTo,
                                                                                      false, orderDetail.HuLotSize, true, null, null, this.locationMgr.GetRejectLocation());
                    #endregion
                }
                else if (orderHead.Type == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_TRANSFER)
                {
                    #region 移库,需要记录出库事务ISS-TR和入库事务RCT-TR
                    this.orderLocationTransactionMgr.GenerateOrderLocationTransaction(orderDetail, orderDetail.Item, null,
                                                                                      fgUom, maxOp, BusinessConstants.IO_TYPE_OUT, BusinessConstants.CODE_MASTER_LOCATION_TRANSACTION_TYPE_VALUE_ISS_TR,
                                                                                      fgUnityQty, orderDetail.DefaultLocationFrom,
                                                                                      false, orderDetail.HuLotSize, true, null, null, this.locationMgr.GetRejectLocation());

                    this.orderLocationTransactionMgr.GenerateOrderLocationTransaction(orderDetail, orderDetail.Item, null,
                                                                                      fgUom, maxOp, BusinessConstants.IO_TYPE_IN, BusinessConstants.CODE_MASTER_LOCATION_TRANSACTION_TYPE_VALUE_RCT_TR,
                                                                                      fgUnityQty, orderDetail.DefaultLocationTo,
                                                                                      false, orderDetail.HuLotSize, true, null, null, this.locationMgr.GetRejectLocation());
                    #endregion
                }
                //else if (orderHead.Type == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_INSPECTION)
                //{
                //    #region 检验,需要记录出库事务ISS-TR和入库事务RCT-TR
                //    this.orderLocationTransactionMgr.GenerateOrderLocationTransaction(orderDetail, orderDetail.Item, null,
                //                fgUom, maxOp, BusinessConstants.IO_TYPE_OUT, BusinessConstants.CODE_MASTER_LOCATION_TRANSACTION_TYPE_VALUE_ISS_TR,
                //                fgUnityQty, orderDetail.DefaultLocationFrom,
                //                false, orderDetail.HuLotSize, true, null, null, this.locationMgr.GetRejectLocation());

                //    this.orderLocationTransactionMgr.GenerateOrderLocationTransaction(orderDetail, orderDetail.Item, null,
                //                fgUom, maxOp, BusinessConstants.IO_TYPE_IN, BusinessConstants.CODE_MASTER_LOCATION_TRANSACTION_TYPE_VALUE_RCT_TR,
                //                fgUnityQty, orderDetail.DefaultLocationTo,
                //                false, orderDetail.HuLotSize, true, null, null, this.locationMgr.GetRejectLocation());
                //    #endregion
                //}
                else if (orderHead.Type == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_PRODUCTION)
                {
                    #region 创建生产物料的OrderLocTrans
                    //如果是生产订单,必须要有Bom
                    FillBomForOrderDetail(orderDetail);

                    IList <BomDetail> bomDetailList = this.bomDetailMgr.GetFlatBomDetail(orderDetail.Bom.Code, orderHead.StartTime);
                    foreach (BomDetail bomDetail in bomDetailList)
                    {
                        #region 记录最大工序号
                        //最大工序号是从Bom上取还是从Routing上取?
                        if (maxOp < bomDetail.Operation)
                        {
                            //记录最大工序号
                            maxOp = bomDetail.Operation;
                        }
                        #endregion

                        #region 记录最小工序号
                        //最小工序号是从Bom上取还是从Routing上取?
                        if (minOp > bomDetail.Operation || minOp == 0)
                        {
                            //记录最大工序号
                            minOp = bomDetail.Operation;
                        }
                        #endregion

                        #region 查找物料的来源库位
                        //来源库位查找逻辑BomDetail-->RoutingDetail-->FlowDetail-->Flow
                        Location bomLocFrom = bomDetail.Location;

                        if (orderHead.Routing != null)
                        {
                            //在Routing上查找,并检验Routing上的工序和BOM上的是否匹配
                            RoutingDetail routingDetail = routingDetailMgr.LoadRoutingDetail(orderHead.Routing, bomDetail.Operation, bomDetail.Reference);
                            if (routingDetail != null)
                            {
                                if (bomLocFrom == null)
                                {
                                    bomLocFrom = routingDetail.Location;
                                }

                                //if (maxOp < routingDetail.Operation)
                                //{
                                //    //记录最大工序号
                                //    maxOp = routingDetail.Operation;
                                //}

                                orderHead.AddOrderOperation(this.orderOperationMgr.GenerateOrderOperation(orderHead, routingDetail));
                            }
                            //else
                            //{
                            //    //没有找到和BOM上相匹配的工序
                            //    throw new BusinessErrorException("Order.Error.OpNotMatch", bomDetail.Bom.Code, bomDetail.Item.Code, routing.Code, bomDetail.Operation.ToString(), bomDetail.Reference);
                            //}
                        }

                        if (bomLocFrom == null)
                        {
                            //取默认库位FlowDetail-->Flow
                            bomLocFrom = orderDetail.DefaultLocationFrom;
                        }
                        //string bomLocFromType = bomLocFrom != null ? bomLocFrom.Type : null;
                        #endregion

                        #region 查找物料的目的库位
                        //目的库位,如果是生产类型,直接置为Null,其它情况FlowDetail-->Flow
                        Location bomLocTo = (orderHead.Type != BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_PRODUCTION) ?
                                            orderDetail.DefaultLocationTo : null;
                        //string bomLocToType = bomLocTo != null ? bomLocTo.Type : null;
                        #endregion

                        #region 生产物料,只需要记录出库事务ISS-TR
                        this.orderLocationTransactionMgr.GenerateOrderLocationTransaction(orderDetail, bomDetail.Item, bomDetail,
                                                                                          bomDetail.Uom, bomDetail.Operation, BusinessConstants.IO_TYPE_OUT, BusinessConstants.CODE_MASTER_LOCATION_TRANSACTION_TYPE_VALUE_ISS_WO,
                                                                                          bomDetail.CalculatedQty * fgUnityQty, //返工,原材料数量默认等于0
                                                                                          bomLocFrom, bomDetail.IsShipScanHu, bomDetail.HuLotSize, bomDetail.NeedPrint, bomDetail.BackFlushMethod, null, this.locationMgr.GetRejectLocation());
                        #endregion
                    }
                    #endregion

                    #region 生产成品,只需要记录入库事务RCT-WO
                    this.orderLocationTransactionMgr.GenerateOrderLocationTransaction(orderDetail, orderDetail.Item, null,
                                                                                      fgUom, maxOp, BusinessConstants.IO_TYPE_IN, BusinessConstants.CODE_MASTER_LOCATION_TRANSACTION_TYPE_VALUE_RCT_WO,
                                                                                      fgUnityQty, orderDetail.DefaultLocationTo,
                                                                                      false, orderDetail.HuLotSize, true, null, orderDetail.ItemVersion, this.locationMgr.GetRejectLocation());

                    //返工,把自己添加到物料中
                    if (orderHead.SubType == BusinessConstants.CODE_MASTER_ORDER_SUB_TYPE_VALUE_RWO)
                    {
                        //Location loc = orderDetail.DefaultLocationTo.ActingLocation != null ? orderDetail.DefaultLocationTo.ActingLocation : orderDetail.DefaultLocationTo;
                        Location loc = this.locationMgr.GetRejectLocation();


                        //todo 处理返工的成品是否需要扫描Hu,现在不扫描
                        //返工对成品的投料记RCT-WO事务
                        this.orderLocationTransactionMgr.GenerateOrderLocationTransaction(orderDetail, orderDetail.Item, null,
                                                                                          fgUom, minOp, BusinessConstants.IO_TYPE_OUT, BusinessConstants.CODE_MASTER_LOCATION_TRANSACTION_TYPE_VALUE_RCT_WO,
                                                                                          fgUnityQty, loc,
                                                                                          false, orderDetail.HuLotSize, true, null, null, this.locationMgr.GetRejectLocation());
                    }
                    #endregion
                }
            }
            #endregion

            #region 生产,给没有Op的OrderLocTrans赋值maxOp
            if (orderHead.Type == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_PRODUCTION)
            {
                if (maxOp == 0)
                {
                    EntityPreference entityPreference = this.entityPreferenceMgr.LoadEntityPreference(BusinessConstants.ENTITY_PREFERENCE_CODE_SEQ_INTERVAL);
                    int seqInterval = int.Parse(entityPreference.Value);
                    maxOp = seqInterval; //默认工序号
                }

                if (orderDetail.OrderLocationTransactions != null && orderDetail.OrderLocationTransactions.Count > 0)
                {
                    foreach (OrderLocationTransaction orderLocationTransaction in orderDetail.OrderLocationTransactions)
                    {
                        if (orderLocationTransaction.Operation == 0)
                        {
                            orderLocationTransaction.Operation = maxOp;
                        }
                    }
                }
            }
            #endregion
        }
示例#18
0
        public IList <OrderDetail> GenerateOrderDetail(OrderHead orderHead, FlowDetail flowDetail, bool isReferencedFlow)
        {
            EntityPreference entityPreference = this.entityPreferenceMgr.LoadEntityPreference(BusinessConstants.ENTITY_PREFERENCE_CODE_SEQ_INTERVAL);
            int seqInterval = int.Parse(entityPreference.Value);

            IList <OrderDetail> orderDetailList = new List <OrderDetail>();
            OrderDetail         orderDetail     = new OrderDetail();

            orderDetail.FlowDetail = flowDetail;
            orderDetail.OrderHead  = orderHead;
            if (!isReferencedFlow)
            {
                CloneHelper.CopyProperty(flowDetail, orderDetail, FlowDetail2OrderDetailCloneFields);
            }
            else
            {
                CloneHelper.CopyProperty(flowDetail, orderDetail, ReferenceOrderDetailCloneFields);
            }

            #region 查找价格
            if (orderHead.Type == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_PROCUREMENT || orderHead.Type == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_DISTRIBUTION)
            {
                if (orderDetail.DefaultPriceListFrom != null)
                {
                    PriceListDetail priceListDetailFrom = priceListDetailMgr.GetLastestPriceListDetail(orderDetail.DefaultPriceListFrom, orderDetail.Item, orderHead.StartTime, orderHead.Currency, orderDetail.Uom);
                    if (priceListDetailFrom != null)
                    {
                        orderDetail.PriceListDetailFrom = priceListDetailFrom;
                    }
                }
                if (orderDetail.DefaultPriceListTo != null)
                {
                    PriceListDetail priceListDetailTo = priceListDetailMgr.GetLastestPriceListDetail(orderDetail.DefaultPriceListTo, orderDetail.Item, orderHead.StartTime, orderHead.Currency, orderDetail.Uom);
                    if (priceListDetailTo != null)
                    {
                        orderDetail.PriceListDetailTo = priceListDetailTo;
                    }
                }
            }
            #endregion

            #region 设置退货和次品库位
            //if (orderHead.SubType == BusinessConstants.CODE_MASTER_ORDER_SUB_TYPE_VALUE_RTN
            //    || orderHead.SubType == BusinessConstants.CODE_MASTER_ORDER_SUB_TYPE_VALUE_RWO)
            //{
            //    if (flowDetail.LocationFrom != null && flowDetail.LocationFrom.ActingLocation != null)
            //    {
            //        orderDetail.LocationFrom = flowDetail.LocationFrom.ActingLocation;
            //    }

            //    if (flowDetail.LocationTo != null && flowDetail.LocationTo.ActingLocation != null)
            //    {
            //        orderDetail.LocationTo = flowDetail.LocationTo.ActingLocation;
            //    }
            //}
            if (orderHead.SubType == BusinessConstants.CODE_MASTER_ORDER_SUB_TYPE_VALUE_RWO)
            {
                orderDetail.LocationTo = this.locationMgr.GetRejectLocation();
            }
            #endregion

            //if (orderDetail.Item.Type == BusinessConstants.CODE_MASTER_ITEM_TYPE_VALUE_K)
            //{
            //    #region 处理套件
            //    IList<ItemKit> itemKitList = this.itemKitMgr.GetChildItemKit(orderDetail.Item.Code);

            //    if (itemKitList != null && itemKitList.Count > 0)
            //    {
            //        int count = 0;
            //        decimal? convertRate = null;
            //        foreach (ItemKit itemKit in itemKitList)
            //        {
            //            count++;

            //            if (!convertRate.HasValue)
            //            {
            //                if (itemKit.ParentItem.Uom.Code != orderDetail.Uom.Code)
            //                {
            //                    convertRate = this.uomConversionMgr.ConvertUomQty(orderDetail.Item, orderDetail.Uom, 1, itemKit.ParentItem.Uom);
            //                }
            //                else
            //                {
            //                    convertRate = 1;
            //                }
            //            }

            //            OrderDetail orderDetailOfChildKit = new OrderDetail();
            //            CloneHelper.CopyProperty(orderDetail, orderDetailOfChildKit, OrderDetailOfChildKitCloneFields);
            //            orderDetailOfChildKit.Sequence = orderDetailOfChildKit.Sequence + count;
            //            orderDetailOfChildKit.Item = itemKit.ChildItem;
            //            orderDetailOfChildKit.ReferenceItemCode = this.itemReferenceMgr.GetItemReferenceByItem(itemKit.ChildItem.Code, orderDetail.OrderHead.PartyFrom.Code, orderDetail.OrderHead.PartyTo.Code);
            //            orderDetailOfChildKit.Uom = itemKit.ChildItem.Uom;
            //            orderDetailOfChildKit.UnitCount = itemKit.ChildItem.UnitCount;
            //            //orderDetailOfChildKit.RequiredQty = orderDetailOfChildKit.RequiredQty * itemKit.Qty * convertRate;
            //            //orderDetailOfChildKit.OrderedQty = orderDetailOfChildKit.OrderedQty * itemKit.Qty * convertRate;
            //            orderDetailOfChildKit.GoodsReceiptLotSize = orderDetailOfChildKit.GoodsReceiptLotSize * itemKit.Qty * convertRate;
            //            orderDetailOfChildKit.BatchSize = orderDetailOfChildKit.BatchSize * itemKit.Qty * convertRate;
            //            if (orderDetailOfChildKit.HuLotSize.HasValue)
            //            {
            //                orderDetailOfChildKit.HuLotSize = int.Parse((orderDetailOfChildKit.HuLotSize.Value * itemKit.Qty * convertRate.Value).ToString("#"));
            //            }

            //            #region 计算价格
            //            if (orderDetailOfChildKit.DefaultPriceListFrom != null)
            //            {
            //                PriceListDetail priceListDetailFrom = priceListDetailMgr.GetLastestPriceListDetail(orderDetailOfChildKit.DefaultPriceListFrom, orderDetailOfChildKit.Item, orderHead.StartTime, orderHead.Currency, orderDetailOfChildKit.Uom);
            //                if (priceListDetailFrom != null)
            //                {
            //                    orderDetailOfChildKit.PriceListDetailFrom = priceListDetailFrom;
            //                }
            //            }
            //            if (orderDetailOfChildKit.DefaultPriceListTo != null)
            //            {
            //                PriceListDetail priceListDetailTo = priceListDetailMgr.GetLastestPriceListDetail(orderDetailOfChildKit.DefaultPriceListTo, orderDetailOfChildKit.Item, orderHead.StartTime, orderHead.Currency, orderDetailOfChildKit.Uom);
            //                if (priceListDetailTo != null)
            //                {
            //                    orderDetailOfChildKit.PriceListDetailTo = priceListDetailTo;
            //                }
            //            }
            //            #endregion

            //            //重新设置Sequence
            //            int detailCount = orderHead.OrderDetails != null ? orderHead.OrderDetails.Count : 0;
            //            orderDetail.Sequence = (detailCount + 1) * seqInterval;

            //            orderHead.AddOrderDetail(orderDetailOfChildKit);
            //            orderDetailList.Add(orderDetailOfChildKit);
            //        }
            //    }
            //    else
            //    {
            //        throw new BusinessErrorException("ItemKit.Error.NotFoundForParentItem", orderDetail.Item.Code);
            //    }
            //    #endregion
            //}
            //else
            //{
            //重新设置Sequence
            int detailCount = orderHead.OrderDetails != null ? orderHead.OrderDetails.Count : 0;
            orderDetail.Sequence = (detailCount + 1) * seqInterval;

            #region 参考零件号
            if (orderDetail.ReferenceItemCode == null || orderDetail.ReferenceItemCode == string.Empty)
            {
                string firstPartyCode  = string.Empty;
                string secondPartyCode = string.Empty;
                if (orderHead.Type == BusinessConstants.CODE_MASTER_FLOW_TYPE_VALUE_DISTRIBUTION)
                {
                    firstPartyCode = orderHead.PartyTo.Code;
                }
                else
                {
                    firstPartyCode = orderHead.PartyFrom.Code;
                }
                orderDetail.ReferenceItemCode = itemReferenceMgr.GetItemReferenceByItem(orderDetail.Item.Code, firstPartyCode, secondPartyCode);
            }
            #endregion

            #region 设置默认库位
            orderDetail.LocationFrom = orderDetail.LocationFrom == null ? orderHead.LocationFrom : orderDetail.LocationFrom;
            orderDetail.LocationTo   = orderDetail.LocationTo == null ? orderHead.LocationTo : orderDetail.LocationTo;
            #endregion

            orderHead.AddOrderDetail(orderDetail);
            orderDetailList.Add(orderDetail);
            //}

            return(orderDetailList);
        }
    protected void btnPrint_Click(object sender, EventArgs e)
    {
        IList <OrderDetail> orderDetailList       = PopulateOrderDetailList();
        IList <OrderDetail> targetOrderDetailList = new List <OrderDetail>();

        if (orderDetailList != null && orderDetailList.Count > 0)
        {
            foreach (OrderDetail orderDetail in orderDetailList)
            {
                if (orderDetail.OrderedQty > 0)
                {
                    targetOrderDetailList.Add(orderDetail);
                }
            }
        }

        if (targetOrderDetailList.Count == 0)
        {
            this.ShowErrorMessage("Inventory.Error.PrintHu.OrderDetail.Required");
            return;
        }

        IList <Hu> huList = null;

        #region  内/外包装
        string          packageType    = null;
        RadioButtonList rblPackageType = (RadioButtonList)this.Parent.FindControl("rblPackageType");
        if (rblPackageType.SelectedValue == "0")
        {
            packageType = BusinessConstants.CODE_MASTER_PACKAGETYPE_INNER;
        }
        else if (rblPackageType.SelectedValue == "1")
        {
            packageType = BusinessConstants.CODE_MASTER_PACKAGETYPE_OUTER;
        }
        #endregion
        if (this.ModuleType == BusinessConstants.CODE_MASTER_PARTY_TYPE_VALUE_SUPPLIER)
        {
            huList = TheHuMgr.CreateHu(targetOrderDetailList, this.CurrentUser, null, packageType);
        }
        else
        {
            EntityPreference entityPreference = this.TheEntityPreferenceMgr.LoadEntityPreference(BusinessConstants.ENTITY_PREFERENCE_CODE_COMPANY_ID_MARK);
            huList = TheHuMgr.CreateHu(targetOrderDetailList, this.CurrentUser, entityPreference.Value, packageType);
        }

        String huTemplate = "";
        if (this.ModuleType == BusinessConstants.CODE_MASTER_PARTY_TYPE_VALUE_REGION)
        {
            huTemplate = TheEntityPreferenceMgr.LoadEntityPreference(BusinessConstants.ENTITY_PREFERENCE_CODE_DEFAULT_HU_TEMPLATE).Value;
        }
        else if (targetOrderDetailList != null &&
                 targetOrderDetailList.Count > 0 &&
                 targetOrderDetailList[0].OrderHead != null &&
                 targetOrderDetailList[0].OrderHead.HuTemplate != null &&
                 targetOrderDetailList[0].OrderHead.HuTemplate.Length > 0)
        {
            huTemplate = targetOrderDetailList[0].OrderHead.HuTemplate;
        }

        if (huTemplate != null && huTemplate.Length > 0)
        {
            IList <object> huDetailObj = new List <object>();
            huDetailObj.Add(huList);
            huDetailObj.Add(CurrentUser.Code);

            string barCodeUrl = "";
            if (packageType == BusinessConstants.CODE_MASTER_PACKAGETYPE_OUTER)
            {
                barCodeUrl = TheReportMgr.WriteToFile(huTemplate, huDetailObj, huTemplate);
            }
            else
            {
                barCodeUrl = TheReportMgr.WriteToFile("Inside" + huTemplate, huDetailObj, "Inside" + huTemplate);
            }
            Page.ClientScript.RegisterStartupScript(GetType(), "method", " <script language='javascript' type='text/javascript'>PrintOrder('" + barCodeUrl + "'); </script>");

            this.ShowSuccessMessage("Inventory.PrintHu.Successful");
        }
    }
示例#20
0
 public virtual void UpdateEntityPreference(EntityPreference entity)
 {
     Update(entity);
 }
示例#21
0
        public void ReverseUpdateActingBill(BillDetail oldBillDetail, BillDetail newBillDetail, User user)
        {
            if (oldBillDetail != null && newBillDetail != null &&
                oldBillDetail.ActingBill.Id != newBillDetail.ActingBill.Id)
            {
                throw new TechnicalException("oldBillDetail.ActingBill.Id != newBillDetail.ActingBill.Id when ReverseUpdateActingBill");
            }

            DateTime dateTimeNow = DateTime.Now;

            #region 扣减旧BillDetail的数量和金额
            if (oldBillDetail != null)
            {
                //todo 校验数量、金额
                ActingBill actingBill = this.LoadActingBill(oldBillDetail.ActingBill.Id);
                actingBill.BilledQty     -= oldBillDetail.BilledQty;
                actingBill.BilledAmount  -= oldBillDetail.OrderAmount;
                actingBill.LastModifyDate = dateTimeNow;
                actingBill.LastModifyUser = user;
                if (actingBill.BillQty == actingBill.BilledQty)
                {
                    actingBill.Status = BusinessConstants.CODE_MASTER_STATUS_VALUE_CLOSE;
                }
                else
                {
                    actingBill.Status = BusinessConstants.CODE_MASTER_STATUS_VALUE_CREATE;
                }
                this.UpdateActingBill(actingBill);
            }
            #endregion

            #region 增加新BillDetail的数量和金额
            if (newBillDetail != null)
            {
                //todo 校验数量、金额
                ActingBill actingBill = this.LoadActingBill(newBillDetail.ActingBill.Id);

                #region 根据新开票数量计算开票金额
                EntityPreference entityPreference = this.entityPreferenceMgr.LoadEntityPreference(
                    BusinessConstants.ENTITY_PREFERENCE_CODE_AMOUNT_DECIMAL_LENGTH);
                int amountDecimalLength = int.Parse(entityPreference.Value);
                if (newBillDetail.BilledQty != (actingBill.BillQty - actingBill.BilledQty))
                {
                    //本次开票数量大于剩余数量
                    if ((actingBill.BillQty > 0 && actingBill.BillQty - actingBill.BilledQty - newBillDetail.BilledQty < 0) ||
                        (actingBill.BillQty < 0 && actingBill.BillQty - actingBill.BilledQty - newBillDetail.BilledQty > 0))
                    {
                        throw new BusinessErrorException("ActingBill.Error.CurrentBillQtyGeRemainQty");
                    }

                    //本次开票数量小于剩余数量
                    newBillDetail.OrderAmount = Math.Round((actingBill.BillAmount / actingBill.BillQty * newBillDetail.BilledQty), amountDecimalLength, MidpointRounding.AwayFromZero);
                }
                else
                {
                    //本次开票数量等于剩余数量
                    newBillDetail.OrderAmount = actingBill.BillAmount - actingBill.BilledAmount;
                }
                #endregion

                actingBill.BilledQty     += newBillDetail.BilledQty;
                actingBill.BilledAmount  += newBillDetail.OrderAmount;
                actingBill.LastModifyDate = dateTimeNow;
                actingBill.LastModifyUser = user;
                if (actingBill.BillQty == actingBill.BilledQty)
                {
                    actingBill.Status = BusinessConstants.CODE_MASTER_STATUS_VALUE_CLOSE;
                }
                else
                {
                    actingBill.Status = BusinessConstants.CODE_MASTER_STATUS_VALUE_CREATE;
                }
                this.UpdateActingBill(actingBill);
            }
            #endregion
        }
        public void RawMaterialBackflush(string prodLineCode, IDictionary <string, decimal> itemQtydic, User user)
        {
            if (itemQtydic == null || itemQtydic.Count == 0)
            {
                throw new BusinessErrorException("MasterData.Production.Feed.Error.NoSelectFeed");
            }

            Flow     flow        = this.flowMgr.CheckAndLoadFlow(prodLineCode);
            DateTime dateTimeNow = DateTime.Now;

            IList <ProductLineInProcessLocationDetail> productLineInProcessLocationDetailList =
                this.GetProductLineInProcessLocationDetail(prodLineCode, BusinessConstants.CODE_MASTER_STATUS_VALUE_CREATE, itemQtydic.Keys.ToArray <string>());

            IList <ProductLineInProcessLocationDetail> targetProductLineInProcessLocationDetailList = new List <ProductLineInProcessLocationDetail>();

            #region 根据剩余数量计算回冲零件数量,添加到待处理列表
            if (itemQtydic != null && itemQtydic.Count > 0)
            {
                foreach (string itemCode in itemQtydic.Keys)
                {
                    decimal remainQty = itemQtydic[itemCode]; //剩余投料量
                    decimal inQty     = 0;                    //总投料量
                    IList <ProductLineInProcessLocationDetail> currentProductLineInProcessLocationDetailList = new List <ProductLineInProcessLocationDetail>();
                    foreach (ProductLineInProcessLocationDetail productLineInProcessLocationDetail in productLineInProcessLocationDetailList)
                    {
                        if (productLineInProcessLocationDetail.Item.Code == itemCode)
                        {
                            inQty += (productLineInProcessLocationDetail.Qty - productLineInProcessLocationDetail.BackflushQty);
                            currentProductLineInProcessLocationDetailList.Add(productLineInProcessLocationDetail);
                        }
                    }

                    if (remainQty > inQty)
                    {
                        throw new BusinessErrorException("MasterData.Production.Feed.Error.RemainQtyGtFeedQty", itemCode);
                    }

                    decimal backflushQty = inQty - remainQty;  //本次回冲量

                    #region 设定本次回冲数量
                    if (backflushQty > 0)
                    {
                        foreach (ProductLineInProcessLocationDetail productLineInProcessLocationDetail in currentProductLineInProcessLocationDetailList)
                        {
                            if (backflushQty - (productLineInProcessLocationDetail.Qty - productLineInProcessLocationDetail.BackflushQty) > 0)
                            {
                                productLineInProcessLocationDetail.CurrentBackflushQty = productLineInProcessLocationDetail.Qty - productLineInProcessLocationDetail.BackflushQty;
                                backflushQty -= productLineInProcessLocationDetail.Qty - productLineInProcessLocationDetail.BackflushQty;
                                productLineInProcessLocationDetail.BackflushQty = productLineInProcessLocationDetail.Qty;
                                targetProductLineInProcessLocationDetailList.Add(productLineInProcessLocationDetail);
                            }
                            else
                            {
                                productLineInProcessLocationDetail.CurrentBackflushQty = backflushQty;
                                productLineInProcessLocationDetail.BackflushQty       += backflushQty;
                                backflushQty = 0;
                                targetProductLineInProcessLocationDetailList.Add(productLineInProcessLocationDetail);
                                break;
                            }
                        }
                    }
                    #endregion
                }
            }
            #endregion


            if (targetProductLineInProcessLocationDetailList != null && targetProductLineInProcessLocationDetailList.Count > 0)
            {
                #region 更新生产线上的物料
                foreach (ProductLineInProcessLocationDetail productLineInProcessLocationDetail in targetProductLineInProcessLocationDetailList)
                {
                    if (productLineInProcessLocationDetail.Qty == productLineInProcessLocationDetail.BackflushQty)
                    {
                        productLineInProcessLocationDetail.Status = BusinessConstants.CODE_MASTER_STATUS_VALUE_CLOSE;
                    }
                    productLineInProcessLocationDetail.LastModifyDate = dateTimeNow;
                    productLineInProcessLocationDetail.LastModifyUser = user;

                    this.UpdateProductLineInProcessLocationDetail(productLineInProcessLocationDetail);

                    //记录库存事务
                    //this.locationTransactionMgrE.RecordLocationTransaction(productLineInProcessLocationDetail, BusinessConstants.CODE_MASTER_LOCATION_TRANSACTION_TYPE_VALUE_ISS_TR, user, BusinessConstants.IO_TYPE_OUT);
                    //this.locationTransactionMgrE.RecordLocationTransaction(productLineInProcessLocationDetail, BusinessConstants.CODE_MASTER_LOCATION_TRANSACTION_TYPE_VALUE_RCT_TR, user, BusinessConstants.IO_TYPE_OUT);
                }
                #endregion
                IList <object[]> orderPlannedBackflushList = this.orderPlannedBackflushMgr.GetActiveOrderPlannedBackflush(prodLineCode);

                if (orderPlannedBackflushList == null || orderPlannedBackflushList.Count == 0)
                {
                    throw new BusinessErrorException("MasterData.Production.Feed.Error.NoWO", prodLineCode);
                }

                var productLineInProcessLocationDetailDic = from plIp in targetProductLineInProcessLocationDetailList
                                                            group plIp by new
                {
                    Item          = plIp.Item.Code,
                    Operation     = plIp.Operation,
                    HuId          = plIp.HuId,
                    LotNo         = plIp.LotNo,
                    LocationFrom  = plIp.LocationFrom,
                    IsConsignment = plIp.IsConsignment,
                    PlannedBill   = plIp.PlannedBill
                } into result
                    select new
                {
                    Item          = result.Key.Item,
                    Operation     = result.Key.Operation,
                    HuId          = result.Key.HuId,
                    LotNo         = result.Key.LotNo,
                    LocationFrom  = result.Key.LocationFrom,
                    IsConsignment = result.Key.IsConsignment,
                    PlannedBill   = result.Key.PlannedBill,
                    BackflushQty  = result.Sum(plIp => plIp.CurrentBackflushQty)
                };

                foreach (var productLineInProcessLocationDetail in productLineInProcessLocationDetailDic)
                {
                    var planList = orderPlannedBackflushList.Where(p => (string)p[3] == productLineInProcessLocationDetail.Item &&
                                                                   (!productLineInProcessLocationDetail.Operation.HasValue || productLineInProcessLocationDetail.Operation == (int?)p[1])).ToList();

                    var totalBaseQty = planList.Sum(p => (decimal)p[2]); //回冲分配基数

                    if (planList.Count > 0)
                    {
                        EntityPreference entityPreference = this.entityPreferenceMgr.LoadEntityPreference(BusinessConstants.ENTITY_PREFERENCE_CODE_AMOUNT_DECIMAL_LENGTH);
                        int amountDecimalLength           = int.Parse(entityPreference.Value);

                        decimal remainTobeBackflushQty = productLineInProcessLocationDetail.BackflushQty;         //剩余待回冲数量
                        decimal unitQty = Math.Round(remainTobeBackflushQty / totalBaseQty, amountDecimalLength); //单位基数的回冲数量

                        for (int i = 0; i < planList.Count; i++)
                        {
                            #region 物料回冲
                            #region 更新匹配的OrderLocationTransaction
                            OrderPlannedBackflush    matchedOrderPlannedBackflush    = orderPlannedBackflushMgr.LoadOrderPlannedBackflush((int)planList[i][0]);
                            OrderLocationTransaction matchedOrderLocationTransaction = matchedOrderPlannedBackflush.OrderLocationTransaction;
                            //InProcessLocation ip = inProcessLocationMgr.LoadInProcessLocation(matchedOrderPlannedBackflush.InProcessLocation);

                            bool    isLastestRecord          = (i == (planList.Count - 1));
                            decimal currentTotalBackflushQty = 0;

                            if (!matchedOrderLocationTransaction.AccumulateQty.HasValue)
                            {
                                matchedOrderLocationTransaction.AccumulateQty = 0;
                            }

                            if (!isLastestRecord)
                            {
                                decimal currentBackflushQty = matchedOrderPlannedBackflush.PlannedQty * unitQty;
                                currentTotalBackflushQty += currentBackflushQty;
                                matchedOrderLocationTransaction.AccumulateQty += currentBackflushQty;
                                remainTobeBackflushQty -= currentBackflushQty;
                            }
                            else
                            {
                                currentTotalBackflushQty += remainTobeBackflushQty;
                                matchedOrderLocationTransaction.AccumulateQty += remainTobeBackflushQty;
                                remainTobeBackflushQty = 0;
                            }

                            this.orderLocationTransactionMgr.UpdateOrderLocationTransaction(matchedOrderLocationTransaction);
                            #endregion

                            #region 新增/更新AsnDetail,暂时不更新了
                            //InProcessLocationDetail inProcessLocationDetail = null;

                            //if (productLineInProcessLocationDetail.HuId == null || productLineInProcessLocationDetail.HuId.Trim() == string.Empty)
                            //{
                            //    inProcessLocationDetail = this.inProcessLocationDetailMgr.GetNoneHuAndIsConsignmentInProcessLocationDetail(ip, matchedOrderPlannedBackflush.OrderLocationTransaction);
                            //    if (inProcessLocationDetail != null)
                            //    {
                            //        inProcessLocationDetail.Qty += currentTotalBackflushQty;

                            //        this.inProcessLocationDetailMgr.UpdateInProcessLocationDetail(inProcessLocationDetail);
                            //    }
                            //}

                            //if (inProcessLocationDetail == null)
                            //{
                            //    inProcessLocationDetail = new InProcessLocationDetail();
                            //    inProcessLocationDetail.InProcessLocation = ip;
                            //    inProcessLocationDetail.OrderLocationTransaction = matchedOrderPlannedBackflush.OrderLocationTransaction;
                            //    inProcessLocationDetail.HuId = productLineInProcessLocationDetail.HuId;
                            //    inProcessLocationDetail.LotNo = productLineInProcessLocationDetail.LotNo;
                            //    inProcessLocationDetail.IsConsignment = productLineInProcessLocationDetail.IsConsignment;
                            //    inProcessLocationDetail.PlannedBill = productLineInProcessLocationDetail.PlannedBill;
                            //    inProcessLocationDetail.Qty = currentTotalBackflushQty;

                            //    this.inProcessLocationDetailMgr.CreateInProcessLocationDetail(inProcessLocationDetail);

                            //    ip.AddInProcessLocationDetail(inProcessLocationDetail);
                            //}

                            #endregion

                            #region 新增库存事务
                            this.locationTransactionMgr.RecordWOBackflushLocationTransaction(
                                matchedOrderPlannedBackflush.OrderLocationTransaction, productLineInProcessLocationDetail.HuId,
                                productLineInProcessLocationDetail.LotNo, currentTotalBackflushQty,
                                matchedOrderPlannedBackflush.InProcessLocation, user, productLineInProcessLocationDetail.LocationFrom);
                            #endregion
                            #endregion

                            #region 关闭OrderPlannedBackflush
                            if (matchedOrderPlannedBackflush.IsActive)
                            {
                                matchedOrderPlannedBackflush.IsActive = false;
                                this.orderPlannedBackflushMgr.UpdateOrderPlannedBackflush(matchedOrderPlannedBackflush);
                            }
                            #endregion
                        }
                    }
                    else
                    {
                        #region 没有匹配的OrderLocationTransaction
                        //退回原库位
                        throw new BusinessErrorException("MasterData.BackFlush.NotFoundResources", productLineInProcessLocationDetail.Item);
                        //this.locationMgrE.InventoryIn(productLineInProcessLocationDetail, user);
                        #endregion
                    }
                }
            }
            else
            {
                throw new BusinessErrorException("MasterData.Production.Feed.Error.NoFeed", prodLineCode);
            }
        }
        public void ReverseUpdateTransportationActBill(TransportationBillDetail oldBillDetail, TransportationBillDetail newBillDetail, User user)
        {
            if (oldBillDetail != null && newBillDetail != null &&
                oldBillDetail.ActBill.Id != newBillDetail.ActBill.Id)
            {
                throw new TechnicalException("oldBillDetail.ActingBill.Id != newBillDetail.ActingBill.Id when ReverseUpdateActingBill");
            }

            DateTime dateTimeNow = DateTime.Now;

            #region 扣减旧TransportationBillDetail的数量和金额
            if (oldBillDetail != null)
            {
                //todo 校验数量、金额
                TransportationActBill transportationActBill = this.LoadTransportationActBill(oldBillDetail.ActBill.Id);

                /*
                 *
                 * 1.TransType=Transportation 价格单明细(承运商) 或  短拨费(区域)时
                 * a.PricingMethod=M3或KG  按数量
                 * b.SHIPT   按金额
                 * 2.TransType=WarehouseLease(固定费用) 按金额
                 * 3.TransType=Operation(操作费) 按数量
                 */
                if (transportationActBill.TransType == BusinessConstants.TRANSPORTATION_PRICELIST_DETAIL_TYPE_OPERATION
                    ||
                    (transportationActBill.TransType == BusinessConstants.TRANSPORTATION_PRICELIST_DETAIL_TYPE_TRANSPORTATION &&
                     (transportationActBill.PricingMethod == BusinessConstants.TRANSPORTATION_PRICING_METHOD_M3 || transportationActBill.PricingMethod == BusinessConstants.TRANSPORTATION_PRICING_METHOD_KG)
                    )
                    )
                {
                    transportationActBill.BilledQty    -= oldBillDetail.BilledQty;
                    transportationActBill.BilledAmount -= oldBillDetail.Amount;
                    if (transportationActBill.BillQty == transportationActBill.BilledQty)
                    {
                        transportationActBill.Status = BusinessConstants.CODE_MASTER_STATUS_VALUE_CLOSE;
                    }
                    else
                    {
                        transportationActBill.Status = BusinessConstants.CODE_MASTER_STATUS_VALUE_CREATE;
                    }
                }
                else
                {
                    transportationActBill.BilledAmount -= oldBillDetail.Amount;

                    if (transportationActBill.BilledAmount == 0)
                    {
                        transportationActBill.BilledQty = 0;
                    }

                    if (transportationActBill.BillAmount == transportationActBill.BilledAmount)
                    {
                        transportationActBill.Status = BusinessConstants.CODE_MASTER_STATUS_VALUE_CLOSE;
                    }
                    else
                    {
                        transportationActBill.Status = BusinessConstants.CODE_MASTER_STATUS_VALUE_CREATE;
                    }
                }

                transportationActBill.LastModifyDate = dateTimeNow;
                transportationActBill.LastModifyUser = user;

                this.UpdateTransportationActBill(transportationActBill);
            }
            #endregion

            #region 增加新BillDetail的数量和金额
            if (newBillDetail != null)
            {
                //todo 校验数量、金额
                TransportationActBill transportationActBill = this.LoadTransportationActBill(newBillDetail.ActBill.Id);

                EntityPreference entityPreference = this.entityPreferenceMgr.LoadEntityPreference(
                    BusinessConstants.ENTITY_PREFERENCE_CODE_AMOUNT_DECIMAL_LENGTH);
                int amountDecimalLength = int.Parse(entityPreference.Value);

                /*
                 *
                 * 1.TransType=Transportation 价格单明细(承运商) 或  短拨费(区域)时
                 * a.PricingMethod=M3或KG  按数量
                 * b.SHIPT   按金额
                 * 2.TransType=WarehouseLease(固定费用) 按金额
                 * 3.TransType=Operation(操作费) 按数量
                 */
                if (transportationActBill.TransType == BusinessConstants.TRANSPORTATION_PRICELIST_DETAIL_TYPE_OPERATION
                    ||
                    (transportationActBill.TransType == BusinessConstants.TRANSPORTATION_PRICELIST_DETAIL_TYPE_TRANSPORTATION &&
                     (transportationActBill.PricingMethod == BusinessConstants.TRANSPORTATION_PRICING_METHOD_M3 || transportationActBill.PricingMethod == BusinessConstants.TRANSPORTATION_PRICING_METHOD_KG)
                    )
                    )
                {
                    #region 根据新开票数量计算开票金额
                    if (newBillDetail.BilledQty != (transportationActBill.BillQty - transportationActBill.BilledQty))
                    {
                        //本次开票数量大于剩余数量
                        if ((transportationActBill.BillQty > 0 &&
                             transportationActBill.BillQty - transportationActBill.BilledQty - newBillDetail.BilledQty <
                             0)
                            ||
                            (transportationActBill.BillQty < 0 &&
                             transportationActBill.BillQty - transportationActBill.BilledQty - newBillDetail.BilledQty >
                             0))
                        {
                            throw new BusinessErrorException("TransportationActBill.Error.CurrentBillQtyGeRemainQty");
                        }

                        //本次开票数量小于剩余数量
                        newBillDetail.Amount =
                            Math.Round(
                                (transportationActBill.BillAmount / transportationActBill.BillQty * newBillDetail.BilledQty),
                                amountDecimalLength, MidpointRounding.AwayFromZero);
                    }
                    else
                    {
                        //本次开票数量等于剩余数量
                        newBillDetail.Amount = transportationActBill.BillAmount - transportationActBill.BilledAmount;
                    }
                    #endregion

                    transportationActBill.BilledQty    += newBillDetail.BilledQty;
                    transportationActBill.BilledAmount += newBillDetail.Amount;
                    if (transportationActBill.BillQty == transportationActBill.BilledQty)
                    {
                        transportationActBill.Status = BusinessConstants.CODE_MASTER_STATUS_VALUE_CLOSE;
                    }
                    else
                    {
                        transportationActBill.Status = BusinessConstants.CODE_MASTER_STATUS_VALUE_CREATE;
                    }
                }
                else
                {
                    if (newBillDetail.Amount != (transportationActBill.BillAmount - transportationActBill.BilledAmount))
                    {
                        //本次开票金额大于剩余金额
                        if ((transportationActBill.BillAmount > 0 &&
                             transportationActBill.BillAmount - transportationActBill.BilledAmount - newBillDetail.Amount <
                             0)
                            ||
                            (transportationActBill.BillAmount < 0 &&
                             transportationActBill.BillAmount - transportationActBill.BilledAmount - newBillDetail.Amount >
                             0))
                        {
                            throw new BusinessErrorException("TransportationActBill.Error.CurrentBillAmountGeRemainAmount");
                        }
                    }
                    else
                    {
                        //本次开票金额等于剩余金额
                        newBillDetail.Amount = transportationActBill.BillAmount - transportationActBill.BilledAmount;
                    }

                    transportationActBill.BilledQty     = 1;
                    transportationActBill.BilledAmount += newBillDetail.Amount;
                    if (transportationActBill.BillAmount == transportationActBill.BilledAmount)
                    {
                        transportationActBill.Status = BusinessConstants.CODE_MASTER_STATUS_VALUE_CLOSE;
                    }
                    else
                    {
                        transportationActBill.Status = BusinessConstants.CODE_MASTER_STATUS_VALUE_CREATE;
                    }
                }

                transportationActBill.LastModifyDate = dateTimeNow;
                transportationActBill.LastModifyUser = user;
                this.UpdateTransportationActBill(transportationActBill);
            }
            #endregion
        }
 public virtual void UpdateEntityPreference(EntityPreference entity)
 {
     entityDao.UpdateEntityPreference(entity);
 }
示例#25
0
 public virtual void CreateEntityPreference(EntityPreference entity)
 {
     Create(entity);
 }
示例#26
0
        public void RecordOrderShipQty(OrderLocationTransaction orderLocationTransaction, InProcessLocationDetail inProcessLocationDetail, bool checkExcceed)
        {
            //orderLocationTransaction = this.orderLocationTransactionMgr.LoadOrderLocationTransaction(orderLocationTransaction.Id);
            EntityPreference entityPreference = this.entityPreferenceMgr.LoadEntityPreference(BusinessConstants.ENTITY_PREFERENCE_CODE_ALLOW_EXCEED_GI_GR);
            bool             allowExceedGiGR  = bool.Parse(entityPreference.Value); //企业属性,允许过量发货和收货

            OrderDetail orderDetail = orderLocationTransaction.OrderDetail;
            OrderHead   orderHead   = orderDetail.OrderHead;
            decimal     shipQty     = inProcessLocationDetail.Qty * orderLocationTransaction.UnitQty;

            #region 是否过量发货判断
            //生产物料发货不检查过量选项
            if (orderLocationTransaction.OrderDetail.OrderHead.Type != BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_PRODUCTION &&
                orderLocationTransaction.OrderDetail.OrderHead.SubType != BusinessConstants.CODE_MASTER_ORDER_SUB_TYPE_VALUE_ADJ)
            {
                //检查AccumulateQty(已发数)不能大于等于OrderedQty(订单数)
                //if (!(orderHead.AllowExceed && allowExceedGiGR))
                //{
                //    if ((orderLocationTransaction.OrderedQty > 0 && orderLocationTransaction.AccumulateQty.HasValue && orderLocationTransaction.AccumulateQty.Value >= orderLocationTransaction.OrderedQty && shipQty > 0)
                //            || (orderLocationTransaction.OrderedQty < 0 && orderLocationTransaction.AccumulateQty.HasValue && orderLocationTransaction.AccumulateQty.Value <= orderLocationTransaction.OrderedQty && shipQty < 0))
                //    {
                //        throw new BusinessErrorException("Order.Error.ShipExcceed", orderHead.OrderNo, orderLocationTransaction.Item.Code);
                //    }
                //}

                if (!(orderHead.AllowExceed && allowExceedGiGR) && checkExcceed)   //不允许过量发货
                {
                    //检查AccumulateQty(已发数) + shipQty(本次发货数)不能大于OrderedQty(订单数)
                    orderLocationTransaction.AccumulateQty = orderLocationTransaction.AccumulateQty.HasValue ? orderLocationTransaction.AccumulateQty.Value : 0;
                    if ((orderLocationTransaction.OrderedQty > 0 && (orderLocationTransaction.AccumulateQty + shipQty > orderLocationTransaction.OrderedQty)) ||
                        (orderLocationTransaction.OrderedQty < 0 && (orderLocationTransaction.AccumulateQty + shipQty < orderLocationTransaction.OrderedQty)))
                    {
                        throw new BusinessErrorException("Order.Error.ShipExcceed", orderHead.OrderNo, orderLocationTransaction.Item.Code);
                    }
                }
            }
            #endregion

            #region 记录发货量
            if (orderLocationTransaction.BackFlushMethod == null ||
                orderLocationTransaction.BackFlushMethod == BusinessConstants.CODE_MASTER_BACKFLUSH_METHOD_VALUE_GOODS_RECEIVE)
            {
                if (!orderLocationTransaction.AccumulateQty.HasValue)
                {
                    orderLocationTransaction.AccumulateQty = 0;
                }
                //记录LocationTransaction的累计发货量
                orderLocationTransaction.AccumulateQty += shipQty;
                this.orderLocationTransactionMgr.UpdateOrderLocationTransaction(orderLocationTransaction);

                //记录OrderDetail的累计发货量
                if (orderLocationTransaction.Item.Code == orderLocationTransaction.OrderDetail.Item.Code)
                {
                    //如果OrderLocationTransaction和OrderDetail上的Item一致,需要更新OrderDetail上的ShippedQty
                    if (!orderDetail.ShippedQty.HasValue)
                    {
                        orderDetail.ShippedQty = 0;
                    }

                    //OrderLocationTransaction和OrderDetail上的Item可能单位不一致,直接除以UnitQty就可以转换了
                    orderDetail.ShippedQty += (shipQty / orderLocationTransaction.UnitQty);
                    this.UpdateOrderDetail(orderDetail);
                }
            }
            #endregion
        }
示例#27
0
 public virtual void DeleteEntityPreference(EntityPreference entity)
 {
     Delete(entity);
 }
示例#28
0
        public IList <MaterialFlushBack> AssignMaterialFlushBack(MaterialFlushBack sourceMaterialFlushBack, IList <OrderLocationTransaction> inOrderLocationTransactionList)
        {
            Hu hu = null;

            if (sourceMaterialFlushBack.HuId != null && sourceMaterialFlushBack.HuId.Trim() != string.Empty)
            {
                hu = this.huMgr.CheckAndLoadHu(sourceMaterialFlushBack.HuId);
            }

            IList <MaterialFlushBack> materialFlushBackList = new List <MaterialFlushBack>();
            decimal theoryTotalQty = 0;  //理论消耗量

            if (inOrderLocationTransactionList != null && inOrderLocationTransactionList.Count > 0)
            {
                foreach (OrderLocationTransaction inOrderLocationTransaction in inOrderLocationTransactionList)
                {
                    IList <OrderLocationTransaction> orderLocationTransactionList = this.orderLocationTransactionMgr.GetOrderLocationTransaction(inOrderLocationTransaction.OrderDetail.Id, BusinessConstants.IO_TYPE_OUT);
                    if (orderLocationTransactionList != null && orderLocationTransactionList.Count > 0)
                    {
                        foreach (OrderLocationTransaction orderLocationTransaction in orderLocationTransactionList)
                        {
                            if (orderLocationTransaction.Item.Code == sourceMaterialFlushBack.RawMaterial.Code)
                            {
                                if (sourceMaterialFlushBack.Operation == 0 ||
                                    orderLocationTransaction.Operation == sourceMaterialFlushBack.Operation)
                                {
                                    if ((hu == null) ||                                                                                                                //按数量分配
                                        (hu != null && (hu.Version == null || hu.Version.Trim() == string.Empty)) || //按条码分配
                                        (hu != null && hu.Version != null && hu.Version.Trim() != string.Empty && hu.Version == orderLocationTransaction.ItemVersion)) //按条码和工程状态分配
                                    {
                                        MaterialFlushBack materialFlushBack = new MaterialFlushBack();
                                        materialFlushBack.OrderDetail = inOrderLocationTransaction.OrderDetail;
                                        materialFlushBack.OrderLocationTransaction = orderLocationTransaction;
                                        materialFlushBack.Operation   = orderLocationTransaction.Operation;
                                        materialFlushBack.RawMaterial = orderLocationTransaction.Item;
                                        materialFlushBack.Uom         = orderLocationTransaction.OrderDetail.Uom;
                                        materialFlushBack.HuId        = sourceMaterialFlushBack.HuId;
                                        if (inOrderLocationTransaction.OrderDetail.OrderHead.Type != BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_PRODUCTION)
                                        {
                                            materialFlushBack.Qty = inOrderLocationTransaction.CurrentReceiveQty * orderLocationTransaction.UnitQty;
                                        }
                                        else
                                        {
                                            //生产,废品和次品都消耗原材料
                                            materialFlushBack.Qty =
                                                (inOrderLocationTransaction.CurrentReceiveQty + inOrderLocationTransaction.CurrentRejectQty + inOrderLocationTransaction.CurrentScrapQty)
                                                * orderLocationTransaction.UnitQty;
                                        }
                                        theoryTotalQty += materialFlushBack.Qty;

                                        materialFlushBackList.Add(materialFlushBack);
                                    }
                                }
                            }
                        }
                    }
                }
            }

            int FlushBackListCount = materialFlushBackList.Count;

            if (FlushBackListCount == 0)
            {
                throw new BusinessErrorException("Order.Error.ReceiveOrder.AssignMaterial", sourceMaterialFlushBack.RawMaterial.Code);
            }

            EntityPreference entityPreference = entityPreferenceMgr.LoadEntityPreference(BusinessConstants.ENTITY_PREFERENCE_CODE_AMOUNT_DECIMAL_LENGTH);
            int decimalLength = int.Parse(entityPreference.Value);

            decimal remainFlushBack = sourceMaterialFlushBack.Qty;

            for (int i = 0; i < FlushBackListCount; i++)
            {
                //分配的消耗量等于实际的总消耗量 / 理论总消耗量 * 单个物料的消耗量,最后一条用减法处理
                if (i < FlushBackListCount - 1)
                {
                    materialFlushBackList[i].Qty = Math.Round(sourceMaterialFlushBack.Qty / theoryTotalQty * materialFlushBackList[i].Qty, decimalLength, MidpointRounding.AwayFromZero);;
                    remainFlushBack = remainFlushBack - materialFlushBackList[i].Qty;
                }
                else
                {
                    materialFlushBackList[i].Qty = remainFlushBack;
                }
            }
            //foreach(MaterialFlushBack materialFlushBack in materialFlushBackList)
            //{



            //    materialFlushBack.Qty = sourceMaterialFlushBack.Qty / theoryTotalQty * materialFlushBack.Qty;
            //}

            return(materialFlushBackList);
        }