168 lines
		
	
	
		
			8.9 KiB
		
	
	
	
		
			Transact-SQL
		
	
	
	
			
		
		
	
	
			168 lines
		
	
	
		
			8.9 KiB
		
	
	
	
		
			Transact-SQL
		
	
	
	
ALTER TABLE dbo.Batch_PointBatchItem ADD JLAudit NVARCHAR(50) NULL
 | 
						|
ALTER TABLE dbo.Batch_PointBatchItem ADD GLGSAudit NVARCHAR(50) NULL
 | 
						|
ALTER TABLE dbo.Batch_PointBatchItem ADD QTAudit NVARCHAR(50) NULL
 | 
						|
GO
 | 
						|
 | 
						|
 | 
						|
 INSERT INTO Sys_ButtonToMenu(ButtonToMenuId,MenuId,ButtonName,ButtonEnName,SortIndex) 
 | 
						|
 VALUES('4F7159BD-41CE-420B-97BD-47C424C03B57','3ACE25CE-C5CE-4CEC-AD27-0D5CF1DF2F01','监理审核','JLAudit',7)
 | 
						|
 GO
 | 
						|
 INSERT INTO Sys_ButtonToMenu(ButtonToMenuId,MenuId,ButtonName,ButtonEnName,SortIndex) 
 | 
						|
 VALUES('50B2493D-6D31-428B-A7BE-BADAFCD42133','3ACE25CE-C5CE-4CEC-AD27-0D5CF1DF2F01','管理公司审核','GLGSAudit',8)
 | 
						|
 GO
 | 
						|
 INSERT INTO Sys_ButtonToMenu(ButtonToMenuId,MenuId,ButtonName,ButtonEnName,SortIndex) 
 | 
						|
 VALUES('5767A4F3-3F07-480B-B571-FAF8BD3E3932','3ACE25CE-C5CE-4CEC-AD27-0D5CF1DF2F01','其他审核','QTAudit',9)
 | 
						|
 GO
 | 
						|
 DELETE FROM dbo.Sys_ButtonToMenu WHERE ButtonToMenuId='8A5AAC48-660A-4139-9D27-B43716F4BD90'
 | 
						|
 UPDATE dbo.Sys_ButtonToMenu SET SortIndex=15 WHERE ButtonToMenuId='477D2645-257D-4928-9FE5-3A54241ADF16'
 | 
						|
 | 
						|
ALTER VIEW [dbo].[View_Batch_PointBatchItem]
 | 
						|
AS
 | 
						|
/*************点口明细表*************/
 | 
						|
SELECT PointBatchItem.PointBatchItemId,
 | 
						|
PointBatchItem.PointBatchId,
 | 
						|
PointBatch.ProjectId,
 | 
						|
PointBatch.InstallationId,
 | 
						|
PointBatch.UnitId,
 | 
						|
PointBatch.PointBatchCode,
 | 
						|
PointBatch.DetectionTypeId,
 | 
						|
Pipeline.WorkAreaId,
 | 
						|
PointBatchItem.WeldJointId,
 | 
						|
PointBatchItem.PointState AS PState,
 | 
						|
(CASE PointBatchItem.PointState WHEN '1' THEN '点口' WHEN '2' THEN '扩透' END) AS PointState,
 | 
						|
--(CASE PointBatchItem.IsAudit WHEN 1 THEN '是' ELSE '否' END) AS PointIsAudit,
 | 
						|
--(CASE WHEN PointBatchItem.IsAudit=1 THEN '是' 
 | 
						|
--      WHEN (PointBatchItem.IsAudit IS NULL OR PointBatchItem.IsAudit=0) AND PointBatchItem.PointState IS NOT NULL THEN '否'
 | 
						|
--      WHEN (PointBatchItem.IsAudit IS NULL OR PointBatchItem.IsAudit=0) AND PointBatchItem.PointState IS  NULL THEN '' END) AS PointIsAudit,
 | 
						|
PointBatchItem.PointDate,--点口日期
 | 
						|
