SVN r322
SVN-Revision: r322
This commit is contained in:
@@ -34,7 +34,7 @@ namespace Lskj.ProductSched
|
||||
DynamicProductSchedModel moduleModel = new DynamicProductSchedModel(obj);
|
||||
main.Model = moduleModel;
|
||||
moduleModel.DataCaches = new Dictionary<object, Hashtable>();
|
||||
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))
|
||||
{
|
||||
|
||||
+31
-48
@@ -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
|
||||
this.splitLeftControl.ResumeLayout(f
|
||||
@@ -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;
|
||||
}
|
||||
/// <summary>
|
||||
/// 选中行改变时
|
||||
/// 单元格点击刷新当前行数据
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void OnBandedTopFocusedRowObjectChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowObjectChangedEventArgs e)
|
||||
private void OnBandedViewRowCellClick(object sender, RowCellClickEventArgs e)
|
||||
{
|
||||
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<BaseUserControl>().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);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取查询sql
|
||||
@@ -495,7 +539,7 @@ namespace Lskj.ProductiSched
|
||||
/// <param name="e"></param>
|
||||
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,6 +565,8 @@ namespace Lskj.ProductiSched
|
||||
bandedColumnList.AddRange(gridBand.Columns.Cast<BandedGridColumn>());
|
||||
}
|
||||
}
|
||||
if (bandedColumnList.Count > 0)
|
||||
{
|
||||
int perWidth = allWidth / bandedColumnList.Count;
|
||||
foreach (BandedGridColumn bandedGridColumn in bandedColumnList)
|
||||
{
|
||||
@@ -528,6 +574,7 @@ namespace Lskj.ProductiSched
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 水平滚动条改变时
|
||||
/// </summary>
|
||||
@@ -582,9 +629,13 @@ namespace Lskj.ProductiSched
|
||||
DataTable dataDayPlan = BaseImpl.GetDataTableResult(sqlValue);
|
||||
MergeMainDataWithDayPlan(dataMain, dataDayPlan, dateTime);
|
||||
bandGcTop.BandedView.GridControl.DataSource = dataMain;
|
||||
if (bandGcBottom.Visible)
|
||||
{
|
||||
DataTable bottomTab = BuildCTable(dataDetail, dataDayPlan, dateTime, 93);
|
||||
bandGcBottom.BandedView.GridControl.DataSource = bottomTab;
|
||||
}
|
||||
OnBandedViewRowCellClick(bandGcTop.BandedView, null);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取数据源缓存
|
||||
@@ -744,12 +795,14 @@ namespace Lskj.ProductiSched
|
||||
/// <returns></returns>
|
||||
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<string, List<DataRow>> dayPlanMap = new Dictionary<string, List<DataRow>>();
|
||||
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<DataRow>();
|
||||
@@ -769,7 +822,7 @@ namespace Lskj.ProductiSched
|
||||
Dictionary<string, Dictionary<string, decimal>> dataMap = new Dictionary<string, Dictionary<string, decimal>>();
|
||||
foreach (DataRow row in dataMain.Rows)
|
||||
{
|
||||
string key = row["keyvalue"].ToString();
|
||||
string key = row[topPrimaryKey].ToString();
|
||||
if (!dataMap.ContainsKey(key))
|
||||
{
|
||||
dataMap[key] = new Dictionary<string, decimal>();
|
||||
@@ -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;
|
||||
}
|
||||
/// <summary>
|
||||
/// 构建带日期的数据源
|
||||
/// </summary>
|
||||
/// <param name="focusedRow"></param>
|
||||
/// <param name="dataDayPlan"></param>
|
||||
/// <param name="startDate"></param>
|
||||
/// <returns></returns>
|
||||
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<string, List<DataRow>> dayPlanMap = new Dictionary<string, List<DataRow>>();
|
||||
foreach (DataRow row in dataDayPlan.Rows)
|
||||
{
|
||||
string billId = row[rightPrimaryKey].ToString();
|
||||
if (!dayPlanMap.ContainsKey(billId))
|
||||
{
|
||||
dayPlanMap[billId] = new List<DataRow>();
|
||||
}
|
||||
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<string, Dictionary<string, decimal>> dataMap = new Dictionary<string, Dictionary<string, decimal>>();
|
||||
string key = focusedRow[topPrimaryKey].ToString();
|
||||
if (!dataMap.ContainsKey(key))
|
||||
{
|
||||
dataMap[key] = new Dictionary<string, decimal>();
|
||||
}
|
||||
// **查找 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 日期对照
|
||||
/// </summary>
|
||||
/// <param name="date"></param>
|
||||
|
||||
Reference in New Issue
Block a user