HJGL_DS/DataBase/版本日志/HJGLDB_DS_2024-10-22_gf.sql

133 lines
7.4 KiB
Transact-SQL
Raw Blame History

ALTER PROC [dbo].[HJGL_sp_StatisticsSampleTable]
@projectId NVARCHAR(50) = NULL,
@iso_isoNo VARCHAR(50) = NULL,
@isHotPress bit = NULL,
@Welded NVARCHAR(50) =NULL,
@ndtType NVARCHAR(10) = NULL,
@ndtResult NVARCHAR(20)=NULL
AS
/*********固셕湳깊 杳뉴<E69DB3>錦맣黨2022.11.30********/
SELECT
JointInfo.JOT_ID,
project.ProjectCode, --嘉묏뵀
IsoInfo.PressureTestPackageNo,--桿箕관긍뵀
IsoInfo.ISO_ID,
IsoInfo.ISO_IsoNo, --밗窟뵀
'1-'+IsoClass.ISC_IsoName+'-'+Ser.SER_Code+'-'+Steel.STE_Code AS ISO_Code, --밗돛긍뵀
IsoClass.ISC_IsoName, --밗돛된섬
Ser.SER_Name, --썽醴
IsoInfo.ISO_DesignPress, --<2D>셕箕제
IsoInfo.PipeLineClass, --밗돛잚깎
JointInfo.JOT_JointNo, --보룹긍뵀
JointInfo.JOT_JointDesc, --보룹방목
JointInfo.JOT_Location, --보쌈貫零
WeldMethod.WME_Name, --보쌈렘랬
JointType.JOTY_Code, --보룹잚謹
IsoInfo.ISO_Insulator, --없훑잚깎
IsoInfo.ISO_DesignTemperature, --<2D>셕侊똑
IsoInfo.ISO_TestPress, --켐箕桿駱
(CASE WHEN WeldMat.WMT_MatCode IS NOT NULL AND WeldSilk.WMT_MatCode IS NOT NULL and WeldMat.WMT_MatCode!=WeldSilk.WMT_MatCode
THEN WeldMat.WMT_MatCode + '/' + WeldSilk.WMT_MatCode
WHEN WeldMat.WMT_MatCode IS NOT NULL THEN WeldMat.WMT_MatCode
ELSE ISNULL(WeldSilk.WMT_MatCode,'') END) AS WeldMatSilkCode,
(CASE WHEN JointInfo.JOT_CellWelder!=JointInfo.JOT_FloorWelder THEN Welder1.WED_Code+'/'+Welder2.WED_Code ELSE Welder1.WED_Code END) AS WED_Code,
--Welder1.WED_Code,--보묏뵀
Steel.STE_Code,--꼼醴
Steel.STE_Name,--꼼醴잚謹
NDTRate.NDTR_Name,--뚤壇쇱꿎궐절
(CASE WHEN JointInfo.Jot_WeldingDate IS NOT NULL THEN JointInfo.Jot_WeldingDate
ELSE WeldReportMain.JOT_WeldDate END) AS JOT_WeldDate, --보쌈휑퍅
JointInfo.JOT_Size,--당쒔
Batch.BatchCode,--툽늴
BatchDetail.NDT, --쇱꿎렘駕Id
(CASE WHEN BatchDetail.PointType=2 THEN 'K' ELSE '' END) AS PointType,--윈탠뵀
JointInfo.JOT_Dia,--殮쓺
JointInfo.JOT_Sch, --귿비
(CASE WHEN JointInfo.RT_TrustCode IS NOT NULL THEN '' ELSE '' END) AS RTTrust, --RT官辜
JointInfo.RT_TrustCode, --RT官辜데긍뵀
JointInfo.RT_TrustDate AS RTTrustDate, --<2D>窟쇱꿎官辜휑퍅
JointInfo.RTFeedbackDate, --<2D>窟쇱꿎럽웩휑퍅
JointInfo.RT_States AS RTTestResult,--RT쇱꿎써벎
(CASE WHEN JointInfo.UT_TrustCode IS NOT NULL THEN '' ELSE '' END) AS UTTrust,--UT官辜
JointInfo.UT_States AS UTTestResult,--UT쇱꿎써벎
(CASE WHEN JointInfo.MT_TrustCode IS NOT NULL THEN '' ELSE '' END) AS MTTrust,--MT官辜
JointInfo.MT_States AS MTTestResult,--MT쇱꿎써벎
(CASE WHEN JointInfo.PT_TrustCode IS NOT NULL THEN '' ELSE '' END) AS PTTrust,--PT官辜
JointInfo.PT_TrustCode, --PT官辜데긍뵀
JointInfo.PT_TrustDate, --PT官辜휑퍅
JointInfo.PT_States AS PTTestResult,--PT쇱꿎써벎
(CASE WHEN JointInfo.PAUT_TrustCode IS NOT NULL THEN '' ELSE '' END) AS PAUTTrust, --PAUT官辜
JointInfo.PAUT_TrustCode, --PAUT官辜데긍뵀
JointInfo.PAUT_TrustDate AS PAUTTrustDate, --PAUT쇱꿎官辜휑퍅
JointInfo.PAUT_States AS PAUTTestResult,--PAUT쇱꿎써벎
(CASE WHEN (SELECT TOP 1 UnableCheck FROM dbo.HJGL_CH_TrustItem c WHERE c.JOT_ID=JointInfo.JOT_ID )=1
THEN '' ELSE '' END) AS UnableCheck,
(SELECT TOP 1 UnableCheckReason FROM dbo.HJGL_CH_TrustItem c WHERE c.JOT_ID=JointInfo.JOT_ID ) AS UnableCheckReason,
(CASE WHEN JointInfo.ProessTypes like '%4|5%' Then '句壇제훑뇹잿,洸땍뺏뇹잿'
WHEN JointInfo.ProessTypes like '%4%' Then '句壇제훑뇹잿'
WHEN JointInfo.ProessTypes like '%5%' Then '洸땍뺏뇹잿'
ELSE '' END) AS ProessTypes,--훑뇹잿잚謹
(case when JointInfo.ProessTypes like '%4%' or JointInfo.ProessTypes like '%5%' then 'Y'
else 'N' end) as IS_Proess,
(case when JointInfo.ProessTypes like '%1%' then 'Y'
else '' end) as IS_Preheating,
(select top 1 HotProessTrustCode from HJGL_CH_HotProessTrust t left join HJGL_CH_HotProessTrustItem i on t.HotProessTrustId=i.HotProessTrustId where i.JOT_ID=JointInfo.JOT_ID order by TrustDate desc)
as HotProessTrustCode, --훑뇹잿官辜긍뵀
JointInfo.HotProessTrustDate,--훑뇹잿官辜珂쇌
JointInfo.HotResultDate,--훑뇹잿럽웩珂쇌
(select top 1 HotHardCode from HJGL_CH_HardTestReport t left join HJGL_CH_HardTestReportItem i on t.HardTestReportId=i.HardTestReportId where i.JOT_ID=JointInfo.JOT_ID order by TestDate desc)
as HotHardCode, --袒똑官辜긍뵀
JointInfo.HardTrustDate,--袒똑官辜珂쇌
JointInfo.HardResultDate,--袒똑럽웩珂쇌
(case when JointInfo.HardTestResultOK=1 then '북목' when JointInfo.HardTestResultOK=0 then '꼇북목' else '' end) as HardResult,--袒똑쇱꿎써벎
BatchDetail.BatchDetailId
FROM dbo.HJGL_PW_JointInfo AS JointInfo
LEFT JOIN DBO.HJGL_BO_BatchDetail AS BatchDetail ON JointInfo.JOT_ID = BatchDetail.JOT_ID
LEFT JOIN DBO.HJGL_PW_IsoInfo AS IsoInfo ON IsoInfo.ISO_ID = JointInfo.ISO_ID
LEFT JOIN HJGL_BS_WeldMethod AS WeldMethod ON WeldMethod.WME_ID = JointInfo.WME_ID
LEFT JOIN HJGL_BS_JointType AS JointType ON JointType.JOTY_ID=JointInfo.JOTY_ID
LEFT JOIN DBO.HJGL_BO_Batch AS Batch ON Batch.BatchId = BatchDetail.BatchId
LEFT JOIN dbo.Base_Project project ON project.ProjectId=JointInfo.ProjectId
LEFT JOIN dbo.HJGL_BS_Steel AS Steel ON Steel.STE_ID = JointInfo.STE_ID
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_BO_WeldReportMain AS WeldReportMain ON WeldReportMain.DReportID = JointInfo.DReportID
LEFT JOIN dbo.HJGL_BS_NDTRate AS NDTRate ON NDTRate.NDTR_ID = JointInfo.NDTR_ID
LEFT JOIN dbo.HJGL_BS_IsoClass AS IsoClass ON IsoClass.ISC_ID =IsoInfo.ISC_ID
LEFT JOIN dbo.HJGL_BS_Service AS Ser ON Ser.SER_ID = IsoInfo.SER_ID
LEFT JOIN HJGL_BS_WeldMaterial AS WeldMat ON WeldMat.WMT_ID=JointInfo.JOT_WeldMat
LEFT JOIN HJGL_BS_WeldMaterial AS WeldSilk ON WeldSilk.WMT_ID=JointInfo.JOT_WeldSilk
WHERE (JointInfo.ProjectId=@projectId OR @projectId IS NULL)
AND ((CASE WHEN @ndtType='RT' THEN JointInfo.RT_TrustCode
WHEN @ndtType='PT' THEN JointInfo.PT_TrustCode
WHEN @ndtType='MT' THEN JointInfo.MT_TrustCode
WHEN @ndtType='UT' THEN JointInfo.UT_TrustCode
WHEN @ndtType='PAUT' THEN JointInfo.PAUT_TrustCode END) IS NOT NULL OR @ndtType IS NULL)
AND ((CASE WHEN @ndtType='RT' AND @ndtResult IS NOT NULL THEN JointInfo.RT_States
WHEN @ndtType='PT' AND @ndtResult IS NOT NULL THEN JointInfo.PT_States
WHEN @ndtType='MT' AND @ndtResult IS NOT NULL THEN JointInfo.MT_States
WHEN @ndtType='UT' AND @ndtResult IS NOT NULL THEN JointInfo.UT_States
WHEN @ndtType='PAUT' AND @ndtResult IS NOT NULL THEN JointInfo.PAUT_States END) =@ndtResult OR @ndtResult IS NULL)
AND ((case when JointInfo.DReportID IS NOT NULL then '1' else '2' end)=@Welded OR @Welded IS NULL)
AND (IsoInfo.ISO_IsoNo =@iso_isoNo OR @iso_isoNo IS NULL)
AND (((SELECT TOP 1 TrustDate from dbo.HJGL_CH_HotProessTrustItem a
WHERE a.JOT_ID=BatchDetail.JOT_ID and (a.ProessTypes='4' OR a.ProessTypes='5')) IS NOT NULL
AND @isHotPress=1) OR @isHotPress IS NULL)
ORDER BY project.ProjectCode,IsoInfo.ISO_IsoNo,JointInfo.JOT_JointNo
GO
delete from Sys_ButtonPower where MenuId='BD71676E-9680-4C52-8271-3257C9A0B656'
delete from Sys_RolePower where MenuId='BD71676E-9680-4C52-8271-3257C9A0B656'
delete from ButtonToMenu where MenuId='BD71676E-9680-4C52-8271-3257C9A0B656'
delete from Sys_Menu where MenuId='BD71676E-9680-4C52-8271-3257C9A0B656'
GO