From e63dd0e2f7e169c330aae120a25bca6a46a47d23 Mon Sep 17 00:00:00 2001 From: 10191 <506754232@qq.com> Date: Sun, 14 Jun 2026 17:55:08 +0800 Subject: [PATCH] 11 --- .../DataIn/DrawingRecognitionContent.aspx | 55 +++++- .../DataIn/DrawingRecognitionContent.aspx.cs | 174 +++++++++++++++++- ...DrawingRecognitionContent.aspx.designer.cs | 63 +++++++ 3 files changed, 283 insertions(+), 9 deletions(-) diff --git a/HJGL_DS/FineUIPro.Web/HJGL/DataIn/DrawingRecognitionContent.aspx b/HJGL_DS/FineUIPro.Web/HJGL/DataIn/DrawingRecognitionContent.aspx index 9b75c67..a81c3a6 100644 --- a/HJGL_DS/FineUIPro.Web/HJGL/DataIn/DrawingRecognitionContent.aspx +++ b/HJGL_DS/FineUIPro.Web/HJGL/DataIn/DrawingRecognitionContent.aspx @@ -115,9 +115,7 @@ EnableTextSelection="True" AllowColumnLocking="true"> - - + @@ -144,7 +142,7 @@ - + @@ -189,10 +187,59 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/HJGL_DS/FineUIPro.Web/HJGL/DataIn/DrawingRecognitionContent.aspx.cs b/HJGL_DS/FineUIPro.Web/HJGL/DataIn/DrawingRecognitionContent.aspx.cs index 3438056..fcbefc6 100644 --- a/HJGL_DS/FineUIPro.Web/HJGL/DataIn/DrawingRecognitionContent.aspx.cs +++ b/HJGL_DS/FineUIPro.Web/HJGL/DataIn/DrawingRecognitionContent.aspx.cs @@ -426,11 +426,139 @@ namespace FineUIPro.Web.HJGL.DataIn Grid1.DataSource = dt; Grid1.DataBind(); - Grid2.DataSource = dt; + // Grid2: 按图号合并 — 图号、类型、规格、描述相同的,数量累加 + if (dt != null && dt.Rows.Count > 0) + { + DataTable dtGroupByDrawing = new DataTable(); + dtGroupByDrawing.Columns.Add("id"); + dtGroupByDrawing.Columns.Add("drawing_number"); + dtGroupByDrawing.Columns.Add("category"); + dtGroupByDrawing.Columns.Add("spec"); + dtGroupByDrawing.Columns.Add("qty"); + dtGroupByDrawing.Columns.Add("description"); + var groups2 = dt.AsEnumerable() + .GroupBy(r => new + { + drawing_number = r.Field("drawing_number") ?? "", + category = r.Field("category") ?? "", + spec = r.Field("spec") ?? "", + description = r.Field("description") ?? "" + }) + .Select(g => new + { + g.Key.drawing_number, + g.Key.category, + g.Key.spec, + g.Key.description, + qty = g.Sum(r => Funs.GetNewDecimalOrZero(r.Field("qty"))) + }); + foreach (var g in groups2) + { + DataRow newRow = dtGroupByDrawing.NewRow(); + newRow["id"] = Guid.NewGuid().ToString(); + newRow["drawing_number"] = g.drawing_number; + newRow["category"] = g.category; + newRow["spec"] = g.spec; + newRow["qty"] = g.qty; + newRow["description"] = g.description; + dtGroupByDrawing.Rows.Add(newRow); + } + Grid2.DataSource = dtGroupByDrawing; + } + else + { + Grid2.DataSource = null; + } Grid2.DataBind(); - Grid3.DataSource = dt; + // Grid3: 按管线号合并 — 类型、规格、描述相同的,数量累加(不展示图号) + if (dt != null && dt.Rows.Count > 0) + { + DataTable dtGroupByPipe = new DataTable(); + dtGroupByPipe.Columns.Add("id"); + dtGroupByPipe.Columns.Add("pipe_no"); + dtGroupByPipe.Columns.Add("category"); + dtGroupByPipe.Columns.Add("spec"); + dtGroupByPipe.Columns.Add("qty"); + dtGroupByPipe.Columns.Add("description"); + var groups3 = dt.AsEnumerable() + .GroupBy(r => new + { + pipe_no = r.Field("pipe_no") ?? "", + category = r.Field("category") ?? "", + spec = r.Field("spec") ?? "", + description = r.Field("description") ?? "" + }) + .Select(g => new + { + g.Key.pipe_no, + g.Key.category, + g.Key.spec, + g.Key.description, + qty = g.Sum(r => Funs.GetNewDecimalOrZero(r.Field("qty"))) + }); + foreach (var g in groups3) + { + DataRow newRow = dtGroupByPipe.NewRow(); + newRow["id"] = Guid.NewGuid().ToString(); + newRow["pipe_no"] = g.pipe_no; + newRow["category"] = g.category; + newRow["spec"] = g.spec; + newRow["qty"] = g.qty; + newRow["description"] = g.description; + dtGroupByPipe.Rows.Add(newRow); + } + Grid3.DataSource = dtGroupByPipe; + } + else + { + Grid3.DataSource = null; + } Grid3.DataBind(); + + // 材料汇总表:按类型、规格、描述汇总数量 + + DataTable dtSummary = new DataTable(); + dtSummary.Columns.Add("id"); + dtSummary.Columns.Add("category"); + dtSummary.Columns.Add("spec"); + dtSummary.Columns.Add("qty"); + dtSummary.Columns.Add("description"); + + if (dt != null && dt.Rows.Count > 0) + { + var groups = dt.AsEnumerable() + .GroupBy(r => new + { + cat = r["category"].ToString().Trim(), + sp = r["spec"].ToString().Trim(), + desc = r["description"].ToString().Trim() + }) + .OrderBy(g => g.Key.cat) + .ThenBy(g => g.Key.sp); + + int idx = 1; + foreach (var g in groups) + { + var row = dtSummary.NewRow(); + row["id"] = idx++; + row["category"] = g.Key.cat; + row["spec"] = g.Key.sp; + row["description"] = g.Key.desc; + + decimal totalQty = 0; + foreach (var r in g) + { + if (decimal.TryParse(r["qty"].ToString(), out decimal qty)) + totalQty += qty; + } + row["qty"] = totalQty.ToString(); + dtSummary.Rows.Add(row); + } + } + + Grid4.DataSource = dtSummary; + Grid4.DataBind(); } #region 双击事件 /// @@ -471,6 +599,22 @@ namespace FineUIPro.Web.HJGL.DataIn } #region 导出按钮 + /// + /// 从URL中获取文件名(不含扩展名) + /// + private string GetUrlFileName() + { + if (!string.IsNullOrEmpty(URL)) + { + try + { + return System.IO.Path.GetFileNameWithoutExtension(URL); + } + catch { } + } + return ""; + } + /// /// 导出材料表 /// @@ -480,7 +624,8 @@ namespace FineUIPro.Web.HJGL.DataIn { Response.ClearContent(); string filename = Funs.GetNewFileName(); - Response.AddHeader("content-disposition", "attachment; filename=" + System.Web.HttpUtility.UrlEncode("材料表" + filename, System.Text.Encoding.UTF8) + ".xls"); + string prefix = GetUrlFileName(); + Response.AddHeader("content-disposition", "attachment; filename=" + System.Web.HttpUtility.UrlEncode(prefix + "材料表" + filename, System.Text.Encoding.UTF8) + ".xls"); Response.ContentType = "application/excel"; Response.ContentEncoding = System.Text.Encoding.UTF8; Response.Write(GetGridTableHtml(Grid1)); @@ -496,7 +641,8 @@ namespace FineUIPro.Web.HJGL.DataIn { Response.ClearContent(); string filename = Funs.GetNewFileName(); - Response.AddHeader("content-disposition", "attachment; filename=" + System.Web.HttpUtility.UrlEncode("图纸材料表" + filename, System.Text.Encoding.UTF8) + ".xls"); + string prefix = GetUrlFileName(); + Response.AddHeader("content-disposition", "attachment; filename=" + System.Web.HttpUtility.UrlEncode(prefix + "图纸材料表" + filename, System.Text.Encoding.UTF8) + ".xls"); Response.ContentType = "application/excel"; Response.ContentEncoding = System.Text.Encoding.UTF8; Response.Write(GetGridTableHtml(Grid2)); @@ -512,13 +658,31 @@ namespace FineUIPro.Web.HJGL.DataIn { Response.ClearContent(); string filename = Funs.GetNewFileName(); - Response.AddHeader("content-disposition", "attachment; filename=" + System.Web.HttpUtility.UrlEncode("管道材料表" + filename, System.Text.Encoding.UTF8) + ".xls"); + string prefix = GetUrlFileName(); + Response.AddHeader("content-disposition", "attachment; filename=" + System.Web.HttpUtility.UrlEncode(prefix + "管道材料表" + filename, System.Text.Encoding.UTF8) + ".xls"); Response.ContentType = "application/excel"; Response.ContentEncoding = System.Text.Encoding.UTF8; Response.Write(GetGridTableHtml(Grid3)); Response.End(); } + /// + /// 导出材料汇总表 + /// + /// + /// + protected void btnOut4_Click(object sender, EventArgs e) + { + Response.ClearContent(); + string filename = Funs.GetNewFileName(); + string prefix = GetUrlFileName(); + Response.AddHeader("content-disposition", "attachment; filename=" + System.Web.HttpUtility.UrlEncode(prefix + "材料汇总表" + filename, System.Text.Encoding.UTF8) + ".xls"); + Response.ContentType = "application/excel"; + Response.ContentEncoding = System.Text.Encoding.UTF8; + Response.Write(GetGridTableHtml(Grid4)); + Response.End(); + } + /// /// 导出方法 /// diff --git a/HJGL_DS/FineUIPro.Web/HJGL/DataIn/DrawingRecognitionContent.aspx.designer.cs b/HJGL_DS/FineUIPro.Web/HJGL/DataIn/DrawingRecognitionContent.aspx.designer.cs index 4eeadd1..d0f199d 100644 --- a/HJGL_DS/FineUIPro.Web/HJGL/DataIn/DrawingRecognitionContent.aspx.designer.cs +++ b/HJGL_DS/FineUIPro.Web/HJGL/DataIn/DrawingRecognitionContent.aspx.designer.cs @@ -239,6 +239,69 @@ namespace FineUIPro.Web.HJGL.DataIn /// protected global::FineUIPro.Grid Grid3; + /// + /// RegionPanel4 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.RegionPanel RegionPanel4; + + /// + /// Toolbar5 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.Toolbar Toolbar5; + + /// + /// Button1 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.Button Button1; + + /// + /// Region5 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.Region Region5; + + /// + /// Toolbar6 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.Toolbar Toolbar6; + + /// + /// btnOut4 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.Button btnOut4; + + /// + /// Grid4 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.Grid Grid4; + /// /// Window1 控件。 ///