using System; using System.Collections; using System.Collections.Generic; using System.Linq; using FineUIPro; using Model; namespace BLL { public static class Project_HSSEData_HSSEService { /// /// HSSE数据类型 /// public enum HSSEDateType { /// /// 全部数据 /// All, /// /// 项目信息数据 /// ProjectInformation, /// /// 工时数据 /// WorkingHours, /// /// 教育培训数据 /// EducationAndTraining, /// /// 环保数据 /// Environmental, /// /// 安监人员数据 /// OfSafetySupervisors, /// /// 安全会议数据 /// SafetyMeeting, /// /// 监督检查数据 /// SupervisionAndInspection, /// /// 事故事件数据 /// AccidentEvent, /// /// 应急管理数据 /// EmergencyManagement, /// /// 安全费用数据 /// SecurityCost, /// /// 施工机具数据 /// ConstructionEquipment, /// /// 作业许可数据 /// WorkPermit, /// /// 隐患排查数据 /// HiddenDangerTroubleshooting, /// /// 安全风险数据 /// SecurityRisk, /// /// 隐患类别数据 /// HiddenDangerCategory, /// /// 危大工程数据 /// DangerousProject } public static SGGLDB db = Funs.DB; /// /// 新增实体 /// /// public static void AddProject_HSSEData_HSSE(Project_HSSEData_HSSE newtable) { using (var db = new SGGLDB(Funs.ConnString)) { var table = new Project_HSSEData_HSSE { Id = newtable.Id, ProjectId = newtable.ProjectId, UnitId = newtable.UnitId, CollCropCode = newtable.CollCropCode, UnitName = newtable.UnitName, ReportDate = newtable.ReportDate, BeUnderConstructionNum = newtable.BeUnderConstructionNum, ShutdownNum = newtable.ShutdownNum, JoinConstructionPersonNum = newtable.JoinConstructionPersonNum, MajorProjectsUnderConstructionNum = newtable.MajorProjectsUnderConstructionNum, TotalWorkingHour = newtable.TotalWorkingHour, LostWorkingHour = newtable.LostWorkingHour, SafeWorkingHour = newtable.SafeWorkingHour, SafeTrainNum = newtable.SafeTrainNum, SpecialTrainNum = newtable.SpecialTrainNum, SpecialOperationTrainNum = newtable.SpecialOperationTrainNum, TotalEnergyConsumption = newtable.TotalEnergyConsumption, IncomeComprehensiveEnergyConsumption = newtable.IncomeComprehensiveEnergyConsumption, NewWaterConsumption = newtable.NewWaterConsumption, HeadOfficeInspectorGeneralNum = newtable.HeadOfficeInspectorGeneralNum, HeadOfficeFullTimeNum = newtable.HeadOfficeFullTimeNum, BranchInspectorGeneralNum = newtable.BranchInspectorGeneralNum, BranchFullTimeNum = newtable.BranchFullTimeNum, ProjectInspectorGeneralNum = newtable.ProjectInspectorGeneralNum, ProjectFullTimeNum = newtable.ProjectFullTimeNum, ProjectSafetyMonitorNum = newtable.ProjectSafetyMonitorNum, SafetyInjectionEngineer = newtable.SafetyInjectionEngineer, CertificateANum = newtable.CertificateANum, CertificateBNum = newtable.CertificateBNum, CertificateCNum = newtable.CertificateCNum, SafetyCommitteeMeetingNum = newtable.SafetyCommitteeMeetingNum, EnterpriseTopicsMeetingNum = newtable.EnterpriseTopicsMeetingNum, ProjectSafetyLeadingGroupMeetingNum = newtable.ProjectSafetyLeadingGroupMeetingNum, ProjectSafetyMeetingNum = newtable.ProjectSafetyMeetingNum, CompanyLeadShiftCheckNum = newtable.CompanyLeadShiftCheckNum, CompanyComprehensiveCheckNum = newtable.CompanyComprehensiveCheckNum, CompanySpecialCheckNum = newtable.CompanySpecialCheckNum, ProjectLeadShiftCheckNum = newtable.ProjectLeadShiftCheckNum, ProjectSpecialCheckNum = newtable.ProjectSpecialCheckNum, ProjectMajorCheckNum = newtable.ProjectMajorCheckNum, NearMissNum = newtable.NearMissNum, RecordableEventNum = newtable.RecordableEventNum, GeneralAccidentNum = newtable.GeneralAccidentNum, MajorAccidentNum = newtable.MajorAccidentNum, SeriousAccidentNum = newtable.SeriousAccidentNum, SpecialSeriousAccidentNum = newtable.SpecialSeriousAccidentNum, CompanyComprehensivePlanNum = newtable.CompanyComprehensivePlanNum, CompanySpecialPlanNum = newtable.CompanySpecialPlanNum, CompanyOnSiteDisposalPlan = newtable.CompanyOnSiteDisposalPlan, CompanyDrillNum = newtable.CompanyDrillNum, ProjectComprehensivePlanNum = newtable.ProjectComprehensivePlanNum, ProjectSpecialPlanNum = newtable.ProjectSpecialPlanNum, ProjectOnSiteDisposalPlan = newtable.ProjectOnSiteDisposalPlan, ProjectDrillNum = newtable.ProjectDrillNum, CostExtract = newtable.CostExtract, CostUse = newtable.CostUse, UseEquipmentNum = newtable.UseEquipmentNum, SpecialEquipmentNum = newtable.SpecialEquipmentNum, LicensesNum = newtable.LicensesNum, LicensesCloseNum = newtable.LicensesCloseNum, GeneralClosedNum = newtable.GeneralClosedNum, GeneralNotClosedNum = newtable.GeneralNotClosedNum, MajorClosedNum = newtable.MajorClosedNum, MajorNotClosedNum = newtable.MajorNotClosedNum, GeneralRiskNum = newtable.GeneralRiskNum, LowRiskNum = newtable.LowRiskNum, MediumRiskNum = newtable.MediumRiskNum, HighRiskNum = newtable.HighRiskNum, CompletedNum = newtable.CompletedNum, TrainPersonNum = newtable.TrainPersonNum, ConstructionNum = newtable.ConstructionNum, FinishedNum = newtable.FinishedNum, SuperCompletedNum = newtable.SuperCompletedNum, SuperTrainPersonNum = newtable.SuperTrainPersonNum, SuperConstructionNum = newtable.SuperConstructionNum, SuperFinishedNum = newtable.SuperFinishedNum }; db.Project_HSSEData_HSSE.InsertOnSubmit(table); db.SubmitChanges(); } } /// /// 删除实体 /// /// public static void DeleteProject_HSSEData_HSSEById(string Id) { using (var db = new SGGLDB(Funs.ConnString)) { var table = db.Project_HSSEData_HSSE.FirstOrDefault(x => x.Id == Id); if (table != null) { db.Project_HSSEData_HSSE.DeleteOnSubmit(table); db.SubmitChanges(); } } } /// /// 根据id获取实体 /// /// /// public static Project_HSSEData_HSSE GetProject_HSSEData_HSSEById(string Id) { return db.Project_HSSEData_HSSE.FirstOrDefault(x => x.Id == Id); } public static List GetProject_HSSEData_HSSEByProjectid(string Projectid) { using (var db = new SGGLDB(Funs.ConnString)) { var q = (from x in db.Project_HSSEData_HSSE where x.ProjectId == Projectid select x).ToList(); return q; } } public static void UpdateProject_HSSEData_HSSE(Project_HSSEData_HSSE newtable) { using (var db = new SGGLDB(Funs.ConnString)) { var table = db.Project_HSSEData_HSSE.FirstOrDefault(x => x.Id == newtable.Id); if (table != null) { table.Id = newtable.Id; table.ProjectId = newtable.ProjectId; table.UnitId = newtable.UnitId; table.CollCropCode = newtable.CollCropCode; table.UnitName = newtable.UnitName; table.ReportDate = newtable.ReportDate; table.BeUnderConstructionNum = newtable.BeUnderConstructionNum; table.ShutdownNum = newtable.ShutdownNum; table.JoinConstructionPersonNum = newtable.JoinConstructionPersonNum; table.MajorProjectsUnderConstructionNum = newtable.MajorProjectsUnderConstructionNum; table.TotalWorkingHour = newtable.TotalWorkingHour; table.LostWorkingHour = newtable.LostWorkingHour; table.SafeWorkingHour = newtable.SafeWorkingHour; table.SafeTrainNum = newtable.SafeTrainNum; table.SpecialTrainNum = newtable.SpecialTrainNum; table.SpecialOperationTrainNum = newtable.SpecialOperationTrainNum; table.TotalEnergyConsumption = newtable.TotalEnergyConsumption; table.IncomeComprehensiveEnergyConsumption = newtable.IncomeComprehensiveEnergyConsumption; table.NewWaterConsumption = newtable.NewWaterConsumption; table.HeadOfficeInspectorGeneralNum = newtable.HeadOfficeInspectorGeneralNum; table.HeadOfficeFullTimeNum = newtable.HeadOfficeFullTimeNum; table.BranchInspectorGeneralNum = newtable.BranchInspectorGeneralNum; table.BranchFullTimeNum = newtable.BranchFullTimeNum; table.ProjectInspectorGeneralNum = newtable.ProjectInspectorGeneralNum; table.ProjectFullTimeNum = newtable.ProjectFullTimeNum; table.ProjectSafetyMonitorNum = newtable.ProjectSafetyMonitorNum; table.SafetyInjectionEngineer = newtable.SafetyInjectionEngineer; table.CertificateANum = newtable.CertificateANum; table.CertificateBNum = newtable.CertificateBNum; table.CertificateCNum = newtable.CertificateCNum; table.SafetyCommitteeMeetingNum = newtable.SafetyCommitteeMeetingNum; table.EnterpriseTopicsMeetingNum = newtable.EnterpriseTopicsMeetingNum; table.ProjectSafetyLeadingGroupMeetingNum = newtable.ProjectSafetyLeadingGroupMeetingNum; table.ProjectSafetyMeetingNum = newtable.ProjectSafetyMeetingNum; table.CompanyLeadShiftCheckNum = newtable.CompanyLeadShiftCheckNum; table.CompanyComprehensiveCheckNum = newtable.CompanyComprehensiveCheckNum; table.CompanySpecialCheckNum = newtable.CompanySpecialCheckNum; table.ProjectLeadShiftCheckNum = newtable.ProjectLeadShiftCheckNum; table.ProjectSpecialCheckNum = newtable.ProjectSpecialCheckNum; table.ProjectMajorCheckNum = newtable.ProjectMajorCheckNum; table.NearMissNum = newtable.NearMissNum; table.RecordableEventNum = newtable.RecordableEventNum; table.GeneralAccidentNum = newtable.GeneralAccidentNum; table.MajorAccidentNum = newtable.MajorAccidentNum; table.SeriousAccidentNum = newtable.SeriousAccidentNum; table.SpecialSeriousAccidentNum = newtable.SpecialSeriousAccidentNum; table.CompanyComprehensivePlanNum = newtable.CompanyComprehensivePlanNum; table.CompanySpecialPlanNum = newtable.CompanySpecialPlanNum; table.CompanyOnSiteDisposalPlan = newtable.CompanyOnSiteDisposalPlan; table.CompanyDrillNum = newtable.CompanyDrillNum; table.ProjectComprehensivePlanNum = newtable.ProjectComprehensivePlanNum; table.ProjectSpecialPlanNum = newtable.ProjectSpecialPlanNum; table.ProjectOnSiteDisposalPlan = newtable.ProjectOnSiteDisposalPlan; table.ProjectDrillNum = newtable.ProjectDrillNum; table.CostExtract = newtable.CostExtract; table.CostUse = newtable.CostUse; table.UseEquipmentNum = newtable.UseEquipmentNum; table.SpecialEquipmentNum = newtable.SpecialEquipmentNum; table.LicensesNum = newtable.LicensesNum; table.LicensesCloseNum = newtable.LicensesCloseNum; table.GeneralClosedNum = newtable.GeneralClosedNum; table.GeneralNotClosedNum = newtable.GeneralNotClosedNum; table.MajorClosedNum = newtable.MajorClosedNum; table.MajorNotClosedNum = newtable.MajorNotClosedNum; table.GeneralRiskNum = newtable.GeneralRiskNum; table.LowRiskNum = newtable.LowRiskNum; table.MediumRiskNum = newtable.MediumRiskNum; table.HighRiskNum = newtable.HighRiskNum; table.CompletedNum = newtable.CompletedNum; table.TrainPersonNum = newtable.TrainPersonNum; table.ConstructionNum = newtable.ConstructionNum; table.FinishedNum = newtable.FinishedNum; table.SuperCompletedNum = newtable.SuperCompletedNum; table.SuperTrainPersonNum = newtable.SuperTrainPersonNum; table.SuperConstructionNum = newtable.SuperConstructionNum; table.SuperFinishedNum = newtable.SuperFinishedNum; db.SubmitChanges(); } } } /// /// 判断该项目的该日期是否统计数据 /// /// /// /// public static bool IsReportByDate(DateTime dateTime, string projectid) { var result = false; var q = (from x in Funs.DB.Project_HSSEData_HSSE where x.ReportDate >= dateTime.Date && x.ReportDate < dateTime.Date.AddDays(1).Date && x.ProjectId == projectid select x).ToList(); if (q != null && q.Count > 0) result = true; return result; } /// /// 判断当天是否已上报 /// /// public static bool IsReportByToday(string projectid) { var result = false; var q = (from x in Funs.DB.Project_HSSEData_HSSE where x.ReportDate < DateTime.Now.AddDays(1).Date && x.ReportDate >= DateTime.Now.Date && x.ProjectId == projectid select x).ToList(); if (q != null && q.Count > 0) result = true; return result; } /// /// 根据projectid,获取该项目当天的统计数据 /// /// /// public static Project_HSSEData_HSSE getProject_HSSEData_HSSEByDate(string projectid) { var q = (from x in Funs.DB.Project_HSSEData_HSSE where x.ReportDate < DateTime.Now.AddDays(1).Date && x.ReportDate >= DateTime.Now.Date && x.ProjectId == projectid select x).FirstOrDefault(); return q; } /// /// 统计所有在建项目数据 /// public static void StatisticalAllProjectData() { var projectlist = ProjectService.GetProjectWorkList(); foreach (var item in projectlist) StatisticalData(item.ProjectId, HSSEDateType.All); } /// /// 统计数据 /// /// /// public static void StatisticalData(string projectid, HSSEDateType hSseDateType) { var thisUnitId = string.Empty; var thisUnit = CommonService.GetIsThisUnit(); if (thisUnit != null) thisUnitId = thisUnit.UnitId; var baseUnit = UnitService.GetUnitByUnitId(thisUnitId); var table = new Project_HSSEData_HSSE(); if (IsReportByToday(projectid)) table = getProject_HSSEData_HSSEByDate(projectid); else table.Id = SQLHelper.GetNewID(); table.UnitId = thisUnitId; table.CollCropCode = baseUnit.CollCropCode; table.UnitName = baseUnit.UnitName; table.ProjectId = projectid; table.ReportDate = DateTime.Now.Date; if (hSseDateType == HSSEDateType.ProjectInformation || hSseDateType == HSSEDateType.All) { table.BeUnderConstructionNum = GetBeUnderConstructionNum(projectid); table.ShutdownNum = GetShutdownNum(projectid); table.JoinConstructionPersonNum = GetJoinConstructionPersonNum(projectid); table.MajorProjectsUnderConstructionNum = GetMajorProjectsUnderConstructionNum(projectid); } if (hSseDateType == HSSEDateType.WorkingHours || hSseDateType == HSSEDateType.All) { table.TotalWorkingHour = GetTotalWorkingHour(projectid); table.LostWorkingHour = GetLostWorkingHour(projectid); table.SafeWorkingHour = GetSafeWorkingHour(projectid); } if (hSseDateType == HSSEDateType.EducationAndTraining || hSseDateType == HSSEDateType.All) { table.SafeTrainNum = GetSafeTrainNum(projectid); table.SpecialTrainNum = GetSpecialTrainNum(projectid); table.SpecialOperationTrainNum = GetSpecialOperationTrainNum(projectid); } if (hSseDateType == HSSEDateType.Environmental || hSseDateType == HSSEDateType.All) { table.TotalEnergyConsumption = GetTotalEnergyConsumption(projectid); table.IncomeComprehensiveEnergyConsumption = GetIncomeComprehensiveEnergyConsumption(projectid); table.NewWaterConsumption = GetNewWaterConsumption(projectid); } if (hSseDateType == HSSEDateType.OfSafetySupervisors || hSseDateType == HSSEDateType.All) { table.HeadOfficeInspectorGeneralNum = GetHeadOfficeInspectorGeneralNum(projectid); table.HeadOfficeFullTimeNum = GetHeadOfficeFullTimeNum(projectid); table.BranchInspectorGeneralNum = GetBranchInspectorGeneralNum(projectid); table.BranchFullTimeNum = GetBranchFullTimeNum(projectid); table.ProjectInspectorGeneralNum = GetProjectInspectorGeneralNum(projectid); table.ProjectFullTimeNum = GetProjectFullTimeNum(projectid); table.ProjectSafetyMonitorNum = GetProjectSafetyMonitorNum(projectid); table.SafetyInjectionEngineer = GetSafetyInjectionEngineer(projectid); table.CertificateANum = GetCertificateANum(projectid); table.CertificateBNum = GetCertificateBNum(projectid); table.CertificateCNum = GetCertificateCNum(projectid); } if (hSseDateType == HSSEDateType.SafetyMeeting || hSseDateType == HSSEDateType.All) { table.SafetyCommitteeMeetingNum = GetSafetyCommitteeMeetingNum(projectid); table.EnterpriseTopicsMeetingNum = GetEnterpriseTopicsMeetingNum(projectid); table.ProjectSafetyLeadingGroupMeetingNum = GetProjectSafetyLeadingGroupMeetingNum(projectid); table.ProjectSafetyMeetingNum = GetProjectSafetyMeetingNum(projectid); } if (hSseDateType == HSSEDateType.SupervisionAndInspection || hSseDateType == HSSEDateType.All) { table.CompanyLeadShiftCheckNum = GetCompanyLeadShiftCheckNum(projectid); table.CompanyComprehensiveCheckNum = GetCompanyComprehensiveCheckNum(projectid); table.CompanySpecialCheckNum = GetCompanySpecialCheckNum(projectid); table.ProjectLeadShiftCheckNum = GetProjectLeadShiftCheckNum(projectid); table.ProjectSpecialCheckNum = GetProjectSpecialCheckNum(projectid); table.ProjectMajorCheckNum = GetProjectMajorCheckNum(projectid); } if (hSseDateType == HSSEDateType.AccidentEvent || hSseDateType == HSSEDateType.All) { table.NearMissNum = GetNearMissNum(projectid); table.RecordableEventNum = GetRecordableEventNum(projectid); table.GeneralAccidentNum = GetGeneralAccidentNum(projectid); table.MajorAccidentNum = GetMajorAccidentNum(projectid); table.SeriousAccidentNum = GetSeriousAccidentNum(projectid); table.SpecialSeriousAccidentNum = GetSpecialSeriousAccidentNum(projectid); } if (hSseDateType == HSSEDateType.EmergencyManagement || hSseDateType == HSSEDateType.All) { table.CompanyComprehensivePlanNum = GetCompanyComprehensivePlanNum(projectid); table.CompanySpecialPlanNum = GetCompanySpecialPlanNum(projectid); table.CompanyOnSiteDisposalPlan = GetCompanyOnSiteDisposalPlan(projectid); table.CompanyDrillNum = GetCompanyDrillNum(projectid); table.ProjectComprehensivePlanNum = GetProjectComprehensivePlanNum(projectid); table.ProjectSpecialPlanNum = GetProjectSpecialPlanNum(projectid); table.ProjectOnSiteDisposalPlan = GetProjectOnSiteDisposalPlan(projectid); table.ProjectDrillNum = GetProjectDrillNum(projectid); } if (hSseDateType == HSSEDateType.SecurityCost || hSseDateType == HSSEDateType.All) { table.CostExtract = GetCostExtract(projectid); table.CostUse = GetCostUse(projectid); } if (hSseDateType == HSSEDateType.ConstructionEquipment || hSseDateType == HSSEDateType.All) { table.UseEquipmentNum = GetUseEquipmentNum(projectid); table.SpecialEquipmentNum = GetSpecialEquipmentNum(projectid); } if (hSseDateType == HSSEDateType.WorkPermit || hSseDateType == HSSEDateType.All) { table.LicensesNum = GetLicensesNum(projectid); table.LicensesCloseNum = GetLicensesCloseNum(projectid); } if (hSseDateType == HSSEDateType.HiddenDangerTroubleshooting || hSseDateType == HSSEDateType.All) { table.GeneralClosedNum = GetGeneralClosedNum(projectid); table.GeneralNotClosedNum = GetGeneralNotClosedNum(projectid); table.MajorClosedNum = GetMajorClosedNum(projectid); table.MajorNotClosedNum = GetMajorNotClosedNum(projectid); } if (hSseDateType == HSSEDateType.SecurityRisk || hSseDateType == HSSEDateType.All) { table.GeneralRiskNum = GetGeneralRiskNum(projectid); table.LowRiskNum = GetLowRiskNum(projectid); table.MediumRiskNum = GetMediumRiskNum(projectid); table.HighRiskNum = GetHighRiskNum(projectid); } if (hSseDateType == HSSEDateType.HiddenDangerCategory || hSseDateType == HSSEDateType.All) { string thisUnitId1 = string.Empty; var thisUnit1 = CommonService.GetIsThisUnit(); if (thisUnit1 != null) { thisUnitId1 = thisUnit1.UnitId; } var base_Unit = BLL.UnitService.GetUnitByUnitId(thisUnitId1); DateTime date = DateTime.Now; Model.SGGLDB db1 = Funs.DB; var list = from x in db1.HSSE_Hazard_HazardRegister select x; var types = (from x in db1.HSSE_Hazard_HazardRegisterTypes join y in list on x.RegisterTypesId equals y.RegisterTypesId select new { x.RegisterTypesId, x.RegisterTypesName }).Distinct().ToList(); foreach (var type in types) { Model.Project_HSSEData_HiddenDangerDetail table1 = new Model.Project_HSSEData_HiddenDangerDetail { UnitId = thisUnitId1, CollCropCode = base_Unit.CollCropCode, UnitName = base_Unit.UnitName, ProjectId = projectid, ReportDate = DateTime.Now.Date, TypeName = type.RegisterTypesName, TotalNum = list.Count(x => x.RegisterTypesId == type.RegisterTypesId), NeedRectifyNum = list.Count(x => x.RegisterTypesId == type.RegisterTypesId && (x.States == "1")), }; if (Project_HSSEData_HiddenDangerDetailService.IsReportByToday(projectid, type.RegisterTypesName)) { table1.Id = Project_HSSEData_HiddenDangerDetailService.GetTodayModelByProjectAndType(projectid, type.RegisterTypesName).Id; Project_HSSEData_HiddenDangerDetailService.UpdateProject_HSSEData_HiddenDangerDetail(table1); } else { table1.Id = SQLHelper.GetNewID(); Project_HSSEData_HiddenDangerDetailService.AddProject_HSSEData_HiddenDangerDetail(table1); } } } if (hSseDateType == HSSEDateType.DangerousProject || hSseDateType == HSSEDateType.All) { table.CompletedNum = GetCompletedNum(projectid); table.TrainPersonNum = GetTrainPersonNum(projectid); table.ConstructionNum = GetConstructionNum(projectid); table.FinishedNum = GetFinishedNum(projectid); table.SuperCompletedNum = GetSuperCompletedNum(projectid); table.SuperTrainPersonNum = GetSuperTrainPersonNum(projectid); table.SuperConstructionNum = GetSuperConstructionNum(projectid); table.SuperFinishedNum = GetSuperFinishedNum(projectid); } if (IsReportByToday(projectid)) UpdateProject_HSSEData_HSSE(table); else AddProject_HSSEData_HSSE(table); HSSEData_HSSEService.UpdateTodyData_State(); } /// /// 获取在建项目数 /// /// public static int GetBeUnderConstructionNum(string projectid) { var result = (from x in Funs.DB.Base_Project where x.ProjectState == "1" && x.ProjectId == projectid select x).Count(); return result; } /// /// 获取停工项目数 /// /// public static int GetShutdownNum(string projectid) { var result = (from x in Funs.DB.Base_Project where x.ProjectState == "2" && x.ProjectId == projectid select x).Count(); return result; } /// /// 获取参建人数 /// /// public static int GetJoinConstructionPersonNum(string projectid) { var result = (from x in Funs.DB.SitePerson_Person where x.ProjectId == projectid && x.IsUsed == 1 select x).Count(); return result; } /// /// 获取在施危大工程数 /// /// public static int GetMajorProjectsUnderConstructionNum(string projectid) { var result = (from x in Funs.DB.Solution_LargerHazard where x.ProjectId == projectid && x.States == "2" && x.RecordTime > Const.DtmarkTime select x).Count(); return result; } /// /// 获取总工时数 /// /// public static int GetTotalWorkingHour(string projectid) { var result = (from x in Funs.DB.SitePerson_DayReportDetail join y in Funs.DB.SitePerson_DayReport on x.DayReportId equals y.DayReportId where y.ProjectId == projectid && y.CompileDate > Const.DtmarkTime select x.PersonWorkTime ?? 0).ToList().Sum(); var q = Funs.GetNewIntOrZero(result.ToString().Split('.')[0]); return q; } /// /// 获取损失工时数 /// /// public static int GetLostWorkingHour(string projectid) { var result = (from x in Funs.DB.Accident_AccidentHandle where x.ProjectId == projectid && x.CompileDate > Const.DtmarkTime select x.WorkHoursLoss) .ToList().Sum(x => x.Value) + (from x in Funs.DB.Accident_AccidentReport where x.ProjectId == projectid && x.CompileDate > Const.DtmarkTime select x.WorkingHoursLoss) .ToList().Sum(x => x.Value); var q = Funs.GetNewIntOrZero(result.ToString().Split('.')[0]); return q; } /// /// 获取安全工时数 /// /// public static int GetSafeWorkingHour(string projectid) { var result1 = (from x in Funs.DB.SitePerson_DayReportDetail join y in Funs.DB.SitePerson_DayReport on x.DayReportId equals y.DayReportId where y.ProjectId == projectid && y.CompileDate > Const.DtmarkTime select x.PersonWorkTime ?? 0).ToList().Sum(); var result2 = (from x in Funs.DB.Accident_AccidentHandle where x.ProjectId == projectid && x.CompileDate > Const.DtmarkTime select x.WorkHoursLoss) .ToList().Sum(x => x.Value) + (from x in Funs.DB.Accident_AccidentReport where x.ProjectId == projectid && x.CompileDate > Const.DtmarkTime select x.WorkingHoursLoss) .ToList().Sum(x => x.Value); var result = result1 - result2; var q = Funs.GetNewIntOrZero(result.ToString().Split('.')[0]); return q; } /// /// 获取三级安全教育培训数 /// /// public static int GetSafeTrainNum(string projectid) { var result = (from x in Funs.DB.EduTrain_TrainRecord join y in Funs.DB.Base_TrainType on x.TrainTypeId equals y.TrainTypeId where x.ProjectId == projectid && y.TrainType == "1" && x.TrainStartDate > Const.DtmarkTime select x).Count(); return result; } /// /// 获取专项培训数 /// /// public static int GetSpecialTrainNum(string projectid) { var result = (from x in Funs.DB.EduTrain_TrainRecord join y in Funs.DB.Base_TrainType on x.TrainTypeId equals y.TrainTypeId where x.ProjectId == projectid && y.TrainType == "2" && x.TrainStartDate > Const.DtmarkTime select x).Count(); return result; } /// /// 获取特种作业培训数 /// /// public static int GetSpecialOperationTrainNum(string projectid) { var result = (from x in Funs.DB.EduTrain_TrainRecord join y in Funs.DB.Base_TrainType on x.TrainTypeId equals y.TrainTypeId where x.ProjectId == projectid && y.TrainType == "3" && x.TrainStartDate > Const.DtmarkTime select x).Count(); return result; } /// /// 获取能耗总量 /// /// public static int GetTotalEnergyConsumption(string projectid) { var result = 0; return result; } /// /// 获取万元营业收入综合能耗 /// /// public static int GetIncomeComprehensiveEnergyConsumption(string projectid) { var result = 0; return result; } /// /// 获取二氧化碳 /// /// public static int GetNewWaterConsumption(string projectid) { var result = 0; return result; } /// /// 获取企业总部总监人数 /// /// public static int GetHeadOfficeInspectorGeneralNum(string projectid) { var result = 0; return result; } /// /// 获取企业总部专职人数 /// /// public static int GetHeadOfficeFullTimeNum(string projectid) { var result = 0; return result; } /// /// 获取分支机构总监人数 /// /// public static int GetBranchInspectorGeneralNum(string projectid) { var result = 0; return result; } /// /// 获取分支机构专职人数 /// /// public static int GetBranchFullTimeNum(string projectid) { var result = 0; return result; } /// /// 获取项目总监人数 /// /// public static int GetProjectInspectorGeneralNum(string projectid) { var result = (from x in Funs.DB.SitePerson_Person where x.ProjectId == projectid && x.WorkPostId == Const.WorkPost_ProjectHSSEDirector && x.IsUsed == 1 select x).Count(); return result; } /// /// 获取项目专职人数 /// /// public static int GetProjectFullTimeNum(string projectid) { var result = (from x in Funs.DB.SitePerson_Person join y in Funs.DB.Base_WorkPost on x.WorkPostId equals y.WorkPostId where x.ProjectId == projectid && y.IsHsse == true && x.IsUsed == 1 select x).Count(); return result; } /// /// 获取项目安全监护人数 /// /// public static int GetProjectSafetyMonitorNum(string projectid) { var result = (from x in Funs.DB.SitePerson_Person where x.ProjectId == projectid && x.IsSafetyMonitoring == true && x.IsUsed == 1 select x).Count(); return result; } /// /// 获取在岗执业注安师 /// /// public static int GetSafetyInjectionEngineer(string projectid) { var result = (from x in Funs.DB.SitePerson_Person join y in Funs.DB.Base_Certificate on x.CertificateId equals y.CertificateId where x.ProjectId == projectid && y.IsRegisterHSSE == true && x.IsUsed == 1 select x).Count(); return result; } /// /// 获取A证人员 /// /// public static int GetCertificateANum(string projectid) { var result = (from x in Funs.DB.SitePerson_Person join y in Funs.DB.QualityAudit_PersonQuality on x.PersonId equals y.PersonId join z in Funs.DB.Base_Certificate on y.CertificateId equals z.CertificateId where x.ProjectId == projectid && z.CertificateType == "A" && x.IsUsed == 1 select x).Count(); return result; } /// /// 获取B证人员 /// /// public static int GetCertificateBNum(string projectid) { var result = (from x in Funs.DB.SitePerson_Person join y in Funs.DB.QualityAudit_PersonQuality on x.PersonId equals y.PersonId join z in Funs.DB.Base_Certificate on y.CertificateId equals z.CertificateId where x.ProjectId == projectid && z.CertificateType == "B" && x.IsUsed == 1 select x).Count(); return result; } /// /// 获取C证人员 /// /// public static int GetCertificateCNum(string projectid) { var result = (from x in Funs.DB.SitePerson_Person join y in Funs.DB.QualityAudit_PersonQuality on x.PersonId equals y.PersonId join z in Funs.DB.Base_Certificate on y.CertificateId equals z.CertificateId where x.ProjectId == projectid && z.CertificateType == "C" && x.IsUsed == 1 select x).Count(); return result; } /// /// 获取企业安委会会议数 /// /// public static int GetSafetyCommitteeMeetingNum(string projectid) { var result = 0; return result; } /// /// 获取企业专题会议数 /// /// public static int GetEnterpriseTopicsMeetingNum(string projectid) { var result = 0; return result; } /// /// 获取项目安全领导小组会议数 /// /// public static int GetProjectSafetyLeadingGroupMeetingNum(string projectid) { var result = (from x in Funs.DB.Meeting_SafetyLeaderGroupMeeting where x.ProjectId == projectid && x.CompileDate > Const.DtmarkTime select x) .Count(); return result; } /// /// 获取项目安全例会数 /// /// public static int GetProjectSafetyMeetingNum(string projectid) { var result = (from x in Funs.DB.Meeting_WeekMeeting where x.ProjectId == projectid && x.CompileDate > Const.DtmarkTime select x).Count() + (from x in Funs.DB.Meeting_MonthMeeting where x.ProjectId == projectid && x.CompileDate > Const.DtmarkTime select x).Count(); return result; } /// /// 获取企业负责人带班检查次数 /// /// public static int GetCompanyLeadShiftCheckNum(string projectid) { var result = 0; return result; } /// /// 获取企业综合检查次数 /// /// public static int GetCompanyComprehensiveCheckNum(string projectid) { var result = 0; return result; } /// /// 获取企业专项检查次数 /// /// public static int GetCompanySpecialCheckNum(string projectid) { var result = 0; return result; } /// /// 获取项目负责人带班检查次数 /// /// public static int GetProjectLeadShiftCheckNum(string projectid) { var result = (from x in Funs.DB.Check_ProjectLeaderCheck where x.ProjectId == projectid && x.CheckDate > Const.DtmarkTime select x).Count(); return result; } /// /// 获取项目专项检查次数 /// /// public static int GetProjectSpecialCheckNum(string projectid) { var result = (from x in Funs.DB.Check_CheckSpecial where x.ProjectId == projectid && x.CheckTime > Const.DtmarkTime select x).Count(); return result; } /// /// 获取项目专业检查次数 /// /// public static int GetProjectMajorCheckNum(string projectid) { var result = (from x in Funs.DB.HSSE_Hazard_HazardRegister where x.ProjectId == projectid && x.CheckTime > Const.DtmarkTime select x).Count(); return result; } /// /// 获取未遂事件数 /// /// public static int GetNearMissNum(string projectid) { var result = (from x in Funs.DB.Accident_AccidentPersonRecord join y in Funs.DB.Base_AccidentType on x.AccidentTypeId equals y.AccidentTypeId where x.ProjectId == projectid && x.IsAttempt == "1" && x.CompileDate > Const.DtmarkTime select x).Count(); return result; } /// /// 获取可记录事件数 /// /// public static int GetRecordableEventNum(string projectid) { var result = (from x in Funs.DB.Accident_AccidentPersonRecord join y in Funs.DB.Base_AccidentType on x.AccidentTypeId equals y.AccidentTypeId where x.ProjectId == projectid && x.CompileDate > Const.DtmarkTime select x).Count(); return result; } /// /// 获取一般事故数 /// /// public static int GetGeneralAccidentNum(string projectid) { var result = (from x in Funs.DB.Accident_AccidentReport where x.ProjectId == projectid && x.AccidentDegree == "1" && x.CompileDate > Const.DtmarkTime select x).Count(); return result; } /// /// 获取较大事故数 /// /// public static int GetMajorAccidentNum(string projectid) { var result = (from x in Funs.DB.Accident_AccidentReport where x.ProjectId == projectid && x.AccidentDegree == "2" && x.CompileDate > Const.DtmarkTime select x).Count(); return result; } /// /// 获取重大事故数 /// /// public static int GetSeriousAccidentNum(string projectid) { var result = (from x in Funs.DB.Accident_AccidentReport where x.ProjectId == projectid && x.AccidentDegree == "3" && x.CompileDate > Const.DtmarkTime select x).Count(); return result; } /// /// 获取特别重大事故数 /// /// public static int GetSpecialSeriousAccidentNum(string projectid) { var result = (from x in Funs.DB.Accident_AccidentReport where x.ProjectId == projectid && x.AccidentDegree == "4" select x).Count(); return result; } /// /// 获取企业级综合预案数 /// /// public static int GetCompanyComprehensivePlanNum(string projectid) { var result = 0; return result; } /// /// 获取企业级专项预案数 /// /// public static int GetCompanySpecialPlanNum(string projectid) { var result = 0; return result; } /// /// 获取企业级现场处置预案 /// /// public static int GetCompanyOnSiteDisposalPlan(string projectid) { var result = 0; return result; } /// /// 获取企业级演练次数 /// /// public static int GetCompanyDrillNum(string projectid) { var result = 0; return result; } /// /// 获取项目级综合预案 /// /// public static int GetProjectComprehensivePlanNum(string projectid) { var result = (from x in Funs.DB.Emergency_EmergencyList join y in Funs.DB.Base_EmergencyType on x.EmergencyTypeId equals y.EmergencyTypeId where x.ProjectId == projectid && y.EmergencyTypeName.Contains("综合") && x.CompileDate > Const.DtmarkTime select x).Count(); return result; } /// /// 获取项目级专项预案数 /// /// public static int GetProjectSpecialPlanNum(string projectid) { var result = (from x in Funs.DB.Emergency_EmergencyList join y in Funs.DB.Base_EmergencyType on x.EmergencyTypeId equals y.EmergencyTypeId where x.ProjectId == projectid && y.EmergencyTypeName.Contains("专项") && x.CompileDate > Const.DtmarkTime select x).Count(); return result; } /// /// 获取项目级现场处置预案 /// /// public static int GetProjectOnSiteDisposalPlan(string projectid) { var result = (from x in Funs.DB.Emergency_EmergencyList join y in Funs.DB.Base_EmergencyType on x.EmergencyTypeId equals y.EmergencyTypeId where x.ProjectId == projectid && y.EmergencyTypeName.Contains("现场处置") && x.CompileDate > Const.DtmarkTime select x).Count(); return result; } /// /// 获取项目级演练次数 /// /// public static int GetProjectDrillNum(string projectid) { var result = (from x in Funs.DB.Emergency_DrillRecordList where x.ProjectId == projectid && x.CompileDate > Const.DtmarkTime select x).Count(); return result; } /// /// 获取费用提取(万元) /// /// public static int GetCostExtract(string projectid) { var result = 0; return result; } /// /// 获取费用使用(万元) /// /// public static int GetCostUse(string projectid) { var result = 0; var costs = (from x in Funs.DB.CostGoods_CostSmallDetailItem join y in Funs.DB.CostGoods_CostSmallDetail on x.CostSmallDetailId equals y.CostSmallDetailId where y.ProjectId == projectid && y.CompileDate > Const.DtmarkTime select x.CostMoney ?? 0).ToList().Sum(); result = Funs.GetNewIntOrZero(costs.ToString().Split('.')[0]); return result; } /// /// 获取施工机具在用数 /// /// public static int GetUseEquipmentNum(string projectid) { var result = (from x in Funs.DB.InApproveManager_EquipmentInItem join y in Funs.DB.InApproveManager_EquipmentIn on x.EquipmentInId equals y.EquipmentInId where y.ProjectId == projectid && x.IsUsed == true select x).Count() + (from x in Funs.DB.InApproveManager_GeneralEquipmentInItem join y in Funs.DB.InApproveManager_GeneralEquipmentIn on x.GeneralEquipmentInId equals y .GeneralEquipmentInId where y.ProjectId == projectid && x.IsUsed == true select x).Count(); return result; } /// /// 获取施工机具特种设备数 /// /// public static int GetSpecialEquipmentNum(string projectid) { var result = (from x in Funs.DB.InApproveManager_EquipmentInItem join y in Funs.DB.InApproveManager_EquipmentIn on x.EquipmentInId equals y.EquipmentInId where y.ProjectId == projectid && x.IsUsed == true select x).Count(); return result; } /// /// 获取作业许可项数 /// /// public static int GetLicensesNum(string projectid) { var result = (from x in Funs.DB.License_LicenseManager where x.ProjectId == projectid && x.IsHighRisk == true && x.CompileDate > Const.DtmarkTime select x).Count(); return result; } /// /// 获取作业许可关闭项数 /// /// public static int GetLicensesCloseNum(string projectid) { var result = (from x in Funs.DB.License_LicenseManager where x.ProjectId == projectid && x.IsHighRisk == true && x.WorkStates == "3" && x.CompileDate > Const.DtmarkTime select x).Count(); return result; } /// /// 获取一般隐患整改闭环项 /// /// public static int GetGeneralClosedNum(string projectid) { var result = (from x in Funs.DB.HSSE_Hazard_HazardRegister where x.ProjectId == projectid && x.Risk_Level == "一般" && x.States == "3" && x.CheckTime > Const.DtmarkTime select x).Count(); return result; } /// /// 获取一般隐患未整改完成项 /// /// public static int GetGeneralNotClosedNum(string projectid) { var result = (from x in Funs.DB.HSSE_Hazard_HazardRegister where x.ProjectId == projectid && x.Risk_Level == "一般" && x.States != "3" && x.CheckTime > Const.DtmarkTime select x).Count(); return result; } /// /// 获取重大隐患整改闭环项 /// /// public static int GetMajorClosedNum(string projectid) { var result = (from x in Funs.DB.HSSE_Hazard_HazardRegister where x.ProjectId == projectid && x.Risk_Level == "重大" && x.States == "3" && x.CheckTime > Const.DtmarkTime select x).Count(); return result; } /// /// 获取重大隐患未整改完成项 /// /// public static int GetMajorNotClosedNum(string projectid) { var result = (from x in Funs.DB.HSSE_Hazard_HazardRegister where x.ProjectId == projectid && x.Risk_Level == "重大" && x.States != "3" && x.CheckTime > Const.DtmarkTime select x).Count(); return result; } /// /// 获取一般风险数 /// /// public static int GetGeneralRiskNum(string projectid) { var result = (from x in Funs.DB.Hazard_HazardSelectedItem join y in Funs.DB.Base_RiskLevel on x.HazardLevel equals y.RiskLevelId where x.ProjectId == projectid && y.RiskLevel == 2 && x.IsStart == true select x).Count(); return result; } /// /// 获取低风险数 /// /// public static int GetLowRiskNum(string projectid) { var result = (from x in Funs.DB.Hazard_HazardSelectedItem join y in Funs.DB.Base_RiskLevel on x.HazardLevel equals y.RiskLevelId where x.ProjectId == projectid && y.RiskLevel == 1 && x.IsStart == true select x).Count(); return result; } /// /// 获取中风险数 /// /// public static int GetMediumRiskNum(string projectid) { var result = (from x in Funs.DB.Hazard_HazardSelectedItem join y in Funs.DB.Base_RiskLevel on x.HazardLevel equals y.RiskLevelId where x.ProjectId == projectid && y.RiskLevel == 3 && x.IsStart == true select x).Count(); return result; } /// /// 获取高风险数 /// /// public static int GetHighRiskNum(string projectid) { var result = (from x in Funs.DB.Hazard_HazardSelectedItem join y in Funs.DB.Base_RiskLevel on x.HazardLevel equals y.RiskLevelId where x.ProjectId == projectid && y.RiskLevel == 4 && x.IsStart == true select x).Count(); return result; } /// /// 获取危大工程审批完成数 /// /// public static int GetCompletedNum(string projectid) { var result = (from x in Funs.DB.Solution_LargerHazard where x.ProjectId == projectid && x.States == "1" && x.IsSuperLargerHazard == false && x.RecordTime > Const.DtmarkTime select x).Count(); return result; } /// /// 获取危大工程培训人次数 /// /// public static int GetTrainPersonNum(string projectid) { var result = (from x in Funs.DB.Solution_LargerHazard where x.ProjectId == projectid && x.IsSuperLargerHazard == false && x.RecordTime > Const.DtmarkTime select x.TrainPersonNum).ToList().Sum(x => x.Value); return result; } /// /// 获取危大工程施工个数 /// /// public static int GetConstructionNum(string projectid) { var result = (from x in Funs.DB.Solution_LargerHazard where x.ProjectId == projectid && x.States == "2" && x.IsSuperLargerHazard == false && x.RecordTime > Const.DtmarkTime select x).Count(); return result; } /// /// 获取危大工程完工个数 /// /// public static int GetFinishedNum(string projectid) { var result = (from x in Funs.DB.Solution_LargerHazard where x.ProjectId == projectid && x.States == "3" && x.IsSuperLargerHazard == false && x.RecordTime > Const.DtmarkTime select x).Count(); return result; } /// /// 获取超危大工程审批完成数 /// /// public static int GetSuperCompletedNum(string projectid) { var result = (from x in Funs.DB.Solution_LargerHazard where x.ProjectId == projectid && x.States == "1" && x.IsSuperLargerHazard == true && x.RecordTime > Const.DtmarkTime select x).Count(); return result; } /// /// 获取超危大工程培训人次数 /// /// public static int GetSuperTrainPersonNum(string projectid) { var result = (from x in Funs.DB.Solution_LargerHazard where x.ProjectId == projectid && x.IsSuperLargerHazard == true && x.RecordTime > Const.DtmarkTime select x.TrainPersonNum).ToList().Sum(x => x.Value); return result; } /// /// 获取超危大工程施工个数 /// /// public static int GetSuperConstructionNum(string projectid) { var result = (from x in Funs.DB.Solution_LargerHazard where x.ProjectId == projectid && x.States == "2" && x.IsSuperLargerHazard == true && x.RecordTime > Const.DtmarkTime select x).Count(); return result; } /// /// 获取超危大工程完工个数 /// /// public static int GetSuperFinishedNum(string projectid) { var result = (from x in Funs.DB.Solution_LargerHazard where x.ProjectId == projectid && x.States == "3" && x.IsSuperLargerHazard == true && x.RecordTime > Const.DtmarkTime select x).Count(); return result; } #region 获取列表 /// /// 记录数 /// public static int Count { get; set; } public static List GetProject_HSSEData_HSSEByModle(Project_HSSEData_HSSE table) { var q = from x in db.Project_HSSEData_HSSE where (string.IsNullOrEmpty(table.Id) || x.Id.Contains(table.Id)) && (string.IsNullOrEmpty(table.ProjectId) || x.Id.Contains(table.ProjectId)) && (string.IsNullOrEmpty(table.UnitId) || x.UnitId.Contains(table.UnitId)) && (string.IsNullOrEmpty(table.CollCropCode) || x.CollCropCode.Contains(table.CollCropCode)) && (string.IsNullOrEmpty(table.UnitName) || x.UnitName.Contains(table.UnitName)) select x ; return q.ToList(); } /// 获取分页列表 /// /// /// public static IEnumerable GetListData(Project_HSSEData_HSSE table, Grid grid1) { var q = GetProject_HSSEData_HSSEByModle(table); Count = q.Count(); if (Count == 0) return null; // q = SortConditionHelper.SortingAndPaging(q, Grid1.SortField, Grid1.SortDirection, Grid1.PageIndex, Grid1.PageSize); return from x in q select new { x.Id, x.ProjectId, x.UnitId, x.CollCropCode, x.UnitName, x.ReportDate, x.BeUnderConstructionNum, x.ShutdownNum, x.JoinConstructionPersonNum, x.MajorProjectsUnderConstructionNum, x.TotalWorkingHour, x.LostWorkingHour, x.SafeWorkingHour, x.SafeTrainNum, x.SpecialTrainNum, x.SpecialOperationTrainNum, x.TotalEnergyConsumption, x.IncomeComprehensiveEnergyConsumption, x.NewWaterConsumption, x.HeadOfficeInspectorGeneralNum, x.HeadOfficeFullTimeNum, x.BranchInspectorGeneralNum, x.BranchFullTimeNum, x.ProjectInspectorGeneralNum, x.ProjectFullTimeNum, x.ProjectSafetyMonitorNum, x.SafetyInjectionEngineer, x.CertificateANum, x.CertificateBNum, x.CertificateCNum, x.SafetyCommitteeMeetingNum, x.EnterpriseTopicsMeetingNum, x.ProjectSafetyLeadingGroupMeetingNum, x.ProjectSafetyMeetingNum, x.CompanyLeadShiftCheckNum, x.CompanyComprehensiveCheckNum, x.CompanySpecialCheckNum, x.ProjectLeadShiftCheckNum, x.ProjectSpecialCheckNum, x.ProjectMajorCheckNum, x.NearMissNum, x.RecordableEventNum, x.GeneralAccidentNum, x.MajorAccidentNum, x.SeriousAccidentNum, x.SpecialSeriousAccidentNum, x.CompanyComprehensivePlanNum, x.CompanySpecialPlanNum, x.CompanyOnSiteDisposalPlan, x.CompanyDrillNum, x.ProjectComprehensivePlanNum, x.ProjectSpecialPlanNum, x.ProjectOnSiteDisposalPlan, x.ProjectDrillNum, x.CostExtract, x.CostUse, x.UseEquipmentNum, x.SpecialEquipmentNum, x.LicensesNum, x.LicensesCloseNum, x.GeneralClosedNum, x.GeneralNotClosedNum, x.MajorClosedNum, x.MajorNotClosedNum, x.GeneralRiskNum, x.LowRiskNum, x.MediumRiskNum, x.HighRiskNum, x.CompletedNum, x.TrainPersonNum, x.ConstructionNum, x.FinishedNum, x.SuperCompletedNum, x.SuperTrainPersonNum, x.SuperConstructionNum, x.SuperFinishedNum }; } #endregion } }