237 lines
29 KiB
Transact-SQL
237 lines
29 KiB
Transact-SQL
|
|
ALTER 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,
|
|
cast(ISNULL((select sum(PriceMoney) from CostGoods_CostManageItem r left join CostGoods_CostManage t on r.CostManageId=t.CostManageId where t.ProjectId=p.ProjectId and t.CompileDate>'2023-01-01'),0) as decimal(18,2)) 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 Sys_Menu(MenuId,MenuName,Url,SortIndex,SuperMenu,MenuType,IsOffice,IsEnd,IsUsed)
|
|
VALUES('CF5516F7-0735-44EF-9A6D-46FABF8EBC6E','Ó¦¼±ÑÝÁ·¿ªÕ¹Çé¿ö','HSSE/Emergency/DrillRecordList.aspx',50,'B6FBD6B6-F9A0-49B1-87F9-160748162131','Menu_HSSE',0,1,1)
|
|
GO
|
|
INSERT INTO dbo.Sys_ButtonToMenu(ButtonToMenuId,MenuId,ButtonName,SortIndex)
|
|
VALUES('5621C1B0-AE75-467C-801E-7D776BDB9F0F','CF5516F7-0735-44EF-9A6D-46FABF8EBC6E','Ôö¼Ó',1)
|
|
INSERT INTO dbo.Sys_ButtonToMenu(ButtonToMenuId,MenuId,ButtonName,SortIndex)
|
|
VALUES('628DA0F7-2952-48A4-947E-E42A92EDCD4F','CF5516F7-0735-44EF-9A6D-46FABF8EBC6E','ÐÞ¸Ä',2)
|
|
INSERT INTO dbo.Sys_ButtonToMenu(ButtonToMenuId,MenuId,ButtonName,SortIndex)
|
|
VALUES('DEA0EDC8-4ACE-4E12-9506-4E993678FA76','CF5516F7-0735-44EF-9A6D-46FABF8EBC6E','ɾ³ý',3)
|
|
INSERT INTO dbo.Sys_ButtonToMenu(ButtonToMenuId,MenuId,ButtonName,SortIndex)
|
|
VALUES('E2736506-C222-4194-A279-DD92FA9976AE','CF5516F7-0735-44EF-9A6D-46FABF8EBC6E','±£´æ',4)
|
|
GO
|
|
|
|
|
|
ALTER VIEW [dbo].[View_HJGL_Pipeline]
|
|
AS
|
|
/*************¹ÜÏßÊÓͼ*****************/
|
|
SELECT pipeline.PipelineId,
|
|
pipeline.ProjectId,
|
|
pipeline.UnitId,
|
|
pipeline.UnitWorkId,
|
|
pipeline.PipelineCode,
|
|
pipeline.SingleName,
|
|
pipeline.SingleNumber,
|
|
pipeline.PipingClassId,
|
|
pipeline.MediumId,
|
|
pipingClass.PipingClassCode,
|
|
pipeline.DetectionRateId,
|
|
rate.DetectionRateCode,
|
|
pipeline.DetectionType,
|
|
pipeline.TestPressure,
|
|
pipeline.TestMedium,
|
|
pipeline.PressurePipingClassId,
|
|
pc.PressurePipingClassCode,
|
|
pipeline.PipeLenth,
|
|
pipeline.DesignPress,
|
|
pipeline.DesignTemperature,
|
|
pipeline.Remark,
|
|
pipeline.LeakPressure,
|
|
pipeline.LeakMedium,
|
|
pipeline.VacuumPressure,
|
|
pipeline.PCMedium ,
|
|
pipeline.PCtype,
|
|
pipeline.MaterialId,
|
|
pipeline.PipeArea,
|
|
pipeline.FlowingSection,
|
|
mat.MaterialCode,
|
|
dType.DetectionTypeCode,
|
|
lea.MediumName AS LeakMediumName,
|
|
pur.PurgeMethodName AS PCMediumName,
|
|
CAST((SELECT SUM(ISNULL(Size,0)) FROM dbo.HJGL_WeldJoint WHERE PipelineId=pipeline.PipelineId) AS DECIMAL(8,3)) AS TotalDin,
|
|
CAST((SELECT ISNULL(SUM(ISNULL(jot.Size,0)),0) FROM dbo.HJGL_WeldJoint jot WHERE jot.PipelineId=pipeline.PipelineId AND jot.WeldingDailyId IS NOT NULL) AS DECIMAL(8,3)) AS FinishSize,
|
|
(SELECT COUNT(WeldJointId) FROM dbo.HJGL_WeldJoint WHERE PipelineId=pipeline.PipelineId and IsTwoJoint is null) AS JointCount,
|
|
(SELECT COUNT(WeldJointId) FROM dbo.HJGL_WeldJoint WHERE PipelineId=pipeline.PipelineId and IsTwoJoint is null and WeldingDailyId IS NOT NULL) AS FinishJointCount,
|
|
unit.UnitName,
|
|
workArea.UnitWorkCode,
|
|
medium.MediumCode,
|
|
medium.MediumName AS MediumName,
|
|
testMedium.MediumCode AS TestMediumCode,
|
|
pipeline.ActEndDate AS FinishedDate,
|
|
pipeline.IsFinished
|
|
FROM dbo.HJGL_Pipeline AS pipeline
|
|
LEFT JOIN Base_PipingClass AS pipingClass ON pipingClass.PipingClassId=pipeline.PipingClassId
|
|
LEFT JOIN dbo.Base_Unit AS unit ON unit.UnitId=pipeline.UnitId
|
|
LEFT JOIN WBS_UnitWork AS workArea ON workArea.UnitWorkId=pipeline.UnitWorkId
|
|
LEFT JOIN Base_Medium AS medium ON medium.MediumId=pipeline.MediumId
|
|
LEFT JOIN dbo.Base_TestMedium AS testMedium ON testMedium.TestMediumId=pipeline.TestMedium
|
|
LEFT JOIN dbo.Base_DetectionRate rate ON rate.DetectionRateId = pipeline.DetectionRateId
|
|
LEFT JOIN dbo.Base_PressurePipingClass pc ON pc.PressurePipingClassId = pipeline.PressurePipingClassId
|
|
LEFT JOIN dbo.Base_TestMedium AS lea ON lea.TestMediumId=pipeline.LeakMedium
|
|
LEFT JOIN dbo.Base_PurgeMethod AS pur ON pur.PurgeMethodId=pipeline.PCMedium
|
|
LEFT JOIN dbo.Base_Material AS mat ON mat.MaterialId=pipeline.MaterialId
|
|
LEFT JOIN dbo.Base_DetectionType dType on dType.DetectionTypeId=pipeline.DetectionType
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
GO
|
|
|
|
|