ALTER PROCEDURE [dbo].[HJGL_sp_rpt_TrustItem] ( @CH_TrustID NVARCHAR(50) ) AS /******项目管理部焊缝检测委托单明细表*******/ SELECT ROW_NUMBER() OVER(ORDER BY JointInfo.Sort1,JointInfo.Sort2,JointInfo.Sort3,JointInfo.Sort4,JointInfo.Sort5) as Sort, ROW_NUMBER() OVER(ORDER BY JointInfo.Sort1,JointInfo.Sort2,JointInfo.Sort3,JointInfo.Sort4,JointInfo.Sort5) as Number, TrustItem.CH_TrustItemID, TrustItem.CH_TrustID, iso.ISO_IsoNo, iso.ISO_IsoNo AS ISO_Number,--单线图 JointInfo.JOT_JointDesc,--焊缝规格 batch.BatchCode, (CASE WHEN batchDetail.PointType=2 THEN JointInfo.JOT_JointNo+'K' ELSE JointInfo.JOT_JointNo END) AS JOT_JointNo,--焊缝编号 (CASE WHEN JointInfo.JOT_CellWelder!=JointInfo.JOT_FloorWelder THEN Welder1.WED_Code+'/'+Welder2.WED_Code ELSE Welder1.WED_Code END) AS WED_Code,--焊工号 (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, --材质 (CASE WHEN (TrustItem.CH_Remark IS NULL OR TrustItem.CH_Remark='') AND jotR.JOT_JointNo IS NOT NULL THEN isoR.ISO_IsoNo+','+jotR.JOT_JointNo+' 返修' ELSE batchDetail.CheckAddress END) AS CH_Remark, --备注 isoClass.ISC_IsoName FROM HJGL_CH_TrustItem AS TrustItem LEFT JOIN dbo.HJGL_PW_JointInfo AS JointInfo ON JointInfo.JOT_ID = TrustItem.JOT_ID LEFT JOIN dbo.HJGL_BO_BatchDetail batchDetail on batchDetail.BatchDetailId=TrustItem.BatchDetailId LEFT JOIN dbo.HJGL_BO_Batch batch on batch.BatchId=batchDetail.BatchId LEFT JOIN dbo.HJGL_PW_IsoInfo iso on iso.ISO_ID=JointInfo.ISO_ID LEFT JOIN dbo.HJGL_BS_Steel AS Steel ON Steel.STE_ID = JointInfo.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 dbo.HJGL_CH_RepairItemRecord AS repair ON batchDetail.ToRepairId=repair.RepairItemRecordId LEFT JOIN dbo.HJGL_PW_JointInfo AS jotR ON jotR.JOT_ID = repair.JOT_ID LEFT JOIN dbo.HJGL_PW_IsoInfo AS isoR ON isoR.ISO_ID = repair.ISO_ID LEFT JOIN HJGL_BS_IsoClass AS isoClass ON isoClass.ISC_ID = iso.ISC_ID WHERE TrustItem.CH_TrustID=@CH_TrustID union SELECT 99999 as Sort,null, NEWID(), NULL, '以下空白' AS ISO_IsoNo,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL order by Sort GO ALTER PROCEDURE [dbo].[HJGL_sp_rpt_RepairItem] ( @CH_RepairID NVARCHAR(50) ) AS /******项目管理部返修焊缝检测委托单明细表*******/ SELECT ROW_NUMBER() OVER(ORDER BY JointInfo.Sort1,JointInfo.Sort2,JointInfo.Sort3,JointInfo.Sort4,JointInfo.Sort5) as Sort, ROW_NUMBER() OVER(ORDER BY JointInfo.Sort1,JointInfo.Sort2,JointInfo.Sort3,JointInfo.Sort4,JointInfo.Sort5) as Number, RepairItem.CH_RepairItemID, RepairItem.CH_RepairID, iso.ISO_IsoNo, batch.BatchCode, (JointInfo.JOT_JointNo+ (case when BatchDetail.PointType='2' then 'K' else '' end)+ '-'+isnull(RepairItem.FilmNum,'')+repairRecord.RepairMark) AS JOT_JointNo, --焊缝编号 (CASE WHEN JointInfo.JOT_CellWelder!=JointInfo.JOT_FloorWelder THEN FloorWelder.WED_Code+'/'+CellWelder.WED_Code ELSE FloorWelder.WED_Code END) AS WED_Code, --焊工号 JointInfo.JOT_JointDesc,--焊缝规格 (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, --材质 RepairItem.CheckPlace as CH_Remark,--备注 isoClass.ISC_IsoName FROM HJGL_CH_RepairItem AS RepairItem LEFT JOIN dbo.HJGL_PW_JointInfo AS JointInfo ON JointInfo.JOT_ID = RepairItem.JOT_ID LEFT JOIN dbo.HJGL_BO_BatchDetail AS BatchDetail ON JointInfo.JOT_ID = BatchDetail.JOT_ID LEFT JOIN dbo.HJGL_CH_Repair Repair on Repair.CH_RepairID=RepairItem.CH_RepairID LEFT JOIN dbo.HJGL_BO_Batch batch on batch.BatchId=Repair.BatchId LEFT JOIN dbo.HJGL_PW_IsoInfo iso on iso.ISO_ID=JointInfo.ISO_ID LEFT JOIN dbo.HJGL_BS_Steel AS Steel ON Steel.STE_ID = JointInfo.STE_ID LEFT JOIN dbo.HJGL_BS_Steel AS Steel2 ON Steel2.STE_ID=JointInfo.STE_ID2 LEFT JOIN dbo.HJGL_BS_Welder AS CellWelder ON CellWelder.WED_ID=JointInfo.JOT_CellWelder LEFT JOIN dbo.HJGL_BS_Welder AS FloorWelder ON FloorWelder.WED_ID=JointInfo.JOT_FloorWelder LEFT JOIN dbo.HJGL_CH_RepairItemRecord AS repairRecord ON repairRecord.RepairItemRecordId = RepairItem.RepairItemRecordId LEFT JOIN HJGL_BS_IsoClass AS isoClass ON isoClass.ISC_ID = iso.ISC_ID WHERE RepairItem.CH_RepairID=@CH_RepairID union select 99999 as Sort,null,null,null,null,'以下空白'AS BatchCode,null,null,null,null,null,null order by Sort GO ALTER PROCEDURE [dbo].[HJGL_spCH_HotProessTrustItem] ( @HotProessTrustId nvarchar(50) ) AS --通过检测id获取委托单信息 BEGIN select *, ProessTypes1+ (case when ProessTypes1<>'' and ProessTypes2<>'' then ','+ ProessTypes2 else ProessTypes2 end) +(case when (ProessTypes1<>'' or ProessTypes2<>'') and ProessTypes3<>'' then ','+ ProessTypes3 else ProessTypes3 end) +(case when (ProessTypes1<>'' or ProessTypes2<>'' or ProessTypes3<>'') and ProessTypes4<>'' then ','+ ProessTypes4 else ProessTypes4 end) +(case when (ProessTypes1<>'' or ProessTypes2<>'' or ProessTypes3<>'' or ProessTypes4<>'') and ProessTypes5<>'' then ','+ ProessTypes5 else ProessTypes5 end) as ProessTypes from ( select ROW_NUMBER() OVER(ORDER BY JOT_JointNo) as Sort, ROW_NUMBER() OVER(ORDER BY JOT_JointNo) as Number, c.HotProessTrustItemId, --热处理委托明细id c.HotProessTrustId, -- 热处理委托id c.JOT_ID, --焊口id c.TrustDate, c.ISO_IsoNo, c.JOT_JointNo, c.Remark, ProessTypes1 =case when ProessTypes like '%1%' then '预热' else '' end, ProessTypes2 =case when ProessTypes like '%2%' then '消氢' else '' end, ProessTypes3 =case when ProessTypes like '%3%' then '后热' else '' end, ProessTypes4 =case when ProessTypes like '%4%' then '消应力热处理' else '' end, ProessTypes5 =case when ProessTypes like '%5%' then '稳定化处理' else '' end, c.JOT_JointDesc, --规格 c.ProjectId, c.STE_Code, --材质 c.WME_Code, --焊接方法 c.WED_Code --焊工代号 from dbo.HJGL_View_CH_HotProessTrustItem c where c.HotProessTrustId = @HotProessTrustId ) as t --order by t.ISO_IsoNo,t.JOT_JointNo union select 9999 as Sort,null,null,null,null,null,'以下空白' AS ISO_IsoNo,null,null,null,null,null,null,null,null,null,null,null,null,null order by Sort END GO