102 lines
5.9 KiB
Transact-SQL
102 lines
5.9 KiB
Transact-SQL
insert into Sys_Menu(MenuId,MenuName,Url,SortIndex,SuperMenu,MenuModule)
|
|
values('C2D55C90-59BE-4400-9BCD-D0A8B72B3F2B','焊缝返修台账','HJGL/WeldingReport/WeldRepairLists.aspx',250,'F3B157B7-9BEE-4150-6666-087828F1C51D','3')
|
|
go
|
|
|
|
CREATE PROCEDURE [dbo].[HJGL_rpt_RepairLists]
|
|
(
|
|
@projectId NVARCHAR(50) =null
|
|
)
|
|
AS
|
|
/************返修台账************/
|
|
select distinct jointInfo.JOT_ID,jointInfo.ISO_ID,isoInfo.ISO_IsoNo,jointInfo.JOT_JointNo,jointInfo.JOT_JointDesc,
|
|
(case when Steel.STE_Code is not null
|
|
then (case when Steel2.STE_Code is not null and Steel.STE_Code<>Steel2.STE_Code
|
|
then Steel.STE_Code+'/'+Steel2.STE_Code
|
|
else Steel.STE_Code end)
|
|
else Steel2.STE_Code end) as SteelCode,--材质
|
|
rate.NDTR_Name,
|
|
----------初次焊接--------------
|
|
(case when Welder.WED_Code is not null
|
|
then (case when FloorWelder.WED_Code is not null and Welder.WED_Code<>FloorWelder.WED_Code
|
|
then Welder.WED_Code+'/'+FloorWelder.WED_Code
|
|
else Welder.WED_Code end)
|
|
else FloorWelder.WED_Code end) as WelderCode, --焊工号
|
|
(CASE WHEN JointInfo.Jot_WeldingDate IS NOT NULL THEN JointInfo.Jot_WeldingDate
|
|
ELSE WeldReportMain.JOT_WeldDate END) AS JOT_WeldDate, --焊接日期
|
|
(SELECT TOP 1 PostHeatingDate FROM dbo.HJGL_HotProessItem HotProessItem WHERE HotProessItem.JOT_ID=jointInfo.JOT_ID) as PostHeatingDate,--后热日期
|
|
null as PostHeatingCode,--后热曲线编号
|
|
(SELECT TOP 1 HotProessDate FROM dbo.HJGL_HotProessItem HotProessItem WHERE HotProessItem.JOT_ID=jointInfo.JOT_ID) as HotProessDate,--热处理日期
|
|
(SELECT TOP 1 RecordChartNo FROM dbo.HJGL_HotProessItem HotProessItem WHERE HotProessItem.JOT_ID=jointInfo.JOT_ID and RecordChartNo is not null and RecordChartNo!='') AS RecordChartNo,--热处理曲线编号
|
|
CONVERT(VARCHAR,(case when jointInfo.RT_States is not null and jointInfo.RT_States='检测合格' then jointInfo.RT_TrustDate
|
|
else (case when jointInfo.UT_States is not null and jointInfo.UT_States='检测合格' then jointInfo.UT_TrustDate
|
|
else (case when jointInfo.MT_States is not null and jointInfo.MT_States='检测合格' then jointInfo.MT_TrustDate
|
|
else (case when jointInfo.PT_States is not null and jointInfo.PT_States='检测合格' then jointInfo.PT_TrustDate
|
|
else (case when jointInfo.PAUT_States is not null and jointInfo.PAUT_States='检测合格' then jointInfo.PAUT_TrustDate
|
|
else null end) end)end) end) end),23) as TestDate,--检测日期
|
|
---------------------------------
|
|
------------一返------------
|
|
repairItemRecord.RepairWelderCode1,--焊工号
|
|
repairItemRecord.WeldDate as RepairWeldDate1,--焊接日期
|
|
null as RepairPostHeatingDate1,--后热日期
|
|
null as RepairPostHeatingCode1,--后热曲线编号
|
|
CONVERT(VARCHAR,repairItemRecord.TrustDate,23) as RepairHotDate1,--热处理日期
|
|
null as RepairRecordChartNo1,--热处理曲线编号
|
|
null as RepairTestDate1,--检测日期
|
|
---------------------------------
|
|
------------二返------------
|
|
repairItemRecord2.RepairWelderCode2,--焊工号
|
|
repairItemRecord2.WeldDate as RepairWeldDate2,--焊接日期
|
|
null as RepairPostHeatingDate2,--后热日期
|
|
null as RepairPostHeatingCode2,--后热曲线编号
|
|
CONVERT(VARCHAR,repairItemRecord2.TrustDate,23) as RepairHotDate2,--热处理日期
|
|
null as RepairRecordChartNo2,---热处理曲线编号
|
|
null as RepairTestDate2,--检测日期
|
|
---------------------------------
|
|
------------硬度------------
|
|
--第一次时间
|
|
--第一次时间
|
|
--第一次时间
|
|
---------------------------------
|
|
jointType.JOTY_Group,
|
|
jointInfo.Sort1,
|
|
jointInfo.Sort2,
|
|
jointInfo.Sort3,
|
|
jointInfo.Sort4,
|
|
jointInfo.Sort5
|
|
from HJGL_PW_JointInfo jointInfo
|
|
left join HJGL_PW_IsoInfo as isoInfo on isoInfo.ISO_ID = jointInfo.ISO_ID
|
|
LEFT JOIN HJGL_BS_Steel AS Steel ON Steel.STE_ID=jointInfo.STE_ID
|
|
LEFT JOIN HJGL_BS_Steel AS Steel2 ON Steel2.STE_ID=jointInfo.STE_ID2
|
|
LEFT JOIN HJGL_BS_JointType AS jointType ON jointType.JOTY_ID=jointInfo.JOTY_ID
|
|
left join HJGL_BS_NDTRate as rate on rate.NDTR_ID = jointInfo.NDTR_ID
|
|
LEFT JOIN HJGL_BS_Welder AS Welder ON Welder.WED_ID= jointInfo.JOT_CellWelder
|
|
LEFT JOIN HJGL_BS_Welder AS FloorWelder ON FloorWelder.WED_ID=jointInfo.JOT_FloorWelder
|
|
LEFT JOIN HJGL_BO_WeldReportMain AS WeldReportMain ON WeldReportMain.DReportID=jointInfo.DReportID
|
|
--一返
|
|
--一返
|
|
left join (select distinct HJGL_CH_RepairItemRecord.JOT_ID,(case when Welder.WED_Code is not null
|
|
then (case when FloorWelder.WED_Code is not null and Welder.WED_Code<>FloorWelder.WED_Code
|
|
then Welder.WED_Code+'/'+FloorWelder.WED_Code
|
|
else Welder.WED_Code end)
|
|
else FloorWelder.WED_Code end) as RepairWelderCode1,CONVERT(VARCHAR, WeldDate, 23) as WeldDate,hotProessTrustItem.TrustDate
|
|
from HJGL_CH_RepairItemRecord
|
|
LEFT JOIN HJGL_BS_Welder AS Welder ON Welder.WED_ID= HJGL_CH_RepairItemRecord.JOT_CellWelder
|
|
LEFT JOIN HJGL_BS_Welder AS FloorWelder ON FloorWelder.WED_ID=HJGL_CH_RepairItemRecord.JOT_FloorWelder
|
|
left join HJGL_CH_HotProessTrustItem as hotProessTrustItem on hotProessTrustItem.TrustItemID = HJGL_CH_RepairItemRecord.RepairItemRecordId
|
|
where RepairMark='R1') as repairItemRecord on repairItemRecord.JOT_ID = jointInfo.JOT_ID
|
|
----二返
|
|
left join (select distinct HJGL_CH_RepairItemRecord.JOT_ID,(case when Welder.WED_Code is not null
|
|
then (case when FloorWelder.WED_Code is not null and Welder.WED_Code<>FloorWelder.WED_Code
|
|
then Welder.WED_Code+'/'+FloorWelder.WED_Code
|
|
else Welder.WED_Code end)
|
|
else FloorWelder.WED_Code end) as RepairWelderCode2,CONVERT(VARCHAR, WeldDate, 23) as WeldDate,hotProessTrustItem.TrustDate
|
|
from HJGL_CH_RepairItemRecord
|
|
LEFT JOIN HJGL_BS_Welder AS Welder ON Welder.WED_ID= HJGL_CH_RepairItemRecord.JOT_CellWelder
|
|
LEFT JOIN HJGL_BS_Welder AS FloorWelder ON FloorWelder.WED_ID=HJGL_CH_RepairItemRecord.JOT_FloorWelder
|
|
left join HJGL_CH_HotProessTrustItem as hotProessTrustItem on hotProessTrustItem.TrustItemID = HJGL_CH_RepairItemRecord.RepairItemRecordId
|
|
where RepairMark='R2') as repairItemRecord2 on repairItemRecord2.JOT_ID = jointInfo.JOT_ID
|
|
|
|
where jointInfo.JOT_ID in (select JOT_ID from HJGL_CH_RepairItem)
|
|
and (jointInfo.ProjectId=@projectId or @projectId is null)
|
|
order by isoInfo.ISO_IsoNo,jointType.JOTY_Group,jointInfo.Sort1,jointInfo.Sort2,jointInfo.Sort3,jointInfo.Sort4,jointInfo.Sort5
|
|
go |