225 lines
11 KiB
Transact-SQL
225 lines
11 KiB
Transact-SQL
|
|
alter table [dbo].[HJGL_Pipeline] add SingleName nvarchar(50) null
|
|||
|
|
GO
|
|||
|
|
|
|||
|
|
|
|||
|
|
ALTER VIEW [dbo].[View_HJGL_Pipeline]
|
|||
|
|
AS
|
|||
|
|
/*************管线视图*****************/
|
|||
|
|
SELECT pipeline.PipelineId,
|
|||
|
|
pipeline.ProjectId,
|
|||
|
|
pipeline.UnitId,
|
|||
|
|
pipeline.UnitWorkId,
|
|||
|
|
pipeline.PipelineCode,
|
|||
|
|
pipeline.SingleName,
|
|||
|
|
pipeline.SingleNumber,
|
|||
|
|
pipeline.PipingClassId,
|
|||
|
|
pipeline.MediumId,
|
|||
|
|
pipingClass.PipingClassCode,
|
|||
|
|
pipeline.DetectionRateId,
|
|||
|
|
rate.DetectionRateCode,
|
|||
|
|
pipeline.DetectionType,
|
|||
|
|
pipeline.TestPressure,
|
|||
|
|
pipeline.TestMedium,
|
|||
|
|
pipeline.PressurePipingClassId,
|
|||
|
|
pc.PressurePipingClassCode,
|
|||
|
|
pipeline.PipeLenth,
|
|||
|
|
pipeline.DesignPress,
|
|||
|
|
pipeline.DesignTemperature,
|
|||
|
|
pipeline.Remark,
|
|||
|
|
pipeline.LeakPressure,
|
|||
|
|
pipeline.LeakMedium,
|
|||
|
|
pipeline.VacuumPressure,
|
|||
|
|
pipeline.PCMedium ,
|
|||
|
|
pipeline.PCtype,
|
|||
|
|
pipeline.MaterialId,
|
|||
|
|
mat.MaterialCode,
|
|||
|
|
lea.MediumName as LeakMediumName,
|
|||
|
|
pur.PurgeMethodName as PCMediumName,
|
|||
|
|
CAST((SELECT SUM(ISNULL(Size,0)) FROM dbo.HJGL_WeldJoint WHERE PipelineId=pipeline.PipelineId) AS DECIMAL(8,3)) AS TotalDin,
|
|||
|
|
(SELECT COUNT(WeldJointId) FROM dbo.HJGL_WeldJoint WHERE PipelineId=pipeline.PipelineId) AS JointCount,
|
|||
|
|
unit.UnitName,
|
|||
|
|
workArea.UnitWorkCode,
|
|||
|
|
medium.MediumCode,
|
|||
|
|
testMedium.MediumCode AS TestMediumCode
|
|||
|
|
FROM dbo.HJGL_Pipeline AS pipeline
|
|||
|
|
LEFT JOIN Base_PipingClass AS pipingClass ON pipingClass.PipingClassId=pipeline.PipingClassId
|
|||
|
|
LEFT JOIN dbo.Base_Unit AS unit ON unit.UnitId=pipeline.UnitId
|
|||
|
|
LEFT JOIN WBS_UnitWork AS workArea ON workArea.UnitWorkId=pipeline.UnitWorkId
|
|||
|
|
LEFT JOIN Base_Medium AS medium ON medium.MediumId=pipeline.MediumId
|
|||
|
|
LEFT JOIN dbo.Base_TestMedium AS testMedium ON testMedium.TestMediumId=pipeline.TestMedium
|
|||
|
|
LEFT JOIN dbo.Base_DetectionRate rate ON rate.DetectionRateId = pipeline.DetectionRateId
|
|||
|
|
LEFT JOIN dbo.Base_PressurePipingClass pc ON pc.PressurePipingClassId = pipeline.PressurePipingClassId
|
|||
|
|
LEFT JOIN dbo.Base_TestMedium AS lea ON lea.TestMediumId=pipeline.LeakMedium
|
|||
|
|
LEFT JOIN dbo.Base_PurgeMethod AS pur ON pur.PurgeMethodId=pipeline.PCMedium
|
|||
|
|
LEFT JOIN dbo.Base_Material AS mat ON mat.MaterialId=pipeline.MaterialId
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
GO
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
ALTER VIEW [dbo].[View_HJGL_WeldJoint]
|
|||
|
|
AS
|
|||
|
|
SELECT jot.[ProjectId] --项目Id
|
|||
|
|
,pipe.[UnitWorkId] --单位工程Id
|
|||
|
|
,uw.UnitWorkName --单位工程
|
|||
|
|
,pipe.[UnitId] --单位Id
|
|||
|
|
,unit.UnitName --单位
|
|||
|
|
,jot.[PipelineCode] --管线号
|
|||
|
|
,pipe.[SingleNumber] --单线图号
|
|||
|
|
,pipe.[SingleName] --图纸名称
|
|||
|
|
,pipe.[MediumId] --介质Id
|
|||
|
|
,medium.MediumCode
|
|||
|
|
,medium.MediumName --介质名称
|
|||
|
|
,pipe.[PipingClassId] --管道等级Id
|
|||
|
|
,pipingClass.PipingClassCode --管道等级
|
|||
|
|
,pipe.[DetectionRateId] --探伤比例Id
|
|||
|
|
,dr.DetectionRateCode --探伤比例(例如5,10,20)
|
|||
|
|
,pipe.DetectionType --探伤类型Id(可能多个,中间用|分隔)
|
|||
|
|
,stuff((select ',' + DetectionTypeCode from Base_DetectionType
|
|||
|
|
where charindex('|'+ltrim(DetectionTypeId)+'|','|'+ pipe.DetectionType + '|') > 0 for xml path('') ), 1, 1, '') as DetectionTypeStr --探伤类型(可能多个,中间用,分隔)
|
|||
|
|
,pipe.DesignTemperature --设计温度℃
|
|||
|
|
,pipe.DesignPress --设计压力Mpa(g)
|
|||
|
|
,pipe.TestMedium --压力试验介质Id
|
|||
|
|
,tm.MediumName as TestMediumName --压力试验介质
|
|||
|
|
,pipe.TestPressure --压力试验压力Mpa(g)
|
|||
|
|
,pipe.PressurePipingClassId --压力管道级别Id
|
|||
|
|
,ppc.PressurePipingClassCode --压力管道级别
|
|||
|
|
,pipe.PipeLenth --管线长度(m)
|
|||
|
|
,pipe.LeakMedium --泄露性试验介质Id
|
|||
|
|
,tm2.MediumName as LeakMediumName --泄露性试验介质
|
|||
|
|
,pipe.LeakPressure --泄露性试验压力Mpa(g)
|
|||
|
|
,pipe.PCMedium --吹洗要求Id
|
|||
|
|
,pm.PurgeMethodCode --吹洗要求
|
|||
|
|
,pipe.VacuumPressure --真空试验压力Kpa(a)
|
|||
|
|
,pipe.MaterialId --材质Id
|
|||
|
|
,mat.MaterialCode as PipeMaterialCode --材质
|
|||
|
|
,pipe.Remark as PipeRemark --备注
|
|||
|
|
|
|||
|
|
,jot.[WeldJointId] --焊口Id
|
|||
|
|
,jot.[WeldJointCode] --焊口号
|
|||
|
|
,jot.[Material1Id] --材质1Id
|
|||
|
|
,mat1.MaterialCode AS Material1Code --材质1
|
|||
|
|
,jot.[Material2Id] --材质2Id
|
|||
|
|
,mat2.MaterialCode AS Material2Code --材质2
|
|||
|
|
,jot.[Dia] --外径
|
|||
|
|
,jot.[Size] --达因
|
|||
|
|
,jot.[Thickness] --壁厚
|
|||
|
|
,jot.[Specification] --规格
|
|||
|
|
,jot.[WeldTypeId] --焊缝类型Id
|
|||
|
|
,WeldType.WeldTypeCode --焊缝类型
|
|||
|
|
,jot.[DetectionTypeId] --检测类型Id
|
|||
|
|
,ndt.DetectionTypeCode --检测类型
|
|||
|
|
,jot.[Components1Id] --组件1号Id
|
|||
|
|
,com1.ComponentsCode AS ComponentsCode1 --组件1号
|
|||
|
|
,jot.[Components2Id] --组件2号Id
|
|||
|
|
,com2.ComponentsCode AS ComponentsCode2 --组件2号
|
|||
|
|
,jot.DesignIsHotProess --是否热处理
|
|||
|
|
,case jot.DesignIsHotProess when 1 then '是' else '否' end as DesignIsHotProessStr --是否热处理
|
|||
|
|
,jot.[WeldingMethodId] --焊接方法Id
|
|||
|
|
,WeldingMethod.WeldingMethodCode --焊接方法
|
|||
|
|
,jot.WPQId --WPS的Id
|
|||
|
|
,wps.WPQCode --WPS编号
|
|||
|
|
,jot.[GrooveTypeId] --坡口类型Id
|
|||
|
|
,GrooveType.GrooveTypeCode --坡口类型
|
|||
|
|
,jot.[WeldingRod] --焊条Id
|
|||
|
|
,rod.ConsumablesCode AS WeldingRodCode --焊条
|
|||
|
|
,jot.[WeldingWire] --焊丝Id
|
|||
|
|
,wire.ConsumablesCode AS WeldingWireCode --焊丝
|
|||
|
|
,jot.PreTemperature --预热温度
|
|||
|
|
,jot.[JointAttribute] --焊口属性
|
|||
|
|
,CONVERT(VARCHAR(100), daily.WeldingDate, 23) AS WeldingDate --焊接日期
|
|||
|
|
,BackingWelder.WelderCode as BackingWelderCode --打底焊工
|
|||
|
|
,CoverWelder.WelderCode as CoverWelderCode --盖面焊工
|
|||
|
|
,(case (select COUNT(*) from [dbo].[HJGL_HotProess_TrustItem] hpti
|
|||
|
|
where hpti.WeldJointId=jot.WeldJointId) when 0 then '' else (select top 1 isnull(ReportNo,'') from [dbo].[HJGL_HotProess_Trust] hpt
|
|||
|
|
left join [dbo].[HJGL_HotProess_TrustItem] hpti on hpti.HotProessTrustId=hpt.HotProessTrustId
|
|||
|
|
where hpti.WeldJointId=jot.WeldJointId) end) as HotProessReportNo --热处理报告编号
|
|||
|
|
,(case (select top 1 IsCompleted from [dbo].[HJGL_HotProess_TrustItem] hpti
|
|||
|
|
where hpti.WeldJointId=jot.WeldJointId) when 1 then '完成' when 0 then '未完成' else '未热处理' end) as HotProessResult --热处理检测结果
|
|||
|
|
,(case (select COUNT(*) from [dbo].HJGL_Hard_TrustItem hti
|
|||
|
|
where hti.WeldJointId=jot.WeldJointId) when 0 then '' else (select top 1 isnull(InspectionNum,'') from [dbo].HJGL_Hard_Trust ht
|
|||
|
|
left join [dbo].HJGL_Hard_TrustItem hti on hti.HardTrustID=ht.HardTrustID
|
|||
|
|
where hti.WeldJointId=jot.WeldJointId) end) as HardReportNo --硬度报告编号
|
|||
|
|
,(case (select top 1 IsPass from [dbo].HJGL_Hard_TrustItem hti
|
|||
|
|
where hti.WeldJointId=jot.WeldJointId) when 1 then '合格' when 0 then '不合格' else '待检测' end) as HardResult --硬度检测结果
|
|||
|
|
,(case (select COUNT(*) from [dbo].HJGL_Batch_BatchTrustItem bti
|
|||
|
|
where bti.WeldJointId=jot.WeldJointId) when 0 then '' else (select top 1 TrustBatchCode from [dbo].HJGL_Batch_BatchTrust bt
|
|||
|
|
left join [dbo].HJGL_Batch_BatchTrustItem bti on bti.TrustBatchId=bt.TrustBatchId
|
|||
|
|
where bti.WeldJointId=jot.WeldJointId) end) as TrustBatchCode --委托单编号
|
|||
|
|
,(case (select COUNT(*) from [dbo].HJGL_Batch_NDEItem ndei
|
|||
|
|
left join [dbo].HJGL_Batch_BatchTrustItem bti on bti.TrustBatchItemId=ndei.TrustBatchItemId
|
|||
|
|
where bti.WeldJointId=jot.WeldJointId) when 0 then '' else (select top 1 isnull(NDECode,'') from [dbo].HJGL_Batch_NDE nde
|
|||
|
|
left join [dbo].HJGL_Batch_NDEItem ndei on ndei.NDEID=nde.NDEID
|
|||
|
|
left join [dbo].HJGL_Batch_BatchTrustItem bti on bti.TrustBatchItemId=ndei.TrustBatchItemId
|
|||
|
|
where bti.WeldJointId=jot.WeldJointId) end) as NDECode --检测单编号
|
|||
|
|
,(case (select top 1 CheckResult from [dbo].HJGL_Batch_NDEItem ndei
|
|||
|
|
left join [dbo].HJGL_Batch_BatchTrustItem bti on bti.TrustBatchItemId=ndei.TrustBatchItemId
|
|||
|
|
where bti.WeldJointId=jot.WeldJointId) when '1' then '合格' when '2' then '不合格' else '' end) as CheckResult --检测结果
|
|||
|
|
,jot.PipelineId
|
|||
|
|
,jot.[JointArea]
|
|||
|
|
,jot.[WeldingLocationId]
|
|||
|
|
,jot.[HeartNo1]
|
|||
|
|
,jot.[HeartNo2]
|
|||
|
|
,jot.[IsHotProess]
|
|||
|
|
,jot.[WeldingDailyId]
|
|||
|
|
,jot.[BackingWelderId]
|
|||
|
|
,jot.[CoverWelderId]
|
|||
|
|
,jot.WeldingMode
|
|||
|
|
,jot.Remark
|
|||
|
|
,WeldingLocation.WeldingLocationCode
|
|||
|
|
,CASE WHEN jot.WeldingDailyId IS NULL THEN '否' ELSE '是' END AS IsWelding
|
|||
|
|
,CASE WHEN jot.IsHotProess=1 THEN '是' ELSE '否' END AS IsHotProessStr,
|
|||
|
|
BackingWelder.PersonName AS BackingWelderName,
|
|||
|
|
CoverWelder.PersonName AS CoverWelderName,
|
|||
|
|
(CASE WHEN CoverWelder.WelderCode IS NOT NULL AND BackingWelder.WelderCode IS NOT NULL
|
|||
|
|
THEN CoverWelder.WelderCode + '/' + BackingWelder.WelderCode
|
|||
|
|
ELSE (ISNULL(CoverWelder.WelderCode,'') + ISNULL(BackingWelder.WelderCode,'')) END) AS WelderCode, --焊工
|
|||
|
|
(CASE WHEN mat1.MaterialCode IS NOT NULL AND mat2.MaterialCode IS NOT NULL
|
|||
|
|
THEN mat1.MaterialCode + '/' + mat2.MaterialCode
|
|||
|
|
ELSE (ISNULL(mat1.MaterialCode,'') + ISNULL(mat2.MaterialCode,'')) END) AS MaterialCode, --材质
|
|||
|
|
|
|||
|
|
daily.WeldingDailyCode,
|
|||
|
|
pointItem.PointBatchId,
|
|||
|
|
point.PointBatchCode,
|
|||
|
|
(CASE WHEN pointItem.PointState='1' THEN '已点口' WHEN pointItem.PointState='2' THEN '已扩透' ELSE '' END) AS IsPoint
|
|||
|
|
FROM [dbo].[HJGL_WeldJoint] jot
|
|||
|
|
LEFT JOIN dbo.HJGL_Pipeline pipe ON pipe.PipelineId=jot.PipelineId
|
|||
|
|
LEFT JOIN dbo.WBS_UnitWork uw ON uw.UnitWorkId=pipe.UnitWorkId
|
|||
|
|
LEFT JOIN dbo.Base_Unit unit ON unit.UnitId=pipe.UnitId
|
|||
|
|
LEFT JOIN Base_WeldType AS WeldType ON WeldType.WeldTypeId=jot.WeldTypeId
|
|||
|
|
LEFT JOIN dbo.Base_DetectionRate dr ON dr.DetectionRateId = pipe.DetectionRateId
|
|||
|
|
LEFT JOIN Base_TestMedium tm ON tm.TestMediumId=pipe.TestMedium
|
|||
|
|
LEFT JOIN Base_TestMedium tm2 ON tm2.TestMediumId=pipe.LeakMedium
|
|||
|
|
LEFT JOIN Base_PurgeMethod pm ON pm.PurgeMethodId=pipe.PCMedium
|
|||
|
|
LEFT JOIN Base_PressurePipingClass ppc ON ppc.PressurePipingClassId=pipe.PressurePipingClassId
|
|||
|
|
LEFT JOIN Base_Material AS mat ON mat.MaterialId = pipe.MaterialId
|
|||
|
|
LEFT JOIN Base_Material AS mat1 ON mat1.MaterialId = jot.Material1Id
|
|||
|
|
LEFT JOIN Base_Material AS mat2 ON mat2.MaterialId = jot.Material2Id
|
|||
|
|
LEFT JOIN Base_WeldingMethod AS WeldingMethod ON WeldingMethod.WeldingMethodId=jot.WeldingMethodId
|
|||
|
|
LEFT JOIN Base_WeldingLocation AS WeldingLocation ON WeldingLocation.WeldingLocationId=jot.WeldingLocationId
|
|||
|
|
LEFT JOIN Base_Consumables AS wire ON wire.ConsumablesId=jot.WeldingWire
|
|||
|
|
LEFT JOIN Base_Consumables AS rod ON rod.ConsumablesId=jot.WeldingRod
|
|||
|
|
LEFT JOIN Base_GrooveType AS GrooveType ON GrooveType.GrooveTypeId=jot.GrooveTypeId
|
|||
|
|
LEFT JOIN Base_Components AS com1 ON com1.ComponentsId = jot.Components1Id
|
|||
|
|
LEFT JOIN Base_Components AS com2 ON com2.ComponentsId = jot.Components2Id
|
|||
|
|
LEFT JOIN SitePerson_Person AS BackingWelder ON BackingWelder.PersonId=jot.BackingWelderId
|
|||
|
|
LEFT JOIN SitePerson_Person AS CoverWelder ON CoverWelder.PersonId=jot.CoverWelderId
|
|||
|
|
LEFT JOIN dbo.HJGL_WeldingDaily AS daily ON daily.WeldingDailyId=jot.WeldingDailyId
|
|||
|
|
LEFT JOIN Base_PipingClass AS pipingClass ON pipingClass.PipingClassId=pipe.PipingClassId
|
|||
|
|
LEFT JOIN dbo.Base_Medium medium ON medium.MediumId = pipe.MediumId
|
|||
|
|
LEFT JOIN dbo.Base_DetectionType ndt ON ndt.DetectionTypeId = jot.DetectionTypeId
|
|||
|
|
LEFT JOIN dbo.WPQ_WPQList wps ON wps.WPQId = jot.WPQId
|
|||
|
|
LEFT JOIN dbo.HJGL_Batch_PointBatchItem pointItem ON pointItem.WeldJointId = jot.WeldJointId
|
|||
|
|
LEFT JOIN dbo.HJGL_Batch_PointBatch point ON point.PointBatchId = pointItem.PointBatchId
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
GO
|
|||
|
|
|
|||
|
|
|