From 74670f25e311baeb25aa81190e228596fcd5af03 Mon Sep 17 00:00:00 2001 From: 王 垚 <1402714037@qq.com> Date: 星期一, 01 二月 2021 16:53:16 +0800 Subject: [PATCH] 性能优化 更改为批量保存方式插入 --- src/BLL/Demo.BillView/PRD/ProCompleteAnalysisMateriel.cs | 93 ++++++++++++++++++++++++++++++++++++---------- 1 files changed, 72 insertions(+), 21 deletions(-) diff --git a/src/BLL/Demo.BillView/PRD/ProCompleteAnalysisMateriel.cs b/src/BLL/Demo.BillView/PRD/ProCompleteAnalysisMateriel.cs index 4b2e832..80c55bf 100644 --- a/src/BLL/Demo.BillView/PRD/ProCompleteAnalysisMateriel.cs +++ b/src/BLL/Demo.BillView/PRD/ProCompleteAnalysisMateriel.cs @@ -1,8 +1,11 @@ 锘縰sing Kingdee.BOS.App.Data; using Kingdee.BOS.Core.DynamicForm; using Kingdee.BOS.Core.DynamicForm.PlugIn; +using Kingdee.BOS.Core.DynamicForm.PlugIn.Args; + using Kingdee.BOS.Core.Metadata.EntityElement; using Kingdee.BOS.Orm.DataEntity; +using Kingdee.BOS.ServiceHelper; using Kingdee.BOS.Util; using System; using System.Collections.Generic; @@ -18,41 +21,89 @@ [HotUpdate] public class ProCompleteAnalysisMateriel : AbstractDynamicFormPlugIn { + bool did = false; + string FMatrailId = ""; public override void OnLoad(EventArgs e) { base.OnLoad(e); - - string FHMainICMOInterIDr = this.View.OpenParameter.GetCustomParameter("FHMainICMOInterIDr").ToString();//涓荤敓浜ц鍗曚富鍐呯爜 - //string FBillNo = this.View.OpenParameter.GetCustomParameter("FBillNo").ToString(); - string sql = string.Format(@"/*dialect*/select a.*,b.FBILLNO FBILLNOs from JIT_MOMaterReadysBill a + if (this.View.OpenParameter.GetCustomParameter("FHMainICMOInterIDr") == null) + { + SearchList(); + } + else + { + if (did) + return; + string FHMainICMOInterIDr = this.View.OpenParameter.GetCustomParameter("FHMainICMOInterIDr").ToString();//涓荤敓浜ц鍗曚富鍐呯爜 + FMatrailId = this.View.OpenParameter.GetCustomParameter("FMatrailId").ToString();//鐗╂枡 + string sql = string.Format(@"/*dialect*/select a.*,b.FBILLNO FBILLNOs from JIT_MOMaterReadysBill a left join T_PRD_MO b on a.FHMainICMOInterIDr=b.FID - where FHMainICMOInterIDr ='{0}' ", FHMainICMOInterIDr); - DataTable dt = DBUtils.ExecuteDataSet(this.Context, sql).Tables[0]; + where FCompleteCount1>0 and FHMATERID ='{0}'", FMatrailId); + DataTable dt = DBServiceHelper.ExecuteDataSet(this.Context, sql).Tables[0]; + if (dt.Rows.Count > 0) + { + for (int i = 0; i < dt.Rows.Count; i++) + { + this.Model.CreateNewEntryRow("FEntity"); + this.Model.SetValue("FSEQ", i + 1, i);//搴忓彿 + this.Model.SetValue("FMateralDetailId", dt.Rows[i]["FHMATERID"], i); + this.Model.SetValue("FScOrderNoDetail", dt.Rows[i]["FBILLNOs"], i);//鐢熶骇璁㈠崟鍙� + this.Model.SetValue("FOccupyCount", dt.Rows[i]["FCompleteCount1"], i);// + this.Model.SetValue("FCurrentCount", dt.Rows[i]["FHStockQty"], i);//褰撳墠搴撳瓨鎯呭喌 + this.Model.SetValue("FOrgId", dt.Rows[i]["FHStockOrgID"], i);//搴撳瓨缁勭粐 + this.Model.SetValue("FOwnerTypeId", dt.Rows[i]["FOwnerTypeId"], i);//璐т富绫诲瀷 + this.Model.SetValue("FOwnerId", dt.Rows[i]["FOwnerId"], i);//璐т富 + this.Model.SetValue("FPlanDate", dt.Rows[i]["FPlanDate"].ToString(), i);//鏃ヨ鍒掓棩鏈� + } + } + did = true; + } + } + + /// <summary> + /// 鏌ヨ浜嬩欢 + /// </summary> + public void SearchList() + { + string sqlwhere = " where FCompleteCount1>0 and 1=1"; + string sql = string.Format(@"/*dialect*/select a.*,b.FBILLNO FBILLNOs from JIT_MOMaterReadysBill a + left join T_PRD_MO b on a.FHMainICMOInterIDr=b.FID + "); + //鐢熶骇璁㈠崟鍙� + string PRDBillNo = Convert.ToString(this.Model.GetValue("FScOrderNo")); + if (!string.IsNullOrEmpty(PRDBillNo)) + sqlwhere += $" and FPRDBillNo='{PRDBillNo}'"; + if (FMatrailId != "") + sqlwhere += $" and FHMATERID='{FMatrailId}'"; + sql += sqlwhere; + DataTable dt = DBServiceHelper.ExecuteDataSet(this.Context, sql).Tables[0]; + this.Model.DeleteEntryData("FEntity"); if (dt.Rows.Count > 0) { for (int i = 0; i < dt.Rows.Count; i++) { - /* - 璁″垝鍙戞枡鏁伴噺 = 璁″垝鎬绘暟閲� * 鍗曚綅鐢ㄦ枡 - 榻愬鏁伴噺 = 榻愬鏁� * 鍗曚綅鐢ㄦ枡锛堣�冭檻鍒嗗眰绾�* 鐖剁骇锛� - 缂烘枡鏁伴噺 = 1 - 2 - 鏄惁榻愬 = 缂烘枡 < 0 ? - */ - decimal FPlanIssueCount = Convert.ToDecimal(dt.Rows[i]["FSumPlanCount"]) * Convert.ToDecimal(dt.Rows[i]["FUNITDOSAGE"]);//璁″垝鍙戞枡鏁伴噺 - decimal FCompleteCount = Convert.ToDecimal(dt.Rows[i]["FCompleteCount"]) * Convert.ToDecimal(dt.Rows[i]["FUNITDOSAGE"]);//榻愬鏁伴噺 - - decimal FLackCount = FPlanIssueCount - FCompleteCount;//缂烘枡鏁伴噺 this.Model.CreateNewEntryRow("FEntity"); this.Model.SetValue("FSEQ", i + 1, i);//搴忓彿 this.Model.SetValue("FMateralDetailId", dt.Rows[i]["FHMATERID"], i); - this.Model.SetValue("FScOrderNoDetail", dt.Rows[i]["FBILLNOs"], i);//鐢熶骇璁㈠崟鍙� - this.Model.SetValue("FOccupyCount", FCompleteCount, i);// + this.Model.SetValue("FScOrderNoDetail", dt.Rows[i]["FBILLNOs"], i);//鐢熶骇璁㈠崟鍙� + this.Model.SetValue("FOccupyCount", dt.Rows[i]["FCompleteCount1"], i);// this.Model.SetValue("FCurrentCount", dt.Rows[i]["FHStockQty"], i);//褰撳墠搴撳瓨鎯呭喌 + this.Model.SetValue("FOrgId", dt.Rows[i]["FHStockOrgID"], i);//搴撳瓨缁勭粐 + this.Model.SetValue("FOwnerTypeId", dt.Rows[i]["FOwnerTypeId"], i);//璐т富绫诲瀷 + this.Model.SetValue("FOwnerId", dt.Rows[i]["FOwnerId"], i);//璐т富 + this.Model.SetValue("FPlanDate", dt.Rows[i]["FPlanDate"].ToString(), i);//鏃ヨ鍒掓棩鏈� } } + this.View.UpdateView(); + did = true; } - - - + public override void BarItemClick(BarItemClickEventArgs e) + { + base.BarItemClick(e); + if (e.BarItemKey.ToUpper() == "TBFILTER") + { + SearchList(); + } + } } } -- Gitblit v1.9.1