CNCEC_SUBQHSE_WUHUAN/SGGL/FineUIPro.Web/Transfer/Chart/Systemstatus.aspx.cs

447 lines
20 KiB
C#
Raw Normal View History

2024-07-30 14:08:46 +08:00
using BLL;
2024-07-30 15:29:18 +08:00
using Newtonsoft.Json.Linq;
2024-07-30 14:08:46 +08:00
using System;
2024-07-29 18:06:25 +08:00
using System.Collections.Generic;
2024-07-30 14:08:46 +08:00
using System.Data;
using System.Data.SqlClient;
2024-07-29 18:06:25 +08:00
using System.Linq;
2024-07-30 15:29:18 +08:00
using System.Text;
2024-07-29 18:06:25 +08:00
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
2024-07-30 15:29:18 +08:00
using static FineUIPro.Web.CQMS.Performance.Performance;
using AspNet = System.Web.UI.WebControls;
2024-07-29 18:06:25 +08:00
namespace FineUIPro.Web.Transfer.Chart
{
2024-07-30 14:08:46 +08:00
public partial class Systemstatus : PageBase
2024-07-29 18:06:25 +08:00
{
2024-07-30 14:08:46 +08:00
#region
/// <summary>
/// 加载页面
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
2024-07-29 18:06:25 +08:00
protected void Page_Load(object sender, EventArgs e)
{
2024-07-30 14:08:46 +08:00
if (!IsPostBack)
{
var systemCode = Funs.DB.Transfer_LHCSystemList
.Where(x => x.ProjectId == CurrUser.LoginProjectId)
.GroupBy(p => new { p.SystemNo })
.Select(p => new { SystemNo = p.Key.SystemNo }).ToList();
int indexRow = 1;
ddlSystemNo.Items.Insert(0, new FineUIPro.ListItem("ALL", ""));
foreach (var t in systemCode)
{
ddlSystemNo.Items.Insert(indexRow, new FineUIPro.ListItem(t.SystemNo, t.SystemNo));
indexRow++;
}
2024-07-29 18:06:25 +08:00
2024-07-30 14:08:46 +08:00
BindGrid();
}
}
public DataTable DataSql()
{
string strSql = @"
select f.SystemNo,f.ProjectId,
ISNULL(tpi.PipingCount,0) PipingCount,ISNULL(tpi1.PipingScount,0) PipingScount,
case ISNULL(tpi.PipingCount,0)
when 0 then 0
else 100*(ISNULL(tpi1.PipingScount,0)/ISNULL(tpi.PipingCount,0)) end PipingPercent,
ISNULL((TseCount+TreCount),0) as EqCount,ISNULL((TseSCount+TreSCount),0) as EqScount,
case ISNULL((TseCount+TreCount),0)
when 0 then 0
else 100 *(ISNULL((TseSCount+TreSCount),0)/ISNULL((TseCount+TreCount),0)) end EqPercent,
ISNULL(TeCount,0) TeCount,ISNULL(TeScount,0) TeScount,
case ISNULL(TeCount,0)
when 0 then 0
else 100*(ISNULL(TeScount,0)/ISNULL(TeCount,0)) end TePercent,
ISNULL(TiCount,0) TiCount,ISNULL(TiScount,0) TiScount,
case ISNULL(TiCount,0)
when 0 then 0
else 100*(ISNULL(TiScount,0)/ISNULL(TiCount,0)) end TiPercent,
ISNULL(TcsCount,0) TcsCount,ISNULL(TcsScount,0) TcsScount,
case ISNULL(TcsCount,0)
when 0 then 0
else 100*(ISNULL(TcsScount,0)/ISNULL(TcsCount,0)) end TcsPercent,
ISNULL(TfCount,0) TfCount,ISNULL(TfScount,0) TfScount,
case ISNULL(TfCount,0)
when 0 then 0
else 100*(ISNULL(TfScount,0)/ISNULL(TfCount,0)) end TfPercent,
ISNULL(TtCount,0) TtCount,ISNULL(TtScount,0) TtScount,
case ISNULL(TtCount,0)
when 0 then 0
else 100*(ISNULL(TtScount,0)/ISNULL(TtCount,0)) end TtPercent,
ISNULL(TpCount,0) TpCount,ISNULL(TpScount,0) TtScount,
case ISNULL(TpCount,0)
when 0 then 0
else 100*(ISNULL(TpScount,0)/ISNULL(TpCount,0)) end TpPercent,
ts.PlanPWD,PlanJWD,McPlan,
SubmitPackage,ActualPWD,ActualJWD,ActualMC,Commissioning,
2024-07-30 15:29:18 +08:00
IaQian,TcccQ,SystemStatus,TurnoverDescription,ts.Remark,
ISNULL(pwdACount,0) pwdACount,ISNULL(pwdBCount,0) pwdBCount,ISNULL(pwdCCount,0) pwdCCount,
ISNULL(fwdACount,0) fwdACount,ISNULL(fwdBCount,0) fwdBCount,ISNULL(fwdCCount,0) fwdCCount
2024-07-30 14:08:46 +08:00
from(
SELECT SystemNo,ProjectId FROM Transfer_LHCSystemList group by SystemNo,ProjectId
) f
left join Transfer_SystemControl ts on f.ProjectId=ts.ProjectId and f.SystemNo=ts.SystemNo
--piping
left join (select count(*)as PipingCount,ProjectId,SYSTEM from Transfer_Piping
group by ProjectId,SYSTEM)
tpi on f.ProjectId=tpi.ProjectId and f.SystemNo=tpi.SYSTEM
left join (select count(*)as PipingScount,ProjectId,SYSTEM from Transfer_Piping where FINALStatus='Completed'
group by ProjectId,SYSTEM)
tpi1 on f.ProjectId=tpi1.ProjectId and f.SystemNo=tpi1.SYSTEM
--
left join (select count(*)as TseCount,ProjectId,SYSTEM from Transfer_StaticEquipment
group by ProjectId,SYSTEM)
tse on f.ProjectId=tse.ProjectId and f.SystemNo=tse.SYSTEM
left join (select count(*)as TseSCount,ProjectId,SYSTEM from Transfer_StaticEquipment where MechanicalFINALStatus='Completed'
group by ProjectId,SYSTEM)
tse1 on f.ProjectId=tse1.ProjectId and f.SystemNo=tse1.SYSTEM
--
left join (select count(*)as TreCount,ProjectId,SYSTEM from Transfer_RotatingEquipment
group by ProjectId,SYSTEM)
tre on f.ProjectId=tre.ProjectId and f.SystemNo=tre.SYSTEM
left join (select count(*)as TreSCount,ProjectId,SYSTEM from Transfer_RotatingEquipment where MechanicalFINALStatus='Completed'
group by ProjectId,SYSTEM)
tre1 on f.ProjectId=tre1.ProjectId and f.SystemNo=tre1.SYSTEM
--Transfer_Electrical
left join (select count(*)as TeCount,ProjectId,SystemName from Transfer_Electrical
group by ProjectId,SystemName)
te on f.ProjectId=te.ProjectId and f.SystemNo=te.SystemName
left join (select count(*)as TeScount,ProjectId,SystemName from Transfer_Electrical where FINAL_Status='Completed'
group by ProjectId,SystemName)
te1 on f.ProjectId=te1.ProjectId and f.SystemNo=te1.SystemName
--Transfer_Instrumentation
left join (select count(*)as TiCount,ProjectId,SystemName from Transfer_Instrumentation
group by ProjectId,SystemName)
ti on f.ProjectId=ti.ProjectId and f.SystemNo=ti.SystemName
left join (select count(*)as TiScount,ProjectId,SystemName from Transfer_Instrumentation where FINAL_Status='Completed'
group by ProjectId,SystemName)
ti1 on f.ProjectId=ti1.ProjectId and f.SystemNo=ti1.SystemName
--Transfer_Civil_Structure
left join (select count(*)as TcsCount,ProjectId,SystemName from Transfer_Civil_Structure
group by ProjectId,SystemName)
tcs on f.ProjectId=tcs.ProjectId and f.SystemNo=tcs.SystemName
left join (select count(*)as TcsScount,ProjectId,SystemName from Transfer_Civil_Structure where FINAL_Status='Completed'
group by ProjectId,SystemName)
tcs1 on f.ProjectId=tcs1.ProjectId and f.SystemNo=tcs1.SystemName
--Transfer_Firefighting
left join (select count(*)as TfCount,ProjectId,SystemName from Transfer_Firefighting
group by ProjectId,SystemName)
tf on f.ProjectId=tf.ProjectId and f.SystemNo=tf.SystemName
left join (select count(*)as TfScount,ProjectId,SystemName from Transfer_Firefighting where FINAL_Status='Completed'
group by ProjectId,SystemName)
tf1 on f.ProjectId=tf1.ProjectId and f.SystemNo=tf1.SystemName
--Transfer_Telecom
left join (select count(*)as TtCount,ProjectId,SystemName from Transfer_Telecom
group by ProjectId,SystemName)
Tt on f.ProjectId=Tt.ProjectId and f.SystemNo=Tt.SystemName
left join (select count(*)as TtScount,ProjectId,SystemName from Transfer_Telecom where FINAL_Status='Completed'
group by ProjectId,SystemName)
Tt1 on f.ProjectId=Tt1.ProjectId and f.SystemNo=Tt1.SystemName
--Transfer_Plumbing
left join (select count(*)as TpCount,ProjectId,SystemName from Transfer_Plumbing
group by ProjectId,SystemName)
tp on f.ProjectId=tp.ProjectId and f.SystemNo=tp.SystemName
left join (select count(*)as TpScount,ProjectId,SystemName from Transfer_Plumbing where FINAL_Status='Completed'
group by ProjectId,SystemName)
tp1 on f.ProjectId=tp1.ProjectId and f.SystemNo=tp1.SystemName
2024-07-30 15:29:18 +08:00
left join (select count(*) as pwdACount,ProjectId,System_No from Transfer_PunchlistFrom where Status!='Completed'
and Punch_Type='PWD' and Cat='A' group by ProjectId,System_No)
tpA on f.ProjectId=tpA.ProjectId and f.SystemNo=tpA.System_No
2024-07-30 14:08:46 +08:00
2024-07-30 15:29:18 +08:00
left join (select count(*) as pwdBCount,ProjectId,System_No from Transfer_PunchlistFrom where Status!='Completed'
and Punch_Type='PWD' and Cat='B' group by ProjectId,System_No)
tpB on f.ProjectId=tpB.ProjectId and f.SystemNo=tpB.System_No
left join (select count(*) as pwdCCount,ProjectId,System_No from Transfer_PunchlistFrom where Status!='Completed'
and Punch_Type='PWD' and Cat='C' group by ProjectId,System_No)
tpC on f.ProjectId=tpC.ProjectId and f.SystemNo=tpC.System_No
left join (select count(*) as fwdACount,ProjectId,System_No from Transfer_PunchlistFrom where Status!='Completed'
and Punch_Type='FWD' and Cat='A' group by ProjectId,System_No)
tpfA on f.ProjectId=tpfA.ProjectId and f.SystemNo=tpfA.System_No
left join (select count(*) as fwdBCount,ProjectId,System_No from Transfer_PunchlistFrom where Status!='Completed'
and Punch_Type='FWD' and Cat='B' group by ProjectId,System_No)
tpfB on f.ProjectId=tpfB.ProjectId and f.SystemNo=tpfB.System_No
left join (select count(*) as fwdCCount,ProjectId,System_No from Transfer_PunchlistFrom where Status!='Completed'
and Punch_Type='FWD' and Cat='C' group by ProjectId,System_No)
tpfC on f.ProjectId=tpfC.ProjectId and f.SystemNo=tpfC.System_No
2024-07-30 14:08:46 +08:00
where f.ProjectId = @ProjectId";
List<SqlParameter> listStr = new List<SqlParameter>();
listStr.Add(new SqlParameter("@ProjectId", this.CurrUser.LoginProjectId));
2024-07-30 15:29:18 +08:00
if (!string.IsNullOrEmpty(ddlSystemNo.SelectedValue))
{
strSql += " AND SystemNo='" + ddlSystemNo.SelectedValue + "' ";
}
2024-07-30 14:08:46 +08:00
strSql += " order by SystemNo ";
SqlParameter[] parameter = listStr.ToArray();
return SQLHelper.GetDataTableRunText(strSql, parameter);
}
/// <summary>
/// 数据绑定
/// </summary>
public void BindGrid()
{
DataTable tb = DataSql();
Grid1.RecordCount = tb.Rows.Count;
var table = this.GetPagedDataTable(Grid1, tb);
Grid1.DataSource = table;
Grid1.DataBind();
}
#endregion
#region
/// <summary>
/// 分页下拉
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e)
{
Grid1.PageSize = Convert.ToInt32(ddlPageSize.SelectedValue);
BindGrid();
}
/// <summary>
/// 分页索引事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e)
{
BindGrid();
}
/// <summary>
/// 排序
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Grid1_Sort(object sender, FineUIPro.GridSortEventArgs e)
{
Grid1.SortDirection = e.SortDirection;
Grid1.SortField = e.SortField;
BindGrid();
}
#endregion
#region
/// <summary>
/// 查询
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnSearch_Click(object sender, EventArgs e)
{
BindGrid();
}
#endregion
#region
/// <summary>
/// 关闭弹出窗口
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Window1_Close(object sender, WindowCloseEventArgs e)
{
BindGrid();
}
#endregion
#region
/// <summary>
/// 右键编辑事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnMenuModify_Click(object sender, EventArgs e)
{
if (Grid1.SelectedRowIndexArray.Length == 0)
{
Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning);
return;
}
2024-07-30 15:29:18 +08:00
string SystemNo = Grid1.SelectedRowID;
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("SystemstatusEdit.aspx?SystemNo={0}", SystemNo, "编辑 - ")));
2024-07-30 14:08:46 +08:00
}
#endregion
protected void ddlSystemNo_SelectedIndexChanged(object sender, EventArgs e)
{
BindGrid();
}
/// <summary>
/// 获取总完成率
/// </summary>
/// <param name="systemNo"></param>
/// <returns></returns>
2024-07-30 15:29:18 +08:00
protected string totalper(object systemNo)
{
2024-07-30 14:08:46 +08:00
string rate = string.Empty;
2024-07-30 15:29:18 +08:00
if (systemNo != null)
{
var pid = CurrUser.LoginProjectId;
var scode = systemNo.ToString();
2024-07-30 14:08:46 +08:00
//根据systemNo和projectid获取所有数据 和完成的数据
2024-07-30 15:29:18 +08:00
#region
var list1 = Funs.DB.Transfer_Piping.Where(x => x.ProjectId == pid && x.SYSTEM == scode).ToList();
var list2 = Funs.DB.Transfer_StaticEquipment.Where(x => x.ProjectId == pid && x.SYSTEM == scode).ToList();
var list3 = Funs.DB.Transfer_RotatingEquipment.Where(x => x.ProjectId == pid && x.SYSTEM == scode).ToList();
var list4 = Funs.DB.Transfer_Instrumentation.Where(x => x.ProjectId == pid && x.SystemName == scode).ToList();
var list5 = Funs.DB.Transfer_Electrical.Where(x => x.ProjectId == pid && x.SystemName == scode).ToList();
var list6 = Funs.DB.Transfer_Civil_Structure.Where(x => x.ProjectId == pid && x.SystemName == scode).ToList();
var list7 = Funs.DB.Transfer_Firefighting.Where(x => x.ProjectId == pid && x.SystemName == scode).ToList();
var list8 = Funs.DB.Transfer_Telecom.Where(x => x.ProjectId == pid && x.SystemName == scode).ToList();
#endregion
float allcount = (list1.Count + list2.Count + list3.Count + list4.Count +
list5.Count + list6.Count + list7.Count + list8.Count);
float allScount = (list1.Where(x => x.FINALStatus == "Completed").ToList().Count + list2.Where(x => x.MechanicalFINALStatus == "Completed").ToList().Count
+ list3.Where(x => x.MechanicalFINALStatus == "Completed").ToList().Count + list4.Where(x => x.FINAL_Status == "Completed").ToList().Count +
list5.Where(x => x.FINAL_Status == "Completed").ToList().Count + list6.Where(x => x.FINAL_Status == "Completed").ToList().Count
+ list7.Where(x => x.FINAL_Status == "Completed").ToList().Count + list8.Where(x => x.FINAL_Status == "Completed").ToList().Count
);
if (Convert.ToInt32(allcount)==0)
{
return "0";
}
var rateF = 100 * (allScount / allcount);
rate = rateF.ToString("F2");
2024-07-30 14:08:46 +08:00
}
return rate;
2024-07-29 18:06:25 +08:00
}
2024-07-30 15:29:18 +08:00
#region
/// 导出按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnOut_Click(object sender, EventArgs e)
{
Response.ClearContent();
string filename = Funs.GetNewFileName();
Response.AddHeader("content-disposition", "attachment; filename=" + System.Web.HttpUtility.UrlEncode("项目月报" + filename, System.Text.Encoding.UTF8) + ".xls");
Response.ContentType = "application/excel";
Response.ContentEncoding = System.Text.Encoding.UTF8;
this.Grid1.PageSize = 100000;
this.BindGrid();
Response.Write(GetGridTableHtml(Grid1));
Response.End();
}
/// <summary>
/// 导出方法
/// </summary>
/// <param name="grid"></param>
/// <returns></returns>
private string GetGridTableHtml(Grid grid)
{
StringBuilder sb = new StringBuilder();
sb.Append("<meta http-equiv=\"content-type\" content=\"application/excel; charset=UTF-8\"/>");
sb.Append("<table cellspacing=\"0\" rules=\"all\" border=\"1\" style=\"border-collapse:collapse;\">");
//sb.Append("<tr>");
//foreach (GridColumn column in grid.Columns)
//{
// if (column.ColumnID != "ckbIsSelected" && column.ColumnID != "Punish" && column.ColumnID != "Del")
// {
// sb.AppendFormat("<td>{0}</td>", column.HeaderText);
// }
//}
//sb.Append("</tr>");
MultiHeaderTable mht = new MultiHeaderTable();
mht.ResolveMultiHeaderTable(Grid1.Columns);
foreach (List<object[]> rows in mht.MultiTable)
{
sb.Append("<tr>");
foreach (object[] cell in rows)
{
int rowspan = Convert.ToInt32(cell[0]);
int colspan = Convert.ToInt32(cell[1]);
GridColumn column = cell[2] as GridColumn;
if (column.Hidden == false)
{
sb.AppendFormat("<th{0}{1}{2}>{3}</th>",
rowspan != 1 ? " rowspan=\"" + rowspan + "\"" : "",
colspan != 1 ? " colspan=\"" + colspan + "\"" : "",
colspan != 1 ? " style=\"text-align:center;\"" : "",
column.HeaderText);
}
}
sb.Append("</tr>");
}
foreach (GridRow row in grid.Rows)
{
sb.Append("<tr>");
//if (row.Grid.gr.Hidden == false) {
foreach (GridColumn column in mht.Columns)
{
if (column.ColumnID != "ckbIsSelected" && column.ColumnID != "Punish" && column.ColumnID != "Del")
{
string html = row.Values[column.ColumnIndex].ToString();
if (column.ColumnID == "tfPageIndex")
{
html = (row.FindControl("lblPageIndex") as AspNet.Label).Text;
}
else if (column.ColumnID == "Count4")
{
html = (row.FindControl("Label5") as AspNet.Label).Text;
}
sb.AppendFormat("<td>{0}</td>", html);
}
}
//}
sb.Append("</tr>");
}
sb.Append("</table>");
return sb.ToString();
}
#endregion
2024-07-29 18:06:25 +08:00
}
}