This commit is contained in:
2026-01-21 17:31:29 +08:00
6 changed files with 410 additions and 6 deletions
@@ -0,0 +1,137 @@
ALTER PROC [dbo].[HJGL_sp_StatisticsSampleTable]
@projectId NVARCHAR(50) = NULL,
@iso_isoNo VARCHAR(50) = NULL,
@isHotPress bit = NULL,
@Welded NVARCHAR(50) =NULL,
@ndtType NVARCHAR(10) = NULL,
@ndtResult NVARCHAR(20)=NULL
AS
/*********统计样表 佘春生修改于2022.11.30********/
SELECT
JointInfo.JOT_ID,
project.ProjectCode, --施工号
IsoInfo.PressureTestPackageNo,--试压包编号
IsoInfo.ISO_ID,
IsoInfo.ISO_IsoNo, --管线号
'1-'+IsoClass.ISC_IsoName+'-'+Ser.SER_Code+'-'+Steel.STE_Code AS ISO_Code, --管道编号
IsoClass.ISC_IsoName, --管道等级
Ser.SER_Name, --介质
IsoInfo.ISO_DesignPress, --设计压力
IsoInfo.PipeLineClass, --管道类别
JointInfo.JOT_JointNo, --焊缝编号
JointInfo.JOT_JointDesc, --焊缝规格
JointInfo.JOT_Location, --焊接位置
WeldMethod.WME_Name, --焊接方法
JointType.JOTY_Code, --焊缝类型
JointType.JOTY_Group,
Sort1,Sort2,Sort3,Sort4,Sort5,
IsoInfo.ISO_Insulator, --绝热类别
IsoInfo.ISO_DesignTemperature, --设计温度
IsoInfo.ISO_TestPress, --耐压试验
(CASE WHEN WeldMat.WMT_MatCode IS NOT NULL AND WeldSilk.WMT_MatCode IS NOT NULL and WeldMat.WMT_MatCode!=WeldSilk.WMT_MatCode
THEN WeldMat.WMT_MatCode + '/' + WeldSilk.WMT_MatCode
WHEN WeldMat.WMT_MatCode IS NOT NULL THEN WeldMat.WMT_MatCode
ELSE ISNULL(WeldSilk.WMT_MatCode,'') END) AS WeldMatSilkCode,
(CASE WHEN JointInfo.JOT_CellWelder!=JointInfo.JOT_FloorWelder THEN Welder1.WED_Code+'/'+Welder2.WED_Code ELSE Welder1.WED_Code END) AS WED_Code,
--Welder1.WED_Code,--焊工号
Steel.STE_Code,--材质
Steel.STE_Name,--材质类型
NDTRate.NDTR_Name,--对应检测比例
(CASE WHEN JointInfo.Jot_WeldingDate IS NOT NULL THEN JointInfo.Jot_WeldingDate
ELSE WeldReportMain.JOT_WeldDate END) AS JOT_WeldDate, --焊接日期
JointInfo.JOT_Size,--寸经
Batch.BatchCode,--批次
BatchDetail.NDT, --检测方式Id
(CASE WHEN BatchDetail.PointType=2 THEN 'K' ELSE '' END) AS PointType,--扩拍号
JointInfo.JOT_Dia,--直径
JointInfo.JOT_Sch, --壁厚
(CASE WHEN JointInfo.RT_TrustCode IS NOT NULL THEN '' ELSE '' END) AS RTTrust, --RT委托
JointInfo.RT_TrustCode, --RT委托单编号
JointInfo.RT_TrustDate AS RTTrustDate, --射线检测委托日期
JointInfo.RTFeedbackDate, --射线检测反馈日期
JointInfo.RT_States AS RTTestResult,--RT检测结果
(CASE WHEN JointInfo.UT_TrustCode IS NOT NULL THEN '' ELSE '' END) AS UTTrust,--UT委托
JointInfo.UT_States AS UTTestResult,--UT检测结果
(CASE WHEN JointInfo.MT_TrustCode IS NOT NULL THEN '' ELSE '' END) AS MTTrust,--MT委托
JointInfo.MT_States AS MTTestResult,--MT检测结果
(CASE WHEN JointInfo.PT_TrustCode IS NOT NULL THEN '' ELSE '' END) AS PTTrust,--PT委托
JointInfo.PT_TrustCode, --PT委托单编号
JointInfo.PT_TrustDate, --PT委托日期
JointInfo.PT_States AS PTTestResult,--PT检测结果
(CASE WHEN JointInfo.PAUT_TrustCode IS NOT NULL THEN '' ELSE '' END) AS PAUTTrust, --PAUT委托
JointInfo.PAUT_TrustCode, --PAUT委托单编号
JointInfo.PAUT_TrustDate AS PAUTTrustDate, --PAUT检测委托日期
JointInfo.PAUT_States AS PAUTTestResult,--PAUT检测结果
(CASE WHEN (SELECT TOP 1 UnableCheck FROM dbo.HJGL_CH_TrustItem c WHERE c.JOT_ID=JointInfo.JOT_ID )=1
THEN '' ELSE '' END) AS UnableCheck,
(SELECT TOP 1 UnableCheckReason FROM dbo.HJGL_CH_TrustItem c WHERE c.JOT_ID=JointInfo.JOT_ID ) AS UnableCheckReason,
(CASE WHEN JointInfo.ProessTypes like '%4|5%' Then '消应力热处理,稳定化处理'
WHEN JointInfo.ProessTypes like '%4%' Then '消应力热处理'
WHEN JointInfo.ProessTypes like '%5%' Then '稳定化处理'
ELSE '' END) AS ProessTypes,--热处理类型
(case when JointInfo.ProessTypes like '%4%' or JointInfo.ProessTypes like '%5%' then 'Y'
else 'N' end) as IS_Proess,
(case when JointInfo.ProessTypes like '%1%' then 'Y'
else '' end) as IS_Preheating,
(select top 1 HotProessTrustCode from HJGL_CH_HotProessTrust t left join HJGL_CH_HotProessTrustItem i on t.HotProessTrustId=i.HotProessTrustId where i.JOT_ID=JointInfo.JOT_ID order by TrustDate desc)
as HotProessTrustCode, --热处理委托编号
JointInfo.HotProessTrustDate,--热处理委托时间
(select top 1 HotStartDate from HJGL_HotProessItem hpi where hpi.JOT_ID=JointInfo.JOT_ID) as HotStartDate, --热处理开始时间
JointInfo.HotResultDate,--热处理反馈时间
(select top 1 HotHardCode from HJGL_CH_HardTestReport t left join HJGL_CH_HardTestReportItem i on t.HardTestReportId=i.HardTestReportId where i.JOT_ID=JointInfo.JOT_ID order by TestDate desc)
as HotHardCode, --硬度委托编号
JointInfo.HardTrustDate,--硬度委托时间
JointInfo.HardResultDate,--硬度反馈时间
(case when JointInfo.HardTestResultOK=1 then '合格' when JointInfo.HardTestResultOK=0 then '不合格' else '' end) as HardResult,--硬度检测结果
BatchDetail.BatchDetailId
FROM dbo.HJGL_PW_JointInfo AS JointInfo
LEFT JOIN DBO.HJGL_BO_BatchDetail AS BatchDetail ON JointInfo.JOT_ID = BatchDetail.JOT_ID
LEFT JOIN DBO.HJGL_PW_IsoInfo AS IsoInfo ON IsoInfo.ISO_ID = JointInfo.ISO_ID
LEFT JOIN HJGL_BS_WeldMethod AS WeldMethod ON WeldMethod.WME_ID = JointInfo.WME_ID
LEFT JOIN HJGL_BS_JointType AS JointType ON JointType.JOTY_ID=JointInfo.JOTY_ID
LEFT JOIN DBO.HJGL_BO_Batch AS Batch ON Batch.BatchId = BatchDetail.BatchId
LEFT JOIN dbo.Base_Project project ON project.ProjectId=JointInfo.ProjectId
LEFT JOIN dbo.HJGL_BS_Steel AS Steel ON Steel.STE_ID = JointInfo.STE_ID
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 DBO.HJGL_BO_WeldReportMain AS WeldReportMain ON WeldReportMain.DReportID = JointInfo.DReportID
LEFT JOIN dbo.HJGL_BS_NDTRate AS NDTRate ON NDTRate.NDTR_ID = JointInfo.NDTR_ID
LEFT JOIN dbo.HJGL_BS_IsoClass AS IsoClass ON IsoClass.ISC_ID =IsoInfo.ISC_ID
LEFT JOIN dbo.HJGL_BS_Service AS Ser ON Ser.SER_ID = IsoInfo.SER_ID
LEFT JOIN HJGL_BS_WeldMaterial AS WeldMat ON WeldMat.WMT_ID=JointInfo.JOT_WeldMat
LEFT JOIN HJGL_BS_WeldMaterial AS WeldSilk ON WeldSilk.WMT_ID=JointInfo.JOT_WeldSilk
WHERE (JointInfo.ProjectId=@projectId OR @projectId IS NULL)
AND ((CASE WHEN @ndtType='RT' THEN JointInfo.RT_TrustCode
WHEN @ndtType='PT' THEN JointInfo.PT_TrustCode
WHEN @ndtType='MT' THEN JointInfo.MT_TrustCode
WHEN @ndtType='UT' THEN JointInfo.UT_TrustCode
WHEN @ndtType='PAUT' THEN JointInfo.PAUT_TrustCode END) IS NOT NULL OR @ndtType IS NULL)
AND ((CASE WHEN @ndtType='RT' AND @ndtResult IS NOT NULL THEN JointInfo.RT_States
WHEN @ndtType='PT' AND @ndtResult IS NOT NULL THEN JointInfo.PT_States
WHEN @ndtType='MT' AND @ndtResult IS NOT NULL THEN JointInfo.MT_States
WHEN @ndtType='UT' AND @ndtResult IS NOT NULL THEN JointInfo.UT_States
WHEN @ndtType='PAUT' AND @ndtResult IS NOT NULL THEN JointInfo.PAUT_States END) =@ndtResult OR @ndtResult IS NULL)
AND ((case when JointInfo.DReportID IS NOT NULL then '1' else '2' end)=@Welded OR @Welded IS NULL)
AND (IsoInfo.ISO_IsoNo =@iso_isoNo OR @iso_isoNo IS NULL)
AND (((SELECT TOP 1 TrustDate from dbo.HJGL_CH_HotProessTrustItem a
WHERE a.JOT_ID=BatchDetail.JOT_ID and (a.ProessTypes='4' OR a.ProessTypes='5')) IS NOT NULL
AND @isHotPress=1) OR @isHotPress IS NULL)
ORDER BY project.ProjectCode,IsoInfo.ISO_IsoNo,JointInfo.JOT_JointNo
GO