542 lines
		
	
	
		
			23 KiB
		
	
	
	
		
			C#
		
	
	
	
			
		
		
	
	
			542 lines
		
	
	
		
			23 KiB
		
	
	
	
		
			C#
		
	
	
	
| using BLL;
 | |
| using Model;
 | |
| using System;
 | |
| using System.Collections.Generic;
 | |
| using System.Data.SqlClient;
 | |
| using System.Data;
 | |
| using System.Linq;
 | |
| using System.Web;
 | |
| using System.Web.UI;
 | |
| using static FineUIPro.Web.TestRun.Report.PreRunSchedule;
 | |
| using System.Reflection;
 | |
| using Newtonsoft.Json.Linq;
 | |
| using NPOI.SS.UserModel;
 | |
| using NPOI.SS.Util;
 | |
| using NPOI.XSSF.UserModel;
 | |
| using System.IO;
 | |
| 
 | |
| namespace FineUIPro.Web.TestRun.Report
 | |
| {
 | |
|     public partial class TestRunSchedule : PageBase
 | |
|     {
 | |
|         /// <summary>
 | |
|         /// 点击树状主键
 | |
|         /// </summary>
 | |
|         public string TreePreRunId { get { return (string)ViewState["TreePreRunId"]; } set { ViewState["TreePreRunId"] = value; } }
 | |
|         /// <summary>
 | |
|         /// 系统主键
 | |
|         /// </summary>
 | |
|         public List<string> SystemIds { get { return (List<string>)ViewState["SystemIds"]; } set { ViewState["SystemIds"] = value; } }
 | |
| 
 | |
|         protected void Page_Load(object sender, EventArgs e)
 | |
|         {
 | |
|             if (!IsPostBack)
 | |
|             {
 | |
|                 if (SystemIds == null) SystemIds = new List<string>();
 | |
|                 this.InitTreeMenu();//加载树
 | |
|             }
 | |
|         }
 | |
| 
 | |
| 
 | |
|         #region 加载树
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 加载树
 | |
|         /// </summary>
 | |
|         private void InitTreeMenu()
 | |
|         {
 | |
|             this.tvControlItem.Nodes.Clear();
 | |
|             TreeNode rootNode = new TreeNode();
 | |
|             rootNode.Text = "系统划分";
 | |
|             rootNode.NodeID = "0";
 | |
|             rootNode.Expanded = true;
 | |
|             rootNode.ToolTip = "";
 | |
|             rootNode.EnableClickEvent = true;
 | |
|             this.tvControlItem.Nodes.Add(rootNode);
 | |
|             var allPreRunLs = Funs.DB.PreRun_SysDevice.Where(p => p.ProjectId == this.CurrUser.LoginProjectId && p.PreRunLevel != 4).ToList();
 | |
|             var onePreRunLs = allPreRunLs.Where(p => p.PreRunLevel == 1).OrderBy(x => x.Sort);
 | |
|             foreach (var item in onePreRunLs)
 | |
|             {
 | |
|                 TreeNode rootUnitNode = new TreeNode();//定义根节点
 | |
|                 rootUnitNode.NodeID = item.PreRunId;
 | |
|                 rootUnitNode.Text = item.PreRunName;
 | |
|                 rootUnitNode.ToolTip = item.PreRunName;
 | |
|                 rootUnitNode.CommandName = "";
 | |
|                 rootUnitNode.EnableClickEvent = true;
 | |
|                 rootUnitNode.EnableExpandEvent = true;
 | |
|                 rootNode.Nodes.Add(rootUnitNode);
 | |
|                 rootUnitNode.Expanded = true;
 | |
|                 var otherPreRunls = allPreRunLs.Where(p => p.PreRunLevel != 1).ToList();
 | |
|                 this.BindNodes(rootUnitNode, otherPreRunls, item.PreRunId);
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         ///  绑定树节点
 | |
|         /// </summary>
 | |
|         private void BindNodes(TreeNode node, List<PreRun_SysDevice> list, string parentId)
 | |
|         {
 | |
| 
 | |
|             var itemList = list.Where(p => p.ParentId == parentId).OrderBy(x => x.Sort).ToList();
 | |
|             if (itemList.Count > 0)
 | |
|             {
 | |
|                 foreach (var item in itemList)
 | |
|                 {
 | |
|                     TreeNode newNode = new TreeNode();
 | |
|                     newNode.Text = item.PreRunName;
 | |
|                     newNode.NodeID = item.PreRunId;
 | |
|                     newNode.ToolTip = item.PreRunName;
 | |
|                     newNode.CommandName = "";
 | |
|                     newNode.EnableClickEvent = true;
 | |
|                     node.Nodes.Add(newNode);
 | |
|                     BindNodes(newNode, list, item.PreRunId);
 | |
|                 }
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 数加载
 | |
|         /// </summary>
 | |
|         protected void tvControlItem_NodeExpand(object sender, TreeNodeEventArgs e)
 | |
|         {
 | |
|             if (e.Node.Nodes != null)
 | |
|             {
 | |
|                 e.Node.Nodes.Clear();
 | |
|             }
 | |
|             var allPreRunLs = Funs.DB.PreRun_SysDevice.Where(p => p.ProjectId == this.CurrUser.LoginProjectId).ToList();
 | |
|             this.BindNodes(e.Node, allPreRunLs, e.NodeID);
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 点击TreeView
 | |
|         /// </summary>
 | |
|         /// <param name="sender"></param>
 | |
|         /// <param name="e"></param>
 | |
|         protected void tvControlItem_NodeCommand(object sender, TreeCommandEventArgs e)
 | |
|         {
 | |
|             var devices = new List<PreRun_SysDevice>();
 | |
|             this.TreePreRunId = tvControlItem.SelectedNodeID != "0" ? tvControlItem.SelectedNodeID : string.Empty;
 | |
|             if (!string.IsNullOrWhiteSpace(this.TreePreRunId))
 | |
|             {
 | |
|                 var model = Funs.DB.PreRun_SysDevice.FirstOrDefault(x => x.PreRunId == this.TreePreRunId);
 | |
|                 if (model.PreRunLevel == 3)
 | |
|                 {
 | |
|                     this.SystemIds = new List<string>() { model.PreRunId };
 | |
|                 }
 | |
|                 else if (model.PreRunLevel == 2)
 | |
|                 {
 | |
|                     devices = Funs.DB.PreRun_SysDevice.Where(x => x.ProjectId == this.CurrUser.LoginProjectId && x.PreRunLevel == 3 && x.ProcessesId == model.PreRunId).ToList();
 | |
|                     if (devices.Count > 0)
 | |
|                     {
 | |
|                         this.SystemIds = devices.ConvertAll(x => x.PreRunId);
 | |
|                     }
 | |
|                 }
 | |
|                 else if (model.PreRunLevel == 1)
 | |
|                 {
 | |
|                     devices = Funs.DB.PreRun_SysDevice.Where(x => x.ProjectId == this.CurrUser.LoginProjectId && x.PreRunLevel == 3 && x.InstallationId == model.PreRunId).ToList();
 | |
|                     if (devices.Count > 0)
 | |
|                     {
 | |
|                         this.SystemIds = devices.ConvertAll(x => x.PreRunId);
 | |
|                     }
 | |
|                 }
 | |
|             }
 | |
|             else
 | |
|             {
 | |
|                 devices = Funs.DB.PreRun_SysDevice.Where(x => x.ProjectId == this.CurrUser.LoginProjectId && x.PreRunLevel == 3).ToList();
 | |
|                 if (devices.Count > 0)
 | |
|                 {
 | |
|                     this.SystemIds = devices.ConvertAll(x => x.PreRunId);
 | |
|                 }
 | |
|             }
 | |
|             TestRunBrid();
 | |
|         }
 | |
| 
 | |
|         #endregion
 | |
| 
 | |
|         #region 数据绑定/导出
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 预试车绑定
 | |
|         /// </summary>
 | |
|         public void TestRunBrid()
 | |
|         {
 | |
|             var result = new List<TestRunScheduleDto>();
 | |
|             if (this.SystemIds.Count > 0)
 | |
|             {
 | |
|                 result = GetTestRunSchedules();
 | |
|             }
 | |
| 
 | |
|             GridTestRun.DataSource = result;
 | |
|             GridTestRun.DataBind();
 | |
|             JObject summary = new JObject();
 | |
|             summary.Add("WorkPackNum", result.Sum(x => x.WorkPackNum));
 | |
|             summary.Add("WorkPackNotStartedNum", result.Sum(x => x.WorkPackNotStartedNum));
 | |
|             summary.Add("WorkPackNoCloseNum", result.Sum(x => x.WorkPackNoCloseNum));
 | |
|             summary.Add("WorkPackCloseNum", result.Sum(x => x.WorkPackCloseNum));
 | |
|             summary.Add("InspectNum", result.Sum(x => x.InspectNum));
 | |
|             summary.Add("InspectNoCloseNum", result.Sum(x => x.InspectNoCloseNum));
 | |
|             summary.Add("InspectCloseNum", result.Sum(x => x.InspectCloseNum));
 | |
|             GridTestRun.SummaryData = summary;
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 试车导出
 | |
|         /// </summary>
 | |
|         protected void btnScExport_Click(object sender, EventArgs e)
 | |
|         {
 | |
|             string rootPath = Server.MapPath("~/") + Const.ExcelUrl;
 | |
|             //导出文件
 | |
|             string filePath = rootPath + DateTime.Now.ToString("yyyyMMddhhmmss") + "\\";
 | |
|             if (!Directory.Exists(filePath))
 | |
|             {
 | |
|                 Directory.CreateDirectory(filePath);
 | |
|             }
 | |
|             string ReportFileName = filePath + "试车进度.xlsx";
 | |
| 
 | |
|             var result = GetTestRunSchedules();
 | |
| 
 | |
|             if (result.Count > 0)
 | |
|             {
 | |
|                 XSSFWorkbook hssfworkbook = new XSSFWorkbook();
 | |
|                 XSSFSheet ws = (XSSFSheet)hssfworkbook.CreateSheet("试车进度");
 | |
| 
 | |
|                 #region 列宽
 | |
| 
 | |
|                 ws.SetColumnWidth(0, (30 * 256));
 | |
|                 ws.SetColumnWidth(1, (20 * 256));
 | |
|                 ws.SetColumnWidth(2, (20 * 256));
 | |
|                 ws.SetColumnWidth(3, (20 * 256));
 | |
|                 ws.SetColumnWidth(4, (20 * 256));
 | |
|                 ws.SetColumnWidth(5, (20 * 256));
 | |
|                 ws.SetColumnWidth(6, (20 * 256));
 | |
|                 ws.SetColumnWidth(7, (20 * 256));
 | |
|                 ws.SetColumnWidth(8, (20 * 256));
 | |
|                 ws.SetColumnWidth(9, (20 * 256));
 | |
|                 ws.SetColumnWidth(10, (20 * 256));
 | |
| 
 | |
|                 #endregion
 | |
| 
 | |
|                 #region 样式
 | |
|                 //公共样式
 | |
|                 ICellStyle style = SetExcelStyle(hssfworkbook, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.Thin, VerticalAlignment.Center, HorizontalAlignment.Center, 10.5, true);
 | |
|                 //公共样式加粗
 | |
|                 ICellStyle styleBold = SetExcelStyle(hssfworkbook, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.Thin, VerticalAlignment.Center, HorizontalAlignment.Center, 10.5, true, true);
 | |
| 
 | |
|                 #endregion
 | |
| 
 | |
|                 #region 头部
 | |
| 
 | |
|                 ws = ExcelCreateRowTitle(ws, hssfworkbook, style, 0, 0, 0, 10);
 | |
|                 //行1
 | |
|                 ws.GetRow(0).GetCell(0).CellStyle = styleBold;
 | |
|                 ws.GetRow(0).GetCell(0).SetCellValue("工作包名称");
 | |
|                 ws.GetRow(0).GetCell(1).CellStyle = styleBold;
 | |
|                 ws.GetRow(0).GetCell(1).SetCellValue("装置名称");
 | |
|                 ws.GetRow(0).GetCell(2).CellStyle = styleBold;
 | |
|                 ws.GetRow(0).GetCell(2).SetCellValue("工序名称");
 | |
|                 ws.GetRow(0).GetCell(3).CellStyle = styleBold;
 | |
|                 ws.GetRow(0).GetCell(3).SetCellValue("系统名称");
 | |
|                 ws.GetRow(0).GetCell(4).CellStyle = styleBold;
 | |
|                 ws.GetRow(0).GetCell(4).SetCellValue("工作包数量");
 | |
|                 ws.GetRow(0).GetCell(5).CellStyle = styleBold;
 | |
|                 ws.GetRow(0).GetCell(5).SetCellValue("工作包未开始数量");
 | |
|                 ws.GetRow(0).GetCell(6).CellStyle = styleBold;
 | |
|                 ws.GetRow(0).GetCell(6).SetCellValue("工作包未关闭数量");
 | |
|                 ws.GetRow(0).GetCell(7).CellStyle = styleBold;
 | |
|                 ws.GetRow(0).GetCell(7).SetCellValue("工作包已关闭数量");
 | |
|                 ws.GetRow(0).GetCell(8).CellStyle = styleBold;
 | |
|                 ws.GetRow(0).GetCell(8).SetCellValue("检查表数量");
 | |
|                 ws.GetRow(0).GetCell(9).CellStyle = styleBold;
 | |
|                 ws.GetRow(0).GetCell(9).SetCellValue("检查表未关闭数量");
 | |
|                 ws.GetRow(0).GetCell(10).CellStyle = styleBold;
 | |
|                 ws.GetRow(0).GetCell(10).SetCellValue("检查表已关闭数量");
 | |
| 
 | |
|                 #endregion
 | |
| 
 | |
|                 #region 表格
 | |
| 
 | |
|                 var start = 1;
 | |
|                 var end = result.Count;
 | |
|                 ws = ExcelCreateRowTitle(ws, hssfworkbook, style, start, end, 0, 10);
 | |
| 
 | |
|                 //数据
 | |
|                 var dataIndex = 1;
 | |
|                 foreach (var item in result)
 | |
|                 {
 | |
|                     ws.GetRow(dataIndex).GetCell(0).SetCellValue(item.WorkPackName);
 | |
|                     ws.GetRow(dataIndex).GetCell(1).SetCellValue(item.InstallationName);
 | |
|                     ws.GetRow(dataIndex).GetCell(2).SetCellValue(item.ProcessesName);
 | |
|                     ws.GetRow(dataIndex).GetCell(3).SetCellValue(item.SystemName);
 | |
|                     ws.GetRow(dataIndex).GetCell(4).SetCellValue(item.WorkPackNum);
 | |
|                     ws.GetRow(dataIndex).GetCell(5).SetCellValue(item.WorkPackNotStartedNum);
 | |
|                     ws.GetRow(dataIndex).GetCell(6).SetCellValue(item.WorkPackNoCloseNum);
 | |
|                     ws.GetRow(dataIndex).GetCell(7).SetCellValue(item.WorkPackCloseNum);
 | |
|                     ws.GetRow(dataIndex).GetCell(8).SetCellValue(item.InspectNum);
 | |
|                     ws.GetRow(dataIndex).GetCell(9).SetCellValue(item.InspectNoCloseNum);
 | |
|                     ws.GetRow(dataIndex).GetCell(10).SetCellValue(item.InspectCloseNum);
 | |
|                     dataIndex++;
 | |
|                 }
 | |
| 
 | |
|                 #endregion
 | |
| 
 | |
|                 #region 尾部
 | |
| 
 | |
|                 ws = ExcelCreateRowTitle(ws, hssfworkbook, style, end + 1, end + 1, 0, 10);
 | |
|                 var region = new CellRangeAddress(end + 1, end + 1, 0, 3);
 | |
|                 ws.AddMergedRegion(region);
 | |
|                 ws.GetRow(end + 1).GetCell(0).SetCellValue("合计");
 | |
|                 ws.GetRow(end + 1).GetCell(4).SetCellValue(result.Count > 0 ? result.Sum(x => x.WorkPackNum).ToString() : "0");
 | |
|                 ws.GetRow(end + 1).GetCell(5).SetCellValue(result.Count > 0 ? result.Sum(x => x.WorkPackNotStartedNum).ToString() : "0");
 | |
|                 ws.GetRow(end + 1).GetCell(6).SetCellValue(result.Count > 0 ? result.Sum(x => x.WorkPackNoCloseNum).ToString() : "0");
 | |
|                 ws.GetRow(end + 1).GetCell(7).SetCellValue(result.Count > 0 ? result.Sum(x => x.WorkPackCloseNum).ToString() : "0");
 | |
|                 ws.GetRow(end + 1).GetCell(8).SetCellValue(result.Count > 0 ? result.Sum(x => x.InspectNum).ToString() : "0");
 | |
|                 ws.GetRow(end + 1).GetCell(9).SetCellValue(result.Count > 0 ? result.Sum(x => x.InspectNoCloseNum).ToString() : "0");
 | |
|                 ws.GetRow(end + 1).GetCell(10).SetCellValue(result.Count > 0 ? result.Sum(x => x.InspectCloseNum).ToString() : "0");
 | |
| 
 | |
|                 #endregion
 | |
| 
 | |
|                 ws.PrintSetup.Landscape = false;
 | |
|                 ws.PrintSetup.PaperSize = 9;
 | |
|                 ws.ForceFormulaRecalculation = true;
 | |
|                 using (FileStream filess = File.OpenWrite(ReportFileName))
 | |
|                 {
 | |
|                     hssfworkbook.Write(filess);
 | |
|                 }
 | |
|                 FileInfo filet = new FileInfo(ReportFileName);
 | |
|                 Response.Clear();
 | |
|                 Response.Charset = "GB2312";
 | |
|                 Response.ContentEncoding = System.Text.Encoding.UTF8;
 | |
|                 // 添加头信息,为"文件下载/另存为"对话框指定默认文件名
 | |
|                 Response.AddHeader("Content-Disposition", "attachment; filename=" + Server.UrlEncode("试车进度.xlsx"));
 | |
|                 // 添加头信息,指定文件大小,让浏览器能够显示下载进度
 | |
|                 Response.AddHeader("Content-Length", filet.Length.ToString());
 | |
|                 // 指定返回的是一个不能被客户端读取的流,必须被下载
 | |
|                 Response.ContentType = "application/ms-excel";
 | |
|                 // 把文件流发送到客户端
 | |
|                 Response.WriteFile(filet.FullName);
 | |
|                 // 停止页面的执行
 | |
|                 Response.End();
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         #endregion
 | |
| 
 | |
|         #region 私有方法
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 创建头部
 | |
|         /// </summary>
 | |
|         /// <returns></returns>
 | |
|         private XSSFSheet ExcelCreateRowTitle(XSSFSheet ws, XSSFWorkbook hssfworkbook, ICellStyle style, int sRows, int eRows, int cStart, int cEnd, float height = 21)
 | |
|         {
 | |
|             for (int i = sRows; i <= eRows; i++)
 | |
|             {
 | |
|                 ws.CreateRow(i);
 | |
|                 ws.GetRow(i).HeightInPoints = height;
 | |
|                 for (int j = cStart; j <= cEnd; j++)
 | |
|                 {
 | |
|                     ws.GetRow(i).CreateCell(j);
 | |
|                     ws.GetRow(i).CreateCell(j).CellStyle = style;
 | |
|                 }
 | |
|             }
 | |
|             return ws;
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 创建样式
 | |
|         /// </summary>
 | |
|         /// <returns></returns>
 | |
|         public static ICellStyle SetExcelStyle(XSSFWorkbook wb, BorderStyle Bottom, BorderStyle Left, BorderStyle Right, BorderStyle Top, VerticalAlignment VerAig, HorizontalAlignment HorAig, double FontSize, bool WrapText = true, bool Bold = false, string FontName = "宋体")
 | |
|         {
 | |
|             ICellStyle style = wb.CreateCellStyle();
 | |
|             style.BorderBottom = Bottom;
 | |
|             style.BorderLeft = Left;
 | |
|             style.BorderRight = Right;
 | |
|             style.BorderTop = Top;
 | |
|             style.VerticalAlignment = VerAig;
 | |
|             style.Alignment = HorAig;
 | |
|             IFont font = wb.CreateFont();
 | |
|             font.FontHeightInPoints = FontSize;
 | |
|             font.IsBold = Bold;
 | |
|             font.FontName = FontName;
 | |
|             style.SetFont(font);
 | |
|             style.WrapText = WrapText;
 | |
|             return style;
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 获取试车统计
 | |
|         /// </summary>
 | |
|         /// <returns></returns>
 | |
|         private List<TestRunScheduleDto> GetTestRunSchedules()
 | |
|         {
 | |
|             var list = new List<TestRunScheduleDto>();
 | |
| 
 | |
|             string allStr = $"select b.WorkPackId,b.WorkPackName,COUNT(a.SystemId) as WorkPackNum from TestRun_SubSysWorkPackage as a inner join TestRun_WorkPackage as b on a.WorkPackId = b.WorkPackId where a.SystemId in ('{string.Join("','", this.SystemIds)}') group by b.WorkPackId,b.WorkPackName";
 | |
|             var dt = SQLHelper.GetDataTableRunText(allStr);
 | |
| 
 | |
|             string inspectStr = $"select a.WorkPackId,b.WorkPackName,b.Sort,SUM(case ISNULL(a.InspectIsClose, 0) when 1 then 1 else 0 end) as CloseNum,SUM(case ISNULL(a.InspectIsClose, 0) when 0 then 1 else 0 end) as NoCloseNum,COUNT(1) as AllNum from TestRun_SubInspectTerm as a inner join TestRun_WorkPackage as b on a.WorkPackId = b.WorkPackId where 1=1 and a.ProjectId = '{this.CurrUser.LoginProjectId}' group by a.WorkPackId,b.WorkPackName,b.Sort order by b.Sort asc";
 | |
|             var inspectDt = SQLHelper.GetDataTableRunText(inspectStr);
 | |
|             var inspectlist = DataTableToList<WorkPackageInspectDto>(inspectDt);
 | |
| 
 | |
|             string deviceStr = $"select b.PreRunName as InstallationName,c.PreRunName as ProcessesName,d.PreRunName as SystemName from PreRun_SysDevice as a left join PreRun_SysDevice as b on b.PreRunId=ISNULL(a.InstallationId,a.PreRunId) left join PreRun_SysDevice as c on c.PreRunId=a.ProcessesId left join PreRun_SysDevice as d on d.PreRunId=a.SystemId where a.PreRunId='{this.TreePreRunId}'";
 | |
|             var driveDt = SQLHelper.GetDataTableRunText(deviceStr);
 | |
| 
 | |
|             if (dt.Rows.Count > 0)
 | |
|             {
 | |
|                 list = DataTableToList<TestRunScheduleDto>(dt);
 | |
|                 foreach (var item in list)
 | |
|                 {
 | |
|                     if (inspectlist.Count(x => x.WorkPackId == item.WorkPackId) > 0)
 | |
|                     {
 | |
|                         var itemInspect = inspectlist.FirstOrDefault(x => x.WorkPackId == item.WorkPackId);
 | |
|                         item.InspectNum = itemInspect.AllNum;
 | |
|                         item.InspectCloseNum = itemInspect.CloseNum;
 | |
|                         item.InspectNoCloseNum = itemInspect.NoCloseNum;
 | |
|                         item.WorkPackCloseNum = itemInspect.CloseNum;
 | |
|                         item.WorkPackNoCloseNum = itemInspect.NoCloseNum;
 | |
|                         item.WorkPackNum = itemInspect.CloseNum + itemInspect.NoCloseNum;
 | |
|                     }
 | |
|                     else
 | |
|                     {
 | |
|                         item.InspectNum = 0;
 | |
|                         item.InspectCloseNum = 0;
 | |
|                         item.InspectNoCloseNum = 0;
 | |
|                         item.WorkPackNotStartedNum = 1;
 | |
|                         item.WorkPackNoCloseNum = 0;
 | |
|                         item.WorkPackCloseNum = 0;
 | |
|                         item.WorkPackNum = 1;
 | |
|                     }
 | |
|                     if (driveDt.Rows.Count > 0)
 | |
|                     {
 | |
|                         item.InstallationName = driveDt.Rows[0]["InstallationName"].ToString();
 | |
|                         item.ProcessesName = driveDt.Rows[0]["ProcessesName"].ToString();
 | |
|                         item.SystemName = driveDt.Rows[0]["SystemName"].ToString();
 | |
|                     }
 | |
|                 }
 | |
|             }
 | |
| 
 | |
|             return list;
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 试车统计实体
 | |
|         /// </summary>
 | |
|         public class TestRunScheduleDto
 | |
|         {
 | |
|             /// <summary>
 | |
|             /// 工作包主键
 | |
|             /// </summary>
 | |
|             public string WorkPackId { get; set; }
 | |
|             /// <summary>
 | |
|             /// 工作包名称
 | |
|             /// </summary>
 | |
|             public string WorkPackName { get; set; }
 | |
|             /// <summary>
 | |
|             /// 装置名称
 | |
|             /// </summary>
 | |
|             public string InstallationName { get; set; }
 | |
|             /// <summary>
 | |
|             /// 工序名称
 | |
|             /// </summary>
 | |
|             public string ProcessesName { get; set; }
 | |
|             /// <summary>
 | |
|             /// 系统名称
 | |
|             /// </summary>
 | |
|             public string SystemName { get; set; }
 | |
|             /// <summary>
 | |
|             /// 工作包数量
 | |
|             /// </summary>
 | |
|             public int WorkPackNum { get; set; }
 | |
|             /// <summary>
 | |
|             /// 工作包未关闭数量
 | |
|             /// </summary>
 | |
|             public int WorkPackNoCloseNum { get; set; }
 | |
|             /// <summary>
 | |
|             /// 工作包未开始数量
 | |
|             /// </summary>
 | |
|             public int WorkPackNotStartedNum { get; set; }
 | |
|             /// <summary>
 | |
|             /// 工作包已关闭数量
 | |
|             /// </summary>
 | |
|             public int WorkPackCloseNum { get; set; }
 | |
|             /// <summary>
 | |
|             /// 检查表数量
 | |
|             /// </summary>
 | |
|             public int InspectNum { get; set; }
 | |
|             /// <summary>
 | |
|             /// 检查表未关闭数量
 | |
|             /// </summary>
 | |
|             public int InspectNoCloseNum { get; set; }
 | |
|             /// <summary>
 | |
|             /// 检查表已关闭数量
 | |
|             /// </summary>
 | |
|             public int InspectCloseNum { get; set; }
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 试车检查表实体
 | |
|         /// </summary>
 | |
|         public class WorkPackageInspectDto
 | |
|         {
 | |
|             /// <summary>
 | |
|             /// 工作包主键
 | |
|             /// </summary>
 | |
|             public string WorkPackId { get; set; }
 | |
|             /// <summary>
 | |
|             /// 工作包名称
 | |
|             /// </summary>
 | |
|             public string WorkPackName { get; set; }
 | |
|             /// <summary>
 | |
|             /// 检查表数量
 | |
|             /// </summary>
 | |
|             public int AllNum { get; set; }
 | |
|             /// <summary>
 | |
|             /// 未关闭任务单数量
 | |
|             /// </summary>
 | |
|             public int NoCloseNum { get; set; }
 | |
|             /// <summary>
 | |
|             /// 已关闭任务单数量
 | |
|             /// </summary>
 | |
|             public int CloseNum { get; set; }
 | |
|         }
 | |
| 
 | |
|         #endregion
 | |
| 
 | |
|         #region 转换
 | |
| 
 | |
|         /// <summary>
 | |
|         /// DataTable转换List
 | |
|         /// </summary>
 | |
|         /// <returns></returns>
 | |
|         public List<T> DataTableToList<T>(DataTable table)
 | |
|         {
 | |
|             List<T> list = new List<T>();
 | |
|             T t = default(T);
 | |
|             PropertyInfo[] propertypes = null;
 | |
|             string tempName = string.Empty;
 | |
|             foreach (DataRow row in table.Rows)
 | |
|             {
 | |
|                 t = Activator.CreateInstance<T>();
 | |
|                 propertypes = t.GetType().GetProperties();
 | |
|                 foreach (PropertyInfo pro in propertypes)
 | |
|                 {
 | |
|                     tempName = pro.Name;
 | |
|                     if (table.Columns.Contains(tempName))
 | |
|                     {
 | |
|                         object value = row[tempName];
 | |
|                         if (!value.ToString().Equals(""))
 | |
|                         {
 | |
|                             pro.SetValue(t, value, null);
 | |
|                         }
 | |
|                     }
 | |
|                 }
 | |
|                 list.Add(t);
 | |
|             }
 | |
|             return list.Count == 0 ? new List<T>() : list;
 | |
|         }
 | |
| 
 | |
|         #endregion
 | |
| 
 | |
|     }
 | |
| } |