值集值查询SELECT Base_DefineValue_Trl.Name FROM Base_DefineValue --值集值 LEFT JOIN Base_DefineValue_Trl ON Base_DefineValue.ID = Base_DefineValue_Trl.ID AND Base_DefineValue_Trl.SysMLFlag = 'zh-CN' --值集值Trl LEFT JOIN Base_ValueSetDef ON Base_ValueSetDef.ID = Base_DefineValue.ValueSetDef --值集 WHERE Base_ValueSetDef.Code = 'zfbz' AND Base_DefineValue.Code = 'N'枚举值查询SELECT UBF_Sys_ExtEnumValue.Code,* FROM UBF_Sys_ExtEnumType LEFT JOIN UBF_Sys_ExtEnumValue ON UBF_Sys_ExtEnumValue.ExtEnumType = UBF_Sys_ExtEnumType.ID LEFT JOIN UBF_Sys_ExtEnumValue_Trl ON UBF_Sys_ExtEnumValue_Trl.ID = UBF_Sys_ExtEnumValue.ID WHERE UBF_Sys_ExtEnumType.Code = 'QR.ZHXY.CGHTBE.MonthEnum'
U9页面字段联动代码注意事项所有的代码都需要写在WebPart目录中*.Extend.cs注册CallBack方法 public void AfterOnLoad() { CallBack_UomTab_硬件成本不含税(); CallBack_UomTab_小计(); CallBack_UomTab_合同额And占比(); CallBack_UomTab_费用And毛利(); CallBack_UomTab_总收入And总成本(); CallBack_UomTab_合同计算(); }实现注册方法// private void CallBack_UomTab_硬件成本不含税() { // 所有控件集合，按顺序对应每个 AssociationControl IUFFldNumberControl[] sourceControls = new IUFFldNumberControl[] { PartsCostOutsource65, // 硬件成本外购（含税） PartsCostOwnProduction53, // 硬件成本自产（含税） InstallMaterialCost76, // 安装材料成本（含税） InstallArtificialCost100, // 安装人工成本（含税） }; IUFFldReference[] sourceControls1 = new IUFFldReference[] { PartsCostOutsourceTax43, // 硬件成本外购（含税）税率 PartsCostOwnProductionTax68, // 硬件成本自产（含税）税率 InstallMaterialCostTax40, // 安装材料成本（含税）税率 InstallArtificialCostTax82, // 安装人工成本（含税）税率 }; ClientCallBackFrm cF = new ClientCallBackFrm(); cF.DoCustomerAction += new ClientCallBackFrm.ActionCustomer(CallBack_UomTab_硬件成本不含税); foreach (var ctrl in sourceControls) { // 注册控件到参数 cF.ParameterControls.Add(ctrl); // 创建并配置关联控制器 var assoc = new AssociationControl { SourceServerControl = ctrl, SourceControl = { EventName = "OnValueChanged" } }; cF.Add(assoc); } foreach (var ctrl in sourceControls1) { // 注册控件到参数 cF.ParameterControls.Add(ctrl); // 创建并配置关联控制器 var assoc = new AssociationControl { SourceServerControl = ctrl, SourceControl = { EventName = "OnValueChanged" } }; cF.Add(assoc); } } /// /// 回调函数：【含税金额+税率】，自动计算并设置【不含税金额】 /// object CallBack_UomTab_硬件成本不含税(CustomerActionEventArgs args) { // 硬件成本 - 外购部分 ComputeNoTaxValue(args, this.PartsCostOutsource65, this.PartsCostOutsourceTax43, this.PartsCostOutsourceNo55); // 硬件成本 - 自产部分 ComputeNoTaxValue(args, this.PartsCostOwnProduction53, this.PartsCostOwnProductionTax68, this.PartsCostOwnProductionNo85); // 安装材料成本 ComputeNoTaxValue(args, this.InstallMaterialCost76, this.InstallMaterialCostTax40, this.InstallMaterialCostNo37); // 安装人工成本 ComputeNoTaxValue(args, this.InstallArtificialCost100, this.InstallArtificialCostTax82, this.InstallArtificialCostNo76); return args; } private void CallBack_UomTab_合同计算() { // 所有控件集合，按顺序对应每个 AssociationControl IUFFldNumberControl[] sourceControls = new IUFFldNumberControl[] { ContractMoneyOne70, //合同金额1 ContractMoneyTwo52, //合同金额2 ContractMoneyThree67, //合同金额3 ContractMoneyFour44, //合同金额4 }; IUFFldReference[] sourceControls1 = new IUFFldReference[] { ContractMoneyOneTax52, //合同金额1_税率 ContractMoneyTwoTax22, //合同金额2_税率 ContractMoneyThreeTax83, //合同金额3_税率 ContractMoneyFourTax122, //合同金额4_税率 }; ClientCallBackFrm cF = new ClientCallBackFrm(); cF.DoCustomerAction += new ClientCallBackFrm.ActionCustomer(CallBack_UomTab_合同计算); foreach (var ctrl in sourceControls) { // 注册控件到参数 cF.ParameterControls.Add(ctrl); // 创建并配置关联控制器 var assoc = new AssociationControl { SourceServerControl = ctrl, SourceControl = { EventName = "OnValueChanged" } }; cF.Add(assoc); } foreach (var ctrl in sourceControls1) { // 注册控件到参数 cF.ParameterControls.Add(ctrl); // 创建并配置关联控制器 var assoc = new AssociationControl { SourceServerControl = ctrl, SourceControl = { EventName = "OnValueChanged" } }; cF.Add(assoc); } } object CallBack_UomTab_合同计算(CustomerActionEventArgs args) { //合同金额1 decimal ContractMoneyOne70 = decimal.Parse(args.ArgsHash[this.ContractMoneyOne70.ClientID].ToString()); //合同金额1_税率 long ContractMoneyOneTax52 = long.Parse(args.ArgsHash[this.ContractMoneyOneTax52.ClientID].ToString()); if (ContractMoneyOneTax52 > 0) { // 税率 string queryTax = QueryTax(ContractMoneyOneTax52); args.ArgsResult.Add(new UFWebClientNumberAdapter(this.ProjectIncomeOne7).ClientInstance + ".set_Value('" + ContractMoneyOne70 / (1 + decimal.Parse(queryTax)) + "')"); } //合同金额2 decimal ContractMoneyTwo52 = decimal.Parse(args.ArgsHash[this.ContractMoneyTwo52.ClientID].ToString()); //合同金额2_税率 long ContractMoneyTwoTax22 = long.Parse(args.ArgsHash[this.ContractMoneyTwoTax22.ClientID].ToString()); if (ContractMoneyTwoTax22 > 0) { // 税率 string queryTax = QueryTax(ContractMoneyTwoTax22); args.ArgsResult.Add(new UFWebClientNumberAdapter(this.ProjectIncomeTwo19).ClientInstance + ".set_Value('" + ContractMoneyTwo52 / (1 + decimal.Parse(queryTax)) + "')"); } //合同金额3 decimal ContractMoneyThree67 = decimal.Parse(args.ArgsHash[this.ContractMoneyThree67.ClientID].ToString()); //合同金额3_税率 long ContractMoneyThreeTax83 = long.Parse(args.ArgsHash[this.ContractMoneyThreeTax83.ClientID].ToString()); if (ContractMoneyThreeTax83 > 0) { // 税率 string queryTax = QueryTax(ContractMoneyThreeTax83); args.ArgsResult.Add(new UFWebClientNumberAdapter(this.ProjectIncomeThree59).ClientInstance + ".set_Value('" + ContractMoneyThree67 / (1 + decimal.Parse(queryTax)) + "')"); } //合同金额1 decimal ContractMoneyFour44 = decimal.Parse(args.ArgsHash[this.ContractMoneyFour44.ClientID].ToString()); //合同金额1_税率 long ContractMoneyFourTax122 = long.Parse(args.ArgsHash[this.ContractMoneyFourTax122.ClientID].ToString()); if (ContractMoneyFourTax122 > 0) { // 税率 string queryTax = QueryTax(ContractMoneyFourTax122); args.ArgsResult.Add(new UFWebClientNumberAdapter(this.ProjectIncomeFour42).ClientInstance + ".set_Value('" + ContractMoneyFour44 / (1 + decimal.Parse(queryTax)) + "')"); } return args; } private void CallBack_UomTab_小计() { IUFFldNumberControl[] sourceControls = new IUFFldNumberControl[] { PartsCostOutsource65, // 硬件成本外购（含税） PartsCostOwnProduction53, // 硬件成本自产（含税） PartsCostOutsourceNo55, // 硬件成本外购（不含税） PartsCostOwnProductionNo85, // 硬件成本自产（不含税） InstallMaterialCost76, // 安装材料成本（含税） InstallMaterialCostNo37, // 安装材料成本（不含税） InstallArtificialCost100, // 安装人工（含税） InstallArtificialCostNo76, // 安装人工（不含税） ArtificialCostSO121, // 人工成本-销售 ArtificialCostMO46, //人工成本-生产 ArtificialCostAssembly20, //人工成本-装配 ArtificialCostProject44, //人工成本-工程 ArtificialCostDesign127, //人工成本-设计 ArtificialCostPurchase44, //人工成本-采购 ArtificialCostOperations46, //人工成本-运营 ArtificialCostOther91, //人工成本-其他 TravelCostSO29, // 差旅费-销售 TravelCostProject43, //差旅费-工程 TravelCostDesign56, //差旅费-设计 TravelCostPurchase47, //差旅费-采购 TravelCostOperations34, //差旅费-运营 CostOther70, //差旅费-其他 InstallCostSubtotal351, //安装成本小计（含税） PartsCostSubtotal43, //硬件成本-小计(含税) InstallCostSubtotalNo38, //安装成本小计（不含税） PartsCostSubtotalNo55, //硬件成本-小计(不含税) }; ClientCallBackFrm cF = new ClientCallBackFrm(); cF.DoCustomerAction += new ClientCallBackFrm.ActionCustomer(CallBack_UomTab_小计); // 注册控件 & 创建 AssociationControl foreach (IUFFldNumberControl ctrl in sourceControls) { cF.ParameterControls.Add(ctrl); AssociationControl assoc = new AssociationControl { SourceServerControl = ctrl, SourceControl = { EventName = "OnValueChanged" } }; cF.Add(assoc); } } /// /// 计算小计 /// /// /// <returns></returns> object CallBack_UomTab_小计(CustomerActionEventArgs args) { // ========== 硬件成本-小计 ========== decimal outsourceTax = GetDecimalFromArgs(args, this.PartsCostOutsource65); decimal ownProductionTax = GetDecimalFromArgs(args, this.PartsCostOwnProduction53); SetClientValue(args, this.PartsCostSubtotal43, outsourceTax + ownProductionTax); decimal outsourceNoTax = GetDecimalFromArgs(args, this.PartsCostOutsourceNo55); decimal ownProductionNoTax = GetDecimalFromArgs(args, this.PartsCostOwnProductionNo85); SetClientValue(args, this.PartsCostSubtotalNo55, outsourceNoTax + ownProductionNoTax); // ========== 安装成本-小计 ========== decimal materialTax = GetDecimalFromArgs(args, this.InstallMaterialCost76); decimal laborTax = GetDecimalFromArgs(args, this.InstallArtificialCost100); SetClientValue(args, this.InstallCostSubtotal351, materialTax + laborTax); decimal materialNoTax = GetDecimalFromArgs(args, this.InstallMaterialCostNo37); decimal laborNoTax = GetDecimalFromArgs(args, this.InstallArtificialCostNo76); SetClientValue(args, this.InstallCostSubtotalNo38, materialNoTax + laborNoTax); // ========== 人工成本-小计 ========== var artificialControls = new[] { this.ArtificialCostSO121, this.ArtificialCostMO46, this.ArtificialCostAssembly20, this.ArtificialCostProject44, this.ArtificialCostDesign127, this.ArtificialCostPurchase44, this.ArtificialCostOperations46, this.ArtificialCostOther91 }; decimal totalArtificial = artificialControls.Sum(ctrl => GetDecimalFromArgs(args, ctrl)); SetClientValue(args, this.ArtificialCostSubtotal49, totalArtificial); // ========== 费用-小计 ========== var costSubtotalControls = new[] { TravelCostSO29, // 差旅费-销售 TravelCostProject43, //差旅费-工程 TravelCostDesign56, //差旅费-设计 TravelCostPurchase47, //差旅费-采购 TravelCostOperations34, //差旅费-运营 CostOther70, //差旅费-其他 }; decimal costSubtotal = costSubtotalControls.Sum(ctrl => GetDecimalFromArgs(args, ctrl)); SetClientValue(args, this.CostSubtotal58, costSubtotal); // ========== 材料成本-小计（含税） ========== decimal partsCostOutsource = GetDecimalFromArgs(args, this.PartsCostOutsource65); decimal partsCostOwnProduction53 = GetDecimalFromArgs(args, this.PartsCostOwnProduction53); SetClientValue(args, this.MaterialCostSubtotal257, partsCostOutsource + partsCostOwnProduction53); // ========== 材料成本-小计（不含税） ========== decimal installCostSubtotalNo = GetDecimalFromArgs(args, this.InstallCostSubtotalNo38); decimal partsCostSubtotalNo55 = GetDecimalFromArgs(args, this.PartsCostSubtotalNo55); SetClientValue(args, this.MaterialCostSubtotalNo37, installCostSubtotalNo + partsCostSubtotalNo55); return args; } private void CallBack_UomTab_合同额And占比() { // 所有控件集合，按顺序对应每个 AssociationControl IUFFldNumberControl[] sourceControls = new IUFFldNumberControl[] { ArtificialCostSubtotal49, // 人工成本-小计 ContractTotalMoney32, // 合同总金额（文档上：原合同金额） ProjectTotalIncome58, // 项目总收入 CostSubtotal58, // 费用小计 InstallCostSubtotal351, // 安装成本-小计（含税） MaterialCostSubtotalNo37, // 材料成本-小计（不含税） }; ClientCallBackFrm cF = new ClientCallBackFrm(); cF.DoCustomerAction += new ClientCallBackFrm.ActionCustomer(CallBack_UomTab_合同额And占比); foreach (var ctrl in sourceControls) { // 注册控件到参数 cF.ParameterControls.Add(ctrl); // 创建并配置关联控制器 var assoc = new AssociationControl { SourceServerControl = ctrl, SourceControl = { EventName = "OnValueChanged" } }; cF.Add(assoc); } } /// /// 计算合同额和占比 /// /// /// <returns></returns> object CallBack_UomTab_合同额And占比(CustomerActionEventArgs args) { // 人工成本-小计 decimal artificialCostSubtotal = GetDecimalFromArgs(args, this.ArtificialCostSubtotal49); // 费用小计 decimal costSubtotal = GetDecimalFromArgs(args, this.CostSubtotal58); // 安装成本-小计（含税） decimal installCostSubtotal = GetDecimalFromArgs(args, this.InstallCostSubtotal351); // 材料成本-小计（不含税） decimal materialCostSubtotalNo = GetDecimalFromArgs(args, this.MaterialCostSubtotalNo37); // 原合同金额 decimal contractTotalMoney = GetDecimalFromArgs(args, this.ContractTotalMoney32); // 项目总收入 decimal projectTotalIncome = GetDecimalFromArgs(args, this.ProjectTotalIncome58); if (contractTotalMoney > 0) { // ========== 人工成本合同额 =人工成本-小计/原合同金额 ========== SetClientValue(args, this.ArtificialCostContractAmount73, artificialCostSubtotal / contractTotalMoney); // ========== 人工成本/合同额 =费用小计/原合同金额 ========== SetClientValue(args, this.CostContractAmount43, costSubtotal / contractTotalMoney); // ========== 含税材料成本占比 = 材料成本-小计（含税）/原合同金额 ========== SetClientValue(args, this.MaterialCostProportion43, installCostSubtotal / contractTotalMoney); } if (projectTotalIncome > 0) { // ========== 人工成本占比 =人工成本-小计/项目总收入 ========== SetClientValue(args, this.ArtificialProportion70, artificialCostSubtotal / projectTotalIncome); // ========== 费用-占比 =费用小计/原合同金额 ========== SetClientValue(args, this.CostProportion83, costSubtotal / projectTotalIncome); // ========== 不含税材料成本占比 = 材料成本-小计（不含税）/项目总收入 ========== SetClientValue(args, this.MaterialCostProportionNo98, materialCostSubtotalNo / projectTotalIncome); } return args; } private void CallBack_UomTab_费用And毛利() { // 所有控件集合，按顺序对应每个 AssociationControl IUFFldNumberControl[] sourceControls = new IUFFldNumberControl[] { ArtificialCostSO121, // 人工成本-销售 TravelCostSO29, //差旅费-销售 ArtificialCostPurchase44, // 人工成本-采购 ArtificialCostOperations46, //人工成本-运营 ArtificialCostOther91, // 人工成本-其他 TravelCostOperations34, // 差旅费-运营 CostOther70, //费用其他 ContractTotalMoney32, // 原合同金额 ProjectTotalCost61, //项目总成本含税 ProjectTotalCostNo43, //项目总成本（不含税） GrossProfitNo88, //毛利（不含税） ProjectTotalIncome58, //项目总收入 }; ClientCallBackFrm cF = new ClientCallBackFrm(); cF.DoCustomerAction += new ClientCallBackFrm.ActionCustomer(CallBack_UomTab_费用And毛利); foreach (var ctrl in sourceControls) { // 注册控件到参数 cF.ParameterControls.Add(ctrl); // 创建并配置关联控制器 var assoc = new AssociationControl { SourceServerControl = ctrl, SourceControl = { EventName = "OnValueChanged" } }; cF.Add(assoc); } } /// /// 计算费用 /// /// /// <returns></returns> object CallBack_UomTab_费用And毛利(CustomerActionEventArgs args) { // 人工成本-销售 decimal artificialCostSo = GetDecimalFromArgs(args, this.ArtificialCostSO121); //差旅费-销售 decimal travelCostSo = GetDecimalFromArgs(args, this.TravelCostSO29); // 人工成本-采购 decimal artificialCostPurchase = GetDecimalFromArgs(args, this.ArtificialCostPurchase44); //人工成本-运营 decimal artificialCostOperations = GetDecimalFromArgs(args, this.ArtificialCostOperations46); // 人工成本-其他 decimal artificialCostOther = GetDecimalFromArgs(args, this.ArtificialCostOther91); // 差旅费-运营 decimal travelCostOperations = GetDecimalFromArgs(args, this.TravelCostOperations34); //费用其他 decimal costOther = GetDecimalFromArgs(args, this.CostOther70); decimal ContractTotalMoney = GetDecimalFromArgs(args, this.ContractTotalMoney32); decimal ProjectTotalCost = GetDecimalFromArgs(args, this.ProjectTotalCost61); decimal ProjectTotalCostNo = GetDecimalFromArgs(args, this.ProjectTotalCostNo43); decimal GrossProfitNo = GetDecimalFromArgs(args, this.GrossProfitNo88); decimal ProjectTotalIncome = GetDecimalFromArgs(args, this.ProjectTotalIncome58); // ========== 销售费用 =人工成本-销售+差旅费-销售 ========== SetClientValue(args, this.SOCost148, artificialCostSo + travelCostSo); // ========== 管理费用 =人工成本-采购+人工成本-运营+人工成本-其他+差旅费-采购+差旅费-运营+费用-其它 ========== SetClientValue(args, this.ManageCost44, artificialCostPurchase + artificialCostOperations + artificialCostOther + travelCostOperations + costOther); // ========== 毛利（含税） =原合同金额-项目总成本（含税） ========== SetClientValue(args, this.GrossProfit47, ContractTotalMoney - ProjectTotalCost); // ========== 毛利（不含税） =项目总收入-项目总成本（不含税） ========== SetClientValue(args, this.GrossProfitNo88, ProjectTotalIncome - ProjectTotalCostNo); // ========== 毛利率（不含税） =毛利（不含税）/项目总收入 ========== SetClientValue(args, this.GrossProfitTaxNo43, GrossProfitNo - ProjectTotalIncome); return args; } private void CallBack_UomTab_总收入And总成本() { // 所有控件集合，按顺序对应每个 AssociationControl IUFFldNumberControl[] sourceControls = new IUFFldNumberControl[] { ProjectIncomeOne7, //收入1 ProjectIncomeTwo19, //收入2 ProjectIncomeThree59, //收入3 ProjectIncomeFour42, //收入4 MaterialCostSubtotal257, //材料成本-小计（含税） ArtificialCostProject44, //人工成本-工程 ArtificialCostDesign127, //人工成本-设计 TravelCostProject43, //差旅费-工程 TravelCostDesign56, //差旅费-设计 ArtificialCostMO46, //人工成本-生产 ArtificialCostAssembly20, //人工成本-装配 FreightPackagFee34, //运费/包装费（含税） MaterialCostSubtotalNo37, //材料成本-小计（不含税） FreightPackagFeeNo112, //运费/包装费（不含税） }; ClientCallBackFrm cF = new ClientCallBackFrm(); cF.DoCustomerAction += new ClientCallBackFrm.ActionCustomer(CallBack_UomTab_总收入And总成本); foreach (var ctrl in sourceControls) { // 注册控件到参数 cF.ParameterControls.Add(ctrl); // 创建并配置关联控制器 var assoc = new AssociationControl { SourceServerControl = ctrl, SourceControl = { EventName = "OnValueChanged" } }; cF.Add(assoc); } } /// /// 计算总收入和总成本 /// /// /// <returns></returns> object CallBack_UomTab_总收入And总成本(CustomerActionEventArgs args) { // 收入1 decimal projectIncomeOne = GetDecimalFromArgs(args, this.ProjectIncomeOne7); //收入2 decimal projectIncomeTwo = GetDecimalFromArgs(args, this.ProjectIncomeTwo19); // 收入3 decimal projectIncomeThree = GetDecimalFromArgs(args, this.ProjectIncomeThree59); // 收入4 decimal projectIncomeFour = GetDecimalFromArgs(args, this.ProjectIncomeFour42); decimal MaterialCostSubtotal = GetDecimalFromArgs(args, this.MaterialCostSubtotal257); decimal ArtificialCostProject = GetDecimalFromArgs(args, this.ArtificialCostProject44); decimal ArtificialCostDesign = GetDecimalFromArgs(args, this.ArtificialCostDesign127); decimal TravelCostProject = GetDecimalFromArgs(args, this.TravelCostProject43); decimal TravelCostDesign = GetDecimalFromArgs(args, this.TravelCostDesign56); decimal ArtificialCostMO = GetDecimalFromArgs(args, this.ArtificialCostMO46); decimal ArtificialCostAssembly = GetDecimalFromArgs(args, this.ArtificialCostAssembly20); decimal FreightPackagFee = GetDecimalFromArgs(args, this.FreightPackagFee34); decimal MaterialCostSubtotalNo = GetDecimalFromArgs(args, this.MaterialCostSubtotalNo37); decimal FreightPackagFeeNo = GetDecimalFromArgs(args, this.FreightPackagFeeNo112); // ========== 项目总收入 =项目收入1+项目收入2+项目收入3+项目收入4 ========== SetClientValue(args, this.ProjectTotalIncome58, projectIncomeOne + projectIncomeTwo + projectIncomeThree + projectIncomeFour); // ========== 项目总成本（含税） =材料成本-小计（含税）+人工成本-工程+人工成本-设计+差旅费-工程+差旅费-设计+人工成本-生产+人工成本-装配+运费/包装费（含税） ========== SetClientValue(args, this.ProjectTotalCost61, MaterialCostSubtotal + ArtificialCostProject + ArtificialCostDesign + TravelCostProject + TravelCostDesign + ArtificialCostMO + ArtificialCostAssembly + FreightPackagFee); // ========== 项目总成本（不含税） =材料成本-小计（不含税）+人工成本-工程+人工成本-设计+差旅费-工程+差旅费-设计+人工成本-生产+人工成本-装配+运费/包装费（不含税） ========== SetClientValue(args, this.ProjectTotalCostNo43, MaterialCostSubtotalNo + ArtificialCostProject + ArtificialCostDesign + TravelCostProject + TravelCostDesign + ArtificialCostMO + ArtificialCostAssembly + FreightPackagFeeNo); return args; } /// /// 查询税率 /// /// /// <returns></returns> public string QueryTax(long id) { string sql = $"SELECT CBO_Tax.TaxRate FROM CBO_TaxScheduleTax LEFT JOIN CBO_TaxSchedule ON CBO_TaxScheduleTax.TaxSchedule = CBO_TaxSchedule.ID LEFT JOIN CBO_Tax ON CBO_TaxScheduleTax.Tax = CBO_Tax.ID WHERE CBO_TaxSchedule.ID = {id}"; DataSet ds; DataAccessor.RunSQL(DatabaseManager.GetCurrentConnection(), sql, null, out ds); return ds.Tables[0].Rows[0]["TaxRate"].ToString(); } /// /// 根据含税金额和税率控件，计算不含税金额，并设置到对应控件中 /// /// 回调参数对象，包含所有控件提交的数据 /// 含税金额控件 /// 税率ID控件 /// 要设置值的目标控件（不含税金额） private void ComputeNoTaxValue( CustomerActionEventArgs args, IUFFldNumberControl taxIncludedControls, IUFFldReference taxRateControl, IUFFldNumberControl taxIncludedNoControl) { // 页面上的含税值 string taxIncludedKey = taxIncludedControls.ClientID; // 页面上的税率值 string taxRateKey = taxRateControl.ClientID; //含税金额 decimal taxIncludedMoney = decimal.Parse(args.ArgsHash[taxIncludedKey].ToString()); //税组合ID long taxId = long.Parse(args.ArgsHash[taxRateKey].ToString()); if (taxId > 0) { string queryTax = QueryTax(taxId); // 返回 0.13 等 decimal taxRate = decimal.Parse(queryTax); decimal noTaxIncludedMoney = taxIncludedMoney / (1 + taxRate); SetClientValue(args, taxIncludedNoControl, noTaxIncludedMoney); } } /// /// 从 args.ArgsHash 中获取指定控件的 decimal 值 /// private decimal GetDecimalFromArgs(CustomerActionEventArgs args, IUFFldNumberControl ctrl) { var key = ctrl.ClientID; return args.ArgsHash.ContainsKey(key) && decimal.TryParse(args.ArgsHash[key]?.ToString(), out var val) ? val: 0m; } /// /// 生成设置客户端控件值的 JS 脚本 /// private void SetClientValue(CustomerActionEventArgs args, IUFControl target, decimal value) { args.ArgsResult.Add(new UFWebClientNumberAdapter(target).ClientInstance + $".set_Value('{value}')"); }
{callout color="#ef4d4d"}由于无法指定组织只能采取登录组织方式{/callout}dll名：AutoGenerateConfirmBillBPProxydll位置：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); }
select a.ID,a.Code,b.* from Base_Profile a left join Base_Profile_Trl b on a.ID=b.ID where a.Code like 'OAtemplate%'
DLL：UFIDA.U9.ISV.Supplier.Agent.dllDLL位置: 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.Proxydll：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; } }
create table #APDirectTmp (ID bigint, APStatementDirect int) -- 付款单据类型 insert into #APDirectTmp select A.[ID], A.[APStatementDirect] from AP_PayDocType as A create table #AccrueSupplierTmp (AccrueSupplierSite_ID bigint, Org_IsAuditOrg bit, Org_IsOperatingOrg bit, AccrueSupplier_ID bigint, AccrueSupplierSite_Territory_CombineName nvarchar(255), AccrueSupplier_CombineName nvarchar(255), AccrueSupplier_Territory_CombineName nvarchar(255), AccrueSupplier_Category_CombineName nvarchar(255), AccrueSupplier_Category_ID bigint, AccrueSupplier_Territory_ID bigint, AccrueSupplierSite_Territory_ID bigint) insert into #AccrueSupplierTmp select A.[ID] as [AccrueSupplierSite_ID], --供应商位置ID A2.[IsAuditOrg] as [Org_IsAuditOrg], --核算组织 A2.[IsOperatingOrg] as [Org_IsOperatingOrg], -- 营运组织 A1.[ID] as [AccrueSupplier_ID], -- 供应商ID A6.[CombineName] as [AccrueSupplierSite_Territory_CombineName],--地区名称 A7.[CombineName] as [AccrueSupplier_CombineName], --供应商名称 A8.[CombineName] as [AccrueSupplier_Territory_CombineName], --地区名称 A9.[CombineName] as [AccrueSupplier_Category_CombineName], --供应商分类名称 A3.[ID] as [AccrueSupplier_Category_ID], --供应商ID A4.[ID] as [AccrueSupplier_Territory_ID], --地区ID A5.[ID] as [AccrueSupplierSite_Territory_ID] --地区ID from CBO_SupplierSite as A -- 供应商位置 left join [CBO_Supplier] as A1 on (A.[Supplier] = A1.[ID]) -- 供应商 left join [Base_Organization] as A2 on (A1.[Org] = A2.[ID]) -- 组织 left join [CBO_SupplierCategory] as A3 on (A1.[Category] = A3.[ID]) -- 供应商分类 left join [Base_Territory] as A4 on (A1.[Territory] = A4.[ID]) -- 地区 left join [Base_Territory] as A5 on (A.[Territory] = A5.[ID]) -- 地区 left join [Base_Territory_Trl] as A6 on (A6.SysMlFlag = 'zh-CN') and (A5.[ID] = A6.[ID]) --地区TRl left join [CBO_Supplier_Trl] as A7 on (A7.SysMlFlag = 'zh-CN') and (A1.[ID] = A7.[ID]) -- 供应商TRL left join [Base_Territory_Trl] as A8 on (A8.SysMlFlag = 'zh-CN') and (A4.[ID] = A8.[ID]) --地区TRl left join [CBO_SupplierCategory_Trl] as A9 on (A9.SysMlFlag = 'zh-CN') and (A3.[ID] = A9.[ID]) --供应商分类TRL where (1 = 1) create table #PaySupplierTmp (PaySupplierSite_ID bigint, Org_IsAuditOrg bit, Org_IsOperatingOrg bit, PaySupplier_Code nvarchar(255), PaySupplier_ID bigint, PaySupplier_Name nvarchar(255), PaySupplierSite_Territory_CombineName nvarchar(255), PaySupplier_CombineName nvarchar(255), PaySupplier_Territory_CombineName nvarchar(255), PaySupplier_Category_CombineName nvarchar(255), PaySupplier_Category_ID bigint, PaySupplier_Territory_ID bigint, PaySupplierSite_Territory_ID bigint) insert into #PaySupplierTmp select A.[ID] as [PaySupplierSite_ID], --供应商位ID A2.[IsAuditOrg] as [Org_IsAuditOrg], --核算组织 A2.[IsOperatingOrg] as [Org_IsOperatingOrg], -- 营运组织 A1.[Code] as [PaySupplier_Code], --供应商编码 A1.[ID] as [PaySupplier_ID], --供应商ID A6.[Name] as [PaySupplier_Name], -- 供应商名称 A7.[CombineName] as [PaySupplierSite_Territory_CombineName], --地区名称 A6.[CombineName] as [PaySupplier_CombineName], -- 供应商名称 A8.[CombineName] as [PaySupplier_Territory_CombineName],--地区名称 A9.[CombineName] as [PaySupplier_Category_CombineName], --供应商分类名称 A3.[ID] as [PaySupplier_Category_ID], -- 供应商分类ID A4.[ID] as [PaySupplier_Territory_ID], -- 地区ID A5.[ID] as [PaySupplierSite_Territory_ID] -- 地区ID from CBO_SupplierSite as A --供应商位置 left join [CBO_Supplier] as A1 on (A.[Supplier] = A1.[ID]) -- 供应商 left join [Base_Organization] as A2 on (A1.[Org] = A2.[ID]) -- 组织 left join [CBO_SupplierCategory] as A3 on (A1.[Category] = A3.[ID]) -- 供应商分类 left join [Base_Territory] as A4 on (A1.[Territory] = A4.[ID]) -- 地区 left join [Base_Territory] as A5 on (A.[Territory] = A5.[ID]) -- 地区 left join [CBO_Supplier_Trl] as A6 on (A6.SysMlFlag = 'zh-CN') and (A1.[ID] = A6.[ID]) left join [Base_Territory_Trl] as A7 on (A7.SysMlFlag = 'zh-CN') and (A5.[ID] = A7.[ID]) left join [Base_Territory_Trl] as A8 on (A8.SysMlFlag = 'zh-CN') and (A4.[ID] = A8.[ID]) left join [CBO_SupplierCategory_Trl] as A9 on (A9.SysMlFlag = 'zh-CN') and (A3.[ID] = A9.[ID]) where ((1 = 1) and (A1.[Code] = N'1.006')) select A.[ID], A.[Code], A1.[Name], A.[APStatementDirect], '1' as [BillCategory] into #APDirectTempTable from AP_APDocType as A left join [AP_APDocType_Trl] as A1 on (A1.SysMlFlag = 'zh-CN') and (A.[ID] = A1.[ID]) insert into #APDirectTempTable select A.[ID], -- 付款单据类型ID A.[Code], -- 付款单据类型编码 A1.[Name], -- 付款单据类型名称 A.[APStatementDirect], --应付对账单方向 '0' as [BillCategory] from AR_ARDocType as A -- 付款单据类型 left join [AR_ARDocType_Trl] as A1 on (A1.SysMlFlag = 'zh-CN') and (A.[ID] = A1.[ID])-- 付款单据类型TRL create table #TempMXHZ (AccrueSupplierSite_ID bigint, PaySupplierSite_ID bigint, Dept_TreeDisplayName nvarchar(2000), Item_ID bigint, BC_Code nvarchar(50), BC_Name nvarchar(50), AP_BusinessType nvarchar(50), AP_DocumentType bigint, DocType_Code nvarchar(50), DocType_Name nvarchar(50), AccrueSupplier_CombineName nvarchar(255), AccrueSupplierSite_Territory_CombineName nvarchar(255), AccrueSupplier_Category_CombineName nvarchar(255), AccrueSupplier_Territory_CombineName nvarchar(255), PaySupplier_CombineName nvarchar(255), PaySupplierSite_Territory_CombineName nvarchar(255), PaySupplier_Category_CombineName nvarchar(255), PaySupplier_Territory_CombineName nvarchar(255), PaySupplier_Code nvarchar(255), PaySupplier_Name nvarchar(255), DescFlexField_CombineName nvarchar(4000), QCAmount decimal(24,9), QCACMoney decimal(24,9), QCFCMoney decimal(24,9), ARAmount decimal(24,9), ARACMoney decimal(24,9), ARFCMoney decimal(24,9), RecoverAmount decimal(24,9), RecoverACMoney decimal(24,9), RecoverFCMoney decimal(24,9), QMAmount decimal(24,9), QMACMoney decimal(24,9), QMFCMoney decimal(24,9), BCMoneyRound int, FCMoneyRound int, UOMMoneyRound int, BC_Symbol nvarchar(50), FC_Symbol nvarchar(50), PUom_Code nvarchar(50), PUom_Name nvarchar(50)) insert into #TempMXHZ select A.[AccrueSuppSite_SupplierSite] as [AccrueSupplierSite_ID], --供应商位置ID A.[PaySuppSite_SupplierSite] as [PaySupplierSite_ID], -- 付款供应商位置ID A18.[TreeDisplayName] as [Dept_TreeDisplayName], -- 部门名称 A.[Item_ItemID] as [Item_ID], -- 料品ID A10.[Code] as [BC_Code], -- 币种编码 A19.[Name] as [BC_Name], --单据币种名称 dbo.F_GetEnumName('UFIDA.U9.Base.Doc.BusinessTypeEnum',A.[BusinessType],'zh-CN') as [AP_BusinessType], --业务类型 A.[DocumentType] as [AP_DocumentType], -- 应付账已记账明细单据类型 A11.Code as [DocType_Code], -- 付款单据类型编码 A11.Name as [DocType_Name], -- -- 付款单据类型名称 null as [AccrueSupplier_CombineName], --应计供应商组合名称？ null as [AccrueSupplierSite_Territory_CombineName], --应计供应商位置组合名称？ null as [AccrueSupplier_Category_CombineName], --应计供应商联系人组合名称？ null as [AccrueSupplier_Territory_CombineName], -- 应计供应商地区组合名称？ isnull(A13.PaySupplier_CombineName,'') as [PaySupplier_CombineName], -- 付款供应商名称 isnull(A13.PaySupplierSite_Territory_CombineName,'') as [PaySupplierSite_Territory_CombineName], --付款供应商位置名称？ isnull(A13.PaySupplier_Category_CombineName,'') as [PaySupplier_Category_CombineName], --付款供应商联系人组合名称？ isnull(A13.PaySupplier_Territory_CombineName,'') as [PaySupplier_Territory_CombineName], -- 付款供应商地区组合名称？ A13.PaySupplier_Code as [PaySupplier_Code], --付款供应商编码 A13.PaySupplier_Name as [PaySupplier_Name], --付款供应商名称 null as [DescFlexField_CombineName], (A.[CRPUAmount] - A.[DRPUAmount]) as [QCAmount], --计价单位数量 - 计价单位数量 (A.[CROCMoney_TotalMoney] - A.[DROCMoney_TotalMoney]) as [QCACMoney], -- 核币总金额差额 (A.[CRFCMoney_TotalMoney] - A.[DRFCMoney_TotalMoney]) as [QCFCMoney], -- 本币总金额差额 0 as [ARAmount], 0 as [ARACMoney], 0 as [ARFCmoney], 0 as [RecoverAmount], 0 as [RecoverACMoney], 0 as [RecoverFCmoney], 0 as [QMAmount], 0 as [QMACMoney], 0 as [QMFCmoney], A16.[MoneyRound_Precision] as [BCMoneyRound], -- 单据币种金额精度 A17.[MoneyRound_Precision] as [FCMoneyRound], -- 本币币种金额精度 A15.[Round_Precision]as [UOMMoneyRound], -- 单位精度 A16.[Symbol] as [BC_Symbol], -- 单据币种货币符号 A17.[Symbol] as [FC_Symbol], --本币币种货币符号 A15.[Code] as [PUom_Code], -- 单位编码 A20.[Name] as [PUom_Name] -- 单位名称 from AP_APPostedDetail as A --应付账已记账明细 left join [CBO_Operators] as A1 on (A.[Transactor] = A1.[ID]) --业务员 left join [Base_Organization] as A2 on (A.[Org] = A2.[ID]) --组织 left join [Base_Organization] as A3 on (A.[SrcBusinessOrg] = A3.[ID]) --来源组织 left join [Base_Organization] as A4 on (A.[BizOrg] = A4.[ID]) --业务组织 left join [Base_Organization] as A5 on (A.[SettleOrg] = A5.[ID]) -- 结算组织 left join [CBO_Department] as A6 on (A.[Dept] = A6.[ID]) --部门 left join [CBO_Project] as A7 on (A.[Project] = A7.[ID]) --项目 left join [CBO_Task] as A8 on (A.[Task] = A8.[ID]) -- 任务 left join [Base_Currency] as A9 on (A.[FC] = A9.[ID]) --本币币种 left join [Base_Currency] as A10 on (A.[BC] = A10.[ID]) --单据币种 left join #APDirectTempTable as A11 on (A.[DocumentType] = A11.ID) -- 付款单据类型临时表 left join #AccrueSupplierTmp as A12 on (A.[AccrueSuppSite_SupplierSite] = A12.AccrueSupplierSite_ID) --供应商信息临时表 inner join #PaySupplierTmp as A13 on (A.[PaySuppSite_SupplierSite] = A13.PaySupplierSite_ID) -- 付款供应商信息临时表 left join Base_SOBAccountingPeriod as A14 on (A.[ProcessBillPeriod] = A14.[ID]) --账簿会计期间 left join Base_UOM as A15 on (A.[PUom] = A15.[ID]) --单位 left join Base_Currency as A16 on (A.[BC] = A16.[ID]) -- 单据币种 left join Base_Currency as A17 on (A.[FC] = A17.[ID]) -- 本币币种 left join [CBO_Department_Trl] as A18 on (A18.SysMlFlag = 'zh-CN') and (A6.[ID] = A18.[ID]) --部门TRL left join [Base_Currency_Trl] as A19 on (A19.SysMlFlag = 'zh-CN') and (A10.[ID] = A19.[ID]) -- 币种TRl left join [Base_UOM_Trl] as A20 on (A20.SysMlFlag = 'zh-CN') and (A15.[ID] = A20.[ID]) --单位TRL where (((((((1 = 1) and (A2.[Code] = N'10')) and (A.[PaySupp_Code] = N'1.006')) and (A.[IsSureAccrue] = 1)) and A.[DocStatus] in (2)) and (A14.[DisplayName] >= '2023-12')) and (A14.[DisplayName] <= '2024-12')) create table #TempMXCur (AccrueSupplierSite_ID bigint, PaySupplierSite_ID bigint, Dept_TreeDisplayName nvarchar(2000), Item_ID bigint, BC_Code nvarchar(50), BC_Name nvarchar(100), AP_BusinessType nvarchar(50), AP_DocumentType bigint, DocType_Code nvarchar(50), DocType_Name nvarchar(100), AccrueSupplier_CombineName nvarchar(255), AccrueSupplierSite_Territory_CombineName nvarchar(255), AccrueSupplier_Category_CombineName nvarchar(255), AccrueSupplier_Territory_CombineName nvarchar(255), PaySupplier_CombineName nvarchar(255), PaySupplierSite_Territory_CombineName nvarchar(255), PaySupplier_Category_CombineName nvarchar(255), PaySupplier_Territory_CombineName nvarchar(255), PaySupplier_Code nvarchar(255), PaySupplier_Name nvarchar(255), DescFlexField_CombineName nvarchar(4000), APStatementDirect int, OppAPStatementDirect int, CurAmount decimal(24,9), CurACMoney decimal(24,9), CurFCMoney decimal(24,9), BCMoneyRound int, FCMoneyRound int, UOMMoneyRound int, BC_Symbol nvarchar(50), FC_Symbol nvarchar(50), PUom_Code nvarchar(50), PUom_Name nvarchar(100)) create table #selectPeriod (ID bigint) --账簿会计期间ID insert into #selectPeriod select A.[ID] from Base_SOBAccountingPeriod as A where (((1 = 1) and (A.[DisplayName] >= '2025-01')) and (A.[DisplayName] <= '2025-01')) insert into #TempMXCur select A.[AccrueSuppSite_SupplierSite] as [AccrueSupplierSite_ID], --供应商位置ID A.[PaySuppSite_SupplierSite] as [PaySupplierSite_ID], -- 付款供应商位置ID A20.[TreeDisplayName] as [Dept_TreeDisplayName], -- 部门名称 A.[Item_ItemID] as [Item_ID], -- 料品ID A10.[Code] as [BC_Code], -- 单据币种编码 A21.[Name] as [BC_Name], -- 单据币种名称 dbo.F_GetEnumName('UFIDA.U9.Base.Doc.BusinessTypeEnum',A.[BusinessType],'zh-CN') as [AP_BusinessType], -- 业务类型 A.[DocumentType] as [AP_DocumentType], -- 应付账已记账明细单据类型 A11.Code as [DocType_Code], -- 付款单据类型编码 A11.Name as [DocType_Name], -- 付款单据类型名称 null as [AccrueSupplier_CombineName], null as [AccrueSupplierSite_Territory_CombineName], null as [AccrueSupplier_Category_CombineName], null as [AccrueSupplier_Territory_CombineName], isnull(A13.PaySupplier_CombineName,'') as [PaySupplier_CombineName], -- 付款供应商名称 isnull(A13.PaySupplierSite_Territory_CombineName,'') as [PaySupplierSite_Territory_CombineName], -- 付款供应商位置名称 isnull(A13.PaySupplier_Category_CombineName,'') as [PaySupplier_Category_CombineName],-- 付款供应商联系人组合名称 isnull(A13.PaySupplier_Territory_CombineName,'') as [PaySupplier_Territory_CombineName], -- 付款供应商地区组合名称 A13.PaySupplier_Code as [PaySupplier_Code], A13.PaySupplier_Name as [PaySupplier_Name], -- 付款供应商编码 null as [DescFlexField_CombineName], A14.APStatementDirect as [APStatementDirect], -- 付款供应商名称 A15.APStatementDirect as [OppAPStatementDirect], (A.[CRPUAmount] - A.[DRPUAmount]) as [CurAmount],-- 计价单位数量差额（计入数量 - 计出数量）） (A.[CROCMoney_TotalMoney] - A.[DROCMoney_TotalMoney]) as [CurACMoney], -- 核币总金额差额 (A.[CRFCMoney_TotalMoney] - A.[DRFCMoney_TotalMoney]) as [CurFCMoney], -- 本币总金额差额 A17.[MoneyRound_Precision] as [BCMoneyRound],-- 单据币种金额精度 A18.[MoneyRound_Precision] as [FCMoneyRound], -- 本币币种金额精度 A16.[Round_Precision] as [UOMMoneyRound], -- 单位精度 A17.[Symbol] as [BC_Symbol], -- 单据币种货币符号 A18.[Symbol] as [FC_Symbol], -- 本币币种货币符号 A16.[Code] as [PUom_Code], -- 单位编码 A22.[Name] as [PUom_Name] -- 单位名称 from AP_APPostedDetail as A -- 应付账已记账明细 left join [CBO_Operators] as A1 on (A.[Transactor] = A1.[ID]) -- 业务员 left join [Base_Organization] as A2 on (A.[Org] = A2.[ID]) -- 组织 left join [Base_Organization] as A3 on (A.[SrcBusinessOrg] = A3.[ID]) -- 来源组织 left join [Base_Organization] as A4 on (A.[BizOrg] = A4.[ID]) -- 业务组织 left join [Base_Organization] as A5 on (A.[SettleOrg] = A5.[ID]) -- 结算组织 left join [CBO_Department] as A6 on (A.[Dept] = A6.[ID]) -- 部门 left join [CBO_Project] as A7 on (A.[Project] = A7.[ID]) -- 项目 left join [CBO_Task] as A8 on (A.[Task] = A8.[ID]) -- 任务 left join [Base_Currency] as A9 on (A.[FC] = A9.[ID]) -- 本币币种 left join [Base_Currency] as A10 on (A.[BC] = A10.[ID]) -- 单据币种 left join #APDirectTempTable as A11 on (A.[DocumentType] = A11.ID) -- 付款单据类型临时表 left join #AccrueSupplierTmp as A12 on (A.[AccrueSuppSite_SupplierSite] = A12.AccrueSupplierSite_ID) -- 供应商信息临时表 inner join #PaySupplierTmp as A13 on (A.[PaySuppSite_SupplierSite] = A13.PaySupplierSite_ID) -- 付款供应商信息临时表 left join #APDirectTmp as A14 on (A.[DocumentType] = A14.ID) -- 应付账结算方向临时表 left join #APDirectTmp as A15 on (A.[OppDocType] = A15.ID) -- 应付账结算方向临时表 left join Base_UOM as A16 on (A.[PUom] = A16.[ID]) -- 单位 left join Base_Currency as A17 on (A.[BC] = A17.[ID]) -- 单据币种（用于金额精度和符号） left join Base_Currency as A18 on (A.[FC] = A18.[ID]) -- 本币币种（用于金额精度和符号） inner join #selectPeriod as A19 on (A.[ProcessBillPeriod] = A19.ID) -- 账簿会计期间筛选 left join [CBO_Department_Trl] as A20 on (A20.SysMlFlag = 'zh-CN') and (A6.[ID] = A20.[ID]) left join [Base_Currency_Trl] as A21 on (A21.SysMlFlag = 'zh-CN') and (A10.[ID] = A21.[ID]) left join [Base_UOM_Trl] as A22 on (A22.SysMlFlag = 'zh-CN') and (A16.[ID] = A22.[ID]) where (((((1 = 1) and (A2.[Code] = N'10')) and (A.[PaySupp_Code] = N'1.006')) and (A.[IsSureAccrue] = 1)) and A.[DocStatus] in (2)) insert into #TempMXHZ select A.AccrueSupplierSite_ID, -- 供应商位置ID A.PaySupplierSite_ID, -- 付款供应商位置ID A.Dept_TreeDisplayName,-- 部门名称 A.Item_ID, -- 料品ID A.BC_Code, -- 单据币种编码 A.BC_Name, -- 单据币种名称 A.AP_BusinessType, -- 业务类型 A.AP_DocumentType, -- 应付账已记账明细单据类型 A.DocType_Code,-- 付款单据类型编码 A.DocType_Name,-- 付款单据类型名称 A.AccrueSupplier_CombineName, -- 应计供应商组合名称？ A.AccrueSupplierSite_Territory_CombineName, -- 应计供应商位置组合名称？ A.AccrueSupplier_Category_CombineName, -- 应计供应商联系人组合名称？ A.AccrueSupplier_Territory_CombineName, -- 应计供应商地区组合名称？ A.PaySupplier_CombineName, -- 付款供应商名称 A.PaySupplierSite_Territory_CombineName, -- 付款供应商位置名称 A.PaySupplier_Category_CombineName,-- 付款供应商联系人组合名称 A.PaySupplier_Territory_CombineName, -- 付款供应商地区组合名称 A.PaySupplier_Code, A.PaySupplier_Name, -- 付款供应商编码 A.DescFlexField_CombineName, -- 付款供应商名称 0 as [QCAmount], 0 as [QCACMoney], 0 as [QCFCMoney], case when ((A.APStatementDirect = 0) and ((A.OppAPStatementDirect = 0) or A.OppAPStatementDirect is null)) then A.CurAmount else 0 end as [ARAmount], -- 应收数量：当应付账结算方向为正向（0）且对方结算方向为正向或为空时，取当前数量；否则为0 case when ((A.APStatementDirect = 0) and ((A.OppAPStatementDirect = 0) or A.OppAPStatementDirect is null)) then A.CurACMoney else 0 end as [ARACMoney], -- 应收核算币金额：同上条件取当前核算币金额；否则为0 case when ((A.APStatementDirect = 0) and ((A.OppAPStatementDirect = 0) or A.OppAPStatementDirect is null)) then A.CurFCMoney else 0 end as [ARFCMoney], -- 应收本币金额：同上条件取当前本币金额；否则为0 case when (not(((A.APStatementDirect = 0) and ((A.OppAPStatementDirect = 0) or A.OppAPStatementDirect is null)))) then (-(A.CurAmount)) else 0 end as [RecoverAmount], -- 数量：当应付账结算方向不符合上述条件时，取当前数量的负值；否则为0 case when (not(((A.APStatementDirect = 0) and ((A.OppAPStatementDirect = 0) or A.OppAPStatementDirect is null)))) then (-(A.CurACMoney)) else 0 end as [RecoverACMoney], -- 核算币金额：条件不满足时，取当前核算币金额的负值；否则为0 case when (not(((A.APStatementDirect = 0) and ((A.OppAPStatementDirect = 0) or A.OppAPStatementDirect is null)))) then (-(A.CurFCMoney)) else 0 end as [RecoverFCMoney],-- 本币金额：条件不满足时，取当前本币金额的负值；否则为0 0 as [QMAmount], 0 as [QMACMoney], 0 as [QMFCmoney], A.BCMoneyRound,-- 单据币种金额精度 A.FCMoneyRound, -- 本币币种金额精度 A.UOMMoneyRound, -- 单位精度 A.BC_Symbol, -- 单据币种货币符号 A.FC_Symbol, -- 本币币种货币符号 A.PUom_Code, -- 单位编码 A.PUom_Name -- 单位名称 from #TempMXCur as A -- 临时表 #TempMXCur 存储了当前期间的应付/应收数据 where ((A.CurACMoney != 0) or (A.CurFCMoney != 0))-- 仅返回当前核算币金额或本币金额不为0的记录 drop table #PaySupplierTmp select A.PaySupplier_Code, A.BC_Code, A.PaySupplier_Name, A.BC_Name, sum(A.QCACMoney) as [QCACMoney], max(A.BCMoneyRound) as [BCMoneyRound], A.BC_Symbol, sum(A.ARACMoney) as [ARACMoney], sum(A.RecoverACMoney) as [RecoverACMoney], sum(((A.QCACMoney + A.ARACMoney) - A.RecoverACMoney)) as [QMACMoney], sum(((A.QCFCMoney + A.ARFCMoney) - A.RecoverFCMoney)) as [QMFCMoney] into #TempGroupHZ from #TempMXHZ as A group by A.PaySupplier_Code, A.BC_Code, A.PaySupplier_Name, A.BC_Name, A.BC_Symbol select * from #TempGroupHZ as A where (1 = 1) order by A.PaySupplier_Code asc, A.PaySupplier_Name asc, A.BC_Name asc
⚠️ 注意事项 目前仅知道V60可用：BP名：RMAPushARBillBPProxy命名空间：UFIDA.U9.SM.RMA.Proxydll： C:\yonyou\U9V60\Portal\ApplicationServer\Libs\UFIDA.U9.SM.SMBP.Agent.dll示例代码RMA rma = RMA.Finder.Find( string.Format("DocNo = '{0}' and Org = {1}", "RMA1002932",Context.LoginOrg.ID)); if (rma.RMALines[0].DescFlexField == null || string.IsNullOrEmpty(rma.RMALines[0].DescFlexField.PrivateDescSeg2)) continue; RMAPushARBillBPProxy proxy = new RMAPushARBillBPProxy(); proxy.RMAKey = rma.Key.ID; proxy.BillingMode = rma.BillingMode.Value; proxy.RMALineKeys = new List<long>(); foreach (RMALine rmaRmaLine in rma.RMALines) { proxy.RMALineKeys.Add(rmaRmaLine.ID); } proxy.Do(); // 提交 ARBillSubmitBatchBPProxy arBillSubmitBatchBpProxy = new ARBillSubmitBatchBPProxy(); arBillSubmitBatchBpProxy.ARBillHeadDTOs = new List<IDSysVersionDTOData>(); // 查找来源退货单的应收单 ARBillHead arBillHead = ARBillHead.Finder.Find(string.Format("SrcBillID = '{0}'", rma.ID)); if (arBillHead != null) { IDSysVersionDTOData idSysVersionDtoData = new IDSysVersionDTOData(); idSysVersionDtoData.SysVer = arBillHead.SysVersion; idSysVersionDtoData.EntityID = arBillHead.ID; arBillSubmitBatchBpProxy.ARBillHeadDTOs.Add(idSysVersionDtoData); } arBillSubmitBatchBpProxy.Do(); // 审核 ARBillApproveBatchBPProxy arBillApproveBatchBpProxy = new ARBillApproveBatchBPProxy(); arBillApproveBatchBpProxy.ARBillHeadDTOs = new List<IDSysVersionDTOData>(); if (arBillHead != null) { IDSysVersionDTOData idSysVersionDtoData = new IDSysVersionDTOData(); idSysVersionDtoData.SysVer = arBillHead.SysVersion; idSysVersionDtoData.EntityID = arBillHead.ID; arBillApproveBatchBpProxy.ARBillHeadDTOs.Add(idSysVersionDtoData); } arBillApproveBatchBpProxy.Do();