using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Runtime.InteropServices.ComTypes; using System.Runtime.Remoting.Contexts; using System.Text.RegularExpressions; using System.Threading.Tasks; using System.Web.UI.WebControls; using Aspose.Words.Lists; using FastReport; using FineUIPro; using Model; using Newtonsoft.Json; namespace BLL { public static class HSSEData_HSSEService { public static List BeUnderConstructionList = BaseDataService.BeUnderConstructionList; public static void AddHSSEData_HSSE(HSSEData_HSSE newtable) { using (var db = new SUBQHSEDB(Funs.ConnString)) { var table = new HSSEData_HSSE { Id = newtable.Id, 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, HseTechnicalNum = newtable.HseTechnicalNum, EnvironmentalTrainNum = newtable.EnvironmentalTrainNum, 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, ProjectSubFullTimeNum = newtable.ProjectSubFullTimeNum, ProjectSafetyMonitorNum = newtable.ProjectSafetyMonitorNum, SafetyInjectionEngineer = newtable.SafetyInjectionEngineer, CertificateANum = newtable.CertificateANum, CertificateBNum = newtable.CertificateBNum, CertificateCNum = newtable.CertificateCNum, QualityPersonNum = newtable.QualityPersonNum, SafetyCommitteeMeetingNum = newtable.SafetyCommitteeMeetingNum, EnterpriseTopicsMeetingNum = newtable.EnterpriseTopicsMeetingNum, ProjectSafetyLeadingGroupMeetingNum = newtable.ProjectSafetyLeadingGroupMeetingNum, ProjectSafetyMeetingNum = newtable.ProjectSafetyMeetingNum, CompanyLeadShiftCheckNum = newtable.CompanyLeadShiftCheckNum, CompanyComprehensiveCheckNum = newtable.CompanyComprehensiveCheckNum, CompanySpecialCheckNum = newtable.CompanySpecialCheckNum, BranchLeadShiftCheckNum = newtable.BranchLeadShiftCheckNum, BranchComprehensiveCheckNum = newtable.BranchComprehensiveCheckNum, BranchSpecialCheckNum = newtable.BranchSpecialCheckNum, 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, BranchComprehensivePlanNum = newtable.BranchComprehensivePlanNum, BranchSpecialPlanNum = newtable.BranchSpecialPlanNum, BranchOnSiteDisposalPlan = newtable.BranchOnSiteDisposalPlan, CompanyDrillNum = newtable.CompanyDrillNum, CompanyDrillPersonNum = newtable.CompanyDrillPersonNum, BranchDrillNum = newtable.BranchDrillNum, BranchDrillPersonNum = newtable.BranchDrillPersonNum, ProjectComprehensivePlanNum = newtable.ProjectComprehensivePlanNum, ProjectSpecialPlanNum = newtable.ProjectSpecialPlanNum, ProjectOnSiteDisposalPlan = newtable.ProjectOnSiteDisposalPlan, ProjectDrillNum = newtable.ProjectDrillNum, ProjectDrillPersonNum = newtable.ProjectDrillPersonNum, 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, OperativesNum = newtable.OperativesNum, ConstructionNum = newtable.ConstructionNum, FinishedNum = newtable.FinishedNum, ArgumentNum = newtable.ArgumentNum, SuperCompletedNum = newtable.SuperCompletedNum, SuperTrainPersonNum = newtable.SuperTrainPersonNum, SuperConstructionNum = newtable.SuperConstructionNum, SuperFinishedNum = newtable.SuperFinishedNum, SuperArgumentNum = newtable.SuperArgumentNum, State = newtable.State, CreateDate = newtable.CreateDate, CreateMan = newtable.CreateMan }; db.HSSEData_HSSE.InsertOnSubmit(table); db.SubmitChanges(); } } public static void DeleteHSSEData_HSSEById(string id) { using (var db = new SUBQHSEDB(Funs.ConnString)) { var table = db.HSSEData_HSSE.FirstOrDefault(x => x.Id == id); if (table != null) { db.HSSEData_HSSE.DeleteOnSubmit(table); db.SubmitChanges(); } } } public static HSSEData_HSSE GetHSSEData_HSSEById(string id) { using (var db = new SUBQHSEDB(Funs.ConnString)) { return db.HSSEData_HSSE.FirstOrDefault(x => x.Id == id); } } public static HSSEData GetItemById(string id) { var item = new HsseDataItem(); var data = new HSSEData(); var dataHsse = GetHSSEData_HSSEById(id); if (dataHsse != null) { item.BranchLeadShiftCheckNum = dataHsse.BranchLeadShiftCheckNum; item.BranchComprehensiveCheckNum = dataHsse.BranchComprehensiveCheckNum; item.BranchSpecialCheckNum = dataHsse.BranchSpecialCheckNum; item.BeUnderConstructionNum = dataHsse.BeUnderConstructionNum; item.BranchFullTimeNum = dataHsse.BranchFullTimeNum; item.BranchInspectorGeneralNum = dataHsse.BranchInspectorGeneralNum; item.BranchComprehensivePlanNum = dataHsse.BranchComprehensivePlanNum; item.BranchSpecialPlanNum = dataHsse.BranchSpecialPlanNum; item.BranchOnSiteDisposalPlan = dataHsse.BranchOnSiteDisposalPlan; item.CertificateANum = dataHsse.CertificateANum; item.CertificateBNum = dataHsse.CertificateBNum; item.CertificateCNum = dataHsse.CertificateCNum; item.QualityPersonNum = dataHsse.QualityPersonNum; item.CollCropCode = dataHsse.CollCropCode; item.CompanyComprehensiveCheckNum = dataHsse.CompanyComprehensiveCheckNum; item.CompanyComprehensivePlanNum = dataHsse.CompanyComprehensivePlanNum; item.CompanyDrillNum = dataHsse.CompanyDrillNum; item.CompanyDrillPersonNum = dataHsse.CompanyDrillPersonNum; item.BranchDrillNum = dataHsse.BranchDrillNum; item.BranchDrillPersonNum = dataHsse.BranchDrillPersonNum; item.CompanyLeadShiftCheckNum = dataHsse.CompanyLeadShiftCheckNum; item.CompanyOnSiteDisposalPlan = dataHsse.CompanyOnSiteDisposalPlan; item.CompanySpecialCheckNum = dataHsse.CompanySpecialCheckNum; item.CompanySpecialPlanNum = dataHsse.CompanySpecialPlanNum; item.CompletedNum = dataHsse.CompletedNum; item.ConstructionNum = dataHsse.ConstructionNum; item.CostExtract = dataHsse.CostExtract; item.CostUse = dataHsse.CostUse; item.EnterpriseTopicsMeetingNum = dataHsse.EnterpriseTopicsMeetingNum; item.FinishedNum = dataHsse.FinishedNum; item.ArgumentNum = dataHsse.ArgumentNum; item.GeneralAccidentNum = dataHsse.GeneralAccidentNum; item.GeneralClosedNum = dataHsse.GeneralClosedNum; item.GeneralNotClosedNum = dataHsse.GeneralNotClosedNum; item.GeneralRate = ""; item.GeneralRiskNum = dataHsse.GeneralRiskNum; item.HeadOfficeFullTimeNum = dataHsse.HeadOfficeFullTimeNum; item.HeadOfficeInspectorGeneralNum = dataHsse.HeadOfficeInspectorGeneralNum; item.HighRiskNum = dataHsse.HighRiskNum; item.Id = dataHsse.Id; item.IncomeComprehensiveEnergyConsumption = dataHsse.IncomeComprehensiveEnergyConsumption; item.JoinConstructionPersonNum = dataHsse.JoinConstructionPersonNum; item.LicensesCloseNum = dataHsse.LicensesCloseNum; item.LicensesNum = dataHsse.LicensesNum; item.LostWorkingHour = dataHsse.LostWorkingHour; item.LowRiskNum = dataHsse.LowRiskNum; item.MajorAccidentNum = dataHsse.MajorAccidentNum; item.MajorClosedNum = dataHsse.MajorClosedNum; item.MajorNotClosedNum = dataHsse.MajorNotClosedNum; item.MajorProjectsUnderConstructionNum = dataHsse.MajorProjectsUnderConstructionNum; item.MajorRate = ""; item.MediumRiskNum = dataHsse.MediumRiskNum; item.NearMissNum = dataHsse.NearMissNum; item.NewWaterConsumption = dataHsse.NewWaterConsumption; item.ProjectComprehensivePlanNum = dataHsse.ProjectComprehensivePlanNum; item.ProjectDrillNum = dataHsse.ProjectDrillNum; item.ProjectDrillPersonNum = dataHsse.ProjectDrillPersonNum; item.ProjectFullTimeNum = dataHsse.ProjectFullTimeNum; item.ProjectInspectorGeneralNum = dataHsse.ProjectInspectorGeneralNum; item.ProjectLeadShiftCheckNum = dataHsse.ProjectLeadShiftCheckNum; item.ProjectMajorCheckNum = dataHsse.ProjectMajorCheckNum; item.ProjectOnSiteDisposalPlan = dataHsse.ProjectOnSiteDisposalPlan; item.ProjectSafetyLeadingGroupMeetingNum = dataHsse.ProjectSafetyLeadingGroupMeetingNum; item.ProjectSafetyMeetingNum = dataHsse.ProjectSafetyMeetingNum; item.ProjectSafetyMonitorNum = dataHsse.ProjectSafetyMonitorNum; item.ProjectSpecialCheckNum = dataHsse.ProjectSpecialCheckNum; item.ProjectSpecialPlanNum = dataHsse.ProjectSpecialPlanNum; item.RecordableEventNum = dataHsse.RecordableEventNum; item.ReportDate = dataHsse.ReportDate.Value.ToShortDateString(); item.SafeTrainNum = dataHsse.SafeTrainNum; item.SafetyCommitteeMeetingNum = dataHsse.SafetyCommitteeMeetingNum; item.SafetyInjectionEngineer = dataHsse.SafetyInjectionEngineer; item.SafeWorkingHour = dataHsse.SafeWorkingHour; item.SeriousAccidentNum = dataHsse.SeriousAccidentNum; item.ShutdownNum = dataHsse.ShutdownNum; item.SpecialEquipmentNum = dataHsse.SpecialEquipmentNum; item.SpecialOperationTrainNum = dataHsse.SpecialOperationTrainNum; item.HseTechnicalNum = dataHsse.HseTechnicalNum; item.EnvironmentalTrainNum = dataHsse.EnvironmentalTrainNum; item.SpecialSeriousAccidentNum = dataHsse.SpecialSeriousAccidentNum; item.SpecialTrainNum = dataHsse.SpecialTrainNum; item.SuperCompletedNum = dataHsse.SuperCompletedNum; item.SuperConstructionNum = dataHsse.SuperConstructionNum; item.SuperFinishedNum = dataHsse.SuperFinishedNum; item.SuperTrainPersonNum = dataHsse.SuperTrainPersonNum; item.SuperOperativesNum = dataHsse.SuperOperativesNum; item.SuperArgumentNum = dataHsse.SuperArgumentNum; item.TotalEnergyConsumption = dataHsse.TotalEnergyConsumption; item.TotalWorkingHour = dataHsse.TotalWorkingHour; item.TrainPersonNum = dataHsse.TrainPersonNum; item.OperativesNum = dataHsse.OperativesNum; item.UnitId = dataHsse.UnitId; item.UseEquipmentNum = dataHsse.UseEquipmentNum; var hSseDataHiddens = HSSEData_HiddenDangerDetailService.GetHSSEData_HiddenDangerDetailByDate(dataHsse.ReportDate); if (hSseDataHiddens != null) { var list = hSseDataHiddens.Select(detail => new HSSEDataHiddenDangerDetailItem { Id = detail.Id, NeedRectifyNum = detail.NeedRectifyNum, TotalNum = detail.TotalNum, TypeName = detail.TypeName }).ToList(); item.HiddenDangerDetailItems = list; } } var hsseDataItems = new List { item }; data.HSSEDataItems = hsseDataItems; return data; } public static HSSEData GetItemByHSSEData_HSSE(HSSEData_HSSE dataHsse, List hSseDataHiddens) { var item = new HsseDataItem(); var data = new HSSEData(); if (dataHsse != null) { item.BranchLeadShiftCheckNum = dataHsse.BranchLeadShiftCheckNum; item.BranchComprehensiveCheckNum = dataHsse.BranchComprehensiveCheckNum; item.BranchSpecialCheckNum = dataHsse.BranchSpecialCheckNum; item.BeUnderConstructionNum = dataHsse.BeUnderConstructionNum; item.BranchFullTimeNum = dataHsse.BranchFullTimeNum; item.BranchInspectorGeneralNum = dataHsse.BranchInspectorGeneralNum; item.BranchComprehensivePlanNum = dataHsse.BranchComprehensivePlanNum; item.BranchSpecialPlanNum = dataHsse.BranchSpecialPlanNum; item.BranchOnSiteDisposalPlan = dataHsse.BranchOnSiteDisposalPlan; item.CertificateANum = dataHsse.CertificateANum; item.CertificateBNum = dataHsse.CertificateBNum; item.CertificateCNum = dataHsse.CertificateCNum; item.QualityPersonNum = dataHsse.QualityPersonNum; item.CollCropCode = dataHsse.CollCropCode; item.CompanyComprehensiveCheckNum = dataHsse.CompanyComprehensiveCheckNum; item.CompanyComprehensivePlanNum = dataHsse.CompanyComprehensivePlanNum; item.CompanyDrillNum = dataHsse.CompanyDrillNum; item.CompanyDrillPersonNum = dataHsse.CompanyDrillPersonNum; item.BranchDrillNum = dataHsse.BranchDrillNum; item.BranchDrillPersonNum = dataHsse.BranchDrillPersonNum; item.CompanyLeadShiftCheckNum = dataHsse.CompanyLeadShiftCheckNum; item.CompanyOnSiteDisposalPlan = dataHsse.CompanyOnSiteDisposalPlan; item.CompanySpecialCheckNum = dataHsse.CompanySpecialCheckNum; item.CompanySpecialPlanNum = dataHsse.CompanySpecialPlanNum; item.CompletedNum = dataHsse.CompletedNum; item.ConstructionNum = dataHsse.ConstructionNum; item.CostExtract = dataHsse.CostExtract; item.CostUse = dataHsse.CostUse; item.EnterpriseTopicsMeetingNum = dataHsse.EnterpriseTopicsMeetingNum; item.FinishedNum = dataHsse.FinishedNum; item.ArgumentNum = dataHsse.ArgumentNum; item.GeneralAccidentNum = dataHsse.GeneralAccidentNum; item.GeneralClosedNum = dataHsse.GeneralClosedNum; item.GeneralNotClosedNum = dataHsse.GeneralNotClosedNum; item.GeneralRate = ""; item.GeneralRiskNum = dataHsse.GeneralRiskNum; item.HeadOfficeFullTimeNum = dataHsse.HeadOfficeFullTimeNum; item.HeadOfficeInspectorGeneralNum = dataHsse.HeadOfficeInspectorGeneralNum; item.HighRiskNum = dataHsse.HighRiskNum; item.Id = dataHsse.Id; item.IncomeComprehensiveEnergyConsumption = dataHsse.IncomeComprehensiveEnergyConsumption; item.JoinConstructionPersonNum = dataHsse.JoinConstructionPersonNum; item.LicensesCloseNum = dataHsse.LicensesCloseNum; item.LicensesNum = dataHsse.LicensesNum; item.LostWorkingHour = dataHsse.LostWorkingHour; item.LowRiskNum = dataHsse.LowRiskNum; item.MajorAccidentNum = dataHsse.MajorAccidentNum; item.MajorClosedNum = dataHsse.MajorClosedNum; item.MajorNotClosedNum = dataHsse.MajorNotClosedNum; item.MajorProjectsUnderConstructionNum = dataHsse.MajorProjectsUnderConstructionNum; item.MajorRate = ""; item.MediumRiskNum = dataHsse.MediumRiskNum; item.NearMissNum = dataHsse.NearMissNum; item.NewWaterConsumption = dataHsse.NewWaterConsumption; item.ProjectComprehensivePlanNum = dataHsse.ProjectComprehensivePlanNum; item.ProjectDrillNum = dataHsse.ProjectDrillNum; item.ProjectDrillPersonNum = dataHsse.ProjectDrillPersonNum; item.ProjectFullTimeNum = dataHsse.ProjectFullTimeNum; item.ProjectSubFullTimeNum = dataHsse.ProjectSubFullTimeNum; item.ProjectInspectorGeneralNum = dataHsse.ProjectInspectorGeneralNum; item.ProjectLeadShiftCheckNum = dataHsse.ProjectLeadShiftCheckNum; item.ProjectMajorCheckNum = dataHsse.ProjectMajorCheckNum; item.ProjectOnSiteDisposalPlan = dataHsse.ProjectOnSiteDisposalPlan; item.ProjectSafetyLeadingGroupMeetingNum = dataHsse.ProjectSafetyLeadingGroupMeetingNum; item.ProjectSafetyMeetingNum = dataHsse.ProjectSafetyMeetingNum; item.ProjectSafetyMonitorNum = dataHsse.ProjectSafetyMonitorNum; item.ProjectSpecialCheckNum = dataHsse.ProjectSpecialCheckNum; item.ProjectSpecialPlanNum = dataHsse.ProjectSpecialPlanNum; item.RecordableEventNum = dataHsse.RecordableEventNum; item.ReportDate = dataHsse.ReportDate.Value.ToShortDateString(); item.SafeTrainNum = dataHsse.SafeTrainNum; item.SafetyCommitteeMeetingNum = dataHsse.SafetyCommitteeMeetingNum; item.SafetyInjectionEngineer = dataHsse.SafetyInjectionEngineer; item.SafeWorkingHour = dataHsse.SafeWorkingHour; item.SeriousAccidentNum = dataHsse.SeriousAccidentNum; item.ShutdownNum = dataHsse.ShutdownNum; item.SpecialEquipmentNum = dataHsse.SpecialEquipmentNum; item.SpecialOperationTrainNum = dataHsse.SpecialOperationTrainNum; item.HseTechnicalNum = dataHsse.HseTechnicalNum; item.EnvironmentalTrainNum = dataHsse.EnvironmentalTrainNum; item.SpecialSeriousAccidentNum = dataHsse.SpecialSeriousAccidentNum; item.SpecialTrainNum = dataHsse.SpecialTrainNum; item.SuperCompletedNum = dataHsse.SuperCompletedNum; item.SuperConstructionNum = dataHsse.SuperConstructionNum; item.SuperFinishedNum = dataHsse.SuperFinishedNum; item.SuperArgumentNum = dataHsse.SuperArgumentNum; item.SuperTrainPersonNum = dataHsse.SuperTrainPersonNum; item.SuperOperativesNum = dataHsse.SuperOperativesNum; item.TotalEnergyConsumption = dataHsse.TotalEnergyConsumption; item.TotalWorkingHour = dataHsse.TotalWorkingHour; item.TrainPersonNum = dataHsse.TrainPersonNum; item.OperativesNum = dataHsse.OperativesNum; item.UnitId = dataHsse.UnitId; item.UseEquipmentNum = dataHsse.UseEquipmentNum; if (hSseDataHiddens != null) { var list = hSseDataHiddens.Select(detail => new HSSEDataHiddenDangerDetailItem { Id = detail.Id, NeedRectifyNum = detail.NeedRectifyNum, TotalNum = detail.TotalNum, TypeName = detail.TypeName }).ToList(); item.HiddenDangerDetailItems = list; } } var hsseDataItems = new List { item }; data.HSSEDataItems = hsseDataItems; return data; } public static async Task GetTodayHSSEData_HSSE() { var modelTask = StatisticalDataAsync(); var model = await modelTask; HSSEData data = model; return data; } public static HSSEData GetTheLastData() { HSSEData hSSEData = new HSSEData(); var dataHsse = (from x in Funs.DB.HSSEData_HSSE orderby x.ReportDate descending select x).FirstOrDefault(); var hSseDataHiddens = Project_HSSEData_HiddenDangerDetailService.GetModelByDate(dataHsse.ReportDate.Value); hSSEData = GetItemByHSSEData_HSSE(dataHsse, hSseDataHiddens); return hSSEData; } public static HSSEData_HSSE GetTodayData() { var q = (from x in Funs.DB.HSSEData_HSSE where x.ReportDate < DateTime.Now.AddDays(1).Date && x.ReportDate >= DateTime.Now.Date select x).FirstOrDefault(); return q; } public static void UpdateTodyData_State() { var q = GetTodayData(); if (q != null) { q.State = Const.CNCEC_State_1; UpdateHSSEData_HSSE(q); } } public static bool IsReportByDate(DateTime dateTime) { var result = false; var q = (from x in Funs.DB.HSSEData_HSSE where x.ReportDate >= dateTime.Date && x.ReportDate < dateTime.Date.AddDays(1).Date select x).ToList(); if (q.Count > 0) result = true; return result; } /// /// 判断当天是否已上报 /// /// public static bool IsReportByToday() { var result = false; var q = (from x in Funs.DB.HSSEData_HSSE where x.ReportDate < DateTime.Now.AddDays(1).Date && x.ReportDate >= DateTime.Now.Date select x).ToList(); if (q.Count > 0) result = true; return result; } public static ReturnData PushCncec(string id) { var baseurl = "/api/HSSEData/SaveHSSEData"; var item = GetItemById(id); var str = JsonConvert.SerializeObject(item); var responeData = ServerService.PushCNCEC(str, baseurl); return responeData; } public static Model.HSSEData_HSSE GetSubUnitHsseDataByDate(string Unitid, DateTime? reportdate) { var result = new Model.HSSEData_HSSE(); if (reportdate == null) { return result; } var projectlist = BLL.ProjectService.GetProjectWorkList(Unitid); var baseUnit = UnitService.GetUnitByUnitId(Unitid); var projectData = (from x in Funs.DB.Project_HSSEData_HSSE where x.ReportDate == reportdate && projectlist.Select(e => e.ProjectId).Contains(x.ProjectId) select x).ToList(); result = new HSSEData_HSSE { UnitId = Unitid, CollCropCode = baseUnit.CollCropCode, UnitName = baseUnit.UnitName, ReportDate = DateTime.Now.Date, BeUnderConstructionNum = projectData.Sum(x => x.BeUnderConstructionNum), ShutdownNum = projectData.Sum(x => x.ShutdownNum), JoinConstructionPersonNum = projectData.Sum(x => x.JoinConstructionPersonNum), MajorProjectsUnderConstructionNum = projectData.Sum(x => x.MajorProjectsUnderConstructionNum), TotalWorkingHour = projectData.Sum(x => x.TotalWorkingHour), LostWorkingHour = projectData.Sum(x => x.LostWorkingHour), SafeWorkingHour = projectData.Sum(x => x.SafeWorkingHour), SafeTrainNum = projectData.Sum(x => x.SafeTrainNum), SpecialTrainNum = projectData.Sum(x => x.SpecialTrainNum), SpecialOperationTrainNum = projectData.Sum(x => x.SpecialOperationTrainNum), TotalEnergyConsumption = 0, IncomeComprehensiveEnergyConsumption = 0, NewWaterConsumption = 0, HeadOfficeInspectorGeneralNum = GetHeadOfficeInspectorGeneral().Count, HeadOfficeFullTimeNum = GetHeadOfficeFullTime().Count, BranchInspectorGeneralNum = GetBranchInspectorGeneral().Count, BranchFullTimeNum = GetBranchFullTime().Count, ProjectInspectorGeneralNum = projectData.Sum(x => x.ProjectInspectorGeneralNum), ProjectFullTimeNum = projectData.Sum(x => x.ProjectFullTimeNum), ProjectSafetyMonitorNum = projectData.Sum(x => x.ProjectSafetyMonitorNum), SafetyInjectionEngineer = projectData.Sum(x => x.SafetyInjectionEngineer), CertificateANum = projectData.Sum(x => x.CertificateANum), CertificateBNum = projectData.Sum(x => x.CertificateBNum), CertificateCNum = projectData.Sum(x => x.CertificateCNum), SafetyCommitteeMeetingNum = GetSafetyCommitteeMeeting().Count, EnterpriseTopicsMeetingNum = GetEnterpriseTopicsMeetingNum(), ProjectSafetyLeadingGroupMeetingNum = projectData.Sum(x => x.ProjectSafetyLeadingGroupMeetingNum), ProjectSafetyMeetingNum = projectData.Sum(x => x.ProjectSafetyMeetingNum), CompanyLeadShiftCheckNum = GetCompanyLeadShiftCheck().Count, CompanyComprehensiveCheckNum = GetCompanyComprehensiveCheck().Count, CompanySpecialCheckNum = GetCompanySpecialCheck().Count, ProjectLeadShiftCheckNum = projectData.Sum(x => x.ProjectLeadShiftCheckNum), ProjectSpecialCheckNum = projectData.Sum(x => x.ProjectSpecialCheckNum), ProjectMajorCheckNum = projectData.Sum(x => x.ProjectMajorCheckNum), NearMissNum = projectData.Sum(x => x.NearMissNum), RecordableEventNum = projectData.Sum(x => x.RecordableEventNum), GeneralAccidentNum = projectData.Sum(x => x.GeneralAccidentNum), MajorAccidentNum = projectData.Sum(x => x.MajorAccidentNum), SeriousAccidentNum = projectData.Sum(x => x.SeriousAccidentNum), SpecialSeriousAccidentNum = projectData.Sum(x => x.SpecialSeriousAccidentNum), // CompanyComprehensivePlanNum = GetCompanyComprehensivePlan(), // CompanySpecialPlanNum = GetCompanySpecialPlan(), // CompanyOnSiteDisposalPlan = GetCompanyOnSiteDisposalPlan(), // CompanyDrillNum = GetCompanyDrill(), ProjectComprehensivePlanNum = projectData.Sum(x => x.ProjectComprehensivePlanNum), ProjectSpecialPlanNum = projectData.Sum(x => x.ProjectSpecialPlanNum), ProjectOnSiteDisposalPlan = projectData.Sum(x => x.ProjectOnSiteDisposalPlan), ProjectDrillNum = projectData.Sum(x => x.ProjectDrillNum), CostExtract = projectData.Sum(x => x.CostExtract), CostUse = projectData.Sum(x => x.CostUse), UseEquipmentNum = projectData.Sum(x => x.UseEquipmentNum), SpecialEquipmentNum = projectData.Sum(x => x.SpecialEquipmentNum), LicensesNum = projectData.Sum(x => x.LicensesNum), LicensesCloseNum = projectData.Sum(x => x.LicensesCloseNum), GeneralClosedNum = projectData.Sum(x => x.GeneralClosedNum), GeneralNotClosedNum = projectData.Sum(x => x.GeneralNotClosedNum), MajorClosedNum = projectData.Sum(x => x.MajorClosedNum), MajorNotClosedNum = projectData.Sum(x => x.MajorNotClosedNum), GeneralRiskNum = projectData.Sum(x => x.GeneralRiskNum), LowRiskNum = projectData.Sum(x => x.LowRiskNum), MediumRiskNum = projectData.Sum(x => x.MediumRiskNum), HighRiskNum = projectData.Sum(x => x.HighRiskNum), CompletedNum = projectData.Sum(x => x.CompletedNum), TrainPersonNum = projectData.Sum(x => x.TrainPersonNum), ConstructionNum = projectData.Sum(x => x.ConstructionNum), FinishedNum = projectData.Sum(x => x.FinishedNum), SuperCompletedNum = projectData.Sum(x => x.SuperCompletedNum), SuperTrainPersonNum = projectData.Sum(x => x.SuperTrainPersonNum), SuperConstructionNum = projectData.Sum(x => x.SuperConstructionNum), SuperFinishedNum = projectData.Sum(x => x.SuperFinishedNum), CreateMan = Const.sysglyId, CreateDate = DateTime.Now }; return result; } /// /// 统计数据(异步) /// /// public static async Task StatisticalDataAsync() { var thisUnitId = string.Empty; var thisUnit = CommonService.GetIsThisUnit(); if (thisUnit != null) thisUnitId = thisUnit.UnitId; var baseUnit = UnitService.GetUnitByUnitId(thisUnitId); Project_HSSEData_HiddenDangerDetailService.StatisticalAllProjectData(); // 并行执行异步方法 var totalEnergyConsumptionTask = ChemicalReportItemService.GetLatstTimeTotalEnergyConsumption(); var incomeComprehensiveEnergyConsumptionTask = ChemicalReportItemService.GetLatstTimeIncomeComprehensiveEnergyConsumption(); var newWaterConsumptionTask = ChemicalReportItemService.GetLatstTimeNewWaterConsumption(); var securityRiskOutputListTask = HSSEData_HSSEService.GetSecurityRiskOutputsAsync(); var largeEngineeringOutputsTask = HSSEData_HSSEService.GetLargeEngineeringOutputsAsync(); var safetyInjectionEngineerTask = HSSEData_HSSEService.GetSafetyInjectionEngineerAsync(); var certificateATask = HSSEData_HSSEService.GetCertificateAAsync(); var certificateBTask = HSSEData_HSSEService.GetCertificateBAsync(); var certificateCTask = HSSEData_HSSEService.GetCertificateCAsync(); var qualityPersonNumTask = HSSEData_HSSEService.GetQualityPersonNumAsync(); var beUnderConstructionTask = HSSEData_HSSEService.GetBeUnderConstructionAsync(); var shutdownTask = HSSEData_HSSEService.GetShutdownAsync(); var joinConstructionPersonTask = HSSEData_HSSEService.GetJoinConstructionPersonAsync(); var joinConstructionPersonPushGroupTask = HSSEData_HSSEService.GetJoinConstructionPersonPushGroupAsync(); var majorProjectsUnderConstructionTask = HSSEData_HSSEService.GetMajorProjectsUnderConstructionAsync(); var totalWorkingHourTask = HSSEData_HSSEService.GetTotalWorkingHourAsync(); var lostWorkingHourTask = HSSEData_HSSEService.GetLostWorkingHourAsync(); var safeWorkingHourTask = HSSEData_HSSEService.GetSafeWorkingHourAsync(); var safeTrainTask = HSSEData_HSSEService.GetSafeTrainAsync(); var specialTrainTask = HSSEData_HSSEService.GetSpecialTrainAsync(); var specialOperationTrainTask = HSSEData_HSSEService.GetSpecialOperationTrainAsync(); var hseTechnicalTask = HSSEData_HSSEService.GetHseTechnicalAsync(); var headOfficeInspectorGeneralTask = HSSEData_HSSEService.GetHeadOfficeInspectorGeneralAsync(); var headOfficeFullTimeTask = HSSEData_HSSEService.GetHeadOfficeFullTimeAsync(); var branchInspectorGeneralTask = HSSEData_HSSEService.GetBranchInspectorGeneralAsync(); var branchFullTimeTask = HSSEData_HSSEService.GetBranchFullTimeAsync(); var projectInspectorGeneralTask = HSSEData_HSSEService.GetProjectInspectorGeneralAsync(); var projectFullTimeTask = HSSEData_HSSEService.GetProjectFullTimeAsync(); var projectSafetyMonitorTask = HSSEData_HSSEService.GetProjectSafetyMonitorAsync(); var safetyCommitteeMeetingTask = HSSEData_HSSEService.GetSafetyCommitteeMeetingAsync(); var enterpriseTopicsMeetingTask = HSSEData_HSSEService.GetEnterpriseTopicsMeetingAsync(); var projectSafetyLeadingGroupMeetingTask = HSSEData_HSSEService.GetProjectSafetyLeadingGroupMeetingAsync(); var projectSafetyMeetingTask = HSSEData_HSSEService.GetProjectSafetyMeetingAsync(); var companyLeadShiftCheckTask = HSSEData_HSSEService.GetCompanyLeadShiftCheckAsync(); var companyComprehensiveCheckTask = HSSEData_HSSEService.GetCompanyComprehensiveCheckAsync(); var companySpecialCheckTask = HSSEData_HSSEService.GetCompanySpecialCheckAsync(); var branchLeadShiftCheckTask = HSSEData_HSSEService.GetBranchLeadShiftCheckAsync(); var branchComprehensiveCheckTask = HSSEData_HSSEService.GetBranchComprehensiveCheckAsync(); var branchSpecialCheckTask = HSSEData_HSSEService.GetBranchSpecialCheckAsync(); var projectLeadShiftCheckTask = HSSEData_HSSEService.GetProjectLeadShiftCheckAsync(); var projectSpecialCheckTask = HSSEData_HSSEService.GetProjectSpecialCheckAsync(); var projectMajorCheckTask = HSSEData_HSSEService.GetProjectMajorCheckAsync(); var nearMissTask = HSSEData_HSSEService.GetNearMissAsync(); var recordableEventTask = HSSEData_HSSEService.GetRecordableEventAsync(); var generalAccidentTask = HSSEData_HSSEService.GetGeneralAccidentAsync(); var majorAccidentTask = HSSEData_HSSEService.GetMajorAccidentAsync(); var seriousAccidentTask = HSSEData_HSSEService.GetSeriousAccidentAsync(); var specialSeriousAccidentTask = HSSEData_HSSEService.GetSpecialSeriousAccidentAsync(); var companyComprehensivePlanTask = HSSEData_HSSEService.GetCompanyComprehensivePlanAsync(); var companySpecialPlanTask = HSSEData_HSSEService.GetCompanySpecialPlanAsync(); var companyOnSiteDisposalPlanTask = HSSEData_HSSEService.GetCompanyOnSiteDisposalPlanAsync(); var branchComprehensivePlanTask = HSSEData_HSSEService.GetBranchComprehensivePlanAsync(); var branchSpecialPlanTask = HSSEData_HSSEService.GetBranchSpecialPlanAsync(); var branchOnSiteDisposalPlanTask = HSSEData_HSSEService.GetBranchOnSiteDisposalPlanAsync(); var companyDrillTask = HSSEData_HSSEService.GetCompanyDrillAsync(); var branchDrillTask = HSSEData_HSSEService.GetBranchDrillAsync(); var projectComprehensivePlanTask = HSSEData_HSSEService.GetProjectComprehensivePlanAsync(); var projectSpecialPlanTask = HSSEData_HSSEService.GetProjectSpecialPlanAsync(); var projectOnSiteDisposalPlanTask = HSSEData_HSSEService.GetProjectOnSiteDisposalPlanAsync(); var projectDrillTask = HSSEData_HSSEService.GetProjectDrillAsync(); var costExtractTask = HSSEData_HSSEService.GetCostExtractAsync(); var costUseTask = HSSEData_HSSEService.GetCostUseAsync(); var useEquipmentTask = HSSEData_HSSEService.GetUseEquipmentAsync(); var specialEquipmentTask = HSSEData_HSSEService.GetSpecialEquipmentAsync(); var licensesTask = HSSEData_HSSEService.GetLicensesAsync(); var licensesCloseTask = HSSEData_HSSEService.GetLicensesCloseAsync(); var generalHiddenRectificationOutputsTask = HSSEData_HSSEService.GetGeneralHiddenRectificationOutputsAsync(); var majorHiddenRectificationOutputsTask = HSSEData_HSSEService.GetMajorHiddenRectificationOutputsAsync(); // 等待所有异步方法执行完成 await Task.WhenAll( securityRiskOutputListTask, largeEngineeringOutputsTask, safetyInjectionEngineerTask, certificateATask, certificateBTask, certificateCTask, qualityPersonNumTask, beUnderConstructionTask, shutdownTask, joinConstructionPersonTask,joinConstructionPersonPushGroupTask, majorProjectsUnderConstructionTask, totalWorkingHourTask, lostWorkingHourTask, safeWorkingHourTask, safeTrainTask, specialTrainTask, specialOperationTrainTask, hseTechnicalTask, headOfficeInspectorGeneralTask, headOfficeFullTimeTask, branchInspectorGeneralTask, branchFullTimeTask, projectInspectorGeneralTask, projectFullTimeTask, projectSafetyMonitorTask, safetyCommitteeMeetingTask, enterpriseTopicsMeetingTask, projectSafetyLeadingGroupMeetingTask, projectSafetyMeetingTask, companyLeadShiftCheckTask, companyComprehensiveCheckTask, companySpecialCheckTask, branchLeadShiftCheckTask, branchComprehensiveCheckTask, branchSpecialCheckTask, projectLeadShiftCheckTask, projectSpecialCheckTask, projectMajorCheckTask, nearMissTask, recordableEventTask, generalAccidentTask, majorAccidentTask, seriousAccidentTask, specialSeriousAccidentTask, companyComprehensivePlanTask, companySpecialPlanTask, companyOnSiteDisposalPlanTask, branchComprehensivePlanTask, branchSpecialPlanTask, branchOnSiteDisposalPlanTask, companyDrillTask, branchDrillTask, projectComprehensivePlanTask, projectSpecialPlanTask, projectOnSiteDisposalPlanTask, projectDrillTask, costExtractTask, costUseTask, useEquipmentTask, specialEquipmentTask, licensesTask, licensesCloseTask, generalHiddenRectificationOutputsTask, majorHiddenRectificationOutputsTask ); // 统一获取异步方法的返回值 var totalEnergyConsumption = totalEnergyConsumptionTask; var incomeComprehensiveEnergyConsumption = incomeComprehensiveEnergyConsumptionTask; var newWaterConsumption = newWaterConsumptionTask; var safetyInjectionEngineerList = await safetyInjectionEngineerTask; var certificateAList = await certificateATask; var certificateBList = await certificateBTask; var certificateCList = await certificateCTask; var qualityPersonList = await qualityPersonNumTask; var beUnderConstructionList = await beUnderConstructionTask; var shutdownList = await shutdownTask; var joinConstructionPersonList = await joinConstructionPersonTask; var joinConstructionPersonPushGroupList = await joinConstructionPersonPushGroupTask; var majorProjectsUnderConstructionList = await majorProjectsUnderConstructionTask; var totalWorkingHour = await totalWorkingHourTask; var lostWorkingHour = await lostWorkingHourTask; var safeWorkingHour = await safeWorkingHourTask; var safeTrainList = await safeTrainTask; var specialTrainList = await specialTrainTask; var specialOperationTrainList = await specialOperationTrainTask; var hseTechnicalList = await hseTechnicalTask; var headOfficeInspectorGeneralList = await headOfficeInspectorGeneralTask; var headOfficeFullTimeList = await headOfficeFullTimeTask; var branchInspectorGeneralList = await branchInspectorGeneralTask; var branchFullTimeList = await branchFullTimeTask; var projectInspectorGeneralList = await projectInspectorGeneralTask; var projectFullTimeList = await projectFullTimeTask; var projectSafetyMonitorList = await projectSafetyMonitorTask; var safetyCommitteeMeetingList = await safetyCommitteeMeetingTask; var enterpriseTopicsMeetingList = await enterpriseTopicsMeetingTask; var projectSafetyLeadingGroupMeetingList = await projectSafetyLeadingGroupMeetingTask; var projectSafetyMeetingList = await projectSafetyMeetingTask; var companyLeadShiftCheckList = await companyLeadShiftCheckTask; var companyComprehensiveCheckList = await companyComprehensiveCheckTask; var companySpecialCheckList = await companySpecialCheckTask; var branchLeadShiftCheckList = await branchLeadShiftCheckTask; var branchComprehensiveCheckList = await branchComprehensiveCheckTask; var branchSpecialCheckList = await branchSpecialCheckTask; var projectLeadShiftCheckList = await projectLeadShiftCheckTask; var projectSpecialCheckList = await projectSpecialCheckTask; var projectMajorCheckList = await projectMajorCheckTask; var nearMissList = await nearMissTask; var recordableEventList = await recordableEventTask; var generalAccidentList = await generalAccidentTask; var majorAccidentList = await majorAccidentTask; var seriousAccidentList = await seriousAccidentTask; var specialSeriousAccidentList = await specialSeriousAccidentTask; var companyComprehensivePlanList = await companyComprehensivePlanTask; var companySpecialPlanList = await companySpecialPlanTask; var companyOnSiteDisposalPlanList = await companyOnSiteDisposalPlanTask; var branchComprehensivePlanList = await branchComprehensivePlanTask; var branchSpecialPlanList = await branchSpecialPlanTask; var branchOnSiteDisposalPlanList = await branchOnSiteDisposalPlanTask; var companyDrillList = await companyDrillTask; var branchDrillList = await branchDrillTask; var projectComprehensivePlanList = await projectComprehensivePlanTask; var projectSpecialPlanList = await projectSpecialPlanTask; var projectOnSiteDisposalPlanList = await projectOnSiteDisposalPlanTask; var projectDrillList = await projectDrillTask; var costExtract = await costExtractTask; var costUseList = await costUseTask; var useEquipmentList = await useEquipmentTask; var specialEquipmentList = await specialEquipmentTask; var licensesList = await licensesTask; var licensesCloseList = await licensesCloseTask; var generalHiddenRectificationOutputsList = await generalHiddenRectificationOutputsTask; var majorHiddenRectificationOutputsList = await majorHiddenRectificationOutputsTask; // 构造结果对象 var table = new HSSEData_HSSE { UnitId = thisUnitId, CollCropCode = baseUnit.CollCropCode, UnitName = baseUnit.UnitName, ReportDate = DateTime.Now.Date, BeUnderConstructionNum = beUnderConstructionList.Count(), ShutdownNum = shutdownList.Count(), SafetyInjectionEngineer = safetyInjectionEngineerList.Count(), CertificateANum = certificateAList.Count(), CertificateBNum = certificateBList.Count(), CertificateCNum = certificateCList.Count(), QualityPersonNum = qualityPersonList.Count(), //JoinConstructionPersonNum = joinConstructionPersonList.Count(), JoinConstructionPersonNum = joinConstructionPersonPushGroupList.Select(p => new { p.IdentityCard }).Distinct().Count(), MajorProjectsUnderConstructionNum = majorProjectsUnderConstructionList.Count(), TotalWorkingHour = totalWorkingHour, LostWorkingHour = lostWorkingHour, SafeWorkingHour = safeWorkingHour, SafeTrainNum = safeTrainList.Sum(x => x.TrainPersonNum), SpecialTrainNum = specialTrainList.Sum(x => x.TrainPersonNum), SpecialOperationTrainNum = specialOperationTrainList.Sum(x => x.TrainPersonNum), HseTechnicalNum = hseTechnicalList.Count(), EnvironmentalTrainNum = 0, TotalEnergyConsumption = totalEnergyConsumption, IncomeComprehensiveEnergyConsumption = incomeComprehensiveEnergyConsumption, NewWaterConsumption = newWaterConsumption, HeadOfficeInspectorGeneralNum = headOfficeInspectorGeneralList.Count, HeadOfficeFullTimeNum = headOfficeFullTimeList.Count, BranchInspectorGeneralNum = branchInspectorGeneralList.Count, BranchFullTimeNum = branchFullTimeList.Count, ProjectInspectorGeneralNum = projectInspectorGeneralList.Count, ProjectFullTimeNum = projectFullTimeList.Count(x=>x.IsOffice==true), ProjectSubFullTimeNum = projectFullTimeList.Count(x=>x.IsOffice==false), ProjectSafetyMonitorNum = projectSafetyMonitorList.Count, SafetyCommitteeMeetingNum = safetyCommitteeMeetingList.Count(), EnterpriseTopicsMeetingNum = enterpriseTopicsMeetingList.Count(), ProjectSafetyLeadingGroupMeetingNum = projectSafetyLeadingGroupMeetingList.Count(), ProjectSafetyMeetingNum = projectSafetyMeetingList.Count(), CompanyLeadShiftCheckNum = companyLeadShiftCheckList.Count(), CompanyComprehensiveCheckNum = companyComprehensiveCheckList.Count(), CompanySpecialCheckNum = companySpecialCheckList.Count(), BranchLeadShiftCheckNum = branchLeadShiftCheckList.Count(), BranchComprehensiveCheckNum = branchComprehensiveCheckList.Count(), BranchSpecialCheckNum = branchSpecialCheckList.Count(), ProjectLeadShiftCheckNum = projectLeadShiftCheckList.Count(), ProjectSpecialCheckNum = projectSpecialCheckList.Count(), ProjectMajorCheckNum = projectMajorCheckList.Count(), NearMissNum = nearMissList.Count(), RecordableEventNum = recordableEventList.Count(), GeneralAccidentNum = generalAccidentList.Count(), MajorAccidentNum = majorAccidentList.Count(), SeriousAccidentNum = seriousAccidentList.Count(), SpecialSeriousAccidentNum = specialSeriousAccidentList.Count(), CompanyComprehensivePlanNum = companyComprehensivePlanList.Count(), CompanySpecialPlanNum = companySpecialPlanList.Count(), CompanyOnSiteDisposalPlan = companyOnSiteDisposalPlanList.Count(), BranchComprehensivePlanNum = branchComprehensivePlanList.Count(), BranchSpecialPlanNum = branchSpecialPlanList.Count(), BranchOnSiteDisposalPlan = branchOnSiteDisposalPlanList.Count(), CompanyDrillNum = companyDrillList.Count(), CompanyDrillPersonNum = companyDrillList.Sum(x => x.JointPersonNum), BranchDrillNum = branchDrillList.Count(), BranchDrillPersonNum = branchDrillList.Sum(x => x.JointPersonNum), ProjectComprehensivePlanNum = projectComprehensivePlanList.Count(), ProjectSpecialPlanNum = projectSpecialPlanList.Count(), ProjectOnSiteDisposalPlan = projectOnSiteDisposalPlanList.Count(), ProjectDrillNum = projectDrillList.Count(), ProjectDrillPersonNum = projectDrillList.Sum(x => x.JointPersonNum), CostExtract = Convert.ToInt32(costExtract.Sum(x => x.SUMCost)), CostUse = Convert.ToInt32(costUseList.Sum(x => x.SUMCost)), UseEquipmentNum = useEquipmentList.Count(), SpecialEquipmentNum = specialEquipmentList.Count(), LicensesNum = licensesList.Count(), LicensesCloseNum = licensesCloseList.Count(), GeneralClosedNum = generalHiddenRectificationOutputsList.Sum(x => x.RecNum), GeneralNotClosedNum = generalHiddenRectificationOutputsList.Sum(x => x.NoRecNum), MajorClosedNum = majorHiddenRectificationOutputsList.Sum(x => x.RecNum), MajorNotClosedNum = majorHiddenRectificationOutputsList.Sum(x => x.NoRecNum), LowRiskNum = securityRiskOutputListTask.Result.Sum(x => x.LowRiskNum), GeneralRiskNum = securityRiskOutputListTask.Result.Sum(x => x.GeneralRiskNum), MediumRiskNum = securityRiskOutputListTask.Result.Sum(x => x.MediumRiskNum), HighRiskNum = securityRiskOutputListTask.Result.Sum(x => x.HighRiskNum), CompletedNum = largeEngineeringOutputsTask.Result.Sum(x => x.CompletedNum), TrainPersonNum = largeEngineeringOutputsTask.Result.Sum(x => x.TrainPersonNum), OperativesNum = largeEngineeringOutputsTask.Result.Sum(x => x.OperativesNum), ConstructionNum = largeEngineeringOutputsTask.Result.Sum(x => x.ConstructionNum), FinishedNum = largeEngineeringOutputsTask.Result.Sum(x => x.FinishedNum), ArgumentNum = largeEngineeringOutputsTask.Result.Sum(x => x.ArgumentNum), SuperCompletedNum = largeEngineeringOutputsTask.Result.Sum(x => x.SuperCompletedNum), SuperTrainPersonNum = largeEngineeringOutputsTask.Result.Sum(x => x.SuperTrainPersonNum), SuperOperativesNum = largeEngineeringOutputsTask.Result.Sum(x => x.SuperOperativesNum), SuperConstructionNum = largeEngineeringOutputsTask.Result.Sum(x => x.SuperConstructionNum), SuperFinishedNum = largeEngineeringOutputsTask.Result.Sum(x => x.SuperFinishedNum), SuperArgumentNum = largeEngineeringOutputsTask.Result.Sum(x => x.SuperArgumentNum) }; #region 添加项目统计数据 Project_HSSEData_HSSEService.DeleteProject_HSSEData_HSSEByDate(DateTime.Now.Date); var generalHiddenRectificationOutputsDict = generalHiddenRectificationOutputsList .GroupBy(x => x.ProjectId) .ToDictionary( g => g.Key, g => new { ClosedNum = g.Sum(x => x.RecNum), NotClosedNum = g.Sum(x => x.NoRecNum) } ); var majorHiddenRectificationOutputsDict = majorHiddenRectificationOutputsList .GroupBy(x => x.ProjectId) .ToDictionary( g => g.Key, g => new { ClosedNum = g.Sum(x => x.RecNum), NotClosedNum = g.Sum(x => x.NoRecNum) } ); var securityRiskOutputList = securityRiskOutputListTask.Result; var securityRiskOutputDict = securityRiskOutputList .GroupBy(x => x.ProjectId) .ToDictionary( g => g.Key, g => new { LowRiskNum = g.Sum(x => x.LowRiskNum), GeneralRiskNum = g.Sum(x => x.GeneralRiskNum), MediumRiskNum = g.Sum(x => x.MediumRiskNum), HighRiskNum = g.Sum(x => x.HighRiskNum) } ); var largeEngineeringOutputList = largeEngineeringOutputsTask.Result; var largeEngineeringOutputsDict = largeEngineeringOutputList .GroupBy(x => x.ProjectId) .ToDictionary( g => g.Key, g => new { CompletedNum = g.Sum(x => x.CompletedNum), TrainPersonNum = g.Sum(x => x.TrainPersonNum), OperativesNum = g.Sum(x => x.OperativesNum), ConstructionNum = g.Sum(x => x.ConstructionNum), FinishedNum = g.Sum(x => x.FinishedNum), ArgumentNum = g.Sum(x => x.ArgumentNum), SuperCompletedNum = g.Sum(x => x.SuperCompletedNum), SuperTrainPersonNum = g.Sum(x => x.SuperTrainPersonNum), SuperOperativesNum = g.Sum(x => x.SuperOperativesNum), SuperConstructionNum = g.Sum(x => x.SuperConstructionNum), SuperFinishedNum = g.Sum(x => x.SuperFinishedNum), SuperArgumentNum = g.Sum(x => x.SuperArgumentNum) } ); foreach (var projectid in BeUnderConstructionList) { generalHiddenRectificationOutputsDict.TryGetValue(projectid, out var generalHiddenRectificationOutputs); majorHiddenRectificationOutputsDict.TryGetValue(projectid, out var majorHiddenRectificationOutputs); securityRiskOutputDict.TryGetValue(projectid, out var securityRiskOutputs); largeEngineeringOutputsDict.TryGetValue(projectid, out var largeEngineeringOutputs); var projectHsseData = new Project_HSSEData_HSSE { Id = SQLHelper.GetNewID(), ProjectId = projectid, UnitId = thisUnitId, CollCropCode = baseUnit.CollCropCode, UnitName = baseUnit.UnitName, ReportDate = DateTime.Now.Date, JoinConstructionPersonNum = joinConstructionPersonList.Count(x => x.ProjectId == projectid), MajorProjectsUnderConstructionNum = majorProjectsUnderConstructionList.Count(x => x.ProjectId == projectid), TotalWorkingHour = 0,//工时数据取自集团报表,项目无法提取 LostWorkingHour = 0, SafeWorkingHour = 0, SafeTrainNum = safeTrainList.Where(x => x.ProjectId == projectid).Sum(x => x.TrainPersonNum), SpecialTrainNum = specialTrainList.Where(x => x.ProjectId == projectid).Sum(x => x.TrainPersonNum), SpecialOperationTrainNum = specialOperationTrainList.Where(x => x.ProjectId == projectid).Sum(x => x.TrainPersonNum), HseTechnicalNum = hseTechnicalList.Count(x => x.ProjectId == projectid), EnvironmentalTrainNum = 0, TotalEnergyConsumption = 0, IncomeComprehensiveEnergyConsumption = 0, NewWaterConsumption = 0, HeadOfficeInspectorGeneralNum = 0, HeadOfficeFullTimeNum = 0, BranchInspectorGeneralNum = 0, BranchFullTimeNum = 0, SafetyInjectionEngineer = safetyInjectionEngineerList.Count(x => x.ProjectId == projectid), EnterpriseTopicsMeetingNum = safetyInjectionEngineerList.Count(x => x.ProjectId == projectid), CertificateANum = certificateAList.Count(x => x.ProjectId == projectid), CertificateBNum = certificateBList.Count(x => x.ProjectId == projectid), CertificateCNum = certificateCList.Count(x => x.ProjectId == projectid), QualityPersonNum = qualityPersonList.Count(x => x.ProjectId == projectid), ProjectInspectorGeneralNum = projectInspectorGeneralList.Count(x => x.ProjectId == projectid), ProjectFullTimeNum = projectFullTimeList.Count(x => x.ProjectId == projectid && x.IsOffice==true), ProjectSubFullTimeNum = projectFullTimeList.Count(x => x.ProjectId == projectid && x.IsOffice== false), ProjectSafetyMonitorNum = projectSafetyMonitorList.Count(x => x.ProjectId == projectid), ProjectSafetyLeadingGroupMeetingNum = projectSafetyLeadingGroupMeetingList.Count(x => x.ProjectId == projectid), ProjectSafetyMeetingNum = projectSafetyMeetingList.Count(x => x.ProjectId == projectid), CompanyLeadShiftCheckNum = companyLeadShiftCheckList.Count(x => x.ProjectId == projectid), CompanyComprehensiveCheckNum = companyComprehensiveCheckList.Count(x => x.ProjectId == projectid), CompanySpecialCheckNum = companySpecialCheckList.Count(x => x.ProjectId == projectid), BranchLeadShiftCheckNum = branchLeadShiftCheckList.Count(x => x.ProjectId == projectid), BranchComprehensiveCheckNum = branchComprehensiveCheckList.Count(x => x.ProjectId == projectid), BranchSpecialCheckNum = branchSpecialCheckList.Count(x => x.ProjectId == projectid), ProjectLeadShiftCheckNum = projectLeadShiftCheckList.Count(x => x.ProjectId == projectid), ProjectSpecialCheckNum = projectSpecialCheckList.Count(x => x.ProjectId == projectid), ProjectMajorCheckNum = projectMajorCheckList.Count(x => x.ProjectId == projectid), NearMissNum = nearMissList.Count(x => x.ProjectId == projectid), RecordableEventNum = recordableEventList.Count(x => x.ProjectId == projectid), GeneralAccidentNum = generalAccidentList.Count(x => x.ProjectId == projectid), MajorAccidentNum = majorAccidentList.Count(x => x.ProjectId == projectid), SeriousAccidentNum = seriousAccidentList.Count(x => x.ProjectId == projectid), SpecialSeriousAccidentNum = specialSeriousAccidentList.Count(x => x.ProjectId == projectid), CompanyComprehensivePlanNum = 0, CompanySpecialPlanNum = 0, CompanyOnSiteDisposalPlan = 0, BranchComprehensivePlanNum = 0, BranchSpecialPlanNum = 0, BranchOnSiteDisposalPlan = 0, CompanyDrillNum = 0, CompanyDrillPersonNum = 0, BranchDrillNum = 0, BranchDrillPersonNum = 0, ProjectComprehensivePlanNum = projectComprehensivePlanList.Count(x => x.ProjectId == projectid), ProjectSpecialPlanNum = projectSpecialPlanList.Count(x => x.ProjectId == projectid), ProjectOnSiteDisposalPlan = projectOnSiteDisposalPlanList.Count(x => x.ProjectId == projectid), ProjectDrillNum = projectDrillList.Count(x => x.ProjectId == projectid), ProjectDrillPersonNum = projectDrillList.Where(x => x.ProjectId == projectid).Sum(x => x.JointPersonNum), CostExtract = Convert.ToInt32(costExtract.Where(x => x.ProjectId == projectid).Sum(x => x.SUMCost)), CostUse = Convert.ToInt32(costUseList.Where(x => x.ProjectId == projectid).Sum(x => x.SUMCost)), UseEquipmentNum = useEquipmentList.Count(x => x.ProjectId == projectid), SpecialEquipmentNum = specialEquipmentList.Count(x => x.ProjectId == projectid), LicensesNum = licensesList.Count(x => x.ProjectId == projectid), LicensesCloseNum = licensesCloseList.Count(x => x.ProjectId == projectid), GeneralClosedNum = generalHiddenRectificationOutputs?.ClosedNum ?? 0, GeneralNotClosedNum = generalHiddenRectificationOutputs?.NotClosedNum ?? 0, MajorClosedNum = majorHiddenRectificationOutputs?.ClosedNum ?? 0, MajorNotClosedNum = majorHiddenRectificationOutputs?.NotClosedNum ?? 0, LowRiskNum = securityRiskOutputs?.LowRiskNum ?? 0, GeneralRiskNum = securityRiskOutputs?.GeneralRiskNum ?? 0, MediumRiskNum = securityRiskOutputs?.MediumRiskNum ?? 0, HighRiskNum = securityRiskOutputs?.HighRiskNum ?? 0, CompletedNum = largeEngineeringOutputs?.CompletedNum ?? 0, TrainPersonNum = largeEngineeringOutputs?.TrainPersonNum ?? 0, OperativesNum = largeEngineeringOutputs?.OperativesNum ?? 0, ConstructionNum = largeEngineeringOutputs?.ConstructionNum ?? 0, FinishedNum = largeEngineeringOutputs?.FinishedNum ?? 0, ArgumentNum = largeEngineeringOutputs?.ArgumentNum ?? 0, SuperCompletedNum = largeEngineeringOutputs?.SuperCompletedNum ?? 0, SuperTrainPersonNum = largeEngineeringOutputs?.SuperTrainPersonNum ?? 0, SuperOperativesNum = largeEngineeringOutputs?.SuperOperativesNum ?? 0, SuperConstructionNum = largeEngineeringOutputs?.SuperConstructionNum ?? 0, SuperFinishedNum=largeEngineeringOutputs?.SuperFinishedNum ?? 0, SuperArgumentNum = largeEngineeringOutputs?.SuperArgumentNum ?? 0 }; Project_HSSEData_HSSEService.AddProject_HSSEData_HSSE(projectHsseData); } #endregion if (IsReportByToday()) { table.Id = GetTodayData().Id; table.State = Const.CNCEC_State_1; UpdateHSSEData_HSSE(table); } else { table.Id = SQLHelper.GetNewID(); table.State = Const.CNCEC_State_0; AddHSSEData_HSSE(table); } var data = GetItemByHSSEData_HSSE(table, Project_HSSEData_HiddenDangerDetailService.GetTodayModel()); return data; } public static void UpdateHSSEData_HSSE(HSSEData_HSSE newtable) { using (var db = new SUBQHSEDB(Funs.ConnString)) { var table = db.HSSEData_HSSE.FirstOrDefault(x => x.Id == newtable.Id); if (table != null) { table.Id = newtable.Id; 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.HseTechnicalNum = newtable.HseTechnicalNum; table.EnvironmentalTrainNum = newtable.EnvironmentalTrainNum; 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.ProjectSubFullTimeNum = newtable.ProjectSubFullTimeNum; table.ProjectSafetyMonitorNum = newtable.ProjectSafetyMonitorNum; table.SafetyInjectionEngineer = newtable.SafetyInjectionEngineer; table.CertificateANum = newtable.CertificateANum; table.CertificateBNum = newtable.CertificateBNum; table.CertificateCNum = newtable.CertificateCNum; table.QualityPersonNum = newtable.QualityPersonNum; 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.BranchLeadShiftCheckNum = newtable.BranchLeadShiftCheckNum; table.BranchComprehensiveCheckNum = newtable.BranchComprehensiveCheckNum; table.BranchSpecialCheckNum = newtable.BranchSpecialCheckNum; 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.BranchComprehensivePlanNum = newtable.BranchComprehensivePlanNum; table.BranchSpecialPlanNum = newtable.BranchSpecialPlanNum; table.BranchOnSiteDisposalPlan = newtable.BranchOnSiteDisposalPlan; table.CompanyDrillNum = newtable.CompanyDrillNum; table.CompanyDrillPersonNum = newtable.CompanyDrillPersonNum; table.BranchDrillNum = newtable.BranchDrillNum; table.BranchDrillPersonNum = newtable.BranchDrillPersonNum; table.ProjectComprehensivePlanNum = newtable.ProjectComprehensivePlanNum; table.ProjectSpecialPlanNum = newtable.ProjectSpecialPlanNum; table.ProjectOnSiteDisposalPlan = newtable.ProjectOnSiteDisposalPlan; table.ProjectDrillNum = newtable.ProjectDrillNum; table.ProjectDrillPersonNum = newtable.ProjectDrillPersonNum; 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.OperativesNum = newtable.OperativesNum; table.ConstructionNum = newtable.ConstructionNum; table.FinishedNum = newtable.FinishedNum; table.ArgumentNum = newtable.ArgumentNum; table.SuperCompletedNum = newtable.SuperCompletedNum; table.SuperTrainPersonNum = newtable.SuperTrainPersonNum; table.SuperOperativesNum = newtable.SuperOperativesNum; table.SuperConstructionNum = newtable.SuperConstructionNum; table.SuperFinishedNum = newtable.SuperFinishedNum; table.SuperArgumentNum = newtable.SuperArgumentNum; table.State = newtable.State; table.CreateMan = newtable.CreateMan; table.CreateDate = newtable.CreateDate; db.SubmitChanges(); } } } #region 安监人员数据 /// /// 获取企业总部总监人数 /// /// public static List GetHeadOfficeInspectorGeneral() { var unitId = string.Empty; var thisUnit = CommonService.GetIsThisUnit(); if (thisUnit != null) unitId = thisUnit.UnitId; var result = (from x in Funs.DB.Person_CompanyBranchPerson join u in Funs.DB.Base_Unit on x.UnitId equals u.UnitId into uGroup from u in uGroup.DefaultIfEmpty() join m in Funs.DB.Base_Post on x.WorkPostId equals m.PostId into mGroup from m in mGroup.DefaultIfEmpty() where x.IsOnJob == true && x.WorkPostId == Const.WorkPost_HSSEDirector && x.UnitId == unitId && x.IdentityCard != null select new Model.OfSafetySupervisorsOutput { ProjectId = "", ProjectName = "", UnitName = u.UnitName, Name = x.PersonName, Sex = x.Sex == null ? "" : (x.Sex == "1" ? "男" : "女"), IdentityCard = x.IdentityCard, WorkPostName = m.PostName == null ? "" : m.PostName, Phone = x.Telephone }).ToList(); result = result .GroupBy(x => x.IdentityCard) .Select(g => g.FirstOrDefault()) .ToList(); return result; } /// /// 获取企业总部总监人数(异步) /// /// public static async Task> GetHeadOfficeInspectorGeneralAsync() { return await Task.Run(GetHeadOfficeInspectorGeneral); } /// /// 获取企业总部专职人数 /// /// public static List GetHeadOfficeFullTime() { var unitId = string.Empty; var thisUnit = CommonService.GetIsThisUnit(); if (thisUnit != null) unitId = thisUnit.UnitId; var result = (from x in Funs.DB.Person_CompanyBranchPerson join u in Funs.DB.Base_Unit on x.UnitId equals u.UnitId into uGroup from u in uGroup.DefaultIfEmpty() join y in Funs.DB.Base_WorkPost on x.WorkPostId equals y.WorkPostId join m in Funs.DB.Base_Post on x.WorkPostId equals m.PostId into mGroup from m in mGroup.DefaultIfEmpty() where x.IsOnJob == true && y.IsHsse == true && x.UnitId == unitId && x.IdentityCard != null select new Model.OfSafetySupervisorsOutput { ProjectName = "", UnitName = u.UnitName, Name = x.PersonName, Sex = x.Sex == null ? "" : (x.Sex == "1" ? "男" : "女"), IdentityCard = x.IdentityCard, WorkPostName = m.PostName == null ? "" : m.PostName, Phone = x.Telephone }).ToList(); result = result .GroupBy(x => x.IdentityCard) .Select(g => g.FirstOrDefault()) .ToList(); return result; } /// /// 获取企业总部专职人数(异步) /// /// public static async Task> GetHeadOfficeFullTimeAsync() { return await Task.Run(GetHeadOfficeFullTime); } /// /// 获取分支机构专职人数 /// /// public static List GetBranchFullTime() { var unitId = string.Empty; var thisUnit = CommonService.GetIsThisUnit(); if (thisUnit != null) unitId = thisUnit.UnitId; var result = (from x in Funs.DB.Person_CompanyBranchPerson join u in Funs.DB.Base_Unit on x.UnitId equals u.UnitId into uGroup from u in uGroup.DefaultIfEmpty() join y in Funs.DB.Base_WorkPost on x.WorkPostId equals y.WorkPostId join m in Funs.DB.Base_Post on x.WorkPostId equals m.PostId into mGroup from m in mGroup.DefaultIfEmpty() where x.IsOnJob == true && y.IsHsse == true && x.UnitId != unitId && x.IdentityCard != null select new Model.OfSafetySupervisorsOutput { ProjectName = "", UnitName = u.UnitName, Name = x.PersonName, Sex = x.Sex == null ? "" : (x.Sex == "1" ? "男" : "女"), IdentityCard = x.IdentityCard, WorkPostName = m.PostName == null ? "" : m.PostName, Phone = x.Telephone }).ToList(); result = result .GroupBy(x => x.IdentityCard) .Select(g => g.FirstOrDefault()) .ToList(); return result; } /// /// 获取分支机构专职人数(异步) /// /// public static async Task> GetBranchFullTimeAsync() { return await Task.Run(GetBranchFullTime); } /// /// 获取分支机构总监人数 /// /// public static List GetBranchInspectorGeneral() { var unitId = string.Empty; var thisUnit = CommonService.GetIsThisUnit(); if (thisUnit != null) unitId = thisUnit.UnitId; var result = (from x in Funs.DB.Person_CompanyBranchPerson join u in Funs.DB.Base_Unit on x.UnitId equals u.UnitId into uGroup from u in uGroup.DefaultIfEmpty() join m in Funs.DB.Base_Post on x.WorkPostId equals m.PostId into mGroup from m in mGroup.DefaultIfEmpty() where x.IsOnJob == true && x.WorkPostId == Const.WorkPost_HSSEDirector && x.UnitId != unitId && x.IdentityCard != null select new Model.OfSafetySupervisorsOutput { ProjectName = "", UnitName = u.UnitName, Name = x.PersonName, Sex = x.Sex == null ? "" : (x.Sex == "1" ? "男" : "女"), IdentityCard = x.IdentityCard, WorkPostName = m.PostName == null ? "" : m.PostName, Phone = x.Telephone }).ToList(); result = result .GroupBy(x => x.IdentityCard) .Select(g => g.FirstOrDefault()) .ToList(); return result; } /// /// 获取分支机构总监人数(异步) /// /// public static async Task> GetBranchInspectorGeneralAsync() { return await Task.Run(GetBranchInspectorGeneral); } /// /// 获取项目总监人数 /// /// public static List GetProjectInspectorGeneral() { var result = (from x in Funs.DB.SitePerson_Person join p in Funs.DB.Base_Project on x.ProjectId equals p.ProjectId into pGroup from p in pGroup.DefaultIfEmpty() join u in Funs.DB.Base_Unit on x.UnitId equals u.UnitId into uGroup from u in uGroup.DefaultIfEmpty() join y in Funs.DB.Base_WorkPost on x.WorkPostId equals y.WorkPostId join z in Funs.DB.Base_Post on x.WorkPostId equals z.PostId into zGroup from z in zGroup.DefaultIfEmpty() where BeUnderConstructionList.Contains(p.ProjectId) && x.WorkPostId == Const.WorkPost_ProjectHSSEDirector && x.IsUsed == true && x.IdentityCard != null select new Model.OfSafetySupervisorsOutput { ProjectId = x.ProjectId, ProjectName = p.ProjectName, UnitId = u.UnitId, UnitName = u.UnitName, Name = x.PersonName, Sex = x.Sex == null ? "" : (x.Sex == "1" ? "男" : "女"), IdentityCard = x.IdentityCard, WorkPostName = z.PostName == null ? "" : z.PostName, Phone = x.Telephone }).ToList(); result = result .GroupBy(x => x.IdentityCard) .Select(g => g.FirstOrDefault()) .ToList(); return result; } /// /// 获取项目总监人数(异步) /// /// public static async Task> GetProjectInspectorGeneralAsync() { return await Task.Run(GetProjectInspectorGeneral); } /// /// 获取项目专职人数 /// /// public static List GetProjectFullTime() { var mianAndSubUnitList = (from x in Funs.DB.Base_Unit where x.IsThisUnit == true || x.IsBranch == true select x.UnitId).ToList(); var result = (from x in Funs.DB.SitePerson_Person join p in Funs.DB.Base_Project on x.ProjectId equals p.ProjectId into pGroup from p in pGroup.DefaultIfEmpty() join u in Funs.DB.Base_Unit on x.UnitId equals u.UnitId into uGroup from u in uGroup.DefaultIfEmpty() join y in Funs.DB.Base_WorkPost on x.WorkPostId equals y.WorkPostId into yGroup from y in yGroup.DefaultIfEmpty() join z in Funs.DB.Base_Post on x.WorkPostId equals z.PostId into zGroup from z in zGroup.DefaultIfEmpty() where BeUnderConstructionList.Contains(p.ProjectId) && y.IsHsse == true && x.IsUsed == true && x.IdentityCard != null select new Model.OfSafetySupervisorsOutput { ProjectId = x.ProjectId, ProjectName = p.ProjectName, ProjectFromUnitId = p.UnitId, UnitId = u.UnitId, UnitName = u.UnitName, Name = x.PersonName, Sex = x.Sex == null ? "" : (x.Sex == "1" ? "男" : "女"), IdentityCard = x.IdentityCard, WorkPostName = y.WorkPostName == null ? "" : y.WorkPostName, Phone = x.Telephone, IsOffice = x.UnitId==null?false: mianAndSubUnitList.Contains(x.UnitId) }).ToList(); result = result .GroupBy(x => x.IdentityCard) .Select(g => g.FirstOrDefault()) .ToList(); return result; } /// /// 获取项目专职人数(异步) /// /// public static async Task> GetProjectFullTimeAsync() { return await Task.Run(GetProjectFullTime); } /// /// 获取项目安全监护人数 /// /// public static List GetProjectSafetyMonitor() { var result = (from x in Funs.DB.SitePerson_Person where x.IsSafetyMonitoring == true && x.IsUsed == true && x.IdentityCard != null join p in Funs.DB.Base_Project on x.ProjectId equals p.ProjectId into pGroup from p in pGroup.DefaultIfEmpty() join u in Funs.DB.Base_Unit on x.UnitId equals u.UnitId into uGroup from u in uGroup.DefaultIfEmpty() join post in Funs.DB.Base_WorkPost on x.WorkPostId equals post.WorkPostId into postGroup from post in postGroup.DefaultIfEmpty() where BeUnderConstructionList.Contains(p.ProjectId) select new Model.OfSafetySupervisorsOutput { ProjectId = x.ProjectId, ProjectName = p.ProjectName, UnitId = u.UnitId, UnitName = u.UnitName, Name = x.PersonName, Sex = x.Sex == null ? "" : (x.Sex == "1" ? "男" : "女"), IdentityCard = x.IdentityCard, WorkPostName = post.WorkPostName, Phone = x.Telephone }).ToList(); result = result .GroupBy(x => x.IdentityCard) .Select(g => g.FirstOrDefault()) .ToList(); return result; } /// /// 获取项目安全监护人数(异步) /// /// public static async Task> GetProjectSafetyMonitorAsync() { return await Task.Run(GetProjectSafetyMonitor); } /// /// 获取在岗执业注安师 /// /// public static List GetSafetyInjectionEngineer() { var result = (from x in Funs.DB.SitePerson_Person join p in Funs.DB.Base_Project on x.ProjectId equals p.ProjectId into pGroup from p in pGroup.DefaultIfEmpty() join u in Funs.DB.Base_Unit on x.UnitId equals u.UnitId into uGroup from u in uGroup.DefaultIfEmpty() 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 join m in Funs.DB.Base_Post on x.WorkPostId equals m.PostId into mGroup from m in mGroup.DefaultIfEmpty() where BeUnderConstructionList.Contains(p.ProjectId) && z.IsRegisterHSSE == true && x.IsUsed == true && x.IdentityCard != null select new Model.OfSafetySupervisorsOutput { ProjectId = x.ProjectId, ProjectName = p.ProjectName, UnitId = u.UnitId, UnitName = u.UnitName, Name = x.PersonName, Sex = x.Sex == null ? "" : (x.Sex == "1" ? "男" : "女"), IdentityCard = x.IdentityCard, WorkPostName = m.PostName == null ? "" : m.PostName, Phone = x.Telephone }).ToList(); var query2 = (from x in Funs.DB.Sys_User join p in Funs.DB.Base_Project on x.ProjectId equals p.ProjectId into pGroup from p in pGroup.DefaultIfEmpty() join u in Funs.DB.Base_Unit on x.UnitId equals u.UnitId into uGroup from u in uGroup.DefaultIfEmpty() join y in Funs.DB.QualityAudit_PersonQuality on x.UserId equals y.UserId join z in Funs.DB.Base_Certificate on y.CertificateId equals z.CertificateId join m in Funs.DB.Base_Post on x.WorkPostId equals m.PostId into mGroup from m in mGroup.DefaultIfEmpty() where z.IsRegisterHSSE == true && x.IdentityCard != null && x.IsPost == true select new Model.OfSafetySupervisorsOutput { ProjectId = x.ProjectId, ProjectName = p.ProjectName, UnitName = u.UnitName, Name = x.UserName, Sex = x.Sex == null ? "" : (x.Sex == "1" ? "男" : "女"), IdentityCard = x.IdentityCard, WorkPostName = m.PostName == null ? "" : m.PostName == null ? "" : m.PostName, Phone = x.Telephone }).ToList(); result.AddRange(query2); result = result .GroupBy(x => x.IdentityCard) .Select(g => g.FirstOrDefault()) .ToList(); return result; } /// /// 获取在岗执业注安师(异步) /// /// public static async Task> GetSafetyInjectionEngineerAsync() { return await Task.Run(GetSafetyInjectionEngineer); } /// /// 获取A证人员 /// /// public static List GetCertificateA() { var result = new List(); var query1 = (from x in Funs.DB.SitePerson_Person join p in Funs.DB.Base_Project on x.ProjectId equals p.ProjectId into pGroup from p in pGroup.DefaultIfEmpty() join u in Funs.DB.Base_Unit on x.UnitId equals u.UnitId into uGroup from u in uGroup.DefaultIfEmpty() 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 join m in Funs.DB.Base_Post on x.WorkPostId equals m.PostId into mGroup from m in mGroup.DefaultIfEmpty() where BeUnderConstructionList.Contains(p.ProjectId) && z.CertificateType == "A" && x.IsUsed == true && x.IdentityCard != null select new Model.OfSafetySupervisorsOutput { ProjectId = x.ProjectId, ProjectName = p.ProjectName, UnitId = u.UnitId, UnitName = u.UnitName, Name = x.PersonName, Sex = x.Sex == null ? "" : (x.Sex == "1" ? "男" : "女"), IdentityCard = x.IdentityCard, WorkPostName = m.PostName == null ? "" : m.PostName, Phone = x.Telephone }).ToList(); var query2 = (from x in Funs.DB.Sys_User join p in Funs.DB.Base_Project on x.ProjectId equals p.ProjectId into pGroup from p in pGroup.DefaultIfEmpty() join u in Funs.DB.Base_Unit on x.UnitId equals u.UnitId into uGroup from u in uGroup.DefaultIfEmpty() join y in Funs.DB.QualityAudit_PersonQuality on x.UserId equals y.UserId join z in Funs.DB.Base_Certificate on y.CertificateId equals z.CertificateId join m in Funs.DB.Base_Post on x.WorkPostId equals m.PostId into mGroup from m in mGroup.DefaultIfEmpty() where z.CertificateType == "A" && x.IdentityCard != null && x.IsPost == true select new Model.OfSafetySupervisorsOutput { ProjectId = x.ProjectId, ProjectName = p.ProjectName, UnitName = u.UnitName, Name = x.UserName, Sex = x.Sex == null ? "" : (x.Sex == "1" ? "男" : "女"), IdentityCard = x.IdentityCard, WorkPostName = m.PostName == null ? "" : m.PostName, Phone = x.Telephone }).ToList(); query1.AddRange(query2); result = query1 .GroupBy(x => x.IdentityCard) .Select(g => g.FirstOrDefault()) .ToList(); return result; } /// /// 获取A证人员(异步) /// /// public static async Task> GetCertificateAAsync() { return await Task.Run(GetCertificateA); } /// /// 获取B证人员 /// /// public static List GetCertificateB() { var result = new List(); var query1 = (from x in Funs.DB.SitePerson_Person join p in Funs.DB.Base_Project on x.ProjectId equals p.ProjectId into pGroup from p in pGroup.DefaultIfEmpty() join u in Funs.DB.Base_Unit on x.UnitId equals u.UnitId into uGroup from u in uGroup.DefaultIfEmpty() 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 join m in Funs.DB.Base_Post on x.WorkPostId equals m.PostId into mGroup from m in mGroup.DefaultIfEmpty() where BeUnderConstructionList.Contains(p.ProjectId) && z.CertificateType == "B" && x.IsUsed == true && x.IdentityCard != null select new Model.OfSafetySupervisorsOutput { ProjectId = x.ProjectId, ProjectName = p.ProjectName, UnitId = u.UnitId, UnitName = u.UnitName, Name = x.PersonName, Sex = x.Sex == null ? "" : (x.Sex == "1" ? "男" : "女"), IdentityCard = x.IdentityCard, WorkPostName = m.PostName == null ? "" : m.PostName, Phone = x.Telephone }).ToList(); var query2 = (from x in Funs.DB.Sys_User join p in Funs.DB.Base_Project on x.ProjectId equals p.ProjectId into pGroup from p in pGroup.DefaultIfEmpty() join u in Funs.DB.Base_Unit on x.UnitId equals u.UnitId into uGroup from u in uGroup.DefaultIfEmpty() join y in Funs.DB.QualityAudit_PersonQuality on x.UserId equals y.UserId join z in Funs.DB.Base_Certificate on y.CertificateId equals z.CertificateId join m in Funs.DB.Base_Post on x.WorkPostId equals m.PostId into mGroup from m in mGroup.DefaultIfEmpty() where z.CertificateType == "B" && x.IdentityCard != null && x.IsPost == true select new Model.OfSafetySupervisorsOutput { ProjectId = x.ProjectId, ProjectName = p.ProjectName, UnitName = u.UnitName, Name = x.UserName, Sex = x.Sex == null ? "" : (x.Sex == "1" ? "男" : "女"), IdentityCard = x.IdentityCard, WorkPostName = m.PostName == null ? "" : m.PostName, Phone = x.Telephone }).ToList(); query1.AddRange(query2); result = query1 .GroupBy(x => x.IdentityCard) .Select(g => g.FirstOrDefault()) .ToList(); return result; } /// /// 获取B证人员(异步) /// /// public static async Task> GetCertificateBAsync() { return await Task.Run(GetCertificateB); } /// /// 获取C证人员 /// /// public static List GetCertificateC() { var result = new List(); var query1 = (from x in Funs.DB.SitePerson_Person join p in Funs.DB.Base_Project on x.ProjectId equals p.ProjectId into pGroup from p in pGroup.DefaultIfEmpty() join u in Funs.DB.Base_Unit on x.UnitId equals u.UnitId into uGroup from u in uGroup.DefaultIfEmpty() 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 join m in Funs.DB.Base_Post on x.WorkPostId equals m.PostId into mGroup from m in mGroup.DefaultIfEmpty() where BeUnderConstructionList.Contains(p.ProjectId) && z.CertificateType == "C" && x.IsUsed == true && x.IdentityCard != null select new Model.OfSafetySupervisorsOutput { ProjectId = x.ProjectId, ProjectName = p.ProjectName, UnitId = u.UnitId, UnitName = u.UnitName, Name = x.PersonName, Sex = x.Sex == null ? "" : (x.Sex == "1" ? "男" : "女"), IdentityCard = x.IdentityCard, WorkPostName = m.PostName == null ? "" : m.PostName, Phone = x.Telephone }).ToList(); var query2 = (from x in Funs.DB.Sys_User join p in Funs.DB.Base_Project on x.ProjectId equals p.ProjectId into pGroup from p in pGroup.DefaultIfEmpty() join u in Funs.DB.Base_Unit on x.UnitId equals u.UnitId into uGroup from u in uGroup.DefaultIfEmpty() join y in Funs.DB.QualityAudit_PersonQuality on x.UserId equals y.UserId join z in Funs.DB.Base_Certificate on y.CertificateId equals z.CertificateId join m in Funs.DB.Base_Post on x.WorkPostId equals m.PostId into mGroup from m in mGroup.DefaultIfEmpty() where z.CertificateType == "C" && x.IdentityCard != null && x.IsPost == true select new Model.OfSafetySupervisorsOutput { ProjectId = x.ProjectId, ProjectName = p.ProjectName, UnitName = u.UnitName, Name = x.UserName, Sex = x.Sex == null ? "" : (x.Sex == "1" ? "男" : "女"), IdentityCard = x.IdentityCard, WorkPostName = m.PostName == null ? "" : m.PostName, Phone = x.Telephone }).ToList(); query1.AddRange(query2); result = query1 .GroupBy(x => x.IdentityCard) .Select(g => g.FirstOrDefault()) .ToList(); return result; } /// /// 获取C证人员(异步) /// /// public static async Task> GetCertificateCAsync() { return await Task.Run(GetCertificateC); } /// /// 获取在岗特种作业人员数量 /// /// public static List GetQualityPersonNum() { var result = (from p in Funs.DB.SitePerson_Person join bp in Funs.DB.Base_Project on p.ProjectId equals bp.ProjectId into bpGroup from bp in bpGroup.DefaultIfEmpty() join u in Funs.DB.Base_Unit on p.UnitId equals u.UnitId into uGroup from u in uGroup.DefaultIfEmpty() join q in Funs.DB.QualityAudit_PersonQuality on p.PersonId equals q.PersonId into qGroup from q in qGroup.DefaultIfEmpty() join m in Funs.DB.Base_WorkPost on p.WorkPostId equals m.WorkPostId into mGroup from m in mGroup.DefaultIfEmpty() join su in Funs.DB.Sys_User on q.CompileMan equals su.UserId into suGroup from su in suGroup.DefaultIfEmpty() join bc in Funs.DB.Base_Certificate on q.CertificateId equals bc.CertificateId into bcGroup from bc in bcGroup.DefaultIfEmpty() join su1 in Funs.DB.Sys_User on q.AuditorId equals su1.UserId into su1Group from su1 in su1Group.DefaultIfEmpty() where BeUnderConstructionList.Contains(p.ProjectId) && m.PostType == Const.PostType_2 && p.IsUsed == true select new Model.OfSafetySupervisorsOutput { ProjectId = p.ProjectId, ProjectName = bp.ProjectName, UnitId = u.UnitId, UnitName = u.UnitName, Name = p.PersonName, Sex = p.Sex == null ? "" : (p.Sex == "1" ? "男" : "女"), IdentityCard = p.IdentityCard, WorkPostName = m.WorkPostName == null ? "" : m.WorkPostName, Phone = p.Telephone }).ToList(); return result; } /// /// 获取在岗特种作业人员数量(异步) /// /// public static async Task> GetQualityPersonNumAsync() { return await Task.Run(GetQualityPersonNum); } #endregion #region 安全会议数据 /// /// 获取企业安委会会数据 /// /// public static List GetSafetyCommitteeMeeting() { var result = (from x in Funs.DB.Meeting_CompanySafetyMeeting join p in Funs.DB.Base_Project on x.ProjectId equals p.ProjectId into pGroup from p in pGroup.DefaultIfEmpty() join u in Funs.DB.Base_Unit on x.UnitId equals u.UnitId into uGroup from u in uGroup.DefaultIfEmpty() where x.CompileDate > Const.DtmarkTime select new MeetingOutput() { ProjectId = x.ProjectId, ProjectName = p.ProjectName, UnitId = x.UnitId, UnitName = u.UnitName, Id = x.CompanySafetyMeetingId, MeetingName = x.CompanySafetyMeetingName, MeetingDate = x.CompanySafetyMeetingDate, MeetingHours = x.MeetingHours, HostMan = x.MeetingHostMan, AttentPerson = x.AttentPerson, AttentPersonNum = x.AttentPersonNum, }); return result.ToList(); } /// /// 获取企业安委会会数据(异步) /// /// public static async Task> GetSafetyCommitteeMeetingAsync() { return await Task.Run(GetSafetyCommitteeMeeting); } /// /// 获取企业专题会议数 /// /// public static int GetEnterpriseTopicsMeetingNum() { var result = (from x in Funs.DB.Meeting_CompanySpecialMeeting where x.CompileDate > Const.DtmarkTime select x).Count(); return result; } /// /// 获取企业专题会议 /// /// public static List GetEnterpriseTopicsMeeting() { var result = (from x in Funs.DB.Meeting_CompanySpecialMeeting join u in Funs.DB.Base_Unit on x.UnitId equals u.UnitId into uGroup from u in uGroup.DefaultIfEmpty() where x.CompileDate > Const.DtmarkTime select new MeetingOutput() { UnitId = x.UnitId, UnitName = u.UnitName, Id = x.CompanySpecialMeetingId, MeetingName = x.CompanySpecialMeetingName, MeetingDate = x.CompanySpecialMeetingDate, MeetingHours = x.MeetingHours, HostMan = x.MeetingHostMan, AttentPerson = x.AttentPerson, AttentPersonNum = x.AttentPersonNum, }); return result.ToList(); } /// /// 获取企业专题会议(异步) /// /// public static async Task> GetEnterpriseTopicsMeetingAsync() { return await Task.Run(GetEnterpriseTopicsMeeting); } /// /// 获取项目班前会 /// /// public static List GetProjectClassMeeting(string projectId) { var result = ( from x in Funs.DB.Meeting_ClassMeeting join p in Funs.DB.Base_Project on x.ProjectId equals p.ProjectId into pGroup from p in pGroup.DefaultIfEmpty() where x.ProjectId == projectId && x.CompileDate > Const.DtmarkTime && BeUnderConstructionList.Contains(p.ProjectId) select new MeetingOutput() { ProjectId = x.ProjectId, ProjectName = p.ProjectName, Id = x.ClassMeetingId, MeetingName = x.ClassMeetingName, MeetingDate = x.ClassMeetingDate, MeetingHours = x.MeetingHours, HostMan = x.MeetingHostMan, AttentPerson = x.AttentPerson, AttentPersonNum = x.AttentPersonNum, }).ToList(); return result.ToList(); } ///// ///// 获取项目班前会议(异步) ///// ///// //public static async Task> GetProjectClassMeetingAsync() //{ // return await Task.Run(GetProjectClassMeeting); //} /// /// 获取项目周前会 /// /// public static List GetProjectWeekMeeting(string projectId) { var list = (from x in Funs.DB.Meeting_WeekMeeting join p in Funs.DB.Base_Project on x.ProjectId equals p.ProjectId into pGroup from p in pGroup.DefaultIfEmpty() where BeUnderConstructionList.Contains(p.ProjectId) && x.CompileDate > Const.DtmarkTime select new MeetingOutput() { ProjectId = x.ProjectId, ProjectName = p.ProjectName, Id = x.WeekMeetingId, MeetingName = x.WeekMeetingName, MeetingDate = x.WeekMeetingDate, MeetingHours = x.MeetingHours, HostMan = x.MeetingHostMan, AttentPerson = x.AttentPerson, AttentPersonNum = x.AttentPersonNum, }).ToList(); if (!string.IsNullOrWhiteSpace(projectId)) { list = list.Where(x => x.ProjectId == projectId).ToList(); } return list.ToList(); } /// /// 获取项目专题会议 /// /// public static List GetProjectSpecialMeeting(string projectId) { var result = ( from x in Funs.DB.Meeting_SpecialMeeting join p in Funs.DB.Base_Project on x.ProjectId equals p.ProjectId into pGroup from p in pGroup.DefaultIfEmpty() where x.ProjectId == projectId && x.CompileDate > Const.DtmarkTime && BeUnderConstructionList.Contains(p.ProjectId) select new MeetingOutput() { ProjectId = x.ProjectId, ProjectName = p.ProjectName, Id = x.SpecialMeetingId, MeetingName = x.SpecialMeetingName, MeetingDate = x.SpecialMeetingDate, MeetingHours = x.MeetingHours, HostMan = x.MeetingHostMan, AttentPerson = x.AttentPerson, AttentPersonNum = x.AttentPersonNum, }); return result.ToList(); } ///// ///// 获取项目专题会议(异步) ///// ///// //public static async Task> GetProjectSpecialMeetingAsync() //{ // return await Task.Run(GetProjectSpecialMeeting); //} /// /// 获取项目安全领导小组会议 /// /// public static List GetProjectSafetyLeadingGroupMeeting() { var result = ( from x in Funs.DB.Meeting_SafetyLeaderGroupMeeting join p in Funs.DB.Base_Project on x.ProjectId equals p.ProjectId into pGroup from p in pGroup.DefaultIfEmpty() where x.CompileDate > Const.DtmarkTime && BeUnderConstructionList.Contains(p.ProjectId) select new MeetingOutput() { ProjectId = x.ProjectId, ProjectName = p.ProjectName, Id = x.SafetyLeaderGroupMeetingId, MeetingName = x.SafetyLeaderGroupMeetingName, MeetingDate = x.SafetyLeaderGroupMeetingDate, MeetingHours = x.MeetingHours, HostMan = x.MeetingHostMan, AttentPerson = x.AttentPerson, AttentPersonNum = x.AttentPersonNum, }); return result.ToList(); } /// /// 获取项目安全领导小组会议 /// /// /// public static List GetProjectSafetyLeadingGroupMeeting(string projectId) { var result = ( from x in Funs.DB.Meeting_SafetyLeaderGroupMeeting join p in Funs.DB.Base_Project on x.ProjectId equals p.ProjectId into pGroup from p in pGroup.DefaultIfEmpty() where x.ProjectId == projectId && x.CompileDate > Const.DtmarkTime && BeUnderConstructionList.Contains(p.ProjectId) select new MeetingOutput() { ProjectId = x.ProjectId, ProjectName = p.ProjectName, Id = x.SafetyLeaderGroupMeetingId, MeetingName = x.SafetyLeaderGroupMeetingName, MeetingDate = x.SafetyLeaderGroupMeetingDate, MeetingHours = x.MeetingHours, HostMan = x.MeetingHostMan, AttentPerson = x.AttentPerson, AttentPersonNum = x.AttentPersonNum, }); return result.ToList(); } /// /// 获取项目安全领导小组会议(异步) /// /// public static async Task> GetProjectSafetyLeadingGroupMeetingAsync() { return await Task.Run(GetProjectSafetyLeadingGroupMeeting); } /// /// 获取项目安全例会数 /// /// public static List GetProjectSafetyMeeting() { var result = (from x in Funs.DB.Meeting_WeekMeeting join p in Funs.DB.Base_Project on x.ProjectId equals p.ProjectId into pGroup from p in pGroup.DefaultIfEmpty() where BeUnderConstructionList.Contains(p.ProjectId) && x.CompileDate > Const.DtmarkTime select new MeetingOutput() { ProjectId = x.ProjectId, ProjectName = p.ProjectName, Id = x.WeekMeetingId, MeetingName = x.WeekMeetingName, MeetingDate = x.WeekMeetingDate, MeetingHours = x.MeetingHours, HostMan = x.MeetingHostMan, AttentPerson = x.AttentPerson, AttentPersonNum = x.AttentPersonNum, }).Union (from x in Funs.DB.Meeting_MonthMeeting join p in Funs.DB.Base_Project on x.ProjectId equals p.ProjectId into pGroup from p in pGroup.DefaultIfEmpty() where BeUnderConstructionList.Contains(x.ProjectId) && x.CompileDate > Const.DtmarkTime select new MeetingOutput() { ProjectId = x.ProjectId, ProjectName = p.ProjectName, Id = x.MonthMeetingId, MeetingName = x.MonthMeetingName, MeetingDate = x.MonthMeetingDate, MeetingHours = x.MeetingHours, HostMan = x.MeetingHostMan, AttentPerson = x.AttentPerson, AttentPersonNum = x.AttentPersonNum, }); return result.ToList(); } /// /// 获取项目安全例会数 /// /// /// public static List GetProjectSafetyMeeting(string projectId) { var result = (from x in Funs.DB.Meeting_WeekMeeting join p in Funs.DB.Base_Project on x.ProjectId equals p.ProjectId into pGroup from p in pGroup.DefaultIfEmpty() where x.ProjectId == projectId && BeUnderConstructionList.Contains(p.ProjectId) && x.CompileDate > Const.DtmarkTime select new MeetingOutput() { ProjectId = x.ProjectId, ProjectName = p.ProjectName, Id = x.WeekMeetingId, MeetingName = x.WeekMeetingName, MeetingDate = x.WeekMeetingDate, MeetingHours = x.MeetingHours, HostMan = x.MeetingHostMan, AttentPerson = x.AttentPerson, AttentPersonNum = x.AttentPersonNum, }).Union (from x in Funs.DB.Meeting_MonthMeeting join p in Funs.DB.Base_Project on x.ProjectId equals p.ProjectId into pGroup from p in pGroup.DefaultIfEmpty() where x.ProjectId == projectId && BeUnderConstructionList.Contains(x.ProjectId) && x.CompileDate > Const.DtmarkTime select new MeetingOutput() { ProjectId = x.ProjectId, ProjectName = p.ProjectName, Id = x.MonthMeetingId, MeetingName = x.MonthMeetingName, MeetingDate = x.MonthMeetingDate, MeetingHours = x.MeetingHours, HostMan = x.MeetingHostMan, AttentPerson = x.AttentPerson, AttentPersonNum = x.AttentPersonNum, }); return result.ToList(); } /// /// 获取项目安全例会数(异步) /// /// public static async Task> GetProjectSafetyMeetingAsync() { return await Task.Run(GetProjectSafetyMeeting); } #endregion #region 安全监督检查数据 #region 企业级-本单位 /// /// 获取企业负责人带班检查次数 /// /// public static List GetCompanyLeadShiftCheck() { var result = (from x in Funs.DB.Supervise_SuperviseCheckReport join p in Funs.DB.Base_Project on x.ProjectId equals p.ProjectId into pGroup from p in pGroup.DefaultIfEmpty() join u in Funs.DB.Base_Unit on x.UnitId equals u.UnitId into uGroup from u in uGroup.DefaultIfEmpty() join cu in Funs.DB.Base_Unit on x.CheckUnitId equals cu.UnitId into cuGroup from cu in cuGroup.DefaultIfEmpty() where cu.IsThisUnit == true && x.CheckMainType == "0" && x.CheckType == "1" && x.CheckDate > Const.DtmarkTime select new Model.CheckOutput() { ProjectId = x.ProjectId, ProjectName = p.ProjectName, UnitId = x.UnitId, UnitName = u.UnitName, Id = x.SuperviseCheckReportId, CheckTeam = x.CheckTeam, CheckDate = x.CheckDate, }); return result.ToList(); } /// /// 获取企业负责人带班检查次数(异步) /// /// public static async Task> GetCompanyLeadShiftCheckAsync() { return await Task.Run(GetCompanyLeadShiftCheck); } /// /// 获取企业综合检查次数 /// /// public static List GetCompanyComprehensiveCheck() { var result = (from x in Funs.DB.Supervise_SuperviseCheckReport join p in Funs.DB.Base_Project on x.ProjectId equals p.ProjectId into pGroup from p in pGroup.DefaultIfEmpty() join u in Funs.DB.Base_Unit on x.UnitId equals u.UnitId into uGroup from u in uGroup.DefaultIfEmpty() join cu in Funs.DB.Base_Unit on x.CheckUnitId equals cu.UnitId into cuGroup from cu in cuGroup.DefaultIfEmpty() where cu.IsThisUnit == true && x.CheckMainType == "0" && x.CheckType == "2" && x.CheckDate > Const.DtmarkTime select new Model.CheckOutput() { ProjectId = x.ProjectId, ProjectName = p.ProjectName, UnitId = x.UnitId, UnitName = u.UnitName, Id = x.SuperviseCheckReportId, CheckTeam = x.CheckTeam, CheckDate = x.CheckDate, }); #region 交建统计 var IsCnccg = CommonService.GetIsThisUnit().CollCropCode == "913700001630777743"; if (IsCnccg) { result = (from x in Funs.DB.Problem_Notice join p in Funs.DB.Base_Project on x.ProjectId equals p.ProjectId into pGroup from p in pGroup.DefaultIfEmpty() join u in Funs.DB.Base_Unit on x.Unitid equals u.UnitId into uGroup from u in uGroup.DefaultIfEmpty() select new Model.CheckOutput() { ProjectId = x.ProjectId, ProjectName = p.ProjectName, UnitId = x.Unitid, UnitName = u.UnitName, Id = x.ProNoticeId, CheckTeam = "", CheckDate = x.CheckStartTime, } ); } #endregion #region 四化建 var IsCncec4 = CommonService.GetIsThisUnit().CollCropCode == "914306001837642996"; if (IsCncec4) { result = (from x in Funs.DB.Supervise_SuperviseCheckReport_Shj join p in Funs.DB.Base_Project on x.ProjectOrUnit equals p.ProjectId into pGroup from p in pGroup.DefaultIfEmpty() join u in Funs.DB.Base_Unit on x.ProjectOrUnit equals u.UnitId into uGroup from u in uGroup.DefaultIfEmpty() select new Model.CheckOutput() { ProjectId = x.ProjectOrUnit, ProjectName = p.ProjectName, UnitId = x.ProjectOrUnit, UnitName = u.UnitName, Id = x.SuperviseCheckReportId, CheckTeam = "", CheckDate = x.CheckDate, } ); } #endregion return result.ToList(); } /// /// 获取企业综合检查次数(异步) /// /// public static async Task> GetCompanyComprehensiveCheckAsync() { return await Task.Run(GetCompanyComprehensiveCheck); } /// /// 获取企业专项检查次数 /// /// public static List GetCompanySpecialCheck() { var result = (from x in Funs.DB.Supervise_SuperviseCheckReport join p in Funs.DB.Base_Project on x.ProjectId equals p.ProjectId into pGroup from p in pGroup.DefaultIfEmpty() join u in Funs.DB.Base_Unit on x.UnitId equals u.UnitId into uGroup from u in uGroup.DefaultIfEmpty() join cu in Funs.DB.Base_Unit on x.CheckUnitId equals cu.UnitId into cuGroup from cu in cuGroup.DefaultIfEmpty() where cu.IsThisUnit == true && x.CheckMainType == "0" && x.CheckType == "3" && x.CheckDate > Const.DtmarkTime select new Model.CheckOutput() { ProjectId = x.ProjectId, ProjectName = p.ProjectName, UnitId = x.UnitId, UnitName = u.UnitName, Id = x.SuperviseCheckReportId, CheckTeam = x.CheckTeam, CheckDate = x.CheckDate, }); return result.ToList(); } /// /// 获取企业专项检查次数(异步) /// /// public static async Task> GetCompanySpecialCheckAsync() { return await Task.Run(GetCompanySpecialCheck); } #endregion #region 分支机构 /// /// 获取分支机构企业负责人带班检查次数 /// /// public static List GetBranchLeadShiftCheck() { var result = (from x in Funs.DB.Supervise_SuperviseCheckReport join p in Funs.DB.Base_Project on x.ProjectId equals p.ProjectId into pGroup from p in pGroup.DefaultIfEmpty() join u in Funs.DB.Base_Unit on x.UnitId equals u.UnitId into uGroup from u in uGroup.DefaultIfEmpty() join cu in Funs.DB.Base_Unit on x.CheckUnitId equals cu.UnitId into cuGroup from cu in cuGroup.DefaultIfEmpty() where cu.IsBranch == true && x.CheckMainType == "0" && x.CheckType == "1" && x.CheckDate > Const.DtmarkTime select new Model.CheckOutput() { ProjectId = x.ProjectId, ProjectName = p.ProjectName, UnitId = x.UnitId, UnitName = u.UnitName, Id = x.SuperviseCheckReportId, CheckTeam = x.CheckTeam, CheckDate = x.CheckDate, }); return result.ToList(); } /// /// 获取分支机构企业负责人带班检查次数(异步) /// /// public static async Task> GetBranchLeadShiftCheckAsync() { return await Task.Run(GetBranchLeadShiftCheck); } /// /// 获取分支机构企业综合检查次数 /// /// public static List GetBranchComprehensiveCheck() { var result = (from x in Funs.DB.Supervise_SuperviseCheckReport join p in Funs.DB.Base_Project on x.ProjectId equals p.ProjectId into pGroup from p in pGroup.DefaultIfEmpty() join u in Funs.DB.Base_Unit on x.UnitId equals u.UnitId into uGroup from u in uGroup.DefaultIfEmpty() join cu in Funs.DB.Base_Unit on x.CheckUnitId equals cu.UnitId into cuGroup from cu in cuGroup.DefaultIfEmpty() where cu.IsBranch == true && x.CheckMainType == "0" && x.CheckType == "2" && x.CheckDate > Const.DtmarkTime select new Model.CheckOutput() { ProjectId = x.ProjectId, ProjectName = p.ProjectName, UnitId = x.UnitId, UnitName = u.UnitName, Id = x.SuperviseCheckReportId, CheckTeam = x.CheckTeam, CheckDate = x.CheckDate, }); #region 交建统计 var IsCnccg = CommonService.GetIsThisUnit().CollCropCode == "913700001630777743"; if (IsCnccg) { result = (from x in Funs.DB.Problem_Notice join p in Funs.DB.Base_Project on x.ProjectId equals p.ProjectId into pGroup from p in pGroup.DefaultIfEmpty() join u in Funs.DB.Base_Unit on x.Unitid equals u.UnitId into uGroup from u in uGroup.DefaultIfEmpty() select new Model.CheckOutput() { ProjectId = x.ProjectId, ProjectName = p.ProjectName, UnitId = x.Unitid, UnitName = u.UnitName, Id = x.ProNoticeId, CheckTeam = "", CheckDate = x.CheckStartTime, } ); } #endregion #region 四化建 var IsCncec4 = CommonService.GetIsThisUnit().CollCropCode == "914306001837642996"; if (IsCncec4) { result = (from x in Funs.DB.Supervise_SuperviseCheckReport_Shj join p in Funs.DB.Base_Project on x.ProjectOrUnit equals p.ProjectId into pGroup from p in pGroup.DefaultIfEmpty() join u in Funs.DB.Base_Unit on x.ProjectOrUnit equals u.UnitId into uGroup from u in uGroup.DefaultIfEmpty() select new Model.CheckOutput() { ProjectId = x.ProjectOrUnit, ProjectName = p.ProjectName, UnitId = x.ProjectOrUnit, UnitName = u.UnitName, Id = x.SuperviseCheckReportId, CheckTeam = "", CheckDate = x.CheckDate, } ); } #endregion return result.ToList(); } /// /// 获取分支机构企业综合检查次数(异步) /// /// public static async Task> GetBranchComprehensiveCheckAsync() { return await Task.Run(GetBranchComprehensiveCheck); } /// /// 获取分支机构企业专项检查次数 /// /// public static List GetBranchSpecialCheck() { var result = (from x in Funs.DB.Supervise_SuperviseCheckReport join p in Funs.DB.Base_Project on x.ProjectId equals p.ProjectId into pGroup from p in pGroup.DefaultIfEmpty() join u in Funs.DB.Base_Unit on x.UnitId equals u.UnitId into uGroup from u in uGroup.DefaultIfEmpty() join cu in Funs.DB.Base_Unit on x.CheckUnitId equals cu.UnitId into cuGroup from cu in cuGroup.DefaultIfEmpty() where cu.IsBranch == true && x.CheckMainType == "0" && x.CheckType == "3" && x.CheckDate > Const.DtmarkTime select new Model.CheckOutput() { ProjectId = x.ProjectId, ProjectName = p.ProjectName, UnitId = x.UnitId, UnitName = u.UnitName, Id = x.SuperviseCheckReportId, CheckTeam = x.CheckTeam, CheckDate = x.CheckDate, }); return result.ToList(); } /// /// 获取分支机构企业专项检查次数(异步) /// /// public static async Task> GetBranchSpecialCheckAsync() { return await Task.Run(GetBranchSpecialCheck); } #endregion #region 项目级 /// /// 获取项目负责人带班检查次数 /// /// public static List GetProjectLeadShiftCheck() { // 先批量获取所有需要的UnitIds和LeaderIds var unitIds = Funs.DB.Check_ProjectLeaderCheck .Where(x => BeUnderConstructionList.Contains(x.ProjectId) && x.CheckDate > Const.DtmarkTime) .Select(x => x.UnitIds).Distinct().ToList(); Dictionary unitNames = new Dictionary(); foreach (var item in unitIds) { unitNames.Add(item ?? "null", UnitService.getUnitNamesUnitIds(item)); } var leaderIds = Funs.DB.Check_ProjectLeaderCheck .Where(x => BeUnderConstructionList.Contains(x.ProjectId) && x.CheckDate > Const.DtmarkTime) .Select(x => x.LeaderIds).Distinct().ToList(); Dictionary leaderNames = new Dictionary(); foreach (var item in leaderIds) { leaderNames.Add(item ?? "null", UserService.getUserNamesUserIds(item)); } var result = (from x in Funs.DB.Check_ProjectLeaderCheck join p in Funs.DB.Base_Project on x.ProjectId equals p.ProjectId into pGroup from p in pGroup.DefaultIfEmpty() where BeUnderConstructionList.Contains(p.ProjectId) && x.CheckDate > Const.DtmarkTime select new Model.CheckOutput() { ProjectId = x.ProjectId, ProjectName = p.ProjectName, UnitName = unitNames[x.UnitIds ?? "null"], // 从预加载的字典中获取 Id = x.ProjectLeaderCheckId, CheckTeam = leaderNames[x.LeaderIds ?? "null"], // 从预加载的字典中获取 CheckDate = x.CheckDate, }); return result.ToList(); } /// /// 获取项目负责人带班检查次数(异步) /// /// public static async Task> GetProjectLeadShiftCheckAsync() { return await Task.Run(GetProjectLeadShiftCheck); } /// /// 获取项目专项检查次数 /// /// public static List GetProjectSpecialCheck() { var unitIds = Funs.DB.Check_CheckSpecial .Where(x => BeUnderConstructionList.Contains(x.ProjectId) && x.CheckTime > Const.DtmarkTime) .Select(x => x.PartInUnits).Distinct().ToList(); Dictionary unitNames = new Dictionary(); foreach (var item in unitIds) { unitNames.Add(item ?? "null", UnitService.getUnitNamesUnitIds(item)); } var result = (from x in Funs.DB.Check_CheckSpecial join p in Funs.DB.Base_Project on x.ProjectId equals p.ProjectId into pGroup from p in pGroup.DefaultIfEmpty() where BeUnderConstructionList.Contains(p.ProjectId) && x.CheckTime > Const.DtmarkTime select new Model.CheckOutput() { ProjectId = x.ProjectId, ProjectName = p.ProjectName, UnitName = unitNames[x.PartInUnits ?? "null"], Id = x.CheckSpecialId, CheckTeam = x.PartInPersonNames, CheckDate = x.CheckTime, }); return result.ToList(); } /// /// 获取项目专项检查次数(异步) /// /// public static async Task> GetProjectSpecialCheckAsync() { return await Task.Run(GetProjectSpecialCheck); } /// /// 获取项目专业检查次数 /// /// public static List GetProjectMajorCheck() { var result = (from x in Funs.DB.HSSE_Hazard_HazardRegister join p in Funs.DB.Base_Project on x.ProjectId equals p.ProjectId into pGroup from p in pGroup.DefaultIfEmpty() join u in Funs.DB.Base_Unit on x.ResponsibleUnit equals u.UnitId into uGroup from u in uGroup.DefaultIfEmpty() join user in Funs.DB.Sys_User on x.CheckManId equals user.UserId into userGroup from user in userGroup.DefaultIfEmpty() where BeUnderConstructionList.Contains(p.ProjectId) && x.CheckTime > Const.DtmarkTime select new Model.CheckOutput() { ProjectId = x.ProjectId, ProjectName = p.ProjectName, UnitId = x.ResponsibleUnit, UnitName = u.UnitName, Id = x.HazardRegisterId, CheckTeam = user.UserName, CheckDate = x.CheckTime, }); return result.ToList(); } /// /// 获取项目专业检查次数(异步) /// /// public static async Task> GetProjectMajorCheckAsync() { return await Task.Run(GetProjectMajorCheck); } #endregion #endregion #region 应急管理数据 /// /// 获取企业级综合预案数 /// /// public static List GetCompanyComprehensivePlan() { var result = (from x in Funs.DB.Emergency_EmergencyList_Unit join y in Funs.DB.Base_EmergencyType on x.EmergencyTypeId equals y.EmergencyTypeId join u in Funs.DB.Base_Unit on x.UnitId equals u.UnitId into uGroup from u in uGroup.DefaultIfEmpty() where u.IsThisUnit == true && y.EmergencyTypeName.Contains("综合") && x.CompileDate > Const.DtmarkTime select new Model.EmergencyOutput { ProjectId = x.ProjectId, ProjectName = ProjectService.GetProjectNameByProjectId(x.ProjectId), UnitId = x.UnitId, UnitName = UnitService.GetUnitNameByUnitId(x.UnitId), Id = x.EmergencyListId, EmergencyName = x.EmergencyName, EmergencyTypeName = y.EmergencyTypeName, VersionCode = x.VersionCode, Date = x.CompileDate, }).ToList(); return result; } /// /// 获取企业级综合预案数(异步) /// /// public static async Task> GetCompanyComprehensivePlanAsync() { return await Task.Run(GetCompanyComprehensivePlan); } /// /// 获取企业级专项预案数 /// /// public static List GetCompanySpecialPlan() { var result = (from x in Funs.DB.Emergency_EmergencyList_Unit join y in Funs.DB.Base_EmergencyType on x.EmergencyTypeId equals y.EmergencyTypeId join u in Funs.DB.Base_Unit on x.UnitId equals u.UnitId into uGroup from u in uGroup.DefaultIfEmpty() where u.IsThisUnit == true && y.EmergencyTypeName.Contains("专项") && x.CompileDate > Const.DtmarkTime select new Model.EmergencyOutput { ProjectId = x.ProjectId, ProjectName = ProjectService.GetProjectNameByProjectId(x.ProjectId), UnitId = x.UnitId, UnitName = UnitService.GetUnitNameByUnitId(x.UnitId), Id = x.EmergencyListId, EmergencyName = x.EmergencyName, EmergencyTypeName = y.EmergencyTypeName, VersionCode = x.VersionCode, Date = x.CompileDate, }).ToList(); return result; } /// /// 获取企业级专项预案数(异步) /// /// public static async Task> GetCompanySpecialPlanAsync() { return await Task.Run(GetCompanySpecialPlan); } /// /// 获取企业级现场处置预案 /// /// public static List GetCompanyOnSiteDisposalPlan() { var result = (from x in Funs.DB.Emergency_EmergencyList_Unit join y in Funs.DB.Base_EmergencyType on x.EmergencyTypeId equals y.EmergencyTypeId join u in Funs.DB.Base_Unit on x.UnitId equals u.UnitId into uGroup from u in uGroup.DefaultIfEmpty() where u.IsThisUnit == true && y.EmergencyTypeName.Contains("现场处置") && x.CompileDate > Const.DtmarkTime select new Model.EmergencyOutput { ProjectId = x.ProjectId, ProjectName = ProjectService.GetProjectNameByProjectId(x.ProjectId), UnitId = x.UnitId, UnitName = UnitService.GetUnitNameByUnitId(x.UnitId), Id = x.EmergencyListId, EmergencyName = x.EmergencyName, EmergencyTypeName = y.EmergencyTypeName, VersionCode = x.VersionCode, Date = x.CompileDate, }).ToList(); return result; } /// /// 获取企业级现场处置预案(异步) /// /// public static async Task> GetCompanyOnSiteDisposalPlanAsync() { return await Task.Run(GetCompanyOnSiteDisposalPlan); } /// /// 获取分支机构综合预案数 /// /// public static List GetBranchComprehensivePlan() { var result = (from x in Funs.DB.Emergency_EmergencyList_Unit join y in Funs.DB.Base_EmergencyType on x.EmergencyTypeId equals y.EmergencyTypeId join u in Funs.DB.Base_Unit on x.UnitId equals u.UnitId into uGroup from u in uGroup.DefaultIfEmpty() where u.IsBranch == true && y.EmergencyTypeName.Contains("综合") && x.CompileDate > Const.DtmarkTime select new Model.EmergencyOutput { ProjectId = x.ProjectId, ProjectName = ProjectService.GetProjectNameByProjectId(x.ProjectId), UnitId = x.UnitId, UnitName = UnitService.GetUnitNameByUnitId(x.UnitId), Id = x.EmergencyListId, EmergencyName = x.EmergencyName, EmergencyTypeName = y.EmergencyTypeName, VersionCode = x.VersionCode, Date = x.CompileDate, }).ToList(); return result; } /// /// 获取分支机构综合预案数(异步) /// /// public static async Task> GetBranchComprehensivePlanAsync() { return await Task.Run(GetBranchComprehensivePlan); } /// /// 获取分支机构专项预案数 /// /// public static List GetBranchSpecialPlan() { var result = (from x in Funs.DB.Emergency_EmergencyList_Unit join y in Funs.DB.Base_EmergencyType on x.EmergencyTypeId equals y.EmergencyTypeId join u in Funs.DB.Base_Unit on x.UnitId equals u.UnitId into uGroup from u in uGroup.DefaultIfEmpty() where u.IsBranch == true && y.EmergencyTypeName.Contains("专项") && x.CompileDate > Const.DtmarkTime select new Model.EmergencyOutput { ProjectId = x.ProjectId, ProjectName = ProjectService.GetProjectNameByProjectId(x.ProjectId), UnitId = x.UnitId, UnitName = UnitService.GetUnitNameByUnitId(x.UnitId), Id = x.EmergencyListId, EmergencyName = x.EmergencyName, EmergencyTypeName = y.EmergencyTypeName, VersionCode = x.VersionCode, Date = x.CompileDate, }).ToList(); return result; } /// /// 获取分支机构专项预案数(异步) /// /// public static async Task> GetBranchSpecialPlanAsync() { return await Task.Run(GetBranchSpecialPlan); } /// /// 获取分支机构现场处置预案 /// /// public static List GetBranchOnSiteDisposalPlan() { var result = (from x in Funs.DB.Emergency_EmergencyList_Unit join y in Funs.DB.Base_EmergencyType on x.EmergencyTypeId equals y.EmergencyTypeId join u in Funs.DB.Base_Unit on x.UnitId equals u.UnitId into uGroup from u in uGroup.DefaultIfEmpty() where u.IsBranch == true && y.EmergencyTypeName.Contains("现场处置") && x.CompileDate > Const.DtmarkTime select new Model.EmergencyOutput { ProjectId = x.ProjectId, ProjectName = ProjectService.GetProjectNameByProjectId(x.ProjectId), UnitId = x.UnitId, UnitName = UnitService.GetUnitNameByUnitId(x.UnitId), Id = x.EmergencyListId, EmergencyName = x.EmergencyName, EmergencyTypeName = y.EmergencyTypeName, VersionCode = x.VersionCode, Date = x.CompileDate, }).ToList(); return result; } /// /// 获取分支机构现场处置预案(异步) /// /// public static async Task> GetBranchOnSiteDisposalPlanAsync() { return await Task.Run(GetBranchOnSiteDisposalPlan); } /// /// 获取企业级演练次数 /// /// public static List GetCompanyDrill() { var result = (from x in Funs.DB.Emergency_DrillRecordList_Unit join y in Funs.DB.Sys_Const on x.DrillRecordType equals y.ConstValue join u in Funs.DB.Base_Unit on x.UnitIds equals u.UnitId into uGroup from u in uGroup.DefaultIfEmpty() where u.IsThisUnit == true && y.GroupId == "DrillRecordType" && x.CompileDate > Const.DtmarkTime select new Model.EmergencyOutput { ProjectId = x.ProjectId, ProjectName = ProjectService.GetProjectNameByProjectId(x.ProjectId), UnitId = x.UnitIds, UnitName = UnitService.getUnitNamesUnitIds(x.UnitIds), Id = x.DrillRecordListId, EmergencyName = x.DrillRecordName, EmergencyTypeName = y.ConstText, Date = x.DrillRecordDate, DrillCost = x.DrillCost, JointPersonNum = x.JointPersonNum, }).ToList(); return result; } /// /// 获取企业级演练次数(异步) /// /// public static async Task> GetCompanyDrillAsync() { return await Task.Run(GetCompanyDrill); } /// /// 获取分支机构演练次数 /// /// public static List GetBranchDrill() { var result = (from x in Funs.DB.Emergency_DrillRecordList_Unit join y in Funs.DB.Sys_Const on x.DrillRecordType equals y.ConstValue join u in Funs.DB.Base_Unit on x.UnitIds equals u.UnitId into uGroup from u in uGroup.DefaultIfEmpty() where u.IsBranch == true && y.GroupId == "DrillRecordType" && x.CompileDate > Const.DtmarkTime select new Model.EmergencyOutput { ProjectId = x.ProjectId, ProjectName = ProjectService.GetProjectNameByProjectId(x.ProjectId), UnitId = x.UnitIds, UnitName = UnitService.getUnitNamesUnitIds(x.UnitIds), Id = x.DrillRecordListId, EmergencyName = x.DrillRecordName, EmergencyTypeName = y.ConstText, Date = x.DrillRecordDate, DrillCost = x.DrillCost, JointPersonNum = x.JointPersonNum ?? 0, }).ToList(); return result; } /// /// 获取分支机构演练次数(异步) /// /// public static async Task> GetBranchDrillAsync() { return await Task.Run(GetBranchDrill); } /// /// 获取项目级综合预案 /// /// public static List GetProjectComprehensivePlan() { var result = (from x in Funs.DB.Emergency_EmergencyList join y in Funs.DB.Base_EmergencyType on x.EmergencyTypeId equals y.EmergencyTypeId where BeUnderConstructionList.Contains(x.ProjectId) && y.EmergencyTypeName.Contains("综合") && x.CompileDate > Const.DtmarkTime select new Model.EmergencyOutput { ProjectId = x.ProjectId, ProjectName = ProjectService.GetProjectNameByProjectId(x.ProjectId), UnitId = x.UnitId, UnitName = UnitService.GetUnitNameByUnitId(x.UnitId), Id = x.EmergencyListId, EmergencyName = x.EmergencyName, EmergencyTypeName = y.EmergencyTypeName, VersionCode = x.VersionCode, Date = x.CompileDate, }).ToList(); return result; } /// /// 获取项目级综合预案(异步) /// /// public static async Task> GetProjectComprehensivePlanAsync() { return await Task.Run(GetProjectComprehensivePlan); } /// /// 获取项目级专项预案数 /// /// public static List GetProjectSpecialPlan() { var result = (from x in Funs.DB.Emergency_EmergencyList join y in Funs.DB.Base_EmergencyType on x.EmergencyTypeId equals y.EmergencyTypeId where BeUnderConstructionList.Contains(x.ProjectId) && y.EmergencyTypeName.Contains("专项") && x.CompileDate > Const.DtmarkTime select new Model.EmergencyOutput { ProjectId = x.ProjectId, ProjectName = ProjectService.GetProjectNameByProjectId(x.ProjectId), UnitId = x.UnitId, UnitName = UnitService.GetUnitNameByUnitId(x.UnitId), Id = x.EmergencyListId, EmergencyName = x.EmergencyName, EmergencyTypeName = y.EmergencyTypeName, VersionCode = x.VersionCode, Date = x.CompileDate, }).ToList(); return result; } /// /// 获取项目级专项预案数(异步) /// /// public static async Task> GetProjectSpecialPlanAsync() { return await Task.Run(GetProjectSpecialPlan); } /// /// 获取项目级现场处置预案 /// /// public static List GetProjectOnSiteDisposalPlan() { var result = (from x in Funs.DB.Emergency_EmergencyList join y in Funs.DB.Base_EmergencyType on x.EmergencyTypeId equals y.EmergencyTypeId where BeUnderConstructionList.Contains(x.ProjectId) && y.EmergencyTypeName.Contains("现场处置") && x.CompileDate > Const.DtmarkTime select new Model.EmergencyOutput { ProjectId = x.ProjectId, ProjectName = ProjectService.GetProjectNameByProjectId(x.ProjectId), UnitId = x.UnitId, UnitName = UnitService.GetUnitNameByUnitId(x.UnitId), Id = x.EmergencyListId, EmergencyName = x.EmergencyName, EmergencyTypeName = y.EmergencyTypeName, VersionCode = x.VersionCode, Date = x.CompileDate, }).ToList(); return result; } /// /// 获取项目级现场处置预案(异步) /// /// public static async Task> GetProjectOnSiteDisposalPlanAsync() { return await Task.Run(GetProjectOnSiteDisposalPlan); } /// /// 获取项目级演练次数 /// /// public static List GetProjectDrill() { var result = (from x in Funs.DB.Emergency_DrillRecordList join y in Funs.DB.Sys_Const on x.DrillRecordType equals y.ConstValue where y.GroupId == "DrillRecordType" where BeUnderConstructionList.Contains(x.ProjectId) && x.CompileDate > Const.DtmarkTime select new Model.EmergencyOutput { ProjectId = x.ProjectId, ProjectName = ProjectService.GetProjectNameByProjectId(x.ProjectId), UnitId = x.UnitIds, UnitName = UnitService.getUnitNamesUnitIds(x.UnitIds), Id = x.DrillRecordListId, EmergencyName = x.DrillRecordName, EmergencyTypeName = y.ConstText, Date = x.DrillRecordDate, DrillCost = x.DrillCost, JointPersonNum = x.JointPersonNum ?? 0, }).ToList(); return result; } /// /// 获取项目级演练次数(异步) /// /// public static async Task> GetProjectDrillAsync() { return await Task.Run(GetProjectDrill); } #endregion #region 基础信息 /// /// 获取在建项目数 /// /// public static List GetBeUnderConstruction() { return BaseDataService.GetBeUnderConstruction(); } /// /// 获取在建项目数(异步) /// /// public static async Task> GetBeUnderConstructionAsync() { return await Task.Run(GetBeUnderConstruction); } /// /// 获取停工项目数 /// /// public static List GetShutdown() { return BaseDataService.GetShutdown(); } /// /// 获取停工项目数(异步) /// /// public static async Task> GetShutdownAsync() { return await Task.Run(GetShutdown); } /// /// 获取完工项目数 /// /// public static List GetCompletedProject() { return BaseDataService.GetCompletedProject(); } /// /// 获取所有项目数 /// /// public static List GetALLProject() { return BaseDataService.GetALLProject(); } /// /// 获取参建人数 /// /// public static List GetJoinConstructionPerson() { var result = (from x in Funs.DB.SitePerson_Person where BeUnderConstructionList.Contains(x.ProjectId) && x.IsUsed == true select new Model.BaseEntities { Id = x.PersonId, ProjectId = x.ProjectId, UnitId = x.UnitId }).ToList(); return result; } /// /// 获取参建人数(异步) /// /// public static async Task> GetJoinConstructionPersonAsync() { return await Task.Run(GetJoinConstructionPerson); } /// /// 获取集团二级单位名称list,排除本单位【集团下面二级责任单位】 /// /// public static List GetNonLocalUnitNames() { List list = new List(); list.Add("中国天辰工程有限公司"); list.Add("赛鼎工程有限公司"); list.Add("东华工程科技股份有限公司"); list.Add("中国五环工程有限公司"); list.Add("华陆工程科技有限责任公司"); list.Add("中国成达工程有限公司"); list.Add("中化学土木工程有限公司"); list.Add("中化二建集团有限公司"); list.Add("中国化学工程第三建设有限公司"); list.Add("中国化学工程第四建设有限公司"); list.Add("中国化学工程第六建设有限公司"); list.Add("中国化学工程第七建设有限公司"); list.Add("中国化学工程第十一建设有限公司"); list.Add("中国化学工程第十三建设有限公司"); list.Add("中国化学工程第十四建设有限公司"); list.Add("中国化学工程第十六建设有限公司"); list.Add("中国化学工程重型机械化有限公司"); list.Add("中化学交通建设集团有限公司"); list.Add("中化学(北京)建设投资有限公司"); list.Add("中化学南方建设投资有限公司"); list.Add("中化学城市投资有限公司"); list.Add("中化学生态环境有限公司"); list.Add("中化学西南工程科技有限公司"); list.Add("中化学装备科技集团有限公司"); list.Add("中化学华谊工程科技集团有限公司"); list.Add("中化学开发建设有限公司"); var thisUnit = CommonService.GetIsThisUnit(); list = list.Where(x => x != thisUnit.UnitName).ToList(); return list; } /// /// 获取参建人数【推送集团】 /// /// public static List GetJoinConstructionPersonPushGroup() { var NonLocalUnitNamesList = GetNonLocalUnitNames(); var result = (from x in Funs.DB.SitePerson_Person join unit in Funs.DB.Base_Unit on x.UnitId equals unit.UnitId into unitJoin from unit in unitJoin.DefaultIfEmpty() where BeUnderConstructionList.Contains(x.ProjectId) && x.IsUsed == true && NonLocalUnitNamesList.Contains(unit.UnitName) == false select new Model.BaseEntities { Id = x.PersonId, IdentityCard = x.IdentityCard, ProjectId = x.ProjectId, UnitId = x.UnitId, }).ToList(); return result; } /// /// 获取参建人数(异步)【推送集团】 /// /// public static async Task> GetJoinConstructionPersonPushGroupAsync() { return await Task.Run(GetJoinConstructionPersonPushGroup); } /// /// 获取在施危大工程数 /// /// public static List GetMajorProjectsUnderConstruction() { var result = (from x in Funs.DB.Solution_LargerHazard where BeUnderConstructionList.Contains(x.ProjectId) && x.States == "2" && x.RecordTime > Const.DtmarkTime select new Model.BaseEntities { Id = x.HazardId, ProjectId = x.ProjectId, }).ToList(); return result; } /// /// 获取在施危大工程数(异步) /// /// public static async Task> GetMajorProjectsUnderConstructionAsync() { return await Task.Run(GetMajorProjectsUnderConstruction); } #endregion #region 工时数据 /// /// 获取总工时数 /// /// public static int GetTotalWorkingHour() { var thisUnitid = CommonService.GetThisUnitId(); var yearSumItems = (from x in Funs.DB.Information_MillionsMonthlyReportItem join y in Funs.DB.Information_MillionsMonthlyReport on x.MillionsMonthlyReportId equals y.MillionsMonthlyReportId where y.UnitId == thisUnitid && y.Year == DateTime.Now.Year && y.Month <= DateTime.Now.Month && x.Affiliation == "本月合计" select x).Distinct().ToList(); var result = Convert.ToInt32(yearSumItems.Sum(x => x.TotalWorkNum ?? 0)); return result; /*var result = (from x in Funs.DB.SitePerson_DayReportDetail join y in Funs.DB.SitePerson_DayReport on x.DayReportId equals y.DayReportId where BeUnderConstructionList.Contains(y.ProjectId) && y.CompileDate > Const.DtmarkTime select x.PersonWorkTime ?? 0).ToList().Sum(); var q = Funs.GetNewIntOrZero(result.ToString().Split('.')[0]); */ } /// /// 获取总工时数(异步) /// /// public static async Task GetTotalWorkingHourAsync() { return await Task.Run(GetTotalWorkingHour); } /// /// 获取损失工时数 /// /// public static int GetLostWorkingHour() { //var result = // (from x in Funs.DB.Accident_AccidentHandle // where BeUnderConstructionList.Contains(x.ProjectId) && x.CompileDate > Const.DtmarkTime // select x.WorkHoursLoss) // .ToList().Sum(x => x.Value) // + (from x in Funs.DB.Accident_AccidentReport // where BeUnderConstructionList.Contains(x.ProjectId) && x.CompileDate > Const.DtmarkTime // select x.WorkingHoursLoss) // .ToList().Sum(x => x.Value); //var q = Funs.GetNewIntOrZero(result.ToString().Split('.')[0]); var q = 0; return q; } /// /// 获取损失工时数(异步) /// /// public static async Task GetLostWorkingHourAsync() { return await Task.Run(GetLostWorkingHour); } /// /// 获取安全工时数 /// /// public static int GetSafeWorkingHour() { /*var result1 = (from x in Funs.DB.SitePerson_DayReportDetail join y in Funs.DB.SitePerson_DayReport on x.DayReportId equals y.DayReportId where BeUnderConstructionList.Contains(y.ProjectId) && y.CompileDate > Const.DtmarkTime select x.PersonWorkTime ?? 0).ToList().Sum(); var result2 = (from x in Funs.DB.Accident_AccidentHandle where BeUnderConstructionList.Contains(x.ProjectId) && x.CompileDate > Const.DtmarkTime select x.WorkHoursLoss) .ToList().Sum(x => x.Value) + (from x in Funs.DB.Accident_AccidentReport where BeUnderConstructionList.Contains(x.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;*/ var thisUnitid = CommonService.GetThisUnitId(); var yearSumItems = (from x in Funs.DB.Information_MillionsMonthlyReportItem join y in Funs.DB.Information_MillionsMonthlyReport on x.MillionsMonthlyReportId equals y.MillionsMonthlyReportId where y.UnitId == thisUnitid && y.Year == DateTime.Now.Year && y.Month <= DateTime.Now.Month && x.Affiliation == "本月合计" select x).Distinct().ToList(); var result = Convert.ToInt32(yearSumItems.Sum(x => x.TotalWorkNum ?? 0)); return result; } /// /// 获取安全工时数(异步) /// /// public static async Task GetSafeWorkingHourAsync() { return await Task.Run(GetSafeWorkingHour); } #endregion #region 安全教育培训 /// /// 获取三级安全教育培训数 /// /// public static List GetSafeTrain() { var result = (from x in Funs.DB.EduTrain_TrainRecord join p in Funs.DB.Base_Project on x.ProjectId equals p.ProjectId into pGroup from p in pGroup.DefaultIfEmpty() join y in Funs.DB.Base_TrainType on x.TrainTypeId equals y.TrainTypeId where BeUnderConstructionList.Contains(p.ProjectId) && y.TrainType == "1" && x.TrainStartDate > Const.DtmarkTime select new Model.EduTrainOutput() { ProjectId = x.ProjectId, ProjectName = p.ProjectName, UnitName = UnitService.getUnitNamesUnitIds(x.UnitIds), Id = x.TrainingId, TrainTitle = x.TrainTitle, TrainStartDate = x.TrainStartDate, TrainEndDate = x.TrainEndDate, TrainPersonNum = x.TrainPersonNum ?? 0, }).ToList(); return result; } /// /// 获取三级安全教育培训数(异步) /// /// public static async Task> GetSafeTrainAsync() { return await Task.Run(GetSafeTrain); } /// /// 获取专项培训数 /// /// public static List GetSpecialTrain() { var result = (from x in Funs.DB.EduTrain_TrainRecord join p in Funs.DB.Base_Project on x.ProjectId equals p.ProjectId into pGroup from p in pGroup.DefaultIfEmpty() join y in Funs.DB.Base_TrainType on x.TrainTypeId equals y.TrainTypeId where BeUnderConstructionList.Contains(p.ProjectId) && y.TrainType == "2" && x.TrainStartDate > Const.DtmarkTime select new Model.EduTrainOutput() { ProjectId = x.ProjectId, ProjectName = p.ProjectName, UnitName = UnitService.getUnitNamesUnitIds(x.UnitIds), Id = x.TrainingId, TrainTitle = x.TrainTitle, TrainStartDate = x.TrainStartDate, TrainEndDate = x.TrainEndDate, TrainPersonNum = x.TrainPersonNum ?? 0, }).ToList(); return result; } /// /// 获取专项培训数(异步) /// /// public static async Task> GetSpecialTrainAsync() { return await Task.Run(GetSpecialTrain); } /// /// 获取特种作业培训数 /// /// public static List GetSpecialOperationTrain() { var result = (from x in Funs.DB.EduTrain_TrainRecord join p in Funs.DB.Base_Project on x.ProjectId equals p.ProjectId into pGroup from p in pGroup.DefaultIfEmpty() join y in Funs.DB.Base_TrainType on x.TrainTypeId equals y.TrainTypeId where BeUnderConstructionList.Contains(p.ProjectId) && y.TrainType == "3" && x.TrainStartDate > Const.DtmarkTime select new Model.EduTrainOutput() { ProjectId = x.ProjectId, ProjectName = p.ProjectName, UnitName = UnitService.getUnitNamesUnitIds(x.UnitIds), Id = x.TrainingId, TrainTitle = x.TrainTitle, TrainStartDate = x.TrainStartDate, TrainEndDate = x.TrainEndDate, TrainPersonNum = x.TrainPersonNum ?? 0, }).ToList(); return result; } public static async Task> GetSpecialOperationTrainAsync() { return await Task.Run(GetSpecialOperationTrain); } /// /// 获取安全技术交底数 /// /// public static int GetHseTechnicalNum() { var list = (from x in Funs.DB.License_HSETechnical where BeUnderConstructionList.Contains(x.ProjectId) select x).Distinct().ToList(); var result = list.ToList().Count(); return result; } /// /// 获取安全技术交底数(异步) /// /// public static async Task GetHseTechnicalNumAsync() { return await Task.Run(GetHseTechnicalNum); } /// /// 获取安全技术交底 /// /// public static List GetHseTechnical() { var result = (from x in Funs.DB.License_HSETechnical join p in Funs.DB.Base_Project on x.ProjectId equals p.ProjectId into pGroup from p in pGroup.DefaultIfEmpty() where BeUnderConstructionList.Contains(x.ProjectId) select new Model.LicenseHSETechnicalOutput() { ProjectId = x.ProjectId, ProjectName = p.ProjectName, UnitName = UnitService.getUnitNamesUnitIds(x.UnitId), Id = x.HSETechnicalId, HSETechnicalCode = x.HSETechnicalCode, WorkContents = x.WorkContents }).ToList(); return result; } /// /// 获取安全技术交底(异步) /// /// public static async Task> GetHseTechnicalAsync() { return await Task.Run(GetHseTechnical); } #endregion #region 事故事件数据 /// /// 获取未遂事件数 /// /// public static List GetNearMiss() { var result = (from Record in Funs.DB.Accident_AccidentPersonRecord join AccidentType in Funs.DB.Base_AccidentType on Record.AccidentTypeId equals AccidentType.AccidentTypeId into AccidentTypeGroup from AccidentType in AccidentTypeGroup.DefaultIfEmpty() join Project in Funs.DB.Base_Project on Record.ProjectId equals Project.ProjectId into ProjectGroup from Project in ProjectGroup.DefaultIfEmpty() join Person in Funs.DB.SitePerson_Person on Record.PersonId equals Person.PersonId into PersonGroup from Person in PersonGroup.DefaultIfEmpty() join Unit in Funs.DB.Base_Unit on Person.UnitId equals Unit.UnitId into UnitGroup from Unit in UnitGroup.DefaultIfEmpty() where BeUnderConstructionList.Contains(Record.ProjectId) && Record.IsAttempt == "1" && Record.AccidentDate > Const.DtmarkTime select new AccidentOutput { Id = Record.AccidentPersonRecordId, ProjectId = Record.ProjectId, ProjectCode = Project.ProjectCode, ProjectName = Project.ProjectName, AccidentTypeName = AccidentType.AccidentTypeName, AccidentDate = Record.AccidentDate, UnitId = Unit.UnitId, UnitName = Unit.UnitName, PeopleNum = 1, Info = Record.Injury == "1" ? "死亡" : (Record.Injury == "2" ? "重伤" : "轻伤") }).ToList(); return result; } public static async Task> GetNearMissAsync() { return await Task.Run(GetNearMiss); } /// /// 获取可记录事件数 /// /// public static List GetRecordableEvent() { var result = (from Record in Funs.DB.Accident_AccidentPersonRecord join AccidentType in Funs.DB.Base_AccidentType on Record.AccidentTypeId equals AccidentType.AccidentTypeId into AccidentTypeGroup from AccidentType in AccidentTypeGroup.DefaultIfEmpty() join Project in Funs.DB.Base_Project on Record.ProjectId equals Project.ProjectId into ProjectGroup from Project in ProjectGroup.DefaultIfEmpty() join Person in Funs.DB.SitePerson_Person on Record.PersonId equals Person.PersonId into PersonGroup from Person in PersonGroup.DefaultIfEmpty() join Unit in Funs.DB.Base_Unit on Person.UnitId equals Unit.UnitId into UnitGroup from Unit in UnitGroup.DefaultIfEmpty() where BeUnderConstructionList.Contains(Record.ProjectId) && Record.AccidentDate > Const.DtmarkTime select new AccidentOutput { Id = Record.AccidentPersonRecordId, ProjectId = Record.ProjectId, ProjectCode = Project.ProjectCode, ProjectName = Project.ProjectName, AccidentTypeName = AccidentType.AccidentTypeName, AccidentDate = Record.AccidentDate, UnitId = Unit.UnitId, UnitName = Unit.UnitName, PeopleNum = 1, Info = Record.Injury == "1" ? "死亡" : (Record.Injury == "2" ? "重伤" : "轻伤") }).ToList(); return result; } public static async Task> GetRecordableEventAsync() { return await Task.Run(GetRecordableEvent); } /// /// 获取一般事故数 /// /// public static List GetGeneralAccident() { var query = from Record in Funs.DB.Accident_AccidentReport join AccidentType in Funs.DB.Sys_Const on new { ConstValue = Record.AccidentTypeId, GroupId = "AccidentReportRegistration" } equals new { ConstValue = AccidentType.ConstValue, GroupId = AccidentType.GroupId } into AccidentTypeGroup from AccidentType in AccidentTypeGroup.DefaultIfEmpty() join Project in Funs.DB.Base_Project on Record.ProjectId equals Project.ProjectId into ProjectGroup from Project in ProjectGroup.DefaultIfEmpty() join Unit in Funs.DB.Base_Unit on Record.UnitId equals Unit.UnitId into UnitGroup from Unit in UnitGroup.DefaultIfEmpty() where Record.AccidentDate > Const.DtmarkTime && BeUnderConstructionList.Contains(Record.ProjectId) && Record.AccidentDegree == "1" select new AccidentOutput { Id = Record.AccidentReportId, ProjectId = Record.ProjectId, ProjectCode = Project.ProjectCode, ProjectName = Project.ProjectName, AccidentTypeName = AccidentType.ConstText, AccidentDate = Record.AccidentDate, UnitId = Unit.UnitId, UnitName = Unit.UnitName, PeopleNum = Record.PeopleNum, Info = Record.Abstract }; var result = query.ToList(); return result; } public static async Task> GetGeneralAccidentAsync() { return await Task.Run(GetGeneralAccident); } /// /// 获取较大事故数 /// /// public static List GetMajorAccident() { var query = from Record in Funs.DB.Accident_AccidentReport join AccidentType in Funs.DB.Sys_Const on new { ConstValue = Record.AccidentTypeId, GroupId = "AccidentReportRegistration" } equals new { ConstValue = AccidentType.ConstValue, GroupId = AccidentType.GroupId } into AccidentTypeGroup from AccidentType in AccidentTypeGroup.DefaultIfEmpty() join Project in Funs.DB.Base_Project on Record.ProjectId equals Project.ProjectId into ProjectGroup from Project in ProjectGroup.DefaultIfEmpty() join Unit in Funs.DB.Base_Unit on Record.UnitId equals Unit.UnitId into UnitGroup from Unit in UnitGroup.DefaultIfEmpty() where Record.AccidentDate > Const.DtmarkTime && BeUnderConstructionList.Contains(Record.ProjectId) && Record.AccidentDegree == "2" select new AccidentOutput { Id = Record.AccidentReportId, ProjectId = Record.ProjectId, ProjectCode = Project.ProjectCode, ProjectName = Project.ProjectName, AccidentTypeName = AccidentType.ConstText, AccidentDate = Record.AccidentDate, UnitId = Unit.UnitId, UnitName = Unit.UnitName, PeopleNum = Record.PeopleNum, Info = Record.Abstract }; var result = query.ToList(); return result; } public static async Task> GetMajorAccidentAsync() { return await Task.Run(GetMajorAccident); } /// /// 获取重大事故数 /// /// public static List GetSeriousAccident() { var query = from Record in Funs.DB.Accident_AccidentReport join AccidentType in Funs.DB.Sys_Const on new { ConstValue = Record.AccidentTypeId, GroupId = "AccidentReportRegistration" } equals new { ConstValue = AccidentType.ConstValue, GroupId = AccidentType.GroupId } into AccidentTypeGroup from AccidentType in AccidentTypeGroup.DefaultIfEmpty() join Project in Funs.DB.Base_Project on Record.ProjectId equals Project.ProjectId into ProjectGroup from Project in ProjectGroup.DefaultIfEmpty() join Unit in Funs.DB.Base_Unit on Record.UnitId equals Unit.UnitId into UnitGroup from Unit in UnitGroup.DefaultIfEmpty() where Record.AccidentDate > Const.DtmarkTime && BeUnderConstructionList.Contains(Record.ProjectId) && Record.AccidentDegree == "3" select new AccidentOutput { Id = Record.AccidentReportId, ProjectId = Record.ProjectId, ProjectCode = Project.ProjectCode, ProjectName = Project.ProjectName, AccidentTypeName = AccidentType.ConstText, AccidentDate = Record.AccidentDate, UnitId = Unit.UnitId, UnitName = Unit.UnitName, PeopleNum = Record.PeopleNum, Info = Record.Abstract }; var result = query.ToList(); return result; } public static async Task> GetSeriousAccidentAsync() { return await Task.Run(GetSeriousAccident); } /// /// 获取特别重大事故数 /// /// public static List GetSpecialSeriousAccident() { var query = from Record in Funs.DB.Accident_AccidentReport join AccidentType in Funs.DB.Sys_Const on new { ConstValue = Record.AccidentTypeId, GroupId = "AccidentReportRegistration" } equals new { ConstValue = AccidentType.ConstValue, GroupId = AccidentType.GroupId } into AccidentTypeGroup from AccidentType in AccidentTypeGroup.DefaultIfEmpty() join Project in Funs.DB.Base_Project on Record.ProjectId equals Project.ProjectId into ProjectGroup from Project in ProjectGroup.DefaultIfEmpty() join Unit in Funs.DB.Base_Unit on Record.UnitId equals Unit.UnitId into UnitGroup from Unit in UnitGroup.DefaultIfEmpty() where Record.AccidentDate > Const.DtmarkTime && BeUnderConstructionList.Contains(Record.ProjectId) && Record.AccidentDegree == "4" select new AccidentOutput { Id = Record.AccidentReportId, ProjectId = Record.ProjectId, ProjectCode = Project.ProjectCode, ProjectName = Project.ProjectName, AccidentTypeName = AccidentType.ConstText, AccidentDate = Record.AccidentDate, UnitId = Unit.UnitId, UnitName = Unit.UnitName, PeopleNum = Record.PeopleNum, Info = Record.Abstract }; var result = query.ToList(); return result; } public static async Task> GetSpecialSeriousAccidentAsync() { return await Task.Run(GetSpecialSeriousAccident); } #endregion #region 安全费用 /// /// 获取费用提取(万元) /// /// public static List GetCostExtract() { var query = from cost in Funs.DB.CostGoods_CostSmallDetail join p in Funs.DB.Base_Project on cost.ProjectId equals p.ProjectId into pGroup from p in pGroup.DefaultIfEmpty() join unit in Funs.DB.Base_Unit on cost.UnitId equals unit.UnitId into unitGroup from unit in unitGroup.DefaultIfEmpty() where BeUnderConstructionList.Contains(p.ProjectId) select new CostSmallDetailOutput { Id = cost.CostSmallDetailId, ProjectId = p.ProjectId, ProjectCode = p.ProjectCode, ProjectName = p.ProjectName, UnitId = cost.UnitId, UnitName = unit.UnitName, Months = cost.Months, SUMCost = cost.Extract ?? 0//Math.Round(sumCost, 2) }; return query.ToList(); } public static async Task> GetCostExtractAsync() { return await Task.Run(GetCostExtract); } /// /// 获取费用使用(万元) /// /// public static List GetCostUse() { var query = from cost in Funs.DB.CostGoods_CostSmallDetail join p in Funs.DB.Base_Project on cost.ProjectId equals p.ProjectId into pGroup from p in pGroup.DefaultIfEmpty() join unit in Funs.DB.Base_Unit on cost.UnitId equals unit.UnitId into unitGroup from unit in unitGroup.DefaultIfEmpty() let sumCost = (from item in Funs.DB.CostGoods_CostSmallDetailItem where item.CostSmallDetailId == cost.CostSmallDetailId select item.CostMoney ?? 0).Sum() * 1.0m // 10000 where BeUnderConstructionList.Contains(p.ProjectId) select new CostSmallDetailOutput { Id = cost.CostSmallDetailId, ProjectId = p.ProjectId, ProjectCode = p.ProjectCode, ProjectName = p.ProjectName, UnitId = cost.UnitId, UnitName = unit.UnitName, Months = cost.Months, SUMCost = sumCost//Math.Round(sumCost, 2) }; /*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 BeUnderConstructionList.Contains(y.ProjectId) && y.CompileDate > Const.DtmarkTime select x.CostMoney ?? 0).ToList().Sum(); result = Funs.GetNewIntOrZero(costs.ToString().Split('.')[0]);*/ return query.ToList(); } public static async Task> GetCostUseAsync() { return await Task.Run(GetCostUse); } #endregion #region 施工机具 /// /// 获取施工机具在用数 /// /// public static List GetUseEquipment() { var query = (from item in Funs.DB.InApproveManager_EquipmentInItem join eq in Funs.DB.InApproveManager_EquipmentIn on item.EquipmentInId equals eq.EquipmentInId into eqGroup from eq in eqGroup.DefaultIfEmpty() join spe in Funs.DB.Base_SpecialEquipment on item.SpecialEquipmentId equals spe.SpecialEquipmentId into speGroup from spe in speGroup.DefaultIfEmpty() join p in Funs.DB.Base_Project on eq.ProjectId equals p.ProjectId into pGroup from p in pGroup.DefaultIfEmpty() join unit in Funs.DB.Base_Unit on eq.UnitId equals unit.UnitId into unitGroup from unit in unitGroup.DefaultIfEmpty() where BeUnderConstructionList.Contains(eq.ProjectId) select new ConstructionEquipmentOutput { Id = item.EquipmentInItemId, ProjectId = eq.ProjectId, //ProjectCode = p.ProjectCode, ProjectName = p.ProjectName, //UnitId = eq.UnitId, UnitName = unit.UnitName, //SpecialEquipmentId = item.SpecialEquipmentId, SpecialEquipmentName = spe.SpecialEquipmentName, SizeModel = item.SizeModel, OwnerCheck = item.OwnerCheck, CertificateNum = item.CertificateNum, IsUsed = item.IsUsed, CompileDate = eq.CompileDate, EQType = "特种设备" }) .Union( from item in Funs.DB.InApproveManager_GeneralEquipmentInItem join eq in Funs.DB.InApproveManager_GeneralEquipmentIn on item.GeneralEquipmentInId equals eq.GeneralEquipmentInId into eqGroup from eq in eqGroup.DefaultIfEmpty() join spe in Funs.DB.Base_SpecialEquipment on item.SpecialEquipmentId equals spe.SpecialEquipmentId into speGroup from spe in speGroup.DefaultIfEmpty() join p in Funs.DB.Base_Project on eq.ProjectId equals p.ProjectId into pGroup from p in pGroup.DefaultIfEmpty() join unit in Funs.DB.Base_Unit on eq.UnitId equals unit.UnitId into unitGroup from unit in unitGroup.DefaultIfEmpty() where BeUnderConstructionList.Contains(eq.ProjectId) select new ConstructionEquipmentOutput { Id = item.GeneralEquipmentInItemId, ProjectId = eq.ProjectId, // ProjectCode = p.ProjectCode, ProjectName = p.ProjectName, // UnitId = eq.UnitId, UnitName = unit.UnitName, // SpecialEquipmentId = item.SpecialEquipmentId, SpecialEquipmentName = spe.SpecialEquipmentName, SizeModel = item.SizeModel, OwnerCheck = item.OwnerCheck, CertificateNum = item.CertificateNum, IsUsed = item.IsUsed, CompileDate = eq.CompileDate, EQType = "一般设备" } ); return query.ToList(); } public static async Task> GetUseEquipmentAsync() { return await Task.Run(GetUseEquipment); } /// /// 获取施工机具特种设备数 /// /// public static List GetSpecialEquipment() { var query = (from item in Funs.DB.InApproveManager_EquipmentInItem join eq in Funs.DB.InApproveManager_EquipmentIn on item.EquipmentInId equals eq.EquipmentInId into eqGroup from eq in eqGroup.DefaultIfEmpty() join spe in Funs.DB.Base_SpecialEquipment on item.SpecialEquipmentId equals spe.SpecialEquipmentId into speGroup from spe in speGroup.DefaultIfEmpty() join p in Funs.DB.Base_Project on eq.ProjectId equals p.ProjectId into pGroup from p in pGroup.DefaultIfEmpty() join unit in Funs.DB.Base_Unit on eq.UnitId equals unit.UnitId into unitGroup from unit in unitGroup.DefaultIfEmpty() where BeUnderConstructionList.Contains(eq.ProjectId) select new ConstructionEquipmentOutput { Id = item.EquipmentInItemId, ProjectId = eq.ProjectId, //ProjectCode = p.ProjectCode, ProjectName = p.ProjectName, //UnitId = eq.UnitId, UnitName = unit.UnitName, //SpecialEquipmentId = item.SpecialEquipmentId, SpecialEquipmentName = spe.SpecialEquipmentName, SizeModel = item.SizeModel, OwnerCheck = item.OwnerCheck, CertificateNum = item.CertificateNum, IsUsed = item.IsUsed, CompileDate = eq.CompileDate, EQType = "特种设备" }); return query.ToList(); } public static async Task> GetSpecialEquipmentAsync() { return await Task.Run(GetSpecialEquipment); } #endregion #region 高风险作业许可 /// /// 获取作业许可项数 /// /// public static List GetLicenses() { var WorkAreaIds = Funs.DB.View_License_LicenseManager .Where(x => BeUnderConstructionList.Contains(x.ProjectId) && x.CompileDate > Const.DtmarkTime) .Select(x => x.WorkAreaId).Distinct().ToList(); Dictionary WorkAreaNames = new Dictionary(); foreach (var item in WorkAreaIds) { WorkAreaNames.Add(item ?? "null", UnitWorkService.GetUnitWorkName(item)); } var result = (from x in Funs.DB.View_License_LicenseManager join y in Funs.DB.Base_Unit on x.UnitId equals y.UnitId into yGroup from y in yGroup.DefaultIfEmpty() join p in Funs.DB.Base_Project on x.ProjectId equals p.ProjectId into pGroup from p in pGroup.DefaultIfEmpty() where BeUnderConstructionList.Contains(x.ProjectId) && x.CompileDate > Const.DtmarkTime select new Model.LicenseOutput { Id = x.LicenseManagerId, ProjectId = x.ProjectId, ProjectName = p.ProjectName, UnitId = x.UnitId, UnitName = y.UnitName, LicenseTypeName = x.LicenseTypeName, UnitTypeName = x.UnitTypeName, IsHighRisk = x.IsHighRisk, WorkAreaName = WorkAreaNames[x.WorkAreaId ?? "null"], CompileDate = x.CompileDate, StartDate = x.StartDate, EndDate = x.EndDate, WorkStatesStr = x.WorkStatesStr }).ToList(); return result; } public static async Task> GetLicensesAsync() { return await Task.Run(GetLicenses); } /// /// 获取作业许可关闭项数 /// /// public static List GetLicensesClose() { var WorkAreaIds = Funs.DB.View_License_LicenseManager .Where(x => BeUnderConstructionList.Contains(x.ProjectId) && x.CompileDate > Const.DtmarkTime) .Select(x => x.WorkAreaId).Distinct().ToList(); Dictionary WorkAreaNames = new Dictionary(); foreach (var item in WorkAreaIds) { WorkAreaNames.Add(item ?? "null", UnitWorkService.GetUnitWorkName(item)); } var result = (from x in Funs.DB.View_License_LicenseManager join y in Funs.DB.Base_Unit on x.UnitId equals y.UnitId into yGroup from y in yGroup.DefaultIfEmpty() join p in Funs.DB.Base_Project on x.ProjectId equals p.ProjectId into pGroup from p in pGroup.DefaultIfEmpty() where BeUnderConstructionList.Contains(x.ProjectId) & x.CompileDate > Const.DtmarkTime && x.WorkStates == "3" select new Model.LicenseOutput { Id = x.LicenseManagerId, ProjectId = x.ProjectId, ProjectName = p.ProjectName, UnitId = x.UnitId, UnitName = y.UnitName, LicenseTypeName = x.LicenseTypeName, UnitTypeName = x.UnitTypeName, IsHighRisk = x.IsHighRisk, WorkAreaName = WorkAreaNames[x.WorkAreaId ?? "null"], CompileDate = x.CompileDate, StartDate = x.StartDate, EndDate = x.EndDate, WorkStatesStr = x.WorkStatesStr }).ToList(); return result; } public static async Task> GetLicensesCloseAsync() { return await Task.Run(GetLicensesClose); } #endregion #region 隐患整改 /// /// 获取一般隐患数据 /// /// public static List GetGeneralHiddenRectificationOutputs() { var query = (from x in Funs.DB.Base_Project join y in Funs.DB.HSSE_Hazard_HazardRegister on x.ProjectId equals y.ProjectId into yGroup from y in yGroup.DefaultIfEmpty() where BeUnderConstructionList.Contains(x.ProjectId) && y.ProblemTypes == "1" && y.Risk_Level == "一般" && y.CheckTime > Const.DtmarkTime group y by new { x.ProjectId, x.ProjectName, x.ProjectCode } into gg select new HiddenRectificationOutput { ProjectId = gg.Key.ProjectId, ProjectName = gg.Key.ProjectName, ProjectCode = gg.Key.ProjectCode, ProNum = gg.Count(y => y.States != "4" && y.States != "-1"), RecNum = gg.Count(y => y.States == "3"), NoRecNum = gg.Count(y => y.States != "3" && y.States != "-1"), RecRate = gg.Count(y => y.States != "4" && y.States != "-1") == 0 ? "0" : Math.Round(Convert.ToDecimal(gg.Count(y => y.States == "3") / gg.Count(y => y.States != "4" && y.States != "-1") * 100), 2, MidpointRounding.AwayFromZero).ToString() }).ToList(); foreach (var item in query) { item.RecRate = Math.Round(Convert.ToDecimal(item.RecRate), 2).ToString(); // 转换为字符串并格式化为两位小数 } return query; } public static async Task> GetGeneralHiddenRectificationOutputsAsync() { return await Task.Run(GetGeneralHiddenRectificationOutputs); } /// /// 获取较大隐患数据 /// /// public static List GetLargerHiddenRectificationOutputs() { var query = (from x in Funs.DB.Base_Project join y in Funs.DB.HSSE_Hazard_HazardRegister on x.ProjectId equals y.ProjectId into yGroup from y in yGroup.DefaultIfEmpty() where BeUnderConstructionList.Contains(x.ProjectId) && y.ProblemTypes == "2" && y.Risk_Level == "较大" && y.CheckTime > Const.DtmarkTime group y by new { x.ProjectId, x.ProjectName, x.ProjectCode } into gg select new HiddenRectificationOutput { ProjectId = gg.Key.ProjectId, ProjectName = gg.Key.ProjectName, ProjectCode = gg.Key.ProjectCode, ProNum = gg.Count(y => y.States != "4" && y.States != "-1"), RecNum = gg.Count(y => y.States == "3"), NoRecNum = gg.Count(y => y.States != "3" && y.States != "-1"), RecRate = gg.Count(y => y.States != "4" && y.States != "-1") == 0 ? "0" : Math.Round(Convert.ToDecimal(gg.Count(y => y.States == "3") / gg.Count(y => y.States != "4" && y.States != "-1") * 100), 2, MidpointRounding.AwayFromZero).ToString() }).ToList(); foreach (var item in query) { item.RecRate = Math.Round(Convert.ToDecimal(item.RecRate), 2).ToString(); // 转换为字符串并格式化为两位小数 } return query; } public static async Task> GetLargerHiddenRectificationOutputsAsync() { return await Task.Run(GetLargerHiddenRectificationOutputs); } /// /// 获取重大隐患数据 /// /// public static List GetMajorHiddenRectificationOutputs() { var query = (from x in Funs.DB.Base_Project join y in Funs.DB.HSSE_Hazard_HazardRegister on x.ProjectId equals y.ProjectId into yGroup from y in yGroup.DefaultIfEmpty() where BeUnderConstructionList.Contains(x.ProjectId) && y.ProblemTypes == "1" && y.Risk_Level == "重大" && y.CheckTime > Const.DtmarkTime group y by new { x.ProjectId, x.ProjectName, x.ProjectCode } into gg select new HiddenRectificationOutput { ProjectId = gg.Key.ProjectId, ProjectName = gg.Key.ProjectName, ProjectCode = gg.Key.ProjectCode, ProNum = gg.Count(y => y.States != "4" && y.States != "-1"), RecNum = gg.Count(y => y.States == "3"), NoRecNum = gg.Count(y => y.States != "3" && y.States != "-1"), RecRate = gg.Count(y => y.States != "4" && y.States != "-1") == 0 ? "0" : Math.Round((decimal)gg.Count(y => y.States == "3") / gg.Count(y => y.States != "4" && y.States != "-1") * 100, 2, MidpointRounding.AwayFromZero).ToString() }).ToList(); foreach (var item in query) { item.RecRate = Math.Round(Convert.ToDecimal(item.RecRate), 2).ToString(); // 转换为字符串并格式化为两位小数 } return query; } public static async Task> GetMajorHiddenRectificationOutputsAsync() { return await Task.Run(GetMajorHiddenRectificationOutputs); } #endregion #region 风险数据 /// /// 获取风险数据 /// /// public static List GetSecurityRiskOutputs() { var query = (from x in Funs.DB.Base_Project join y in Funs.DB.Hazard_HazardSelectedItem on x.ProjectId equals y.ProjectId into yGroup from y in yGroup.DefaultIfEmpty() join z in Funs.DB.Base_RiskLevel on y.HazardLevel equals z.RiskLevelId into zGroup from z in zGroup.DefaultIfEmpty() where BeUnderConstructionList.Contains(x.ProjectId) && (y.IsStart == true || y.State == "1") group new { y, z } by new { x.ProjectId, x.ProjectName, x.ProjectCode } into gg select new SecurityRiskOutput { ProjectId = gg.Key.ProjectId, ProjectName = gg.Key.ProjectName, ProjectCode = gg.Key.ProjectCode, LowRiskNum = gg.Sum(g => (g.z.RiskLevel == 1 || g.y.HazardLevel == "1") ? 1 : 0), GeneralRiskNum = gg.Sum(g => (g.z.RiskLevel == 2 || g.y.HazardLevel == "2") ? 1 : 0), MediumRiskNum = gg.Sum(g => (g.z.RiskLevel == 3 || g.y.HazardLevel == "3") ? 1 : 0), HighRiskNum = gg.Sum(g => g.z.RiskLevel == 4 ? 1 : 0), }).ToList(); return query; } public static async Task> GetSecurityRiskOutputsAsync() { return await Task.Run(GetSecurityRiskOutputs); } #endregion #region 危大工程数据 /// /// 获取危大工程数据 /// /// public static List GetLargeEngineeringOutputs() { var query = (from x in Funs.DB.Base_Project join y in Funs.DB.Solution_LargerHazard on x.ProjectId equals y.ProjectId into yGroup from y in yGroup.DefaultIfEmpty() where BeUnderConstructionList.Contains(x.ProjectId) && y.RecordTime > Const.DtmarkTime group y by new { x.ProjectId, x.ProjectName, x.ProjectCode } into gg select new LargeEngineeringOutput { ProjectId = gg.Key.ProjectId, ProjectName = gg.Key.ProjectName, ProjectCode = gg.Key.ProjectCode, CompletedNum = gg.Count(x => x.States == "1" && x.IsSuperLargerHazard == false), TrainPersonNum = gg.Where(x => x.IsSuperLargerHazard == false).Sum(x => x.TrainPersonNum) ?? 0, ConstructionNum = gg.Count(x => x.States == "2" && x.IsSuperLargerHazard == false), FinishedNum = gg.Count(x => x.States == "3" && x.IsSuperLargerHazard == false), ArgumentNum = gg.Count(x => x.IsArgument == true && x.IsSuperLargerHazard == false), SuperCompletedNum = gg.Count(x => x.States == "1" && x.IsSuperLargerHazard == true), SuperTrainPersonNum = gg.Where(x => x.IsSuperLargerHazard == true).Sum(x => x.TrainPersonNum) ?? 0, SuperConstructionNum = gg.Count(x => x.States == "2" && x.IsSuperLargerHazard == true), SuperFinishedNum = gg.Count(x => x.States == "3" && x.IsSuperLargerHazard == true), SuperArgumentNum = gg.Count(x => x.IsArgument == true && x.IsSuperLargerHazard == true), OperativesNum = gg.Where(x => x.IsSuperLargerHazard == false).Sum(x => x.OperativesNum) ?? 0, SuperOperativesNum = gg.Where(x => x.IsSuperLargerHazard == true).Sum(x => x.OperativesNum) ?? 0, }).ToList(); return query; } /// /// 获取危大工程数据(异步) /// /// public static async Task> GetLargeEngineeringOutputsAsync() { return await Task.Run(GetLargeEngineeringOutputs); } /// /// 获取危大工程审批完成数 /// /// public static int GetCompletedNum() { var result = (from x in Funs.DB.Solution_LargerHazard where BeUnderConstructionList.Contains(x.ProjectId) && x.States == "1" && x.IsSuperLargerHazard == false && x.RecordTime > Const.DtmarkTime select x).Count(); return result; } /// /// 获取危大工程培训人次数 /// /// public static int GetTrainPersonNum() { var result = (from x in Funs.DB.Solution_LargerHazard where BeUnderConstructionList.Contains(x.ProjectId) && x.IsSuperLargerHazard == false && x.RecordTime > Const.DtmarkTime select x.TrainPersonNum).ToList().Sum(x => x.Value); return result; } /// /// 获取危大工程施工个数 /// /// public static int GetConstructionNum() { var result = (from x in Funs.DB.Solution_LargerHazard where BeUnderConstructionList.Contains(x.ProjectId) && x.States == "2" && x.IsSuperLargerHazard == false && x.RecordTime > Const.DtmarkTime select x).Count(); return result; } /// /// 获取危大工程完工个数 /// /// public static int GetFinishedNum() { var result = (from x in Funs.DB.Solution_LargerHazard where BeUnderConstructionList.Contains(x.ProjectId) && x.States == "3" && x.IsSuperLargerHazard == false && x.RecordTime > Const.DtmarkTime select x).Count(); return result; } /// /// 获取超危大工程审批完成数 /// /// public static int GetSuperCompletedNum() { var result = (from x in Funs.DB.Solution_LargerHazard where BeUnderConstructionList.Contains(x.ProjectId) && x.States == "1" && x.IsSuperLargerHazard == true && x.RecordTime > Const.DtmarkTime select x).Count(); return result; } /// /// 获取超危大工程培训人次数 /// /// public static int GetSuperTrainPersonNum() { var result = (from x in Funs.DB.Solution_LargerHazard where BeUnderConstructionList.Contains(x.ProjectId) && x.IsSuperLargerHazard == true && x.RecordTime > Const.DtmarkTime select x.TrainPersonNum).ToList().Sum(x => x.Value); return result; } /// /// 获取超危大工程施工个数 /// /// public static int GetSuperConstructionNum() { var result = (from x in Funs.DB.Solution_LargerHazard where BeUnderConstructionList.Contains(x.ProjectId) && x.States == "2" && x.IsSuperLargerHazard == true && x.RecordTime > Const.DtmarkTime select x).Count(); return result; } /// /// 获取超危大工程完工个数 /// /// public static int GetSuperFinishedNum() { var result = (from x in Funs.DB.Solution_LargerHazard where BeUnderConstructionList.Contains(x.ProjectId) && x.States == "3" && x.IsSuperLargerHazard == true && x.RecordTime > Const.DtmarkTime select x).Count(); return result; } #endregion #region 获取列表 /// /// 记录数 /// public static int Count { get; set; } public static List GetHSSEData_HSSEByModle(HSSEData_HSSE table) { var db = Funs.DB; var q = from x in db.HSSEData_HSSE where (string.IsNullOrEmpty(table.Id) || x.Id.Contains(table.Id)) && (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)) orderby x.ReportDate descending select x ; return q.ToList(); } // ReSharper disable once InvalidXmlDocComment /// /// public static IEnumerable GetListData(HSSEData_HSSE table, Grid Grid1) { var q = GetHSSEData_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.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.HseTechnicalNum, x.EnvironmentalTrainNum, 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.QualityPersonNum, 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.BranchComprehensivePlanNum, x.BranchSpecialPlanNum, x.BranchOnSiteDisposalPlan, x.CompanyDrillNum, x.CompanyDrillPersonNum, x.BranchDrillNum, x.BranchDrillPersonNum, x.ProjectComprehensivePlanNum, x.ProjectSpecialPlanNum, x.ProjectOnSiteDisposalPlan, x.ProjectDrillNum, x.ProjectDrillPersonNum, 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.OperativesNum, x.ConstructionNum, x.FinishedNum, x.ArgumentNum, x.SuperCompletedNum, x.SuperTrainPersonNum, x.SuperOperativesNum, x.SuperConstructionNum, x.SuperFinishedNum, x.SuperArgumentNum, x.State, x.CreateDate, x.CreateMan }; } #endregion 获取列表 #region 推送企业级检查明细数据检查 /// /// 推送企业级检查明细数据检查 /// /// public static ReturnData PushSuperviseCheckReportData(int pushNum) { var thisUnit = CommonService.GetIsThisUnit(); Model.SUBQHSEDB db = Funs.DB; var items = (from x in db.Supervise_SuperviseCheckReport join P in db.Base_Project on x.ProjectId equals P.ProjectId into PJ from P in PJ.DefaultIfEmpty() join U in db.Base_Unit on x.UnitId equals U.UnitId into UJ from U in UJ.DefaultIfEmpty() join CU in db.Base_Unit on x.CheckUnitId equals CU.UnitId into CUJ from CU in CUJ.DefaultIfEmpty() where (x.IsUpdate == null || x.IsUpdate == false) && x.CheckDate > BLL.Const.DtmarkTime select new Model.SuperviseCheckReportItem { Id = x.SuperviseCheckReportId, SourceUnitId = thisUnit.UnitId, ProjectId = x.ProjectId, CollCropCode = thisUnit.CollCropCode, DataDate = x.CheckDate, AttachFile = AttachFileService.getFileUrl(x.SuperviseCheckReportId.ToString()), SuperviseCheckReportCode = x.SuperviseCheckReportCode, CheckDate = x.CheckDate, UnitId = x.UnitId, UnitName = U.UnitName, CheckTeam = x.CheckTeam, CheckType = x.CheckType, CheckTypeName = x.CheckType == "1" ? "企业负责人带班检查" : x.CheckType == "2" ? "企业综合检查" : x.CheckType == "3" ? "企业专项检查" : "", CheckMainType = x.CheckMainType, CheckMainTypeName = x.CheckMainType == "0" ? "安全" : x.CheckMainType == "1" ? "质量" : "", CheckUnitId = x.CheckUnitId, CheckUnitName = CU.UnitName, }).Take(pushNum).ToList(); Model.ReturnData responeData = new Model.ReturnData(); if (items.Count() > 0) { foreach (var superviseCheckReportItem in items) { List detailItems = getDetail(superviseCheckReportItem.Id, thisUnit); superviseCheckReportItem.SuperviseCheckReportDetail = detailItems; } var newItem = new { CollCropCode = thisUnit.CollCropCode, Items = items }; var str = JsonConvert.SerializeObject(newItem); var baseurl = "/api/HSSEData/SaveSuperviseCheckReportData"; responeData = ServerService.PushCNCEC(str, baseurl); if (responeData.code == 1) { foreach (var item in items) { var data = db.Supervise_SuperviseCheckReport.FirstOrDefault(x => x.SuperviseCheckReportId == item.Id && (x.IsUpdate == null || x.IsUpdate == false)); data.IsUpdate = true; db.SubmitChanges(); } } } else { responeData.code = 0; responeData.message = "当前没有企业级检查明细数据检查数据"; } return responeData; } #region 转换字符串 /// /// 获取明细 /// /// /// public static List getDetail(string SuperviseCheckReportId, Model.Base_Unit thisUnit) { List detailItems = null; if (!string.IsNullOrEmpty(SuperviseCheckReportId)) { detailItems = (from x in Funs.DB.View_Supervise_SuperviseCheckReportItem where x.SuperviseCheckReportId == SuperviseCheckReportId select new Model.SuperviseCheckReportDetailItem { Id = x.SuperviseCheckReportItemId, SourceUnitId = thisUnit.UnitId, // ProjectId = x.ProjectId, CollCropCode = thisUnit.CollCropCode, // DataDate = x.CheckDate, AttachFile = AttachFileService.getFileUrl(x.SuperviseCheckReportItemId.ToString()), SuperviseCheckReportId = x.SuperviseCheckReportId, RectifyItemId = x.RectifyItemId, IsSelected = x.IsSelected, HazardSourcePoint = x.HazardSourcePoint, RiskAnalysis = x.RiskAnalysis, RiskPrevention = x.RiskPrevention, SimilarRisk = x.SimilarRisk, RectifyName = x.RectifyName, RectifyCode = x.RectifyCode, }).ToList(); } return detailItems; } #endregion #endregion #region 删除企业级检查明细数据检查 /// /// 删除企业级检查明细数据检查 /// /// public static ReturnData DeleteSuperviseCheckReportData(string Id) { Model.ReturnData responeData = new Model.ReturnData(); try { var thisUnit = CommonService.GetIsThisUnit(); Model.SUBQHSEDB db = Funs.DB; var items = (from x in db.Supervise_SuperviseCheckReport join P in db.Base_Project on x.ProjectId equals P.ProjectId into PJ from P in PJ.DefaultIfEmpty() join U in db.Base_Unit on x.UnitId equals U.UnitId into UJ from U in UJ.DefaultIfEmpty() join CU in db.Base_Unit on x.CheckUnitId equals CU.UnitId into CUJ from CU in CUJ.DefaultIfEmpty() where x.SuperviseCheckReportId == Id select new Model.SuperviseCheckReportItem { Id = x.SuperviseCheckReportId, SourceUnitId = thisUnit.UnitId, ProjectId = x.ProjectId, CollCropCode = thisUnit.CollCropCode, DataDate = x.CheckDate, AttachFile = AttachFileService.getFileUrl(x.SuperviseCheckReportId.ToString()), SuperviseCheckReportCode = x.SuperviseCheckReportCode, CheckDate = x.CheckDate, UnitId = x.UnitId, UnitName = U.UnitName, CheckTeam = x.CheckTeam, CheckType = x.CheckType, CheckTypeName = x.CheckType == "1" ? "企业负责人带班检查" : x.CheckType == "2" ? "企业综合检查" : x.CheckType == "3" ? "企业专项检查" : "", CheckMainType = x.CheckMainType, CheckMainTypeName = x.CheckMainType == "0" ? "安全" : x.CheckMainType == "1" ? "质量" : "", CheckUnitId = x.CheckUnitId, CheckUnitName = CU.UnitName, }).ToList(); if (items.Count() > 0) { var newItem = new { CollCropCode = thisUnit.CollCropCode, Items = items }; var str = JsonConvert.SerializeObject(newItem); var baseurl = "/api/HSSEData/DeleteSuperviseCheckReportData"; responeData = ServerService.PushCNCEC(str, baseurl); } else { responeData.code = 0; responeData.message = "集团数据删除失败"; } } catch (Exception) { responeData.code = 0; responeData.message = "集团数据删除失败"; } return responeData; } #endregion } }