HJGL_DS/DataBase/版本日志/HJGLDB_DS_2025-10-12_bwj.sql

61 lines
1.9 KiB
Transact-SQL

ALTER PROCEDURE [dbo].[HJGL_spCH_HotProessTrustItem]
(
@HotProessTrustId nvarchar(50),
@ProessTypes nvarchar(50)=null
)
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.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
and (c.ProessTypes=@ProessTypes or @ProessTypes is null)
) as t
--order by t.ISO_IsoNo,t.JOT_JointNo
union
select 99999999 as Number,null,null,null,null,'以下空白' AS ISO_IsoNo,null,null,null,null,null,null,null,null,null,null,null,null,null
order by Number
END
GO