PointBatchItem.RepairDate,--返修日期
 | 
						|
PointBatchItem.CutDate,--切除日期
 | 
						|
PointBatchItem.RepairRecordId,
 | 
						|
PointBatchItem.IsBuildTrust,--是否委托
 | 
						|
WorkArea.WorkAreaCode,--工区号
 | 
						|
jot.WeldJointCode,--焊口号
 | 
						|
jot.BackingWelderId AS WelderId, --焊工ID
 | 
						|
jot.JointArea,--焊接区域
 | 
						|
jot.Dia,
 | 
						|
jot.Size,--实际寸径
 | 
						|
WeldingDaily.WeldingDate,--焊接日期
 | 
						|
jot.PipelineId, --管线ID
 | 
						|
jot.Material1Id AS Mat, --材质
 | 
						|
jot.Specification,  --规格
 | 
						|
weldType.Flag,     --焊缝类型
 | 
						|
Pipeline.PipelineCode, --管线号
 | 
						|
PipingClass.PipingClassName, --管道等级
 | 
						|
(CASE WHEN PointBatchItem.JLAudit IS NOT NULL THEN userJL.UserName ELSE (CASE WHEN PointBatchItem.PointState IS NOT NULL THEN '未审核' ELSE '' END)  END) AS JLAudit,
 | 
						|
(CASE WHEN PointBatchItem.GLGSAudit IS NOT NULL THEN userGLGS.UserName ELSE (CASE WHEN PointBatchItem.PointState IS NOT NULL THEN '未审核' ELSE '' END)  END) AS GLGSAudit,
 | 
						|
(CASE WHEN PointBatchItem.QTAudit IS NOT NULL THEN userQT.UserName ELSE (CASE WHEN PointBatchItem.PointState IS NOT NULL THEN '未审核' ELSE '' END)  END) AS QTAudit,
 | 
						|
(CASE WHEN jot.BackingWelderId!=jot.CoverWelderId THEN backingWelder.WelderCode+'/'+coverWelder.WelderCode ELSE backingWelder.WelderCode END) AS WelderCode--焊工号
 | 
						|
FROM Batch_PointBatchItem AS PointBatchItem
 | 
						|
LEFT JOIN Batch_PointBatch AS PointBatch ON PointBatch.PointBatchId=PointBatchItem.PointBatchId
 | 
						|
LEFT JOIN Pipeline_WeldJoint AS jot ON jot.WeldJointId=PointBatchItem.WeldJointId
 | 
						|
LEFT JOIN Pipeline_Pipeline AS Pipeline ON Pipeline.PipelineId=jot.PipelineId
 | 
						|
LEFT JOIN dbo.Base_WeldType weldType ON weldType.WeldTypeId = jot.WeldTypeId
 | 
						|
LEFT JOIN dbo.Welder_Welder backingWelder ON backingWelder.WelderId = jot.BackingWelderId
 | 
						|
LEFT JOIN dbo.Welder_Welder coverWelder ON coverWelder.WelderId = jot.CoverWelderId
 | 
						|
LEFT JOIN Project_WorkArea AS WorkArea ON WorkArea.WorkAreaId=Pipeline.WorkAreaId
 | 
						|
LEFT JOIN Pipeline_WeldingDaily AS WeldingDaily ON WeldingDaily.WeldingDailyId=jot.WeldingDailyId
 | 
						|
LEFT JOIN Base_PipingClass AS PipingClass ON PipingClass.PipingClassId=Pipeline.PipingClassId
 | 
						|
LEFT JOIN dbo.Sys_User userJL ON userJL.UserId = PointBatchItem.JLAudit
 | 
						|
LEFT JOIN dbo.Sys_User userGLGS ON userGLGS.UserId = PointBatchItem.GLGSAudit
 | 
						|
LEFT JOIN dbo.Sys_User userQT ON userQT.UserId = PointBatchItem.GLGSAudit
 | 
						|
