51 lines
1.9 KiB
Transact-SQL
51 lines
1.9 KiB
Transact-SQL
ALTER PROCEDURE [dbo].[HJGL_spCH_HotProessTrustItem]
|
|
(
|
|
@HotProessTrustId nvarchar(50),
|
|
@ProessTypes nvarchar(50)=null
|
|
)
|
|
AS
|
|
--通过检测id获取委托单信息
|
|
BEGIN
|
|
SELECT
|
|
HotProessTrustId,ISO_IsoNo,JOT_JointNo,JOT_JointDesc,STE_Code,Sort1,Sort2,Sort3,Sort4,Sort5,
|
|
STUFF(
|
|
(
|
|
SELECT '+' + CASE
|
|
WHEN t.ProessTypes = '1' THEN '预热'
|
|
WHEN t.ProessTypes = '2' THEN '消氢'
|
|
WHEN t.ProessTypes = '3' THEN '后热'
|
|
WHEN t.ProessTypes = '4' THEN '消应力热处理'
|
|
WHEN t.ProessTypes = '5' THEN '稳定化处理'
|
|
ELSE ''
|
|
END
|
|
FROM HJGL_View_CH_HotProessTrustItem t
|
|
WHERE
|
|
t.HotProessTrustId = TrustItem.HotProessTrustId
|
|
AND t.ISO_IsoNo = TrustItem.ISO_IsoNo
|
|
AND t.JOT_JointNo = TrustItem.JOT_JointNo
|
|
AND t.JOT_JointDesc = TrustItem.JOT_JointDesc
|
|
AND t.STE_Code = TrustItem.STE_Code
|
|
AND t.Sort1 = TrustItem.Sort1
|
|
AND t.Sort2 = TrustItem.Sort2
|
|
AND t.Sort3 = TrustItem.Sort3
|
|
AND t.Sort4 = TrustItem.Sort4
|
|
AND t.Sort5 = TrustItem.Sort5
|
|
ORDER BY t.ProessTypes -- 按 ProessTypes 排序拼接
|
|
FOR XML PATH(''), TYPE
|
|
).value('.', 'NVARCHAR(MAX)'),
|
|
1, 1, '' -- 去掉开头的 '+'
|
|
) AS ProessTypes
|
|
FROM HJGL_View_CH_HotProessTrustItem TrustItem
|
|
WHERE
|
|
HotProessTrustId=@HotProessTrustId
|
|
and (ProessTypes=@ProessTypes or @ProessTypes is null)
|
|
GROUP BY
|
|
HotProessTrustId,ISO_IsoNo,JOT_JointNo,JOT_JointDesc,STE_Code,Sort1,Sort2,Sort3,Sort4,Sort5
|
|
|
|
union
|
|
|
|
select '99999999' as Number,'以下空白' AS ISO_IsoNo,null,null,null,null,null,null,null,null,null
|
|
|
|
|
|
ORDER BY ISO_IsoNo,JOT_JointNo,Sort1,Sort2,Sort3,Sort4,Sort5
|
|
end |