CNCEC_SUBQHSE_WUHUAN/DataBase/版本日志/SGGLDB_WH_2023-09-30.sql

48 lines
2.7 KiB
Transact-SQL
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

--专项检查检查记录接收人
alter table Check_CheckSpecial add ReceiveMan nvarchar(2000) null;
--States0-保存 1-提交 2-审核通过 3-已确认
--修改专项检查明细视图
/****** Object: View [dbo].[View_CheckSpecialDetail] Script Date: 2023/9/30 11:19:54 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*LEFT JOIN Sys_Const AS const ON const.ConstValue = detail.HandleStep and const.GroupId='HandleStep'*/
ALTER VIEW [dbo].[View_CheckSpecialDetail]
AS
SELECT detail.CheckSpecialDetailId, detail.CheckSpecialId, detail.CheckItem, checkItemSet.CheckItemName, detail.Unqualified,
detail.SortIndex, detail.UnitId, detail.HandleStep, detail.CompleteStatus,
(CASE WHEN detail.CompleteStatus = 1 THEN '合格' ELSE '不合格' END) AS CompleteStatusName, detail.LimitedDate,
detail.CompletedDate, detail.CheckContent, detail.CheckArea,
workArea.UnitWorkName + (CASE WHEN workArea.ProjectType = '1' THEN '(建筑)' WHEN workArea.ProjectType = '2' THEN '(安装)'
ELSE '' END) AS CheckAreaName, detail.DataId, detail.DataType, unit.UnitName,
dbo.GetConstTextByIds(detail.HandleStep) AS HandleStepStr,
(CASE WHEN detail.DataType LIKE '%1%' THEN '下发整改单:' +
(SELECT RectifyNoticesCode
FROM Check_RectifyNotices
WHERE detail.DataId LIKE '%' + RectifyNoticesId + '%') ELSE '' END)
+ (CASE WHEN detail.DataType LIKE '%2%' THEN '下发处罚单:' +
(SELECT PunishNoticeCode
FROM Check_PunishNotice
WHERE detail.DataId LIKE '%' + PunishNoticeId + '%') ELSE '' END)
+ (CASE WHEN detail.DataType = '3' THEN '下发暂停令:' +
(SELECT PauseNoticeCode
FROM Check_PauseNotice
WHERE detail.DataId LIKE '%' + PauseNoticeId + '%') ELSE '' END) AS HandleStepLink, detail.HiddenHazardType,
(CASE WHEN detail.HiddenHazardType = '3' THEN '重大' WHEN detail.HiddenHazardType = '2' THEN '较大' WHEN detail.HiddenHazardType
= '1' THEN '一般' ELSE '' END) AS HiddenHazardTypeName, detail.CheckItemSetId, detail.CheckItemSetContent,
detail.Rectification_Date
FROM dbo.Check_CheckSpecialDetail AS detail LEFT OUTER JOIN
dbo.Technique_CheckItemSet AS checkItemSet ON checkItemSet.CheckItemSetId = detail.CheckItem LEFT OUTER JOIN
dbo.Base_Unit AS unit ON unit.UnitId = detail.UnitId LEFT OUTER JOIN
dbo.WBS_UnitWork AS workArea ON detail.CheckArea = workArea.UnitWorkId
GO