2023-11-11
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using BLL;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
@@ -9,7 +10,9 @@ namespace FineUIPro.Web.DataShow
|
||||
{
|
||||
public partial class HiddenRectification : PageBase
|
||||
{
|
||||
|
||||
private int AllCount1 = 0;
|
||||
private int AllCount2 = 0;
|
||||
private int AllCount3 = 0;
|
||||
#region 加载页面
|
||||
/// <summary>
|
||||
/// 加载页面
|
||||
@@ -25,6 +28,8 @@ namespace FineUIPro.Web.DataShow
|
||||
BLL.ProjectService.InitProjectDropDownList(this.drpProject, true);
|
||||
// 绑定表格t
|
||||
BindGrid();
|
||||
//合计
|
||||
// OutputSummaryData();
|
||||
this.Panel1.Title = "隐患排查治理数据(" + BLL.UnitService.GetUnitNameByUnitId(BLL.CommonService.GetThisUnitId()) + ")";
|
||||
}
|
||||
}
|
||||
@@ -62,8 +67,9 @@ namespace FineUIPro.Web.DataShow
|
||||
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
|
||||
Grid1.RecordCount = tb.Rows.Count;
|
||||
var table = this.GetPagedDataTable(Grid1, tb);
|
||||
Grid1.DataSource = table;
|
||||
Grid1.DataSource = tb;
|
||||
Grid1.DataBind();
|
||||
OutputSummaryData();
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -75,6 +81,9 @@ namespace FineUIPro.Web.DataShow
|
||||
/// <param name="e"></param>
|
||||
protected void TextBox_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
AllCount1 = 0;
|
||||
AllCount2 = 0;
|
||||
AllCount3= 0;
|
||||
this.BindGrid();
|
||||
}
|
||||
#endregion
|
||||
@@ -154,7 +163,7 @@ namespace FineUIPro.Web.DataShow
|
||||
{
|
||||
EditData();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 数量
|
||||
/// </summary>
|
||||
@@ -166,8 +175,8 @@ namespace FineUIPro.Web.DataShow
|
||||
if (projectId != null)
|
||||
{
|
||||
var datetime1 = Funs.GetNewDateTime(this.txtStartTime.Text);
|
||||
var datetime2 = Funs.GetNewDateTime(this.txtStartTime.Text);
|
||||
var getT = Funs.DB.HSSE_Hazard_HazardRegister.Where(x => x.ProjectId == projectId.ToString() && x.States != "4");
|
||||
var datetime2 = Funs.GetNewDateTime(this.txtEndTime.Text);
|
||||
var getT = Funs.DB.HSSE_Hazard_HazardRegister.Where(x => x.ProjectId == projectId.ToString() && x.States != "4" && x.RegisterDate > Funs.minSysDate && x.ProblemTypes == "1");
|
||||
if (datetime1.HasValue)
|
||||
{
|
||||
getT = getT.Where(x => x.RegisterDate >= datetime1);
|
||||
@@ -186,6 +195,36 @@ namespace FineUIPro.Web.DataShow
|
||||
}
|
||||
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.States != "4" && x.RegisterDate > Funs.minSysDate && x.ProblemTypes == "1");
|
||||
if (datetime1.HasValue)
|
||||
{
|
||||
getT = getT.Where(x => x.RegisterDate >= datetime1);
|
||||
}
|
||||
if (datetime2.HasValue)
|
||||
{
|
||||
getT = getT.Where(x => x.RegisterDate <= 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;
|
||||
}
|
||||
|
||||
@@ -195,8 +234,8 @@ namespace FineUIPro.Web.DataShow
|
||||
if (projectId != null)
|
||||
{
|
||||
var datetime1 = Funs.GetNewDateTime(this.txtStartTime.Text);
|
||||
var datetime2 = Funs.GetNewDateTime(this.txtStartTime.Text);
|
||||
var getT = Funs.DB.HSSE_Hazard_HazardRegister.Where(x => x.ProjectId == projectId.ToString() && x.States == "3");
|
||||
var datetime2 = Funs.GetNewDateTime(this.txtEndTime.Text);
|
||||
var getT = Funs.DB.HSSE_Hazard_HazardRegister.Where(x => x.ProjectId == projectId.ToString() && x.States == "3" && x.RegisterDate > Funs.minSysDate && x.ProblemTypes=="1");
|
||||
if (datetime1.HasValue)
|
||||
{
|
||||
getT = getT.Where(x => x.RegisterDate >= datetime1);
|
||||
@@ -215,17 +254,46 @@ namespace FineUIPro.Web.DataShow
|
||||
}
|
||||
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.States == "3" && x.RegisterDate > Funs.minSysDate && x.ProblemTypes == "1");
|
||||
if (datetime1.HasValue)
|
||||
{
|
||||
getT = getT.Where(x => x.RegisterDate >= datetime1);
|
||||
}
|
||||
if (datetime2.HasValue)
|
||||
{
|
||||
getT = getT.Where(x => x.RegisterDate <= 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.txtStartTime.Text);
|
||||
var getT = Funs.DB.HSSE_Hazard_HazardRegister.Where(x => x.ProjectId == projectId.ToString() && x.States != "3" && x.States != "4");
|
||||
var datetime2 = Funs.GetNewDateTime(this.txtEndTime.Text);
|
||||
var getT = Funs.DB.HSSE_Hazard_HazardRegister.Where(x => x.ProjectId == projectId.ToString() && x.States != "3" && x.States != "4" && x.RegisterDate > Funs.minSysDate && x.ProblemTypes == "1");
|
||||
if (datetime1.HasValue)
|
||||
{
|
||||
getT = getT.Where(x => x.RegisterDate >= datetime1);
|
||||
@@ -244,6 +312,7 @@ namespace FineUIPro.Web.DataShow
|
||||
}
|
||||
cout1 = getT.Count();
|
||||
}
|
||||
AllCount3 += cout1;
|
||||
return cout1;
|
||||
}
|
||||
|
||||
@@ -252,28 +321,8 @@ namespace FineUIPro.Web.DataShow
|
||||
string rate = string.Empty;
|
||||
if (projectId != null)
|
||||
{
|
||||
var datetime1 = Funs.GetNewDateTime(this.txtStartTime.Text);
|
||||
var datetime2 = Funs.GetNewDateTime(this.txtStartTime.Text);
|
||||
var getALL = Funs.DB.HSSE_Hazard_HazardRegister.Where(x => x.ProjectId == projectId.ToString() && x.States != "4");
|
||||
if (this.rbType.SelectedValue == "0")
|
||||
{
|
||||
getALL = getALL.Where(x => x.Risk_Level == "重大");
|
||||
}
|
||||
else
|
||||
{
|
||||
getALL = getALL.Where(x => x.Risk_Level == "一般");
|
||||
}
|
||||
if (datetime1.HasValue)
|
||||
{
|
||||
getALL = getALL.Where(x => x.RegisterDate >= datetime1);
|
||||
}
|
||||
if (datetime2.HasValue)
|
||||
{
|
||||
getALL = getALL.Where(x => x.RegisterDate >= datetime1);
|
||||
}
|
||||
var getT = getALL.Where(x => x.ProjectId == projectId.ToString() && x.States == "3");
|
||||
int coutall = getALL.Count();
|
||||
int cout0 = getT.Count();
|
||||
int coutall = CountALL(projectId);
|
||||
int cout0 = CountOk(projectId);
|
||||
if (coutall > 0)
|
||||
{
|
||||
rate = Math.Round(cout0 * 1.0 / coutall * 100, 2).ToString();
|
||||
@@ -281,5 +330,40 @@ namespace FineUIPro.Web.DataShow
|
||||
}
|
||||
return rate;
|
||||
}
|
||||
|
||||
#region 合计数据(不根据条件改变)
|
||||
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();
|
||||
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;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user