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 ALTER VIEW [dbo].[View_HJGL_Batch_PointBatchItem] AS /*************点口明细表*************/ SELECT PointBatchItem.PointBatchItemId, PointBatchItem.PointBatchId, PointBatch.ProjectId, PointBatch.UnitId, PointBatch.DetectionTypeId, PointBatch.DetectionRateId, PointBatch.PointBatchCode, Pipeline.UnitWorkId, PointBatchItem.WeldJointId, (CASE PointBatchItem.PointState WHEN '1' THEN '点口' WHEN '2' THEN '扩透' END) AS PointState, (CASE PointBatchItem.IsBuildTrust WHEN 1 THEN '是' ELSE '' END) AS IsBuildTrust, (CASE WHEN PointBatchItem.IsAudit=1 THEN '是' WHEN (PointBatchItem.IsAudit IS NULL OR PointBatchItem.IsAudit=0) AND PointBatchItem.PointState IS NOT NULL THEN '否' WHEN (PointBatchItem.IsAudit IS NULL OR PointBatchItem.IsAudit=0) AND PointBatchItem.PointState IS NULL THEN '' END) AS PointIsAudit, PointBatchItem.PointDate,--点口日期 (CASE PointBatchItem.IsWelderFirst WHEN 1 THEN '是' ELSE '' END) AS IsWelderFirst, PointBatchItem.RepairDate,--返修日期 PointBatchItem.RepairRecordId, PointBatchItem.CutDate,--切除日期 PointBatchItem.PBackingWelderId,--返修打底焊工 PointBatchItem.PCoverWelderId,--返修盖面焊工 UnitWork.UnitWorkCode,--工区号 WeldJoint.WeldJointCode,--焊口号 WeldJoint.BackingWelderId AS WelderId, --焊工ID BackingWelder.WelderCode AS BackingWelderCode, CoverWelder.WelderCode AS CoverWelderCode, WeldType.WeldTypeCode, WeldJoint.JointAttribute, WeldJoint.JointArea,--焊接区域 WeldJoint.Size,--实际寸径 WeldingDaily.WeldingDate,--焊接日期 WeldJoint.PipelineId, --管线ID WeldJoint.Material1Id AS Mat, --材质 WeldJoint.Specification, --规格 Pipeline.PipelineCode, --管线号 PipingClass.PipingClassName , --管道等级 WeldJoint.BackingWelderId, WeldJoint.CoverWelderId FROM dbo.HJGL_Batch_PointBatchItem AS PointBatchItem LEFT JOIN dbo.HJGL_Batch_PointBatch AS PointBatch ON PointBatch.PointBatchId=PointBatchItem.PointBatchId LEFT JOIN dbo.HJGL_WeldJoint AS WeldJoint ON WeldJoint.WeldJointId=PointBatchItem.WeldJointId LEFT JOIN dbo.HJGL_Pipeline AS Pipeline ON Pipeline.PipelineId=WeldJoint.PipelineId LEFT JOIN dbo.WBS_UnitWork AS UnitWork ON UnitWork.UnitWorkId=Pipeline.UnitWorkId LEFT JOIN dbo.HJGL_WeldingDaily AS WeldingDaily ON WeldingDaily.WeldingDailyId=WeldJoint.WeldingDailyId LEFT JOIN dbo.Base_PipingClass AS PipingClass ON PipingClass.PipingClassId=Pipeline.PipingClassId LEFT JOIN SitePerson_Person AS BackingWelder ON BackingWelder.PersonId=WeldJoint.BackingWelderId LEFT JOIN SitePerson_Person AS CoverWelder ON CoverWelder.PersonId=WeldJoint.CoverWelderId LEFT JOIN Base_WeldType AS WeldType ON WeldType.WeldTypeId=WeldJoint.WeldTypeId LEFT JOIN HJGL_Hard_TrustItem HardTrustItem ON HardTrustItem.WeldJointId=PointBatchItem.WeldJointId where (WeldJoint.IsHotProess!=1 or (WeldJoint.IsHotProess=1 and HardTrustItem.IsPass=1)) and BackingWelder.ProjectId=Pipeline.ProjectId and CoverWelder.ProjectId=Pipeline.ProjectId GO