From b3a0193a38ff6d17762395a784d7d66e501a9365 Mon Sep 17 00:00:00 2001 From: fly-l <1420031550@qq.com> Date: Mon, 30 Oct 2023 10:40:53 +0800 Subject: [PATCH] 2023-10-30 --- SGGL/BLL/BLL.csproj | 1 + SGGL/BLL/Common/Const.cs | 4 +- SGGL/BLL/Common/MultiHeaderTable.cs | 142 +++++++++++++++++ .../PhtglContracttrackService .cs | 97 ++++++------ ...踪导入模板.xlsx => 合同价格信息导入模板.xlsx} | Bin .../ContractTrackComparison.aspx | 144 +++++++++--------- .../ContractTrackComparison.aspx.cs | 8 + .../ContractTrackComparison.aspx.designer.cs | 17 +-- .../ContractCompile/ContractTrackList.aspx | 52 +++---- ...ContractTrackProgressDetectionGrid.aspx.cs | 76 ++++++++- .../PHTGL/ContractCompile/ContractWBS.aspx | 68 ++++----- SGGL/FineUIPro.Web/common/Menu_DigData.xml | 63 ++++++-- SGGL/FineUIPro.Web/common/Menu_HTGL.xml | 13 +- SGGL/FineUIPro.Web/common/Menu_JDGL.xml | 6 +- SGGL/FineUIPro.Web/common/Menu_PHTGL.xml | 21 +-- SGGL/FineUIPro.Web/common/Menu_ZHGL.xml | 37 ----- 16 files changed, 485 insertions(+), 264 deletions(-) create mode 100644 SGGL/BLL/Common/MultiHeaderTable.cs rename SGGL/FineUIPro.Web/File/Excel/DataIn/{合同执行跟踪导入模板.xlsx => 合同价格信息导入模板.xlsx} (100%) diff --git a/SGGL/BLL/BLL.csproj b/SGGL/BLL/BLL.csproj index ea01de06..b8bfa829 100644 --- a/SGGL/BLL/BLL.csproj +++ b/SGGL/BLL/BLL.csproj @@ -271,6 +271,7 @@ + diff --git a/SGGL/BLL/Common/Const.cs b/SGGL/BLL/Common/Const.cs index b5f1c295..80b375dc 100644 --- a/SGGL/BLL/Common/Const.cs +++ b/SGGL/BLL/Common/Const.cs @@ -3424,9 +3424,9 @@ namespace BLL /// public const string TemQuantityTemplateUrl = "File\\Excel\\DataIn\\工程量清单模板.xlsx"; /// - /// 合同执行跟踪导入模板 + /// 合同价格信息导入模板 /// - public const string TemContractTrackTemplateUrl = "File\\Excel\\DataIn\\合同执行跟踪导入模板.xlsx"; + public const string TemContractTrackTemplateUrl = "File\\Excel\\DataIn\\合同价格信息导入模板.xlsx"; #endregion diff --git a/SGGL/BLL/Common/MultiHeaderTable.cs b/SGGL/BLL/Common/MultiHeaderTable.cs new file mode 100644 index 00000000..1e99cd70 --- /dev/null +++ b/SGGL/BLL/Common/MultiHeaderTable.cs @@ -0,0 +1,142 @@ +using FineUIPro; +using System.Collections.Generic; +using System; +/// +/// 处理多表头的类 +/// +public class MultiHeaderTable +{ + // 包含 rowspan,colspan 的多表头,方便生成 HTML 的 table 标签 + public List> MultiTable = new List>(); + // 最终渲染的列数组 + public List Columns = new List(); + + + public void ResolveMultiHeaderTable(GridColumnCollection columns) + { + List row = new List(); + foreach (GridColumn column in columns) + { + object[] cell = new object[4]; + cell[0] = 1; // rowspan + cell[1] = 1; // colspan + cell[2] = column; + cell[3] = null; + + row.Add(cell); + } + + ResolveMultiTable(row, 0); + + ResolveColumns(row); + } + + private void ResolveColumns(List row) + { + foreach (object[] cell in row) + { + GroupField groupField = cell[2] as GroupField; + if (groupField != null && groupField.Columns.Count > 0) + { + List subrow = new List(); + foreach (GridColumn column in groupField.Columns) + { + subrow.Add(new object[] + { + 1, + 1, + column, + groupField + }); + } + + ResolveColumns(subrow); + } + else + { + Columns.Add(cell[2] as GridColumn); + } + } + + } + + private void ResolveMultiTable(List row, int level) + { + List nextrow = new List(); + + foreach (object[] cell in row) + { + GroupField groupField = cell[2] as GroupField; + if (groupField != null && groupField.Columns.Count > 0) + { + // 如果当前列包含子列,则更改当前列的 colspan,以及增加父列(向上递归)的colspan + cell[1] = Convert.ToInt32(groupField.Columns.Count); + PlusColspan(level - 1, cell[3] as GridColumn, groupField.Columns.Count - 1); + + foreach (GridColumn column in groupField.Columns) + { + nextrow.Add(new object[] + { + 1, + 1, + column, + groupField + }); + } + } + } + + MultiTable.Add(row); + + // 如果当前下一行,则增加上一行(向上递归)中没有子列的列的 rowspan + if (nextrow.Count > 0) + { + PlusRowspan(level); + + ResolveMultiTable(nextrow, level + 1); + } + } + + private void PlusRowspan(int level) + { + if (level < 0) + { + return; + } + + foreach (object[] cells in MultiTable[level]) + { + GroupField groupField = cells[2] as GroupField; + if (groupField != null && groupField.Columns.Count > 0) + { + // ... + } + else + { + cells[0] = Convert.ToInt32(cells[0]) + 1; + } + } + + PlusRowspan(level - 1); + } + + private void PlusColspan(int level, GridColumn parent, int plusCount) + { + if (level < 0) + { + return; + } + + foreach (object[] cells in MultiTable[level]) + { + GridColumn column = cells[2] as GridColumn; + if (column == parent) + { + cells[1] = Convert.ToInt32(cells[1]) + plusCount; + + PlusColspan(level - 1, cells[3] as GridColumn, plusCount); + } + } + } + +} diff --git a/SGGL/BLL/PHTGL/ContractCompile/PhtglContracttrackService .cs b/SGGL/BLL/PHTGL/ContractCompile/PhtglContracttrackService .cs index 1f07a600..ec3bd6d2 100644 --- a/SGGL/BLL/PHTGL/ContractCompile/PhtglContracttrackService .cs +++ b/SGGL/BLL/PHTGL/ContractCompile/PhtglContracttrackService .cs @@ -310,59 +310,62 @@ namespace BLL { var responeData = new ResponeData(); List rows; - try + var sheetNames = MiniExcel.GetSheetNames(path); + foreach (var sheet in sheetNames) ////多sheet导入 { - rows = MiniExcel.Query(path).ToList(); - } - catch (Exception e) - { - responeData.code = 0; - responeData.message = "模板错误"; - return responeData; - } - - var mapper = - ObjectMapperManager.DefaultInstance.GetMapper, List>(); - var modeList = mapper.Map(rows); - - if (modeList.Count == 0) - { - responeData.code = 0; - responeData.message = "没有数据"; - return responeData; - } - foreach (var item in modeList) - { - item.ContractId = contractid; - item.ProjectId = projectid; - if (string.IsNullOrEmpty(item.ProjectCode)) continue; - var phtglContractTrack = new PHTGL_ContractTrack + try { - MainItemCode = item.MainItemCode, - ProjectCode = item.ProjectCode, - ContractId = contractid, - ProjectId = projectid, - }; - var resultModel = GetPHTGL_ContractTrackByModle(phtglContractTrack); - item.ContractNum = ContractService.GetContractById(contractid)?.ContractNum; - if (!string.IsNullOrEmpty(item.ProjectCode) && !item.ProjectCode.Contains("-")) - { - - item.ProjectCode = item.MainItemCode + "-" + item.ProjectCode; + rows = MiniExcel.Query(path, sheetName: sheet).ToList(); } - if (resultModel.Any()) + catch (Exception ex) { - item.Id = resultModel[0].Id; - UpdatePHTGL_ContractTrack(item); + responeData.code = 0; + responeData.message = sheet+"模板错误:" + ex.ToString(); + return responeData; } - else - { - item.Id = SQLHelper.GetNewID(); - AddPHTGL_ContractTrack(item); - } - PhtglContracttrackprogressService.CreateTemplateByContractTrackId(item.Id); - } + var mapper = + ObjectMapperManager.DefaultInstance.GetMapper, List>(); + var modeList = mapper.Map(rows); + if (modeList.Count == 0) + { + responeData.code = 0; + responeData.message = sheet+ "没有数据"; + return responeData; + } + foreach (var item in modeList) + { + item.ContractId = contractid; + item.ProjectId = projectid; + if (string.IsNullOrEmpty(item.ProjectCode)) continue; + var phtglContractTrack = new PHTGL_ContractTrack + { + MainItemCode = item.MainItemCode, + ProjectCode = item.ProjectCode, + ContractId = contractid, + ProjectId = projectid, + }; + var resultModel = GetPHTGL_ContractTrackByModle(phtglContractTrack); + item.ContractNum = ContractService.GetContractById(contractid)?.ContractNum; + if (!string.IsNullOrEmpty(item.ProjectCode) && !item.ProjectCode.Contains("-")) + { + + item.ProjectCode = item.MainItemCode + "-" + item.ProjectCode; + } + if (resultModel.Any()) + { + item.Id = resultModel[0].Id; + UpdatePHTGL_ContractTrack(item); + } + else + { + item.Id = SQLHelper.GetNewID(); + AddPHTGL_ContractTrack(item); + } + PhtglContracttrackprogressService.CreateTemplateByContractTrackId(item.Id); + } + } + return responeData; } diff --git a/SGGL/FineUIPro.Web/File/Excel/DataIn/合同执行跟踪导入模板.xlsx b/SGGL/FineUIPro.Web/File/Excel/DataIn/合同价格信息导入模板.xlsx similarity index 100% rename from SGGL/FineUIPro.Web/File/Excel/DataIn/合同执行跟踪导入模板.xlsx rename to SGGL/FineUIPro.Web/File/Excel/DataIn/合同价格信息导入模板.xlsx diff --git a/SGGL/FineUIPro.Web/PHTGL/ContractCompile/ContractTrackComparison.aspx b/SGGL/FineUIPro.Web/PHTGL/ContractCompile/ContractTrackComparison.aspx index 699a70b0..287ff9e0 100644 --- a/SGGL/FineUIPro.Web/PHTGL/ContractCompile/ContractTrackComparison.aspx +++ b/SGGL/FineUIPro.Web/PHTGL/ContractCompile/ContractTrackComparison.aspx @@ -75,127 +75,125 @@ - - - - - + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + FieldType="String" HeaderText="项目编码" TextAlign="Center" HeaderTextAlign="Center"> + FieldType="String" HeaderText="项目名称" TextAlign="Center" HeaderTextAlign="Center"> + FieldType="String" HeaderText="项目特征描述" TextAlign="Center" HeaderTextAlign="Center"> - + - + - + - + - + + FieldType="String" HeaderText="施工分包商" TextAlign="Center" HeaderTextAlign="Center"> - + + FieldType="String" HeaderText="主材供应方 " TextAlign="Center" HeaderTextAlign="Center"> @@ -203,39 +201,39 @@ + FieldType="String" HeaderText="概算工程量" TextAlign="Center" HeaderTextAlign="Center"> - + - + - + - + - + - + - + diff --git a/SGGL/FineUIPro.Web/PHTGL/ContractCompile/ContractTrackComparison.aspx.cs b/SGGL/FineUIPro.Web/PHTGL/ContractCompile/ContractTrackComparison.aspx.cs index 849e9ad9..9f669dea 100644 --- a/SGGL/FineUIPro.Web/PHTGL/ContractCompile/ContractTrackComparison.aspx.cs +++ b/SGGL/FineUIPro.Web/PHTGL/ContractCompile/ContractTrackComparison.aspx.cs @@ -398,6 +398,14 @@ namespace FineUIPro.Web.PHTGL.ContractCompile { html = (row.FindControl("lblNumber") as System.Web.UI.WebControls.Label).Text; } + else if (column.ColumnID == "QuantityOffset") + { + html = (row.FindControl("lbQuantityOffset") as System.Web.UI.WebControls.Label).Text; + } + else if (column.ColumnID == "AmountOffset") + { + html = (row.FindControl("lbAmountOffset") as System.Web.UI.WebControls.Label).Text; + } sb.AppendFormat("{0}", html); } diff --git a/SGGL/FineUIPro.Web/PHTGL/ContractCompile/ContractTrackComparison.aspx.designer.cs b/SGGL/FineUIPro.Web/PHTGL/ContractCompile/ContractTrackComparison.aspx.designer.cs index 9242dcfb..e3f7fef8 100644 --- a/SGGL/FineUIPro.Web/PHTGL/ContractCompile/ContractTrackComparison.aspx.designer.cs +++ b/SGGL/FineUIPro.Web/PHTGL/ContractCompile/ContractTrackComparison.aspx.designer.cs @@ -140,15 +140,6 @@ namespace FineUIPro.Web.PHTGL.ContractCompile /// protected global::FineUIPro.Button btnQuery; - /// - /// lblNumber 控件。 - /// - /// - /// 自动生成的字段。 - /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 - /// - protected global::System.Web.UI.WebControls.Label lblNumber; - /// /// TextBox2 控件。 /// @@ -357,22 +348,22 @@ namespace FineUIPro.Web.PHTGL.ContractCompile protected global::FineUIPro.NumberBox NumberBox3; /// - /// Label2 控件。 + /// lbQuantityOffset 控件。 /// /// /// 自动生成的字段。 /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// - protected global::System.Web.UI.WebControls.Label Label2; + protected global::System.Web.UI.WebControls.Label lbQuantityOffset; /// - /// Label1 控件。 + /// lbAmountOffset 控件。 /// /// /// 自动生成的字段。 /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// - protected global::System.Web.UI.WebControls.Label Label1; + protected global::System.Web.UI.WebControls.Label lbAmountOffset; /// /// ToolbarSeparator1 控件。 diff --git a/SGGL/FineUIPro.Web/PHTGL/ContractCompile/ContractTrackList.aspx b/SGGL/FineUIPro.Web/PHTGL/ContractCompile/ContractTrackList.aspx index e28b7c98..ded7be69 100644 --- a/SGGL/FineUIPro.Web/PHTGL/ContractCompile/ContractTrackList.aspx +++ b/SGGL/FineUIPro.Web/PHTGL/ContractCompile/ContractTrackList.aspx @@ -80,112 +80,112 @@ - + - + + FieldType="String" HeaderText="主项名称" TextAlign="Center" HeaderTextAlign="Center"> + FieldType="String" HeaderText="专业工程名称" TextAlign="Center" HeaderTextAlign="Center"> + FieldType="String" HeaderText="专业代码" TextAlign="Center" HeaderTextAlign="Center"> + FieldType="String" HeaderText="分部工程" TextAlign="Center" HeaderTextAlign="Center"> + FieldType="String" HeaderText="子分部工程" TextAlign="Center" HeaderTextAlign="Center"> - <%-- + FieldType="String" HeaderText="项目编码" TextAlign="Center" HeaderTextAlign="Center" > --%> + FieldType="String" HeaderText="项目名称" TextAlign="Center" HeaderTextAlign="Center"> + FieldType="String" HeaderText="项目特征描述" TextAlign="Center" HeaderTextAlign="Center"> - + - + - + - + - + + FieldType="String" HeaderText="计算规则" TextAlign="Center" HeaderTextAlign="Center"> + FieldType="String" HeaderText="工作内容" TextAlign="Center" HeaderTextAlign="Center"> + FieldType="String" HeaderText="备注" TextAlign="Center" HeaderTextAlign="Center"> diff --git a/SGGL/FineUIPro.Web/PHTGL/ContractCompile/ContractTrackProgressDetectionGrid.aspx.cs b/SGGL/FineUIPro.Web/PHTGL/ContractCompile/ContractTrackProgressDetectionGrid.aspx.cs index f745cebc..2e1e7c58 100644 --- a/SGGL/FineUIPro.Web/PHTGL/ContractCompile/ContractTrackProgressDetectionGrid.aspx.cs +++ b/SGGL/FineUIPro.Web/PHTGL/ContractCompile/ContractTrackProgressDetectionGrid.aspx.cs @@ -593,7 +593,7 @@ namespace FineUIPro.Web.PHTGL.ContractCompile { Response.ClearContent(); string filename = Funs.GetNewFileName(); - Response.AddHeader("content-disposition", "attachment; filename=" + System.Web.HttpUtility.UrlEncode("合同执行跟踪表" + filename, System.Text.Encoding.UTF8) + ".xls"); + Response.AddHeader("content-disposition", "attachment; filename=" + System.Web.HttpUtility.UrlEncode("进度检测表" + filename, System.Text.Encoding.UTF8) + ".xls"); Response.ContentType = "application/excel"; Response.ContentEncoding = System.Text.Encoding.UTF8; this.Grid1.PageSize = 500; @@ -607,27 +607,87 @@ namespace FineUIPro.Web.PHTGL.ContractCompile /// /// /// + //private string GetGridTableHtml(Grid grid) + //{ + // StringBuilder sb = new StringBuilder(); + // sb.Append(""); + // sb.Append(""); + // sb.Append(""); + // foreach (GridColumn column in grid.Columns) + // { + // sb.AppendFormat("", column.HeaderText); + // } + // sb.Append(""); + // foreach (GridRow row in grid.Rows) + // { + // sb.Append(""); + // foreach (GridColumn column in grid.Columns) + // { + // string html = row.Values[column.ColumnIndex].ToString(); + // if (column.ColumnID == "tfNumber") + // { + // html = (row.FindControl("lblNumber") as System.Web.UI.WebControls.Label).Text; + // } + // sb.AppendFormat("", html); + // } + + // sb.Append(""); + // } + + // sb.Append("
{0}
{0}
"); + + // return sb.ToString(); + //} private string GetGridTableHtml(Grid grid) { StringBuilder sb = new StringBuilder(); - sb.Append(""); + + MultiHeaderTable mht = new MultiHeaderTable(); + mht.ResolveMultiHeaderTable(Grid1.Columns); + + + sb.Append(""); + + sb.Append(""); - sb.Append(""); - foreach (GridColumn column in grid.Columns) + + foreach (List rows in mht.MultiTable) { - sb.AppendFormat("", column.HeaderText); + sb.Append(""); + foreach (object[] cell in rows) + { + int rowspan = Convert.ToInt32(cell[0]); + int colspan = Convert.ToInt32(cell[1]); + GridColumn column = cell[2] as GridColumn; + + sb.AppendFormat("{3}", + rowspan != 1 ? " rowspan=\"" + rowspan + "\"" : "", + colspan != 1 ? " colspan=\"" + colspan + "\"" : "", + colspan != 1 ? " style=\"text-align:center;\"" : "", + column.HeaderText); + } + sb.Append(""); } - sb.Append(""); + + foreach (GridRow row in grid.Rows) { sb.Append(""); - foreach (GridColumn column in grid.Columns) + + foreach (GridColumn column in mht.Columns) { string html = row.Values[column.ColumnIndex].ToString(); + if (column.ColumnID == "tfNumber") { html = (row.FindControl("lblNumber") as System.Web.UI.WebControls.Label).Text; } + else if (column.ColumnID == "tfGender") + { + html = (row.FindControl("labGender") as System.Web.UI.WebControls.Label).Text; + } + + sb.AppendFormat("", html); } @@ -641,6 +701,6 @@ namespace FineUIPro.Web.PHTGL.ContractCompile #endregion - + } } \ No newline at end of file diff --git a/SGGL/FineUIPro.Web/PHTGL/ContractCompile/ContractWBS.aspx b/SGGL/FineUIPro.Web/PHTGL/ContractCompile/ContractWBS.aspx index b7ee0d46..c06358c3 100644 --- a/SGGL/FineUIPro.Web/PHTGL/ContractCompile/ContractWBS.aspx +++ b/SGGL/FineUIPro.Web/PHTGL/ContractCompile/ContractWBS.aspx @@ -33,11 +33,11 @@ Title="中间面板" ShowBorder="true" ShowHeader="false" BodyPadding="10px" IconFont="_RoundPlus"> + EnableRowDoubleClickEvent="true" OnRowDoubleClick="Grid1_RowDoubleClick" EnableRowClickEvent="True"> @@ -47,10 +47,10 @@ - - + @@ -67,77 +67,76 @@ - - + - + - + - + - + - + - + - + - + - <%-- + FieldType="String" HeaderText="项目编码" TextAlign="Center" HeaderTextAlign="Center" > --%> + FieldType="String" HeaderText="项目名称" TextAlign="Center" HeaderTextAlign="Center"> + FieldType="String" HeaderText="项目特征描述" TextAlign="Center" HeaderTextAlign="Center"> + FieldType="String" HeaderText="WBS编号" TextAlign="Center" HeaderTextAlign="Center"> + FieldType="String" HeaderText="工作包名称" TextAlign="Center" HeaderTextAlign="Center"> + FieldType="String" HeaderText="权重" TextAlign="Center" HeaderTextAlign="Center"> @@ -148,7 +147,7 @@ - + @@ -204,7 +203,8 @@ 'SubItemProject', 'ProjectName', 'ProjectDescription'], { - dependsFirst: true }); + dependsFirst: true + }); } diff --git a/SGGL/FineUIPro.Web/common/Menu_DigData.xml b/SGGL/FineUIPro.Web/common/Menu_DigData.xml index b532a9bb..bb7a7a34 100644 --- a/SGGL/FineUIPro.Web/common/Menu_DigData.xml +++ b/SGGL/FineUIPro.Web/common/Menu_DigData.xml @@ -1,9 +1,51 @@  - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -16,12 +58,15 @@ + + + - - - - - + + + + + \ No newline at end of file diff --git a/SGGL/FineUIPro.Web/common/Menu_HTGL.xml b/SGGL/FineUIPro.Web/common/Menu_HTGL.xml index c0fc81f0..129ab5fd 100644 --- a/SGGL/FineUIPro.Web/common/Menu_HTGL.xml +++ b/SGGL/FineUIPro.Web/common/Menu_HTGL.xml @@ -1,12 +1,14 @@  - - - + + + + + @@ -14,7 +16,10 @@ - + + + + diff --git a/SGGL/FineUIPro.Web/common/Menu_JDGL.xml b/SGGL/FineUIPro.Web/common/Menu_JDGL.xml index 8d4aa005..fd6a0762 100644 --- a/SGGL/FineUIPro.Web/common/Menu_JDGL.xml +++ b/SGGL/FineUIPro.Web/common/Menu_JDGL.xml @@ -1,7 +1,11 @@  - + + + + + \ No newline at end of file diff --git a/SGGL/FineUIPro.Web/common/Menu_PHTGL.xml b/SGGL/FineUIPro.Web/common/Menu_PHTGL.xml index eb672a76..31955789 100644 --- a/SGGL/FineUIPro.Web/common/Menu_PHTGL.xml +++ b/SGGL/FineUIPro.Web/common/Menu_PHTGL.xml @@ -17,19 +17,20 @@ - - - - - - - - - + + + + + + + + + + - + diff --git a/SGGL/FineUIPro.Web/common/Menu_ZHGL.xml b/SGGL/FineUIPro.Web/common/Menu_ZHGL.xml index 03eb9188..9bc36592 100644 --- a/SGGL/FineUIPro.Web/common/Menu_ZHGL.xml +++ b/SGGL/FineUIPro.Web/common/Menu_ZHGL.xml @@ -48,43 +48,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
{0}
{0}