129 lines
		
	
	
		
			5.5 KiB
		
	
	
	
		
			MySQL
		
	
	
	
		
		
			
		
	
	
			129 lines
		
	
	
		
			5.5 KiB
		
	
	
	
		
			MySQL
		
	
	
	
| 
								 | 
							
								UPDATE dbo.Batch_PointBatchItem SET IsCompletedPoint=1 WHERE PointState=1
							 | 
						|||
| 
								 | 
							
								GO
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								ALTER VIEW [dbo].[View_Batch_PointBatch]
							 | 
						|||
| 
								 | 
							
								AS
							 | 
						|||
| 
								 | 
							
								/*************<EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD><EFBFBD><EFBFBD>ͼ*************/
							 | 
						|||
| 
								 | 
							
								SELECT PointBatch.PointBatchId
							 | 
						|||
| 
								 | 
							
								      ,PointBatch.PointBatchCode
							 | 
						|||
| 
								 | 
							
								      ,PointBatch.ProjectId
							 | 
						|||
| 
								 | 
							
									  ,Project.ProjectCode
							 | 
						|||
| 
								 | 
							
									  ,Project.ProjectName
							 | 
						|||
| 
								 | 
							
								      ,PointBatch.UnitId
							 | 
						|||
| 
								 | 
							
									  ,Unit.UnitName
							 | 
						|||
| 
								 | 
							
									  ,Unit.UnitCode
							 | 
						|||
| 
								 | 
							
									  ,Unit.UnitTypeId
							 | 
						|||
| 
								 | 
							
								      ,PointBatch.InstallationId
							 | 
						|||
| 
								 | 
							
									  ,Installation.InstallationCode
							 | 
						|||
| 
								 | 
							
									  ,Installation.InstallationName
							 | 
						|||
| 
								 | 
							
								      ,PointBatch.DetectionTypeId
							 | 
						|||
| 
								 | 
							
									  ,DetectionType.DetectionTypeCode
							 | 
						|||
| 
								 | 
							
									  ,DetectionType.DetectionTypeName
							 | 
						|||
| 
								 | 
							
								      ,PointBatch.DetectionRateId
							 | 
						|||
| 
								 | 
							
									  ,DetectionRate.DetectionRateCode
							 | 
						|||
| 
								 | 
							
									  ,DetectionRate.DetectionRateValue
							 | 
						|||
| 
								 | 
							
								      ,PointBatch.WelderId
							 | 
						|||
| 
								 | 
							
									  ,Welder.WelderCode
							 | 
						|||
| 
								 | 
							
									  ,Welder.WelderName
							 | 
						|||
| 
								 | 
							
								      ,PointBatch.MediumId
							 | 
						|||
| 
								 | 
							
									  ,Medium.MediumCode
							 | 
						|||
| 
								 | 
							
									  ,Medium.MediumName
							 | 
						|||
| 
								 | 
							
								      ,PointBatch.MaterialId
							 | 
						|||
| 
								 | 
							
									  ,Material.MaterialCode	 
							 | 
						|||
| 
								 | 
							
								      ,PointBatch.WeldTypeId
							 | 
						|||
| 
								 | 
							
									  ,WeldType.WeldTypeCode
							 | 
						|||
| 
								 | 
							
									  ,WeldType.WeldTypeName
							 | 
						|||
| 
								 | 
							
								      ,PointBatch.StartDate
							 | 
						|||
| 
								 | 
							
								      ,PointBatch.EndDate
							 | 
						|||
| 
								 | 
							
								      ,PointBatch.ClearDate
							 | 
						|||
| 
								 | 
							
								      ,PointBatch.IsTrust
							 | 
						|||
| 
								 | 
							
								      ,PointBatch.IsCheck
							 | 
						|||
| 
								 | 
							
									  ,pipe.PipelineCode
							 | 
						|||
| 
								 | 
							
									  ,(CASE WHEN (SELECT COUNT(item.PointBatchItemId) FROM dbo.Batch_PointBatchItem item 
							 | 
						|||
| 
								 | 
							
									               WHERE item.PointBatchId=PointBatch.PointBatchId AND item.IsCompletedPoint=0)>0 
							 | 
						|||
| 
								 | 
							
											 THEN 1 ELSE 0 END) AS IsCompletedPoint
							 | 
						|||
| 
								 | 
							
								FROM Batch_PointBatch AS PointBatch
							 | 
						|||
| 
								 | 
							
								LEFT JOIN Base_Project AS Project ON PointBatch.ProjectId=Project.ProjectId
							 | 
						|||
| 
								 | 
							
								LEFT JOIN Base_Unit AS Unit ON PointBatch.UnitId=Unit.UnitId
							 | 
						|||
| 
								 | 
							
								LEFT JOIN Project_Installation AS Installation ON PointBatch.InstallationId=Installation.InstallationId
							 | 
						|||
| 
								 | 
							
								LEFT JOIN Base_DetectionType AS DetectionType ON PointBatch.DetectionTypeId=DetectionType.DetectionTypeId
							 | 
						|||
| 
								 | 
							
								LEFT JOIN Base_DetectionRate AS DetectionRate ON PointBatch.DetectionRateId=DetectionRate.DetectionRateId
							 | 
						|||
| 
								 | 
							
								LEFT JOIN Welder_Welder AS Welder ON PointBatch.WelderId=Welder.WelderId
							 | 
						|||
| 
								 | 
							
								LEFT JOIN Base_Medium AS Medium ON PointBatch.MediumId=Medium.MediumId
							 | 
						|||
