218 lines
20 KiB
Transact-SQL
218 lines
20 KiB
Transact-SQL
INSERT INTO dbo.Sys_Menu(MenuId, MenuName, MenuEnName, Url, SortIndex, SuperMenu,MenuModule,IsUse)
|
||
VALUES('794197B8-BBDD-4498-9B0D-6AC3282EB0E4','压力管道分级','PIP Class','PublicInfo/BaseInfo/PIPClass.aspx',55,'8IDKGJE2-09B1-4607-BC6D-865CE48F080F','2',1)
|
||
GO
|
||
/* 压力管道分级*/
|
||
INSERT INTO Sys_ButtonToMenu(ButtonToMenuId,MenuId,ButtonName,ButtonEnName,SortIndex) VALUES('56B400B6-B90F-49D1-B5F7-D95EE66F992B','794197B8-BBDD-4498-9B0D-6AC3282EB0E4','增加','Add',1)
|
||
INSERT INTO Sys_ButtonToMenu(ButtonToMenuId,MenuId,ButtonName,ButtonEnName,SortIndex) VALUES('EB00D588-142A-46A5-8588-4DC08DD56CEE','794197B8-BBDD-4498-9B0D-6AC3282EB0E4','修改','Modify',2)
|
||
INSERT INTO Sys_ButtonToMenu(ButtonToMenuId,MenuId,ButtonName,ButtonEnName,SortIndex) VALUES('3B8005FF-D1A0-4F73-88CE-70EB2A457361','794197B8-BBDD-4498-9B0D-6AC3282EB0E4','删除','Delete',3)
|
||
INSERT INTO Sys_ButtonToMenu(ButtonToMenuId,MenuId,ButtonName,ButtonEnName,SortIndex) VALUES('377698DD-003A-46E6-8D00-A80C05F98353','794197B8-BBDD-4498-9B0D-6AC3282EB0E4','保存','Save',4)
|
||
INSERT INTO Sys_ButtonToMenu(ButtonToMenuId,MenuId,ButtonName,ButtonEnName,SortIndex) VALUES('9CA11EF4-AD73-4009-A289-BA57357678D2','794197B8-BBDD-4498-9B0D-6AC3282EB0E4','查看','See',5)
|
||
GO
|
||
|
||
|
||
|
||
ALTER VIEW [dbo].[View_Pipeline_Pipeline]
|
||
AS
|
||
/*************管线视图*****************/
|
||
SELECT pipeline.PipelineId,
|
||
pipeline.ProjectId,
|
||
pipeline.InstallationId,
|
||
pipeline.UnitId,
|
||
pipeline.WorkAreaId,
|
||
pipeline.PipelineCode,
|
||
pipeline.SingleNumber,
|
||
pipeline.PipingClassId,
|
||
pipeline.MainMaterialId,
|
||
pipeline.MediumId,
|
||
pipeline.Specification,
|
||
pipeline.SystemNumber,
|
||
pipeline.SubSystemNumber,
|
||
pipeline.WorkPackageCode,
|
||
pipeline.TestPackageCode,
|
||
pipeline.PipelineLength,
|
||
pipeline.Sheet,
|
||
pipeline.PipeSegment,
|
||
pipeline.DrawingsNum,
|
||
pipeline.PaintingCategory,
|
||
pipeline.AdiabaticCategory,
|
||
pipeline.DesignPressure,
|
||
pipeline.DesignTemperature,
|
||
pipeline.TestPressure,
|
||
pipeline.TestTemperature,
|
||
pipeline.ModifierId,
|
||
pipeline.ModifyDate,
|
||
pipeline.CreatorId,
|
||
pipeline.CreateDate,
|
||
pipeline.PenetrationRatio,
|
||
pipeline.PenetrationClass,
|
||
pipeline.IfPickling,
|
||
pipeline.IfChasing,
|
||
pipeline.Remark,
|
||
pipingClass.PipingClassCode,
|
||
CASE pipeline.IfPickling WHEN 1 THEN '是' ELSE '否' END AS IfPicklingStr,
|
||
CAST((SELECT SUM(ISNULL(Size,0)) FROM dbo.Pipeline_WeldJoint WHERE PipelineId=pipeline.PipelineId) AS DECIMAL(19,4)) AS TotalDin,
|
||
(SELECT COUNT(WeldJointId) FROM dbo.Pipeline_WeldJoint WHERE PipelineId=pipeline.PipelineId) AS JointCount,
|
||
unit.UnitName,
|
||
workArea.WorkAreaCode,
|
||
material.MaterialCode,
|
||
medium.MediumCode,
|
||
rate.DetectionRateCode,
|
||
pipeline.DetectionRateId,
|
||
(CASE WHEN pipeline.RandomNum IS NULL THEN '否' ELSE '是' END ) AS IsBuilt,
|
||
pipeline.QueClass,pipeline.ExecStandard,
|
||
pipeline.PIPClassId,pip.PIPClassCode
|
||
FROM Pipeline_Pipeline AS pipeline
|
||
LEFT JOIN Base_PipingClass AS pipingClass ON pipingClass.PipingClassId=pipeline.PipingClassId
|
||
LEFT JOIN dbo.Base_Unit AS unit ON unit.UnitId=pipeline.UnitId
|
||
LEFT JOIN Project_WorkArea AS workArea ON workArea.WorkAreaId=pipeline.WorkAreaId
|
||
LEFT JOIN Base_Material AS material ON material.MaterialId=pipeline.MainMaterialId
|
||
LEFT JOIN Base_Medium AS medium ON medium.MediumId=pipeline.MediumId
|
||
LEFT JOIN dbo.Base_DetectionRate AS rate ON rate.DetectionRateId = pipeline.DetectionRateId
|
||
LEFT JOIN dbo.Base_PIPClass pip ON pip.PIPClassId = pipeline.PIPClassId
|
||
|
||
|
||
|
||
|
||
GO
|
||
|
||
|
||
|
||
|
||
ALTER VIEW [dbo].[View_Batch_BatchTrust]
|
||
AS
|
||
/********无损委托********/
|
||
SELECT BatchTrust.TrustBatchId,
|
||
BatchTrust.TrustBatchCode,
|
||
(CASE WHEN BatchTrust.TrustType='1' THEN BatchTrust.TrustBatchCode
|
||
WHEN BatchTrust.TrustType='2' THEN BatchTrust.TrustBatchCode+'K1'
|
||
WHEN BatchTrust.TrustType='3' THEN BatchTrust.TrustBatchCode+'R1' END) AS NewTrustBatchCode,
|
||
BatchTrust.TrustDate,
|
||
BatchTrust.NDEUuit,
|
||
BatchTrust.ProjectId,
|
||
project.ProjectCode,
|
||
BatchTrust.UnitId,
|
||
BatchTrust.InstallationId,
|
||
BatchTrust.PipelineId,
|
||
pipe.PipelineCode,
|
||
BatchTrust.DetectionTypeId,
|
||
BatchTrust.IsCheck,
|
||
BatchTrust.TopointBatch,
|
||
BatchTrust.SurfaceState,
|
||
BatchTrust.DetectionTiming,
|
||
BatchTrust.QuaCertFile,
|
||
BatchTrust.AcceptStandard,
|
||
Unit.UnitCode,
|
||
Unit.UnitName,
|
||
Installation.InstallationName,
|
||
Installation.InstallationCode,
|
||
DetectionType.DetectionTypeCode,
|
||
ndtCheck.TrustBatchId AS CheckTrustBatchId,
|
||
DetectionType.TestStandard,
|
||
DetectionType.TechLevel,
|
||
rate.DetectionRateCode,
|
||
groove.GrooveTypeCode,
|
||
'巴斯夫一体化基地(广东)有限公司' AS TrustUnit,
|
||
mat.WeldingMethodCode,pip.PIPClassCode
|
||
FROM Batch_BatchTrust AS BatchTrust
|
||
LEFT JOIN dbo.Base_Project project ON project.ProjectId = BatchTrust.ProjectId
|
||
LEFT JOIN Base_Unit AS Unit ON Unit.UnitId=BatchTrust.UnitId
|
||
LEFT JOIN Project_Installation AS Installation ON Installation.InstallationId=BatchTrust.InstallationId
|
||
LEFT JOIN dbo.Pipeline_Pipeline pipe ON pipe.PipelineId = BatchTrust.PipelineId
|
||
LEFT JOIN Base_DetectionType AS DetectionType ON DetectionType.DetectionTypeId=BatchTrust.DetectionTypeId
|
||
LEFT JOIN dbo.Base_DetectionRate rate ON rate.DetectionRateId=pipe.DetectionRateId
|
||
LEFT JOIN dbo.Base_PIPClass pip ON pip.PIPClassId = pipe.PIPClassId
|
||
LEFT JOIN dbo.Base_WeldingMethod mat ON mat.WeldingMethodId = BatchTrust.WeldingMethodId
|
||
LEFT JOIN dbo.Base_GrooveType groove ON groove.GrooveTypeId = BatchTrust.GrooveTypeId
|
||
LEFT JOIN dbo.Batch_NDE ndtCheck ON ndtCheck.TrustBatchId = BatchTrust.TrustBatchId
|
||
WHERE (SELECT COUNT(TrustBatchItemId) FROM Batch_BatchTrustItem WHERE IsCancelTrust IS NULL AND TrustBatchId=BatchTrust.TrustBatchId)>0
|
||
|
||
GO
|
||
|
||
|
||
|
||
ALTER PROCEDURE [dbo].[sp_TrustReport]
|
||
(
|
||
@TrustBatchId NVARCHAR(50)
|
||
)
|
||
AS
|
||
SELECT
|
||
('工程名称:'+pro.ProjectName) AS ProjectName,pro.EnProjectName,trust.TrustDate,
|
||
('单元名称:'+area.WorkAreaName) AS WorkAreaName, area.EnWorkAreaName,
|
||
(SELECT unit.UnitName FROM dbo.Project_Unit punit LEFT JOIN dbo.Base_Unit unit ON unit.UnitId = punit.UnitId WHERE ProjectId= trust.ProjectId AND punit.UnitType='1') AS TrustUnit,
|
||
trust.TrustBatchCode,nde.DetectionTypeCode,trust.SurfaceState,nde.TestStandard,rate.DetectionRateCode, nde.TechLevel,
|
||
(CASE WHEN trust.NDEUuit IS NOT NULL THEN unit.UnitName ELSE (SELECT UnitName FROM dbo.Base_Unit WHERE UnitId=(SELECT TOP 1 UnitId FROM dbo.Project_Unit WHERE ProjectId= trust.ProjectId AND UnitType='4')) END) AS NDEUnit,
|
||
mat.WeldingMethodCode,groove.GrooveTypeCode,pipe.PipelineCode,trust.DetectionTiming,
|
||
(CASE WHEN nde.SysType='渗透检测' THEN 'Ⅰ' ELSE (CASE WHEN nde.SysType='超声波检测' THEN 'Ⅱ' ELSE (CASE WHEN rate.DetectionRateCode='5%' OR rate.DetectionRateCode='10%' THEN 'Ⅲ' ELSE 'Ⅱ' END) END)END) AS QueClass,
|
||
|
||
trust.QuaCertFile,--质量证明文件编号
|
||
trust.AcceptStandard,--制造/验收标准
|
||
pip.PIPClassCode
|
||
FROM dbo.Batch_BatchTrust trust
|
||
LEFT JOIN dbo.Base_Project pro ON pro.ProjectId = trust.ProjectId
|
||
--LEFT JOIN dbo.Project_Installation ins ON ins.InstallationId = trust.InstallationId
|
||
LEFT JOIN dbo.Project_WorkArea area ON area.WorkAreaId = trust.WorkAreaId
|
||
LEFT JOIN dbo.Base_Unit unit ON unit.UnitId = trust.NDEUuit
|
||
LEFT JOIN dbo.Base_Unit cunit ON cunit.UnitId = trust.UnitId
|
||
--LEFT JOIN dbo.Base_Unit tunit ON tunit.UnitId = ins.SupervisorUnitId
|
||
LEFT JOIN dbo.Base_DetectionType nde ON nde.DetectionTypeId = trust.DetectionTypeId
|
||
LEFT JOIN dbo.Base_WeldingMethod mat ON mat.WeldingMethodId = trust.WeldingMethodId
|
||
LEFT JOIN dbo.Base_GrooveType groove ON groove.GrooveTypeId = trust.GrooveTypeId
|
||
LEFT JOIN dbo.Pipeline_Pipeline pipe ON pipe.PipelineId = trust.PipelineId
|
||
LEFT JOIN dbo.Base_DetectionRate rate ON rate.DetectionRateId = pipe.DetectionRateId
|
||
LEFT JOIN dbo.Base_PIPClass pip ON pip.PIPClassId = pipe.PIPClassId
|
||
WHERE trust.TrustBatchId=@TrustBatchId
|
||
|
||
GO
|
||
|
||
|
||
ALTER PROCEDURE [dbo].[TrustItemReport]
|
||
(
|
||
@TrustBatchId NVARCHAR(50)
|
||
)
|
||
AS
|
||
/******焊缝检测委托单明细表*******/
|
||
SELECT ROW_NUMBER() OVER(ORDER BY jot.WeldJointCode) AS Number,
|
||
BatchTrustItem.TrustBatchItemId,
|
||
BatchTrustItem.TrustBatchId,
|
||
pipe.PipelineCode, --管线号
|
||
pipe.SingleNumber, --单线号
|
||
(CASE WHEN PointBatchItem.PointState='2' then (CASE WHEN jot.JointAttribute='固定F' THEN 'F'+jot.WeldJointCode ELSE 'S'+jot.WeldJointCode END)+'K'
|
||
ELSE (CASE WHEN jot.JointAttribute='固定F' THEN 'F'+jot.WeldJointCode ELSE 'S'+jot.WeldJointCode END) END) AS WeldJointCode, --焊口号
|
||
jot.Specification, --焊缝规格
|
||
(CASE WHEN mat1.MaterialCode IS NOT NULL AND mat2.MaterialCode IS NOT NULL
|
||
THEN mat1.MaterialCode + '+' + mat2.MaterialCode
|
||
ELSE (ISNULL(mat1.MaterialCode,'') + ISNULL(mat2.MaterialCode,'')) END) AS MaterialCode, --材质
|
||
(CASE WHEN jot.BackingWelderId!=jot.CoverWelderId THEN backingWelder.WelderCode+'/'+coverWelder.WelderCode ELSE backingWelder.WelderCode END) AS WelderCode,--焊工号
|
||
rate.DetectionRateCode AS DetectionRateCode,--检测比例
|
||
PointBatchItem.AcceptLevel AS AcceptLevel, --验收等级
|
||
(case when PointBatchItem.IsWelderFirst=1 then '首三件' else '' end) as Remark,
|
||
jot.HeartNo1,--炉批1号
|
||
jot.HeartNo2,--炉批2号
|
||
(case jot.IsHotProess when 1 then '是' else '否' end) as IsHotProessName--是否热处理
|
||
FROM dbo.Batch_BatchTrustItem AS BatchTrustItem
|
||
LEFT JOIN Batch_PointBatchItem AS PointBatchItem ON PointBatchItem.PointBatchItemId=BatchTrustItem.PointBatchItemId
|
||
LEFT JOIN dbo.Batch_PointBatch point ON point.PointBatchId = PointBatchItem.PointBatchId
|
||
LEFT JOIN dbo.Base_DetectionRate rate ON rate.DetectionRateId = point.DetectionRateId
|
||
LEFT JOIN dbo.Pipeline_WeldJoint jot ON jot.WeldJointId = BatchTrustItem.WeldJointId
|
||
LEFT JOIN dbo.Pipeline_Pipeline pipe ON pipe.PipelineId = jot.PipelineId
|
||
LEFT JOIN dbo.Welder_Welder backingWelder ON backingWelder.WelderId = jot.BackingWelderId
|
||
LEFT JOIN dbo.Welder_Welder coverWelder ON coverWelder.WelderId = jot.CoverWelderId
|
||
LEFT JOIN Base_Material AS mat1 ON mat1.MaterialId = jot.Material1Id
|
||
LEFT JOIN Base_Material AS mat2 ON mat2.MaterialId = jot.Material2Id
|
||
WHERE BatchTrustItem.TrustBatchId=@TrustBatchId and BatchTrustItem.IsCancelTrust is null
|
||
|
||
GO
|
||
|
||
UPDATE dbo.Pipeline_WeldJoint SET WeldingDate=
|
||
(SELECT d.WeldingDate FROM dbo.Pipeline_WeldingDaily d WHERE d.WeldingDailyId=dbo.Pipeline_WeldJoint.WeldingDailyId)
|
||
|
||
GO
|
||
|
||
|
||
|
||
SELECT NEWID()
|
||
SELECT * FROM dbo.Sys_Menu WHERE SuperMenu='8IDKGJE2-09B1-4607-BC6D-865CE48F080F'
|
||
UPDATE dbo.Sys_Menu SET IsUse=1 WHERE MenuId='794197B8-BBDD-4498-9B0D-6AC3282EB0E4'
|
||
SELECT * FROM dbo.Pipeline_WeldJoint
|
||
|