194 lines
20 KiB
Transact-SQL
194 lines
20 KiB
Transact-SQL
|
||
ALTER PROC [dbo].[sp_rpt_JointComprehensive]
|
||
@projectId NVARCHAR(50),
|
||
@workAreaId NVARCHAR(50)=NULL,
|
||
@pipelineIds NVARCHAR(MAX) = NULL
|
||
|
||
AS
|
||
/**********焊口综合信息**********/
|
||
SELECT
|
||
weldJoint.WeldJointId,
|
||
weldJoint.ProjectId,
|
||
WorkArea.WorkAreaId,
|
||
WorkArea.WorkAreaCode,
|
||
weldJoint.SystemNumber,
|
||
weldJoint.TestPackageNo,
|
||
pipeline.SingleNumber,
|
||
pipeline.PipelineCode,
|
||
pipeline.DrawingsNum,
|
||
weldJoint.PageNum,
|
||
weldJoint.PipeSegment,--所属管段
|
||
(CASE WHEN weldJoint.JointAttribute='固定F' THEN 'F'+weldJoint.WeldJointCode ELSE 'S'+weldJoint.WeldJointCode END) AS WeldJointCode,
|
||
weldType.WeldTypeCode,
|
||
weldJoint.JointAttribute,
|
||
wl.WeldingLocationCode,
|
||
weldJoint.Dia,
|
||
weldJoint.Thickness,--壁厚
|
||
weldJoint.HeartNo1,
|
||
weldJoint.HeartNo2,
|
||
com1.ComponentsName AS PipeAssembly1,
|
||
com2.ComponentsName AS PipeAssembly2,
|
||
--material.MaterialCode,
|
||
mat1.MaterialCode AS MaterialCode1,
|
||
mat2.MaterialCode AS MaterialCode2,
|
||
cw.WelderCode AS CoverWelderCode,
|
||
fw.WelderCode AS BackingWelderCode,
|
||
WeldMethod.WeldingMethodName,
|
||
medium.MediumName,
|
||
weldingDaily.WeldingDate,
|
||
weldingDaily.WeldingDailyCode,
|
||
trust.TrustBatchCode,
|
||
--TrustBatchCode.DetectionRateCode,
|
||
--TrustBatchCode.AcceptLevel,
|
||
(CASE WHEN weldJoint.IsHotProess=1 THEN '是' ELSE '否' END) AS IsHotProess,
|
||
null as TrustBatchCode,
|
||
null as DetectionRateCode,
|
||
null as AcceptLevel,
|
||
nde.NDEDate AS CHT_CHECKDATE,
|
||
ndeItem.NDEReportNo,
|
||
CAST(CAST(ISNULL(weldJoint.Size,0) AS REAL) AS NVARCHAR(8)) AS JOT_Size,
|
||
WeldMaterialMat.ConsumablesCode AS WMT_MatCode,
|
||
WeldMaterialMat.ConsumablesName AS WMT_Matname,
|
||
weldJoint.WeldSilkId,
|
||
--WeldMaterialSilk.ConsumablesCode AS hsCode,
|
||
--WeldMaterialSilk.ConsumablesName AS hsname,
|
||
--WeldMaterialSilk.UserFlux,
|
||
weldJoint.Specification,
|
||
wps.WPQCode,ndttype.DetectionTypeCode,NULL AS HotReportCode,
|
||
(CASE WHEN (PointBatchItem.PointState='1' OR PointBatchItem.PointState='2')
|
||
THEN (CASE WHEN PointBatchItem.IsWelderFirst=1 THEN '是首三口' ELSE '是' END) ELSE '否' END) AS if_dk
|
||
FROM Pipeline_WeldJoint AS weldJoint
|
||
LEFT JOIN Pipeline_Pipeline AS pipeline ON pipeline.PipelineId = weldJoint.PipelineId
|
||
LEFT JOIN Project_WorkArea AS WorkArea ON WorkArea.WorkAreaId = pipeline.WorkAreaId
|
||
LEFT JOIN Base_Material AS mat1 ON mat1.MaterialId = weldJoint.Material1Id
|
||
LEFT JOIN Base_Material AS mat2 ON mat2.MaterialId = weldJoint.Material2Id
|
||
LEFT JOIN Base_WeldingMethod AS WeldMethod ON WeldMethod.WeldingMethodId = weldJoint.WeldingMethodId
|
||
LEFT JOIN dbo.Base_WeldType weldType ON weldType.WeldTypeId = weldJoint.WeldTypeId
|
||
LEFT JOIN dbo.Base_WeldingLocation wl ON wl.WeldingLocationId = weldJoint.WeldingLocationId
|
||
LEFT JOIN Base_Medium AS medium ON medium.MediumId = pipeline.MediumId
|
||
LEFT JOIN Base_Components com1 ON com1.ComponentsId=weldJoint.PipeAssembly1Id
|
||
LEFT JOIN Base_Components com2 ON com2.ComponentsId=weldJoint.PipeAssembly2Id
|
||
LEFT JOIN Pipeline_WeldingDaily AS weldingDaily ON weldingDaily.WeldingDailyId = weldJoint.WeldingDailyId
|
||
LEFT JOIN dbo.WPQ_WPQList wps ON wps.WPQId = weldJoint.WPQId
|
||
left join Welder_Welder AS fw on weldJoint.BackingWelderId = fw.WelderId
|
||
left join Welder_Welder AS cw on weldJoint.CoverWelderId = cw.WelderId
|
||
LEFT JOIN Base_Consumables AS WeldMaterialMat ON WeldMaterialMat.ConsumablesId =weldJoint.WeldMatId
|
||
--LEFT JOIN Base_Consumables AS WeldMaterialSilk ON WeldMaterialSilk.ConsumablesId =weldJoint.WeldSilkId
|
||
LEFT JOIN Batch_PointBatchItem AS PointBatchItem ON PointBatchItem.WeldJointId =weldJoint.WeldJointId
|
||
LEFT JOIN dbo.Batch_PointBatch point ON point.PointBatchId = PointBatchItem.PointBatchId
|
||
LEFT JOIN dbo.Base_DetectionType ndttype ON ndttype.DetectionTypeId = point.DetectionTypeId
|
||
LEFT JOIN dbo.Batch_BatchTrustItem trustItem ON trustItem.PointBatchItemId = PointBatchItem.PointBatchItemId
|
||
LEFT JOIN dbo.Batch_BatchTrust trust ON trust.TrustBatchId = trustItem.TrustBatchId
|
||
LEFT JOIN dbo.Batch_NDEItem ndeItem ON ndeItem.TrustBatchItemId = trustItem.TrustBatchItemId
|
||
LEFT JOIN dbo.Batch_NDE nde ON nde.NDEID = ndeItem.NDEID
|
||
|
||
WHERE weldJoint.ProjectId=@projectId
|
||
AND(pipeline.WorkAreaId=@workAreaId OR @workAreaId IS NULL)
|
||
AND (CHARINDEX(weldJoint.PipelineId,@pipelineIds)>0 or @pipelineIds IS NULl)
|
||
--AND(pipeline.PipelineCode=@pipelineCode OR @pipelineCode IS NULl)
|
||
|
||
GO
|
||
|
||
|
||
|
||
ALTER PROCEDURE [dbo].[Sp_WeekWelding]
|
||
(
|
||
@ProjectId nvarchar(50),
|
||
@InstallationId nvarchar(50),
|
||
@WorkAreaId NVARCHAR(1000)=NULL,
|
||
@WeldingDate DATETIME,
|
||
@WelderCode NVARCHAR(20)=NULL
|
||
)
|
||
AS
|
||
SELECT t.WelderCode, t.WeldingSize AS TotalSize, ISNULL(t1.WeldingSize,0) AS week1,ISNULL(t2.WeldingSize,0) AS week2, ISNULL(t3.WeldingSize,0) AS week3,
|
||
ISNULL(t4.WeldingSize,0) AS week4,ISNULL(t5.WeldingSize,0) AS week5,ISNULL(t6.WeldingSize,0) AS week6,ISNULL(t7.WeldingSize,0) AS week7
|
||
FROM
|
||
(SELECT jot.ProjectId,pipe.InstallationId, welder.WelderCode, sum(isnull(jot.Size,0)) as WeldingSize
|
||
FROM Pipeline_WeldJoint jot
|
||
LEFT JOIN dbo.Pipeline_Pipeline pipe ON pipe.PipelineId = jot.PipelineId
|
||
left join Pipeline_WeldingDaily daily on jot.WeldingDailyId=daily.WeldingDailyId
|
||
left join dbo.Welder_Welder welder ON welder.WelderId = jot.BackingWelderId
|
||
WHERE daily.WeldingDate>=@WeldingDate and daily.WeldingDate<=DATEADD(DAY,6,@WeldingDate)
|
||
AND (CHARINDEX(pipe.WorkAreaId,@WorkAreaId)>0 or @WorkAreaId IS NULl)
|
||
--AND (CHARINDEX(welder.WelderCode,@WelderCodes)>0 or @WelderCodes IS NULl)
|
||
GROUP BY jot.ProjectId,pipe.InstallationId, welder.WelderCode)t
|
||
|
||
LEFT JOIN
|
||
(SELECT jot.ProjectId,pipe.InstallationId, welder.WelderCode, sum(isnull(jot.Size,0)) as WeldingSize
|
||
FROM Pipeline_WeldJoint jot
|
||
LEFT JOIN dbo.Pipeline_Pipeline pipe ON pipe.PipelineId = jot.PipelineId
|
||
left join Pipeline_WeldingDaily daily on jot.WeldingDailyId=daily.WeldingDailyId
|
||
left join dbo.Welder_Welder welder ON welder.WelderId = jot.BackingWelderId
|
||
where daily.WeldingDate=@WeldingDate AND (CHARINDEX(pipe.WorkAreaId,@WorkAreaId)>0 or @WorkAreaId IS NULl)
|
||
GROUP BY jot.ProjectId,pipe.InstallationId,welder.WelderCode)t1
|
||
ON t1.ProjectId = t.ProjectId AND t1.InstallationId = t.InstallationId AND t1.WelderCode = t.WelderCode
|
||
|
||
LEFT JOIN
|
||
(SELECT jot.ProjectId,pipe.InstallationId, welder.WelderCode, sum(isnull(jot.Size,0)) as WeldingSize
|
||
FROM Pipeline_WeldJoint jot
|
||
LEFT JOIN dbo.Pipeline_Pipeline pipe ON pipe.PipelineId = jot.PipelineId
|
||
left join Pipeline_WeldingDaily daily on jot.WeldingDailyId=daily.WeldingDailyId
|
||
left join dbo.Welder_Welder welder ON welder.WelderId = jot.BackingWelderId
|
||
WHERE daily.WeldingDate=DATEADD(DAY,1,@WeldingDate) AND (CHARINDEX(pipe.WorkAreaId,@WorkAreaId)>0 or @WorkAreaId IS NULl)
|
||
GROUP BY jot.ProjectId,pipe.InstallationId,welder.WelderCode)t2
|
||
ON t2.ProjectId = t.ProjectId AND t2.InstallationId = t.InstallationId AND t2.WelderCode = t.WelderCode
|
||
|
||
LEFT JOIN
|
||
(SELECT jot.ProjectId,pipe.InstallationId, welder.WelderCode, sum(isnull(jot.Size,0)) as WeldingSize
|
||
FROM Pipeline_WeldJoint jot
|
||
LEFT JOIN dbo.Pipeline_Pipeline pipe ON pipe.PipelineId = jot.PipelineId
|
||
left join Pipeline_WeldingDaily daily on jot.WeldingDailyId=daily.WeldingDailyId
|
||
left join dbo.Welder_Welder welder ON welder.WelderId = jot.BackingWelderId
|
||
WHERE daily.WeldingDate=DATEADD(DAY,2,@WeldingDate) AND (CHARINDEX(pipe.WorkAreaId,@WorkAreaId)>0 or @WorkAreaId IS NULl)
|
||
GROUP BY jot.ProjectId,pipe.InstallationId,welder.WelderCode)t3
|
||
ON t3.ProjectId = t.ProjectId AND t3.InstallationId = t.InstallationId AND t3.WelderCode = t.WelderCode
|
||
|
||
LEFT JOIN
|
||
(SELECT jot.ProjectId,pipe.InstallationId, welder.WelderCode, sum(isnull(jot.Size,0)) as WeldingSize
|
||
FROM Pipeline_WeldJoint jot
|
||
LEFT JOIN dbo.Pipeline_Pipeline pipe ON pipe.PipelineId = jot.PipelineId
|
||
left join Pipeline_WeldingDaily daily on jot.WeldingDailyId=daily.WeldingDailyId
|
||
left join dbo.Welder_Welder welder ON welder.WelderId = jot.BackingWelderId
|
||
WHERE daily.WeldingDate=DATEADD(DAY,3,@WeldingDate) AND (CHARINDEX(pipe.WorkAreaId,@WorkAreaId)>0 or @WorkAreaId IS NULl)
|
||
GROUP BY jot.ProjectId,pipe.InstallationId,welder.WelderCode)t4
|
||
ON t4.ProjectId = t.ProjectId AND t4.InstallationId = t.InstallationId AND t4.WelderCode = t.WelderCode
|
||
|
||
LEFT JOIN
|
||
(SELECT jot.ProjectId,pipe.InstallationId, welder.WelderCode, sum(isnull(jot.Size,0)) as WeldingSize
|
||
FROM Pipeline_WeldJoint jot
|
||
LEFT JOIN dbo.Pipeline_Pipeline pipe ON pipe.PipelineId = jot.PipelineId
|
||
left join Pipeline_WeldingDaily daily on jot.WeldingDailyId=daily.WeldingDailyId
|
||
left join dbo.Welder_Welder welder ON welder.WelderId = jot.BackingWelderId
|
||
WHERE daily.WeldingDate=DATEADD(DAY,4,@WeldingDate) AND (CHARINDEX(pipe.WorkAreaId,@WorkAreaId)>0 or @WorkAreaId IS NULl)
|
||
GROUP BY jot.ProjectId,pipe.InstallationId,welder.WelderCode)t5
|
||
ON t5.ProjectId = t.ProjectId AND t5.InstallationId = t.InstallationId AND t5.WelderCode = t.WelderCode
|
||
|
||
LEFT JOIN
|
||
(SELECT jot.ProjectId,pipe.InstallationId, welder.WelderCode, sum(isnull(jot.Size,0)) as WeldingSize
|
||
FROM Pipeline_WeldJoint jot
|
||
LEFT JOIN dbo.Pipeline_Pipeline pipe ON pipe.PipelineId = jot.PipelineId
|
||
left join Pipeline_WeldingDaily daily on jot.WeldingDailyId=daily.WeldingDailyId
|
||
left join dbo.Welder_Welder welder ON welder.WelderId = jot.BackingWelderId
|
||
WHERE daily.WeldingDate=DATEADD(DAY,5,@WeldingDate) AND (CHARINDEX(pipe.WorkAreaId,@WorkAreaId)>0 or @WorkAreaId IS NULl)
|
||
GROUP BY jot.ProjectId,pipe.InstallationId,welder.WelderCode)t6
|
||
ON t6.ProjectId = t.ProjectId AND t6.InstallationId = t.InstallationId AND t6.WelderCode = t.WelderCode
|
||
|
||
LEFT JOIN
|
||
(SELECT jot.ProjectId,pipe.InstallationId, welder.WelderCode, sum(isnull(jot.Size,0)) as WeldingSize
|
||
FROM Pipeline_WeldJoint jot
|
||
LEFT JOIN dbo.Pipeline_Pipeline pipe ON pipe.PipelineId = jot.PipelineId
|
||
left join Pipeline_WeldingDaily daily on jot.WeldingDailyId=daily.WeldingDailyId
|
||
left join dbo.Welder_Welder welder ON welder.WelderId = jot.BackingWelderId
|
||
WHERE daily.WeldingDate=DATEADD(DAY,6,@WeldingDate) AND (CHARINDEX(pipe.WorkAreaId,@WorkAreaId)>0 or @WorkAreaId IS NULl)
|
||
GROUP BY jot.ProjectId,pipe.InstallationId,welder.WelderCode)t7
|
||
ON t7.ProjectId = t.ProjectId AND t7.InstallationId = t.InstallationId AND t7.WelderCode = t.WelderCode
|
||
|
||
WHERE t.ProjectId=@ProjectId AND t.InstallationId=t.InstallationId
|
||
--t.WorkAreaId=@WorkAreaId
|
||
AND (t.WelderCode LIKE '%'+@WelderCode+'%' OR @WelderCode IS NULl)
|
||
|
||
|
||
GO
|
||
|
||
|