From 78fc801b71909db5b0e066dfd102592ad440e299 Mon Sep 17 00:00:00 2001 From: gaofei1985 <181547018@qq.com> Date: Thu, 25 Jan 2024 16:16:18 +0800 Subject: [PATCH] update test run --- .../DriverPrepareSchemePlanItemService.cs | 2 +- .../File/Excel/TestRun/开车方案编制计划2.xlsx | Bin 0 -> 10712 bytes SGGL/FineUIPro.Web/FineUIPro.Web.csproj | 1 + .../TestRun/DriverPrepare/SchemePlan.aspx.cs | 269 +++++++++++++----- .../DriverPrepare/SchemePlanItemAdd.aspx | 5 + .../DriverPrepare/SchemePlanItemAdd.aspx.cs | 27 +- .../SchemePlanItemAdd.aspx.designer.cs | 9 + 7 files changed, 240 insertions(+), 73 deletions(-) create mode 100644 SGGL/FineUIPro.Web/File/Excel/TestRun/开车方案编制计划2.xlsx diff --git a/SGGL/BLL/TestRun/DriverPrepare/DriverPrepareSchemePlanItemService.cs b/SGGL/BLL/TestRun/DriverPrepare/DriverPrepareSchemePlanItemService.cs index 439d722c..2ee216e1 100644 --- a/SGGL/BLL/TestRun/DriverPrepare/DriverPrepareSchemePlanItemService.cs +++ b/SGGL/BLL/TestRun/DriverPrepare/DriverPrepareSchemePlanItemService.cs @@ -29,7 +29,7 @@ namespace BLL /// public static List GetSchemePlanItemByschemePlanId(string schemePlanId) { - return (from x in Funs.DB.DriverPrepare_SchemePlanItem where x.SchemePlanId == schemePlanId orderby x.SortIndex select x).ToList(); + return (from x in Funs.DB.DriverPrepare_SchemePlanItem where x.SchemePlanId == schemePlanId orderby x.SolutionType, x.SortIndex select x).ToList(); } /// diff --git a/SGGL/FineUIPro.Web/File/Excel/TestRun/开车方案编制计划2.xlsx b/SGGL/FineUIPro.Web/File/Excel/TestRun/开车方案编制计划2.xlsx new file mode 100644 index 0000000000000000000000000000000000000000..f1593bea66b51e09534081167c96d613578b0754 GIT binary patch literal 10712 zcmeHtWl)=IyKa!;?zF)vuEm|=1b26Lx8ho?Kq<7id!fbM-K9{VMGD2;9m)x;@7rCA z_M2H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UH$NL{{&eqgS7E#p(^o0k}QTpw|ZMiA`M zl<^4qTLkTk%AD2@)Qy-4kH|i;HqNw@&oZAq?v(!eM6OoSmruGgaTTg4-qbC|oIPt? znCFql&8^Vs8WJTB*)-XUSFD1&QPKw;H#Z;c(#^8xt0J{1I@;>lfMmpG4hg;Wj-GaX zC_V;J-A338*3YFrIePN=NFR{5UOiOFgxyAgEo%){8uNZ!%T-igu3&e7z~0~2TcGwQgblvk{t zRUi{q*EiTJlvuY{WiGw}n$u$Gs(6ECWi>Ignu%c~eWq7CxK%DV{e*jblr5gSPrq0) zCNIE7mT1M3VRTUey0jGD(}>%xa5oD3yGX-NRw6h$10qzrPE@+tR!aPF$1RyYz&vq} zEsxs*?xc)k84b7*C%$SF_HdYa+?T>A6U?@xR}7ibd4T+OAwfTCkq~b)EHp}@jWXv4 z`w##PC=7)WSCJqBed|GhXTivi7ni6sxtnn#+f(aQy^zgWcUGMisWT-yXBfJ8gn3=& z;X|N`Z1wqDI26sZHfoMmZL4sk5k%kG5RIAxj`>MqLKNMWQB1E;9w9+!egMHzTHIOJ zl2Vjx5jODohZwX7G3N zLekw0 z0Wy?a1FaT%k87x>Z!S--kq0nn)M&N{u&iOjbowgP4Dr4FLSYoea2T+Q#gLqa-+aha zun;OI%RMYpkg%Aw*HaPesG5>P=3K7e^&K*ZSO8ItbhO1FM;+nZPE{V)FG-G}RRzup?)Xp7-bF5~zdID;*PsC>u=`2^+ z<##=QVAbOuF?k_!rOG&R-w1!1f)?-rT!1G^e?&b9NP2Jz`}7t;^%F23JXideQvS89 zKLP&ifjtC#*hBgWSOl(z{v+Vej?zQG|E#zY?1zB&3%!SWi1M(1@N-$BxW7fY?@+AA + diff --git a/SGGL/FineUIPro.Web/TestRun/DriverPrepare/SchemePlan.aspx.cs b/SGGL/FineUIPro.Web/TestRun/DriverPrepare/SchemePlan.aspx.cs index cb89735d..419f1737 100644 --- a/SGGL/FineUIPro.Web/TestRun/DriverPrepare/SchemePlan.aspx.cs +++ b/SGGL/FineUIPro.Web/TestRun/DriverPrepare/SchemePlan.aspx.cs @@ -1,5 +1,6 @@ using BLL; using Newtonsoft.Json.Linq; +using NPOI.SS.Util; using System; using System.Collections.Generic; using System.Data; @@ -38,6 +39,18 @@ namespace FineUIPro.Web.TestRun.DriverPrepare var table = this.GetPagedDataTable(Grid1, tb); Grid1.DataSource = table; Grid1.DataBind(); + var solutionType = (from x in Funs.DB.DriverPrepare_SchemePlan + join y in Funs.DB.DriverPrepare_SchemePlanItem on x.SchemePlanId equals y.SchemePlanId + where y.SolutionType != null && x.ProjectId == this.CurrUser.LoginProjectId + select y).FirstOrDefault(); + if (solutionType == null) + { + this.Grid1.Columns[1].Hidden = true; + } + else + { + this.Grid1.Columns[1].Hidden = false; + } } #endregion @@ -178,87 +191,201 @@ namespace FineUIPro.Web.TestRun.DriverPrepare string uploadfilepath = string.Empty; string newUrl = string.Empty; string filePath = string.Empty; - initTemplatePath = Const.SchemePlanTemplateUrl; + var solutionType = (from x in Funs.DB.DriverPrepare_SchemePlan + join y in Funs.DB.DriverPrepare_SchemePlanItem on x.SchemePlanId equals y.SchemePlanId + where y.SolutionType != null && x.ProjectId == this.CurrUser.LoginProjectId + select y).FirstOrDefault(); + if (solutionType == null) + { + initTemplatePath = Const.SchemePlanTemplateUrl; + } + else + { + initTemplatePath = Const.SchemePlan2TemplateUrl; + } uploadfilepath = rootPath + initTemplatePath; Model.DriverPrepare_SchemePlan plan = BLL.DriverPrepareSchemePlanService.GetDriverPlanByProjectId(this.CurrUser.LoginProjectId); if (plan != null) { string projectName = BLL.ProjectService.GetProjectNameByProjectId(plan.ProjectId); - newUrl = uploadfilepath.Replace(".xlsx", "(" + projectName + ")" + ".xlsx"); - File.Copy(uploadfilepath, newUrl); - // 第一步:读取文件流 - NPOI.SS.UserModel.IWorkbook workbook; - using (FileStream stream = new FileStream(newUrl, FileMode.Open, FileAccess.Read)) - { - workbook = new NPOI.XSSF.UserModel.XSSFWorkbook(stream); - } - // 创建单元格样式 - NPOI.SS.UserModel.ICellStyle cellStyle = workbook.CreateCellStyle(); - cellStyle.BorderTop = NPOI.SS.UserModel.BorderStyle.Thin; - cellStyle.BorderRight = NPOI.SS.UserModel.BorderStyle.Thin; - cellStyle.BorderBottom = NPOI.SS.UserModel.BorderStyle.Thin; - cellStyle.BorderLeft = NPOI.SS.UserModel.BorderStyle.Thin; - cellStyle.Alignment = NPOI.SS.UserModel.HorizontalAlignment.Center; - cellStyle.VerticalAlignment = NPOI.SS.UserModel.VerticalAlignment.Center; - var font = workbook.CreateFont(); - font.FontHeightInPoints = 11; - cellStyle.SetFont(font); - NPOI.SS.UserModel.ICellStyle cellStyle0 = workbook.CreateCellStyle(); - cellStyle0.BorderTop = NPOI.SS.UserModel.BorderStyle.Thin; - cellStyle0.BorderRight = NPOI.SS.UserModel.BorderStyle.Thin; - cellStyle0.BorderBottom = NPOI.SS.UserModel.BorderStyle.Thin; - cellStyle0.BorderLeft = NPOI.SS.UserModel.BorderStyle.Thin; - cellStyle0.Alignment = NPOI.SS.UserModel.HorizontalAlignment.Center; - cellStyle0.VerticalAlignment = NPOI.SS.UserModel.VerticalAlignment.Center; - var font0 = workbook.CreateFont(); - font0.FontHeightInPoints = 12; - font0.IsBold = true; - cellStyle0.SetFont(font0); - // 第二步:创建新数据行 - NPOI.SS.UserModel.ISheet sheet = workbook.GetSheetAt(0); - NPOI.SS.UserModel.IRow row = sheet.GetRow(0); - NPOI.SS.UserModel.ICell cell; - cell = row.GetCell(0); - cell.CellStyle = cellStyle0; - cell.SetCellValue(projectName + "试车方案"); - var items = BLL.DriverPrepareSchemePlanItemService.GetSchemePlanItemByschemePlanId(plan.SchemePlanId); - int i = 2; - foreach (var item in items) + if (solutionType == null) { + newUrl = uploadfilepath.Replace(".xlsx", "(" + projectName + ")" + ".xlsx"); + File.Copy(uploadfilepath, newUrl); + // 第一步:读取文件流 + NPOI.SS.UserModel.IWorkbook workbook; + using (FileStream stream = new FileStream(newUrl, FileMode.Open, FileAccess.Read)) + { + workbook = new NPOI.XSSF.UserModel.XSSFWorkbook(stream); + } + // 创建单元格样式 + NPOI.SS.UserModel.ICellStyle cellStyle = workbook.CreateCellStyle(); + cellStyle.BorderTop = NPOI.SS.UserModel.BorderStyle.Thin; + cellStyle.BorderRight = NPOI.SS.UserModel.BorderStyle.Thin; + cellStyle.BorderBottom = NPOI.SS.UserModel.BorderStyle.Thin; + cellStyle.BorderLeft = NPOI.SS.UserModel.BorderStyle.Thin; + cellStyle.Alignment = NPOI.SS.UserModel.HorizontalAlignment.Center; + cellStyle.VerticalAlignment = NPOI.SS.UserModel.VerticalAlignment.Center; + var font = workbook.CreateFont(); + font.FontHeightInPoints = 11; + cellStyle.SetFont(font); + NPOI.SS.UserModel.ICellStyle cellStyle0 = workbook.CreateCellStyle(); + cellStyle0.BorderTop = NPOI.SS.UserModel.BorderStyle.Thin; + cellStyle0.BorderRight = NPOI.SS.UserModel.BorderStyle.Thin; + cellStyle0.BorderBottom = NPOI.SS.UserModel.BorderStyle.Thin; + cellStyle0.BorderLeft = NPOI.SS.UserModel.BorderStyle.Thin; + cellStyle0.Alignment = NPOI.SS.UserModel.HorizontalAlignment.Center; + cellStyle0.VerticalAlignment = NPOI.SS.UserModel.VerticalAlignment.Center; + var font0 = workbook.CreateFont(); + font0.FontHeightInPoints = 12; + font0.IsBold = true; + cellStyle0.SetFont(font0); // 第二步:创建新数据行 - row = sheet.CreateRow(i); - // 添加数据 - cell = row.CreateCell(0); - cell.CellStyle = cellStyle; - cell.SetCellValue((i-1).ToString()); - cell = row.CreateCell(1); - cell.CellStyle = cellStyle; - cell.SetCellValue(item.SolutionName); - cell = row.CreateCell(2); - cell.CellStyle = cellStyle; - cell.SetCellValue(string.Empty); - cell = row.CreateCell(3); - cell.CellStyle = cellStyle; - cell.SetCellValue(string.Empty); - i++; + NPOI.SS.UserModel.ISheet sheet = workbook.GetSheetAt(0); + NPOI.SS.UserModel.IRow row = sheet.GetRow(0); + NPOI.SS.UserModel.ICell cell; + cell = row.GetCell(0); + cell.CellStyle = cellStyle0; + cell.SetCellValue(projectName + "试车方案"); + var items = BLL.DriverPrepareSchemePlanItemService.GetSchemePlanItemByschemePlanId(plan.SchemePlanId); + int i = 2; + foreach (var item in items) + { + // 第二步:创建新数据行 + row = sheet.CreateRow(i); + // 添加数据 + cell = row.CreateCell(0); + cell.CellStyle = cellStyle; + cell.SetCellValue((i - 1).ToString()); + cell = row.CreateCell(1); + cell.CellStyle = cellStyle; + cell.SetCellValue(item.SolutionName); + cell = row.CreateCell(2); + cell.CellStyle = cellStyle; + cell.SetCellValue(string.Empty); + cell = row.CreateCell(3); + cell.CellStyle = cellStyle; + cell.SetCellValue(string.Empty); + i++; + } + // 第三步:写入文件流 + using (FileStream stream = new FileStream(newUrl, FileMode.Create, FileAccess.Write)) + { + workbook.Write(stream); + workbook.Close(); + } + string fileName = Path.GetFileName(newUrl); + FileInfo info = new FileInfo(newUrl); + long fileSize = info.Length; + Response.Clear(); + Response.ContentType = "application/x-zip-compressed"; + Response.AddHeader("Content-Disposition", "attachment;filename=" + System.Web.HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8)); + Response.AddHeader("Content-Length", fileSize.ToString()); + Response.TransmitFile(newUrl, 0, fileSize); + Response.Flush(); + Response.Close(); + File.Delete(newUrl); } - // 第三步:写入文件流 - using (FileStream stream = new FileStream(newUrl, FileMode.Create, FileAccess.Write)) + else { - workbook.Write(stream); - workbook.Close(); + newUrl = uploadfilepath.Replace("2.xlsx", "(" + projectName + ")" + ".xlsx"); + File.Copy(uploadfilepath, newUrl); + // 第一步:读取文件流 + NPOI.SS.UserModel.IWorkbook workbook; + using (FileStream stream = new FileStream(newUrl, FileMode.Open, FileAccess.Read)) + { + workbook = new NPOI.XSSF.UserModel.XSSFWorkbook(stream); + } + // 创建单元格样式 + NPOI.SS.UserModel.ICellStyle cellStyle = workbook.CreateCellStyle(); + cellStyle.BorderTop = NPOI.SS.UserModel.BorderStyle.Thin; + cellStyle.BorderRight = NPOI.SS.UserModel.BorderStyle.Thin; + cellStyle.BorderBottom = NPOI.SS.UserModel.BorderStyle.Thin; + cellStyle.BorderLeft = NPOI.SS.UserModel.BorderStyle.Thin; + cellStyle.Alignment = NPOI.SS.UserModel.HorizontalAlignment.Center; + cellStyle.VerticalAlignment = NPOI.SS.UserModel.VerticalAlignment.Center; + var font = workbook.CreateFont(); + font.FontHeightInPoints = 11; + cellStyle.SetFont(font); + NPOI.SS.UserModel.ICellStyle cellStyle0 = workbook.CreateCellStyle(); + cellStyle0.BorderTop = NPOI.SS.UserModel.BorderStyle.Thin; + cellStyle0.BorderRight = NPOI.SS.UserModel.BorderStyle.Thin; + cellStyle0.BorderBottom = NPOI.SS.UserModel.BorderStyle.Thin; + cellStyle0.BorderLeft = NPOI.SS.UserModel.BorderStyle.Thin; + cellStyle0.Alignment = NPOI.SS.UserModel.HorizontalAlignment.Center; + cellStyle0.VerticalAlignment = NPOI.SS.UserModel.VerticalAlignment.Center; + var font0 = workbook.CreateFont(); + font0.FontHeightInPoints = 12; + font0.IsBold = true; + cellStyle0.SetFont(font0); + // 第二步:创建新数据行 + NPOI.SS.UserModel.ISheet sheet = workbook.GetSheetAt(0); + NPOI.SS.UserModel.IRow row = sheet.GetRow(0); + NPOI.SS.UserModel.ICell cell; + cell = row.GetCell(0); + cell.CellStyle = cellStyle0; + cell.SetCellValue(projectName + "试车方案"); + var items = BLL.DriverPrepareSchemePlanItemService.GetSchemePlanItemByschemePlanId(plan.SchemePlanId); + int i = 2; + string type = string.Empty; + int firstRow = 2; + foreach (var item in items) + { + if (string.IsNullOrEmpty(type)) + { + type = item.SolutionType; + } + // 第二步:创建新数据行 + row = sheet.CreateRow(i); + // 添加数据 + cell = row.CreateCell(0); + cell.CellStyle = cellStyle; + cell.SetCellValue((i - 1).ToString()); + cell = row.CreateCell(1); + cell.CellStyle = cellStyle; + cell.SetCellValue(item.SolutionType); + cell = row.CreateCell(2); + cell.CellStyle = cellStyle; + cell.SetCellValue(item.SolutionName); + cell = row.CreateCell(3); + cell.CellStyle = cellStyle; + cell.SetCellValue(string.Empty); + cell = row.CreateCell(4); + cell.CellStyle = cellStyle; + cell.SetCellValue(string.Empty); + if (type != item.SolutionType) + { + type = item.SolutionType; + sheet.AddMergedRegion(new CellRangeAddress(firstRow, i - 1, 1, 1)); + firstRow = i; + } + else + { + if (i == 1 + items.Count) + { + sheet.AddMergedRegion(new CellRangeAddress(firstRow, i, 1, 1)); + } + } + i++; + } + // 第三步:写入文件流 + using (FileStream stream = new FileStream(newUrl, FileMode.Create, FileAccess.Write)) + { + workbook.Write(stream); + workbook.Close(); + } + string fileName = Path.GetFileName(newUrl); + FileInfo info = new FileInfo(newUrl); + long fileSize = info.Length; + Response.Clear(); + Response.ContentType = "application/x-zip-compressed"; + Response.AddHeader("Content-Disposition", "attachment;filename=" + System.Web.HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8)); + Response.AddHeader("Content-Length", fileSize.ToString()); + Response.TransmitFile(newUrl, 0, fileSize); + Response.Flush(); + Response.Close(); + File.Delete(newUrl); } - string fileName = Path.GetFileName(newUrl); - FileInfo info = new FileInfo(newUrl); - long fileSize = info.Length; - Response.Clear(); - Response.ContentType = "application/x-zip-compressed"; - Response.AddHeader("Content-Disposition", "attachment;filename=" + System.Web.HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8)); - Response.AddHeader("Content-Length", fileSize.ToString()); - Response.TransmitFile(newUrl, 0, fileSize); - Response.Flush(); - Response.Close(); - File.Delete(newUrl); } else { diff --git a/SGGL/FineUIPro.Web/TestRun/DriverPrepare/SchemePlanItemAdd.aspx b/SGGL/FineUIPro.Web/TestRun/DriverPrepare/SchemePlanItemAdd.aspx index d362434e..fab5528f 100644 --- a/SGGL/FineUIPro.Web/TestRun/DriverPrepare/SchemePlanItemAdd.aspx +++ b/SGGL/FineUIPro.Web/TestRun/DriverPrepare/SchemePlanItemAdd.aspx @@ -14,6 +14,11 @@ + + + + + diff --git a/SGGL/FineUIPro.Web/TestRun/DriverPrepare/SchemePlanItemAdd.aspx.cs b/SGGL/FineUIPro.Web/TestRun/DriverPrepare/SchemePlanItemAdd.aspx.cs index c6f319a4..6a48ebf1 100644 --- a/SGGL/FineUIPro.Web/TestRun/DriverPrepare/SchemePlanItemAdd.aspx.cs +++ b/SGGL/FineUIPro.Web/TestRun/DriverPrepare/SchemePlanItemAdd.aspx.cs @@ -21,8 +21,21 @@ namespace FineUIPro.Web.TestRun.DriverPrepare if (item != null) { this.txtSolutionName.Text = item.SolutionName; + this.txtSolutionType.Text = item.SolutionType; } } + var solutionType = (from x in Funs.DB.DriverPrepare_SchemePlan + join y in Funs.DB.DriverPrepare_SchemePlanItem on x.SchemePlanId equals y.SchemePlanId + where y.SolutionType != null && x.ProjectId == this.CurrUser.LoginProjectId + select y).FirstOrDefault(); + if (solutionType != null) + { + this.txtSolutionType.Hidden = false; + } + else + { + this.txtSolutionType.Hidden = true; + } } } @@ -54,13 +67,25 @@ namespace FineUIPro.Web.TestRun.DriverPrepare newItem.SchemePlanId = newData.SchemePlanId; } newItem.SortIndex = sortIndex; + var solutionType = (from x in Funs.DB.DriverPrepare_SchemePlan + join y in Funs.DB.DriverPrepare_SchemePlanItem on x.SchemePlanId equals y.SchemePlanId + where y.SolutionType != null && x.ProjectId == this.CurrUser.LoginProjectId + select y).FirstOrDefault(); + if (solutionType != null) + { + newItem.SolutionType = this.txtSolutionType.Text.Trim(); + } + else + { + + } if (string.IsNullOrEmpty(SchemePlanItemId)) { newItem.SchemePlanItemId = SQLHelper.GetNewID(); BLL.DriverPrepareSchemePlanItemService.AddSchemePlanItem(newItem); BLL.LogService.AddSys_Log(this.CurrUser, newItem.SolutionName, newItem.SolutionName, BLL.Const.ControlItemInitSetMenuId, "增加开车方案!"); } - if (Request.Params["type"] == "modify") + else { newItem.SchemePlanItemId = SchemePlanItemId; BLL.DriverPrepareSchemePlanItemService.UpdateSchemePlanItem(newItem); diff --git a/SGGL/FineUIPro.Web/TestRun/DriverPrepare/SchemePlanItemAdd.aspx.designer.cs b/SGGL/FineUIPro.Web/TestRun/DriverPrepare/SchemePlanItemAdd.aspx.designer.cs index 793f876e..3e0a5b44 100644 --- a/SGGL/FineUIPro.Web/TestRun/DriverPrepare/SchemePlanItemAdd.aspx.designer.cs +++ b/SGGL/FineUIPro.Web/TestRun/DriverPrepare/SchemePlanItemAdd.aspx.designer.cs @@ -39,6 +39,15 @@ namespace FineUIPro.Web.TestRun.DriverPrepare { /// protected global::FineUIPro.Form SimpleForm1; + /// + /// txtSolutionType 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.TextBox txtSolutionType; + /// /// txtSolutionName 控件。 ///