分类 U9 下的文章

{callout color="#ef4d4d"}
由于无法指定组织只能采取登录组织方式
{/callout}
dll名:AutoGenerateConfirmBillBPProxy
dll位置:C:\yonyou\U9V60\Portal\ApplicationServer\Libs\UFIDA.U9.AP.APBP.Agent.dll

            AutoGenerateConfirmBillBPProxy proxy = new AutoGenerateConfirmBillBPProxy();
            PayReqFundDocType payReqFundDocType = PayReqFundDocType.Finder.Find(string.Format("code = '{0}'","001"));
            PayReqFundDocType payReqFundDocType1 = PayReqFundDocType.Finder.Find(string.Format("code = '{0}'","002"));
            Entity.EntityList<PayReqFundHead> entityList = PayReqFundHead.Finder.FindAll(
                string.Format("DocStatus = 2 and DocumentType != '{1}' and DocumentType!= '{2}' and Org = {0}",
                    Context.LoginOrg.ID,payReqFundDocType.ID,payReqFundDocType1.ID));
            //string.Format("DocStatus = 1 and Org.Code = '10' and DocNo = '10-0012412200007'"));
            try {
                foreach (PayReqFundHead payReqFundHead in entityList) {
                    proxy.PayReqHeadKey = payReqFundHead.ID;
                    if (!string.IsNullOrEmpty(payReqFundHead.PayReqFundUses[0].OppAccBkAccount)) {
                        BankAccount bankAccount =
                            BankAccount.FindByCode(payReqFundHead.PayReqFundUses[0].OppAccBkAccount);
                        if (bankAccount != null) {
                            proxy.BankAccount = bankAccount.ID;
                        }
                        //proxy.SubBankAccount = bankAccount.PayBkSubAccount;
                    }
                    else {
                        logger.LogInfo("创建请款确认单失败:付款银行账户为空 : 单号:" + payReqFundHead.DocNo + "组织:"
                                       + payReqFundHead.Org.Code);
                        continue;
                    }

                    // CashAccount cashAccount =
                    //     CashAccount.Finder.Find(string.Format("code = '{0}'", "01090699000120109050014"));
                    // proxy.CashAccount = 0;
                    proxy.IsUnApprove = true;
                    proxy.IsCanInputInfo = false;
                    proxy.PayDate = payReqFundHead.ExpectPayDate;
                    AccountPeriod accountPeriod = AccountPeriod.Finder.Find(string.Format(
                        "Year = '{0}' and Month = '{1}'", DateTime.Now.Year, DateTime.Now.Month));
                    // 会计记账期间
                    proxy.PostPeriod = accountPeriod.ID;
                    proxy.PayCurrency = payReqFundHead.ReqFundAC.ID;
                    proxy.ERType = payReqFundHead.ERType.Value;
                    proxy.ExRate = payReqFundHead.PCToMCXR;
                    if (payReqFundHead.PayReqFundUses != null && payReqFundHead.PayReqFundUses.Count > 0 &&
                        payReqFundHead.PayReqFundUses[0].SttlMethod != null) {
                        proxy.SettlementMethod = payReqFundHead.PayReqFundUses[0].SttlMethod.ID;
                    }

                    proxy.Currency = payReqFundHead.ReqFundAC.ID;
                    //proxy.CashAccount = cashAccount.ID;
                    //proxy.BankReturnDate = payReqFundHead.PayReqFundUses[0].TradeDate;
                    //proxy.NoteNo = payReqFundHead.PayReqFundUses[0].NoteNo;
                    proxy.IsMerge = true;
                    proxy.ConfirmDate = DateTime.Now;
                    // if (payReqFundHead.PayReqFundUses[0].RFCashierCfmDate != null)
                    // {
                    //     proxy.ConfirmDate = payReqFundHead.PayReqFundUses[0].RFCashierCfmDate;
                    // }
                    // else
                    // {
                    //     proxy.ConfirmDate = DateTime.Now;
                    // }

                    proxy.PayReqHeadList = new List<long> {
                        payReqFundHead.ID
                    };
                    proxy.Do();
                }
            }
            catch (Exception e) {
                logger.LogError("创建请款确认单BP报错:\t\n" + e);
                throw new ApplicationException(e.Message);
            }


DLL:UFIDA.U9.ISV.Supplier.Agent.dll
DLL位置: C:\yonyou\U9V60\Portal\ApplicationServer\Libs\UFIDA.U9.ISV.Supplier.Agent.dll

            List<ISV.Supplier.SupplierDTOData> supplierDTOList = new List<ISV.Supplier.SupplierDTOData>();
            ISV.Supplier.SupplierDTOData supplierInfo = new ISV.Supplier.SupplierDTOData();
            supplierInfo.Code = model.data.supplier_no; //供应商编号
            supplierInfo.Name = model.data.enterprise_name; //供应商名称
            supplierInfo.Org =
                new CommonArchiveDataDTOData(Context.LoginOrg.ID, Context.LoginOrg.Code, Context.LoginOrg.Name);
            //supplierInfo.ContactObject = new CBO.Pub.Controller.CommonArchiveDataDTOData();
            //supplierInfo.ContactObject.Code = "";
            supplierInfo.DescFlexField = new DescFlexSegmentsData();
            supplierInfo.DescFlexField.PrivateDescSeg1 = model.data.contacts; //联系人
            supplierInfo.DescFlexField.PrivateDescSeg3 = model.data.phone_number; //移动电话
            supplierInfo.DescFlexField.PrivateDescSeg4 = model.data.enterprise_fax; //传真
            supplierInfo.DescFlexField.PrivateDescSeg6 = model.data.email_address; //邮件地址
            supplierInfo.DescFlexField.PrivateDescSeg7 = model.data.bank_name; //银行开户行
            supplierInfo.DescFlexField.PrivateDescSeg8 = model.data.bank_account; //银行汇款账号

            //状态是否生效
            supplierInfo.Effective = new EffectiveData();
            supplierInfo.Effective.IsEffective = true;
            supplierInfo.Effective.EffectiveDate = Convert.ToDateTime("2000-01-01");
            supplierInfo.Effective.DisableDate = Convert.ToDateTime("9999-12-31");

            supplierInfo.IsPriceListModify = true; //价目表可改
            supplierInfo.IsReceiptRuleEditable = true; // 收货原则可改
            supplierInfo.IsPaymentTermModify = true; // 付款条件可改
            supplierInfo.IsAPConfirmTermEditable = true; //立账条件可改

            // 收货原则
            RcvBy receiptRule = RcvBy.FindByCode("G1");
            if (receiptRule != null) {
                supplierInfo.ReceiptRule =
                    new CommonArchiveDataDTOData(receiptRule.ID, receiptRule.Code, receiptRule.Name);
            }

            //供应商分类、税组合、立账条件、付款条件要效验编码  lirh  2025-02-17
            if (!string.IsNullOrEmpty(model.data.supplier_classify_number)) {
                SupplierCategory suppcate = SupplierCategory.Finder.Find(string.Format(
                    "Org.ID='{0}' and Code='{1}'", Context.LoginOrg.ID.ToString(),
                    model.data.supplier_classify_number));
                if (suppcate != null) {
                    supplierInfo.Category = new CommonArchiveDataDTOData();
                    supplierInfo.Category.ID = suppcate.ID;
                    supplierInfo.Category.Code = suppcate.Code;
                    supplierInfo.Category.Name = suppcate.Name;
                }
                else {
                    throw new ApplicationException(string.Format("供应商分类编码:{0}在U9 系统不存在,请检查",
                        model.data.supplier_classify_number));
                }
            }

            if (!string.IsNullOrEmpty(model.data.tax_code)) {
                int index = model.data.tax_code.IndexOf('-');
                string result = index >= 0 ? model.data.tax_code.Substring(0, index) : model.data.tax_code;
                TaxSchedule tax = TaxSchedule.Finder.Find(string.Format("Code='{0}'", result));
                if (tax != null) {
                    supplierInfo.TaxSchedule = new CommonArchiveDataDTOData();
                    supplierInfo.TaxSchedule.ID = tax.ID;
                    supplierInfo.TaxSchedule.Code = tax.Code;
                    supplierInfo.TaxSchedule.Name = tax.Name;
                }
                else {
                    throw new ApplicationException(string.Format("税组合编码:{0}在U9 系统不存在,请检查", result));
                }
            }

            if (!string.IsNullOrEmpty(model.data.accounting_code)) {
                APAccrueTerm apterm = APAccrueTerm.Finder.Find(string.Format("Code='{0}' and Org.ID='{1}'",
                    model.data.accounting_code, Context.LoginOrg.ID.ToString()));
                if (apterm != null) {
                    supplierInfo.APConfirmTerm = new CommonArchiveDataDTOData();
                    supplierInfo.APConfirmTerm.ID = apterm.ID;
                    supplierInfo.APConfirmTerm.Code = apterm.Code;
                    supplierInfo.APConfirmTerm.Name = apterm.Name;
                }
                else {
                    throw new ApplicationException(string.Format("立账条件编码:{0}在U9 系统不存在,请检查",
                        model.data.accounting_code));
                }
            }

            if (!string.IsNullOrEmpty(model.data.pay_term)) {
                PayTerm parterm = PayTerm.Finder.Find(string.Format("Name='{0}' and Org.ID='{1}'",
                    model.data.pay_term, Context.LoginOrg.ID.ToString()));
                if (parterm != null) {
                    supplierInfo.PaymentTerm = new CommonArchiveDataDTOData();
                    supplierInfo.PaymentTerm.ID = parterm.ID;
                    supplierInfo.PaymentTerm.Code = parterm.Code;
                    supplierInfo.PaymentTerm.Name = parterm.Name;
                }
                else {
                    throw new ApplicationException(string.Format("付款条件编码:{0}在U9 系统不存在,请检查", model.data.pay_term));
                }
            }

            //(分类\付款条件\税组合\立账条件\)交易币种、固话、供应商地址、国税号、经营范围、简称未传值  lirh  2025-02-17
            //币种
            if (!string.IsNullOrEmpty(model.data.currency_type)) {
                Currency curry = Currency.Finder.Find(string.Format("Code='{0}'", model.data.currency_type));
                if (curry != null) {
                    supplierInfo.TradeCurrency = new CommonArchiveDataDTOData();
                    supplierInfo.TradeCurrency.ID = curry.ID;
                    supplierInfo.TradeCurrency.Code = curry.Code;
                    supplierInfo.TradeCurrency.Name = curry.Name;
                }
                else {
                    throw new ApplicationException(string.Format("交易币种编码:{0}在U9 系统不存在,请检查",
                        model.data.currency_type));
                }
            }

            //固话
            supplierInfo.DescFlexField.PrivateDescSeg2 = model.data.enterprise_tel; //
            //供应商地址
            supplierInfo.DescFlexField.PrivateDescSeg9 = model.data.address; //
            //国税号
            supplierInfo.StateTaxNo = model.data.credit_code;
            //经营范围
            supplierInfo.DescFlexField.PrivateDescSeg11 = model.data.enterprise_profiles; //
            //简称
            supplierInfo.ShortName = model.data.shorter_name;
            //成立日期

            supplierDTOList.Add(supplierInfo);
            BatchCreateSupplierByDTOSVProxy proxy = new BatchCreateSupplierByDTOSVProxy();
            proxy.SupplierDTOs = supplierDTOList;
            List<SupplierData> listResult = proxy.Do();

