update UBF_Job_Request set BPName=(select Local_ID from UBF_MD_Class where Name='BP名') where ID=(select ID from UBF_Job_Request where code='请求管理编码')
值集值查询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(); } } }
✅ 1. 什么是 Swap？Swap（交换空间） 是 Linux 系统中用于辅助物理内存（RAM）的一种虚拟内存。它在物理内存不足时，将部分数据临时存储在磁盘上的专用空间中，从而缓解内存压力，防止系统崩溃。物理内存（RAM）： 系统主要运行数据的临时存储区域，速度快。交换空间（Swap）： 当物理内存不足时，Linux 将部分数据换出到 Swap 中，释放 RAM 以供其他进程使用。✅ 作用防止内存溢出：当内存不够时，使用 Swap 避免程序崩溃。支持休眠：休眠时，RAM 数据写入到 Swap 中。系统性能优化：适当的 Swap 可提高系统稳定性。✅ 缺点速度慢：磁盘 I/O 速度远低于 RAM，频繁使用 Swap 会显著降低性能。磁盘磨损：在 SSD 上使用 Swap 可能会影响寿命。🔥 2. 查看当前 Swap 信息在 Linux 中，常用以下命令查看 Swap 使用情况：# 查看 Swap 使用情况 free -h # 查看 Swap 分区信息 swapon --show # 查看 Swap 空间大小和使用率 cat /proc/swaps # 使用 htop 查看内存和 Swap 信息 htop✅ 示例输出$ free -h total used free shared buff/cache available Mem: 7.8Gi 2.5Gi 4.3Gi 237Mi 1.0Gi 4.8Gi Swap: 2.0Gi 512Mi 1.5Gitotal：总内存大小。used：已使用的 Swap 空间。free：可用 Swap 空间。⚙️ 3. 创建 Swap 空间如果你的系统没有 Swap 分区或想要扩展 Swap 空间，可以手动创建：🛠️ 3.1 创建 Swap 文件1️⃣ 创建一个新的 Swap 文件sudo fallocate -l 2G /swapfile # 创建 2G Swap 文件 # 如果 fallocate 不支持，可以使用 dd 命令 # sudo dd if=/dev/zero of=/swapfile bs=1M count=20482️⃣ 设置正确权限sudo mkswap /swapfile3️⃣ 格式化为 Swap 格式sudo mkswap /swapfile4️⃣ 启用 Swap 文件sudo swapon /swapfile5️⃣ 验证 Swap 状态swapon --show✅ 示例输出NAME TYPE SIZE USED PRIO /swapfile file 2G 0B -26️⃣ 永久生效 将 Swap 文件添加到 /etc/fstab：echo '/swapfile swap swap defaults 0 0' | sudo tee -a /etc/fstab🛠️ 4. 调整 Swap 大小如果你想扩展或缩小现有的 Swap 空间：1️⃣ 禁用当前 Swapsudo swapoff /swapfile2️⃣ 调整 Swap 大小sudo fallocate -l 4G /swapfile # 扩展为 4G sudo chmod 600 /swapfile sudo mkswap /swapfile3️⃣ 重新启用sudo swapon /swapfile⚙️ 5. 删除 Swap 空间如果不再需要 Swap 文件，可以删除：1️⃣ 禁用 Swapsudo swapoff /swapfile2️⃣ 移除配置 编辑 /etc/fstab 文件，删除相关行：/swapfile swap swap defaults 0 03️⃣ 删除 Swap 文件sudo rm /swapfile🔧 6. 调优 Swap 设置Linux 使用 swappiness 参数控制内核在内存不足时使用 Swap 的倾向：0：尽量避免使用 Swap，仅在 RAM 不足时使用。1-100：数值越大，越倾向于使用 Swap。一般服务器推荐值：10-30桌面系统推荐值：60✅ 查看当前 swappinesscat /proc/sys/vm/swappiness✅ 临时修改 swappinesssudo sysctl vm.swappiness=10✅ 永久修改 swappiness 编辑 /etc/sysctl.conf：sudo nano /etc/sysctl.conf添加：vm.swappiness=10保存后生效：sudo sysctl -p📊 7. Swap 与性能优化建议服务器环境Swap 文件大小：物理内存的 1~2 倍。swappiness：10~30，减少对磁盘的依赖。桌面环境Swap 文件大小：等于物理内存大小。swappiness：60~80，保证内存溢出时不崩溃。特殊情况如果使用 SSD，尽量减少 Swap，以减少磁盘磨损。使用 ZRAM 压缩 Swap，提高性能：sudo apt install zram-tools sudo systemctl enable --now zramswap✅ 8. 总结Swap 是 Linux 系统在内存不足时使用的虚拟内存。你可以使用 Swap 分区或 Swap 文件。调整 swappiness 参数可优化系统性能。小心使用 Swap 于 SSD，避免频繁读写带来磁盘损耗。在性能敏感的服务器环境中，尽量减少 Swap 的使用。
1. RustDesk 简介RustDesk 是一款开源的远程桌面软件，支持 Windows、Linux、macOS、Android 和 iOS 平台。与 TeamViewer、AnyDesk 等远程控制软件类似，RustDesk 允许用户远程访问和管理计算机，但不同之处在于它支持私有化部署，可以自建服务器以确保数据的安全性和隐私性。2. 为什么选择 RustDesk 私有化部署？数据安全：远程连接数据存储在自己的服务器上，避免泄露风险。低成本：无需购买商业远程控制软件的许可证。高可控性：可以自定义服务器配置，满足企业级需求。3. RustDesk 私有化部署组件RustDesk 私有化部署涉及两个核心组件：HBBS（RustDesk Server）：用于管理客户端连接。HBBR（RustDesk Relay）：用于转发远程桌面数据。4. 服务器环境准备4.1 服务器要求操作系统：Linux（推荐 Ubuntu 20.04+ 或 CentOS 7+）CPU：双核及以上内存：2GB 及以上磁盘：10GB 以上网络：拥有公网 IP（如果服务器在内网，则需要配置端口映射）4.2 开放端口端口作用21115用于客户端注册（TCP）21116用于 ID 服务器（TCP）21117用于中继服务器（TCP/UDP）5. RustDesk 私有服务器部署5.1 下载 RustDesk 服务器端mkdir -p /opt/rustdesk && cd /opt/rustdesk wget https://github.com/rustdesk/rustdesk-server/releases/latest/download/hbbs wget https://github.com/rustdesk/rustdesk-server/releases/latest/download/hbbr chmod +x hbbs hbbr5.2 启动服务器启动 hbbr（中继服务器）nohup ./hbbr &启动 hbbs（ID 服务器）nohup ./hbbs -r <服务器IP>:21117 &示例：如果服务器 IP 为 192.168.1.100，则命令如下：nohup ./hbbs -r 192.168.1.100:21117 &6. 配置客户端使用私有服务器在客户端（Windows、Linux、macOS）上，需要配置 RustDesk 以使用自建服务器。6.1 Windows 客户端打开 RustDesk。点击 设置（Settings）。在 ID/Relay Server 中，输入服务器地址（如 192.168.1.100:21115）。关闭 RustDesk 并重新打开，即可使用私有服务器。6.2 Linux/macOS 客户端echo "192.168.1.100:21115" > ~/.config/rustdesk/server7. RustDesk 服务器后台运行与开机自启7.1 创建 Systemd 服务创建 hbbr 服务cat <<EOF | sudo tee /etc/systemd/system/hbbr.service [Unit] Description=RustDesk Relay Server After=network.target [Service] ExecStart=/opt/rustdesk/hbbr Restart=always User=root [Install] WantedBy=multi-user.target EOF创建 hbbs 服务cat <<EOF | sudo tee /etc/systemd/system/hbbs.service [Unit] Description=RustDesk ID Server After=network.target [Service] ExecStart=/opt/rustdesk/hbbs -r 192.168.1.100:21117 Restart=always User=root [Install] WantedBy=multi-user.target EOF7.2 启动服务并设置开机自启sudo systemctl daemon-reload sudo systemctl enable hbbr hbbs sudo systemctl start hbbr hbbs8. 验证部署8.1 检查服务是否运行sudo systemctl status hbbr hbbs如果输出显示 active (running)，说明服务已成功运行。8.2 测试远程连接在客户端 RustDesk 中输入目标设备的 ID。尝试远程连接。如果能成功连接，说明私有化部署成功。
GitLab 是一个功能强大的 DevOps 平台，集成了 Git 代码管理、CI/CD、代码审查等功能。本教程将介绍如何使用 Docker 在服务器上部署 GitLab。1. 先决条件一台运行 CentOS 7 的服务器已安装 Docker 和 Docker Compose至少 4GB 内存，推荐 8GB 以上端口 80、443 和 22 未被占用2. 拉取 GitLab 镜像首先，确保你的 Docker 运行正常，然后使用以下命令拉取 GitLab 官方镜像：sudo docker pull gitlab/gitlab-ce:latest3. 创建 GitLab 配置目录为了持久化 GitLab 数据，我们需要在主机上创建相应的目录：mkdir -p /srv/gitlab/{config,data,logs}4. 运行 GitLab 容器使用 Docker 运行 GitLab 容器：sudo docker run --detach \ --hostname gitlab.example.com \ --publish 80:80 --publish 443:443 --publish 22:22 \ --name gitlab \ --restart always \ --volume /srv/gitlab/config:/etc/gitlab \ --volume /srv/gitlab/data:/var/opt/gitlab \ --volume /srv/gitlab/logs:/var/log/gitlab \ gitlab/gitlab-ce:latest请将 gitlab.example.com 替换为你的实际域名。5. 配置 GitLab等待几分钟后，GitLab 将会启动。你可以通过 http://你的服务器IP 访问 GitLab。初次访问时，GitLab 会要求你设置管理员密码，设置完成后即可使用 root 用户登录。6. 配置 SMTP 发送邮件（可选）编辑 GitLab 配置文件：sudo vi /srv/gitlab/config/gitlab.rb找到并修改 SMTP 设置，例如使用 Gmail：gitlab_rails['smtp_enable'] = true gitlab_rails['smtp_address'] = "smtp.gmail.com" gitlab_rails['smtp_port'] = 587 gitlab_rails['smtp_user_name'] = "your-email@gmail.com" gitlab_rails['smtp_password'] = "your-email-password" gitlab_rails['smtp_domain'] = "gmail.com" gitlab_rails['smtp_authentication'] = "login" gitlab_rails['smtp_enable_starttls_auto'] = true保存后执行以下命令使配置生效：sudo docker restart gitlab7. 备份与恢复备份 GitLab 数据sudo docker exec -t gitlab gitlab-backup create备份文件将存储在 /srv/gitlab/data/backups/ 目录下。恢复 GitLab 数据sudo docker exec -t gitlab gitlab-backup restore BACKUP=备份文件名8. 停止与删除 GitLab如果你需要停止 GitLab，可以运行：sudo docker stop gitlab删除容器：sudo docker rm gitlab删除所有数据：sudo rm -rf /srv/gitlab9. 总结使用 Docker 部署 GitLab 具有快速、便捷、易于管理的特点。你可以通过修改 gitlab.rb 配置文件来自定义 GitLab 功能，同时可以结合 Docker Compose 进一步优化部署。如果你在部署过程中遇到问题，欢迎在评论区讨论！