HJGL_DS/DataBase/版本日志/HJGLDB_DS_2024-12-18_bwj.sql

99 lines
4.7 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_ID,
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,
JointInfo.JOTY_ID
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,null, '鹿苟왕겜' AS ISO_IsoNo,NULL,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_ID,
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,
JointInfo.JOTY_ID
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,null,'鹿苟왕겜'AS BatchCode,null,null,null,null,null,null,null
order by Sort
GO