使用session修改
销售退货修改数量

private WMSResultDataDTOData ProcessReceivement(string docNo, RTNHeadData rtnHeadData) {
    var resultData = new WMSResultDataDTOData();
    Receivement receivement =
        Receivement.Finder.Find(string.Format("DocNo = '{0}' and Org = {1}", docNo, Context.LoginOrg.ID));
    if (receivement == null)
        throw new Exception("找不到销售退回收货单据,DocNo=" + docNo);
    foreach (RTNLineData rtnLineData in rtnHeadData.SoRcvLineList) {
        int docLineNo = int.Parse(rtnLineData.DocLineNo);
        decimal newQty = decimal.Parse(rtnLineData.Qty);
        using (Session session = Session.Open()) {
            for (var i = 0; i < receivement.RcvLines.Count; i++) {
                if (receivement.RcvLines[i].DocLineNo == docLineNo) {
                    _logger.LogInfo(string.Format("[退货处理] - 更新到货数量:DocNo={0}, LineNo={1}, 原数量={2}, 新数量={3}",
                        docNo, docLineNo, receivement.RcvLines[i].ArriveQtyTU, newQty));
                    //数量为0则删除该行
                    if (newQty == decimal.Zero) {
                        receivement.RcvLines.RemoveAt(i);
                        continue;
                    }

                    #region 我自己的

                    receivement.RcvLines[i].ArriveQtyTU = receivement.RcvLines[i].EyeballingQtyTU =
                        receivement.RcvLines[i].RcvQtyTU = Math.Round(Convert.ToDecimal(newQty), 4);
                    receivement.RcvLines[i].ArriveQtyPU = receivement.RcvLines[i].EyeballingQtyPU =
                        receivement.RcvLines[i].RcvQtyPU = Math.Round(Convert.ToDecimal(newQty), 4);
                    receivement.RcvLines[i].ArriveQtySU = receivement.RcvLines[i].EyeballingQtySU =
                        receivement.RcvLines[i].RcvQtySU = Math.Round(Convert.ToDecimal(newQty), 4);
                    receivement.RcvLines[i].ArriveQtyCU = receivement.RcvLines[i].EyeballingQtyCU =
                        receivement.RcvLines[i].RcvQtyCU = Math.Round(Convert.ToDecimal(newQty), 4);
                    receivement.RcvLines[i].ArriveQtyTBU = receivement.RcvLines[i].EyeballingQtyTBU =
                        receivement.RcvLines[i].RcvQtyTBU = 0;


                    //拒收数量
                    receivement.RcvLines[i].RejectQtyTU = Decimal.Zero;
                    receivement.RcvLines[i].RejectQtyTBU = Decimal.Zero;
                    receivement.RcvLines[i].RejectQtySU = Decimal.Zero;
                    receivement.RcvLines[i].RejectQtyPU = Decimal.Zero;
                    receivement.RcvLines[i].RejectQtyCU = Decimal.Zero;
                    //可立账数量
                    receivement.RcvLines[i].CanAPConfirmQtyTU = Math.Round(Convert.ToDecimal(newQty), 4);
                    receivement.RcvLines[i].CanAPConfirmQtyPU = Math.Round(Convert.ToDecimal(newQty), 4);
                    receivement.RcvLines[i].CanAPConfirmQtyCU = Math.Round(Convert.ToDecimal(newQty), 4);
                    receivement.RcvLines[i].CanAPConfirmQtySU = Math.Round(Convert.ToDecimal(newQty), 4);
                    receivement.RcvLines[i].CanAPConfirmQtyTBU = 0;
                    //退补数量
                    receivement.RcvLines[i].RtnFillQtySU = Decimal.Zero;
                    receivement.RcvLines[i].RtnFillQtyTBU = Decimal.Zero;
                    receivement.RcvLines[i].RtnFillQtyTU = Decimal.Zero;
                    receivement.RcvLines[i].RtnFillQtyPU = Decimal.Zero;
                    receivement.RcvLines[i].RtnFillQtyCU = Decimal.Zero;
                    //拒收价税合计
                    receivement.RcvLines[i].RejectMnyAC = Decimal.Zero;
                    receivement.RcvLines[i].RejectMnyFC = Decimal.Zero;
                    receivement.RcvLines[i].RejectMnyTC = Decimal.Zero;
                    //拒收未税金额
                    receivement.RcvLines[i].RejectNetMnyAC = Decimal.Zero;
                    receivement.RcvLines[i].RejectNetMnyTC = Decimal.Zero;
                    receivement.RcvLines[i].RejectNetMnyFC = Decimal.Zero;
                    //拒收税额
                    receivement.RcvLines[i].RejectTaxMnyAC = Decimal.Zero;
                    receivement.RcvLines[i].RejectTaxMnyTC = Decimal.Zero;
                    receivement.RcvLines[i].RejectTaxMnyFC = Decimal.Zero;

                    if (receivement.RcvLines[i].IsPriceIncludeTax == true) {
                        //未税金额 = 含税单价 × 数量 ÷(1 + 税率)
                        receivement.RcvLines[i].ArriveTotalNetMnyTC = Math.Round(
                            receivement.RcvLines[i].FinallyPriceTC * Convert.ToDecimal(newQty) /
                            (1 + receivement.RcvLines[i].TaxRate), 2);
                        //Math.Round(Convert.ToDecimal(arrqty) * receivement.RcvLines[i].FinallyPriceTC / (decimal.Parse(receivement.RcvLines[i].TaxRate.ToString())), 2);//实到未税额 
                        receivement.RcvLines[i].ArriveTotalNetMnyAC =
                            receivement.RcvLines[i].ArriveTotalNetMnyTC; //实到未税额 
                        receivement.RcvLines[i].ArriveTotalNetMnyFC =
                            receivement.RcvLines[i].ArriveTotalNetMnyTC; //实到未税额 
                        //
                        receivement.RcvLines[i].ArriveTotalTaxFC = Math.Round(
                            receivement.RcvLines[i].ArriveTotalNetMnyTC * receivement.RcvLines[i].TaxRate, 2);
                        //Math.Round(Convert.ToDecimal(arrqty) * receivement.RcvLines[i].FinallyPriceTC / (decimal.Parse(receivement.RcvLines[i].TaxRate.ToString())) * (decimal.Parse(receivement.RcvLines[i].TaxRate.ToString())), 2);//实到税额 
                        receivement.RcvLines[i].ArriveTotalTaxTC =
                            receivement.RcvLines[i].ArriveTotalTaxFC; //实到税额 
                        receivement.RcvLines[i].ArriveTotalTaxAC =
                            receivement.RcvLines[i].ArriveTotalTaxFC; //实到税额 

                        receivement.RcvLines[i].ArriveTotalMnyTC = receivement.RcvLines[i].ArriveTotalNetMnyTC +
                                                                   receivement.RcvLines[i]
                                                                       .ArriveTotalTaxFC; //实到价税合计 
                        receivement.RcvLines[i].ArriveTotalMnyAC =
                            receivement.RcvLines[i].ArriveTotalMnyTC; //实到价税合计 
                        receivement.RcvLines[i].ArriveTotalMnyFC =
                            receivement.RcvLines[i].ArriveTotalMnyTC; //实到价税合计 


                        //实收未税额
                        receivement.RcvLines[i].TotalNetMnyTC = Math.Round(
                            receivement.RcvLines[i].FinallyPriceTC * Convert.ToDecimal(newQty) /
                            (1 + receivement.RcvLines[i].TaxRate), 2);
                        receivement.RcvLines[i].TotalNetMnyAC = receivement.RcvLines[i].TotalNetMnyTC;
                        receivement.RcvLines[i].TotalNetMnyFC = receivement.RcvLines[i].TotalNetMnyTC;

                        //实收税额
                        receivement.RcvLines[i].TotalTaxFC = Math.Round(
                            (receivement.RcvLines[i].TotalNetMnyTC * receivement.RcvLines[i].TaxRate), 2);
                        receivement.RcvLines[i].TotalTaxAC = receivement.RcvLines[i].TotalTaxFC;
                        receivement.RcvLines[i].TotalTaxTC = receivement.RcvLines[i].TotalTaxFC;
                        //实收价税合计
                        receivement.RcvLines[i].TotalMnyTC = receivement.RcvLines[i].ArriveTotalNetMnyTC +
                                                             receivement.RcvLines[i].ArriveTotalTaxFC; //实到价税合计 
                        receivement.RcvLines[i].TotalMnyAC = receivement.RcvLines[i].TotalMnyTC;
                        receivement.RcvLines[i].TotalMnyFC = receivement.RcvLines[i].TotalMnyTC;
                    }
                    else {
                        //未税金额 = 含税单价 × 数量 ÷(1 + 税率)
                        receivement.RcvLines[i].ArriveTotalNetMnyTC =
                            Math.Round(receivement.RcvLines[i].FinallyPriceTC * Convert.ToDecimal(newQty), 2);
                        //Math.Round(Convert.ToDecimal(arrqty) * receivement.RcvLines[i].FinallyPriceTC / (decimal.Parse(receivement.RcvLines[i].TaxRate.ToString())), 2);//实到未税额 
                        receivement.RcvLines[i].ArriveTotalNetMnyAC =
                            receivement.RcvLines[i].ArriveTotalNetMnyTC; //实到未税额 
                        receivement.RcvLines[i].ArriveTotalNetMnyFC =
                            receivement.RcvLines[i].ArriveTotalNetMnyTC; //实到未税额 
                        //
                        receivement.RcvLines[i].ArriveTotalTaxFC = Math.Round(
                            receivement.RcvLines[i].ArriveTotalNetMnyTC * receivement.RcvLines[i].TaxRate, 2);
                        //Math.Round(Convert.ToDecimal(arrqty) * receivement.RcvLines[i].FinallyPriceTC / (decimal.Parse(receivement.RcvLines[i].TaxRate.ToString())) * (decimal.Parse(receivement.RcvLines[i].TaxRate.ToString())), 2);//实到税额 
                        receivement.RcvLines[i].ArriveTotalTaxTC =
                            receivement.RcvLines[i].ArriveTotalTaxFC; //实到税额 
                        receivement.RcvLines[i].ArriveTotalTaxAC =
                            receivement.RcvLines[i].ArriveTotalTaxFC; //实到税额 

                        receivement.RcvLines[i].ArriveTotalMnyTC = receivement.RcvLines[i].ArriveTotalNetMnyTC +
                                                                   receivement.RcvLines[i]
                                                                       .ArriveTotalTaxFC; //实到价税合计 
                        receivement.RcvLines[i].ArriveTotalMnyAC =
                            receivement.RcvLines[i].ArriveTotalMnyTC; //实到价税合计 
                        receivement.RcvLines[i].ArriveTotalMnyFC =
                            receivement.RcvLines[i].ArriveTotalMnyTC; //实到价税合计 


                        //实收未税额
                        receivement.RcvLines[i].TotalNetMnyTC =
                            Math.Round(receivement.RcvLines[i].FinallyPriceTC * Convert.ToDecimal(newQty), 2);
                        receivement.RcvLines[i].TotalNetMnyAC = receivement.RcvLines[i].TotalNetMnyTC;
                        receivement.RcvLines[i].TotalNetMnyFC = receivement.RcvLines[i].TotalNetMnyTC;

                        //实收税额
                        receivement.RcvLines[i].TotalTaxFC = Math.Round(
                            (receivement.RcvLines[i].TotalNetMnyTC * receivement.RcvLines[i].TaxRate), 2);
                        receivement.RcvLines[i].TotalTaxAC = receivement.RcvLines[i].TotalTaxFC;
                        receivement.RcvLines[i].TotalTaxTC = receivement.RcvLines[i].TotalTaxFC;
                        //实收价税合计
                        receivement.RcvLines[i].TotalMnyTC = receivement.RcvLines[i].ArriveTotalNetMnyTC +
                                                             receivement.RcvLines[i].ArriveTotalTaxFC; //实到价税合计 
                        receivement.RcvLines[i].TotalMnyAC = receivement.RcvLines[i].TotalMnyTC;
                        receivement.RcvLines[i].TotalMnyFC = receivement.RcvLines[i].TotalMnyTC;
                    }


                    if (receivement.RcvLines[i].RcvTaxs.Count > 0) {
                        foreach (RcvTax item2 in receivement.RcvLines[i].RcvTaxs) {
                            if (item2.TaxMnyType == UFIDA.U9.CBO.FI_SCM.DTOs.TaxMnyTypeEnum.ArriveTax) {
                                item2.TaxMnyTC = receivement.RcvLines[i].ArriveTotalTaxFC;
                                item2.TaxMnyAC = receivement.RcvLines[i].ArriveTotalTaxFC;
                                item2.TaxMnyFC = receivement.RcvLines[i].ArriveTotalTaxFC;
                            }
                        }

                        foreach (RcvTax item2 in receivement.RcvLines[i].RcvTaxs) {
                            if (item2.TaxMnyType == UFIDA.U9.CBO.FI_SCM.DTOs.TaxMnyTypeEnum.ReceiveTax) {
                                item2.TaxMnyTC = receivement.RcvLines[i].ArriveTotalTaxFC;
                                item2.TaxMnyAC = receivement.RcvLines[i].ArriveTotalTaxFC;
                                item2.TaxMnyFC = receivement.RcvLines[i].ArriveTotalTaxFC;
                            }
                        }
                    }

                    #endregion 我自己的
                    
                    // 修改存储地点
                    if (receivement.RcvLines[i].DocLineNo == docLineNo &&
                        receivement.RcvLines[i].Wh.Code != rtnLineData.WhCode) {
                        Warehouse warehouse = Warehouse.FindByCode(receivement.Org, rtnLineData.WhCode);
                        if (warehouse == null) {
                            throw new ApplicationException($"编码为:{rtnLineData.WhCode}的存储地点不存在");
                        }

                        receivement.RcvLines[i].Wh = warehouse;
                    }

                    if (receivement.RcvLines[i].Wh.IsBin) {
                        if (receivement.RcvLines[i].RcvLineLocations.Count > 0) {
                            Bin bin = Bin.Finder.Find(string.Format(
                                "Org.ID='{0}'  and Warehouse.Code='{1}' and Code = '{2}'",
                                Context.LoginOrg.ID.ToString(), receivement.RcvLines[i].Wh.Code, "A1"));
                            if (bin != null) {
                                receivement.RcvLines[i].RcvLineLocations[0].Location = bin;
                                receivement.RcvLines[i].RcvLineLocations[0].LocationQtySU =
                                    receivement.RcvLines[i].ArriveQtySU;
                                receivement.RcvLines[i].RcvLineLocations[0].LocationQtyTU =
                                    receivement.RcvLines[i].ArriveQtySU;
                            }
                        }
                        else {
                            Bin bin = Bin.Finder.Find(string.Format(
                                "Org.ID='{0}'  and Warehouse.Code='{1}' and Code = '{2}'",
                                Context.LoginOrg.ID.ToString(), receivement.RcvLines[i].Wh.Code, "A1"));

                            RcvLineLocation rcvbin = RcvLineLocation.Create(receivement.RcvLines[i]);
                            rcvbin.ItemInfo.ItemCode = receivement.RcvLines[i].ItemInfo.ItemCode;
                            rcvbin.CurrentOrg = Context.LoginOrg;
                            rcvbin.Location = new CBO.SCM.Bin.Bin();
                            rcvbin.Location = bin;
                            rcvbin.LocationQtySU = receivement.RcvLines[i].ArriveQtySU;
                            rcvbin.LocationQtyTU = receivement.RcvLines[i].ArriveQtySU;
                            receivement.RcvLines[i].Wh = bin.Warehouse;
                            receivement.RcvLines[i].RcvLineLocations.Add(rcvbin);
                        }
                    }
                    else {
                        if (receivement.RcvLines[i].RcvLineLocations.Count > 0) {
                            receivement.RcvLines[i].RcvLineLocations[0] = null;
                        }
                    }
                }
            }

            session.Commit();
        }
    }

    ApproveRCV(receivement);
    _logger.LogInfo("修改成功");
    resultData.Code = "200";
    resultData.Message = "成功";
    resultData.DocNo = docNo;
    return resultData;
}

