From ecdfbd6893582fdd9c581e97f027314c51089e02 Mon Sep 17 00:00:00 2001 From: tdx Date: Fri, 14 Mar 2025 06:20:05 +0000 Subject: [PATCH] SVN r322 SVN-Revision: r322 --- 插件库/Lskj.ProductSched/DllBaseClass.cs | 2 +- .../FrmProductSched.Designer.cs | 79 ++++----- 插件库/Lskj.ProductSched/FrmProductSched.cs | 153 +++++++++++++++--- 3 files changed, 167 insertions(+), 67 deletions(-) diff --git a/插件库/Lskj.ProductSched/DllBaseClass.cs b/插件库/Lskj.ProductSched/DllBaseClass.cs index 5429cc6..30fe7a9 100644 --- a/插件库/Lskj.ProductSched/DllBaseClass.cs +++ b/插件库/Lskj.ProductSched/DllBaseClass.cs @@ -34,7 +34,7 @@ namespace Lskj.ProductSched DynamicProductSchedModel moduleModel = new DynamicProductSchedModel(obj); main.Model = moduleModel; moduleModel.DataCaches = new Dictionary(); - if (SystemInfo.Instance.OptimizationSpeed) main.GetDataCaches(moduleModel.DataCaches); + //if (SystemInfo.Instance.OptimizationSpeed) main.GetDataCaches(moduleModel.DataCaches); GridEnum gridEnum = GridEnum.GridView; if (!moduleModel.DataCaches.GetValue(main, "FormType", out int formType)) { diff --git a/插件库/Lskj.ProductSched/FrmProductSched.Designer.cs b/插件库/Lskj.ProductSched/FrmProductSched.Designer.cs index 201f727..f8fa108 100644 --- a/插件库/Lskj.ProductSched/FrmProductSched.Designer.cs +++ b/插件库/Lskj.ProductSched/FrmProductSched.Designer.cs @@ -32,14 +32,13 @@ namespace Lskj.ProductiSched this.pl_main = new DevExpress.XtraEditors.PanelControl(); this.splitMainControl = new DevExpress.XtraEditors.SplitContainerControl(); this.splitLeftControl = new DevExpress.XtraEditors.SplitContainerControl(); - this.bandGcTop = new Lskj.Control.BandedGridControlEx(); this.bandGcBottom = new Lskj.Control.BandedGridControlEx(); + this.gcRight = new Lskj.Control.GridControlEx(); this.pl_mainSearch = new DevExpress.XtraEditors.PanelControl(); this.pl_search = new DevExpress.XtraEditors.PanelControl(); this.flowLayoutPanel = new System.Windows.Forms.FlowLayoutPanel(); - this.gcRight = new Lskj.Control.GridControlEx(); - this.pl_left = new DevExpress.XtraEditors.PanelControl(); this.btnSave = new DevExpress.XtraEditors.SimpleButton(); + this.bandGcTop = new Lskj.Control.BandedGridControlEx(); ((System.ComponentModel.ISupportInitialize)(this.pl_main)).BeginInit(); this.pl_main.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.splitMainControl)).BeginInit(); @@ -50,7 +49,6 @@ namespace Lskj.ProductiSched this.pl_mainSearch.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.pl_search)).BeginInit(); this.flowLayoutPanel.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.pl_left)).BeginInit(); this.SuspendLayout(); // // pl_main @@ -75,7 +73,6 @@ namespace Lskj.ProductiSched this.splitMainControl.Panel1.Controls.Add(this.splitLeftControl); this.splitMainControl.Panel1.Text = "Panel1"; this.splitMainControl.Panel2.Controls.Add(this.gcRight); - this.splitMainControl.Panel2.Controls.Add(this.pl_left); this.splitMainControl.Panel2.Text = "Panel2"; this.splitMainControl.Size = new System.Drawing.Size(1317, 679); this.splitMainControl.SplitterPosition = 997; @@ -90,37 +87,37 @@ namespace Lskj.ProductiSched this.splitLeftControl.Margin = new System.Windows.Forms.Padding(2); this.splitLeftControl.Name = "splitLeftControl"; this.splitLeftControl.Panel1.Controls.Add(this.bandGcTop); + this.splitLeftControl.Panel1.Controls.Add(this.pl_mainSearch); this.splitLeftControl.Panel1.Text = "Panel1"; this.splitLeftControl.Panel2.Controls.Add(this.bandGcBottom); - this.splitLeftControl.Panel2.Controls.Add(this.pl_mainSearch); this.splitLeftControl.Panel2.Text = "Panel2"; this.splitLeftControl.Size = new System.Drawing.Size(997, 679); this.splitLeftControl.SplitterPosition = 353; this.splitLeftControl.TabIndex = 7; this.splitLeftControl.Text = "splitContainerControl2"; // - // bandGcTop - // - this.bandGcTop.AdapterObj = null; - this.bandGcTop.Dock = System.Windows.Forms.DockStyle.Fill; - this.bandGcTop.Location = new System.Drawing.Point(0, 0); - this.bandGcTop.Margin = new System.Windows.Forms.Padding(4); - this.bandGcTop.Name = "bandGcTop"; - this.bandGcTop.SiftEnumObj = Lskj.Control.GridControlEx.HeaderSiftEnum.Sum; - this.bandGcTop.Size = new System.Drawing.Size(997, 353); - this.bandGcTop.TabIndex = 0; - // // bandGcBottom // this.bandGcBottom.AdapterObj = null; this.bandGcBottom.Dock = System.Windows.Forms.DockStyle.Fill; - this.bandGcBottom.Location = new System.Drawing.Point(0, 33); + this.bandGcBottom.Location = new System.Drawing.Point(0, 0); this.bandGcBottom.Margin = new System.Windows.Forms.Padding(4); this.bandGcBottom.Name = "bandGcBottom"; this.bandGcBottom.SiftEnumObj = Lskj.Control.GridControlEx.HeaderSiftEnum.Sum; - this.bandGcBottom.Size = new System.Drawing.Size(997, 288); + this.bandGcBottom.Size = new System.Drawing.Size(997, 321); this.bandGcBottom.TabIndex = 12; // + // gcRight + // + this.gcRight.AdapterObj = null; + this.gcRight.Dock = System.Windows.Forms.DockStyle.Fill; + this.gcRight.Location = new System.Drawing.Point(0, 0); + this.gcRight.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.gcRight.Name = "gcRight"; + this.gcRight.SiftEnumObj = Lskj.Control.GridControlEx.HeaderSiftEnum.Sum; + this.gcRight.Size = new System.Drawing.Size(315, 679); + this.gcRight.TabIndex = 11; + // // pl_mainSearch // this.pl_mainSearch.Appearance.BackColor = System.Drawing.Color.Transparent; @@ -128,12 +125,12 @@ namespace Lskj.ProductiSched this.pl_mainSearch.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder; this.pl_mainSearch.Controls.Add(this.pl_search); this.pl_mainSearch.Controls.Add(this.flowLayoutPanel); - this.pl_mainSearch.Dock = System.Windows.Forms.DockStyle.Top; - this.pl_mainSearch.Location = new System.Drawing.Point(0, 0); + this.pl_mainSearch.Dock = System.Windows.Forms.DockStyle.Bottom; + this.pl_mainSearch.Location = new System.Drawing.Point(0, 320); this.pl_mainSearch.LookAndFeel.UseDefaultLookAndFeel = false; this.pl_mainSearch.Name = "pl_mainSearch"; this.pl_mainSearch.Size = new System.Drawing.Size(997, 33); - this.pl_mainSearch.TabIndex = 11; + this.pl_mainSearch.TabIndex = 12; // // pl_search // @@ -158,29 +155,6 @@ namespace Lskj.ProductiSched this.flowLayoutPanel.TabIndex = 13; this.flowLayoutPanel.WrapContents = false; // - // gcRight - // - this.gcRight.AdapterObj = null; - this.gcRight.Dock = System.Windows.Forms.DockStyle.Fill; - this.gcRight.Location = new System.Drawing.Point(0, 0); - this.gcRight.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); - this.gcRight.Name = "gcRight"; - this.gcRight.SiftEnumObj = Lskj.Control.GridControlEx.HeaderSiftEnum.Sum; - this.gcRight.Size = new System.Drawing.Size(315, 641); - this.gcRight.TabIndex = 11; - // - // pl_left - // - this.pl_left.Appearance.BackColor = System.Drawing.Color.Transparent; - this.pl_left.Appearance.Options.UseBackColor = true; - this.pl_left.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder; - this.pl_left.Dock = System.Windows.Forms.DockStyle.Bottom; - this.pl_left.Location = new System.Drawing.Point(0, 641); - this.pl_left.LookAndFeel.UseDefaultLookAndFeel = false; - this.pl_left.Name = "pl_left"; - this.pl_left.Size = new System.Drawing.Size(315, 38); - this.pl_left.TabIndex = 10; - // // btnSave // this.btnSave.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); @@ -192,6 +166,17 @@ namespace Lskj.ProductiSched this.btnSave.TabIndex = 40; this.btnSave.Text = "保存(&S)"; // + // bandGcTop + // + this.bandGcTop.AdapterObj = null; + this.bandGcTop.Dock = System.Windows.Forms.DockStyle.Fill; + this.bandGcTop.Location = new System.Drawing.Point(0, 0); + this.bandGcTop.Margin = new System.Windows.Forms.Padding(4); + this.bandGcTop.Name = "bandGcTop"; + this.bandGcTop.SiftEnumObj = Lskj.Control.GridControlEx.HeaderSiftEnum.Sum; + this.bandGcTop.Size = new System.Drawing.Size(997, 320); + this.bandGcTop.TabIndex = 13; + // // FrmProductSched // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); @@ -204,6 +189,4 @@ namespace Lskj.ProductiSched ((System.ComponentModel.ISupportInitialize)(this.splitMainControl)).EndInit(); this.splitMainControl.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.splitLeftControl)).EndInit(); - this.splitLeftControl.ResumeLayout(false); - ((System.ComponentModel.ISupportInitialize)(this.pl_mainSearch)).EndInit(); - this.pl_mainSearch.ResumeLayout(fals \ No newline at end of file + this.splitLeftControl.ResumeLayout(f \ No newline at end of file diff --git a/插件库/Lskj.ProductSched/FrmProductSched.cs b/插件库/Lskj.ProductSched/FrmProductSched.cs index d84960e..894995b 100644 --- a/插件库/Lskj.ProductSched/FrmProductSched.cs +++ b/插件库/Lskj.ProductSched/FrmProductSched.cs @@ -66,13 +66,14 @@ namespace Lskj.ProductiSched DataTable detailsTab = BaseModuleImpl.GetBaseDetailPages(DataModel.TopSysModel.ModuleCode); if (detailsTab != null) { - if (detailsTab.Rows.Count > 0) + if (detailsTab.Rows.Count > 1) { string moduleCode = detailsTab.Rows[0]["unionModule"] + ""; DataModel.BottomDetailModel = new GridDetailModel(detailsTab.Rows[0], null, GridCustomColumnStruct.BaseDetailGridView); DataModel.BottomSysModel = new DynamicModel(new string[] { DataModel.TopSysModel.FormText, DataModel.TopSysModel.UserId, DataModel.TopSysModel.UserName, DataModel.TopSysModel.Privilege, moduleCode }); DataRow sysRow = MainImpl.GetSystemdllTab(DataModel.BottomSysModel.ModuleCode); DataModel.BottomModuleModel = new ModuleModel(sysRow); + DataModel.BottomModuleModel.ParmaryKey = BaseImpl.GetBasePrimaryKey(DataModel.BottomSysModel.ModuleCode); DataModel.BottomGridColumns = BaseModuleImpl.GetBaseGridColumns(DataModel.BottomSysModel.ModuleCode); DataModel.BottomRightMenus = BaseModuleImpl.GetBaseGridRightMenus(DataModel.TopModuleModel.FormKey); DataModel.BottomRowColors = BaseModuleImpl.GetBaseGridRowColors(DataModel.TopModuleModel.FormKey); @@ -84,6 +85,19 @@ namespace Lskj.ProductiSched DataModel.RightSysModel = new DynamicModel(new string[] { DataModel.TopSysModel.FormText, DataModel.TopSysModel.UserId, DataModel.TopSysModel.UserName, DataModel.TopSysModel.Privilege, moduleCode }); DataRow sysRow = MainImpl.GetSystemdllTab(DataModel.RightSysModel.ModuleCode); DataModel.RightModuleModel = new ModuleModel(sysRow); + DataModel.RightModuleModel.ParmaryKey = BaseImpl.GetBasePrimaryKey(DataModel.RightSysModel.ModuleCode); + DataModel.RightGridColumns = BaseModuleImpl.GetBaseGridColumns(DataModel.RightSysModel.ModuleCode); + DataModel.RightRightMenus = BaseModuleImpl.GetBaseGridRightMenus(DataModel.TopModuleModel.FormKey); + DataModel.RightRowColors = BaseModuleImpl.GetBaseGridRowColors(DataModel.TopModuleModel.FormKey); + } + else + { + string moduleCode = detailsTab.Rows[0]["unionModule"] + ""; + DataModel.RightDetailModel = new GridDetailModel(detailsTab.Rows[0], null, GridCustomColumnStruct.BaseDetailGridView); + DataModel.RightSysModel = new DynamicModel(new string[] { DataModel.TopSysModel.FormText, DataModel.TopSysModel.UserId, DataModel.TopSysModel.UserName, DataModel.TopSysModel.Privilege, moduleCode }); + DataRow sysRow = MainImpl.GetSystemdllTab(DataModel.RightSysModel.ModuleCode); + DataModel.RightModuleModel = new ModuleModel(sysRow); + DataModel.RightModuleModel.ParmaryKey = BaseImpl.GetBasePrimaryKey(DataModel.RightSysModel.ModuleCode); DataModel.RightGridColumns = BaseModuleImpl.GetBaseGridColumns(DataModel.RightSysModel.ModuleCode); DataModel.RightRightMenus = BaseModuleImpl.GetBaseGridRightMenus(DataModel.TopModuleModel.FormKey); DataModel.RightRowColors = BaseModuleImpl.GetBaseGridRowColors(DataModel.TopModuleModel.FormKey); @@ -115,8 +129,12 @@ namespace Lskj.ProductiSched bandGcTop.SetGridRightMenus(BaseModuleImpl.GetBaseGridRightMenus(DataModel.TopModuleModel.FormKey), DataModel.TopSysModel); bandGcTop.SetGridRowColors(BaseModuleImpl.GetBaseGridRowColors(DataModel.TopModuleModel.FormKey)); AddDataColumns(bandGcTop); + if (DataModel.TopModuleModel.HasReport) + { + flowLayoutPanel.Visible = false; + } //下方表格 - if (!string.IsNullOrEmpty(DataModel.BottomSysModel.ModuleCode)) + if (DataModel.BottomSysModel != null && !string.IsNullOrEmpty(DataModel.BottomSysModel.ModuleCode)) { bandGcBottom.Model = DataModel.BottomSysModel; bandGcBottom.SetEditColumns(DataModel.BottomGridColumns, GridCustomColumnStruct.BaseMainGridView + DataModel.BottomModuleModel.FormKey); @@ -134,6 +152,10 @@ namespace Lskj.ProductiSched bandGcBottom.BandedView.OptionsBehavior.Editable = false; OnBandedViewColumnWidthChanged(bandGcTop.BandedView, null); } + else + { + splitLeftControl.PanelVisibility = DevExpress.XtraEditors.SplitPanelVisibility.Panel1; + } //右侧表格 if (!string.IsNullOrEmpty(DataModel.RightSysModel.ModuleCode)) { @@ -156,7 +178,7 @@ namespace Lskj.ProductiSched bandGcTop.BandedView.ColumnWidthChanged += OnBandedViewColumnWidthChanged; bandGcTop.BandedView.LeftCoordChanged += OnBandedViewLeftCoordChanged; bandGcBottom.BandedView.LeftCoordChanged += OnBandedViewLeftCoordChanged; - bandGcTop.BandedView.FocusedRowObjectChanged += OnBandedTopFocusedRowObjectChanged; + bandGcTop.BandedView.RowCellClick += OnBandedViewRowCellClick; bandGcTop.BandedView.KeyDown += OnBandedViewKeyDown; bandGcTop.BandedView.CustomDrawFooterCell += OnCustomDrawFooterCell; bandGcTop.BandedView.CustomDrawColumnHeader += OnCustomDrawColumnHeader; @@ -445,16 +467,38 @@ namespace Lskj.ProductiSched return result; } /// - /// 选中行改变时 + /// 单元格点击刷新当前行数据 /// /// /// - private void OnBandedTopFocusedRowObjectChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowObjectChangedEventArgs e) + private void OnBandedViewRowCellClick(object sender, RowCellClickEventArgs e) { - GridDetailModel model = DataModel.RightDetailModel; - DataRow rowItem = bandGcTop.BandedView.GetFocusedDataRow(); - string searchSql = this.GetSearchSql(model, rowItem, false); - gcRight.SetGridViewDataSource(BaseImpl.GetDataTableResult(searchSql)); + try + { + GridDetailModel model = DataModel.RightDetailModel; + DataRow rowItem = bandGcTop.BandedView.GetFocusedDataRow(); + if (rowItem != null) + { + string searchSql = this.GetSearchSql(model, rowItem, false); + gcRight.SetGridViewDataSource(BaseImpl.GetDataTableResult(searchSql)); + if (e != null) + { + BaseUserControl baseUserControl = DataModel.TopSearchObj.ParentPanel.Controls.Cast().Where(n => n is LabelDateEdit).FirstOrDefault(); + if (baseUserControl != null) + { + LabelDateEdit labelDateEdit = baseUserControl as LabelDateEdit; + DateTime dateTime = labelDateEdit.TextEdit.DateTime; + DataRow focusedRow = bandGcTop.BandedView.GetFocusedDataRow(); + DataTable dataDayPlan = gcRight.GridControl.DataSourceTable().Copy(); + UpdateRowWithDayPlan(focusedRow, dataDayPlan, dateTime); + } + } + } + } + catch (Exception ex) + { + Console.WriteLine(ex.Message); + } } /// /// 获取查询sql @@ -495,7 +539,7 @@ namespace Lskj.ProductiSched /// private void OnBandedViewColumnWidthChanged(object sender, EventArgs e) { - if (sender == bandGcTop.BandedView) + if (sender == bandGcTop.BandedView && bandGcBottom.Visible) { int allWidth = 0; foreach (GridBand gridBand in bandGcTop.BandedView.Bands) @@ -521,10 +565,13 @@ namespace Lskj.ProductiSched bandedColumnList.AddRange(gridBand.Columns.Cast()); } } - int perWidth = allWidth / bandedColumnList.Count; - foreach (BandedGridColumn bandedGridColumn in bandedColumnList) + if (bandedColumnList.Count > 0) { - bandedGridColumn.Width = perWidth; + int perWidth = allWidth / bandedColumnList.Count; + foreach (BandedGridColumn bandedGridColumn in bandedColumnList) + { + bandedGridColumn.Width = perWidth; + } } } } @@ -582,8 +629,12 @@ namespace Lskj.ProductiSched DataTable dataDayPlan = BaseImpl.GetDataTableResult(sqlValue); MergeMainDataWithDayPlan(dataMain, dataDayPlan, dateTime); bandGcTop.BandedView.GridControl.DataSource = dataMain; - DataTable bottomTab = BuildCTable(dataDetail, dataDayPlan, dateTime, 93); - bandGcBottom.BandedView.GridControl.DataSource = bottomTab; + if (bandGcBottom.Visible) + { + DataTable bottomTab = BuildCTable(dataDetail, dataDayPlan, dateTime, 93); + bandGcBottom.BandedView.GridControl.DataSource = bottomTab; + } + OnBandedViewRowCellClick(bandGcTop.BandedView, null); } } /// @@ -744,12 +795,14 @@ namespace Lskj.ProductiSched /// private DataTable MergeMainDataWithDayPlan(DataTable dataMain, DataTable dataDayPlan, DateTime startDate) { + string rightPrimaryKey = DataModel.RightModuleModel.ParmaryKey; + string topPrimaryKey = DataModel.TopModuleModel.ParmaryKey; DateTime endDate = startDate.AddMonths(3).AddDays(-1); // 计算结束日期 // **1. 预索引 dataDayPlan 数据(billdocument_id -> 该 key 相关的所有行)** Dictionary> dayPlanMap = new Dictionary>(); foreach (DataRow row in dataDayPlan.Rows) { - string billId = row["billdocument_id"].ToString(); + string billId = row[rightPrimaryKey].ToString(); if (!dayPlanMap.ContainsKey(billId)) { dayPlanMap[billId] = new List(); @@ -769,7 +822,7 @@ namespace Lskj.ProductiSched Dictionary> dataMap = new Dictionary>(); foreach (DataRow row in dataMain.Rows) { - string key = row["keyvalue"].ToString(); + string key = row[topPrimaryKey].ToString(); if (!dataMap.ContainsKey(key)) { dataMap[key] = new Dictionary(); @@ -794,7 +847,7 @@ namespace Lskj.ProductiSched // **4. 一次性填充 DataTable(避免逐行赋值带来的性能问题)** foreach (DataRow row in dataMain.Rows) { - string key = row["keyvalue"].ToString(); + string key = row[topPrimaryKey].ToString(); if (dataMap.ContainsKey(key)) { foreach (var col in dataMap[key]) @@ -806,6 +859,70 @@ namespace Lskj.ProductiSched return dataMain; } /// + /// 构建带日期的数据源 + /// + /// + /// + /// + /// + private void UpdateRowWithDayPlan(DataRow focusedRow, DataTable dataDayPlan, DateTime startDate) + { + string rightPrimaryKey = DataModel.RightModuleModel.ParmaryKey; + string topPrimaryKey = DataModel.TopModuleModel.ParmaryKey; + DateTime endDate = startDate.AddMonths(3).AddDays(-1); // 计算结束日期 + // **1. 预索引 dataDayPlan 数据(billdocument_id -> 该 key 相关的所有行)** + Dictionary> dayPlanMap = new Dictionary>(); + foreach (DataRow row in dataDayPlan.Rows) + { + string billId = row[rightPrimaryKey].ToString(); + if (!dayPlanMap.ContainsKey(billId)) + { + dayPlanMap[billId] = new List(); + } + dayPlanMap[billId].Add(row); + } + // **2. 预构建主数据的列** + for (DateTime dt = startDate; dt <= endDate; dt = dt.AddDays(1)) + { + string colName = dt.ToString("yyyy-MM-dd"); + if (!focusedRow.Table.Columns.Contains(colName)) + { + focusedRow.Table.Columns.Add(colName, typeof(decimal)); // 确保列存在 + } + } + // **3. 预构建数据填充映射表** + Dictionary> dataMap = new Dictionary>(); + string key = focusedRow[topPrimaryKey].ToString(); + if (!dataMap.ContainsKey(key)) + { + dataMap[key] = new Dictionary(); + } + // **查找 key 关联的时间数据** + if (dayPlanMap.ContainsKey(key)) + { + foreach (DataRow dayRow in dayPlanMap[key]) + { + if (dayRow["day"] != DBNull.Value) + { + DateTime dayValue = Convert.ToDateTime(dayRow["day"]); + string colName = dayValue.ToString("yyyy-MM-dd"); + if (dayValue >= startDate && dayValue <= endDate && focusedRow.Table.Columns.Contains(colName)) + { + dataMap[key][colName] = Convert.ToDecimal(dayRow["amount"]); + } + } + } + } + // **4. 一次性填充 DataTable(避免逐行赋值带来的性能问题)** + if (dataMap.ContainsKey(key)) + { + foreach (var col in dataMap[key]) + { + focusedRow[col.Key] = col.Value; + } + } + } + /// /// 日期对照 /// ///