SGGL_SHJ/DataBase/版本日志/SGGLDB_V2025-04-18-001.sql

102 lines
4.2 KiB
MySQL
Raw Permalink Normal View History

2025-05-08 18:38:55 +08:00
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,
BatchTrust.TrustBatchCode, --
BatchTrust.ProjectId,
UnitWork.UnitWorkCode, --
pipe.PipelineCode, --线
pipingClass.PipingClassCode, --线
jot.WeldJointCode+isnull((select top 1 RepairMark from [dbo].[HJGL_RepairRecord] where [WeldJointId]=BatchTrustItem.WeldJointId and RepairRecordId=BatchTrustItem.RepairRecordId),'')+(case when PointBatchItem.PointState='2' then 'K' else '' end) as WeldJointCode, --
mat.MaterialCode, --
jot.JointArea, --
welder.WelderCode AS WelderCode, --
weldType.WeldTypeCode, --
jot.Dia, --
jot.Size, --
jot.Thickness, --
method.WeldingMethodCode, --
rate.DetectionRateCode,
null as CheckDefects,
PointBatchItem.PointDate --
FROM dbo.HJGL_Batch_BatchTrustItem AS BatchTrustItem
LEFT JOIN dbo.HJGL_Batch_BatchTrust AS BatchTrust ON BatchTrust.TrustBatchId=BatchTrustItem.TrustBatchId
LEFT JOIN dbo.HJGL_Batch_PointBatchItem AS PointBatchItem ON PointBatchItem.PointBatchItemId=BatchTrustItem.PointBatchItemId
LEFT JOIN dbo.HJGL_Batch_PointBatch point ON point.PointBatchId = PointBatchItem.PointBatchId
LEFT JOIN dbo.Base_DetectionRate rate ON rate.DetectionRateId = point.DetectionRateId
LEFT JOIN dbo.HJGL_WeldJoint jot ON jot.WeldJointId = BatchTrustItem.WeldJointId
LEFT JOIN dbo.HJGL_Pipeline pipe ON pipe.PipelineId = jot.PipelineId
LEFT JOIN Base_PipingClass AS pipingClass ON PipingClass.PipingClassId=pipe.PipingClassId
LEFT JOIN dbo.WBS_UnitWork UnitWork ON UnitWork.UnitWorkId = BatchTrust.UnitWorkId
LEFT JOIN dbo.Base_WeldType weldType ON weldType.WeldTypeId = jot.WeldTypeId
LEFT JOIN dbo.SitePerson_Person welder ON welder.PersonId = jot.BackingWelderId and welder.ProjectId=BatchTrust.ProjectId
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_GenerateTrustItem]
AS
SELECT point.ProjectId,point.UnitWorkId ,point.UnitId,point.DetectionTypeId,point.DetectionRateId,
--
pipe.PipelineCode, --线
pipingClass.PipingClassCode, --线
jot.WeldJointCode+isnull((select RepairMark from [dbo].[HJGL_RepairRecord] where [WeldJointId]=trustItem.WeldJointId),'')+(case when pointItem.PointState='2' then 'K' else '' end) as WeldJointCode, --
mat.MaterialCode, --
jot.JointArea, --
welder.WelderCode AS WelderCode, --
weldType.WeldTypeCode, --
jot.Dia, --
jot.Size, --
jot.Thickness, --
method.WeldingMethodCode, --
rate.DetectionRateCode,
pointItem.PointDate, --
pointItem.PointBatchItemId,pointItem.PointBatchId,pointItem.WeldJointId
FROM dbo.HJGL_Batch_PointBatchItem pointItem
LEFT JOIN dbo.HJGL_Batch_PointBatch point ON point.PointBatchId = pointItem.PointBatchId
LEFT JOIN dbo.HJGL_WeldJoint jot ON jot.WeldJointId = pointItem.WeldJointId
LEFT JOIN dbo.HJGL_Pipeline pipe ON pipe.PipelineId = jot.PipelineId
LEFT JOIN Base_PipingClass AS pipingClass ON PipingClass.PipingClassId=pipe.PipingClassId
LEFT JOIN dbo.HJGL_Batch_BatchTrustItem trustItem ON trustItem.PointBatchItemId = pointItem.PointBatchItemId
LEFT JOIN dbo.Base_Material mat ON mat.MaterialId = jot.Material1Id
LEFT JOIN dbo.Base_WeldType weldType ON weldType.WeldTypeId = jot.WeldTypeId
LEFT JOIN dbo.SitePerson_Person welder ON welder.PersonId = jot.BackingWelderId and welder.ProjectId=point.ProjectId
LEFT JOIN dbo.Base_WeldingMethod method ON method.WeldingMethodId = jot.WeldingMethodId
LEFT JOIN dbo.Base_DetectionRate rate ON rate.DetectionRateId = point.DetectionRateId
WHERE pointItem.PointState IS NOT NULL AND pointItem.CutDate IS NULL
AND trustItem.TrustBatchItemId IS NULL
GO