SGGL_SHJ/DataBase/版本日志/已更新脚本/SGGLDB_V2023-02-17.sql

77 lines
3.0 KiB
Transact-SQL

/****** Object: View [dbo].[View_HJGL_WeldingTask] Script Date: 2023/2/17 9:50:51 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER VIEW [dbo].[View_HJGL_WeldingTask]
AS
SELECT T.WeldTaskId,T.WeldJointId,T.CoverWelderId,T.BackingWelderId,
cov.WelderCode AS CoverWelderCode,back.WelderCode AS BackingWelderCode,
case when jot.JointAttribute is not null then jot.JointAttribute else T.JointAttribute end as JointAttribute,
T.WeldingMode,T.ProjectId,T.UnitWorkId,T.UnitId,T.TaskDate,T.Tabler,T.TableDate,
jot.WeldJointCode,jot.Dia,jot.DNDia, jot.Thickness,jot.Size,jot.WeldingLocationId,
CASE WHEN jot.WeldingDailyId IS NULL THEN '·ñ' ELSE 'ÊÇ' END AS IsWelding,
P.PipelineCode,B.WeldTypeCode,M.WeldingMethodCode,L.WeldingLocationCode,
t.CanWelderCode,t.CanWelderId ,rod.ConsumablesName AS WeldingRodCode,T.CanWeldingRodName,T.CanWeldingWireName,
wire.ConsumablesName AS WeldingWireCode,jot.WeldingDailyId,p.PipeArea,
(case when charindex('/',jot.WeldJointCode)>0
then RIGHT(jot.WeldJointCode,CHARINDEX('/',REVERSE(jot.WeldJointCode))-1)
else jot.WeldJointCode end) as WeldJointNum
from HJGL_WeldTask T
left join HJGL_WeldJoint jot on T.WeldJointId=jot.WeldJointId
LEFT JOIN dbo.SitePerson_Person cov ON cov.PersonId=t.CoverWelderId and cov.ProjectId=t.ProjectId
LEFT JOIN dbo.SitePerson_Person back ON back.PersonId=t.BackingWelderId and back.ProjectId=t.ProjectId
LEFT join HJGL_Pipeline P on jot.PipelineId=P.PipelineId
left join Base_WeldType B on jot.WeldTypeId=B.WeldTypeId
LEFT join Base_WeldingMethod M on jot.WeldingMethodId=M.WeldingMethodId
left join Base_WeldingLocation L on jot.WeldingLocationId=L.WeldingLocationId
LEFT JOIN Base_Consumables AS wire ON wire.ConsumablesId=jot.WeldingWire
LEFT JOIN Base_Consumables AS rod ON rod.ConsumablesId=jot.WeldingRod
GO
ALTER VIEW [dbo].[View_HJGL_NoWeldJointFind]
AS
--δº¸º¸¿Ú²éÕÒ
SELECT jot.WeldJointId,
jot.WeldJointCode,
(case when charindex('/',jot.WeldJointCode)>0
then RIGHT(jot.WeldJointCode,CHARINDEX('/',REVERSE(jot.WeldJointCode))-1)
else jot.WeldJointCode end) as WeldJointNum,
jot.PipelineId,
jot.WeldingDailyId,
jot.JointAttribute,
jot.Dia,
jot.DNDia,
jot.Thickness,
jot.Remark,
WeldType.WeldTypeCode,
method.WeldingMethodCode,
rod.ConsumablesCode AS WeldingRodCode,
wire.ConsumablesCode AS WeldingWireCode,
mat1.MaterialCode AS Material1Code ,
mat2.MaterialCode AS Material2Code
FROM dbo.HJGL_WeldJoint jot
LEFT JOIN dbo.HJGL_PreWeldingDaily pre ON pre.WeldJointId = jot.WeldJointId
LEFT JOIN Base_WeldType AS WeldType ON WeldType.WeldTypeId=jot.WeldTypeId
LEFT JOIN Base_WeldingMethod AS method ON method.WeldingMethodId=jot.WeldingMethodId
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_Consumables AS wire ON wire.ConsumablesId=jot.WeldingWire
LEFT JOIN Base_Consumables AS rod ON rod.ConsumablesId=jot.WeldingRod
WHERE pre.PreWeldingDailyId IS NULL
GO