CREATE View [dbo].[View_DataStatistics] AS /*数据汇总*/ select ShortName, (select COUNT(*) from SitePerson_Person Person where InTime <=GETDATE() AND (OutTime IS NULL OR OutTime > GETDATE()) AND Person.ProjectId=p.ProjectId and Person.WorkPostId='8A7C2CDF-AFB5-4826-9951-343253342DAC') as CommissionerPersonNum, (select COUNT(*) from SitePerson_Person Person LEFT JOIN Base_WorkPost AS WorkPost ON Person.WorkPostId =WorkPost.WorkPostId where InTime <=GETDATE() AND (OutTime IS NULL OR OutTime > GETDATE()) AND Person.ProjectId=p.ProjectId and WorkPost.IsHsse=1) as FullTimePersonNum, (select COUNT(*) from SitePerson_Person Person where InTime <=GETDATE() AND (OutTime IS NULL OR OutTime > GETDATE()) AND Person.ProjectId=p.ProjectId and Person.IsSafetyMonitoring=1) as SafetySupervisionPersonNum, (select COUNT(*) from SitePerson_Person Person where InTime <=GETDATE() AND (OutTime IS NULL OR OutTime > GETDATE()) AND Person.ProjectId=p.ProjectId and (SELECT COUNT(*) FROM QualityAudit_PersonQuality AS Q LEFT JOIN Base_Certificate AS Cer ON Q.CertificateId =Cer.CertificateId WHERE Q.PersonId = Person.PersonId AND IsRegisterHSSE=1)>0) as InjectionSafetyEngineerPersonNum, (select COUNT(*) from SitePerson_Person Person where InTime <=GETDATE() AND (OutTime IS NULL OR OutTime > GETDATE()) AND Person.ProjectId=p.ProjectId and (SELECT COUNT(*) FROM QualityAudit_PersonQuality AS Q LEFT JOIN Base_Certificate AS Cer ON Q.CertificateId =Cer.CertificateId WHERE Q.PersonId = Person.PersonId AND CertificateType='A')> 0) as ACertificatePersonNum, (select COUNT(*) from SitePerson_Person Person where InTime <=GETDATE() AND (OutTime IS NULL OR OutTime > GETDATE()) AND Person.ProjectId=p.ProjectId and (SELECT COUNT(*) FROM QualityAudit_PersonQuality AS Q LEFT JOIN Base_Certificate AS Cer ON Q.CertificateId =Cer.CertificateId WHERE Q.PersonId = Person.PersonId AND CertificateType='B')> 0) as BCertificatePersonNum, (select COUNT(*) from SitePerson_Person Person where InTime <=GETDATE() AND (OutTime IS NULL OR OutTime > GETDATE()) AND Person.ProjectId=p.ProjectId and (SELECT COUNT(*) FROM QualityAudit_PersonQuality AS Q LEFT JOIN Base_Certificate AS Cer ON Q.CertificateId =Cer.CertificateId WHERE Q.PersonId = Person.PersonId AND CertificateType='C')> 0) as CCertificatePersonNum, isnull((select top 1 ProjectWorkTime from SeDin_MonthReport2 a left join SeDin_MonthReport b on a.MonthReportId=b.MonthReportId where b.ProjectId=p.ProjectId order by ReporMonth desc),0) as TotalWorkingHours, cast(isnull(((select sum(isnull(WorkHoursLoss,0)) from Accident_AccidentHandle a where a.ProjectId=p.ProjectId) +(select sum(isnull(WorkingHoursLoss,0)) from Accident_AccidentReport a where a.ProjectId=p.ProjectId)),0) as int) as LostWorkingHours, (isnull((select top 1 ProjectWorkTime from SeDin_MonthReport2 a left join SeDin_MonthReport b on a.MonthReportId=b.MonthReportId where b.ProjectId=p.ProjectId order by ReporMonth desc),0)- cast(isnull(((select sum(isnull(WorkHoursLoss,0)) from Accident_AccidentHandle a where a.ProjectId=p.ProjectId) +(select sum(isnull(WorkingHoursLoss,0)) from Accident_AccidentReport a where a.ProjectId=p.ProjectId)),0) as int)) as SafeWorkingHours, (select COUNT(*) from EduTrain_TrainRecord r left join Base_TrainType t on r.TrainTypeId=t.TrainTypeId where r.ProjectId=p.ProjectId and t.TrainType='1' and r.TrainStartDate>'2023-01-01') as SafeTrainNum, (select COUNT(*) from EduTrain_TrainRecord r left join Base_TrainType t on r.TrainTypeId=t.TrainTypeId where r.ProjectId=p.ProjectId and t.TrainType='2' and r.TrainStartDate>'2023-01-01') as SpecialTrainNum, (select COUNT(*) from EduTrain_TrainRecord r left join Base_TrainType t on r.TrainTypeId=t.TrainTypeId where r.ProjectId=p.ProjectId and t.TrainType='3' and r.TrainStartDate>'2023-01-01') as SpecialOperationTrainNum, (select COUNT(*) from Meeting_SafetyLeaderGroupMeeting r where r.ProjectId=p.ProjectId and r.CompileDate>'2023-01-01') as ProjectSafetyLeadingGroupMeetingNum, ((select COUNT(*) from Meeting_WeekMeeting r where r.ProjectId=p.ProjectId and r.CompileDate>'2023-01-01')+(select COUNT(*) from Meeting_MonthMeeting r where r.ProjectId=p.ProjectId and r.CompileDate>'2023-01-01')) as ProjectSafetyMeetingNum, (select COUNT(*) from Check_ProjectLeaderCheck r where r.ProjectId=p.ProjectId and r.CompileDate>'2023-01-01') as ProjectLeadShiftCheckNum, (select COUNT(*) from Check_CheckSpecial r where r.ProjectId=p.ProjectId and r.CheckTime>'2023-01-01') as ProjectSpecialCheckNum, (select COUNT(*) from HSSE_Hazard_HazardRegister r where r.ProjectId=p.ProjectId and r.CheckTime>'2023-01-01') as ProjectMajorCheckNum, (select COUNT(*) from Accident_AccidentPersonRecord r where r.ProjectId=p.ProjectId and r.IsAttempt='1' and r.CompileDate>'2023-01-01') as NearMissNum, (select COUNT(*) from Accident_AccidentPersonRecord r where r.ProjectId=p.ProjectId and r.CompileDate>'2023-01-01') as RecordableEventNum, (select COUNT(*) from Accident_AccidentReport r where r.ProjectId=p.ProjectId and r.AccidentDegree='1' and r.CompileDate>'2023-01-01') as GeneralAccidentNum, (select COUNT(*) from Accident_AccidentReport r where r.ProjectId=p.ProjectId and r.AccidentDegree='2' and r.CompileDate>'2023-01-01') as MajorAccidentNum, (select COUNT(*) from Accident_AccidentReport r where r.ProjectId=p.ProjectId and r.AccidentDegree='3' and r.CompileDate>'2023-01-01') as SeriousAccidentNum, (select COUNT(*) from Accident_AccidentReport r where r.ProjectId=p.ProjectId and r.AccidentDegree='4' and r.CompileDate>'2023-01-01') as SpecialSeriousAccidentNum, (select COUNT(*) from Emergency_EmergencyList r left join Base_EmergencyType t on r.EmergencyTypeId=t.EmergencyTypeId where r.ProjectId=p.ProjectId and t.EmergencyTypeName like '%综合%' and r.CompileDate>'2023-01-01') as ProjectComprehensivePlanNum, (select COUNT(*) from Emergency_EmergencyList r left join Base_EmergencyType t on r.EmergencyTypeId=t.EmergencyTypeId where r.ProjectId=p.ProjectId and t.EmergencyTypeName like '%专项%' and r.CompileDate>'2023-01-01') as ProjectSpecialPlanNum, (select COUNT(*) from Emergency_EmergencyList r left join Base_EmergencyType t on r.EmergencyTypeId=t.EmergencyTypeId where r.ProjectId=p.ProjectId and t.EmergencyTypeName like '%现场处置%' and r.CompileDate>'2023-01-01') as ProjectOnSiteDisposalPlanNum, (select COUNT(*) from Emergency_DrillRecordList r where r.ProjectId=p.ProjectId and r.CompileDate>'2023-01-01') as ProjectDrillNum, ISNULL((select sum(CostMoney) from CostGoods_CostSmallDetailItem r left join CostGoods_CostSmallDetail t on r.CostSmallDetailId=t.CostSmallDetailId where t.ProjectId=p.ProjectId and t.CompileDate>'2023-01-01'),0) as CostUse, ((select COUNT(*) from InApproveManager_EquipmentInItem r left join InApproveManager_EquipmentIn t on r.EquipmentInId=t.EquipmentInId where t.ProjectId=p.ProjectId) +(select COUNT(*) from InApproveManager_GeneralEquipmentInItem r left join InApproveManager_GeneralEquipmentIn t on r.GeneralEquipmentInId=t.GeneralEquipmentInId where t.ProjectId=p.ProjectId)) as UseEquipmentNum, (select COUNT(*) from InApproveManager_EquipmentInItem r left join InApproveManager_EquipmentIn t on r.EquipmentInId=t.EquipmentInId where t.ProjectId=p.ProjectId) as SpecialEquipmentNum, ((select COUNT(*) from License_LicenseManager r where r.ProjectId=p.ProjectId and r.CompileDate>'2023-01-01') +(select COUNT(*) from License_BreakGround r where r.ProjectId=p.ProjectId and r.ValidityStartTime>'2023-01-01') +(select COUNT(*) from License_FireWork r where r.ProjectId=p.ProjectId and r.ValidityStartTime>'2023-01-01') +(select COUNT(*) from License_HeightWork r where r.ProjectId=p.ProjectId and r.ValidityStartTime>'2023-01-01') +(select COUNT(*) from License_LiftingWork r where r.ProjectId=p.ProjectId and r.ValidityStartTime>'2023-01-01') +(select COUNT(*) from License_LimitedSpace r where r.ProjectId=p.ProjectId and r.ValidityStartTime>'2023-01-01') +(select COUNT(*) from License_NightWork r where r.ProjectId=p.ProjectId and r.ValidityStartTime>'2023-01-01') +(select COUNT(*) from License_OpenCircuit r where r.ProjectId=p.ProjectId and r.ValidityStartTime>'2023-01-01') +(select COUNT(*) from License_RadialWork r where r.ProjectId=p.ProjectId and r.ValidityStartTime>'2023-01-01')) as LicensesNum, ((select COUNT(*) from License_LicenseManager r where r.ProjectId=p.ProjectId and r.CompileDate>'2023-01-01' and WorkStates='3') +(select COUNT(*) from License_BreakGround r where r.ProjectId=p.ProjectId and r.ValidityStartTime>'2023-01-01' and States='3') +(select COUNT(*) from License_FireWork r where r.ProjectId=p.ProjectId and r.ValidityStartTime>'2023-01-01' and States='3') +(select COUNT(*) from License_HeightWork r where r.ProjectId=p.ProjectId and r.ValidityStartTime>'2023-01-01' and States='3') +(select COUNT(*) from License_LiftingWork r where r.ProjectId=p.ProjectId and r.ValidityStartTime>'2023-01-01' and States='3') +(select COUNT(*) from License_LimitedSpace r where r.ProjectId=p.ProjectId and r.ValidityStartTime>'2023-01-01' and States='3') +(select COUNT(*) from License_NightWork r where r.ProjectId=p.ProjectId and r.ValidityStartTime>'2023-01-01' and States='3') +(select COUNT(*) from License_OpenCircuit r where r.ProjectId=p.ProjectId and r.ValidityStartTime>'2023-01-01' and States='3') +(select COUNT(*) from License_RadialWork r where r.ProjectId=p.ProjectId and r.ValidityStartTime>'2023-01-01' and States='3')) as LicensesCloseNum, (select COUNT(*) from HSSE_Hazard_HazardRegister r where r.ProjectId=p.ProjectId and r.CheckTime>'2023-01-01' and States='3' and (r.HazardValue='0.3' or r.HazardValue='1' or r.HazardValue is null)) as GeneralClosedNum, (select COUNT(*) from HSSE_Hazard_HazardRegister r where r.ProjectId=p.ProjectId and r.CheckTime>'2023-01-01' and States!='3' and (r.HazardValue='0.3' or r.HazardValue='1' or r.HazardValue is null)) as GeneralNotClosedNum, (select COUNT(*) from HSSE_Hazard_HazardRegister r where r.ProjectId=p.ProjectId and r.CheckTime>'2023-01-01' and States='3' and r.HazardValue='3') as MajorClosedNum, (select COUNT(*) from HSSE_Hazard_HazardRegister r where r.ProjectId=p.ProjectId and r.CheckTime>'2023-01-01' and States!='3' and r.HazardValue='3') as MajorNotClosedNum, case when (select COUNT(*) from HSSE_Hazard_HazardRegister r where r.ProjectId=p.ProjectId and r.CheckTime>'2023-01-01' and States='3' and (r.HazardValue='0.3' or r.HazardValue='1' or r.HazardValue is null)) +(select COUNT(*) from HSSE_Hazard_HazardRegister r where r.ProjectId=p.ProjectId and r.CheckTime>'2023-01-01' and States!='3' and (r.HazardValue='0.3' or r.HazardValue='1' or r.HazardValue is null))>0 then cast(cast(cast(1.0*(select COUNT(*) from HSSE_Hazard_HazardRegister r where r.ProjectId=p.ProjectId and r.CheckTime>'2023-01-01' and States='3' and (r.HazardValue='0.3' or r.HazardValue='1' or r.HazardValue is null)) /(1.0 *((select COUNT(*) from HSSE_Hazard_HazardRegister r where r.ProjectId=p.ProjectId and r.CheckTime>'2023-01-01' and States='3' and (r.HazardValue='0.3' or r.HazardValue='1' or r.HazardValue is null)) +(select COUNT(*) from HSSE_Hazard_HazardRegister r where r.ProjectId=p.ProjectId and r.CheckTime>'2023-01-01' and States!='3' and (r.HazardValue='0.3' or r.HazardValue='1' or r.HazardValue is null))))*100 as decimal(9,2)) as float) as nvarchar(10))+'%' else '/' end as GeneralRate, case when (select COUNT(*) from HSSE_Hazard_HazardRegister r where r.ProjectId=p.ProjectId and r.CheckTime>'2023-01-01' and States='3' and r.HazardValue='3') +(select COUNT(*) from HSSE_Hazard_HazardRegister r where r.ProjectId=p.ProjectId and r.CheckTime>'2023-01-01' and States!='3' and r.HazardValue='3')>0 then cast(cast(cast(1.0*(select COUNT(*) from HSSE_Hazard_HazardRegister r where r.ProjectId=p.ProjectId and r.CheckTime>'2023-01-01' and States='3' and r.HazardValue='3') /(1.0 *((select COUNT(*) from HSSE_Hazard_HazardRegister r where r.ProjectId=p.ProjectId and r.CheckTime>'2023-01-01' and States='3' and r.HazardValue='3') +(select COUNT(*) from HSSE_Hazard_HazardRegister r where r.ProjectId=p.ProjectId and r.CheckTime>'2023-01-01' and States!='3' and r.HazardValue='3')))*100 as decimal(9,2)) as float) as nvarchar(10))+'%' else '/' end as MajorRate, (select COUNT(*) from Hazard_HazardSelectedItem r left join Base_RiskLevel t on r.HazardLevel=t.RiskLevelId where r.ProjectId=p.ProjectId and t.RiskLevel=1 and r.IsStart=1) as LowRiskNum, (select COUNT(*) from Hazard_HazardSelectedItem r left join Base_RiskLevel t on r.HazardLevel=t.RiskLevelId where r.ProjectId=p.ProjectId and t.RiskLevel=2 and r.IsStart=1) as GeneralRiskNum, (select COUNT(*) from Hazard_HazardSelectedItem r left join Base_RiskLevel t on r.HazardLevel=t.RiskLevelId where r.ProjectId=p.ProjectId and t.RiskLevel=3 and r.IsStart=1) as MediumRiskNum, (select COUNT(*) from Hazard_HazardSelectedItem r left join Base_RiskLevel t on r.HazardLevel=t.RiskLevelId where r.ProjectId=p.ProjectId and t.RiskLevel=4 and r.IsStart=1) as HighRiskNum, (select COUNT(*) from Solution_LargerHazard r where r.ProjectId=p.ProjectId and r.States='1' and r.RecordTime>'2023-01-01' and r.IsSuperLargerHazard=0) as CompletedNum, isnull((select sum(TrainPersonNum) from Solution_LargerHazard r where r.ProjectId=p.ProjectId and r.RecordTime>'2023-01-01' and r.IsSuperLargerHazard=0),0) as TrainPersonNum, (select COUNT(*) from Solution_LargerHazard r where r.ProjectId=p.ProjectId and r.States='2' and r.RecordTime>'2023-01-01' and r.IsSuperLargerHazard=0) as ConstructionNum, (select COUNT(*) from Solution_LargerHazard r where r.ProjectId=p.ProjectId and r.States='3' and r.RecordTime>'2023-01-01' and r.IsSuperLargerHazard=0) as FinishedNum, (select COUNT(*) from Solution_LargerHazard r where r.ProjectId=p.ProjectId and r.States='1' and r.RecordTime>'2023-01-01' and r.IsSuperLargerHazard=1) as SuperCompletedNum, isnull((select sum(TrainPersonNum) from Solution_LargerHazard r where r.ProjectId=p.ProjectId and r.RecordTime>'2023-01-01' and r.IsSuperLargerHazard=1),0) as SuperTrainPersonNum, (select COUNT(*) from Solution_LargerHazard r where r.ProjectId=p.ProjectId and r.States='2' and r.RecordTime>'2023-01-01' and r.IsSuperLargerHazard=1) as SuperConstructionNum, (select COUNT(*) from Solution_LargerHazard r where r.ProjectId=p.ProjectId and r.States='3' and r.RecordTime>'2023-01-01' and r.IsSuperLargerHazard=1) as SuperFinishedNum, isnull((select sum(TrainPersonNum) from Train_TrainPlan r where r.ProjectId=p.ProjectId and r.CompileDate>'2023-01-01'),0) as QTrainPersonNum, isnull((select sum(JoinPersonNum) from Comprehensive_DesignDetails r where r.ProjectId=p.ProjectId and r.CompileDate>'2023-01-01'),0) as TechnicalDisclosePersonNum, (select COUNT(*) from Check_CheckEquipment r where r.ProjectId=p.ProjectId and r.CompileDate>'2023-01-01') as UseNum, (select COUNT(*) from Check_CheckEquipment r where r.ProjectId=p.ProjectId and r.CompileDate>'2023-01-01') as OKNum, (select COUNT(*) from SitePerson_Person Person LEFT JOIN Base_WorkPost AS WorkPost ON Person.WorkPostId =WorkPost.WorkPostId where InTime <=GETDATE() AND (OutTime IS NULL OR OutTime > GETDATE()) AND Person.ProjectId=p.ProjectId and WorkPost.IsCQMS=1) as ProjectPersonNum, (select COUNT(*) from Check_CheckControl r where r.ProjectId=p.ProjectId and r.CheckDate>'2023-01-01') as ProblemNum, (select COUNT(*) from Check_CheckControl r where r.ProjectId=p.ProjectId and r.CheckDate>'2023-01-01' and r.State='7') as ProblemCompletedNum, (select COUNT(*) from Check_CheckControl r where r.ProjectId=p.ProjectId and r.CheckDate>'2023-01-01' and r.State!='7') as ProblemNotCompletedNum, case when (select COUNT(*) from Check_CheckControl r where r.ProjectId=p.ProjectId and r.CheckDate>'2023-01-01')>0 then cast(cast(cast(1.0*(select COUNT(*) from Check_CheckControl r where r.ProjectId=p.ProjectId and r.CheckDate>'2023-01-01' and r.State='7') /(1.0 *((select COUNT(*) from Check_CheckControl r where r.ProjectId=p.ProjectId and r.CheckDate>'2023-01-01')))*100 as decimal(9,2)) as float) as nvarchar(10))+'%' else '/' end as ProblemRate, (select COUNT(*) from WBS_ControlItemAndCycle r where r.ProjectId=p.ProjectId and r.ControlPoint like '%A%' and r.IsApprove=1) as ANum, (select COUNT(*) from WBS_ControlItemAndCycle r where r.ProjectId=p.ProjectId and r.ControlPoint like '%B%' and r.IsApprove=1) as BNum, (select COUNT(*) from WBS_ControlItemAndCycle r where r.ProjectId=p.ProjectId and r.ControlPoint like '%C%' and r.IsApprove=1) as CNum, (select COUNT(*) from Check_SpotCheckDetail r left join Check_SpotCheck t on r.SpotCheckCode=t.SpotCheckCode left join WBS_ControlItemAndCycle c on c.ControlItemAndCycleId=r.ControlItemAndCycleId where t.ProjectId=p.ProjectId and c.CheckAcceptType='1' and t.SpotCheckDate>'2023-01-01') as KeyProcessNum, (select COUNT(*) from Check_SpotCheckDetail r left join Check_SpotCheck t on r.SpotCheckCode=t.SpotCheckCode left join WBS_ControlItemAndCycle c on c.ControlItemAndCycleId=r.ControlItemAndCycleId where t.ProjectId=p.ProjectId and c.CheckAcceptType='1' and r.IsOK=1 and t.SpotCheckDate>'2023-01-01') as KeyProcessOkNum, case when (select COUNT(*) from Check_SpotCheckDetail r left join Check_SpotCheck t on r.SpotCheckCode=t.SpotCheckCode left join WBS_ControlItemAndCycle c on c.ControlItemAndCycleId=r.ControlItemAndCycleId where t.ProjectId=p.ProjectId and c.CheckAcceptType='1' and t.SpotCheckDate>'2023-01-01')>0 then cast(cast(cast(1.0*(select COUNT(*) from Check_SpotCheckDetail r left join Check_SpotCheck t on r.SpotCheckCode=t.SpotCheckCode left join WBS_ControlItemAndCycle c on c.ControlItemAndCycleId=r.ControlItemAndCycleId where t.ProjectId=p.ProjectId and c.CheckAcceptType='1' and r.IsOK=1 and t.SpotCheckDate>'2023-01-01') /(1.0 *((select COUNT(*) from Check_SpotCheckDetail r left join Check_SpotCheck t on r.SpotCheckCode=t.SpotCheckCode left join WBS_ControlItemAndCycle c on c.ControlItemAndCycleId=r.ControlItemAndCycleId where t.ProjectId=p.ProjectId and c.CheckAcceptType='1' and t.SpotCheckDate>'2023-01-01')))*100 as decimal(9,2)) as float) as nvarchar(10))+'%' else '/' end as KeyProcessRate, (select COUNT(*) from Check_SpotCheckDetail r left join Check_SpotCheck t on r.SpotCheckCode=t.SpotCheckCode left join WBS_ControlItemAndCycle c on c.ControlItemAndCycleId=r.ControlItemAndCycleId where t.ProjectId=p.ProjectId and c.CheckAcceptType='2' and t.SpotCheckDate>'2023-01-01') as SpecialProcessNum, (select COUNT(*) from Check_SpotCheckDetail r left join Check_SpotCheck t on r.SpotCheckCode=t.SpotCheckCode left join WBS_ControlItemAndCycle c on c.ControlItemAndCycleId=r.ControlItemAndCycleId where t.ProjectId=p.ProjectId and c.CheckAcceptType='2' and r.IsOK=1 and t.SpotCheckDate>'2023-01-01') as SpecialProcessOkNum, case when (select COUNT(*) from Check_SpotCheckDetail r left join Check_SpotCheck t on r.SpotCheckCode=t.SpotCheckCode left join WBS_ControlItemAndCycle c on c.ControlItemAndCycleId=r.ControlItemAndCycleId where t.ProjectId=p.ProjectId and c.CheckAcceptType='2' and t.SpotCheckDate>'2023-01-01')>0 then cast(cast(cast(1.0*(select COUNT(*) from Check_SpotCheckDetail r left join Check_SpotCheck t on r.SpotCheckCode=t.SpotCheckCode left join WBS_ControlItemAndCycle c on c.ControlItemAndCycleId=r.ControlItemAndCycleId where t.ProjectId=p.ProjectId and c.CheckAcceptType='2' and r.IsOK=1 and t.SpotCheckDate>'2023-01-01') /(1.0 *((select COUNT(*) from Check_SpotCheckDetail r left join Check_SpotCheck t on r.SpotCheckCode=t.SpotCheckCode left join WBS_ControlItemAndCycle c on c.ControlItemAndCycleId=r.ControlItemAndCycleId where t.ProjectId=p.ProjectId and c.CheckAcceptType='2' and t.SpotCheckDate>'2023-01-01')))*100 as decimal(9,2)) as float) as nvarchar(10))+'%' else '/' end as SpecialProcessRate, (select COUNT(*) from Check_SpotCheckDetail r left join Check_SpotCheck t on r.SpotCheckCode=t.SpotCheckCode left join WBS_ControlItemAndCycle c on c.ControlItemAndCycleId=r.ControlItemAndCycleId where t.ProjectId=p.ProjectId and c.CheckAcceptType='3' and t.SpotCheckDate>'2023-01-01') as ConcealedWorksNum, (select COUNT(*) from Check_SpotCheckDetail r left join Check_SpotCheck t on r.SpotCheckCode=t.SpotCheckCode left join WBS_ControlItemAndCycle c on c.ControlItemAndCycleId=r.ControlItemAndCycleId where t.ProjectId=p.ProjectId and c.CheckAcceptType='3' and r.IsOK=1 and t.SpotCheckDate>'2023-01-01') as ConcealedWorksOkNum, case when (select COUNT(*) from Check_SpotCheckDetail r left join Check_SpotCheck t on r.SpotCheckCode=t.SpotCheckCode left join WBS_ControlItemAndCycle c on c.ControlItemAndCycleId=r.ControlItemAndCycleId where t.ProjectId=p.ProjectId and c.CheckAcceptType='3' and t.SpotCheckDate>'2023-01-01')>0 then cast(cast(cast(1.0*(select COUNT(*) from Check_SpotCheckDetail r left join Check_SpotCheck t on r.SpotCheckCode=t.SpotCheckCode left join WBS_ControlItemAndCycle c on c.ControlItemAndCycleId=r.ControlItemAndCycleId where t.ProjectId=p.ProjectId and c.CheckAcceptType='3' and r.IsOK=1 and t.SpotCheckDate>'2023-01-01') /(1.0 *((select COUNT(*) from Check_SpotCheckDetail r left join Check_SpotCheck t on r.SpotCheckCode=t.SpotCheckCode left join WBS_ControlItemAndCycle c on c.ControlItemAndCycleId=r.ControlItemAndCycleId where t.ProjectId=p.ProjectId and c.CheckAcceptType='3' and t.SpotCheckDate>'2023-01-01')))*100 as decimal(9,2)) as float) as nvarchar(10))+'%' else '/' end as ConcealedWorksRate, (select COUNT(*) from Check_SpotCheckDetail r left join Check_SpotCheck t on r.SpotCheckCode=t.SpotCheckCode left join WBS_ControlItemAndCycle c on c.ControlItemAndCycleId=r.ControlItemAndCycleId where t.ProjectId=p.ProjectId and c.CheckAcceptType='4' and t.SpotCheckDate>'2023-01-01') as UnitProjectOnesNum, (select COUNT(*) from Check_SpotCheckDetail r left join Check_SpotCheck t on r.SpotCheckCode=t.SpotCheckCode left join WBS_ControlItemAndCycle c on c.ControlItemAndCycleId=r.ControlItemAndCycleId where t.ProjectId=p.ProjectId and c.CheckAcceptType='4' and r.IsOK=1 and t.SpotCheckDate>'2023-01-01') as UnitProjectOnesOKNum, case when (select COUNT(*) from Check_SpotCheckDetail r left join Check_SpotCheck t on r.SpotCheckCode=t.SpotCheckCode left join WBS_ControlItemAndCycle c on c.ControlItemAndCycleId=r.ControlItemAndCycleId where t.ProjectId=p.ProjectId and c.CheckAcceptType='4' and t.SpotCheckDate>'2023-01-01')>0 then cast(cast(cast(1.0*(select COUNT(*) from Check_SpotCheckDetail r left join Check_SpotCheck t on r.SpotCheckCode=t.SpotCheckCode left join WBS_ControlItemAndCycle c on c.ControlItemAndCycleId=r.ControlItemAndCycleId where t.ProjectId=p.ProjectId and c.CheckAcceptType='4' and r.IsOK=1 and t.SpotCheckDate>'2023-01-01') /(1.0 *((select COUNT(*) from Check_SpotCheckDetail r left join Check_SpotCheck t on r.SpotCheckCode=t.SpotCheckCode left join WBS_ControlItemAndCycle c on c.ControlItemAndCycleId=r.ControlItemAndCycleId where t.ProjectId=p.ProjectId and c.CheckAcceptType='4' and t.SpotCheckDate>'2023-01-01')))*100 as decimal(9,2)) as float) as nvarchar(10))+'%' else '/' end as UnitProjectOnesRate, (select COUNT(*) from Check_SpotCheckDetail r left join Check_SpotCheck t on r.SpotCheckCode=t.SpotCheckCode left join WBS_ControlItemAndCycle c on c.ControlItemAndCycleId=r.ControlItemAndCycleId where t.ProjectId=p.ProjectId and c.CheckAcceptType='5' and t.SpotCheckDate>'2023-01-01') as MaterialInRecheckNum, (select COUNT(*) from Check_SpotCheckDetail r left join Check_SpotCheck t on r.SpotCheckCode=t.SpotCheckCode left join WBS_ControlItemAndCycle c on c.ControlItemAndCycleId=r.ControlItemAndCycleId where t.ProjectId=p.ProjectId and c.CheckAcceptType='5' and r.IsOK=1 and t.SpotCheckDate>'2023-01-01') as MaterialInRecheckOKNum, case when (select COUNT(*) from Check_SpotCheckDetail r left join Check_SpotCheck t on r.SpotCheckCode=t.SpotCheckCode left join WBS_ControlItemAndCycle c on c.ControlItemAndCycleId=r.ControlItemAndCycleId where t.ProjectId=p.ProjectId and c.CheckAcceptType='5' and t.SpotCheckDate>'2023-01-01')>0 then cast(cast(cast(1.0*(select COUNT(*) from Check_SpotCheckDetail r left join Check_SpotCheck t on r.SpotCheckCode=t.SpotCheckCode left join WBS_ControlItemAndCycle c on c.ControlItemAndCycleId=r.ControlItemAndCycleId where t.ProjectId=p.ProjectId and c.CheckAcceptType='5' and r.IsOK=1 and t.SpotCheckDate>'2023-01-01') /(1.0 *((select COUNT(*) from Check_SpotCheckDetail r left join Check_SpotCheck t on r.SpotCheckCode=t.SpotCheckCode left join WBS_ControlItemAndCycle c on c.ControlItemAndCycleId=r.ControlItemAndCycleId where t.ProjectId=p.ProjectId and c.CheckAcceptType='5' and t.SpotCheckDate>'2023-01-01')))*100 as decimal(9,2)) as float) as nvarchar(10))+'%' else '/' end as MaterialInRecheckRate, (select COUNT(*) from WBS_UnitWork r where r.ProjectId=p.ProjectId) as SingleProjectNum, (select COUNT(*) from WBS_UnitWork r where r.ProjectId=p.ProjectId) as UnitProjectNum, (select COUNT(*) from WBS_WorkPackage r where r.ProjectId=p.ProjectId and r.SubItemType='1' and r.IsApprove=1) as SubProjectNum, (select COUNT(*) from WBS_WorkPackage r where r.ProjectId=p.ProjectId and r.SubItemType='3' and r.IsApprove=1) as SubdivisionalWorksNum, (select COUNT(*) from WBS_ControlItemAndCycle r where r.ProjectId=p.ProjectId and r.IsApprove=1) as InspectionLotNum, (select COUNT(*) from SitePerson_Person Person where InTime <=GETDATE() AND (OutTime IS NULL OR OutTime > GETDATE()) AND Person.ProjectId=p.ProjectId and Person.WorkPostId='19B8F2A9-28D3-4F20-867A-1B2237C2E228') as WelderNum, (select CAST((SELECT ISNULL(SUM(ISNULL(Size,0)),0) FROM dbo.HJGL_WeldJoint w WHERE w.ProjectId=p.ProjectId) AS DECIMAL(12,3))) AS TotalDineNum, CAST((SELECT ISNULL(SUM(ISNULL(jot.Size,0)),0) FROM dbo.HJGL_WeldJoint jot left join dbo.HJGL_WeldingDaily d on d.WeldingDailyId=jot.WeldingDailyId WHERE jot.ProjectId=p.ProjectId AND jot.WeldingDailyId IS NOT NULL and d.WeldingDate<=GETDATE()) AS DECIMAL(12,3)) AS CompleteDineNum, isnull((select sum(TotalFilm) from HJGL_Batch_NDEItem r left join HJGL_Batch_NDE t on t.NDEID=r.NDEID where t.ProjectId=p.ProjectId),0) as TotalFilmNum, isnull((select sum(PassFilm) from HJGL_Batch_NDEItem r left join HJGL_Batch_NDE t on t.NDEID=r.NDEID where t.ProjectId=p.ProjectId),0) as OKFilmNum, p.ProjectId from Base_Project p where IsCNCECShow=1 GO INSERT INTO dbo.Sys_Menu(MenuId,MenuName,Url,SortIndex,SuperMenu,MenuType,IsOffice,IsEnd,IsUsed) VALUES('C4B90ED3-0258-437A-BC0D-4AB43721EE08','看板数据汇总','ZHGL/DataSync/DataStatistics.aspx',105,'0','Menu_ZHGL',1,1,1) GO