220 lines
20 KiB
Transact-SQL
220 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,--所属管段
|
||
weldJoint.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 VIEW [dbo].[View_Batch_BatchTrustItem]
|
||
AS
|
||
/********无损委托********/
|
||
SELECT
|
||
ROW_NUMBER() OVER(ORDER BY WeldJointCode) AS Number,
|
||
BatchTrustItem.TrustBatchItemId,
|
||
BatchTrustItem.TrustBatchId,
|
||
BatchTrustItem.PointBatchItemId,
|
||
BatchTrustItem.WeldJointId,
|
||
BatchTrustItem.CreateDate,
|
||
BatchTrustItem.TrustNum,
|
||
BatchTrust.TrustType,
|
||
BatchTrustItem.RepairNum,
|
||
BatchTrustItem.FilmNum,
|
||
BatchTrust.TrustBatchCode, --委托单号
|
||
BatchTrust.ProjectId,
|
||
CONVERT(VARCHAR(10),BatchTrust.TrustDate,120) AS TrustDate,
|
||
BatchTrust.InstallationId,
|
||
ins.InstallationCode, --装置
|
||
area.WorkAreaCode, --工区号
|
||
pipe.PipelineCode, --管线号
|
||
pipingClass.PipingClassCode, --管线等级
|
||
(CASE WHEN PointBatchItem.PointState='2' THEN jot.WeldJointCode+'K'
|
||
ELSE jot.WeldJointCode END) AS WeldJointCode, --焊口号
|
||
--jot.WeldJointCode,
|
||
mat.MaterialCode, --材质
|
||
jot.JointArea, --焊接区域
|
||
welder.WelderCode AS WelderCode, --焊工号
|
||
weldType.WeldTypeCode, --焊缝类型
|
||
CONVERT(FLOAT,jot.Dia) AS Dia, --外径
|
||
CONVERT(FLOAT,jot.Size) AS Size, --寸径
|
||
CONVERT(FLOAT,jot.Thickness) AS Thickness, --壁厚
|
||
method.WeldingMethodCode, --焊接方法
|
||
jot.Specification,
|
||
jot.Remark,
|
||
CAST(rate.DetectionRateValue AS VARCHAR(10))+'%' AS DetectionRateCode,
|
||
PointBatchItem.PointDate, --点口日期
|
||
(CASE WHEN dtype.SysType !='射线检测' THEN 'Ⅰ' ELSE PointBatchItem.AcceptLevel END) AS AcceptLevel, --合格等级
|
||
pipe.Sheet, --页数
|
||
PipingClass.PNO,
|
||
(CASE WHEN BatchTrustItem.IsCancelTrust=1 THEN '已取消' ELSE '' END) AS IsCancelTrust,
|
||
(CASE WHEN PointBatchItem.IsWelderFirst=1 THEN '是' ELSE '' END) AS IsWelderFirst
|
||
FROM Batch_BatchTrustItem AS BatchTrustItem
|
||
LEFT JOIN dbo.Batch_BatchTrust AS BatchTrust ON BatchTrust.TrustBatchId=BatchTrustItem.TrustBatchId
|
||
LEFT JOIN dbo.Base_DetectionType dtype ON dtype.DetectionTypeId = BatchTrust.DetectionTypeId
|
||
LEFT JOIN Batch_PointBatchItem AS PointBatchItem ON PointBatchItem.PointBatchItemId=BatchTrustItem.PointBatchItemId
|
||
LEFT JOIN dbo.Batch_PointBatch point ON point.PointBatchId = PointBatchItem.PointBatchId
|
||
LEFT JOIN dbo.Base_DetectionRate rate ON rate.DetectionRateId = point.DetectionRateId
|
||
LEFT JOIN dbo.Pipeline_WeldJoint jot ON jot.WeldJointId = BatchTrustItem.WeldJointId
|
||
LEFT JOIN dbo.Pipeline_Pipeline pipe ON pipe.PipelineId = jot.PipelineId
|
||
LEFT JOIN Base_PipingClass AS pipingClass ON PipingClass.PipingClassId=pipe.PipingClassId
|
||
LEFT JOIN dbo.Project_Installation ins ON ins.InstallationId = BatchTrust.InstallationId
|
||
LEFT JOIN dbo.Project_WorkArea area ON pipe.WorkAreaId=area.WorkAreaId
|
||
LEFT JOIN dbo.Base_WeldType weldType ON weldType.WeldTypeId = jot.WeldTypeId
|
||
LEFT JOIN dbo.Welder_Welder welder ON welder.WelderId = jot.BackingWelderId
|
||
LEFT JOIN dbo.Base_Material mat ON mat.MaterialId = jot.Material1Id
|
||
LEFT JOIN dbo.Base_WeldingMethod method ON method.WeldingMethodId = jot.WeldingMethodId
|
||
|
||
|
||
|
||
GO
|
||
|
||
|
||
|
||
ALTER VIEW [dbo].[View_Batch_BatchTrustItemSelect]
|
||
AS
|
||
/********无损委托********/
|
||
SELECT
|
||
BatchTrustItem.TrustBatchItemId,
|
||
BatchTrustItem.TrustBatchId,
|
||
BatchTrustItem.PointBatchItemId,
|
||
BatchTrustItem.WeldJointId,
|
||
BatchTrustItem.CreateDate,
|
||
BatchTrustItem.TrustNum,
|
||
BatchTrust.TrustType,
|
||
BatchTrustItem.RepairNum,
|
||
BatchTrustItem.FilmNum,
|
||
BatchTrust.TrustBatchCode, --委托单号
|
||
BatchTrust.ProjectId,
|
||
CONVERT(VARCHAR(10),BatchTrust.TrustDate,120) AS TrustDate,
|
||
BatchTrust.InstallationId,
|
||
ins.InstallationCode, --装置
|
||
area.WorkAreaCode, --工区号
|
||
pipe.PipelineCode, --管线号
|
||
pipingClass.PipingClassCode, --管线等级
|
||
(CASE WHEN PointBatchItem.PointState='2' THEN jot.WeldJointCode+'K'
|
||
ELSE jot.WeldJointCode END) AS WeldJointCode, --焊口号
|
||
--jot.WeldJointCode,
|
||
mat.MaterialCode, --材质
|
||
jot.JointArea, --焊接区域
|
||
welder.WelderCode AS WelderCode, --焊工号
|
||
weldType.WeldTypeCode, --焊缝类型
|
||
CONVERT(FLOAT,jot.Dia) AS Dia, --外径
|
||
CONVERT(FLOAT,jot.Size) AS Size, --寸径
|
||
CONVERT(FLOAT,jot.Thickness) AS Thickness, --壁厚
|
||
method.WeldingMethodCode, --焊接方法
|
||
jot.Specification,
|
||
jot.Remark,
|
||
CAST(rate.DetectionRateValue AS VARCHAR(10))+'%' AS DetectionRateCode,
|
||
PointBatchItem.PointDate, --点口日期
|
||
(CASE WHEN dtype.SysType !='射线检测' THEN 'Ⅰ' ELSE PointBatchItem.AcceptLevel END) AS AcceptLevel, --合格等级
|
||
pipe.Sheet, --页数
|
||
PipingClass.PNO,
|
||
(CASE WHEN BatchTrustItem.IsCancelTrust=1 THEN '已取消' ELSE '' END) AS IsCancelTrust,
|
||
(CASE WHEN PointBatchItem.IsWelderFirst=1 THEN '是' ELSE '' END) AS IsWelderFirst
|
||
FROM Batch_BatchTrustItem AS BatchTrustItem
|
||
LEFT JOIN dbo.Batch_BatchTrust AS BatchTrust ON BatchTrust.TrustBatchId=BatchTrustItem.TrustBatchId
|
||
LEFT JOIN dbo.Base_DetectionType dtype ON dtype.DetectionTypeId = BatchTrust.DetectionTypeId
|
||
LEFT JOIN Batch_PointBatchItem AS PointBatchItem ON PointBatchItem.PointBatchItemId=BatchTrustItem.PointBatchItemId
|
||
LEFT JOIN dbo.Batch_PointBatch point ON point.PointBatchId = PointBatchItem.PointBatchId
|
||
LEFT JOIN dbo.Base_DetectionRate rate ON rate.DetectionRateId = point.DetectionRateId
|
||
LEFT JOIN dbo.Pipeline_WeldJoint jot ON jot.WeldJointId = BatchTrustItem.WeldJointId
|
||
LEFT JOIN dbo.Pipeline_Pipeline pipe ON pipe.PipelineId = jot.PipelineId
|
||
LEFT JOIN Base_PipingClass AS pipingClass ON PipingClass.PipingClassId=pipe.PipingClassId
|
||
LEFT JOIN dbo.Project_Installation ins ON ins.InstallationId = BatchTrust.InstallationId
|
||
LEFT JOIN dbo.Project_WorkArea area ON pipe.WorkAreaId=area.WorkAreaId
|
||
LEFT JOIN dbo.Base_WeldType weldType ON weldType.WeldTypeId = jot.WeldTypeId
|
||
LEFT JOIN dbo.Welder_Welder welder ON welder.WelderId = jot.BackingWelderId
|
||
LEFT JOIN dbo.Base_Material mat ON mat.MaterialId = jot.Material1Id
|
||
LEFT JOIN dbo.Base_WeldingMethod method ON method.WeldingMethodId = jot.WeldingMethodId
|
||
|
||
|
||
|
||
GO
|
||
|
||
|
||
|
||
|