20230920 HSE管理月报

This commit is contained in:
2023-09-20 13:55:00 +08:00
parent 47f9a0e959
commit 374cad03f1
48 changed files with 6674 additions and 8104 deletions
@@ -1,11 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BLL;
using BLL;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
namespace FineUIPro.Web.HSSE.Manager
{
@@ -42,24 +38,16 @@ namespace FineUIPro.Web.HSSE.Manager
}
}
private static DateTime startTime;
private static DateTime endTime;
private static DateTime yearStartTime;
private static DateTime projectStartTime;
#region
/// <summary>
/// 7.1 管理绩效数据统计集合(表一)
/// 新增危险源识别及控制
/// </summary>
private static List<Model.Manager_Month_AccidentDesciptionC> accidentDesciptions = new List<Model.Manager_Month_AccidentDesciptionC>();
private static List<Model.Manager_Month_HazardC> hazardCs = new List<Model.Manager_Month_HazardC>();
/// <summary>
/// 7.2 管理绩效数据统计集合(表二)
/// 其他HSE工作计划
/// </summary>
private static List<Model.Manager_Month_AccidentDesciptionItemC> AccidentDesciptionItems = new List<Model.Manager_Month_AccidentDesciptionItemC>();
private static List<Model.Manager_Month_OtherWorkPlanC> otherWorkPlanCs = new List<Model.Manager_Month_OtherWorkPlanC>();
#endregion
@@ -70,295 +58,173 @@ namespace FineUIPro.Web.HSSE.Manager
{
if (!IsPostBack)
{
accidentDesciptions.Clear();
AccidentDesciptionItems.Clear();
hazardCs.Clear();
otherWorkPlanCs.Clear();
this.MonthReportId = Request.Params["monthReportId"];
this.ProjectId = this.CurrUser.LoginProjectId;
DateTime months = Convert.ToDateTime(Request.Params["months"]);
startTime = Convert.ToDateTime(Request.Params["startTime"]);
endTime = Convert.ToDateTime(Request.Params["endTime"]);
yearStartTime = Convert.ToDateTime(Request.Params["yearStartTime"]);
Model.Manager_MonthReportC monthReport = BLL.MonthReportCService.GetMonthReportByMonths(months, this.CurrUser.LoginProjectId);
Model.Manager_MonthReportC mr = BLL.MonthReportCService.GetLastMonthReportByDate(endTime, this.ProjectId);
Model.Base_Project project = BLL.ProjectService.GetProjectByProjectId(ProjectId);
if (project.StartDate != null)
{
projectStartTime = Convert.ToDateTime(project.StartDate);
}
if (monthReport != null)
{
this.MonthReportId = monthReport.MonthReportId;
this.ProjectId = monthReport.ProjectId;
months = Convert.ToDateTime(monthReport.Months);
Model.SGGLDB db = Funs.DB;
//7.1 管理绩效数据统计(表一)
accidentDesciptions = (from x in db.Manager_Month_AccidentDesciptionC where x.MonthReportId == MonthReportId orderby x.SortIndex select x).ToList();
if (accidentDesciptions.Count > 0)
//新增危险源识别及控制
hazardCs = BLL.HazardCService.GetHazardByMonthReportId(this.MonthReportId);
if (hazardCs.Count > 0)
{
this.gvAccidentDesciption.DataSource = accidentDesciptions;
this.gvAccidentDesciption.DataBind();
this.gvHazardC.DataSource = hazardCs;
this.gvHazardC.DataBind();
}
else
//其他HSE工作计划
otherWorkPlanCs = BLL.OtherWorkPlanCService.GetOtherWorkPlanByMonthReportId(this.MonthReportId);
if (otherWorkPlanCs.Count > 0)
{
GetAccidentDesciption();//管理绩效数据统计(表一)
this.gvOtherWorkPlanC.DataSource = otherWorkPlanCs;
this.gvOtherWorkPlanC.DataBind();
}
//7.2 管理绩效数据统计(表二)
AccidentDesciptionItems = (from x in db.Manager_Month_AccidentDesciptionItemC where x.MonthReportId == MonthReportId orderby x.SortIndex select x).ToList();
if (AccidentDesciptionItems.Count > 0)
{
this.gvAccidentDesciptionItem.DataSource = AccidentDesciptionItems;
this.gvAccidentDesciptionItem.DataBind();
}
else
{
GetAccidentDesciptionItem();//管理绩效数据统计(表二)
}
this.txtAccidentDes.Text = monthReport.AccidentDes;
}
else
{
GetAccidentDesciption();//管理绩效数据统计(表一)
GetAccidentDesciptionItem();//管理绩效数据统计(表二)
}
}
}
#endregion
#region
#region HSE工作计划
#region
/// <summary>
///加载显示初始值
/// 新增危险源识别及控制
/// </summary>
private void GetAccidentDesciption()
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnNewHazardC_Click(object sender, EventArgs e)
{
System.Web.UI.WebControls.ListItem[] list = BLL.AccidentDesciptionCService.GetAccidentDesciptionList();
var accidentPersonRecords = from x in Funs.DB.Accident_AccidentPersonRecord
where x.ProjectId == this.CurrUser.LoginProjectId && x.AccidentDate >= startTime && x.AccidentDate < endTime
select x;
var yearAccidentPersonRecords = from x in Funs.DB.Accident_AccidentPersonRecord
where x.ProjectId == this.CurrUser.LoginProjectId && x.AccidentDate >= yearStartTime && x.AccidentDate < endTime
select x;
var accidentHandles = from x in Funs.DB.Accident_AccidentHandle
where x.ProjectId == this.CurrUser.LoginProjectId && x.AccidentDate >= startTime && x.AccidentDate < endTime
select x;
var yearAccidentHandles = from x in Funs.DB.Accident_AccidentHandle
where x.ProjectId == this.CurrUser.LoginProjectId && x.AccidentDate >= yearStartTime && x.AccidentDate < endTime
select x;
if (list.Count() > 0)
jerqueSaveHazardCList();
Model.Manager_Month_HazardC hazardC = new Model.Manager_Month_HazardC
{
for (int i = 0; i < list.Count(); i++)
{
Model.Manager_Month_AccidentDesciptionC des = new Model.Manager_Month_AccidentDesciptionC
{
AccidentDesId = SQLHelper.GetNewID(typeof(Model.Manager_Month_AccidentDesciptionC)),
Matter = list[i].Value
};
if (des.Matter == "百万工时伤害率" || des.Matter == "伤害严重率")
{
//百万工时伤害率:轻重死总累计人数*1000000/累计总人工时(保留2位小数)
//伤害严重率:事故损失工时数/9*1000000/累计总人工时(保留2位小数)
if (accidentHandles.Count() > 0)
{
decimal totalHseManhours = 0;
Model.Manager_MonthReportC monthReport = BLL.MonthReportCService.GetMonthReportByMonths(Convert.ToDateTime(Request.Params["months"]), this.CurrUser.LoginProjectId);
if (monthReport != null)
{
if (monthReport.TotalHseManhours != null)
{
totalHseManhours = monthReport.TotalHseManhours ?? 0;
}
}
else
{
Model.SitePerson_MonthReport mReport = BLL.Funs.DB.SitePerson_MonthReport.FirstOrDefault(x => x.CompileDate == Convert.ToDateTime(Request.Params["months"])); //当月人工时月报
if (mReport != null)
{
totalHseManhours = (from x in Funs.DB.SitePerson_MonthReportDetail
join y in Funs.DB.SitePerson_MonthReportUnitDetail
on x.MonthReportDetailId equals y.MonthReportDetailId
where x.MonthReportId == mReport.MonthReportId
select y.PersonWorkTime ?? 0).Sum();
}
}
if (des.Matter == "百万工时伤害率")
{
int a = (from x in accidentHandles
select x.MinorInjuriesPersonNum ?? 0).Sum();
int b = (from x in accidentHandles
select x.InjuriesPersonNum ?? 0).Sum();
int c = (from x in accidentHandles
select x.DeathPersonNum ?? 0).Sum();
if (totalHseManhours != 0)
{
des.MonthDataNum = decimal.Round((Convert.ToDecimal(a + b + c) * 1000000 / totalHseManhours), 2);
}
else
{
des.MonthDataNum = 0;
}
int ya = (from x in yearAccidentHandles
select x.MinorInjuriesPersonNum ?? 0).Sum();
int yb = (from x in yearAccidentHandles
select x.InjuriesPersonNum ?? 0).Sum();
int yc = (from x in yearAccidentHandles
select x.DeathPersonNum ?? 0).Sum();
if (totalHseManhours != 0)
{
des.YearDataNum = decimal.Round((Convert.ToDecimal(ya + yb + yc) * 1000000 / totalHseManhours), 2);
}
else
{
des.YearDataNum = 0;
}
}
else if (des.Matter == "伤害严重率")
{
decimal workHoursLoss = (from x in accidentHandles
select x.WorkHoursLoss ?? 0).Sum();
if (totalHseManhours != 0)
{
des.MonthDataNum = decimal.Round((Convert.ToDecimal(workHoursLoss) / 9 * 1000000 / totalHseManhours), 2);
}
else
{
des.MonthDataNum = 0;
}
decimal yearWorkHoursLoss = (from x in yearAccidentHandles
select x.WorkHoursLoss ?? 0).Sum();
if (totalHseManhours != 0)
{
des.YearDataNum = decimal.Round((Convert.ToDecimal(yearWorkHoursLoss) / 9 * 1000000 / totalHseManhours), 2);
}
else
{
des.YearDataNum = 0;
}
}
}
}
else
{
des.MonthDataNum = (from x in accidentPersonRecords
join y in Funs.DB.Base_AccidentType
on x.AccidentTypeId equals y.AccidentTypeId
where y.AccidentTypeName.Contains(des.Matter)
select x).Count();
des.YearDataNum = (from x in yearAccidentPersonRecords
join y in Funs.DB.Base_AccidentType
on x.AccidentTypeId equals y.AccidentTypeId
where y.AccidentTypeName.Contains(des.Matter)
select x).Count();
}
accidentDesciptions.Add(des);
}
}
this.gvAccidentDesciption.DataSource = accidentDesciptions;
this.gvAccidentDesciption.DataBind();
HazardId = SQLHelper.GetNewID(typeof(Model.Manager_Month_HazardC))
};
hazardCs.Add(hazardC);
this.gvHazardC.DataSource = hazardCs;
this.gvHazardC.DataBind();
}
/// <summary>
/// 检查并保存事故(表一)集合
/// 新增危险源识别及控制行点击事件
/// </summary>
private void jerqueSaveAccidentDesciptionList()
/// <param name="sender"></param>
/// <param name="e"></param>
protected void gvHazardC_RowCommand(object sender, GridCommandEventArgs e)
{
accidentDesciptions.Clear();
JArray mergedData = gvAccidentDesciption.GetMergedData();
jerqueSaveHazardCList();
string rowID = this.gvHazardC.DataKeys[e.RowIndex][0].ToString();
if (e.CommandName == "Delete")
{
foreach (var item in hazardCs)
{
if (item.HazardId == rowID)
{
hazardCs.Remove(item);
break;
}
}
gvHazardC.DataSource = hazardCs;
gvHazardC.DataBind();
ShowNotify("删除数据成功!", MessageBoxIcon.Success);
}
}
/// <summary>
/// 新增危险源识别及控制
/// </summary>
private void jerqueSaveHazardCList()
{
hazardCs.Clear();
JArray mergedData = gvHazardC.GetMergedData();
foreach (JObject mergedRow in mergedData)
{
string status = mergedRow.Value<string>("status");
JObject values = mergedRow.Value<JObject>("values");
int i = mergedRow.Value<int>("index");
Model.Manager_Month_AccidentDesciptionC accidentDesciptionSort = new Model.Manager_Month_AccidentDesciptionC
Model.Manager_Month_HazardC hazardC = new Model.Manager_Month_HazardC
{
AccidentDesId = this.gvAccidentDesciption.Rows[i].DataKeys[0].ToString(),
SortIndex = i,
Matter = values.Value<string>("Matter").ToString(),
MonthDataNum = Funs.GetNewDecimalOrZero(values.Value<string>("MonthDataNum").ToString()),
YearDataNum = Funs.GetNewDecimalOrZero(values.Value<string>("YearDataNum").ToString())
HazardId = this.gvHazardC.Rows[i].DataKeys[0].ToString(),
WorkArea = values.Value<string>("WorkArea").ToString(),
EnvironmentalFactors = values.Value<string>("EnvironmentalFactors").ToString(),
Consequence = values.Value<string>("Consequence").ToString(),
ControlMeasures = values.Value<string>("ControlMeasures").ToString()
};
accidentDesciptions.Add(accidentDesciptionSort);
}
}
/// <summary>
/// 加载显示初始值
/// </summary>
private void GetAccidentDesciptionItem()
{
System.Web.UI.WebControls.ListItem[] list = BLL.AccidentDesciptionItemCService.GetMatterList();
var accidentHandles = from x in Funs.DB.Accident_AccidentHandle
where x.ProjectId == this.CurrUser.LoginProjectId && x.AccidentDate >= startTime && x.AccidentDate < endTime
select x;
if (list.Count() > 0)
{
for (int i = 0; i < list.Count(); i++)
if (!string.IsNullOrEmpty(values.Value<string>("IsMajor").ToString()))
{
Model.Manager_Month_AccidentDesciptionItemC item = new Model.Manager_Month_AccidentDesciptionItemC
{
AccidentDesItemId = SQLHelper.GetNewID(typeof(Model.Manager_Month_AccidentDesciptionItemC)),
Matter = list[i].Value
};
if (accidentHandles.Count() > 0)
{
if (item.Matter == "轻伤人数")
{
item.Datas = (from x in accidentHandles
select x.MinorInjuriesPersonNum ?? 0).Sum().ToString();
}
else if (item.Matter == "重伤人数")
{
item.Datas = (from x in accidentHandles
select x.InjuriesPersonNum ?? 0).Sum().ToString();
}
else if (item.Matter == "死亡人数")
{
item.Datas = (from x in accidentHandles
select x.DeathPersonNum ?? 0).Sum().ToString();
}
else if (item.Matter == "直接经济损失")
{
item.Datas = (from x in accidentHandles
select x.MoneyLoss ?? 0).Sum().ToString();
}
else if (item.Matter == "事故失时数")
{
item.Datas = (from x in accidentHandles
select x.WorkHoursLoss ?? 0).Sum().ToString();
}
}
else
{
item.Datas = "无";
}
AccidentDesciptionItems.Add(item);
hazardC.IsMajor = Convert.ToBoolean(values.Value<string>("IsMajor").ToString());
}
hazardCs.Add(hazardC);
}
this.gvAccidentDesciptionItem.DataSource = AccidentDesciptionItems;
this.gvAccidentDesciptionItem.DataBind();
}
#endregion
#region HSE工作计划
/// <summary>
/// 增加其他HSE工作计划
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnOtherWorkPlanC_Click(object sender, EventArgs e)
{
jerqueSaveOtherWorkPlanCList();
Model.Manager_Month_OtherWorkPlanC otherWorkPlanC = new Model.Manager_Month_OtherWorkPlanC
{
OtherWorkPlanId = SQLHelper.GetNewID(typeof(Model.Manager_Month_OtherWorkPlanC))
};
otherWorkPlanCs.Add(otherWorkPlanC);
this.gvOtherWorkPlanC.DataSource = otherWorkPlanCs;
this.gvOtherWorkPlanC.DataBind();
}
/// <summary>
/// 检查并保存事故(表二)集合
/// 删除其他HSE工作计划
/// </summary>
private void jerqueSaveAccidentDesciptionItemList()
/// <param name="sender"></param>
/// <param name="e"></param>
protected void gvOtherWorkPlanC_RowCommand(object sender, GridCommandEventArgs e)
{
AccidentDesciptionItems.Clear();
JArray mergedData = gvAccidentDesciptionItem.GetMergedData();
jerqueSaveOtherWorkPlanCList();
string rowID = this.gvOtherWorkPlanC.DataKeys[e.RowIndex][0].ToString();
if (e.CommandName == "Delete")
{
foreach (var item in otherWorkPlanCs)
{
if (item.OtherWorkPlanId == rowID)
{
otherWorkPlanCs.Remove(item);
break;
}
}
gvOtherWorkPlanC.DataSource = otherWorkPlanCs;
gvOtherWorkPlanC.DataBind();
ShowNotify("删除数据成功!", MessageBoxIcon.Success);
}
}
/// <summary>
/// 其他HSE工作计划
/// </summary>
private void jerqueSaveOtherWorkPlanCList()
{
otherWorkPlanCs.Clear();
JArray mergedData = gvOtherWorkPlanC.GetMergedData();
foreach (JObject mergedRow in mergedData)
{
string status = mergedRow.Value<string>("status");
JObject values = mergedRow.Value<JObject>("values");
int i = mergedRow.Value<int>("index");
Model.Manager_Month_AccidentDesciptionItemC accidentDesciptionItemSort = new Model.Manager_Month_AccidentDesciptionItemC
Model.Manager_Month_OtherWorkPlanC otherWorkPlanC = new Model.Manager_Month_OtherWorkPlanC
{
AccidentDesItemId = this.gvAccidentDesciptionItem.Rows[i].DataKeys[0].ToString(),
OtherWorkPlanId = this.gvOtherWorkPlanC.Rows[i].DataKeys[0].ToString(),
SortIndex = i,
Matter = values.Value<string>("Matter").ToString(),
Datas = values.Value<string>("Datas").ToString()
WorkContent = values.Value<string>("WorkContent").ToString()
};
AccidentDesciptionItems.Add(accidentDesciptionItemSort);
otherWorkPlanCs.Add(otherWorkPlanC);
}
}
#endregion
#endregion
#region
/// <summary>
@@ -371,10 +237,9 @@ namespace FineUIPro.Web.HSSE.Manager
Model.Manager_MonthReportC oldMonthReport = BLL.MonthReportCService.GetMonthReportByMonths(Convert.ToDateTime(Request.Params["months"]), this.CurrUser.LoginProjectId);
if (oldMonthReport != null)
{
oldMonthReport.AccidentDes = this.txtAccidentDes.Text.Trim();
BLL.MonthReportCService.UpdateMonthReport(oldMonthReport);
OperateAccidentDesciptionSort(MonthReportId);
OperateAccidentDesciptionItemSort(MonthReportId);
OperateHazardCSort(MonthReportId);
OperateOtherWorkPlanCSort(MonthReportId);
BLL.LogService.AddSys_Log(this.CurrUser, oldMonthReport.MonthReportCode, oldMonthReport.MonthReportId, BLL.Const.ProjectManagerMonthCMenuId, BLL.Const.BtnModify);
}
else
@@ -388,10 +253,9 @@ namespace FineUIPro.Web.HSSE.Manager
monthReport.Months = Funs.GetNewDateTime(Request.Params["months"]);
monthReport.ReportMan = this.CurrUser.UserId;
monthReport.MonthReportDate = DateTime.Now;
monthReport.AccidentDes = this.txtAccidentDes.Text.Trim();
BLL.MonthReportCService.AddMonthReport(monthReport);
OperateAccidentDesciptionSort(MonthReportId);
OperateAccidentDesciptionItemSort(MonthReportId);
OperateHazardCSort(MonthReportId);
OperateOtherWorkPlanCSort(MonthReportId);
BLL.LogService.AddSys_Log(this.CurrUser, monthReport.MonthReportCode, monthReport.MonthReportId, BLL.Const.ProjectManagerMonthCMenuId, BLL.Const.BtnAdd);
}
ShowNotify("保存成功!", MessageBoxIcon.Success);
@@ -399,32 +263,32 @@ namespace FineUIPro.Web.HSSE.Manager
}
/// <summary>
/// 7.1 管理绩效数据统计 表一
/// 新增危险源识别及控制
/// </summary>
/// <param name="monthReportId"></param>
private void OperateAccidentDesciptionSort(string monthReportId)
private void OperateHazardCSort(string monthReportId)
{
BLL.AccidentDesciptionCService.DeleteAccidentDesciptionByMonthReportId(monthReportId);
jerqueSaveAccidentDesciptionList();
foreach (Model.Manager_Month_AccidentDesciptionC des in accidentDesciptions)
BLL.HazardCService.DeleteHazardByMonthReportId(monthReportId);
jerqueSaveHazardCList();
foreach (Model.Manager_Month_HazardC des in hazardCs)
{
des.MonthReportId = monthReportId;
BLL.AccidentDesciptionCService.AddAccidentDesciption(des);
BLL.HazardCService.AddHazard(des);
}
}
/// <summary>
/// 7.2 管理绩效数据统计 表二
/// 7.2 其他HSE工作计划
/// </summary>
/// <param name="monthReportId"></param>
private void OperateAccidentDesciptionItemSort(string monthReportId)
private void OperateOtherWorkPlanCSort(string monthReportId)
{
BLL.AccidentDesciptionItemCService.DeleteAccidentDesciptionItemByMonthReportId(monthReportId);
jerqueSaveAccidentDesciptionItemList();
foreach (Model.Manager_Month_AccidentDesciptionItemC item in AccidentDesciptionItems)
BLL.OtherWorkPlanCService.DeleteOtherWorkPlanByMonthReportId(monthReportId);
jerqueSaveOtherWorkPlanCList();
foreach (Model.Manager_Month_OtherWorkPlanC item in otherWorkPlanCs)
{
item.MonthReportId = monthReportId;
BLL.AccidentDesciptionItemCService.AddAccidentDesciptionItem(item);
BLL.OtherWorkPlanCService.AddOtherWorkPlan(item);
}
}
#endregion