CREATE PROC [dbo].[sp_rpt_CheckResult] @unitId NVARCHAR(50) = NULL, --单位Id @detectionTypeId NVARCHAR(50) = NULL, --探伤 @flowingSection NVARCHAR(50) = NULL, --探伤 @date1 DATETIME = NULL, @date2 DATETIME = NULL, @projectId NVARCHAR(50) = NULL AS /*检测结果汇总*/ select ndeItem.NDEItemID,unit.UnitName,jot.WeldJointCode,detectionType.DetectionTypeCode,ndeItem.TotalFilm,ndeItem.PassFilm, case ndeItem.CheckResult when '1' then '合格' else '不合格' end as CheckResult,pipeline.FlowingSection from HJGL_Batch_NDEItem ndeItem LEFT JOIN dbo.Base_DetectionType detectionType ON detectionType.DetectionTypeId = ndeItem.DetectionTypeId LEFT JOIN dbo.HJGL_Batch_BatchTrustItem trustItem ON trustItem.TrustBatchItemId = ndeItem.TrustBatchItemId LEFT JOIN dbo.HJGL_WeldJoint jot ON jot.WeldJointId = trustItem.WeldJointId LEFT JOIN dbo.HJGL_Pipeline pipeline ON jot.PipelineId = pipeline.PipelineId LEFT JOIN dbo.HJGL_WeldingDaily daily ON daily.WeldingDailyId = jot.WeldingDailyId LEFT JOIN dbo.Base_Unit unit ON unit.UnitId = daily.UnitId WHERE (ndeItem.DetectionTypeId=@detectionTypeId OR @detectionTypeId IS NULL) AND (jot.ProjectId=@projectId OR @projectId IS NULL) AND (daily.UnitId = @unitId OR @unitId IS NULL) AND (daily.WeldingDate >= @date1 OR @date1 IS NULL) AND (daily.WeldingDate <= @date2 OR @date2 IS NULL) AND (pipeline.FlowingSection like '%'+@flowingSection+'%' OR @flowingSection IS NULL) ORDER BY daily.UnitId,detectionType.DetectionTypeCode,jot.WeldJointCode GO