update test run

This commit is contained in:
高飞 2024-01-25 16:16:18 +08:00
parent 9b01a40341
commit 78fc801b71
7 changed files with 240 additions and 73 deletions

View File

@ -29,7 +29,7 @@ namespace BLL
/// <returns></returns> /// <returns></returns>
public static List<Model.DriverPrepare_SchemePlanItem> GetSchemePlanItemByschemePlanId(string schemePlanId) public static List<Model.DriverPrepare_SchemePlanItem> 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();
} }
/// <summary> /// <summary>

View File

@ -2075,6 +2075,7 @@
<Content Include="File\Excel\TestRun\三查四定检查表模板.xls" /> <Content Include="File\Excel\TestRun\三查四定检查表模板.xls" />
<Content Include="File\Excel\TestRun\仪表索引模板.xlsx" /> <Content Include="File\Excel\TestRun\仪表索引模板.xlsx" />
<Content Include="File\Excel\TestRun\试车系统划分.xlsx" /> <Content Include="File\Excel\TestRun\试车系统划分.xlsx" />
<Content Include="File\Excel\TestRun\开车方案编制计划2.xlsx" />
<None Include="packages.config" /> <None Include="packages.config" />
<Content Include="ReportPrint\ReportTabFile\分包商上传周报.tab" /> <Content Include="ReportPrint\ReportTabFile\分包商上传周报.tab" />
<Content Include="ReportPrint\ReportTabFile\HSSE日志暨管理数据收集.tab" /> <Content Include="ReportPrint\ReportTabFile\HSSE日志暨管理数据收集.tab" />

View File

@ -1,5 +1,6 @@
using BLL; using BLL;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
using NPOI.SS.Util;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Data; using System.Data;
@ -38,6 +39,18 @@ namespace FineUIPro.Web.TestRun.DriverPrepare
var table = this.GetPagedDataTable(Grid1, tb); var table = this.GetPagedDataTable(Grid1, tb);
Grid1.DataSource = table; Grid1.DataSource = table;
Grid1.DataBind(); 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 #endregion
@ -178,87 +191,201 @@ namespace FineUIPro.Web.TestRun.DriverPrepare
string uploadfilepath = string.Empty; string uploadfilepath = string.Empty;
string newUrl = string.Empty; string newUrl = string.Empty;
string filePath = 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; uploadfilepath = rootPath + initTemplatePath;
Model.DriverPrepare_SchemePlan plan = BLL.DriverPrepareSchemePlanService.GetDriverPlanByProjectId(this.CurrUser.LoginProjectId); Model.DriverPrepare_SchemePlan plan = BLL.DriverPrepareSchemePlanService.GetDriverPlanByProjectId(this.CurrUser.LoginProjectId);
if (plan != null) if (plan != null)
{ {
string projectName = BLL.ProjectService.GetProjectNameByProjectId(plan.ProjectId); string projectName = BLL.ProjectService.GetProjectNameByProjectId(plan.ProjectId);
newUrl = uploadfilepath.Replace(".xlsx", "(" + projectName + ")" + ".xlsx"); if (solutionType == null)
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)
{ {
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); NPOI.SS.UserModel.ISheet sheet = workbook.GetSheetAt(0);
// 添加数据 NPOI.SS.UserModel.IRow row = sheet.GetRow(0);
cell = row.CreateCell(0); NPOI.SS.UserModel.ICell cell;
cell.CellStyle = cellStyle; cell = row.GetCell(0);
cell.SetCellValue((i-1).ToString()); cell.CellStyle = cellStyle0;
cell = row.CreateCell(1); cell.SetCellValue(projectName + "试车方案");
cell.CellStyle = cellStyle; var items = BLL.DriverPrepareSchemePlanItemService.GetSchemePlanItemByschemePlanId(plan.SchemePlanId);
cell.SetCellValue(item.SolutionName); int i = 2;
cell = row.CreateCell(2); foreach (var item in items)
cell.CellStyle = cellStyle; {
cell.SetCellValue(string.Empty); // 第二步:创建新数据行
cell = row.CreateCell(3); row = sheet.CreateRow(i);
cell.CellStyle = cellStyle; // 添加数据
cell.SetCellValue(string.Empty); cell = row.CreateCell(0);
i++; 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);
} }
// 第三步:写入文件流 else
using (FileStream stream = new FileStream(newUrl, FileMode.Create, FileAccess.Write))
{ {
workbook.Write(stream); newUrl = uploadfilepath.Replace("2.xlsx", "(" + projectName + ")" + ".xlsx");
workbook.Close(); 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 else
{ {

View File

@ -14,6 +14,11 @@
<f:Form ID="SimpleForm1" ShowBorder="false" ShowHeader="false" AutoScroll="true" <f:Form ID="SimpleForm1" ShowBorder="false" ShowHeader="false" AutoScroll="true"
BodyPadding="10px" runat="server" RedStarPosition="BeforeText" LabelAlign="Right"> BodyPadding="10px" runat="server" RedStarPosition="BeforeText" LabelAlign="Right">
<Rows> <Rows>
<f:FormRow>
<Items>
<f:TextBox ID="txtSolutionType" runat="server" Label="单元" LabelWidth="100px" Required="true" ShowRedStar="true"></f:TextBox>
</Items>
</f:FormRow>
<f:FormRow> <f:FormRow>
<Items> <Items>
<f:TextBox ID="txtSolutionName" runat="server" Label="方案名称" LabelWidth="100px" Required="true" ShowRedStar="true"></f:TextBox> <f:TextBox ID="txtSolutionName" runat="server" Label="方案名称" LabelWidth="100px" Required="true" ShowRedStar="true"></f:TextBox>

View File

@ -21,8 +21,21 @@ namespace FineUIPro.Web.TestRun.DriverPrepare
if (item != null) if (item != null)
{ {
this.txtSolutionName.Text = item.SolutionName; 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.SchemePlanId = newData.SchemePlanId;
} }
newItem.SortIndex = sortIndex; 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)) if (string.IsNullOrEmpty(SchemePlanItemId))
{ {
newItem.SchemePlanItemId = SQLHelper.GetNewID(); newItem.SchemePlanItemId = SQLHelper.GetNewID();
BLL.DriverPrepareSchemePlanItemService.AddSchemePlanItem(newItem); BLL.DriverPrepareSchemePlanItemService.AddSchemePlanItem(newItem);
BLL.LogService.AddSys_Log(this.CurrUser, newItem.SolutionName, newItem.SolutionName, BLL.Const.ControlItemInitSetMenuId, "增加开车方案!"); BLL.LogService.AddSys_Log(this.CurrUser, newItem.SolutionName, newItem.SolutionName, BLL.Const.ControlItemInitSetMenuId, "增加开车方案!");
} }
if (Request.Params["type"] == "modify") else
{ {
newItem.SchemePlanItemId = SchemePlanItemId; newItem.SchemePlanItemId = SchemePlanItemId;
BLL.DriverPrepareSchemePlanItemService.UpdateSchemePlanItem(newItem); BLL.DriverPrepareSchemePlanItemService.UpdateSchemePlanItem(newItem);

View File

@ -39,6 +39,15 @@ namespace FineUIPro.Web.TestRun.DriverPrepare {
/// </remarks> /// </remarks>
protected global::FineUIPro.Form SimpleForm1; protected global::FineUIPro.Form SimpleForm1;
/// <summary>
/// txtSolutionType 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.TextBox txtSolutionType;
/// <summary> /// <summary>
/// txtSolutionName 控件。 /// txtSolutionName 控件。
/// </summary> /// </summary>