211 lines
10 KiB
Transact-SQL
211 lines
10 KiB
Transact-SQL
|
||
insert into Sys_Menu(MenuId,MenuName,Url,SortIndex,SuperMenu,MenuModule)
|
||
values('86A5141D-A608-4EB1-B0CA-CF7B39CBC72C','管道焊口射线检测报告','JGZL/RTCheckReport.aspx',320,'2A84FA58-8B20-48ED-A621-3EC98CF4AD28','3')
|
||
go
|
||
insert into Sys_Menu(MenuId,MenuName,Url,SortIndex,SuperMenu,MenuModule)
|
||
values('DC362EA6-E5AA-4927-B1FF-6296A2CA2DFD','管道焊接接头射线检测比例确认表','JGZL/RTNDTRConfirm.aspx',330,'2A84FA58-8B20-48ED-A621-3EC98CF4AD28','3')
|
||
go
|
||
insert into Sys_Menu(MenuId,MenuName,Url,SortIndex,SuperMenu,MenuModule)
|
||
values('EBC25990-AEFA-4C5F-9919-AA827AADAD95','管道无损检测结果汇总表','JGZL/TestResultsSummary.aspx',340,'2A84FA58-8B20-48ED-A621-3EC98CF4AD28','3')
|
||
go
|
||
insert into Sys_Menu(MenuId,MenuName,Url,SortIndex,SuperMenu,MenuModule)
|
||
values('B1CC7345-5517-43B0-9B2A-F4CFABF48217','管道无损检测数量统计表','JGZL/TestQuantityStatistics.aspx',350,'2A84FA58-8B20-48ED-A621-3EC98CF4AD28','3')
|
||
go
|
||
|
||
|
||
CREATE PROCEDURE [dbo].[HJGL_sp_TestingReportPrint]
|
||
(
|
||
@ProjectId NVARCHAR(50),
|
||
@NDT varchar(100)=null
|
||
)
|
||
AS
|
||
/*********检测报表打印*************/
|
||
create table #SIS(
|
||
BatchId NVARCHAR(50),
|
||
ISO_ID VARCHAR(50),
|
||
ISO_IsoNo nvarchar(50),
|
||
STE_ID nvarchar(50),
|
||
STE_ID2 nvarchar(50),
|
||
WME_ID nvarchar(50),
|
||
STE_Code nvarchar(50),
|
||
WME_Name nvarchar(50),
|
||
JOT_JointDesc nvarchar(50),
|
||
NDT_ID VARCHAR(50),
|
||
NDT_Code nvarchar(50),
|
||
JOT_JointNo nvarchar(1000),
|
||
IsPrint bit,
|
||
CH_TrustID VARCHAR(50)
|
||
)
|
||
BEGIN
|
||
DECLARE My_Cursor CURSOR
|
||
FOR select trust.BatchId,
|
||
joint.ISO_ID,
|
||
iso.ISO_IsoNo,
|
||
joint.STE_ID,
|
||
isnull(joint.STE_ID2,'') as STE_ID2,
|
||
joint.WME_ID,
|
||
(CASE WHEN Steel.STE_Code IS NOT NULL AND Steel2.STE_Code IS NOT NULL and Steel.STE_Code!=Steel2.STE_Code
|
||
THEN Steel.STE_Code + '/' + Steel2.STE_Code
|
||
WHEN Steel.STE_Code IS NOT NULL THEN Steel.STE_Code
|
||
ELSE ISNULL(Steel2.STE_Code,'') END) AS STE_Code,
|
||
WeldMethod.WME_Name,
|
||
joint.JOT_JointDesc,
|
||
trust.CH_NDTMethod AS NDT_ID,
|
||
ndtType.NDT_Code,
|
||
joint.JOT_JointNo+(case when batchDetail.PointType='2' then 'K' else '' end) as JOT_JointNo,
|
||
(case when (SELECT TOP 1 TestingReportPrintId from HJGL_CH_TestingReportPrint as report
|
||
where report.ISO_ID =joint.ISO_ID
|
||
and report.Specifications = joint.JOT_JointDesc
|
||
and report.NDT_ID = trust.CH_NDTMethod
|
||
and report.BatchId = trust.BatchId
|
||
and report.STE_ID=joint.STE_ID and (report.STE_ID2=joint.STE_ID2 or report.STE_ID2='') and report.WME_ID=joint.WME_ID
|
||
and report.Printer is not null
|
||
and report.PrintTime is not null) is null then 0 else 1 end) as IsPrint, --是否打印
|
||
trustItem.CH_TrustID
|
||
from dbo.HJGL_CH_TrustItem trustItem
|
||
left join dbo.HJGL_CH_Trust trust on trust.CH_TrustID=trustItem.CH_TrustID
|
||
left join dbo.HJGL_BO_Batch batch on trust.BatchId=batch.BatchId
|
||
left join dbo.HJGL_BO_BatchDetail batchDetail on trustItem.JOT_ID=batchDetail.JOT_ID
|
||
left join dbo.HJGL_BS_NDTType ndtType on ndtType.NDT_ID=trust.CH_NDTMethod
|
||
left join dbo.HJGL_PW_JointInfo joint on joint.JOT_ID=trustItem.JOT_ID
|
||
left join dbo.HJGL_PW_IsoInfo iso on iso.ISO_ID=joint.ISO_ID
|
||
LEFT JOIN HJGL_BS_Steel AS Steel ON Steel.STE_ID=joint.STE_ID
|
||
LEFT JOIN HJGL_BS_Steel AS Steel2 ON Steel2.STE_ID=joint.STE_ID2
|
||
left join HJGL_BS_WeldMethod AS WeldMethod on WeldMethod.WME_ID=joint.WME_ID
|
||
where trust.ProjectId=@ProjectId
|
||
--AND (batch.BatchId=@BatchId OR @BatchId IS NULL)
|
||
and (ndtType.NDT_Code=@NDT OR @NDT IS NULL)
|
||
and (batch.BatchId in (select BatchId from HJGL_CH_TestingReportPrint))
|
||
--and ((case when (SELECT TOP 1 TestingReportPrintId from HJGL_CH_TestingReportPrint as report
|
||
-- where report.ISO_ID =joint.ISO_ID
|
||
-- and report.Specifications = joint.JOT_JointDesc
|
||
-- and report.NDT_ID = trust.CH_NDTMethod
|
||
-- and report.BatchId = trust.BatchId
|
||
-- and report.Printer is not null
|
||
-- and report.PrintTime is not null)is null then 0 else 1 end)= @IsPrint or @IsPrint is null)
|
||
GROUP by trust.BatchId,joint.ISO_ID,iso.ISO_IsoNo,joint.STE_ID,joint.STE_ID2,joint.WME_ID,
|
||
(CASE WHEN Steel.STE_Code IS NOT NULL AND Steel2.STE_Code IS NOT NULL and Steel.STE_Code!=Steel2.STE_Code
|
||
THEN Steel.STE_Code + '/' + Steel2.STE_Code
|
||
WHEN Steel.STE_Code IS NOT NULL THEN Steel.STE_Code
|
||
ELSE ISNULL(Steel2.STE_Code,'') END),
|
||
WeldMethod.WME_Name,joint.JOT_JointDesc,trust.CH_NDTMethod,ndtType.NDT_Code,
|
||
joint.JOT_JointNo+(case when batchDetail.PointType='2' then 'K' else '' end),
|
||
convert(int,dbo.Fun_GetParseInt(joint.JOT_JointNo)),
|
||
trustItem.CH_TrustID
|
||
order by convert(int,dbo.Fun_GetParseInt(joint.JOT_JointNo))
|
||
OPEN My_Cursor; --打开游标
|
||
DECLARE @Batch NVARCHAR(50),@ISO_ID varchar(50),@ISO_IsoNo nvarchar(50),@STE_ID nvarchar(50),@STE_ID2 nvarchar(50),@WME_ID nvarchar(50),@STE_Code nvarchar(50),@WME_Name nvarchar(50),@JOT_JointDesc nvarchar(50),@NDT_ID varchar(50),@NDT_Code nvarchar(50),@JOT_JointNo nvarchar(1000),@print bit,@CH_TrustID varchar(50)
|
||
|
||
FETCH NEXT FROM My_Cursor into @Batch,@ISO_ID,@ISO_IsoNo,@STE_ID,@STE_ID2,@WME_ID,@STE_Code,@WME_Name,@JOT_JointDesc,@NDT_ID,@NDT_Code,@JOT_JointNo,@print,@CH_TrustID; --读取第一行数据
|
||
WHILE @@FETCH_STATUS = 0
|
||
BEGIN
|
||
if (select COUNT(*) from #SIS where ISO_ID=@ISO_ID and JOT_JointDesc=@JOT_JointDesc and STE_Code=@STE_Code and WME_Name=@WME_Name and NDT_ID=@NDT_ID AND BatchId=@Batch)>0
|
||
begin
|
||
update #SIS set JOT_JointNo=JOT_JointNo+','+@JOT_JointNo
|
||
where ISO_ID=@ISO_ID and JOT_JointDesc=@JOT_JointDesc and STE_Code=@STE_Code and WME_Name=@WME_Name and NDT_ID=@NDT_ID AND BatchId=@Batch
|
||
end
|
||
else
|
||
begin
|
||
|
||
insert into #SIS values(@Batch,@ISO_ID,@ISO_IsoNo,@STE_ID,@STE_ID2,@WME_ID,@STE_Code,@WME_Name,@JOT_JointDesc,@NDT_ID,@NDT_Code,@JOT_JointNo,@print,@CH_TrustID)
|
||
end
|
||
FETCH NEXT FROM My_Cursor into @Batch,@ISO_ID,@ISO_IsoNo,@STE_ID,@STE_ID2,@WME_ID,@STE_Code,@WME_Name,@JOT_JointDesc,@NDT_ID,@NDT_Code,@JOT_JointNo,@print,@CH_TrustID; --读取下一行数据
|
||
END
|
||
CLOSE My_Cursor; --关闭游标
|
||
DEALLOCATE My_Cursor; --释放游标
|
||
END
|
||
select * from #SIS
|
||
drop table #SIS
|
||
|
||
|
||
|
||
GO
|
||
|
||
|
||
ALTER PROCEDURE [dbo].[sp_rpt_Trust]
|
||
(
|
||
@projectId NVARCHAR(50),
|
||
@isoNo nvarchar(50)=null
|
||
)
|
||
AS
|
||
SELECT iso.ISO_IsoNo,ste.STE_Code,class.ISC_IsoClass,v1.JOT_JointDesc,iso.ISO_Remark,
|
||
(case iso.IsHot when 1 then '是' when 0 then '否' end) as isHot,
|
||
|
||
(SELECT TOP 1 NDTR_Name FROM HJGL_BS_NDTRate AS NDTRate
|
||
LEFT JOIN dbo.HJGL_PW_JointInfo AS JointInfo ON JointInfo.NDTR_ID = NDTRate.NDTR_ID
|
||
LEFT JOIN dbo.HJGL_PW_IsoInfo AS IsoInfo ON IsoInfo.ISO_ID = JointInfo.ISO_ID
|
||
WHERE IsoInfo.ISO_ID = v1.ISO_ID) AS NDTRate, --检测比例
|
||
|
||
isnull(gd.gdCount,0) as gdCount,--固定口
|
||
isnull(hd.hdCount,0) as hdCount,--活动口
|
||
|
||
(SELECT TOP 1 jot.JOT_QualifiedLevel FROM dbo.HJGL_PW_JointInfo jot
|
||
LEFT JOIN dbo.HJGL_PW_IsoInfo iso ON iso.ISO_ID = jot.ISO_ID
|
||
WHERE jot.JOT_QualifiedLevel is not null and jot.ISO_ID=v1.ISO_ID
|
||
AND jot.JOT_JointDesc=v1.JOT_JointDesc AND iso.ISC_ID=v1.ISC_ID)
|
||
AS AcceptGrade, --合格等级
|
||
|
||
(SELECT TOP 1 NDT_Code FROM HJGL_BS_NDTType AS ndt
|
||
LEFT JOIN dbo.HJGL_CH_Trust AS Trust ON Trust.CH_NDTMethod = ndt.NDT_ID
|
||
LEFT JOIN dbo.HJGL_BO_Batch AS batch ON batch.BatchId = trust.BatchId
|
||
WHERE Trust.CH_NDTMethod is not null and batch.ISO_ID = v1.ISO_ID) AS NDTCode --检测方法
|
||
FROM
|
||
(
|
||
SELECT iso.ISO_ID,iso.ISC_ID,jot.JOT_JointDesc
|
||
FROM dbo.HJGL_PW_JointInfo jot
|
||
LEFT JOIN dbo.HJGL_PW_IsoInfo iso ON iso.ISO_ID = jot.ISO_ID
|
||
GROUP BY iso.ISO_ID,iso.ISC_ID,jot.JOT_JointDesc ) v1
|
||
|
||
--固定总焊口数
|
||
left join (select count(*) as gdCount,HJGL_PW_JointInfo.ISO_ID,HJGL_PW_IsoInfo.ISC_ID,JOT_JointDesc from HJGL_PW_JointInfo
|
||
left join HJGL_PW_IsoInfo on HJGL_PW_IsoInfo.ISO_ID = HJGL_PW_JointInfo.ISO_ID
|
||
where JOT_JointAttribute='固定'
|
||
group by HJGL_PW_JointInfo.ISO_ID,HJGL_PW_IsoInfo.ISC_ID,JOT_JointDesc) as gd
|
||
on gd.ISO_ID = v1.ISO_ID and gd.ISC_ID = v1.ISC_ID and gd.JOT_JointDesc=v1.JOT_JointDesc
|
||
|
||
--活动总焊口数
|
||
left join (select count(*) as hdCount,HJGL_PW_JointInfo.ISO_ID,HJGL_PW_IsoInfo.ISC_ID,JOT_JointDesc from HJGL_PW_JointInfo
|
||
left join HJGL_PW_IsoInfo on HJGL_PW_IsoInfo.ISO_ID = HJGL_PW_JointInfo.ISO_ID
|
||
where JOT_JointAttribute='活动'
|
||
group by HJGL_PW_JointInfo.ISO_ID,HJGL_PW_IsoInfo.ISC_ID,JOT_JointDesc) as hd
|
||
on hd.ISO_ID = v1.ISO_ID and hd.ISC_ID = v1.ISC_ID and hd.JOT_JointDesc=v1.JOT_JointDesc
|
||
|
||
LEFT JOIN dbo.HJGL_PW_IsoInfo iso ON iso.ISO_ID = v1.ISO_ID
|
||
LEFT JOIN dbo.HJGL_BS_IsoClass class ON class.ISC_ID = v1.ISC_ID
|
||
LEFT JOIN dbo.HJGL_BS_Steel ste ON ste.STE_ID = iso.STE_ID
|
||
WHERE iso.ProjectId=@projectId AND (iso.ISO_IsoNo like @isoNo or @isoNo is null) and
|
||
(SELECT TOP 1 NDTRate.NDTR_Rate FROM HJGL_BS_NDTRate AS NDTRate
|
||
LEFT JOIN dbo.HJGL_PW_JointInfo AS JointInfo ON JointInfo.NDTR_ID = NDTRate.NDTR_ID
|
||
LEFT JOIN dbo.HJGL_PW_IsoInfo AS IsoInfo ON IsoInfo.ISO_ID = JointInfo.ISO_ID
|
||
WHERE IsoInfo.ISO_ID = v1.ISO_ID)!=0
|
||
--select IsoInfo.ISO_ID,
|
||
--IsoInfo.ProjectId,
|
||
--IsoInfo.ISO_IsoNo,--管道编号
|
||
--IsoInfo.Specification,--规格
|
||
--steel.STE_Code, --材质
|
||
--isoClass.ISC_IsoName,--管道级别
|
||
--'' as NDTR_Name, --检测比例
|
||
--isnull(gdJoint.gdCount,0) as gdCount,--固定口
|
||
--isnull(hdJoint.hdCount,0) as hdCount,--活动口
|
||
--(case IsoInfo.IsHot when 1 then '是' when 0 then '否' else '' end) as isHot,--是否热处理
|
||
--'' as NDT_Code, --检测方法
|
||
----(case Trust.CH_AcceptGrade when '1' then 'Ⅰ' when '2' then 'Ⅱ' when '3' then 'Ⅲ' when '4' then 'Ⅳ' when '5' then 'Ⅴ' end) as AcceptGrade, --合格级别
|
||
--'' as AcceptGrade,
|
||
--'' as CH_NDTCriteria,--检测标准
|
||
--'' AS ISO_Executive, --验收标准
|
||
--IsoInfo.ISO_Remark as Remark
|
||
--from HJGL_PW_IsoInfo IsoInfo
|
||
--left join HJGL_BS_IsoClass as isoClass on isoClass.ISC_ID = IsoInfo.ISC_ID
|
||
--left join HJGL_BS_Steel as steel on steel.STE_ID = IsoInfo.STE_ID
|
||
--left join (select count(*) as gdCount,ISO_ID from HJGL_PW_JointInfo where JOT_JointAttribute='固定' group by ISO_ID) as gdJoint on gdJoint.ISO_ID = IsoInfo.ISO_ID
|
||
--left join (select count(*) as hdCount,ISO_ID from HJGL_PW_JointInfo where JOT_JointAttribute='活动' group by ISO_ID) as hdJoint on hdJoint.ISO_ID = IsoInfo.ISO_ID
|
||
--where IsoInfo.ProjectId=@projectId
|
||
--and (ISO_IsoNo like @isoNo or @isoNo is null)
|
||
|
||
|
||
|
||
|
||
GO
|
||
|
||
|