USE [HJGLDB_DS] GO /****** Object: View [dbo].[HJGL_View_CH_HardTestReportItem] Script Date: 2024/6/22 10:48:25 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO ALTER VIEW [dbo].[HJGL_View_CH_HardTestReportItem] /*硬度检验报告明细表查询列表*/ AS SELECT ReportItem.HardTestReportItemId, --硬度检验报告明细id ReportItem.HardTestReportId, -- 硬度检验报告id JointInfo.JOT_ID, --焊口id ReportItem.TestPart, --试验部位 ReportItem.HardNessValue AS HardNessValue1, ReportItem2.HardNessValue AS HardNessValue2, ReportItem3.HardNessValue AS HardNessValue3, ReportItem.IsShow, JointInfo.ISO_ID, IsoInfo.ISO_IsoNo, JointInfo.Sort1,JointInfo.Sort2,JointInfo.Sort3,JointInfo.Sort4,JointInfo.Sort5, ReportItem.HotProessTrustId, ReportItem.SortIndex, 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, ReportItem.Remark, ReportItem.Flag, 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, JointInfo.ProjectId, Project.ProjectCode, Project.ProjectName, Report.FileType, (SELECT TOP 1 r.HotHardCode FROM HJGL_CH_HardTestReportItem i LEFT JOIN HJGL_CH_HardTestReport r ON r.HardTestReportId=i.HardTestReportId WHERE i.JOT_ID=ReportItem.JOT_ID AND i.HotProessTrustId=ReportItem.HotProessTrustId AND (r.FileType='T' OR r.FileType IS NULL) ) AS HotHardCode, --v.HotHardCode, -- (SELECT TOP 1 HotHardCode as HotHardCode FROM dbo.HJGL_CH_HardTestReport --WHERE HardTestReportId =(SELECT TOP 1 re.HardTestReportId FROM dbo.HJGL_CH_HardTestReportItem item --left join dbo.HJGL_CH_HardTestReport re on item.HardTestReportId=re.HardTestReportId -- WHERE item.JOT_ID=ReportItem.JOT_ID AND item.HotProessTrustId=ReportItem.HotProessTrustId and (re.FileType='T' or re.FileType is null))) --AS HotHardCode, (CASE WHEN v.HardTestReportId IS NULL THEN ReportItem.HardTestReportId ELSE v.HardTestReportId END) AS THardTestReportId, (SELECT TOP 1 r.HardTestReportCode FROM HJGL_CH_HardTestReportItem i LEFT JOIN HJGL_CH_HardTestReport r ON r.HardTestReportId=i.HardTestReportId WHERE i.JOT_ID=ReportItem.JOT_ID AND i.HotProessTrustId=ReportItem.HotProessTrustId AND (r.FileType='R' OR r.FileType IS NULL) ) AS HardTestReportCode, --Report.HardTestReportCode, (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 --焊工号 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_CH_HardTestReport AS Report ON Report.HardTestReportId=ReportItem.HardTestReportId 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.Base_Project AS Project ON Project.ProjectId=JointInfo.ProjectId LEFT JOIN dbo.HJGL_CH_HardTestReportItem AS ReportItem2 ON JointInfo.JOT_ID=ReportItem2.JOT_ID AND ReportItem.HotProessTrustId=ReportItem2.HotProessTrustId AND ReportItem.SortIndex=ReportItem2.SortIndex AND ReportItem2.IsShow=0 LEFT JOIN dbo.HJGL_CH_HardTestReportItem AS ReportItem3 ON JointInfo.JOT_ID=ReportItem3.JOT_ID AND ReportItem.HotProessTrustId=ReportItem3.HotProessTrustId AND ReportItem.SortIndex=ReportItem3.SortIndex AND ReportItem3.IsShow IS NULL LEFT JOIN (SELECT TOP 1 r.HotHardCode,r.HardTestReportId,JOT_ID,HotProessTrustId FROM HJGL_CH_HardTestReportItem i LEFT JOIN HJGL_CH_HardTestReport r ON r.HardTestReportId=i.HardTestReportId WHERE (r.FileType='T' OR r.FileType IS NULL) ) v ON v.JOT_ID=ReportItem.JOT_ID AND v.HotProessTrustId=ReportItem.HotProessTrustId 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 WHERE ReportItem.IsShow=1 GO 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 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 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 where c.HardTestReportId = @HardTestReportId and c.TestPart='焊缝' --order by Number,c.SortIndex END GO