insert into Sys_Menu(MenuId,MenuName,Url,SortIndex,SuperMenu,MenuModule) values('142E6B0B-530E-448B-84C5-1A93E0316E3B','黄金(碰头)焊口材质及检测确认表','HJGL/WeldingReport/GoldMouthLedger.aspx',240,'F3B157B7-9BEE-4150-6666-087828F1C51D','3') go CREATE PROCEDURE [dbo].[HJGL_rpt_GoldMouthLedger] ( @projectId NVARCHAR(50) =null ) AS /**********黄金(碰头)焊口材质及检测确认表***************/ SELECT jointInfo.JOT_ID, jointInfo.ProjectId, jointInfo.ISO_ID, isoInfo.ISO_IsoNo, jointInfo.JOT_JointNo, (case when Steel.STE_Code is not null then (case when Steel2.STE_Code is not null and Steel.STE_Code<>Steel2.STE_Code then Steel.STE_Code+'/'+Steel2.STE_Code else Steel.STE_Code end) else Steel2.STE_Code end) as SteelCode,--材质 null as OldIsoNo,--碰头(老)管道管线编号 null as OldSteelCode,--碰头(老)管道材质 (case when Welder.WED_Code is not null then (case when FloorWelder.WED_Code is not null and Welder.WED_Code<>FloorWelder.WED_Code then Welder.WED_Code+'/'+FloorWelder.WED_Code else Welder.WED_Code end) else FloorWelder.WED_Code end) as WelderCode, --焊工号 (CASE WHEN JointInfo.Jot_WeldingDate IS NOT NULL THEN JointInfo.Jot_WeldingDate ELSE WeldReportMain.JOT_WeldDate END) AS JOT_WeldDate, --焊接日期 ndt.NDT_Code,--检测方法 (case when jointInfo.RT_States is not null and jointInfo.RT_States!='待重检' then jointInfo.RT_States else (case when jointInfo.UT_States is not null and jointInfo.UT_States!='待重检' then jointInfo.UT_States else (case when jointInfo.MT_States is not null and jointInfo.MT_States!='待重检' then jointInfo.MT_States else (case when jointInfo.PT_States is not null and jointInfo.PT_States!='待重检' then jointInfo.PT_States else (case when jointInfo.PAUT_States is not null and jointInfo.PAUT_States!='待重检' then jointInfo.PAUT_States else null end) end)end) end) end) as TestStates,--检测状态 (case when jointInfo.RT_States is not null and jointInfo.RT_States='检测合格' then jointInfo.RT_TrustDate else (case when jointInfo.UT_States is not null and jointInfo.UT_States='检测合格' then jointInfo.UT_TrustDate else (case when jointInfo.MT_States is not null and jointInfo.MT_States='检测合格' then jointInfo.MT_TrustDate else (case when jointInfo.PT_States is not null and jointInfo.PT_States='检测合格' then jointInfo.PT_TrustDate else (case when jointInfo.PAUT_States is not null and jointInfo.PAUT_States='检测合格' then jointInfo.PAUT_TrustDate else null end) end)end) end) end) as TestDate,--检测日期 null as ConfirmMan,--确认人 jointType.JOTY_Group, jointInfo.Sort1, jointInfo.Sort2, jointInfo.Sort3, jointInfo.Sort4, jointInfo.Sort5, jointInfo.JOT_Remark FROM HJGL_PW_JointInfo AS jointInfo LEFT JOIN HJGL_PW_IsoInfo AS isoInfo ON isoInfo.ISO_ID = jointInfo.ISO_ID LEFT JOIN HJGL_BS_JointType AS jointType ON jointType.JOTY_ID=jointInfo.JOTY_ID LEFT JOIN HJGL_BS_Steel AS Steel ON Steel.STE_ID=jointInfo.STE_ID LEFT JOIN HJGL_BS_Steel AS Steel2 ON Steel2.STE_ID=jointInfo.STE_ID2 LEFT JOIN HJGL_BS_Welder AS Welder ON Welder.WED_ID= jointInfo.JOT_CellWelder LEFT JOIN HJGL_BS_Welder AS FloorWelder ON FloorWelder.WED_ID=jointInfo.JOT_FloorWelder LEFT JOIN HJGL_BO_WeldReportMain AS WeldReportMain ON WeldReportMain.DReportID=jointInfo.DReportID LEFT JOIN HJGL_BO_BatchDetail AS batchDetail on batchDetail.JOT_ID = jointInfo.JOT_ID LEFT JOIN HJGL_BS_NDTType AS ndt ON ndt.NDT_ID = batchDetail.NDT WHERE IsGold=1 and (jointInfo.ProjectId=@projectId or @projectId is null) order by isoInfo.ISO_IsoNo,jointType.JOTY_Group,jointInfo.Sort1,jointInfo.Sort2,jointInfo.Sort3,jointInfo.Sort4,jointInfo.Sort5 GO