提交代码
This commit is contained in:
@@ -1,14 +1,23 @@
|
||||
using Aspose.Words.Lists;
|
||||
using BLL;
|
||||
using FineUIPro.Web.DataShow;
|
||||
using Model;
|
||||
using System;
|
||||
using System.ArrayExtensions;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Web;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
using WIA;
|
||||
using NPOI.SS.UserModel;
|
||||
using NPOI.SS.Util;
|
||||
using NPOI.XSSF.UserModel;
|
||||
using System.Drawing;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace FineUIPro.Web.TestRun.Report
|
||||
{
|
||||
@@ -21,14 +30,14 @@ namespace FineUIPro.Web.TestRun.Report
|
||||
/// <summary>
|
||||
/// 子系统主键
|
||||
/// </summary>
|
||||
public string SsubSystemId { get { return (string)ViewState["SsubSystemId"]; } set { ViewState["SsubSystemId"] = value; } }
|
||||
public List<string> SubSystemIds { get { return (List<string>)ViewState["SubSystemIds"]; } set { ViewState["SubSystemIds"] = value; } }
|
||||
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (!IsPostBack)
|
||||
{
|
||||
if (SubSystemIds == null) SubSystemIds = new List<string>();
|
||||
this.InitTreeMenu();//加载树
|
||||
TabStrip1.ActiveTabIndex = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,146 +117,214 @@ namespace FineUIPro.Web.TestRun.Report
|
||||
/// <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 (TabStrip1.ActiveTabIndex == 0)
|
||||
if (!string.IsNullOrWhiteSpace(this.TreePreRunId))
|
||||
{
|
||||
PreRunBrid();
|
||||
var model = Funs.DB.PreRun_SysDevice.FirstOrDefault(x => x.PreRunId == this.TreePreRunId);
|
||||
if (model.PreRunLevel == 4)
|
||||
{
|
||||
this.SubSystemIds = new List<string>() { model.PreRunId };
|
||||
}
|
||||
else if (model.PreRunLevel == 3)
|
||||
{
|
||||
devices = Funs.DB.PreRun_SysDevice.Where(x => x.ProjectId == this.CurrUser.LoginProjectId && x.PreRunLevel == 4 && x.SystemId == model.PreRunId).ToList();
|
||||
if (devices.Count > 0)
|
||||
{
|
||||
this.SubSystemIds = devices.ConvertAll(x => x.PreRunId);
|
||||
}
|
||||
}
|
||||
else if (model.PreRunLevel == 2)
|
||||
{
|
||||
devices = Funs.DB.PreRun_SysDevice.Where(x => x.ProjectId == this.CurrUser.LoginProjectId && x.PreRunLevel == 4 && x.ProcessesId == model.PreRunId).ToList();
|
||||
if (devices.Count > 0)
|
||||
{
|
||||
this.SubSystemIds = devices.ConvertAll(x => x.PreRunId);
|
||||
}
|
||||
}
|
||||
else if (model.PreRunLevel == 1)
|
||||
{
|
||||
devices = Funs.DB.PreRun_SysDevice.Where(x => x.ProjectId == this.CurrUser.LoginProjectId && x.PreRunLevel == 4 && x.InstallationId == model.PreRunId).ToList();
|
||||
if (devices.Count > 0)
|
||||
{
|
||||
this.SubSystemIds = devices.ConvertAll(x => x.PreRunId);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (TabStrip1.ActiveTabIndex == 1)
|
||||
else
|
||||
{
|
||||
FourDecisionBrid();
|
||||
devices = Funs.DB.PreRun_SysDevice.Where(x => x.ProjectId == this.CurrUser.LoginProjectId && x.PreRunLevel == 4).ToList();
|
||||
if (devices.Count > 0)
|
||||
{
|
||||
this.SubSystemIds = devices.ConvertAll(x => x.PreRunId);
|
||||
}
|
||||
}
|
||||
PreRunBrid();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 数据绑定
|
||||
#region 数据绑定/导出
|
||||
|
||||
/// <summary>
|
||||
/// 预试车绑定
|
||||
/// </summary>
|
||||
public void PreRunBrid()
|
||||
{
|
||||
var result = new List<ScheduleBridDto>();
|
||||
string strSql = "select a.WorkPackId,b.WorkPackName,b.Sort,SUM(case ISNULL(a.InspectIsClose,0) when 1 then 1 else 0 end) as ygbnum,SUM(case ISNULL(a.InspectIsClose,0) when 0 then 1 else 0 end) as wgbnum,COUNT(1) as allnum from PreRun_SubInspectTerm as a inner join PreRun_WorkPackage as b on a.WorkPackId=b.WorkPackId where 1=1 and a.ProjectId=@ProjectId ";
|
||||
List<SqlParameter> listStr = new List<SqlParameter>();
|
||||
listStr.Add(new SqlParameter("@ProjectId", this.CurrUser.LoginProjectId));
|
||||
string installationName = "-";
|
||||
string processesName = "-";
|
||||
string systemName = "-";
|
||||
string subsystemName = "-";
|
||||
string columnames = string.Empty;
|
||||
if (!string.IsNullOrWhiteSpace(this.TreePreRunId))
|
||||
var result = new List<PreRunScheduleDto>();
|
||||
if (this.SubSystemIds.Count > 0)
|
||||
{
|
||||
var model = Funs.DB.PreRun_SysDevice.FirstOrDefault(p => p.PreRunId == this.TreePreRunId);
|
||||
if (model.PreRunLevel == 1)
|
||||
{
|
||||
installationName = model.PreRunName;
|
||||
columnames = "a.InstallationId";
|
||||
}
|
||||
else if (model.PreRunLevel == 2)
|
||||
{
|
||||
processesName = model.PreRunName;
|
||||
columnames = "a.ProcessesId";
|
||||
}
|
||||
else if (model.PreRunLevel == 3)
|
||||
{
|
||||
systemName = model.PreRunName;
|
||||
columnames = "a.SystemId";
|
||||
}
|
||||
else if (model.PreRunLevel == 4)
|
||||
{
|
||||
subsystemName = model.PreRunName;
|
||||
columnames = "a.SubsystemId";
|
||||
}
|
||||
strSql += $"and {columnames}='{model.PreRunId}'";
|
||||
}
|
||||
strSql += "group by a.WorkPackId,b.WorkPackName,b.Sort order by b.Sort asc";
|
||||
SqlParameter[] parameter = listStr.ToArray();
|
||||
var dt = SQLHelper.GetDataTableRunText(strSql, parameter);
|
||||
if (dt != null)
|
||||
{
|
||||
foreach (DataRow item in dt.Rows)
|
||||
{
|
||||
result.Add(new ScheduleBridDto()
|
||||
{
|
||||
WorkPackId = item["WorkPackId"].ToString(),
|
||||
WorkName = item["WorkPackName"].ToString(),
|
||||
InstallationName = installationName,
|
||||
ProcessesName = processesName,
|
||||
SystemName = systemName,
|
||||
SubsystemName = subsystemName,
|
||||
AllNum = item["allnum"].ToString(),
|
||||
NoCloseNum = item["wgbnum"].ToString(),
|
||||
CloseNum = item["ygbnum"].ToString()
|
||||
});
|
||||
}
|
||||
result = GetPreRunSchedules();
|
||||
}
|
||||
GridPreRun.DataSource = result;
|
||||
GridPreRun.DataBind();
|
||||
JObject summary = new JObject();
|
||||
summary.Add("WorkPackNum", result.Sum(x => x.WorkPackNum));
|
||||
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));
|
||||
GridPreRun.SummaryData = summary;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 三查四定绑定
|
||||
/// 导出
|
||||
/// </summary>
|
||||
public void FourDecisionBrid()
|
||||
protected void btnYscExport_Click(object sender, EventArgs e)
|
||||
{
|
||||
var result = new List<ScheduleBridDto>();
|
||||
string strSql = "select b.PreRunId,b.InstallationId,b.ProcessesId,b.SystemId,b.SubsystemId,b.Sort,SUM(case ISNULL(a.DecisionIsClose,0) when 1 then 1 else 0 end) as ygbnum,SUM(case ISNULL(a.DecisionIsClose,0) when 0 then 1 else 0 end) as wgbnum,COUNT(1) as allnum from PreRun_SubThreeChecksFourDecision as a inner join PreRun_SysDevice as b on a.SubSystemId=b.PreRunId where 1=1 and a.ProjectId=@ProjectId ";
|
||||
List<SqlParameter> listStr = new List<SqlParameter>();
|
||||
listStr.Add(new SqlParameter("@ProjectId", this.CurrUser.LoginProjectId));
|
||||
string installationName = "-";
|
||||
string processesName = "-";
|
||||
string systemName = "-";
|
||||
string subsystemName = "-";
|
||||
string columnames = string.Empty;
|
||||
if (!string.IsNullOrWhiteSpace(this.TreePreRunId))
|
||||
string rootPath = Server.MapPath("~/") + Const.ExcelUrl;
|
||||
//导出文件
|
||||
string filePath = rootPath + DateTime.Now.ToString("yyyyMMddhhmmss") + "\\";
|
||||
if (!Directory.Exists(filePath))
|
||||
{
|
||||
var model = Funs.DB.PreRun_SysDevice.FirstOrDefault(p => p.PreRunId == this.TreePreRunId);
|
||||
if (model.PreRunLevel == 1)
|
||||
{
|
||||
installationName = model.PreRunName;
|
||||
columnames = "b.InstallationId";
|
||||
}
|
||||
else if (model.PreRunLevel == 2)
|
||||
{
|
||||
processesName = model.PreRunName;
|
||||
columnames = "b.ProcessesId";
|
||||
}
|
||||
else if (model.PreRunLevel == 3)
|
||||
{
|
||||
systemName = model.PreRunName;
|
||||
columnames = "b.SystemId";
|
||||
}
|
||||
else if (model.PreRunLevel == 4)
|
||||
{
|
||||
subsystemName = model.PreRunName;
|
||||
columnames = "b.SubsystemId";
|
||||
}
|
||||
strSql += $"and {columnames}='{model.PreRunId}'";
|
||||
Directory.CreateDirectory(filePath);
|
||||
}
|
||||
strSql += "group by b.PreRunId,b.InstallationId,b.ProcessesId,b.SystemId,b.SubsystemId,b.Sort order by b.Sort asc";
|
||||
SqlParameter[] parameter = listStr.ToArray();
|
||||
var dt = SQLHelper.GetDataTableRunText(strSql, parameter);
|
||||
if (dt != null)
|
||||
string ReportFileName = filePath + "预试车进度.xlsx";
|
||||
|
||||
var result = GetPreRunSchedules();
|
||||
|
||||
if (result.Count > 0)
|
||||
{
|
||||
foreach (DataRow item in dt.Rows)
|
||||
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)
|
||||
{
|
||||
result.Add(new ScheduleBridDto()
|
||||
{
|
||||
PreRunId = item["PreRunId"].ToString(),
|
||||
InstallationName = installationName,
|
||||
ProcessesName = processesName,
|
||||
SystemName = systemName,
|
||||
SubsystemName = subsystemName,
|
||||
AllNum = item["allnum"].ToString(),
|
||||
NoCloseNum = item["wgbnum"].ToString(),
|
||||
CloseNum = item["ygbnum"].ToString()
|
||||
});
|
||||
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.SubsystemName);
|
||||
ws.GetRow(dataIndex).GetCell(5).SetCellValue(item.WorkPackNum);
|
||||
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, 4);
|
||||
ws.AddMergedRegion(region);
|
||||
ws.GetRow(end + 1).GetCell(0).SetCellValue("合计");
|
||||
ws.GetRow(end + 1).GetCell(5).SetCellValue(result.Count > 0 ? result.Sum(x => x.WorkPackNum).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();
|
||||
}
|
||||
GridFourDecision.DataSource = result;
|
||||
GridFourDecision.DataBind();
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -255,18 +332,146 @@ namespace FineUIPro.Web.TestRun.Report
|
||||
#region 私有方法
|
||||
|
||||
/// <summary>
|
||||
/// 点击tab
|
||||
/// 创建头部
|
||||
/// </summary>
|
||||
protected void TabStrip1_TabIndexChanged(object sender, EventArgs e)
|
||||
/// <returns></returns>
|
||||
private XSSFSheet ExcelCreateRowTitle(XSSFSheet ws, XSSFWorkbook hssfworkbook, ICellStyle style, int sRows, int eRows, int cStart, int cEnd, float height = 21)
|
||||
{
|
||||
if (TabStrip1.ActiveTabIndex == 0)
|
||||
for (int i = sRows; i <= eRows; i++)
|
||||
{
|
||||
PreRunBrid();
|
||||
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;
|
||||
}
|
||||
}
|
||||
else if (TabStrip1.ActiveTabIndex == 1)
|
||||
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<PreRunScheduleDto> GetPreRunSchedules()
|
||||
{
|
||||
string allStr = $"select a.SubSystemId,a.SystemId,b.WorkPackId,b.WorkPackName,b.WorkPackType,(select count(1) from PreRun_SubPropertySelect as gd where gd.SubSystemId = a.SubSystemId) as GdallNum,(select count(1) from PreRun_SubTechnologySelect as sb where sb.SubSystemId = a.SubSystemId) as SballNum,(select count(1) from PreRun_SubInstrumentSelect as sy where sy.SubSystemId = a.SubSystemId) as SyallNum from PreRun_SubSysWorkPackage as a inner join PreRun_WorkPackage as b on a.WorkPackId = b.WorkPackId where a.SubSystemId in ('{string.Join("','", this.SubSystemIds)}') order by a.WorkPackCode asc";
|
||||
var dt = SQLHelper.GetDataTableRunText(allStr);
|
||||
|
||||
var list = new List<PreRunScheduleDto>();
|
||||
string deviceStr = $"select b.PreRunName as InstallationName,c.PreRunName as ProcessesName,d.PreRunName as SystemName,e.PreRunName as SubsystemName 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 left join PreRun_SysDevice as e on e.PreRunId=a.SubsystemId where a.PreRunId='{this.TreePreRunId}'";
|
||||
var driveDt = SQLHelper.GetDataTableRunText(deviceStr);
|
||||
|
||||
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 PreRun_SubInspectTerm as a inner join PreRun_WorkPackage as b on a.WorkPackId = b.WorkPackId where 1=1 and a.ProjectId = '{this.CurrUser.LoginProjectId}' and a.SubSystemId in ('{string.Join("','", this.SubSystemIds)}') group by a.WorkPackId,b.WorkPackName,b.Sort order by b.Sort asc";
|
||||
var inspectDt = SQLHelper.GetDataTableRunText(inspectStr);
|
||||
var inspectlist = DataTableToList<WorkPackageInspectDto>(inspectDt);
|
||||
if (dt.Rows.Count > 0)
|
||||
{
|
||||
FourDecisionBrid();
|
||||
//获取所有子系统数量
|
||||
var inspects = Funs.DB.PreRun_SubInspectTerm.Where(x => x.ProjectId == this.CurrUser.LoginProjectId && this.SubSystemIds.Contains(x.SubSystemId));
|
||||
var querylist = DataTableToList<QuerySubSysWorkPackage>(dt);
|
||||
var queryGroup = querylist.GroupBy(x => new { x.WorkPackId, x.WorkPackName, x.WorkPackType }).Select(p => new
|
||||
{
|
||||
p.Key.WorkPackId,
|
||||
p.Key.WorkPackName,
|
||||
p.Key.WorkPackType,
|
||||
GdallNum = p.Sum(i => i.GdallNum),
|
||||
SballNum = p.Sum(i => i.SballNum),
|
||||
SyallNum = p.Sum(i => i.SyallNum)
|
||||
});
|
||||
foreach (var itemPack in queryGroup)
|
||||
{
|
||||
var itemQueryList = querylist.Where(x => x.WorkPackId == itemPack.WorkPackId).ToList();
|
||||
var model = new PreRunScheduleDto();
|
||||
model.WorkPackId = itemPack.WorkPackId;
|
||||
model.WorkPackName = itemPack.WorkPackName;
|
||||
model.WorkPackType = itemPack.WorkPackType;
|
||||
if (driveDt.Rows.Count > 0)
|
||||
{
|
||||
model.InstallationName = driveDt.Rows[0]["InstallationName"].ToString();
|
||||
model.ProcessesName = driveDt.Rows[0]["ProcessesName"].ToString();
|
||||
model.SystemName = driveDt.Rows[0]["SystemName"].ToString();
|
||||
model.SubsystemName = driveDt.Rows[0]["SubsystemName"].ToString();
|
||||
}
|
||||
model.GdallNum = itemPack.GdallNum;
|
||||
model.SballNum = itemPack.SballNum;
|
||||
model.SyallNum = itemPack.SyallNum;
|
||||
model.AllGdSbYbNum = (itemPack.GdallNum + itemPack.SballNum + itemPack.SyallNum);
|
||||
model.WorkPackNum = itemQueryList.Count(x => x.WorkPackId == itemPack.WorkPackId);
|
||||
if (inspectlist.Count(a => a.WorkPackId == itemPack.WorkPackId) > 0)
|
||||
{
|
||||
var itemInspect = inspectlist.FirstOrDefault(a => a.WorkPackId == itemPack.WorkPackId);
|
||||
model.InspectNum = itemInspect.AllNum;
|
||||
model.InspectNoCloseNum = itemInspect.NoCloseNum;
|
||||
model.InspectCloseNum = itemInspect.CloseNum;
|
||||
}
|
||||
else
|
||||
{
|
||||
model.WorkPackCloseNum = 0;
|
||||
model.WorkPackNoCloseNum = model.WorkPackNum;
|
||||
model.InspectNum = 0;
|
||||
model.InspectNoCloseNum = 0;
|
||||
model.InspectCloseNum = 0;
|
||||
}
|
||||
model.WorkPackCloseNum = 0;
|
||||
model.WorkPackNoCloseNum = 0;
|
||||
var subsystemids = itemQueryList.ConvertAll(a => a.SubSystemId).Distinct();
|
||||
foreach (var itemsubid in subsystemids)
|
||||
{
|
||||
if (inspects.Count(x => x.SubSystemId == itemsubid) > 0)
|
||||
{
|
||||
var itemQuerylist = itemQueryList.FirstOrDefault(x => x.SubSystemId == itemsubid && x.WorkPackId == itemPack.WorkPackId);
|
||||
var allNum = itemQuerylist.GdallNum + itemQuerylist.SballNum + itemQuerylist.SyallNum;
|
||||
if (inspects.Count(x => x.SubInspectId == itemsubid && x.InspectIsClose != 1) > 0)
|
||||
{
|
||||
model.WorkPackNoCloseNum += 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
var closeInspect = inspects.Where(x => x.SubInspectId == itemsubid && x.InspectIsClose == 1);
|
||||
var closeNums = closeInspect.Count() > 0 ? closeInspect.Select(x => x.PropertyTechnologyId.Split(',').Count()).Sum(x => x) : 0;
|
||||
if (allNum > closeNums)
|
||||
{
|
||||
model.WorkPackNoCloseNum += 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
model.WorkPackCloseNum += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
model.WorkPackNoCloseNum += 1;
|
||||
}
|
||||
}
|
||||
list.Add(model);
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -316,6 +521,186 @@ namespace FineUIPro.Web.TestRun.Report
|
||||
public string CloseNum { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 预试车统计实体
|
||||
/// </summary>
|
||||
public class PreRunScheduleDto
|
||||
{
|
||||
/// <summary>
|
||||
/// 工作包主键
|
||||
/// </summary>
|
||||
public string WorkPackId { get; set; }
|
||||
/// <summary>
|
||||
/// 工作包名称
|
||||
/// </summary>
|
||||
public string WorkPackName { get; set; }
|
||||
/// <summary>
|
||||
/// 工作包类型
|
||||
/// </summary>
|
||||
public int WorkPackType { 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 string SubsystemName { get; set; }
|
||||
/// <summary>
|
||||
/// 所有管道,设备,仪表索引数量
|
||||
/// </summary>
|
||||
public int AllGdSbYbNum { get; set; }
|
||||
/// <summary>
|
||||
/// 工作包所有管道数量
|
||||
/// </summary>
|
||||
public int GdallNum { get; set; }
|
||||
/// <summary>
|
||||
/// 工作包所有设备数量
|
||||
/// </summary>
|
||||
public int SballNum { get; set; }
|
||||
/// <summary>
|
||||
/// 工作包所有仪表索引数量
|
||||
/// </summary>
|
||||
public int SyallNum { get; set; }
|
||||
/// <summary>
|
||||
/// 工作包数量
|
||||
/// </summary>
|
||||
public int WorkPackNum { get; set; }
|
||||
/// <summary>
|
||||
/// 工作包未关闭数量
|
||||
/// </summary>
|
||||
public int WorkPackNoCloseNum { 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 SubSystemId { get; set; }
|
||||
/// <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; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 子系统工作包和总设备/管道/仪表数量
|
||||
/// </summary>
|
||||
public class QuerySubSysWorkPackage
|
||||
{
|
||||
/// <summary>
|
||||
/// 子系统主键
|
||||
/// </summary>
|
||||
public string SubSystemId { get; set; }
|
||||
/// <summary>
|
||||
/// 系统主键
|
||||
/// </summary>
|
||||
public string SystemId { get; set; }
|
||||
/// <summary>
|
||||
/// 工作包主键
|
||||
/// </summary>
|
||||
public string WorkPackId { get; set; }
|
||||
/// <summary>
|
||||
/// 工作包名称
|
||||
/// </summary>
|
||||
public string WorkPackName { get; set; }
|
||||
/// <summary>
|
||||
/// 工作包类型
|
||||
/// </summary>
|
||||
public int WorkPackType { get; set; }
|
||||
/// <summary>
|
||||
/// 管道总数量
|
||||
/// </summary>
|
||||
public int GdallNum { get; set; }
|
||||
/// <summary>
|
||||
/// 设备总数量
|
||||
/// </summary>
|
||||
public int SballNum { get; set; }
|
||||
/// <summary>
|
||||
/// 仪表索引总数量
|
||||
/// </summary>
|
||||
public int SyallNum { 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
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user