采购退货修改数量

private WMSResultDataDTOData ProcessRtn(string docNo, RTNHeadData rtnHeadData) {
    var resultData = new WMSResultDataDTOData();
    Receivement rec =
        Receivement.Finder.Find(string.Format("DocNo = '{0}' and Org = {1}", docNo, Context.LoginOrg.ID));
    if (rec == null)
        throw new Exception("找不到采购退货单据,DocNo=" + docNo);

    foreach (RTNLineData rtnLineData in rtnHeadData.SoRcvLineList) {
        int rtnLineNo = int.Parse(rtnLineData.DocLineNo);
        decimal newQty = decimal.Parse(rtnLineData.Qty);
        using (Session session = Session.Open()) {
            foreach (RcvLine rcvLine in rec.RcvLines) {
                if (rcvLine.DocLineNo == rtnLineNo) {
                    _logger.LogInfo(string.Format("[退货处理] - 更新退货数量:DocNo={0}, LineNo={1}, 原数量={2}, 新数量={3}",
                        docNo,
                        rtnLineNo, rcvLine.RejectQtyTU, newQty));

                    #region 我自己的
                    rcvLine.ArriveQtyTU = rcvLine.EyeballingQtyTU = rcvLine.RcvQtyTU = Decimal.Zero;
                    rcvLine.ArriveQtyPU = rcvLine.EyeballingQtyPU = rcvLine.RcvQtyPU = Decimal.Zero;
                    rcvLine.ArriveQtySU = rcvLine.EyeballingQtySU = rcvLine.RcvQtySU = Decimal.Zero;
                    rcvLine.ArriveQtyCU = rcvLine.EyeballingQtyCU = rcvLine.RcvQtyCU = Decimal.Zero;
                    rcvLine.ArriveQtyTBU = rcvLine.EyeballingQtyTBU = rcvLine.RcvQtyTBU = 0;
                    if (rcvLine.RtnDeductQtyTU > 0) {
                        // 拒收数量
                        rcvLine.RejectQtyTU = Math.Round(Convert.ToDecimal(newQty), 4);
                        rcvLine.RejectQtyCU = Math.Round(Convert.ToDecimal(newQty), 4);
                        rcvLine.RejectQtyPU = Math.Round(Convert.ToDecimal(newQty), 4);
                        rcvLine.RejectQtySU = Math.Round(Convert.ToDecimal(newQty), 4);
                        rcvLine.RejectQtyTBU = 0;
                        rcvLine.RtnFillQtyTU = 0;
                        rcvLine.RtnFillQtyCU = 0;
                        rcvLine.RtnFillQtyPU = 0;
                        rcvLine.RtnFillQtySU = 0;
                        rcvLine.RtnFillQtyTBU = 0;
                        rcvLine.RtnDeductQtyTU = Math.Round(Convert.ToDecimal(newQty), 4);
                        rcvLine.RtnDeductQtyCU = Math.Round(Convert.ToDecimal(newQty), 4);
                        rcvLine.RtnDeductQtyPU = Math.Round(Convert.ToDecimal(newQty), 4);
                        rcvLine.RtnDeductQtySU = Math.Round(Convert.ToDecimal(newQty), 4);
                        rcvLine.RtnDeductQtyTBU = decimal.Zero;
                        // 价税合计
                        rcvLine.RejectMnyAC =
                            Math.Round(Math.Round(Convert.ToDecimal(newQty), 4) * rcvLine.FinallyPriceTC, 2);
                        rcvLine.RejectMnyFC =
                            Math.Round(Math.Round(Convert.ToDecimal(newQty), 4) * rcvLine.FinallyPriceTC, 2);
                        rcvLine.RejectMnyTC =
                            Math.Round(Math.Round(Convert.ToDecimal(newQty), 4) * rcvLine.FinallyPriceTC, 2);
                        // 未税金额 = 含税金额 / (1 + 税率)
                        rcvLine.RejectNetMnyAC = Math.Round(rcvLine.RejectMnyAC / (1 + rcvLine.TaxRate), 2);
                        rcvLine.RejectNetMnyFC = Math.Round(rcvLine.RejectMnyAC / (1 + rcvLine.TaxRate), 2);
                        rcvLine.RejectNetMnyTC = Math.Round(rcvLine.RejectMnyAC / (1 + rcvLine.TaxRate), 2);
                        // 税额 = 价税合计-未税金额
                        rcvLine.RejectTaxMnyAC = Math.Round(rcvLine.RejectMnyAC - rcvLine.RejectNetMnyAC, 2);
                        rcvLine.RejectTaxMnyFC = Math.Round(rcvLine.RejectMnyAC - rcvLine.RejectNetMnyAC, 2);
                        rcvLine.RejectTaxMnyTC = Math.Round(rcvLine.RejectMnyAC - rcvLine.RejectNetMnyAC, 2);


                        rcvLine.RtnDeductMnyTC = rcvLine.RejectMnyAC;
                        rcvLine.RtnDeductMnyFC = rcvLine.RejectMnyAC;
                        rcvLine.RtnDeductMnyAC = rcvLine.RejectMnyAC;

                        rcvLine.RtnDeductNetMnyTC = rcvLine.RejectNetMnyAC;
                        rcvLine.RtnDeductNetMnyFC = rcvLine.RejectNetMnyAC;
                        rcvLine.RtnDeductNetMnyAC = rcvLine.RejectNetMnyAC;


                        rcvLine.RtnDeductTaxAC = rcvLine.RejectTaxMnyAC;
                        rcvLine.RtnDeductTaxFC = rcvLine.RejectTaxMnyAC;
                        rcvLine.RtnDeductTaxTC = rcvLine.RejectTaxMnyAC;
                        if (rcvLine.RcvTaxs.Count > 0) {
                            foreach (RcvTax item2 in rcvLine.RcvTaxs) {
                                if (item2.TaxMnyType == UFIDA.U9.CBO.FI_SCM.DTOs.TaxMnyTypeEnum.RejectTax) {
                                    item2.TaxMnyTC = rcvLine.RejectTaxMnyAC;
                                    item2.TaxMnyAC = rcvLine.RejectTaxMnyAC;
                                    item2.TaxMnyFC = rcvLine.RejectTaxMnyAC;
                                }

                                if (item2.TaxMnyType == UFIDA.U9.CBO.FI_SCM.DTOs.TaxMnyTypeEnum.RtnDeductTax) {
                                    item2.TaxMnyTC = rcvLine.RejectTaxMnyAC;
                                    item2.TaxMnyAC = rcvLine.RejectTaxMnyAC;
                                    item2.TaxMnyFC = rcvLine.RejectTaxMnyAC;
                                }
                            }
                        }
                    }
                    else {
                        // 拒收数量
                        rcvLine.RejectQtyTU = Math.Round(Convert.ToDecimal(newQty), 4);
                        rcvLine.RejectQtyCU = Math.Round(Convert.ToDecimal(newQty), 4);
                        rcvLine.RejectQtyPU = Math.Round(Convert.ToDecimal(newQty), 4);
                        rcvLine.RejectQtySU = Math.Round(Convert.ToDecimal(newQty), 4);
                        rcvLine.RejectQtyTBU = 0;
                        rcvLine.RtnFillQtyTU = Math.Round(Convert.ToDecimal(newQty), 4);
                        rcvLine.RtnFillQtyCU = Math.Round(Convert.ToDecimal(newQty), 4);
                        rcvLine.RtnFillQtyPU = Math.Round(Convert.ToDecimal(newQty), 4);
                        rcvLine.RtnFillQtySU = Math.Round(Convert.ToDecimal(newQty), 4);
                        rcvLine.RtnFillQtyTBU = 0;
                        rcvLine.RtnDeductQtyTU = decimal.Zero;
                        rcvLine.RtnDeductQtyCU = decimal.Zero;
                        rcvLine.RtnDeductQtyPU = decimal.Zero;
                        rcvLine.RtnDeductQtySU = decimal.Zero;
                        rcvLine.RtnDeductQtyTBU = decimal.Zero;
                        // 价税合计
                        rcvLine.RejectMnyAC =
                            Math.Round(Math.Round(Convert.ToDecimal(newQty), 4) * rcvLine.FinallyPriceTC, 2);
                        rcvLine.RejectMnyFC =
                            Math.Round(Math.Round(Convert.ToDecimal(newQty), 4) * rcvLine.FinallyPriceTC, 2);
                        rcvLine.RejectMnyTC =
                            Math.Round(Math.Round(Convert.ToDecimal(newQty), 4) * rcvLine.FinallyPriceTC, 2);
                        // 未税金额 = 含税金额 / (1 + 税率)
                        rcvLine.RejectNetMnyAC = Math.Round(rcvLine.RejectMnyAC / (1 + rcvLine.TaxRate), 2);
                        rcvLine.RejectNetMnyFC = Math.Round(rcvLine.RejectMnyAC / (1 + rcvLine.TaxRate), 2);
                        rcvLine.RejectNetMnyTC = Math.Round(rcvLine.RejectMnyAC / (1 + rcvLine.TaxRate), 2);
                        // 税额 = 价税合计-未税金额
                        rcvLine.RejectTaxMnyAC = Math.Round(rcvLine.RejectMnyAC - rcvLine.RejectNetMnyAC, 2);
                        rcvLine.RejectTaxMnyFC = Math.Round(rcvLine.RejectMnyAC - rcvLine.RejectNetMnyAC, 2);
                        rcvLine.RejectTaxMnyTC = Math.Round(rcvLine.RejectMnyAC - rcvLine.RejectNetMnyAC, 2);
                        if (rcvLine.RcvTaxs.Count > 0) {
                            foreach (RcvTax item2 in rcvLine.RcvTaxs) {
                                if (item2.TaxMnyType == UFIDA.U9.CBO.FI_SCM.DTOs.TaxMnyTypeEnum.RejectTax) {
                                    item2.TaxMnyTC = rcvLine.RejectTaxMnyAC;
                                    item2.TaxMnyAC = rcvLine.RejectTaxMnyAC;
                                    item2.TaxMnyFC = rcvLine.RejectTaxMnyAC;
                                }
                            }
                        }
                    }


                    // 修改存储地点
                    if (rcvLine.DocLineNo == rtnLineNo &&
                        rcvLine.Wh.Code != rtnLineData.WhCode) {
                        Warehouse warehouse = Warehouse.FindByCode(rcvLine.CurrentOrg, rtnLineData.WhCode);
                        if (warehouse == null) {
                            throw new ApplicationException($"编码为:{rtnLineData.WhCode}的存储地点不存在");
                        }
                        rcvLine.Wh = warehouse;
                    }
                    if (rcvLine.Wh.IsBin) {
                        if (rcvLine.RcvLineLocations.Count > 0) {
                            Bin bin = Bin.Finder.Find(string.Format(
                                "Org.ID='{0}'  and Warehouse.Code='{1}' and Code = '{2}'",
                                Context.LoginOrg.ID.ToString(), rcvLine.Wh.Code, "A1"));
                            if (bin != null) {
                                rcvLine.RcvLineLocations[0].Location = bin;
                                rcvLine.RcvLineLocations[0].LocationQtySU = rcvLine.ArriveQtySU;
                                rcvLine.RcvLineLocations[0].LocationQtyTU = newQty;
                            }
                        }
                        else {
                            Bin bin = Bin.Finder.Find(string.Format(
                                "Org.ID='{0}'  and Warehouse.Code='{1}' and Code = '{2}'",
                                Context.LoginOrg.ID.ToString(), rcvLine.Wh.Code, "A1"));

                            RcvLineLocation rcvbin = RcvLineLocation.Create(rcvLine);
                            rcvbin.ItemInfo.ItemCode = rcvLine.ItemInfo.ItemCode;
                            rcvbin.CurrentOrg = Context.LoginOrg;
                            rcvbin.Location = new CBO.SCM.Bin.Bin();
                            rcvbin.Location = bin;
                            rcvbin.LocationQtySU = rcvLine.ArriveQtySU;
                            rcvbin.LocationQtyTU = newQty;
                            rcvLine.Wh = bin.Warehouse;
                            rcvLine.RcvLineLocations.Add(rcvbin);
                        }
                    }
                    else {
                        if (rcvLine.RcvLineLocations.Count > 0) {
                            rcvLine.RcvLineLocations[0] = null;
                        }
                    }
                }

                #endregion 我自己的
            }

            session.Commit();
        }
    }
}

  • BP名:BatchCreateItemByDTOSRVProxy
  • 命名空间:UFIDA.U9.ISV.Item.Proxy
  • dll:C:\yonyou\U9V60\Portal\ApplicationServer\Libs\UFIDA.U9.ISV.Item.Agent.dll
  • 示例代码

    using System;
    using System.Collections.Generic;
    using System.Data;
    using Cust.QR.ZJLHBP.Public;
    using UFIDA.U9.Base;
    using UFIDA.U9.Base.Organization;
    using UFIDA.U9.Base.PropertyTypes;
    using UFIDA.U9.CBO.Pub.Controller;
    using UFIDA.U9.CBO.Pub.Controller.Proxy;
    using UFIDA.U9.CBO.SCM.Item;
    using UFIDA.U9.CBO.SCM.TallyBy;
    using UFIDA.U9.ISV.Item.Proxy;
    using UFSoft.UBF.AopFrame;
    using UFSoft.UBF.Business;
    using UFSoft.UBF.PL.Engine;
    using ItemInspectionInfoDTOData = UFIDA.U9.ISV.Item.ItemInspectionInfoDTOData;
    using ItemInvInfoDTOData = UFIDA.U9.ISV.Item.ItemInvInfoDTOData;
    using ItemMasterDTOData = UFIDA.U9.ISV.Item.ItemMasterDTOData;
    using ItemMFGInfoDTOData = UFIDA.U9.ISV.Item.ItemMFGInfoDTOData;
    using ItemMRPInfoDTOData = UFIDA.U9.ISV.Item.ItemMRPInfoDTOData;
    using ItemPurchaseInfoDTOData = UFIDA.U9.ISV.Item.ItemPurchaseInfoDTOData;
    using ItemSaleInfoDTOData = UFIDA.U9.ISV.Item.ItemSaleInfoDTOData;
    
     internal partial class AutoCreateItemImpementStrategy : BaseStrategy {
          public AutoCreateItemImpementStrategy() { }
    
          public override object Do(object obj) {
              AutoCreateItem bpObj = (AutoCreateItem)obj;
    
              Logger logger = Logger.GetInstance();
              //所有料品都有数据中心(00)创建然后下发
              Organization org = Organization.Finder.Find("Code = '00'");
              // 需要生成流水号的料品
              ItemMaster.EntityList itemMasters =
                  ItemMaster.Finder.FindAll(
                      string.Format("Description = '需要建流水号' and Org = '{0}' and code = '0101000001' ", org.ID));
              foreach (ItemMaster itemMaster in itemMasters) {
                  if (itemMaster.Code.Contains(".")) {
                      continue;
                  }
    
                  // 右匹配查看生成流水号的料品
                  string sql =
                      string.Format(
                          @"select id,code from CBO_ItemMaster where code like '{0}%' and DescFlexField_PrivateDescSeg15 != 'true' and org = '{1}' ORDER BY CreatedOn DESC;
    select id from CBO_ItemMaster where code like '{0}%' and org = '{1}'; ",
                          itemMaster.Code + ".",org.ID);
    
                  // 执行sql
                  DataSet dataset = PubHelper.RunSQLOutDataSet(sql, null);
    
                  // 没有创建过流水号料品
                  try {
                      if (dataset != null && dataset.Tables[1].Rows.Count <= 0) {
                          BatchCreateItemByDTOSRVProxy proxy = new BatchCreateItemByDTOSRVProxy();
                          proxy.ItemMasterDTOs = new List<ItemMasterDTOData>();
                          proxy.TargetOrgCode = Context.LoginOrg.Code;
                          proxy.TargetOrgName = Context.LoginOrg.Name;
                          for (int i = 1; i <= 50; i++) {
                              ItemMasterDTOData itemMasterDtoData = CopyItemMasterDtoData(itemMaster);
                              // 处理下料号,料号为不同  PadLeft(6, '0') 使字符串长度达到 6,不足部分填充 0。
                              itemMasterDtoData.Code = itemMaster.Code + "." + i.ToString().PadLeft(6, '0');
                              proxy.ItemMasterDTOs.Add(itemMasterDtoData);
                          }
    
                          List<ItemMasterData> itemMasterDatas = proxy.Do();
                          foreach (ItemMasterData itemMasterData in itemMasterDatas) {
                              ItemMaster master =
                                  ItemMaster.Finder.Find(string.Format("code = '{0}'", itemMasterData.Code));
                              CopyItemMaster(master);
                          }
    
                          // 结束本次循环作用于 foreach (ItemMaster itemMaster in itemMasters)这部分的代码
                          continue;
                      }
    
                      if (dataset != null && dataset.Tables[0] != null) {
                          // 剩余流水号数量不足50个
                          if (dataset.Tables[0].Rows.Count < 50 && dataset.Tables[0].Rows.Count > 0) {
                              // 差多少?
                              int balance = 50 - dataset.Tables[0].Rows.Count;
                              BatchCreateItemByDTOSRVProxy proxy = new BatchCreateItemByDTOSRVProxy();
                              proxy.ItemMasterDTOs = new List<ItemMasterDTOData>();
                              proxy.TargetOrgCode = Context.LoginOrg.Code;
                              proxy.TargetOrgName = Context.LoginOrg.Name;
                              // 最大的流水号
                              string maxLiuShui = dataset.Tables[0].Rows[0]["code"].ToString();
                              string[] result = maxLiuShui.Split('.');
                              // long 类型是数值类型,它不会存储前导零。因此,无法直接将 "000001" 转换为 long 并保留前导零。下面有处理加上前面的0
                              long liushuihao = long.Parse(result[1]);
                              for (int i = 0; i <= balance; i++) {
                                  ItemMasterDTOData itemMasterDtoData = CopyItemMasterDtoData(itemMaster);
                                  // PadLeft(6, '0') 使字符串长度达到 6,不足部分填充 0。
                                  itemMasterDtoData.Code = result[0] + "." + liushuihao++.ToString().PadLeft(6, '0');
                                  proxy.ItemMasterDTOs.Add(itemMasterDtoData);
                              }
    
                              proxy.Do();
                              }
                          }
                      }
                  }
                  catch (Exception e) {
                      logger.LogError("自动创建流水料品失败:");
                      logger.LogError(e.ToString());
                  }
              }
    
              return null;
          }
    
          private ItemMasterDTOData CopyItemMasterDtoData(ItemMaster itemMaster) {
              ItemMasterDTOData itemMasterDto = new ItemMasterDTOData();
              itemMasterDto.SysState = ObjectState.Inserted;
              itemMasterDto.Name = itemMaster.Name;
              itemMasterDto.SPECS = itemMaster.SPECS;
              itemMasterDto.Effective = new EffectiveData();
              itemMasterDto.Effective.IsEffective = true;
              itemMasterDto.Effective.EffectiveDate = DateTime.Now;
              itemMasterDto.Effective.DisableDate = DateTime.Parse("9999.12.31");
    
              if (itemMaster.MfgInfo != null) {
                  //料品生产信息
                  itemMasterDto.MfgInfo = new ItemMFGInfoDTOData();
                  itemMasterDto.MfgInfo.IsSueOverType = -1;
                  itemMasterDto.MfgInfo.BuildShrinkageRate = 1;
                  itemMasterDto.MfgInfo.IsOutputControlFlag = false;
                  //图号
                  itemMasterDto.MfgInfo.PictureCode = itemMaster.MfgInfo.PictureCode;
    
                  itemMasterDto.MfgInfo.OperateType = -1;
                  if (itemMaster.MfgInfo.ProductDepartment != null) {
                      itemMasterDto.MfgInfo.ProductDepartment = new CommonArchiveDataDTOData();
                      itemMasterDto.MfgInfo.ProductDepartment.ID = itemMaster.MfgInfo.ProductDepartment.ID;
                  }
    
                  //计划.BOM控制方式
                  if (itemMaster.MfgInfo.BomControlMode != null) {
                      itemMasterDto.MfgInfo.BomControlMode = itemMaster.MfgInfo.BomControlMode.Value;
                  }
    
                  //生产.生产数量选择
                  if (itemMaster.MfgInfo.BuildQuanSelectType != null) {
                      itemMasterDto.MfgInfo.BuildQuanSelectType = itemMaster.MfgInfo.BuildQuanSelectType.Value;
                  }
              }
    
              if (itemMaster.MrpInfo != null) {
                  //料品MRP(计划)信息
                  itemMasterDto.MrpInfo = new ItemMRPInfoDTOData();
    
    
                  itemMasterDto.MrpInfo.IsTraceRequirement = true;
                  //计划.计划方法
                  // if (itemMaster.InventoryInfo.InventoryPlanningMethod != InventoryPlanningMethodEnum.UseMRP) {
                  //     if (itemMaster.MrpInfo.MRPPlanningType != null) {
                  //         itemMasterDto.MrpInfo.MRPPlanningType = itemMaster.MrpInfo.MRPPlanningType.Value;
                  //     }
                  // }
    
                  //计划.预测控制
                  if (itemMaster.MrpInfo.ForecastContorlType != null) {
                      itemMasterDto.MrpInfo.ForecastContorlType = itemMaster.MrpInfo.ForecastContorlType.Value;
                  }
    
                  //计划.计划时界原则
                  if (itemMaster.MrpInfo.PlanningTimeFenceRuleType != null) {
                      itemMasterDto.MrpInfo.PlanningTimeFenceRuleType =
                          itemMaster.MrpInfo.PlanningTimeFenceRuleType.Value;
                  }
    
                  //计划.计划时界类型
                  if (itemMaster.MrpInfo.PlanningTimeFence != null) {
                      itemMasterDto.MrpInfo.PlanningTimeFence = itemMaster.MrpInfo.PlanningTimeFence.Value;
                  }
    
                  //计划.需求时界原则
                  if (itemMaster.MrpInfo.DemandTimeFenceRuleType != null) {
                      itemMasterDto.MrpInfo.DemandTimeFenceRuleType = itemMaster.MrpInfo.DemandTimeFenceRuleType.Value;
                  }
    
                  //计划.需求时界类型
                  if (itemMaster.MrpInfo.DemandTimeFence != null) {
                      itemMasterDto.MrpInfo.DemandTimeFence = itemMaster.MrpInfo.DemandTimeFence.Value;
                  }
    
                  //计划.发放时界类型
                  if (itemMaster.MrpInfo.ReleaseTimeFence != null) {
                      itemMasterDto.MrpInfo.ReleaseTimeFence = itemMaster.MrpInfo.ReleaseTimeFence.Value;
                  }
    
                  /*采购预提前期*/
                  itemMasterDto.MrpInfo.PurForwardProcessLT = itemMaster.MrpInfo.PurForwardProcessLT;
    
                  /*采购后提前期*/
                  itemMasterDto.MrpInfo.PurBackwardProcessLT = itemMaster.MrpInfo.PurBackwardProcessLT;
    
                  /*采购处理提前期*/
                  itemMasterDto.MrpInfo.PurProcessLT = itemMaster.MrpInfo.PurProcessLT;
                  //提前期批量
                  itemMasterDto.MrpInfo.LTBatch = itemMaster.MrpInfo.LTBatch;
    
                  //变动提前期
                  itemMasterDto.MrpInfo.VarietyLT = itemMaster.MrpInfo.VarietyLT;
    
                  /*固定提前期*/
                  itemMasterDto.MrpInfo.FixedLT = itemMaster.MrpInfo.FixedLT;
    
                  /*默认计划员*/
                  if (itemMaster.MrpInfo.Planer != null) {
                      itemMasterDto.MrpInfo.Planer = new CommonArchiveDataDTOData(itemMaster.MrpInfo.Planer.ID,
                          itemMaster.MrpInfo.Planer.Code, itemMaster.MrpInfo.Planer.Name);
                  }
    
                  /*制造提前期*/
                  itemMasterDto.MrpInfo.SumManufactureLT = itemMaster.MrpInfo.SumManufactureLT;
              }
    
              itemMasterDto.InventoryInfo = new ItemInvInfoDTOData();
              itemMasterDto.InventoryInfo.InventoryPlanningMethod = 4;
              //存储地点
              if (itemMasterDto.InventoryInfo != null) {
                  //料品库存信息
                  itemMasterDto.InventoryInfo = new ItemInvInfoDTOData();
                  itemMasterDto.InventoryInfo.Warehouse = new CommonArchiveDataDTOData();
                  if (itemMaster.InventoryInfo.Warehouse != null) {
                      itemMasterDto.InventoryInfo.Warehouse.ID = itemMaster.InventoryInfo.Warehouse.ID;
                      itemMasterDto.InventoryInfo.Warehouse.Code = itemMaster.InventoryInfo.Warehouse.Code;
                  }
    
                  itemMasterDto.InventoryInfo.WarehouseManager = new CommonArchiveDataDTOData();
                  if (itemMaster.InventoryInfo.WarehouseManager != null) {
                      itemMasterDto.InventoryInfo.WarehouseManager.Code = itemMaster.InventoryInfo.WarehouseManager.Code;
                      itemMasterDto.InventoryInfo.WarehouseManager.Name = itemMaster.InventoryInfo.WarehouseManager.Name;
                      itemMasterDto.InventoryInfo.WarehouseManager.ID = itemMaster.InventoryInfo.WarehouseManager.ID;
                  }
    
                  itemMasterDto.InventoryInfo.PurchaseControlMode = InvQtyCtlTypeEnum.MaxStockLimit.Value;
                  itemMasterDto.InventoryInfo.IsInvCalculateBySeiban = true;
                  itemMasterDto.InventoryInfo.IsBalanceByProject = false;
                  //库存规划.规划方法
                  //if (itemMaster.InventoryInfo.InventoryPlanningMethod != null) {
                  // itemMasterDto.InventoryInfo.InventoryPlanningMethod =
                  //     itemMaster.InventoryInfo.InventoryPlanningMethod.Value;
                  itemMasterDto.InventoryInfo.InventoryPlanningMethod = 4;
                  // }
    
                  //库存规划.安全存量法
                  if (itemMaster.InventoryInfo.SafetyStockType != null) {
                      itemMasterDto.InventoryInfo.SafetyStockType = itemMaster.InventoryInfo.SafetyStockType.Value;
                  }
    
                  //库存规划.安全库存量
                  itemMasterDto.InventoryInfo.SafetyStockQty = itemMaster.InventoryInfo.SafetyStockQty;
                  /*转换率加权*/
                  if (itemMaster.InventoryInfo != null) {
                      itemMasterDto.InventoryInfo.ConvertRatio = itemMaster.InventoryInfo.ConvertRatio;
                  }
    
                  if (itemMaster.InventoryInfo != null && itemMaster.InventoryInfo.LotParam != null) {
                      /*批号参数*/
                      itemMasterDto.InventoryInfo.LotParam = new CommonArchiveDataDTOData();
                      itemMasterDto.InventoryInfo.LotParam.Code = itemMaster.InventoryInfo.LotParam.Code;
                      itemMasterDto.InventoryInfo.LotParam.ID = itemMaster.InventoryInfo.LotParam.ID;
                      itemMasterDto.InventoryInfo.LotParam.Name = itemMaster.InventoryInfo.LotParam.Name;
                  }
    
                  /*序号参数*/
                  if (itemMaster.InventoryInfo != null && itemMaster.InventoryInfo.SnParam != null) {
                      itemMasterDto.InventoryInfo.SnParam = new CommonArchiveDataDTOData();
                      itemMasterDto.InventoryInfo.SnParam.ID = itemMaster.InventoryInfo.SnParam.ID;
                      itemMasterDto.InventoryInfo.SnParam.Code = itemMaster.InventoryInfo.SnParam.Code;
                      itemMasterDto.InventoryInfo.SnParam.Name = itemMaster.InventoryInfo.SnParam.Name;
                  }
    
                  /*安全库存量*/
                  if (itemMaster.InventoryInfo != null) {
                      itemMasterDto.InventoryInfo.SafetyStockQty = itemMaster.InventoryInfo.SafetyStockQty;
                  }
              }
    
              //料品质量信息
              itemMasterDto.InspectionInfo = new ItemInspectionInfoDTOData();
              itemMasterDto.InspectionInfo.ID = itemMaster.InspectionInfo.ID;
              // 描述
              // itemMasterDto.Description = itemMasterDto.Description;
    
              itemMasterDto.MainItemCategory = new CommonArchiveDataDTOData();
              itemMasterDto.MainItemCategory.Code = itemMaster.MainItemCategory.Code;
    
              //    库存单位
              itemMasterDto.InventorySecondUOM = new CommonArchiveDataDTOData();
              itemMasterDto.InventorySecondUOM.Code = itemMaster.Code;
              //    库存主单位
              itemMasterDto.InventoryUOM = new CommonArchiveDataDTOData();
              itemMasterDto.InventoryUOM.Code = itemMaster.InventorySecondUOM.Code;
              //    重量单位
              itemMasterDto.WeightUom = new CommonArchiveDataDTOData();
              itemMasterDto.WeightUom.Code = itemMaster.InventoryUOM.Code;
              //    体积单位
              itemMasterDto.BulkUom = new CommonArchiveDataDTOData();
              itemMasterDto.BulkUom.Code = itemMaster.InventoryUOM.Code;
    
              itemMasterDto.SalesUOM = new CommonArchiveDataDTOData();
              itemMasterDto.SalesUOM.Code = itemMaster.SalesUOM.Code;
    
              itemMasterDto.PurchaseUOM = new CommonArchiveDataDTOData();
              itemMasterDto.PurchaseUOM.Code = itemMaster.PurchaseUOM.Code;
    
              itemMasterDto.PriceUOM = new CommonArchiveDataDTOData();
              itemMasterDto.PriceUOM.Code = itemMaster.PriceUOM.Code;
    
              itemMasterDto.ManufactureUOM = new CommonArchiveDataDTOData();
              itemMasterDto.ManufactureUOM.Code = itemMaster.ManufactureUOM.Code;
    
              itemMasterDto.CostUOM = new CommonArchiveDataDTOData();
              itemMasterDto.CostUOM.Code = itemMaster.CostUOM.Code;
    
              //    领料单位
              itemMasterDto.MaterialOutUOM = new CommonArchiveDataDTOData();
              itemMasterDto.MaterialOutUOM.Code = itemMaster.MaterialOutUOM.Code;
    
              itemMasterDto.ItemFormAttribute = itemMaster.ItemFormAttribute.Value;
    
              itemMasterDto.IsInventoryEnable = true; //可库存交易
              itemMasterDto.IsPurchaseEnable = true; // 可采购
              itemMasterDto.IsSalesEnable = true; //可销售
              itemMasterDto.IsBOMEnable = true; //可BOM
              itemMasterDto.IsMRPEnable = true; //可MRP
              itemMasterDto.IsVMIEnable = true; //VMI标志
    
              itemMasterDto.IsOutsideOperationEnable = itemMaster.IsOutsideOperationEnable; //可委外
    
              itemMasterDto.IsBuildEnable = itemMaster.IsBuildEnable; //可生产
    
    
              itemMasterDto.IsVarRatio = true;
    
              if (itemMaster.PurchaseInfo != null) {
                  //料品采购信息
                  itemMasterDto.PurchaseInfo = new ItemPurchaseInfoDTOData();
                  //理货规则
                  TallyBy putawayRule = TallyBy.FindByCode(Context.LoginOrg, "1");
                  if (putawayRule != null)
                      itemMasterDto.PurchaseInfo.ReceiptModeAllowModify = true;
                  itemMasterDto.PurchaseInfo.PriceSource = 2;
                  itemMasterDto.PurchaseInfo.ReceiptMode = itemMaster.PurchaseInfo.ReceiptMode.Value;
                  itemMasterDto.PurchaseInfo.IsNeedRequest = false;
                  itemMasterDto.PurchaseInfo.ReceiptRule = new CommonArchiveDataDTOData();
                  itemMasterDto.PurchaseInfo.ReceiptRule.Code = "1";
                  //采购.配额供应商
                  if (itemMaster.PurchaseInfo.QuotaSupplier != null) {
                      itemMasterDto.PurchaseInfo.QuotaSupplier = itemMaster.PurchaseInfo.QuotaSupplier.Value;
                  }
    
                  //采购.收货方式
                  if (itemMaster.PurchaseInfo.ReceiptType != null) {
                      itemMasterDto.PurchaseInfo.ReceiptType = itemMaster.PurchaseInfo.ReceiptType.Value;
                  }
              }
    
              //料品销售信息
              if (itemMaster.SaleInfo != null) {
                  itemMasterDto.SaleInfo = new ItemSaleInfoDTOData();
                  itemMasterDto.SaleInfo.SupplyOrg = new CommonArchiveDataDTOData();
                  itemMasterDto.SaleInfo.SupplyOrg.Code = Context.LoginOrg.Code;
                  if (itemMaster.SaleInfo.LimitPriceMode != null) {
                      itemMasterDto.SaleInfo.LimitPriceMode = itemMaster.SaleInfo.LimitPriceMode.Value;
                  }
    
                  //销售.供应来源
                  if (itemMaster.SaleInfo.SupplySource != null) {
                      itemMasterDto.SaleInfo.SupplySource = itemMaster.SaleInfo.SupplySource.Value;
                  }
    
                  //销售.供应类型
                  if (itemMaster.SaleInfo.DemandTransType != null) {
                      itemMasterDto.SaleInfo.DemandTransType = itemMaster.SaleInfo.DemandTransType.Value;
                  }
              }
    
    
              //转换率策略
              if (itemMaster.ConverRatioRule != null) {
                  itemMasterDto.ConverRatioRule = itemMaster.ConverRatioRule.Value;
              }
    
              //双单位
              itemMasterDto.IsDualUOM = itemMaster.IsDualUOM;
    
              //多单位
              itemMasterDto.IsMultyUOM = itemMaster.IsMultyUOM;
    
              //库存单位重量
              itemMasterDto.Weight = itemMaster.Weight;
    
              // itemMasterDto.MrpInfo = new ItemMRPInfoDTOData();
    
    
              /*财务分类*/
              if (itemMaster.AssetCategory != null) {
                  itemMasterDto.AssetCategory = new CommonArchiveDataDTOData();
                  itemMasterDto.AssetCategory.ID = itemMaster.AssetCategory.ID;
                  itemMasterDto.AssetCategory.Code = itemMaster.AssetCategory.Code;
                  itemMasterDto.AssetCategory.Name = itemMaster.AssetCategory.Name;
              }
    
              /*专用料*/
              itemMasterDto.IsSpecialItem = itemMaster.IsSpecialItem;
    
              return itemMasterDto;
          }
      }