安全危害因素清单【第二版】

This commit is contained in:
2026-04-02 17:00:38 +08:00
parent 3ec7008e0a
commit 5f7620614d
21 changed files with 922 additions and 72 deletions
@@ -55,7 +55,24 @@ namespace FineUIPro.Web.ReportManage.HazardFactor
StringBuilder sb = new StringBuilder();
List<SqlParameter> listStr = new List<SqlParameter>();
sb.Append("SELECT tbb.ProjectName,tba.* ");
string dedupe = rbDedupe.SelectedValue;
if (!string.IsNullOrWhiteSpace(dedupe))
{
sb.Append("WITH CTE AS ( ");
if (dedupe == "0")
{//按月
sb.Append("SELECT ROW_NUMBER() OVER (PARTITION BY tba.Year,tba.Month,tba.WorkPlace,tba.JobStep,tba.Hazard,tba.Consequence,tba.Illegality,tba.BaseRiskSeverity,tba.BaseRiskProbability,tba.BaseRiskScore,tba.BaseRiskLevel,tba.BaseRiskAcceptabity,tba.NetRiskControlMeasures,tba.NetRiskSeverity,tba.NetRiskProbability,tba.NetRiskScore,tba.NetRiskLevel,tba.NetRiskAcceptabity,tba.AdditionalControlMeasures ORDER BY CompileDate desc) as rn,tbb.ProjectName,tba.* ");
}
else
{//按年
sb.Append("SELECT ROW_NUMBER() OVER (PARTITION BY tba.Year,tba.WorkPlace,tba.JobStep,tba.Hazard,tba.Consequence,tba.Illegality,tba.BaseRiskSeverity,tba.BaseRiskProbability,tba.BaseRiskScore,tba.BaseRiskLevel,tba.BaseRiskAcceptabity,tba.NetRiskControlMeasures,tba.NetRiskSeverity,tba.NetRiskProbability,tba.NetRiskScore,tba.NetRiskLevel,tba.NetRiskAcceptabity,tba.AdditionalControlMeasures ORDER BY CompileDate desc) as rn,tbb.ProjectName,tba.* ");
}
}
else
{
sb.Append("SELECT tbb.ProjectName,tba.* ");
}
sb.Append("FROM HazardFactor_Safety AS tba WITH(NOLOCK) ");
sb.Append("LEFT JOIN Base_Project AS tbb WITH(NOLOCK) ON tbb.ProjectId = tba.ProjectId ");
sb.Append("WHERE 1=1 AND tba.State = 1 ");//取已提交数据
@@ -86,8 +103,16 @@ namespace FineUIPro.Web.ReportManage.HazardFactor
listStr.Add(new SqlParameter("@Illegality", this.rbIllegality.SelectedValue == "1" ? true : false));
}
if (!string.IsNullOrWhiteSpace(dedupe))
{
sb.Append(") ");
sb.Append("SELECT * FROM CTE WHERE rn = 1; ");
}
string sqlStr = sb.ToString();
SqlParameter[] parameter = listStr.ToArray();
DataTable tb = SQLHelper.GetDataTableRunText(sb.ToString(), parameter);
DataTable tb = SQLHelper.GetDataTableRunText(sqlStr, parameter);
Grid1.RecordCount = tb.Rows.Count;
var table = this.GetPagedDataTable(Grid1, tb);
@@ -243,8 +268,10 @@ namespace FineUIPro.Web.ReportManage.HazardFactor
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");
string year = !string.IsNullOrWhiteSpace(this.drpYear.SelectedValue) && this.drpYear.SelectedValue != Const._Null ? $"{this.drpYear.SelectedValue}年" : string.Empty;
string month = !string.IsNullOrWhiteSpace(this.drpMonth.SelectedValue) && this.drpMonth.SelectedValue != Const._Null ? $"{this.drpMonth.SelectedValue}月" : string.Empty;
string fileName = System.Web.HttpUtility.UrlEncode($"{year}{month}安全危害因素清单" + Funs.GetNewFileName(), System.Text.Encoding.UTF8);
Response.AddHeader("content-disposition", "attachment; filename=" + fileName + ".xls");
Response.ContentType = "application/excel";
Response.ContentEncoding = System.Text.Encoding.UTF8;
this.Grid1.PageSize = 10000;