135 lines
		
	
	
		
			6.6 KiB
		
	
	
	
		
			MySQL
		
	
	
	
		
		
			
		
	
	
			135 lines
		
	
	
		
			6.6 KiB
		
	
	
	
		
			MySQL
		
	
	
	
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								CREATE TABLE [dbo].[Base_PIPClass](
							 | 
						|||
| 
								 | 
							
									[PIPClassId] [NVARCHAR](50) NOT NULL,
							 | 
						|||
| 
								 | 
							
									[PIPClassCode] [NVARCHAR](50) NULL,
							 | 
						|||
| 
								 | 
							
									[PIPClassName] [NVARCHAR](50) NULL,
							 | 
						|||
| 
								 | 
							
									[Remark] [NCHAR](10) NULL,
							 | 
						|||
| 
								 | 
							
								 CONSTRAINT [PK_Base_PIPClass] PRIMARY KEY CLUSTERED 
							 | 
						|||
| 
								 | 
							
								(
							 | 
						|||
| 
								 | 
							
									[PIPClassId] ASC
							 | 
						|||
| 
								 | 
							
								)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
							 | 
						|||
| 
								 | 
							
								) ON [PRIMARY]
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								GO
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ѹ<EFBFBD><EFBFBD><EFBFBD>ܵ<EFBFBD><EFBFBD>ּ<EFBFBD>ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Base_PIPClass', @level2type=N'COLUMN',@level2name=N'PIPClassId'
							 | 
						|||
| 
								 | 
							
								GO
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ѹ<EFBFBD><EFBFBD><EFBFBD>ܵ<EFBFBD><EFBFBD>ּ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Base_PIPClass', @level2type=N'COLUMN',@level2name=N'PIPClassCode'
							 | 
						|||
| 
								 | 
							
								GO
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ѹ<EFBFBD><EFBFBD><EFBFBD>ܵ<EFBFBD><EFBFBD>ּ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Base_PIPClass', @level2type=N'COLUMN',@level2name=N'PIPClassName'
							 | 
						|||
| 
								 | 
							
								GO
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'<EFBFBD><EFBFBD>ע' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Base_PIPClass', @level2type=N'COLUMN',@level2name=N'Remark'
							 | 
						|||
| 
								 | 
							
								GO
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ѹ<EFBFBD><EFBFBD><EFBFBD>ܵ<EFBFBD><EFBFBD>ּ<EFBFBD><EFBFBD><EFBFBD>' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Base_PIPClass'
							 | 
						|||
| 
								 | 
							
								GO
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								ALTER TABLE dbo.Pipeline_Pipeline ADD PIPClassId NVARCHAR(50) NULL
							 | 
						|||
| 
								 | 
							
								GO
							 | 
						|||
| 
								 | 
							
								ALTER TABLE dbo.Base_Consumables ADD UserFlux NVARCHAR(30) NULL
							 | 
						|||
| 
								 | 
							
								GO
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								ALTER PROC [dbo].[sp_rpt_JointComprehensive]
							 | 
						|||
| 
								 | 
							
								            @projectId NVARCHAR(50),
							 | 
						|||
| 
								 | 
							
											@workAreaId NVARCHAR(50)=NULL, 
							 | 
						|||
| 
								 | 
							
								 			@pipelineIds NVARCHAR(MAX) = NULL
							 | 
						|||
| 
								 | 
							
								 			
							 | 
						|||
| 
								 | 
							
								AS 
							 | 
						|||
| 
								 | 
							
								/**********<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ۺ<EFBFBD><EFBFBD><EFBFBD>Ϣ**********/
							 | 
						|||
| 
								 | 
							
								SELECT 
							 | 
						|||
| 
								 | 
							
								    weldJoint.WeldJointId,
							 | 
						|||
| 
								 | 
							
									weldJoint.ProjectId,
							 | 
						|||
| 
								 | 
							
									WorkArea.WorkAreaId,
							 | 
						|||
| 
								 | 
							
									WorkArea.WorkAreaCode,
							 | 
						|||
| 
								 | 
							
									weldJoint.SystemNumber,
							 | 
						|||
| 
								 | 
							
									weldJoint.TestPackageNo,
							 | 
						|||
| 
								 | 
							
									pipeline.SingleNumber,
							 | 
						|||
| 
								 | 
							
									pipeline.PipelineCode,
							 | 
						|||
| 
								 | 
							
									weldJoint.PipeSegment,--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܶ<EFBFBD>
							 | 
						|||
| 
								 | 
							
									(CASE WHEN weldJoint.JointAttribute='<EFBFBD>̶<EFBFBD>F' THEN 'F'+weldJoint.WeldJointCode ELSE 'S'+weldJoint.WeldJointCode END) AS WeldJointCode,
							 | 
						|||
| 
								 | 
							
									weldType.WeldTypeCode,
							 | 
						|||
| 
								 | 
							
									weldJoint.JointAttribute,
							 | 
						|||
| 
								 | 
							
									wl.WeldingLocationCode,
							 | 
						|||
| 
								 | 
							
									weldJoint.Dia,
							 | 
						|||
| 
								 | 
							
									weldJoint.Thickness,--<EFBFBD>ں<EFBFBD>
							 | 
						|||
| 
								 | 
							
									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 '<EFBFBD><EFBFBD>' ELSE '<EFBFBD><EFBFBD>' 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,
							 | 
						|||
| 
								 | 
							
									WeldMaterialSilk.UserFlux,
							 | 
						|||
| 
								 | 
							
									weldJoint.Specification,
							 | 
						|||
| 
								 | 
							
									wps.WPQCode,ndttype.DetectionTypeCode,NULL AS HotReportCode,
							 | 
						|||
| 
								 | 
							
									
							 | 
						|||
| 
								 | 
							
									(CASE WHEN (PointBatchItem.PointState='1' OR PointBatchItem.PointState='2') then '<EFBFBD><EFBFBD>' ELSE  '<EFBFBD><EFBFBD>' 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 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
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
									--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
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								
							 |