diff --git a/DataBase/版本日志/HJGLDB_DS_2025-11-17_gf.sql b/DataBase/版本日志/HJGLDB_DS_2025-11-17_gf.sql new file mode 100644 index 0000000..24499f5 --- /dev/null +++ b/DataBase/版本日志/HJGLDB_DS_2025-11-17_gf.sql @@ -0,0 +1,279 @@ + +ALTER VIEW [dbo].[View_JointWelder] +AS + +SELECT jot.JOT_ID,jot.JOT_Size,jot.ProjectId,jot.InstallationId,iso.BSU_ID,jot.JOT_CellWelder AS Welder,w.WED_Unit, + jot.STE_ID,jot.DReportID,jot.PointType,jot.RT_FilmNum,jot.RT1_RepairFilm,jot.RT2_RepairFilm, + jot.RT2_RepairFilmNum,jot.RT3_RepairFilm,jot.RT3_RepairFilmNum +FROM dbo.HJGL_PW_JointInfo jot +LEFT JOIN dbo.HJGL_PW_IsoInfo iso ON iso.ISO_ID = jot.ISO_ID +LEFT JOIN dbo.HJGL_BS_Welder w on w.WED_ID=jot.JOT_CellWelder +WHERE DReportID IS NOT NULL AND JOT_FloorWelder=JOT_CellWelder +UNION +SELECT jot.JOT_ID,jot.JOT_Size,jot.ProjectId,jot.InstallationId,iso.BSU_ID,jot.JOT_CellWelder AS Welder,w.WED_Unit, + jot.STE_ID,jot.DReportID,jot.PointType,jot.RT_FilmNum,jot.RT1_RepairFilm,jot.RT2_RepairFilm, + jot.RT2_RepairFilmNum,jot.RT3_RepairFilm,jot.RT3_RepairFilmNum +FROM dbo.HJGL_PW_JointInfo jot +LEFT JOIN dbo.HJGL_PW_IsoInfo iso ON iso.ISO_ID = jot.ISO_ID +LEFT JOIN dbo.HJGL_BS_Welder w on w.WED_ID=jot.JOT_CellWelder +WHERE DReportID IS NOT NULL AND JOT_FloorWelder<>JOT_CellWelder +UNION +SELECT jot.JOT_ID,jot.JOT_Size,jot.ProjectId,jot.InstallationId,iso.BSU_ID,jot.JOT_FloorWelder AS Welder,w.WED_Unit, + jot.STE_ID,jot.DReportID,jot.PointType,jot.RT_FilmNum,jot.RT1_RepairFilm,jot.RT2_RepairFilm, + jot.RT2_RepairFilmNum,jot.RT3_RepairFilm,jot.RT3_RepairFilmNum +FROM dbo.HJGL_PW_JointInfo jot +LEFT JOIN dbo.HJGL_PW_IsoInfo iso ON iso.ISO_ID = jot.ISO_ID +LEFT JOIN dbo.HJGL_BS_Welder w on w.WED_ID=jot.JOT_FloorWelder +WHERE DReportID IS NOT NULL AND JOT_FloorWelder<>JOT_CellWelder + + + +GO + + + +CREATE PROC [dbo].[HJGL_sp_rpt_welderPerformance3] + @unitcode VARCHAR(50) = NULL, + @steel VARCHAR(50) = NULL, + @WED_Unit NVARCHAR(50) = NULL, + @date1 DATETIME = NULL, + @date2 DATETIME = NULL, + @projectId NVARCHAR(500) = NULL, + @installationId NVARCHAR(50)=NULL +AS +/*º¸¹¤Òµ¼¨·ÖÎö*/ +SELECT + NEWID() AS Id, + --total.ProjectId, + --project.ProjectCode,--Ê©¹¤ºÅ + '' as ProjectCode, + total.WED_Unit, + un.UnitCode,-- µ¥Î»´úÂë + un.UnitName,--µ¥Î»Ãû³Æ + -------------±¾ÆÚstart + CAST(ISNULL(total.totalSize,0) AS DECIMAL(19,2)) AS totalSize, --×Ü´ç¾¶ + ISNULL(total.totalJoint,0) AS totalJoint, --×ܺ¸¿Ú + ISNULL(JointNum1.JointNum1,0) AS JointNum1, --Ò»´ÎÅÄÆ¬º¸¿ÚÊý + + ISNULL(JointNum1.JointNum1,0)-ISNULL(JointNoPassNum1.JointNoPassNum1,0) AS JointPassNum1, --Ò»´ÎÅÄÆ¬ºÏ¸ñº¸¿ÚÊý + ISNULL(JointNoPassNum1.JointNoPassNum1,0) AS RepairJoint1, --Ò»´Î·µÐÞº¸¿ÚÊý + ISNULL(RepairJoint2.RepairJoint2,0) AS RepairJoint2, --¶þ´Î·µÐÞº¸¿ÚÊý + ISNULL(RepairJoint3.RepairJoint3,0) AS RepairJoint3, --Èý´Î·µÐÞº¸¿ÚÊý + + CAST((CASE ISNULL((ISNULL(JointNum1.JointNum1,0)-ISNULL(JointNoPassNum1.JointNoPassNum1,0)),0) WHEN 0 THEN 0 + ELSE (CASE(ISNULL(JointNum1.JointNum1,0)) WHEN 0 THEN 0 + ELSE 1.0 * ISNULL((ISNULL(JointNum1.JointNum1,0)-ISNULL(JointNoPassNum1.JointNoPassNum1,0)),0)/(1.0 * JointNum1.JointNum1) + END)END) AS DECIMAL(19,3)) AS JointPassRate , ---Ò»´ÎÅÄÆ¬º¸¿ÚºÏ¸ñÂÊ + + ISNULL(JointNum1.totalfilm,0) AS totalfilm, --Ò»´ÎÅÄÆ¬Êý + (ISNULL(JointNum1.totalfilm,0)- ISNULL(JointNoPassNum2.JointNoPassFilmNum2,0)) AS totalPassfilm, --Ò»´ÎÅÄÆ¬ºÏ¸ñÊý + ISNULL(JointNoPassNum2.JointNoPassFilmNum2,0) AS repairFilm1, --Ò»´Î·µÐÞÆ¬×ÓÊý + + ISNULL(RepairJoint2.repairFilm2,0) AS repairFilm2, --¶þ´Î·µÐÞÆ¬×ÓÊý + ISNULL(RepairJoint3.repairFilm3,0) AS repairFilm3, --Èý´Î·µÐÞÆ¬×ÓÊý + + CAST((CASE (ISNULL(JointNum1.totalfilm,0)- ISNULL(JointNoPassNum2.JointNoPassFilmNum2,0)) WHEN 0 THEN 0 + ELSE (CASE(ISNULL(JointNum1.totalfilm,0)) WHEN 0 THEN 0 + ELSE 1.0 * (ISNULL(JointNum1.totalfilm,0)- ISNULL(JointNoPassNum2.JointNoPassFilmNum2,0))/(1.0 * JointNum1.totalfilm) + END) END) AS DECIMAL(19,3)) AS JointFilmPassRate ---Ò»´ÎÅÄÆ¬ºÏ¸ñÂÊ + +FROM + --×Ü´ïÒòÖµ --×ܺ¸¿Ú + (SELECT SUM(joint.JOT_Size) AS totalSize,COUNT(*) AS totalJoint + ,joint.WED_Unit + FROM View_JointWelder joint + LEFT JOIN HJGL_BO_WeldReportMain report ON joint.DReportID = report.DReportID + WHERE joint.DReportID IS NOT NULL and (CHARINDEX(joint.ProjectId,@projectId)>0 OR @projectId IS NULL) + AND (report.JOT_WeldDate >= @date1 OR @date1 IS NULL) AND (report.JOT_WeldDate <= @date2 OR @date2 IS NULL) + AND (joint.ste_id=@steel OR @steel IS NULL) + GROUP BY joint.WED_Unit) AS total + + +--Ò»´ÎÅÄÆ¬º¸¿ÚÊý , Ò»´ÎÅÄÆ¬×ÜÊý,Ò»´ÎÅÄÆ¬ºÏ¸ñ×ÜÊý + LEFT JOIN (SELECT COUNT(joint.JOT_ID) AS JointNum1, SUM(joint.RT_FilmNum) AS totalfilm, + joint.WED_Unit + FROM dbo.View_JointWelder joint + WHERE joint.PointType='µã¿Ú' AND joint.RT_FilmNum IS NOT NULL and joint.RT_FilmNum>0 and (select COUNT(*) from dbo.HJGL_BO_QualityRating a +left join HJGL_CH_TrustItem b on a.CH_TrustItemID=b.CH_TrustItemID +left join HJGL_CH_Trust c on b.CH_TrustID=c.CH_TrustID where a.JOT_ID=joint.JOT_ID and FilmNum is not null and c.CH_NDTMethod='20d2cbca-8b3d-434b-b1c1-181796986fa5')>0 + AND (joint.ste_id=@steel OR @steel IS NULL) AND joint.dreportid IS NOT NULL and (CHARINDEX(joint.ProjectId,@projectId)>0 OR @projectId IS NULL) + AND ((SELECT TOP 1 SignDate FROM dbo.HJGL_BO_QualityRating WHERE JOT_ID=joint.JOT_ID)>= @date1 OR @date1 IS NULL) + AND ((SELECT TOP 1 SignDate FROM dbo.HJGL_BO_QualityRating WHERE JOT_ID=joint.JOT_ID)<= @date2 OR @date2 IS NULL) + GROUP BY joint.WED_Unit) AS JointNum1 + ON JointNum1.WED_Unit = total.WED_Unit + + --Ò»´ÎÅÄÆ¬²»ºÏ¸ñº¸¿ÚÊý + LEFT JOIN (SELECT COUNT(distinct joint.JOT_ID) AS JointNoPassNum1, + joint.WED_Unit + FROM dbo.HJGL_CH_RepairItemRecord rr + left join dbo.View_JointWelder joint on rr.JOT_ID=joint.JOT_ID + WHERE joint.PointType='µã¿Ú' and rr.NDT_ID='20d2cbca-8b3d-434b-b1c1-181796986fa5' + --AND (joint.RT1_RepairFilm IS NOT NULL or (select top 1 CH_TrustItemID from dbo.HJGL_CH_TrustItem ti where ti.JOT_ID=joint.JOT_ID and ti.States='4') is not null) + AND (joint.ste_id=@steel OR @steel IS NULL) AND joint.dreportid IS NOT NULL and rr.RepairMark='R1' and (CHARINDEX(joint.ProjectId,@projectId)>0 OR @projectId IS NULL) + AND ((SELECT TOP 1 SignDate FROM dbo.HJGL_CH_RepairItemRecord WHERE JOT_ID=joint.JOT_ID AND RepairMark='R1')>= @date1 OR @date1 IS NULL) + AND ((SELECT TOP 1 SignDate FROM dbo.HJGL_CH_RepairItemRecord WHERE JOT_ID=joint.JOT_ID AND RepairMark='R1')<= @date2 OR @date2 IS NULL) + GROUP BY joint.WED_Unit) AS JointNoPassNum1 + ON JointNoPassNum1.WED_Unit = total.WED_Unit + --Ò»´ÎÅÄÆ¬²»ºÏ¸ñÅÄÆ¬Êý + LEFT JOIN (SELECT count(rr.RepairItemRecordId) as JointNoPassFilmNum2, + joint.WED_Unit + FROM dbo.HJGL_CH_RepairItemRecord rr + left join dbo.View_JointWelder joint on rr.JOT_ID=joint.JOT_ID + WHERE joint.PointType='µã¿Ú' and rr.NDT_ID='20d2cbca-8b3d-434b-b1c1-181796986fa5' + --AND (joint.RT1_RepairFilm IS NOT NULL or (select top 1 CH_TrustItemID from dbo.HJGL_CH_TrustItem ti where ti.JOT_ID=joint.JOT_ID and ti.States='4') is not null) + AND (joint.ste_id=@steel OR @steel IS NULL) AND joint.dreportid IS NOT NULL and rr.RepairMark='R1' and (CHARINDEX(joint.ProjectId,@projectId)>0 OR @projectId IS NULL) + AND ((SELECT TOP 1 SignDate FROM dbo.HJGL_CH_RepairItemRecord WHERE JOT_ID=joint.JOT_ID AND RepairMark='R1')>= @date1 OR @date1 IS NULL) + AND ((SELECT TOP 1 SignDate FROM dbo.HJGL_CH_RepairItemRecord WHERE JOT_ID=joint.JOT_ID AND RepairMark='R1')<= @date2 OR @date2 IS NULL) + GROUP BY joint.WED_Unit) AS JointNoPassNum2 + ON JointNoPassNum2.WED_Unit = total.WED_Unit + --¶þ´Î·µÐÞÅÄÆ¬º¸¿ÚÊý,¶þ´Î·µÐÞÅÄÆ¬×ÜÊý + LEFT JOIN (SELECT COUNT(joint.JOT_ID) AS RepairJoint2, SUM(ISNULL(joint.RT2_RepairFilmNum,0)) AS RepairFilm2, + joint.WED_Unit + FROM dbo.View_JointWelder joint + WHERE joint.PointType='µã¿Ú' AND joint.RT2_RepairFilm IS NOT NULL and (CHARINDEX(joint.ProjectId,@projectId)>0 OR @projectId IS NULL) + AND (joint.ste_id=@steel OR @steel IS NULL) AND joint.dreportid IS NOT NULL + AND ((SELECT TOP 1 SignDate FROM dbo.HJGL_CH_RepairItemRecord WHERE JOT_ID=joint.JOT_ID AND RepairMark='R2')>= @date1 OR @date1 IS NULL) + AND ((SELECT TOP 1 SignDate FROM dbo.HJGL_CH_RepairItemRecord WHERE JOT_ID=joint.JOT_ID AND RepairMark='R2')<= @date2 OR @date2 IS NULL) + GROUP BY joint.WED_Unit) AS RepairJoint2 + ON RepairJoint2.WED_Unit = total.WED_Unit + + + + --Èý´Î·µÐÞÅÄÆ¬º¸¿ÚÊý,Èý´Î·µÐÞÅÄÆ¬×ÜÊý + LEFT JOIN (SELECT COUNT(joint.JOT_ID) AS RepairJoint3, SUM(ISNULL(joint.RT3_RepairFilmNum,0)) AS RepairFilm3, + joint.WED_Unit + FROM dbo.View_JointWelder joint + WHERE joint.PointType='µã¿Ú' AND joint.RT3_RepairFilm IS NOT NULL and (CHARINDEX(joint.ProjectId,@projectId)>0 OR @projectId IS NULL) + AND (joint.ste_id=@steel OR @steel IS NULL) AND joint.dreportid IS NOT NULL + AND ((SELECT TOP 1 SignDate FROM dbo.HJGL_CH_RepairItemRecord WHERE JOT_ID=joint.JOT_ID AND RepairMark='R3')>= @date1 OR @date1 IS NULL) + AND ((SELECT TOP 1 SignDate FROM dbo.HJGL_CH_RepairItemRecord WHERE JOT_ID=joint.JOT_ID AND RepairMark='R3')<= @date2 OR @date2 IS NULL) + GROUP BY joint.WED_Unit) AS RepairJoint3 + ON RepairJoint3.WED_Unit = total.WED_Unit + +--LEFT JOIN Base_Project project ON total.ProjectId=project.ProjectId +LEFT JOIN dbo.Base_Unit un ON un.UnitId=total.WED_Unit + +WHERE + -- (CHARINDEX(total.ProjectId,@projectId)>0 OR @projectId IS NULL) + --AND (total.InstallationId = @installationId OR @installationId IS NULL) + (un.UnitId=@unitcode OR @unitcode IS NULL) + AND (total.WED_Unit = @WED_Unit OR @WED_Unit IS NULL) + + + + + + + + + + + + + + + + +GO + + +CREATE VIEW [dbo].[View_UnitPerformance] +AS +SELECT + NEWID() AS Id, + --total.ProjectId, + --project.ProjectCode,--Ê©¹¤ºÅ + '' as ProjectCode, + total.WED_Unit, + un.UnitCode,-- µ¥Î»´úÂë + un.UnitName,--µ¥Î»Ãû³Æ + -------------±¾ÆÚstart + CAST(ISNULL(total.totalSize,0) AS DECIMAL(19,2)) AS totalSize, --×Ü´ç¾¶ + ISNULL(total.totalJoint,0) AS totalJoint, --×ܺ¸¿Ú + ISNULL(JointNum1.JointNum1,0) AS JointNum1, --Ò»´ÎÅÄÆ¬º¸¿ÚÊý + + ISNULL(JointNum1.JointNum1,0)-ISNULL(JointNoPassNum1.JointNoPassNum1,0) AS JointPassNum1, --Ò»´ÎÅÄÆ¬ºÏ¸ñº¸¿ÚÊý + ISNULL(JointNoPassNum1.JointNoPassNum1,0) AS RepairJoint1, --Ò»´Î·µÐÞº¸¿ÚÊý + ISNULL(RepairJoint2.RepairJoint2,0) AS RepairJoint2, --¶þ´Î·µÐÞº¸¿ÚÊý + ISNULL(RepairJoint3.RepairJoint3,0) AS RepairJoint3, --Èý´Î·µÐÞº¸¿ÚÊý + + CAST((CASE ISNULL((ISNULL(JointNum1.JointNum1,0)-ISNULL(JointNoPassNum1.JointNoPassNum1,0)),0) WHEN 0 THEN 0 + ELSE (CASE(ISNULL(JointNum1.JointNum1,0)) WHEN 0 THEN 0 + ELSE 1.0 * ISNULL((ISNULL(JointNum1.JointNum1,0)-ISNULL(JointNoPassNum1.JointNoPassNum1,0)),0)/(1.0 * JointNum1.JointNum1)*100 + END)END) AS DECIMAL(19,3)) AS JointPassRate , ---Ò»´ÎÅÄÆ¬º¸¿ÚºÏ¸ñÂÊ + + ISNULL(JointNum1.totalfilm,0) AS totalfilm, --Ò»´ÎÅÄÆ¬Êý + (ISNULL(JointNum1.totalfilm,0)- ISNULL(JointNoPassNum2.JointNoPassFilmNum2,0)) AS totalPassfilm, --Ò»´ÎÅÄÆ¬ºÏ¸ñÊý + ISNULL(JointNoPassNum2.JointNoPassFilmNum2,0) AS repairFilm1, --Ò»´Î·µÐÞÆ¬×ÓÊý + + ISNULL(RepairJoint2.repairFilm2,0) AS repairFilm2, --¶þ´Î·µÐÞÆ¬×ÓÊý + ISNULL(RepairJoint3.repairFilm3,0) AS repairFilm3, --Èý´Î·µÐÞÆ¬×ÓÊý + + CAST((CASE (ISNULL(JointNum1.totalfilm,0)- ISNULL(JointNoPassNum2.JointNoPassFilmNum2,0)) WHEN 0 THEN 0 + ELSE (CASE(ISNULL(JointNum1.totalfilm,0)) WHEN 0 THEN 0 + ELSE 1.0 * (ISNULL(JointNum1.totalfilm,0)- ISNULL(JointNoPassNum2.JointNoPassFilmNum2,0))/(1.0 * JointNum1.totalfilm)*100 + END) END) AS DECIMAL(19,3)) AS JointFilmPassRate ---Ò»´ÎÅÄÆ¬ºÏ¸ñÂÊ + +FROM + --×Ü´ïÒòÖµ --×ܺ¸¿Ú + (SELECT SUM(joint.JOT_Size) AS totalSize,COUNT(*) AS totalJoint + ,joint.WED_Unit + FROM View_JointWelder joint + LEFT JOIN HJGL_BO_WeldReportMain report ON joint.DReportID = report.DReportID + WHERE joint.DReportID IS NOT NULL + GROUP BY joint.WED_Unit) AS total + + +--Ò»´ÎÅÄÆ¬º¸¿ÚÊý , Ò»´ÎÅÄÆ¬×ÜÊý,Ò»´ÎÅÄÆ¬ºÏ¸ñ×ÜÊý + LEFT JOIN (SELECT COUNT(joint.JOT_ID) AS JointNum1, SUM(joint.RT_FilmNum) AS totalfilm, + joint.WED_Unit + FROM dbo.View_JointWelder joint + WHERE joint.PointType='µã¿Ú' AND joint.RT_FilmNum IS NOT NULL and joint.RT_FilmNum>0 and (select COUNT(*) from dbo.HJGL_BO_QualityRating a +left join HJGL_CH_TrustItem b on a.CH_TrustItemID=b.CH_TrustItemID +left join HJGL_CH_Trust c on b.CH_TrustID=c.CH_TrustID where a.JOT_ID=joint.JOT_ID and FilmNum is not null and c.CH_NDTMethod='20d2cbca-8b3d-434b-b1c1-181796986fa5')>0 + AND joint.dreportid IS NOT NULL + GROUP BY joint.WED_Unit) AS JointNum1 + ON JointNum1.WED_Unit = total.WED_Unit + + --Ò»´ÎÅÄÆ¬²»ºÏ¸ñº¸¿ÚÊý + LEFT JOIN (SELECT COUNT(distinct joint.JOT_ID) AS JointNoPassNum1, + joint.WED_Unit + FROM dbo.HJGL_CH_RepairItemRecord rr + left join dbo.View_JointWelder joint on rr.JOT_ID=joint.JOT_ID + WHERE joint.PointType='µã¿Ú' and rr.NDT_ID='20d2cbca-8b3d-434b-b1c1-181796986fa5' + --AND (joint.RT1_RepairFilm IS NOT NULL or (select top 1 CH_TrustItemID from dbo.HJGL_CH_TrustItem ti where ti.JOT_ID=joint.JOT_ID and ti.States='4') is not null) + AND joint.dreportid IS NOT NULL and rr.RepairMark='R1' + GROUP BY joint.WED_Unit) AS JointNoPassNum1 + ON JointNoPassNum1.WED_Unit = total.WED_Unit + --Ò»´ÎÅÄÆ¬²»ºÏ¸ñÅÄÆ¬Êý + LEFT JOIN (SELECT count(rr.RepairItemRecordId) as JointNoPassFilmNum2, + joint.WED_Unit + FROM dbo.HJGL_CH_RepairItemRecord rr + left join dbo.View_JointWelder joint on rr.JOT_ID=joint.JOT_ID + WHERE joint.PointType='µã¿Ú' and rr.NDT_ID='20d2cbca-8b3d-434b-b1c1-181796986fa5' + --AND (joint.RT1_RepairFilm IS NOT NULL or (select top 1 CH_TrustItemID from dbo.HJGL_CH_TrustItem ti where ti.JOT_ID=joint.JOT_ID and ti.States='4') is not null) + AND joint.dreportid IS NOT NULL and rr.RepairMark='R1' + GROUP BY joint.WED_Unit) AS JointNoPassNum2 + ON JointNoPassNum2.WED_Unit = total.WED_Unit + --¶þ´Î·µÐÞÅÄÆ¬º¸¿ÚÊý,¶þ´Î·µÐÞÅÄÆ¬×ÜÊý + LEFT JOIN (SELECT COUNT(joint.JOT_ID) AS RepairJoint2, SUM(ISNULL(joint.RT2_RepairFilmNum,0)) AS RepairFilm2, + joint.WED_Unit + FROM dbo.View_JointWelder joint + WHERE joint.PointType='µã¿Ú' AND joint.RT2_RepairFilm IS NOT NULL + AND joint.dreportid IS NOT NULL + GROUP BY joint.WED_Unit) AS RepairJoint2 + ON RepairJoint2.WED_Unit = total.WED_Unit + + + + --Èý´Î·µÐÞÅÄÆ¬º¸¿ÚÊý,Èý´Î·µÐÞÅÄÆ¬×ÜÊý + LEFT JOIN (SELECT COUNT(joint.JOT_ID) AS RepairJoint3, SUM(ISNULL(joint.RT3_RepairFilmNum,0)) AS RepairFilm3, + joint.WED_Unit + FROM dbo.View_JointWelder joint + WHERE joint.PointType='µã¿Ú' AND joint.RT3_RepairFilm IS NOT NULL + AND joint.dreportid IS NOT NULL + GROUP BY joint.WED_Unit) AS RepairJoint3 + ON RepairJoint3.WED_Unit = total.WED_Unit + +--LEFT JOIN Base_Project project ON total.ProjectId=project.ProjectId +LEFT JOIN dbo.Base_Unit un ON un.UnitId=total.WED_Unit \ No newline at end of file