| 
								 | 
							
								LEFT JOIN Base_Material AS Material ON PointBatch.MaterialId=Material.MaterialId
							 | 
						|||
| 
								 | 
							
								LEFT JOIN Base_WeldType AS WeldType ON PointBatch.WeldTypeId=WeldType.WeldTypeId
							 | 
						|||
| 
								 | 
							
								LEFT JOIN dbo.Pipeline_Pipeline pipe ON pipe.PipelineId = PointBatch.PipelineId
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								GO
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								ALTER VIEW [dbo].[View_Batch_PointBatchItem]
							 | 
						|||
| 
								 | 
							
								AS
							 | 
						|||
| 
								 | 
							
								/*************<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϸ<EFBFBD><EFBFBD>*************/
							 | 
						|||
| 
								 | 
							
								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 '<EFBFBD><EFBFBD><EFBFBD><EFBFBD>' WHEN '2' THEN '<EFBFBD><EFBFBD>' END) AS PointState,
							 | 
						|||
| 
								 | 
							
								--(CASE PointBatchItem.IsAudit WHEN 1 THEN '<EFBFBD><EFBFBD>' ELSE '<EFBFBD><EFBFBD>' END) AS PointIsAudit,
							 | 
						|||
| 
								 | 
							
								--(CASE WHEN PointBatchItem.IsAudit=1 THEN '<EFBFBD><EFBFBD>' 
							 | 
						|||
| 
								 | 
							
								--      WHEN (PointBatchItem.IsAudit IS NULL OR PointBatchItem.IsAudit=0) AND PointBatchItem.PointState IS NOT NULL THEN '<27><>'
							 | 
						|||
| 
								 | 
							
								--      WHEN (PointBatchItem.IsAudit IS NULL OR PointBatchItem.IsAudit=0) AND PointBatchItem.PointState IS  NULL THEN '' END) AS PointIsAudit,
							 | 
						|||
| 
								 | 
							
								PointBatchItem.PointDate,--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
							 | 
						|||
| 
								 | 
							
								PointBatchItem.RepairDate,--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
							 | 
						|||
| 
								 | 
							
								PointBatchItem.CutDate,--<EFBFBD>г<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
							 | 
						|||
| 
								 | 
							
								PointBatchItem.RepairRecordId,
							 | 
						|||
| 
								 | 
							
								PointBatchItem.IsBuildTrust,--<EFBFBD>Ƿ<EFBFBD>ί<EFBFBD><EFBFBD>
							 | 
						|||
| 
								 | 
							
								WorkArea.WorkAreaCode,--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
							 | 
						|||
| 
								 | 
							
								jot.WeldJointCode,--<EFBFBD><EFBFBD><EFBFBD>ں<EFBFBD>
							 | 
						|||
| 
								 | 
							
								jot.BackingWelderId AS WelderId, --<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ID
							 | 
						|||
| 
								 | 
							
								jot.JointArea,--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
							 | 
						|||
| 
								 | 
							
								jot.Dia,
							 | 
						|||
| 
								 | 
							
								jot.Size,--ʵ<EFBFBD>ʴ羶
							 | 
						|||
| 
								 | 
							
								WeldingDaily.WeldingDate,--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
							 | 
						|||
| 
								 | 
							
								jot.PipelineId, --<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ID
							 | 
						|||
| 
								 | 
							
								jot.Material1Id AS Mat, --<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
							 | 
						|||
| 
								 | 
							
								jot.Specification,  --<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
							 | 
						|||
| 
								 | 
							
								jot.JointAttribute,
							 | 
						|||
| 
								 | 
							
								weldType.Flag,     --<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
							 | 
						|||
| 
								 | 
							
								Pipeline.PipelineCode, --<EFBFBD><EFBFBD><EFBFBD>ߺ<EFBFBD>
							 | 
						|||
| 
								 | 
							
								PipingClass.PipingClassName, --<EFBFBD>ܵ<EFBFBD><EFBFBD>ȼ<EFBFBD>
							 | 
						|||
| 
								 | 
							
								PointBatchItem.IsWelderFirst,
							 | 
						|||
| 
								 | 
							
								PointBatchItem.IsCompletedPoint,
							 | 
						|||
| 
								 | 
							
								(CASE WHEN PointBatchItem.JLAudit IS NOT NULL THEN userJL.UserName ELSE (CASE WHEN PointBatchItem.PointState IS NOT NULL THEN 'δ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>' ELSE '' END)  END) AS JLAudit,
							 | 
						|||
| 
								 | 
							
								(CASE WHEN PointBatchItem.GLGSAudit IS NOT NULL THEN userGLGS.UserName ELSE (CASE WHEN PointBatchItem.PointState IS NOT NULL THEN 'δ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>' ELSE '' END)  END) AS GLGSAudit,
							 | 
						|||
| 
								 | 
							
								(CASE WHEN PointBatchItem.QTAudit IS NOT NULL THEN userQT.UserName ELSE (CASE WHEN PointBatchItem.PointState IS NOT NULL THEN 'δ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>' ELSE '' END)  END) AS QTAudit,
							 | 
						|||
| 
								 | 
							
								(CASE WHEN jot.BackingWelderId!=jot.CoverWelderId THEN backingWelder.WelderCode+'/'+coverWelder.WelderCode ELSE backingWelder.WelderCode END) AS WelderCode, --<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
							 | 
						|||
| 
								 | 
							
								(CASE WHEN PointBatchItem.JLAudit IS NOT NULL AND PointBatchItem.GLGSAudit IS NOT NULL THEN 1 ELSE 0 END) AS IsPointAudit
							 | 
						|||
| 
								 | 
							
								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
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								
							 |