stringstrSql=@"SELECT S.SuperviseCheckReportId AS ID,S.SuperviseCheckReportCode,S.CheckDate,S.ProjectId,P.ProjectName + ( select top 1 case when ProjectState2 is null then '' when ProjectState2 !=3 then '<span style=""color:red"" >'+ ConstText+'<span/>' else ''end from Sys_Const where GroupId ='ProjectState' and (ProjectState2 is null or ProjectState2=ConstValue )) ProjectName,S.UnitId,u.UnitName,S.CheckTeam,S.EvaluationResult,S.AttachUrl,S.IsIssued,case S.CheckType when '1' then '企业负责人带班检查' when '2' then '企业综合检查' when '3' then '企业专项检查' else '' end as CheckTypeName
FROM dbo.Supervise_SuperviseCheckReport AS S
LEFT JOIN dbo.Base_Project AS P ON P.ProjectId=S.ProjectId
LEFT JOIN dbo.Base_Unit AS U ON U.UnitId=S.UnitId
WHERE (ProjectAttribute is null or ProjectAttribute = 'GONGCHENG') and (isDelete is null or isDelete =0) ";
stringstrSql=@"select C.ProjectLeaderCheckId AS ID,C.UnitIds,C.ProjectId,P.ProjectName + ( select top 1 case when ProjectState2 is null then '' when ProjectState2 !=3 then '<span style=""color:red"" >'+ ConstText+'<span/>' else ''end from Sys_Const where GroupId ='ProjectState' and (ProjectState2 is null or ProjectState2=ConstValue )) ProjectName,C.LeaderIds,C.LeaderNames AS CheckTeam,C.CheckDate
,UnitName= STUFF((SELECT ',' + UnitName FROM dbo.Base_Unit where PATINDEX('%,' + RTRIM(UnitId) + ',%',',' +C.UnitIds + ',')>0 FOR XML PATH('')), 1, 1,'')
,CheckTeam= STUFF((SELECT ',' + UserName FROM dbo.Sys_User where PATINDEX('%,' + RTRIM(UserId) + ',%',',' +C.LeaderIds + ',')>0 FOR XML PATH('')), 1, 1,'')
from Check_ProjectLeaderCheck AS C
LEFT JOIN Base_Project AS P ON C.ProjectId =P.ProjectId
where (P.ProjectAttribute is null or P.ProjectAttribute = 'GONGCHENG') and (P.isDelete is null or P.isDelete =0) ";
stringstrSql=@"select C.HazardRegisterId AS ID,C.ResponsibleUnit,C.ProjectId,P.ProjectName + ( select top 1 case when ProjectState2 is null then '' when ProjectState2 !=3 then '<span style=""color:red"" >'+ ConstText+'<span/>' else ''end from Sys_Const where GroupId ='ProjectState' and (ProjectState2 is null or ProjectState2=ConstValue )) ProjectName,C.CheckManId,U.UserName AS CheckTeam,C.CheckTime AS CheckDate,Ut.UnitName
from HSSE_Hazard_HazardRegister AS C
LEFT JOIN Base_Project AS P ON C.ProjectId =P.ProjectId
LEFT JOIN Sys_User AS U ON C.CheckManId=U.UserId
LEFT JOIN Base_Unit AS Ut ON C.ResponsibleUnit=Ut.UnitId
where (P.ProjectAttribute is null or P.ProjectAttribute = 'GONGCHENG') and (P.isDelete is null or P.isDelete =0) ";
stringstrSql=@"select C.CheckSpecialId AS ID,C.ProjectId,P.ProjectName + ( select top 1 case when ProjectState2 is null then '' when ProjectState2 !=3 then '<span style=""color:red"" >'+ ConstText+'<span/>' else ''end from Sys_Const where GroupId ='ProjectState' and (ProjectState2 is null or ProjectState2=ConstValue )) ProjectName, ISNULL(C.PartInPersonNames,'') AS CheckTeam,C.CheckTime AS CheckDate
,UnitName= STUFF((SELECT ',' + UnitName FROM dbo.Base_Unit where PATINDEX('%,' + RTRIM(UnitId) + ',%',',' +(C.PartInUnits) + ',')>0 FOR XML PATH('')), 1, 1,'')
from Check_CheckSpecial AS C
LEFT JOIN Base_Project AS P ON C.ProjectId =P.ProjectId
where (P.ProjectAttribute is null or P.ProjectAttribute = 'GONGCHENG') and (P.isDelete is null or P.isDelete =0) ";