Files
SGGL_SHJ/DataBase/版本日志/已更新脚本/2020年度/SGGLDB_V2020-07-28-001.sql
T
2022-09-05 16:36:31 +08:00

49 lines
2.2 KiB
Transact-SQL

ALTER TABLE [dbo].[Check_CheckSpecialDetail] ADD HiddenHazardType NVARCHAR(50) NULL
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'隐患类别' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Check_CheckSpecialDetail', @level2type=N'COLUMN',@level2name=N'HiddenHazardType'
GO
ALTER VIEW [dbo].[View_CheckSpecialDetail]
AS
/*专项检查明细列表视图*/
SELECT detail.CheckSpecialDetailId,
detail.CheckSpecialId,
detail.CheckItem,
checkItemSet.CheckItemName,
detail.CheckItemType,
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.Suggestions,
detail.CheckContent,
detail.CheckArea,
detail.DataId,
detail.DataType,
detail.WorkArea,
unit.UnitName,
dbo.GetConstTextByIds(detail.HandleStep) as HandleStepStr,
--const.ConstText 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.DataType like '%1%' THEN (CASE WHEN detail.HiddenHazardType='3' THEN '重大'
WHEN detail.HiddenHazardType='2' THEN '较大'
WHEN detail.HiddenHazardType='1' THEN '一般' ELSE '' END) ELSE '' END) AS HiddenHazardTypeName
FROM dbo.Check_CheckSpecialDetail AS detail
LEFT JOIN dbo.Technique_CheckItemSet AS checkItemSet ON checkItemSet.CheckItemSetId=detail.CheckItem
LEFT JOIN dbo.Base_Unit AS unit ON unit.UnitId=detail.UnitId
--LEFT JOIN dbo.WBS_UnitWork AS workArea ON detail.CheckArea=workArea.UnitWorkId
--LEFT JOIN Sys_Const AS const ON const.ConstValue = detail.HandleStep and const.GroupId='HandleStep'
GO