189 lines
13 KiB
Transact-SQL
189 lines
13 KiB
Transact-SQL
|
|
insert into Sys_Menu(MenuId,MenuName,Url,SortIndex,SuperMenu,MenuModule)
|
|
values('4F189F68-D19D-4CAF-9F9C-20614A70A7F6','无损检测日报','HJGL/WeldingReport/NDTReport.aspx',220,'F3B157B7-9BEE-4150-6666-087828F1C51D',3)
|
|
go
|
|
|
|
|
|
|
|
CREATE PROCEDURE [dbo].[HJGL_sp_rpt_NDTReport]
|
|
(
|
|
@ProjectId NVARCHAR(50) = null,
|
|
@trustDate datetime = null
|
|
)
|
|
AS
|
|
/***************无损检测日报**********************/
|
|
SELECT NDTType.NDT_ID,
|
|
NDTType.NDT_Code,
|
|
Base_Project.ProjectName AS ProjectName,
|
|
ISNULL(need_check_count_gd.need_check_count_gd,0) AS need_check_count_gd,--需检测焊口总数(固定口)
|
|
ISNULL(need_check_count_hd.need_check_count_hd,0) AS need_check_count_hd,--需检测焊口总数(活动口)
|
|
(ISNULL(need_check_count_gd.need_check_count_gd,0)+ISNULL(need_check_count_hd.need_check_count_hd,0)) AS need_check_count,--需检测焊口总数(合计)
|
|
ISNULL(trust_count_current_gd.trust_count_current_gd,0) AS trust_count_current_gd,--当日委托焊口(固定口)
|
|
ISNULL(trust_count_current_hd.trust_count_current_hd,0) AS trust_count_current_hd,--当日委托焊口(活动口)
|
|
ISNULL(trust_count_total_gd.trust_count_total_gd,0) AS trust_count_total_gd,--累计委托焊口(固定口)
|
|
ISNULL(trust_count_total_hd.trust_count_total_hd,0) AS trust_count_total_hd, --累计委托焊口(活动口)
|
|
ISNULL(check_count_current_gd.check_count_current_gd,0) AS check_count_current_gd,--当日检测焊口(固定口)
|
|
ISNULL(check_count_current_hd.check_count_current_hd,0) AS check_count_current_hd,--当日检测焊口(活动口)
|
|
ISNULL(check_count_gd.check_count_gd,0) AS check_count_gd,--累计检测(固定口)
|
|
ISNULL(check_count_hd.check_count_hd,0) AS check_count_hd,--累计检测(活动口)
|
|
(ISNULL(check_count_gd.check_count_gd,0)+ISNULL(check_count_hd.check_count_hd,0)) AS check_count_total, --累计检测(焊口合计)
|
|
ISNULL(check_count_film.check_count_film,0) AS check_count_film,--累计检测(片数合计)
|
|
|
|
(CASE WHEN ISNULL(need_check_count_gd.need_check_count_gd,0)>0
|
|
THEN CONVERT(nvarchar(10),ISNULL(check_count_gd.check_count_gd,0)/ISNULL(need_check_count_gd.need_check_count_gd,0)*100)+'%'
|
|
ELSE '0%' END) AS complete_check_gd_rate,--完成检测比例(固定口)
|
|
|
|
(CASE WHEN ISNULL(need_check_count_hd.need_check_count_hd,0)>0
|
|
THEN CONVERT(nvarchar(10),ISNULL(check_count_hd.check_count_hd,0)/ISNULL(need_check_count_hd.need_check_count_hd,0)*100)+'%'
|
|
ELSE '0%' END) AS complete_check_hd_rate,--完成检测比例(活动口)
|
|
|
|
(CASE WHEN (ISNULL(need_check_count_gd.need_check_count_gd,0)+ISNULL(need_check_count_hd.need_check_count_hd,0))>0
|
|
THEN CONVERT(nvarchar(10),(ISNULL(check_count_gd.check_count_gd,0)+ISNULL(check_count_hd.check_count_hd,0))/
|
|
(ISNULL(need_check_count_gd.need_check_count_gd,0)+ISNULL(need_check_count_hd.need_check_count_hd,0))*100)+'%' ELSE '0%' END) AS complete_check_total_rate,--完成检测比例(合计)
|
|
|
|
(CASE WHEN (ISNULL(check_count_gd.check_count_gd,0)+ISNULL(check_count_hd.check_count_hd,0))>0
|
|
THEN CONVERT(nvarchar(10),((ISNULL(check_count_gd.check_count_gd,0)+ISNULL(check_count_hd.check_count_hd,0))-ISNULL(total_check_noPass_count.total_check_noPass_count,0))/
|
|
(ISNULL(check_count_gd.check_count_gd,0)+ISNULL(check_count_hd.check_count_hd,0))*100)+'%' ELSE '0%' END) AS check_one_pass_rate_count,--检测一次合格率(焊口数)
|
|
|
|
(CASE WHEN ISNULL(check_count_film.check_count_film,0)>0 THEN
|
|
CONVERT(nvarchar(10),(ISNULL(check_count_film.check_count_film,0)-ISNULL(check_count_noPass_film.check_count_noPass_film,0))/ISNULL(check_count_film.check_count_film,0)*100)+'%'
|
|
ELSE '0%' END) AS check_one_pass_rate_film,--检测一次合格率(片数)
|
|
|
|
ISNULL(total_check_noPass_count.total_check_noPass_count,0) AS total_check_noPass_count,--累计检测不合格数(焊口)
|
|
ISNULL(check_count_noPass_film.check_count_noPass_film,0) AS check_count_noPass_film,--累计检测不合格数(片数)
|
|
|
|
ISNULL(check_count_current_film.check_count_current_film,0) AS check_count_current_film,--焊缝返修情况(片数)(当日完成)
|
|
ISNULL(check_count_total_film.check_count_total_film,0) AS check_count_total_film,--焊缝返修情况(片数)(累计完成)
|
|
ISNULL(check_count_repair_film.check_count_repair_film,0) AS check_count_repair_film --焊缝返修情况(片数)(待返修)
|
|
|
|
FROM HJGL_BS_NDTType AS NDTType
|
|
LEFT JOIN Base_Project ON Base_Project.ProjectId=@ProjectId
|
|
--需检测焊口总数(固定口)
|
|
LEFT JOIN (SELECT COUNT(*) AS need_check_count_gd,HJGL_CH_Trust.CH_NDTMethod FROM HJGL_CH_TrustItem
|
|
LEFT JOIN HJGL_CH_Trust ON HJGL_CH_Trust.CH_TrustID = HJGL_CH_TrustItem.CH_TrustID
|
|
LEFT JOIN HJGL_PW_JointInfo ON HJGL_PW_JointInfo.JOT_ID = HJGL_CH_TrustItem.JOT_ID
|
|
WHERE HJGL_CH_TrustItem.States='1' AND HJGL_PW_JointInfo.JOT_JointAttribute='固定'
|
|
AND HJGL_CH_Trust.ProjectId=@ProjectId
|
|
GROUP BY HJGL_CH_Trust.CH_NDTMethod) AS need_check_count_gd ON need_check_count_gd.CH_NDTMethod = NDTType.NDT_ID
|
|
|
|
--需检测焊口总数(活动口)
|
|
LEFT JOIN (SELECT COUNT(*) AS need_check_count_hd,HJGL_CH_Trust.CH_NDTMethod FROM HJGL_CH_TrustItem
|
|
LEFT JOIN HJGL_CH_Trust ON HJGL_CH_Trust.CH_TrustID = HJGL_CH_TrustItem.CH_TrustID
|
|
LEFT JOIN HJGL_PW_JointInfo ON HJGL_PW_JointInfo.JOT_ID = HJGL_CH_TrustItem.JOT_ID
|
|
WHERE HJGL_CH_TrustItem.States='1' AND HJGL_PW_JointInfo.JOT_JointAttribute='活动'
|
|
AND HJGL_CH_Trust.ProjectId=@ProjectId
|
|
GROUP BY HJGL_CH_Trust.CH_NDTMethod) AS need_check_count_hd ON need_check_count_hd.CH_NDTMethod = NDTType.NDT_ID
|
|
|
|
--当日委托焊口(固定口)
|
|
LEFT JOIN (SELECT COUNT(*) AS trust_count_current_gd,HJGL_CH_Trust.CH_NDTMethod FROM HJGL_CH_TrustItem
|
|
LEFT JOIN HJGL_CH_Trust ON HJGL_CH_Trust.CH_TrustID = HJGL_CH_TrustItem.CH_TrustID
|
|
LEFT JOIN HJGL_PW_JointInfo ON HJGL_PW_JointInfo.JOT_ID = HJGL_CH_TrustItem.JOT_ID
|
|
WHERE HJGL_PW_JointInfo.JOT_JointAttribute='固定'
|
|
AND HJGL_CH_Trust.ProjectId=@ProjectId AND CONVERT(varchar(10), HJGL_CH_Trust.CH_TrustDate,120)=@trustDate
|
|
GROUP BY HJGL_CH_Trust.CH_NDTMethod) AS trust_count_current_gd ON trust_count_current_gd.CH_NDTMethod = NDTType.NDT_ID
|
|
|
|
--当日委托焊口(活动口)
|
|
LEFT JOIN (SELECT COUNT(*) AS trust_count_current_hd,HJGL_CH_Trust.CH_NDTMethod FROM HJGL_CH_TrustItem
|
|
LEFT JOIN HJGL_CH_Trust ON HJGL_CH_Trust.CH_TrustID = HJGL_CH_TrustItem.CH_TrustID
|
|
LEFT JOIN HJGL_PW_JointInfo ON HJGL_PW_JointInfo.JOT_ID = HJGL_CH_TrustItem.JOT_ID
|
|
WHERE HJGL_PW_JointInfo.JOT_JointAttribute='固定'
|
|
AND HJGL_CH_Trust.ProjectId=@ProjectId AND CONVERT(varchar(10), HJGL_CH_Trust.CH_TrustDate,120)=@trustDate
|
|
GROUP BY HJGL_CH_Trust.CH_NDTMethod) AS trust_count_current_hd ON trust_count_current_hd.CH_NDTMethod = NDTType.NDT_ID
|
|
|
|
--累计委托焊口(固定口)
|
|
LEFT JOIN (SELECT COUNT(*) AS trust_count_total_gd,HJGL_CH_Trust.CH_NDTMethod FROM HJGL_CH_TrustItem
|
|
LEFT JOIN HJGL_CH_Trust ON HJGL_CH_Trust.CH_TrustID = HJGL_CH_TrustItem.CH_TrustID
|
|
LEFT JOIN HJGL_PW_JointInfo ON HJGL_PW_JointInfo.JOT_ID = HJGL_CH_TrustItem.JOT_ID
|
|
WHERE HJGL_PW_JointInfo.JOT_JointAttribute='固定'
|
|
AND HJGL_CH_Trust.ProjectId=@ProjectId
|
|
GROUP BY HJGL_CH_Trust.CH_NDTMethod) AS trust_count_total_gd ON trust_count_total_gd.CH_NDTMethod = NDTType.NDT_ID
|
|
|
|
--累计委托焊口(活动口)
|
|
LEFT JOIN (SELECT COUNT(*) AS trust_count_total_hd,HJGL_CH_Trust.CH_NDTMethod FROM HJGL_CH_TrustItem
|
|
LEFT JOIN HJGL_CH_Trust ON HJGL_CH_Trust.CH_TrustID = HJGL_CH_TrustItem.CH_TrustID
|
|
LEFT JOIN HJGL_PW_JointInfo ON HJGL_PW_JointInfo.JOT_ID = HJGL_CH_TrustItem.JOT_ID
|
|
WHERE HJGL_PW_JointInfo.JOT_JointAttribute='活动'
|
|
AND HJGL_CH_Trust.ProjectId=@ProjectId
|
|
GROUP BY HJGL_CH_Trust.CH_NDTMethod) AS trust_count_total_hd ON trust_count_total_hd.CH_NDTMethod = NDTType.NDT_ID
|
|
|
|
--当日检测焊口(固定口)
|
|
LEFT JOIN (SELECT COUNT(*) AS check_count_current_gd,HJGL_CH_Trust.CH_NDTMethod FROM HJGL_CH_TrustItem
|
|
LEFT JOIN HJGL_CH_Trust ON HJGL_CH_Trust.CH_TrustID = HJGL_CH_TrustItem.CH_TrustID
|
|
LEFT JOIN HJGL_PW_JointInfo ON HJGL_PW_JointInfo.JOT_ID = HJGL_CH_TrustItem.JOT_ID
|
|
WHERE HJGL_CH_TrustItem.States!='1' AND HJGL_PW_JointInfo.JOT_JointAttribute='固定'
|
|
AND HJGL_CH_Trust.ProjectId=@ProjectId AND CONVERT(varchar(10), HJGL_CH_Trust.CH_TrustDate,120)=@trustDate
|
|
GROUP BY HJGL_CH_Trust.CH_NDTMethod) AS check_count_current_gd ON check_count_current_gd.CH_NDTMethod = NDTType.NDT_ID
|
|
|
|
--当日检测焊口(固定口)
|
|
LEFT JOIN (SELECT COUNT(*) AS check_count_current_hd,HJGL_CH_Trust.CH_NDTMethod FROM HJGL_CH_TrustItem
|
|
LEFT JOIN HJGL_CH_Trust ON HJGL_CH_Trust.CH_TrustID = HJGL_CH_TrustItem.CH_TrustID
|
|
LEFT JOIN HJGL_PW_JointInfo ON HJGL_PW_JointInfo.JOT_ID = HJGL_CH_TrustItem.JOT_ID
|
|
WHERE HJGL_CH_TrustItem.States!='1' AND HJGL_PW_JointInfo.JOT_JointAttribute='活动'
|
|
AND HJGL_CH_Trust.ProjectId=@ProjectId AND CONVERT(varchar(10), HJGL_CH_Trust.CH_TrustDate,120)=@trustDate
|
|
GROUP BY HJGL_CH_Trust.CH_NDTMethod) AS check_count_current_hd ON check_count_current_hd.CH_NDTMethod = NDTType.NDT_ID
|
|
|
|
--累计检测(固定口)
|
|
LEFT JOIN (SELECT COUNT(*) AS check_count_gd,HJGL_CH_Trust.CH_NDTMethod FROM HJGL_CH_TrustItem
|
|
LEFT JOIN HJGL_CH_Trust ON HJGL_CH_Trust.CH_TrustID = HJGL_CH_TrustItem.CH_TrustID
|
|
LEFT JOIN HJGL_PW_JointInfo ON HJGL_PW_JointInfo.JOT_ID = HJGL_CH_TrustItem.JOT_ID
|
|
WHERE HJGL_CH_TrustItem.States!='1' AND HJGL_PW_JointInfo.JOT_JointAttribute='固定'
|
|
AND HJGL_CH_Trust.ProjectId=@ProjectId
|
|
GROUP BY HJGL_CH_Trust.CH_NDTMethod) AS check_count_gd ON check_count_gd.CH_NDTMethod = NDTType.NDT_ID
|
|
|
|
--累计检测(活动口)
|
|
LEFT JOIN (SELECT COUNT(*) AS check_count_hd,HJGL_CH_Trust.CH_NDTMethod FROM HJGL_CH_TrustItem
|
|
LEFT JOIN HJGL_CH_Trust ON HJGL_CH_Trust.CH_TrustID = HJGL_CH_TrustItem.CH_TrustID
|
|
LEFT JOIN HJGL_PW_JointInfo ON HJGL_PW_JointInfo.JOT_ID = HJGL_CH_TrustItem.JOT_ID
|
|
WHERE HJGL_CH_TrustItem.States!='1' AND HJGL_PW_JointInfo.JOT_JointAttribute='活动'
|
|
AND HJGL_CH_Trust.ProjectId=@ProjectId
|
|
GROUP BY HJGL_CH_Trust.CH_NDTMethod) AS check_count_hd ON check_count_hd.CH_NDTMethod = NDTType.NDT_ID
|
|
|
|
----累计检测(片数合计)
|
|
LEFT JOIN (SELECT COUNT(*) AS check_count_film,HJGL_CH_Trust.CH_NDTMethod FROM HJGL_BO_QualityRating
|
|
LEFT JOIN HJGL_CH_TrustItem ON HJGL_CH_TrustItem.CH_TrustItemID = HJGL_BO_QualityRating.CH_TrustItemID
|
|
LEFT JOIN HJGL_CH_Trust ON HJGL_CH_Trust.CH_TrustID = HJGL_CH_TrustItem.CH_TrustID
|
|
WHERE HJGL_CH_Trust.ProjectId=@ProjectId
|
|
GROUP BY HJGL_CH_Trust.CH_NDTMethod) AS check_count_film ON check_count_film.CH_NDTMethod = NDTType.NDT_ID
|
|
|
|
--累计检测不合格数(焊口)
|
|
LEFT JOIN (SELECT COUNT(*) AS total_check_noPass_count,HJGL_CH_Trust.CH_NDTMethod FROM HJGL_CH_TrustItem
|
|
LEFT JOIN HJGL_CH_Trust ON HJGL_CH_Trust.CH_TrustID = HJGL_CH_TrustItem.CH_TrustID
|
|
WHERE HJGL_CH_Trust.ProjectId=@ProjectId AND HJGL_CH_TrustItem.States='3'
|
|
GROUP BY HJGL_CH_Trust.CH_NDTMethod) AS total_check_noPass_count ON total_check_noPass_count.CH_NDTMethod = NDTType.NDT_ID
|
|
|
|
--累计检测不合格数(片数)
|
|
LEFT JOIN (SELECT COUNT(*) AS check_count_noPass_film,HJGL_CH_Trust.CH_NDTMethod FROM HJGL_BO_QualityRating
|
|
LEFT JOIN HJGL_CH_TrustItem ON HJGL_CH_TrustItem.CH_TrustItemID = HJGL_BO_QualityRating.CH_TrustItemID
|
|
LEFT JOIN HJGL_CH_Trust ON HJGL_CH_Trust.CH_TrustID = HJGL_CH_TrustItem.CH_TrustID
|
|
WHERE HJGL_BO_QualityRating.IsPass='不合格' and HJGL_CH_Trust.ProjectId=@ProjectId
|
|
GROUP BY HJGL_CH_Trust.CH_NDTMethod) AS check_count_noPass_film ON check_count_noPass_film.CH_NDTMethod = NDTType.NDT_ID
|
|
|
|
--焊缝返修情况(片数)(当日完成)
|
|
LEFT JOIN (SELECT COUNT(*) AS check_count_current_film,HJGL_CH_Trust.CH_NDTMethod FROM HJGL_BO_QualityRatingRepair
|
|
LEFT JOIN HJGL_CH_RepairItem ON HJGL_CH_RepairItem.CH_RepairItemId = HJGL_BO_QualityRatingRepair.CH_RepairItemId
|
|
LEFT JOIN HJGL_CH_Repair ON HJGL_CH_Repair.CH_RepairID = HJGL_CH_RepairItem.CH_RepairID
|
|
LEFT JOIN HJGL_CH_TrustItem ON HJGL_CH_TrustItem.CH_TrustItemID = HJGL_CH_Repair.TrustItemID
|
|
LEFT JOIN HJGL_CH_Trust ON HJGL_CH_Trust.CH_TrustID = HJGL_CH_TrustItem.CH_TrustID
|
|
WHERE HJGL_CH_Trust.ProjectId=@ProjectId AND CONVERT(varchar(10),HJGL_CH_Repair.RepairTrustDate,120)=@trustDate
|
|
GROUP BY HJGL_CH_Trust.CH_NDTMethod) AS check_count_current_film ON check_count_current_film.CH_NDTMethod = NDTType.NDT_ID
|
|
|
|
--焊缝返修情况(片数)(累计完成)
|
|
LEFT JOIN (SELECT COUNT(*) AS check_count_total_film,HJGL_CH_Trust.CH_NDTMethod FROM HJGL_BO_QualityRatingRepair
|
|
LEFT JOIN HJGL_CH_RepairItem ON HJGL_CH_RepairItem.CH_RepairItemId = HJGL_BO_QualityRatingRepair.CH_RepairItemId
|
|
LEFT JOIN HJGL_CH_Repair ON HJGL_CH_Repair.CH_RepairID = HJGL_CH_RepairItem.CH_RepairID
|
|
LEFT JOIN HJGL_CH_TrustItem ON HJGL_CH_TrustItem.CH_TrustItemID = HJGL_CH_Repair.TrustItemID
|
|
LEFT JOIN HJGL_CH_Trust ON HJGL_CH_Trust.CH_TrustID = HJGL_CH_TrustItem.CH_TrustID
|
|
WHERE HJGL_CH_Trust.ProjectId=@ProjectId
|
|
GROUP BY HJGL_CH_Trust.CH_NDTMethod) AS check_count_total_film ON check_count_total_film.CH_NDTMethod = NDTType.NDT_ID
|
|
|
|
----焊缝返修情况(片数)(待返修)
|
|
LEFT JOIN (SELECT COUNT(*) AS check_count_repair_film,HJGL_CH_Repair.NDT_ID FROM HJGL_BO_QualityRatingRepair
|
|
LEFT JOIN HJGL_CH_RepairItem ON HJGL_CH_RepairItem.CH_RepairItemId = HJGL_BO_QualityRatingRepair.CH_RepairItemId
|
|
LEFT JOIN HJGL_CH_Repair ON HJGL_CH_Repair.CH_RepairID = HJGL_CH_RepairItem.CH_RepairID
|
|
LEFT JOIN HJGL_CH_TrustItem ON HJGL_CH_TrustItem.CH_TrustItemID = HJGL_CH_Repair.TrustItemID
|
|
WHERE HJGL_CH_RepairItem.States='4' AND HJGL_CH_Repair.ProjectId=@ProjectId
|
|
GROUP BY HJGL_CH_Repair.NDT_ID) AS check_count_repair_film ON check_count_repair_film.NDT_ID = NDTType.NDT_ID
|
|
GO
|
|
|
|
|