ALTER VIEW [dbo].[View_CH_RepairSearch] /*返修委托明细表查询列表*/ AS SELECT DISTINCT JointInfo.JOT_ID, --焊口id JointInfo.JOT_JointNo, --焊口代号 (CASE WHEN JointInfo.JOT_JointStatus ='102' THEN '扩透' ELSE CASE WHEN JointInfo.JOT_JointStatus ='104' THEN '切除' ELSE '点口' END END) AS JOT_JointStatus, IsoInfo.ISO_ID, --管线id IsoInfo.ISO_IsoNo, IsoInfo.UnitId, WorkArea.WorkAreaId, --区域id JointInfo.ProjectId, Checks.CHT_CheckID, --点口 Checks.CHT_CheckCode, Checks.RepairTrustId, JointInfo.JOT_JointDesc,--焊口规格 case when isoInfo.[Is_Standard] = 0 then (detectionRate.DetectionRate+'%') else (detectionRate1.DetectionRate+'%') end AS DetectionRate FROM dbo.CH_Check AS Checks LEFT JOIN dbo.CH_CheckItem AS CheckItem ON Checks.CHT_CheckID =CheckItem.CHT_CheckID LEFT JOIN dbo.PW_JointInfo AS JointInfo ON CheckItem.JOT_ID =JointInfo.JOT_ID LEFT JOIN dbo.PW_IsoInfo AS IsoInfo ON IsoInfo.ISO_ID = JointInfo.ISO_ID LEFT JOIN dbo.ProjectData_WorkArea AS WorkArea ON WorkArea.WorkAreaId=IsoInfo.WorkAreaId LEFT JOIN dbo.CH_Trust AS trust ON trust.CH_TrustID = Checks.CH_TrustID LEFT JOIN dbo.Base_DetectionType AS ndt ON ndt.DetectionTypeId = trust.CH_NDTMethod LEFT JOIN Base_DetectionRate AS detectionRate ON detectionRate.DetectionRateId = IsoInfo.DetectionRateId LEFT JOIN Base_DetectionRate AS detectionRate1 ON detectionRate1.DetectionRateId = JointInfo.DetectionRateId WHERE Checks.CHT_AuditDate IS NOT NULL AND ndt.DetectionTypeCode='RT' AND CheckItem.CHT_PassFilm != CheckItem.CHT_TotalFilm UNION SELECT DISTINCT JointInfo.JOT_ID, --焊口id JointInfo.JOT_JointNo, --焊口代号 (CASE WHEN JointInfo.JOT_JointStatus ='102' THEN '扩透' ELSE CASE WHEN JointInfo.JOT_JointStatus ='104' THEN '切除' ELSE '点口' END END) AS JOT_JointStatus, IsoInfo.ISO_ID, --管线id IsoInfo.ISO_IsoNo, IsoInfo.UnitId, WorkArea.WorkAreaId, --区域id JointInfo.ProjectId, Checks.CHT_CheckID, --点口 Checks.CHT_CheckCode, Checks.RepairTrustId, JointInfo.JOT_JointDesc,--焊口规格 case when isoInfo.[Is_Standard] = 0 then (detectionRate.DetectionRate+'%') else (detectionRate1.DetectionRate+'%') end AS DetectionRate FROM dbo.CH_Check AS Checks LEFT JOIN dbo.CH_CheckItem AS CheckItem ON Checks.CHT_CheckID =CheckItem.CHT_CheckID LEFT JOIN dbo.PW_JointInfo AS JointInfo ON CheckItem.JOT_ID =JointInfo.JOT_ID LEFT JOIN dbo.PW_IsoInfo AS IsoInfo ON IsoInfo.ISO_ID = JointInfo.ISO_ID LEFT JOIN dbo.ProjectData_WorkArea AS WorkArea ON WorkArea.WorkAreaId=IsoInfo.WorkAreaId LEFT JOIN dbo.CH_Trust AS trust ON trust.CH_TrustID = Checks.CH_TrustID LEFT JOIN dbo.Base_DetectionType AS ndt ON ndt.DetectionTypeId = trust.CH_NDTMethod LEFT JOIN Base_DetectionRate AS detectionRate ON detectionRate.DetectionRateId = IsoInfo.DetectionRateId LEFT JOIN Base_DetectionRate AS detectionRate1 ON detectionRate1.DetectionRateId = JointInfo.DetectionRateId WHERE Checks.CHT_AuditDate IS NOT NULL AND ndt.DetectionTypeCode!='RT' AND CheckItem.CHT_CheckResult='不合格' GO