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

49 lines
1.9 KiB
Transact-SQL

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,
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,
--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.HiddenHazardType='3' THEN '重大'
WHEN detail.HiddenHazardType='2' THEN '较大'
WHEN detail.HiddenHazardType='1' THEN '一般' 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