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 is null or (WeldJoint.IsHotProess=1 and HardTrustItem.IsPass=1)) and BackingWelder.ProjectId=Pipeline.ProjectId and CoverWelder.ProjectId=Pipeline.ProjectId GO