ALTER PROCEDURE [dbo].[HJGL_spCH_HardTestReportItemDistinct2] ( @HardTestReportId nvarchar(50) ) AS --通过检测id获取委托单信息 BEGIN -- select ROW_NUMBER() OVER(ORDER BY c.Sort1,c.Sort2,c.Sort3,c.Sort4,c.Sort5,c.SortIndex) as sort, -- ROW_NUMBER() OVER(ORDER BY c.Sort1,c.Sort2,c.Sort3,c.Sort4,c.Sort5,c.SortIndex) as Number, -- c.HardTestReportItemId, --硬度委托明细id -- c.HardTestReportId, -- 硬度委托id -- c.JOT_ID, --焊口id -- c.ISO_IsoNo, -- Batch.BatchCode,--检测批号 -- c.JOT_JointNo, -- c.Remark, -- c.JOT_JointDesc, --规格 -- c.TestPart, -- Result.Remark as RemarkStr, -- c.STE_Code, --材质 -- c.WED_Code, -- convert(nvarchar(10),HotProessItem.HotProessDate,111) as HotProessDate, --热处理日期 -- HotProessItem.RecordChartNo --曲线编号 --from dbo.HJGL_View_CH_HardTestReportItem c --left join dbo.HJGL_BO_BatchDetail BatchDetail on BatchDetail.JOT_ID=c.JOT_ID --left join dbo.HJGL_BO_Batch Batch on Batch.BatchId=BatchDetail.BatchId --left join dbo.HJGL_CH_HotProessResult Result ON Result.JOT_ID=c.JOT_ID and Result.HotProessTrustId=c.HotProessTrustId --left join HJGL_HotProessItem HotProessItem on HotProessItem.JOT_ID = c.JOT_ID SELECT ROW_NUMBER() OVER(ORDER BY JointInfo.Sort1,JointInfo.Sort2,JointInfo.Sort3,JointInfo.Sort4,JointInfo.Sort5,ReportItem.SortIndex) as Number, ReportItem.HardTestReportItemId, --硬度检验报告明细id --ReportItem.HardTestReportId, -- 硬度检验报告id JointInfo.JOT_ID, --焊口id --ReportItem.TestPart, --试验部位 ReportItem.IsShow, JointInfo.ISO_ID, IsoInfo.ISO_IsoNo, JointInfo.JOT_JointNo+ ISNULL((SELECT TOP 1 RepairMark FROM dbo.HJGL_CH_HotProessTrustItem TrustItem LEFT JOIN dbo.HJGL_CH_RepairItemRecord AS record ON record.RepairItemRecordId=TrustItem.TrustItemID WHERE TrustItem.JOT_ID=JointInfo.JOT_ID AND TrustItem.HotProessTrustId=ReportItem.HotProessTrustId),'')+ ISNULL((SELECT TOP 1 HardRepairMark FROM dbo.HJGL_CH_HotProessTrustItem a WHERE a.JOT_ID=JointInfo.JOT_ID AND a.HotProessTrustId=ReportItem.HotProessTrustId AND a.ProessTypes='4'),'') AS JOT_JointNo, JointInfo.JOT_JointDesc, --规格 --(JointInfo.JOT_JointNo+ -- ISNULL((SELECT TOP 1 RepairMark FROM dbo.HJGL_CH_HotProessTrustItem TrustItem -- LEFT JOIN dbo.HJGL_CH_RepairItemRecord AS record ON record.RepairItemRecordId=TrustItem.TrustItemID -- WHERE TrustItem.JOT_ID=JointInfo.JOT_ID AND TrustItem.HotProessTrustId=ReportItem.HotProessTrustId),'')+ -- ISNULL((SELECT TOP 1 HardRepairMark FROM dbo.HJGL_CH_HotProessTrustItem a WHERE a.JOT_ID=JointInfo.JOT_ID AND a.HotProessTrustId=ReportItem.HotProessTrustId AND a.ProessTypes='4'),''))+'('+JointInfo.JOT_JointDesc+')' AS JOT_JointNoStr, (CASE WHEN Steel.STE_Code IS NOT NULL AND Steel2.STE_Code IS NOT NULL AND Steel.STE_Code!=Steel2.STE_Code THEN Steel.STE_Code + '/' + Steel2.STE_Code WHEN Steel.STE_Code IS NOT NULL THEN Steel.STE_Code ELSE ISNULL(Steel2.STE_Code,'') END) AS STE_Code, --材质 JointInfo.JOT_CellWelder, JointInfo.JOT_FloorWelder, (CASE WHEN JointInfo.JOT_CellWelder!=JointInfo.JOT_FloorWelder THEN Welder1.WED_Code+'/'+Welder2.WED_Code ELSE Welder1.WED_Code END) AS WED_Code, --焊工号 convert(nvarchar(10),HotProessItem.HotProessDate,111) as HotProessDate, --热处理日期 HotProessItem.RecordChartNo --曲线编号 FROM dbo.HJGL_PW_JointInfo AS JointInfo LEFT JOIN dbo.HJGL_CH_HardTestReportItem AS ReportItem ON JointInfo.JOT_ID = ReportItem.JOT_ID LEFT JOIN dbo.HJGL_PW_IsoInfo AS IsoInfo ON IsoInfo.ISO_ID = JointInfo.ISO_ID LEFT JOIN dbo.HJGL_BS_Steel AS Steel ON JointInfo.STE_ID = Steel.STE_ID LEFT JOIN dbo.HJGL_BS_Steel AS Steel2 ON Steel2.STE_ID =JointInfo.STE_ID2 LEFT JOIN dbo.HJGL_BS_Welder AS Welder1 ON Welder1.WED_ID = JointInfo.JOT_CellWelder LEFT JOIN dbo.HJGL_BS_Welder AS Welder2 ON Welder2.WED_ID = JointInfo.JOT_FloorWelder left join HJGL_HotProessItem HotProessItem on HotProessItem.JOT_ID = JointInfo.JOT_ID WHERE ReportItem.IsShow=1 and ReportItem.HardTestReportId = @HardTestReportId and ReportItem.TestPart='焊缝' union select 99999 as sort,null,null,null,null,null,'以下空白',null,null,null,null,null,null,null END GO