Basf_TCC7/DataBase/版本日志/HJGLDB_2024.04.13.sql

231 lines
20 KiB
MySQL
Raw Normal View History

2024-05-08 10:02:08 +08:00
<EFBFBD><EFBFBD>ALTER PROC [dbo].[sp_rpt_JointComprehensive]
@projectId NVARCHAR(50),
@workAreaId NVARCHAR(50)=NULL,
@pipelineIds NVARCHAR(MAX) = NULL
AS
/**********
q<EFBFBD>S<EFBFBD>~T<EFBFBD>Oo`**********/
SELECT
weldJoint.WeldJointId,
weldJoint.ProjectId,
WorkArea.WorkAreaId,
WorkArea.WorkAreaCode,
weldJoint.SystemNumber,
weldJoint.TestPackageNo,
pipeline.SingleNumber,
pipeline.PipelineCode,
pipeline.DrawingsNum,
weldJoint.PageNum,
weldJoint.PipeSegment,--@b^\<EFBFBD>{<EFBFBD>k
weldJoint.WeldJointCode,
weldType.WeldTypeCode,
weldJoint.JointAttribute,
wl.WeldingLocationCode,
weldJoint.Dia,
weldJoint.Thickness,--<EFBFBD>X<EFBFBD>S
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 '/f' ELSE '&T' 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 '/f<><66> N<>S' ELSE '/f' END) ELSE '&T' 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
/********<EFBFBD>e_c<EFBFBD>YXb********/
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, --<EFBFBD>YXbUS<EFBFBD>S
BatchTrust.ProjectId,
CONVERT(VARCHAR(10),BatchTrust.TrustDate,120) AS TrustDate,
BatchTrust.InstallationId,
ins.InstallationCode, --ňn
area.WorkAreaCode, --<EFBFBD>]:S<EFBFBD>S
pipe.PipelineCode, --<EFBFBD>{<EFBFBD>~<EFBFBD>S
pipingClass.PipingClassCode, --<EFBFBD>{<EFBFBD>~I{<EFBFBD>~
(CASE WHEN PointBatchItem.PointState='2' THEN jot.WeldJointCode+'K'
ELSE jot.WeldJointCode END) AS WeldJointCode, --
q<EFBFBD>S<EFBFBD>S
--jot.WeldJointCode,
mat.MaterialCode, --Pg(<EFBFBD>
jot.JointArea, --
q<EFBFBD>c:S<EFBFBD>W
welder.WelderCode AS WelderCode, --
q<EFBFBD>]<EFBFBD>S
weldType.WeldTypeCode, --
q{|<EFBFBD>W
CONVERT(FLOAT,jot.Dia) AS Dia, --Y<EFBFBD>_
CONVERT(FLOAT,jot.Size) AS Size, --<EFBFBD>[<EFBFBD>_
CONVERT(FLOAT,jot.Thickness) AS Thickness, --<EFBFBD>X<EFBFBD>S
method.WeldingMethodCode, --
q<EFBFBD>c<EFBFBD>e<EFBFBD>l
jot.Specification,
jot.Remark,
CAST(rate.DetectionRateValue AS VARCHAR(10))+'%' AS DetectionRateCode,
PointBatchItem.PointDate, --<EFBFBD>p<EFBFBD>S<EFBFBD>eg
(CASE WHEN dtype.SysType !='\<5C>~<7E>hKm' THEN '`!' ELSE PointBatchItem.AcceptLevel END) AS AcceptLevel, --T<hI{<EFBFBD>~
pipe.Sheet, --u<EFBFBD>pe
PipingClass.PNO,
(CASE WHEN BatchTrustItem.IsCancelTrust=1 THEN '<00>]<5D>S<EFBFBD>m' ELSE '' END) AS IsCancelTrust,
(CASE WHEN PointBatchItem.IsWelderFirst=1 THEN '/f' 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
/********<EFBFBD>e_c<EFBFBD>YXb********/
SELECT
BatchTrustItem.TrustBatchItemId,
BatchTrustItem.TrustBatchId,
BatchTrustItem.PointBatchItemId,
BatchTrustItem.WeldJointId,
BatchTrustItem.CreateDate,
BatchTrustItem.TrustNum,
BatchTrust.TrustType,
BatchTrustItem.RepairNum,
BatchTrustItem.FilmNum,
BatchTrust.TrustBatchCode, --<EFBFBD>YXbUS<EFBFBD>S
BatchTrust.ProjectId,
CONVERT(VARCHAR(10),BatchTrust.TrustDate,120) AS TrustDate,
BatchTrust.InstallationId,
ins.InstallationCode, --ňn
area.WorkAreaCode, --<EFBFBD>]:S<EFBFBD>S
pipe.PipelineCode, --<EFBFBD>{<EFBFBD>~<EFBFBD>S
pipingClass.PipingClassCode, --<EFBFBD>{<EFBFBD>~I{<EFBFBD>~
(CASE WHEN PointBatchItem.PointState='2' THEN jot.WeldJointCode+'K'
ELSE jot.WeldJointCode END) AS WeldJointCode, --
q<EFBFBD>S<EFBFBD>S
--jot.WeldJointCode,
mat.MaterialCode, --Pg(<EFBFBD>
jot.JointArea, --
q<EFBFBD>c:S<EFBFBD>W
welder.WelderCode AS WelderCode, --
q<EFBFBD>]<EFBFBD>S
weldType.WeldTypeCode, --
q{|<EFBFBD>W
CONVERT(FLOAT,jot.Dia) AS Dia, --Y<EFBFBD>_
CONVERT(FLOAT,jot.Size) AS Size, --<EFBFBD>[<EFBFBD>_
CONVERT(FLOAT,jot.Thickness) AS Thickness, --<EFBFBD>X<EFBFBD>S
method.WeldingMethodCode, --
q<EFBFBD>c<EFBFBD>e<EFBFBD>l
jot.Specification,
jot.Remark,
CAST(rate.DetectionRateValue AS VARCHAR(10))+'%' AS DetectionRateCode,
PointBatchItem.PointDate, --<EFBFBD>p<EFBFBD>S<EFBFBD>eg
(CASE WHEN dtype.SysType !='\<5C>~<7E>hKm' THEN '`!' ELSE PointBatchItem.AcceptLevel END) AS AcceptLevel, --T<hI{<EFBFBD>~
pipe.Sheet, --u<EFBFBD>pe
PipingClass.PNO,
(CASE WHEN BatchTrustItem.IsCancelTrust=1 THEN '<00>]<5D>S<EFBFBD>m' ELSE '' END) AS IsCancelTrust,
(CASE WHEN PointBatchItem.IsWelderFirst=1 THEN '/f' 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