GO
 | 
						|
 | 
						|
 | 
						|
 | 
						|
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,
 | 
						|
	weldJoint.PipeSegment,--所属管段
 | 
						|
	(CASE WHEN weldJoint.JointAttribute='固定F' THEN 'F'+weldJoint.WeldJointCode ELSE 'S'+weldJoint.WeldJointCode END) AS WeldJointCode,
 | 
						|
	weldType.WeldTypeCode,
 | 
						|
	weldJoint.JointAttribute,
 | 
						|
	weldJoint.Dia,
 | 
						|
	weldJoint.Thickness,--壁厚
 | 
						|
	weldJoint.HeartNo1,
 | 
						|
	weldJoint.HeartNo2,
 | 
						|
	com1.ComponentsName AS PipeAssembly1,
 | 
						|
	com2.ComponentsName AS PipeAssembly2,
 | 
						|
	material.MaterialCode,
 | 
						|
	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(ISNULL(weldJoint.Size,0) AS DECIMAL(19,2)) AS JOT_Size,
 | 
						|
	WeldMaterialMat.ConsumablesCode  AS WMT_MatCode,
 | 
						|
	WeldMaterialMat.ConsumablesName AS WMT_Matname,
 | 
						|
	WeldMaterialSilk.ConsumablesCode AS hsCode,
 | 
						|
	WeldMaterialSilk.ConsumablesName AS hsname,
 | 
						|
	weldJoint.Specification,
 | 
						|
	wps.WPQCode,ndttype.DetectionTypeCode,NULL AS HotReportCode,
 | 
						|
	
 | 
						|
	(CASE WHEN (PointBatchItem.PointState='1' OR PointBatchItem.PointState='2') then '是' 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 material ON material.MaterialId = weldJoint.Material1Id
 | 
						|
	LEFT JOIN Base_WeldingMethod AS WeldMethod ON WeldMethod.WeldingMethodId = weldJoint.WeldingMethodId	
 | 
						|
	LEFT JOIN dbo.Base_WeldType weldType ON weldType.WeldTypeId = weldJoint.WeldTypeId
 | 
						|
	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
 | 
						|
 | 
						|
	--LEFT JOIN (SELECT PointBatchItem.WeldJointId,PointBatchItem.AcceptLevel, TrustBatchCode,rate.DetectionRateCode FROM Batch_BatchTrustItem AS TrustBatchItem
 | 
						|
	--		LEFT JOIN Batch_BatchTrust AS TrustBatch ON TrustBatchItem.TrustBatchId = TrustBatch.TrustBatchId
 | 
						|
	--		LEFT JOIN Batch_PointBatchItem AS PointBatchItem ON TrustBatchItem.PointBatchItemId =PointBatchItem.PointBatchItemId
 | 
						|
	--		LEFT JOIN Batch_PointBatch AS point ON point.PointBatchId =PointBatchItem.PointBatchId
 | 
						|
	--		LEFT JOIN Base_DetectionRate rate  ON rate.DetectionRateId =point.DetectionRateId) 
 | 
						|
	--		AS TrustBatchCode ON TrustBatchCode.WeldJointId = weldJoint.WeldJointId
 | 
						|
	--LEFT JOIN  (SELECT PointBatchItem.WeldJointId,NDEDate 
 | 
						|
	--			FROM Batch_NDEItem AS NDEItem
 | 
						|
	--			LEFT JOIN Batch_BatchTrustItem AS TrustBatchItem ON NDEItem.TrustBatchItemId = TrustBatchItem.TrustBatchItemId
 | 
						|
	--			LEFT JOIN Batch_PointBatchItem AS PointBatchItem ON PointBatchItem.PointBatchItemId = TrustBatchItem.PointBatchItemId
 | 
						|
	--		    LEFT JOIN Batch_NDE AS Checks ON NDEItem.NDEID = Checks.NDEID)
 | 
						|
	--			 AS CheckDate ON CheckDate.WeldJointId = weldJoint.WeldJointId
 | 
						|
 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 
 |