362 lines
15 KiB
C#
362 lines
15 KiB
C#
using BLL;
|
|
using Newtonsoft.Json;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data.SqlClient;
|
|
using System.Data;
|
|
using System.Linq;
|
|
|
|
namespace FineUIPro.Web
|
|
{
|
|
public partial class mainMenu_HSSE : PageBase
|
|
{
|
|
#region 项目ID
|
|
/// <summary>
|
|
/// 项目ID
|
|
/// </summary>
|
|
public string ProjectId
|
|
{
|
|
get
|
|
{
|
|
return (string)ViewState["ProjectId"];
|
|
}
|
|
set
|
|
{
|
|
ViewState["ProjectId"] = value;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!IsPostBack)
|
|
{
|
|
this.ProjectId = string.Empty;
|
|
if (this.CurrUser != null)
|
|
{
|
|
this.ProjectId = this.CurrUser.LoginProjectId;
|
|
}
|
|
|
|
///当前现场总人数
|
|
this.getSitePerson();
|
|
///项目通讯
|
|
var project = BLL.ProjectService.GetProjectByProjectId(this.ProjectId);
|
|
if (project != null)
|
|
{
|
|
divXmTelTitle = project.Telephone ?? "---";
|
|
}
|
|
///项目安全人工时
|
|
this.getSafeWorkTimes();
|
|
///安全检查问题统计
|
|
this.getSafeCheck();
|
|
///获取作业票数量
|
|
this.getLicenseCount();
|
|
////安全教育培训数量
|
|
this.getEduTrainCount();
|
|
////事故数量
|
|
this.getAccidentCount();
|
|
}
|
|
}
|
|
|
|
protected string divXmTelTitle;
|
|
|
|
#region 当前现场总人数
|
|
/// <summary>
|
|
/// 当前现场总人数
|
|
/// </summary>
|
|
private void getSitePerson()
|
|
{
|
|
// var getallin = APIPageDataService.getPersonInOutNum(this.ProjectId, DateTime.Now);
|
|
string sql = @"select c.ConstText,b.PostType,count( *) num from SitePerson_Person a left join Base_WorkPost b on a.WorkPostId=b.WorkPostId
|
|
LEFT JOIN Sys_Const AS c ON c.ConstValue = b.PostType and c.GroupId = 'PostType' where IsUsed =1 and InTime<='" + DateTime.Now.ToString("yyyy-MM-dd") + "' and (OutTime is null or OutTime>'" + DateTime.Now.ToString("yyyy-MM-dd") + @"' )
|
|
and a.ProjectId='" + this.CurrUser.LoginProjectId + @"' and a.AuditorDate is not null
|
|
group by c.ConstText,b.PostType ";
|
|
List<SqlParameter> listStr = new List<SqlParameter>();
|
|
SqlParameter[] parameter = listStr.ToArray();
|
|
DataTable tb = SQLHelper.GetDataTableRunText(sql, parameter);
|
|
int allcount = 0;
|
|
int mcount = 0;
|
|
if (tb != null)
|
|
{
|
|
foreach (DataRow row in tb.Rows)
|
|
{
|
|
allcount += int.Parse(row["num"].ToString());
|
|
if (!string.IsNullOrEmpty(row["ConstText"].ToString()) && row["ConstText"].ToString().Contains("管理"))
|
|
{
|
|
mcount += int.Parse(row["num"].ToString());
|
|
}
|
|
}
|
|
}
|
|
|
|
this.divPersonNum.InnerHtml = allcount.ToString();
|
|
|
|
if (CurrUser.LoginProjectId == "b11a16ea-148c-4bae-a5a1-32158b599482")
|
|
{
|
|
this.divPersonNum.InnerHtml = "1301";
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 项目安全人工时
|
|
protected string SafeWorkTimeMonths;
|
|
protected string SafeWorkTimeCounts;
|
|
protected string SumSafeWorkTimeCounts;
|
|
/// <summary>
|
|
/// 项目安全人工时
|
|
/// </summary>
|
|
protected void getSafeWorkTimes()
|
|
{
|
|
SafeWorkTimeMonths = "[]";
|
|
SafeWorkTimeCounts = "[]";
|
|
SumSafeWorkTimeCounts = "[]";
|
|
|
|
List<string> monhts = new List<string>();
|
|
List<decimal> counts = new List<decimal>();
|
|
List<decimal> countSums = new List<decimal>();
|
|
decimal sumMonthCount = 0;
|
|
var getMonts = Funs.DB.SeDin_MonthReport.Where(x => x.ProjectId == this.ProjectId).OrderBy(x => x.ReporMonth);
|
|
var getmax = getMonts.FirstOrDefault();
|
|
if (getMonts.Count() > 0)
|
|
{
|
|
foreach (var item in getMonts)
|
|
{
|
|
monhts.Add(string.Format("{0:yyyy-MM}", item.ReporMonth));
|
|
decimal monthCount = 0;
|
|
var getItem = Funs.DB.SeDin_MonthReport2.FirstOrDefault(x => x.MonthReportId == item.MonthReportId);
|
|
if (getItem != null && getItem.MonthWorkTime.HasValue)
|
|
{
|
|
monthCount = getItem.MonthWorkTime ?? 0;
|
|
sumMonthCount += monthCount;
|
|
if (sumMonthCount < getItem.ProjectWorkTime)
|
|
{
|
|
sumMonthCount = getItem.ProjectWorkTime ?? 0;
|
|
}
|
|
}
|
|
counts.Add(monthCount);
|
|
countSums.Add(sumMonthCount);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
monhts.Add(string.Format("{0:yyyy-MM}", DateTime.Now));
|
|
counts.Add(0);
|
|
countSums.Add(0);
|
|
}
|
|
|
|
SafeWorkTimeMonths = JsonConvert.SerializeObject(monhts);
|
|
SafeWorkTimeCounts = JsonConvert.SerializeObject(counts);
|
|
SumSafeWorkTimeCounts = JsonConvert.SerializeObject(countSums);
|
|
|
|
|
|
if (CurrUser.LoginProjectId == "b11a16ea-148c-4bae-a5a1-32158b599482")
|
|
{
|
|
SafeWorkTimeMonths = "[\"2022-08\",\"2022-09\",\"2022-10\",\"2022-11\",\"2022-12\",\"2023-01\",\"2023-02\"]";
|
|
SafeWorkTimeCounts = "[672512,658746,568426,486204,153402,68742,213854]";
|
|
SumSafeWorkTimeCounts = "[3221746,3880492,4448918,4935122,5088524,5157266,5371120]";
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 作业许可数量统计
|
|
protected string LicenseStates;
|
|
protected string LicenseCounts;
|
|
/// <summary>
|
|
/// 作业许可数量统计
|
|
/// </summary>
|
|
protected void getLicenseCount()
|
|
{
|
|
LicenseStates = "[]";
|
|
LicenseCounts = "[]";
|
|
List<string> stateList = new List<string>();
|
|
List<int> countList = new List<int>();
|
|
var getStates = LicensePublicService.drpStatesItem().Where(x => x.Value != Const._Null);
|
|
var getLicense = APILicenseDataService.getLicenseDataListByStates(this.CurrUser.LoginProjectId, Const.UnitId_CD, null );
|
|
foreach (var itemStates in getStates)
|
|
{
|
|
stateList.Add(itemStates.Text);
|
|
if (getLicense != null)
|
|
{
|
|
countList.Add(getLicense.Where(x => x.States == itemStates.Value).Count());
|
|
}
|
|
countList.Add(0);
|
|
}
|
|
if (stateList.Count() > 0)
|
|
{
|
|
LicenseStates = JsonConvert.SerializeObject(stateList);
|
|
LicenseCounts = JsonConvert.SerializeObject(countList);
|
|
}
|
|
|
|
if (CurrUser.LoginProjectId == "b11a16ea-148c-4bae-a5a1-32158b599482")
|
|
{
|
|
LicenseStates = "[\"待提交\",\"审核中\",\"作业中\",\"已完成\",\"作废\"]";
|
|
LicenseCounts = "[0,0,258,9027,0]";
|
|
}
|
|
|
|
|
|
}
|
|
#endregion
|
|
|
|
#region 安全检查问题统计
|
|
protected string CheckUnit ;
|
|
protected string CheckUnitALLCount;
|
|
protected string CheckUnitNoCount;
|
|
protected string CheckType;
|
|
protected string CheckTypeALLCount;
|
|
protected string CheckTypeNoCount;
|
|
|
|
/// <summary>
|
|
/// 按单位统计
|
|
/// </summary>
|
|
protected void getSafeCheck()
|
|
{
|
|
CheckUnit = "[]";
|
|
CheckUnitALLCount = "[]";
|
|
CheckUnitNoCount = "[]";
|
|
List<string> listUnit = new List<string>();
|
|
List<int> listUAll = new List<int>();
|
|
List<int> listUNo = new List<int>();
|
|
var getHazardRegisterLists = HSSE_Hazard_HazardRegisterService.GetHazardRegisterListByProjectId(this.ProjectId);
|
|
var units = UnitService.GetUnitByProjectIdUnitTypeList(this.ProjectId, BLL.Const.ProjectUnitType_2);
|
|
if (units.Count() > 0)
|
|
{
|
|
foreach (var unit in units)
|
|
{
|
|
listUnit.Add(unit.ShortUnitName ?? "");
|
|
var unitHazardRegisters = getHazardRegisterLists.Where(x => x.ResponsibleUnit == unit.UnitId && x.States != "-1");
|
|
var noW = unitHazardRegisters.Where(x => x.States == "3");
|
|
listUAll.Add(unitHazardRegisters.Count());
|
|
listUNo.Add(unitHazardRegisters.Count() - noW.Count());
|
|
}
|
|
}
|
|
else
|
|
{
|
|
listUnit.Add("");
|
|
listUAll.Add(0);
|
|
listUNo.Add(0);
|
|
}
|
|
CheckUnit = JsonConvert.SerializeObject(listUnit);
|
|
CheckUnitALLCount = JsonConvert.SerializeObject(listUAll);
|
|
CheckUnitNoCount = JsonConvert.SerializeObject(listUNo);
|
|
|
|
CheckType = "[]";
|
|
CheckTypeALLCount = "[]";
|
|
CheckTypeNoCount = "[]";
|
|
List<string> listType = new List<string>();
|
|
List<int> listTAll = new List<int>();
|
|
List<int> listTNo = new List<int>();
|
|
|
|
string strSql = @"select b.RegisterTypesName ,count(*) allr ,sum(case when states=3 then 1 else 0 end) finish from HSSE_Hazard_HazardRegister a left join HSSE_Hazard_HazardRegisterTypes b on a.RegisterTypesId = b.RegisterTypesId
|
|
where a.ProjectId='" + this.ProjectId + @"' and b.RegisterTypesName is not null
|
|
group by b.RegisterTypesName";
|
|
DataTable tb = SQLHelper.GetDataTableRunText(strSql, null);
|
|
|
|
if (tb!=null && tb.Rows.Count>0)
|
|
{
|
|
foreach (DataRow item in tb.Rows)
|
|
{
|
|
listType.Add(item["RegisterTypesName"].ToString());
|
|
//var unitHazardRegisters = getHazardRegisterLists.Where(x => x.RegisterTypesId == item.RegisterTypesId);
|
|
//var noW = unitHazardRegisters.Where(x => x.States == "3");
|
|
listTAll.Add(int.Parse(item["allr"].ToString()));
|
|
listTNo.Add(int.Parse(item["allr"].ToString()) - int.Parse(item["finish"].ToString()));
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
listType.Add("");
|
|
listTAll.Add(0);
|
|
listTNo.Add(0);
|
|
}
|
|
CheckType = JsonConvert.SerializeObject(listType);
|
|
CheckTypeALLCount = JsonConvert.SerializeObject(listTAll);
|
|
CheckTypeNoCount = JsonConvert.SerializeObject(listTNo);
|
|
}
|
|
#endregion
|
|
|
|
#region 入场安全培训
|
|
public string EduTrainMonths;
|
|
public string EduTrainCounts;
|
|
public string EduTrainSumCounts;
|
|
/// <summary>
|
|
/// 入场安全培训
|
|
/// </summary>
|
|
protected void getEduTrainCount()
|
|
{
|
|
EduTrainMonths = "[]";
|
|
EduTrainCounts = "[]";
|
|
EduTrainSumCounts = "[]";
|
|
//// 每月培训数量
|
|
List<double> listdata = new List<double>();
|
|
List<double> listdataSum = new List<double>();
|
|
List<string> listMonths = new List<string>();
|
|
var getTrainRecord = from x in Funs.DB.EduTrain_TrainRecord
|
|
where x.ProjectId == this.ProjectId && x.TrainTypeId == Const.EntryTrainTypeId
|
|
select x;
|
|
var getTrainRecordDetail = from x in Funs.DB.EduTrain_TrainRecordDetail
|
|
join y in getTrainRecord on x.TrainingId equals y.TrainingId
|
|
select x;
|
|
|
|
DateTime startTime = DateTime.Now;
|
|
DateTime endTime = DateTime.Now;
|
|
var getProject = ProjectService.GetProjectByProjectId(this.CurrUser.LoginProjectId);
|
|
if (getProject != null && getProject.StartDate.HasValue)
|
|
{
|
|
startTime = getProject.StartDate.Value;
|
|
if (getProject.EndDate.HasValue && getProject.EndDate < DateTime.Now)
|
|
{
|
|
endTime = getProject.EndDate.Value;
|
|
}
|
|
}
|
|
int totalCout = 0;
|
|
for (int i = 0; startTime.AddMonths(i) <= endTime; i++)
|
|
{
|
|
listMonths.Add(string.Format("{0:yyyy-MM}", startTime.AddMonths(i)));
|
|
var getMontDetail = from x in getTrainRecordDetail
|
|
join y in getTrainRecord on x.TrainingId equals y.TrainingId
|
|
where y.TrainStartDate.Value.Year == startTime.AddMonths(i).Year && y.TrainStartDate.Value.Month == startTime.AddMonths(i).Month
|
|
select x;
|
|
listdata.Add(getMontDetail.Count());
|
|
totalCout = totalCout + getMontDetail.Count();
|
|
listdataSum.Add(totalCout);
|
|
}
|
|
if (listMonths.Count() > 0)
|
|
{
|
|
EduTrainMonths = JsonConvert.SerializeObject(listMonths);
|
|
EduTrainCounts = JsonConvert.SerializeObject(listdata);
|
|
EduTrainSumCounts = JsonConvert.SerializeObject(listdataSum);
|
|
}
|
|
|
|
if (CurrUser.LoginProjectId == "b11a16ea-148c-4bae-a5a1-32158b599482")
|
|
{
|
|
EduTrainMonths = "[\"2022-08\",\"2022-09\",\"2022-10\",\"2022-11\",\"2022-12\",\"2023-01\",\"2023-02\"]";
|
|
EduTrainCounts = "[1250,486,76,150,18,532,846]";
|
|
EduTrainSumCounts = "[1250,486,76,150,18,532,846]";
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 事故统计
|
|
public string AccidentTypes;
|
|
public string AccidentCounts;
|
|
/// <summary>
|
|
/// 事故统计
|
|
/// </summary>
|
|
protected void getAccidentCount()
|
|
{
|
|
//AccidentTypes = "[人身伤害, 未遂事故, 火灾, 机械设备, 环境影响, 其他]";
|
|
List<int> listCount = new List<int>();
|
|
var getAccident = from x in Funs.DB.Accident_AccidentReport
|
|
where x.ProjectId == this.ProjectId
|
|
select x;
|
|
listCount.Add(getAccident.Where(x => x.AccidentTypeId == "1" || x.AccidentTypeId == "2" || x.AccidentTypeId == "3" || x.AccidentTypeId == "4").Count());
|
|
listCount.Add(getAccident.Where(x => x.AccidentTypeId == "5").Count());
|
|
listCount.Add(getAccident.Where(x => x.AccidentTypeId == "6" || x.AccidentTypeId == "7").Count());
|
|
listCount.Add(getAccident.Where(x => x.AccidentTypeId == "8" || x.AccidentTypeId == "9").Count());
|
|
listCount.Add(getAccident.Where(x => x.AccidentTypeId == "10").Count());
|
|
listCount.Add(getAccident.Where(x => x.AccidentTypeId == "11").Count());
|
|
AccidentCounts = JsonConvert.SerializeObject(listCount);
|
|
}
|
|
#endregion
|
|
}
|
|
} |