429 lines
16 KiB
C#
429 lines
16 KiB
C#
|
using BLL;
|
|||
|
using Newtonsoft.Json.Linq;
|
|||
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Data;
|
|||
|
using System.Data.SqlClient;
|
|||
|
using System.Linq;
|
|||
|
|
|||
|
namespace FineUIPro.Web.DataShow
|
|||
|
{
|
|||
|
public partial class HiddenRectification : PageBase
|
|||
|
{
|
|||
|
#region 项目主键
|
|||
|
/// <summary>
|
|||
|
/// 项目主键
|
|||
|
/// </summary>
|
|||
|
public string ProjectId
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return (string)ViewState["ProjectId"];
|
|||
|
}
|
|||
|
set
|
|||
|
{
|
|||
|
ViewState["ProjectId"] = value;
|
|||
|
}
|
|||
|
}
|
|||
|
#endregion
|
|||
|
private int AllCount1 = 0;
|
|||
|
private int AllCount2 = 0;
|
|||
|
private int AllCount3 = 0;
|
|||
|
private List<Model.HiddenRectificationOutput> model = new List<Model.HiddenRectificationOutput>();
|
|||
|
#region 加载页面
|
|||
|
/// <summary>
|
|||
|
/// 加载页面
|
|||
|
/// </summary>
|
|||
|
/// <param name="sender"></param>
|
|||
|
/// <param name="e"></param>
|
|||
|
protected void Page_Load(object sender, EventArgs e)
|
|||
|
{
|
|||
|
if (!IsPostBack)
|
|||
|
{
|
|||
|
Funs.DropDownPageSize(this.ddlPageSize);
|
|||
|
ddlPageSize.SelectedValue = Grid1.PageSize.ToString();
|
|||
|
//BLL.ProjectService.InitProjectDropDownList(this.drpProject, true);
|
|||
|
// 绑定表格t
|
|||
|
BindGrid();
|
|||
|
//合计
|
|||
|
// OutputSummaryData();
|
|||
|
this.Panel1.Title = "隐患排查治理数据(" + BLL.UnitService.GetUnitNameByUnitId(BLL.CommonService.GetThisUnitId()) + ")";
|
|||
|
}
|
|||
|
}
|
|||
|
protected void changeTree(object sender, EventArgs e)
|
|||
|
{
|
|||
|
|
|||
|
this.ProjectId = this.ucTree.ProjectId;
|
|||
|
this.BindGrid();
|
|||
|
}
|
|||
|
/// <summary>
|
|||
|
/// 绑定数据
|
|||
|
/// </summary>
|
|||
|
private void BindGrid()
|
|||
|
{
|
|||
|
|
|||
|
if (rbType.SelectedValue == "0")
|
|||
|
{
|
|||
|
model = HSSEData_HSSEService.GetMajorHiddenRectificationOutputs();
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
model = HSSEData_HSSEService.GetGeneralHiddenRectificationOutputs();
|
|||
|
}
|
|||
|
|
|||
|
//if (this.drpProject.SelectedValue != Const._Null)
|
|||
|
//{
|
|||
|
// model = model.Where(x => x.ProjectId == this.drpProject.SelectedValue).ToList();
|
|||
|
//}
|
|||
|
if (!string.IsNullOrEmpty(this.ucTree.SelectedNodeID))
|
|||
|
{
|
|||
|
if (!string.IsNullOrEmpty(this.ucTree.ProjectId))
|
|||
|
{
|
|||
|
model = model.Where(x => x.ProjectId == this.ucTree.ProjectId).ToList();
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
var BeUnderConstructionList = ProjectService.GetProjectWorkList().Where(x => (x.ProjectAttribute == "GONGCHENG" || x.ProjectAttribute == null) && x.UnitId == this.ucTree.UnitId).Select(x => x.ProjectId).ToList();
|
|||
|
model = model.Where(x => BeUnderConstructionList.Contains(x.ProjectId)).ToList();
|
|||
|
|
|||
|
}
|
|||
|
}
|
|||
|
Grid1.RecordCount = model.Count;
|
|||
|
Grid1.DataSource = this.GetPagedDataTable(Grid1, Funs.LINQToDataTable(model.OrderBy(x => x.ProjectId).ThenBy(x => x.UnitName)));
|
|||
|
Grid1.DataBind();
|
|||
|
|
|||
|
OutputSummaryData();
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region 查询
|
|||
|
/// <summary>
|
|||
|
/// 查询
|
|||
|
/// </summary>
|
|||
|
/// <param name="sender"></param>
|
|||
|
/// <param name="e"></param>
|
|||
|
protected void TextBox_TextChanged(object sender, EventArgs e)
|
|||
|
{
|
|||
|
AllCount1 = 0;
|
|||
|
AllCount2 = 0;
|
|||
|
AllCount3= 0;
|
|||
|
this.BindGrid();
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region 表排序、分页、关闭窗口
|
|||
|
/// <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, GridSortEventArgs e)
|
|||
|
{
|
|||
|
BindGrid();
|
|||
|
}
|
|||
|
|
|||
|
/// <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 Window1_Close(object sender, WindowCloseEventArgs e)
|
|||
|
{
|
|||
|
BindGrid();
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Grid双击事件 编辑
|
|||
|
/// <summary>
|
|||
|
/// Grid行双击事件
|
|||
|
/// </summary>
|
|||
|
/// <param name="sender"></param>
|
|||
|
/// <param name="e"></param>
|
|||
|
protected void Grid1_RowDoubleClick(object sender, GridRowClickEventArgs e)
|
|||
|
{
|
|||
|
EditData();
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
/// <summary>
|
|||
|
///
|
|||
|
/// </summary>
|
|||
|
private void EditData()
|
|||
|
{
|
|||
|
if (Grid1.SelectedRowIndexArray.Length == 0)
|
|||
|
{
|
|||
|
Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning);
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("HiddenRectificationItem.aspx?projectId={0}", Grid1.SelectedRowID, "查看 - ")));
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
|
|||
|
protected void btnView_Click(object sender, EventArgs e)
|
|||
|
{
|
|||
|
EditData();
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 数量
|
|||
|
/// </summary>
|
|||
|
/// <param name="state"></param>
|
|||
|
/// <returns></returns>
|
|||
|
protected int Count1(object projectId)
|
|||
|
{
|
|||
|
int cout1 = 0;
|
|||
|
if (projectId != null)
|
|||
|
{
|
|||
|
var datetime1 = Funs.GetNewDateTime(this.txtStartTime.Text);
|
|||
|
var datetime2 = Funs.GetNewDateTime(this.txtEndTime.Text);
|
|||
|
var getT = Funs.DB.HSSE_Hazard_HazardRegister.Where(x => x.ProjectId == projectId.ToString() && x.ProblemTypes=="1" && x.States != "4" && x.States != "-1" && x.CheckTime > Const.DtmarkTime);
|
|||
|
if (datetime1.HasValue)
|
|||
|
{
|
|||
|
getT = getT.Where(x => x.CheckTime >= datetime1);
|
|||
|
}
|
|||
|
if (datetime2.HasValue)
|
|||
|
{
|
|||
|
getT = getT.Where(x => x.CheckTime <= datetime2);
|
|||
|
}
|
|||
|
if (this.rbType.SelectedValue == "0")
|
|||
|
{
|
|||
|
getT = getT.Where(x => x.Risk_Level == "重大");
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
getT = getT.Where(x => x.Risk_Level == "一般");
|
|||
|
}
|
|||
|
cout1 = getT.Count();
|
|||
|
}
|
|||
|
|
|||
|
AllCount1 += cout1;
|
|||
|
return cout1;
|
|||
|
}
|
|||
|
protected int CountALL(object projectId)
|
|||
|
{
|
|||
|
int cout1 = 0;
|
|||
|
if (projectId != null)
|
|||
|
{
|
|||
|
var datetime1 = Funs.GetNewDateTime(this.txtStartTime.Text);
|
|||
|
var datetime2 = Funs.GetNewDateTime(this.txtEndTime.Text);
|
|||
|
var getT = Funs.DB.HSSE_Hazard_HazardRegister.Where(x => x.ProjectId == projectId.ToString() && x.ProblemTypes == "1" && x.States != "4" && x.States != "-1" && x.CheckTime > Const.DtmarkTime);
|
|||
|
if (datetime1.HasValue)
|
|||
|
{
|
|||
|
getT = getT.Where(x => x.CheckTime >= datetime1);
|
|||
|
}
|
|||
|
if (datetime2.HasValue)
|
|||
|
{
|
|||
|
getT = getT.Where(x => x.CheckTime <= datetime2);
|
|||
|
}
|
|||
|
if (this.rbType.SelectedValue == "0")
|
|||
|
{
|
|||
|
getT = getT.Where(x => x.Risk_Level == "重大");
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
getT = getT.Where(x => x.Risk_Level == "一般");
|
|||
|
}
|
|||
|
cout1 = getT.Count();
|
|||
|
}
|
|||
|
return cout1;
|
|||
|
}
|
|||
|
|
|||
|
protected int Count2(object projectId)
|
|||
|
{
|
|||
|
int cout1 = 0;
|
|||
|
if (projectId != null)
|
|||
|
{
|
|||
|
var datetime1 = Funs.GetNewDateTime(this.txtStartTime.Text);
|
|||
|
var datetime2 = Funs.GetNewDateTime(this.txtEndTime.Text);
|
|||
|
var getT = Funs.DB.HSSE_Hazard_HazardRegister.Where(x => x.ProjectId == projectId.ToString() && x.ProblemTypes == "1" && x.States == "3" && x.CheckTime > Const.DtmarkTime);
|
|||
|
if (datetime1.HasValue)
|
|||
|
{
|
|||
|
getT = getT.Where(x => x.CheckTime >= datetime1);
|
|||
|
}
|
|||
|
if (datetime2.HasValue)
|
|||
|
{
|
|||
|
getT = getT.Where(x => x.CheckTime <= datetime2);
|
|||
|
}
|
|||
|
if (this.rbType.SelectedValue == "0")
|
|||
|
{
|
|||
|
getT = getT.Where(x => x.Risk_Level == "重大");
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
getT = getT.Where(x => x.Risk_Level == "一般");
|
|||
|
}
|
|||
|
cout1 = getT.Count();
|
|||
|
}
|
|||
|
|
|||
|
AllCount2 += cout1;
|
|||
|
return cout1;
|
|||
|
}
|
|||
|
protected int CountOk(object projectId)
|
|||
|
{
|
|||
|
int cout1 = 0;
|
|||
|
if (projectId != null)
|
|||
|
{
|
|||
|
var datetime1 = Funs.GetNewDateTime(this.txtStartTime.Text);
|
|||
|
var datetime2 = Funs.GetNewDateTime(this.txtEndTime.Text);
|
|||
|
var getT = Funs.DB.HSSE_Hazard_HazardRegister.Where(x => x.ProjectId == projectId.ToString() && x.ProblemTypes == "1" && x.States == "3" && x.CheckTime > Const.DtmarkTime);
|
|||
|
if (datetime1.HasValue)
|
|||
|
{
|
|||
|
getT = getT.Where(x => x.CheckTime >= datetime1);
|
|||
|
}
|
|||
|
if (datetime2.HasValue)
|
|||
|
{
|
|||
|
getT = getT.Where(x => x.CheckTime <= datetime2);
|
|||
|
}
|
|||
|
if (this.rbType.SelectedValue == "0")
|
|||
|
{
|
|||
|
getT = getT.Where(x => x.Risk_Level == "重大");
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
getT = getT.Where(x => x.Risk_Level == "一般");
|
|||
|
}
|
|||
|
cout1 = getT.Count();
|
|||
|
}
|
|||
|
return cout1;
|
|||
|
}
|
|||
|
protected int Count3(object projectId)
|
|||
|
{
|
|||
|
int cout1 = 0;
|
|||
|
if (projectId != null)
|
|||
|
{
|
|||
|
var datetime1 = Funs.GetNewDateTime(this.txtStartTime.Text);
|
|||
|
var datetime2 = Funs.GetNewDateTime(this.txtEndTime.Text);
|
|||
|
var getT = Funs.DB.HSSE_Hazard_HazardRegister.Where(x => x.ProjectId == projectId.ToString() && x.ProblemTypes == "1" && x.States != "3" && x.States != "-1" && x.CheckTime > Const.DtmarkTime);
|
|||
|
if (datetime1.HasValue)
|
|||
|
{
|
|||
|
getT = getT.Where(x => x.CheckTime >= datetime1);
|
|||
|
}
|
|||
|
if (datetime2.HasValue)
|
|||
|
{
|
|||
|
getT = getT.Where(x => x.CheckTime <= datetime2);
|
|||
|
}
|
|||
|
if (this.rbType.SelectedValue == "0")
|
|||
|
{
|
|||
|
getT = getT.Where(x => x.Risk_Level == "重大");
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
getT = getT.Where(x => x.Risk_Level == "一般");
|
|||
|
}
|
|||
|
cout1 = getT.Count();
|
|||
|
}
|
|||
|
AllCount3 += cout1;
|
|||
|
return cout1;
|
|||
|
}
|
|||
|
|
|||
|
protected string Count4(object projectId)
|
|||
|
{
|
|||
|
string rate = string.Empty;
|
|||
|
if (projectId != null)
|
|||
|
{
|
|||
|
int coutall = CountALL(projectId);
|
|||
|
int cout0 = CountOk(projectId);
|
|||
|
if (coutall > 0)
|
|||
|
{
|
|||
|
rate = Math.Round(cout0 * 1.0 / coutall * 100, 2).ToString();
|
|||
|
}
|
|||
|
}
|
|||
|
return rate;
|
|||
|
}
|
|||
|
|
|||
|
#region 合计数据(不根据条件改变)
|
|||
|
public void OutputSummaryData2()
|
|||
|
{
|
|||
|
//string strSql = @"select ProjectId,ProjectCode, ProjectName,isnull(count1,0) as count1,isnull(count2,0) as count2,isnull(count3,0) as count3 from Base_Project f
|
|||
|
//left join(select count(*) as count1,ProjectId as ProjectIda from HSSE_Hazard_HazardRegister
|
|||
|
//where states <> 4 and Risk_Level= '" + this.rbType.SelectedItem.Text + @"' and RegisterDate > '2023-01-01'
|
|||
|
//group by ProjectId) a
|
|||
|
//on f.ProjectId = a.ProjectIda
|
|||
|
|
|||
|
//left join(select count(*) as count2,ProjectId as ProjectIdb from HSSE_Hazard_HazardRegister
|
|||
|
//where states = 3 and Risk_Level= '" + this.rbType.SelectedItem.Text + @"' and RegisterDate > '2023-01-01'
|
|||
|
//group by ProjectId) b
|
|||
|
//on f.ProjectId = b.ProjectIdb
|
|||
|
|
|||
|
//left join(select count(*) as count3,ProjectId as ProjectIdc from HSSE_Hazard_HazardRegister
|
|||
|
//where states <> 3 and states<>4 and Risk_Level= '" + this.rbType.SelectedItem.Text + @"' and RegisterDate > '2023-01-01'
|
|||
|
//group by ProjectId) c
|
|||
|
//on f.ProjectId = c.ProjectIdc
|
|||
|
|
|||
|
//where ProjectState = 1 and(isDelete IS NULL OR isDelete = 0)";
|
|||
|
//List<SqlParameter> listStr = new List<SqlParameter>();
|
|||
|
//SqlParameter[] parameter = listStr.ToArray();
|
|||
|
//DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
|
|||
|
|
|||
|
|
|||
|
JObject summary = new JObject();
|
|||
|
summary.Add("ProjectName", "合计:");
|
|||
|
summary.Add("Count1", AllCount1.ToString());
|
|||
|
summary.Add("Count2", AllCount2.ToString());
|
|||
|
summary.Add("Count3", AllCount3.ToString());
|
|||
|
summary.Add("Count4", (float.Parse(AllCount2.ToString()) / float.Parse(AllCount1.ToString()) *100).ToString("F2"));
|
|||
|
Grid1.SummaryData = summary;
|
|||
|
}
|
|||
|
public void OutputSummaryData()
|
|||
|
{
|
|||
|
//string strSql = @"select ProjectId,ProjectCode, ProjectName,isnull(count1,0) as count1,isnull(count2,0) as count2,isnull(count3,0) as count3 from Base_Project f
|
|||
|
//left join(select count(*) as count1,ProjectId as ProjectIda from HSSE_Hazard_HazardRegister
|
|||
|
//where states <> 4 and Risk_Level= '" + this.rbType.SelectedItem.Text + @"' and RegisterDate > '2023-01-01'
|
|||
|
//group by ProjectId) a
|
|||
|
//on f.ProjectId = a.ProjectIda
|
|||
|
|
|||
|
//left join(select count(*) as count2,ProjectId as ProjectIdb from HSSE_Hazard_HazardRegister
|
|||
|
//where states = 3 and Risk_Level= '" + this.rbType.SelectedItem.Text + @"' and RegisterDate > '2023-01-01'
|
|||
|
//group by ProjectId) b
|
|||
|
//on f.ProjectId = b.ProjectIdb
|
|||
|
|
|||
|
//left join(select count(*) as count3,ProjectId as ProjectIdc from HSSE_Hazard_HazardRegister
|
|||
|
//where states <> 3 and states<>4 and Risk_Level= '" + this.rbType.SelectedItem.Text + @"' and RegisterDate > '2023-01-01'
|
|||
|
//group by ProjectId) c
|
|||
|
//on f.ProjectId = c.ProjectIdc
|
|||
|
|
|||
|
//where ProjectState = 1 and(isDelete IS NULL OR isDelete = 0)";
|
|||
|
//List<SqlParameter> listStr = new List<SqlParameter>();
|
|||
|
//SqlParameter[] parameter = listStr.ToArray();
|
|||
|
//DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
|
|||
|
|
|||
|
|
|||
|
JObject summary = new JObject();
|
|||
|
var countAll = model.Sum(x => x.ProNum);
|
|||
|
var countRec = model.Sum(x => x.RecNum);
|
|||
|
var countNoRec = model.Sum(x => x.NoRecNum);
|
|||
|
summary.Add("ProjectName", "合计:");
|
|||
|
summary.Add("ProNum", countAll);
|
|||
|
summary.Add("RecNum", countRec);
|
|||
|
summary.Add("NoRecNum", countNoRec);
|
|||
|
summary.Add("RecRate", (float.Parse(countRec.ToString()) / float.Parse(countAll.ToString()) * 100).ToString("F2"));
|
|||
|
Grid1.SummaryData = summary;
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
}
|
|||
|
}
|