HJGL_DS/DataBase/版本日志/HJGLDB_DS_2024-08-30_bwj.sql

153 lines
6.5 KiB
Transact-SQL

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