SGGL_SHJ/SGGL/FineUIPro.Web/HSSE/Hazard/ConstructionRiskMap.aspx.cs

117 lines
5.4 KiB
C#
Raw Normal View History

2024-08-15 14:56:34 +08:00
using BLL;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Web.Services;
namespace FineUIPro.Web.ProjectData
{
public partial class ConstructionRiskMap : PageBase
{
2024-11-07 14:24:59 +08:00
2024-08-15 14:56:34 +08:00
public string Coordinate = "";
2024-09-24 11:28:27 +08:00
public string ProjectCode = "";
2024-08-15 14:56:34 +08:00
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
2024-09-24 11:28:27 +08:00
string strSql = @"SELECT b.[MainItemId],b.[Coordinate],b.[MainItemName],count(*) num ,max(case when RiskLevel='低风险' then 1 when RiskLevel='一般风险' then 2 when RiskLevel='较大风险' then 3 else 4 end) RiskLevel
FROM [dbo].[HSSE_ConstructionRisk] a left join [dbo].[ProjectData_MainItem] b on a.[WorkAreaId]=b.[MainItemId]
2025-02-18 15:12:04 +08:00
where a.ProjectId=@ProjectId and a.States!='5'
2024-09-24 11:28:27 +08:00
group by b.[MainItemId],b.[Coordinate],b.[MainItemName]";
2024-08-15 14:56:34 +08:00
List<SqlParameter> listStr = new List<SqlParameter>();
listStr.Add(new SqlParameter("@ProjectId", CurrUser.LoginProjectId));
SqlParameter[] parameter = listStr.ToArray();
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
2024-11-07 14:24:59 +08:00
foreach (DataRow row in tb.Rows)
2024-08-15 14:56:34 +08:00
{
2024-11-07 14:24:59 +08:00
Coordinate += row["MainItemId"].ToString() + ";" + row["MainItemName"].ToString() + ";" + row["num"].ToString() + ";" + row["Coordinate"].ToString() + ";" + row["RiskLevel"].ToString() + ",";
2024-08-15 14:56:34 +08:00
}
Coordinate = Coordinate.TrimEnd(',');
2024-09-24 11:28:27 +08:00
ProjectCode = BLL.ProjectService.GetProjectCodeByProjectId(this.CurrUser.LoginProjectId);
2024-08-15 14:56:34 +08:00
}
}
[WebMethod]
2024-11-07 14:24:59 +08:00
public static string getRisk(string WorkAreaId, string RiskLevel)
2024-08-15 14:56:34 +08:00
{
string res = "";
string strSql = @"SELECT [ConstructionRiskId]
,b.UnitName
,[ConstructionContent]
,[RefLicense]
,[LicenseDes]
,[RiskLevel]
,[States]
,[DateA]
,[DateZ]
,[DateWeek]
,[ProjectId]
,[Coordinate]
FROM [dbo].[HSSE_ConstructionRisk] a left join Base_Unit b on a.[UnitId] = b.[UnitId]
2025-02-18 15:12:04 +08:00
where a.WorkAreaId=@WorkAreaId and a.States!='5'
2024-08-15 14:56:34 +08:00
";
2024-09-24 11:28:27 +08:00
2024-11-07 14:24:59 +08:00
//if (!string.IsNullOrEmpty(RiskLevel))
//{
// strSql += " and RiskLevel='" + RiskLevel + "'";
//}
2024-09-24 11:28:27 +08:00
if (!string.IsNullOrEmpty(RiskLevel))
{
2024-11-07 14:24:59 +08:00
//strSql += " and RiskLevel='" + drpRiskLevel.SelectedValue + "' ";
strSql += " and '" + RiskLevel + "' like '%'+RiskLevel+'%' ";
2024-09-24 11:28:27 +08:00
}
2024-08-15 14:56:34 +08:00
List<SqlParameter> listStr = new List<SqlParameter>();
listStr.Add(new SqlParameter("@WorkAreaId", WorkAreaId));
SqlParameter[] parameter = listStr.ToArray();
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
foreach (DataRow row in tb.Rows)
{
2024-11-07 14:24:59 +08:00
res += row["ConstructionRiskId"].ToString() + ";" + row["UnitName"].ToString() + ";" + Funs.GetNewDateTimeOrNow(row["DateA"].ToString()).ToString("yyyy-MM-dd") + "至" + Funs.GetNewDateTimeOrNow(row["DateZ"].ToString()).ToString("yyyy-MM-dd") + ";" + row["RiskLevel"].ToString() + ";" + row["ConstructionContent"].ToString() + ";" + row["Coordinate"].ToString() + ",";
2024-08-15 14:56:34 +08:00
}
res = res.TrimEnd(',');
return res;
}
2024-09-24 11:28:27 +08:00
protected void drpRiskLevel_SelectedIndexChanged(object sender, EventArgs e)
{
2024-11-07 14:24:59 +08:00
string riskLevel = "";
2024-09-24 11:28:27 +08:00
string strSql = @"SELECT b.[MainItemId],b.[Coordinate],b.[MainItemName],count(*) num ,max(case when RiskLevel='低风险' then 1 when RiskLevel='一般风险' then 2 when RiskLevel='较大风险' then 3 else 4 end) RiskLevel
FROM [dbo].[HSSE_ConstructionRisk] a left join [dbo].[ProjectData_MainItem] b on a.[WorkAreaId]=b.[MainItemId]
2025-02-18 15:12:04 +08:00
where a.ProjectId=@ProjectId and a.States!='5'
2024-09-24 11:28:27 +08:00
";
List<SqlParameter> listStr = new List<SqlParameter>();
listStr.Add(new SqlParameter("@ProjectId", CurrUser.LoginProjectId));
2024-11-07 14:24:59 +08:00
if (drpRiskLevel.SelectedItemArray.Length == 1 && this.drpRiskLevel.SelectedValue == string.Empty)
{
}
else
2024-09-24 11:28:27 +08:00
{
2024-11-07 14:24:59 +08:00
foreach (var item in this.drpRiskLevel.SelectedValueArray)
{
riskLevel += item + ",";
}
//strSql += " and RiskLevel='" + drpRiskLevel.SelectedValue + "' ";
strSql += " and '" + riskLevel + "' like '%'+RiskLevel+'%' ";
2024-09-24 11:28:27 +08:00
}
strSql += " group by b.[MainItemId],b.[Coordinate],b.[MainItemName] ";
SqlParameter[] parameter = listStr.ToArray();
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
foreach (DataRow row in tb.Rows)
{
Coordinate += row["MainItemId"].ToString() + ";" + row["MainItemName"].ToString() + ";" + row["num"].ToString() + ";" + row["Coordinate"].ToString() + ";" + row["RiskLevel"].ToString() + ",";
}
Coordinate = Coordinate.TrimEnd(',');
2024-08-15 14:56:34 +08:00
2024-11-07 14:24:59 +08:00
PageContext.RegisterStartupScript(" setRiskLevel('" + riskLevel + "'); clearOverlays() ; drawMap('" + Coordinate + "') ");
2024-08-15 14:56:34 +08:00
2024-09-24 11:28:27 +08:00
}
2024-08-15 14:56:34 +08:00
}
}