CNCEC_SUBQHSE_WUHUAN/DataBase/版本日志/已更新脚本/SGGLDB_V2021-01-05-001.sql

397 lines
20 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.

INSERT INTO dbo.Sys_Menu(MenuId,MenuName,Url,SortIndex,SuperMenu,MenuType,IsOffice,IsEnd,IsUsed)
VALUES('7ecf0229-8a0b-40ce-8b04-e556f7bd3394','质量报表管理','',15,'0','Menu_CQMS',0,0,1)
GO
INSERT INTO dbo.Sys_Menu(MenuId,MenuName,Url,SortIndex,SuperMenu,MenuType,IsOffice,IsEnd,IsUsed)
VALUES('69327975-cd18-4443-8d2c-c8b6e31be5ef','现场检查情况','CQMS/ManageReport/CheckStatisc.aspx',10,'7ecf0229-8a0b-40ce-8b04-e556f7bd3394','Menu_CQMS',0,1,1)
GO
INSERT INTO dbo.Sys_ButtonToMenu(ButtonToMenuId,MenuId,ButtonName,SortIndex)
VALUES('270d071a-111c-4645-98a3-3996d56ab47c','69327975-cd18-4443-8d2c-c8b6e31be5ef','导出',1)
GO
INSERT INTO dbo.Sys_Menu(MenuId,MenuName,Url,SortIndex,SuperMenu,MenuType,IsOffice,IsEnd,IsUsed)
VALUES('e58366b4-70a5-41d1-a26f-0ab4a234004c','现场焊接无损检测情况','CQMS/ManageReport/HJGLStatisc.aspx',11,'7ecf0229-8a0b-40ce-8b04-e556f7bd3394','Menu_CQMS',0,1,1)
GO
INSERT INTO dbo.Sys_ButtonToMenu(ButtonToMenuId,MenuId,ButtonName,SortIndex)
VALUES('df992b1f-ef61-427f-9396-b997a3d66b37','e58366b4-70a5-41d1-a26f-0ab4a234004c','导出',1)
GO
INSERT INTO dbo.Sys_Menu(MenuId,MenuName,Url,SortIndex,SuperMenu,MenuType,IsOffice,IsEnd,IsUsed)
VALUES('0c65cad2-2279-48fc-b78c-82bfbe01f037','NCR统计','CQMS/ManageReport/NCRStatisc.aspx',12,'7ecf0229-8a0b-40ce-8b04-e556f7bd3394','Menu_CQMS',0,1,1)
GO
INSERT INTO dbo.Sys_ButtonToMenu(ButtonToMenuId,MenuId,ButtonName,SortIndex)
VALUES('7b422d89-845c-4639-9691-46dfa606de22','0c65cad2-2279-48fc-b78c-82bfbe01f037','导出',1)
GO
INSERT INTO dbo.Sys_Menu(MenuId,MenuName,Url,SortIndex,SuperMenu,MenuType,IsOffice,IsEnd,IsUsed)
VALUES('227d640a-9494-41ce-95bf-748dd59e986f','设计变更单统计统计','CQMS/ManageReport/DesignChangeStatisc.aspx',13,'7ecf0229-8a0b-40ce-8b04-e556f7bd3394','Menu_CQMS',0,1,1)
GO
INSERT INTO dbo.Sys_ButtonToMenu(ButtonToMenuId,MenuId,ButtonName,SortIndex)
VALUES('9c7b4c22-a6da-4355-9ab4-18a654b2b945','227d640a-9494-41ce-95bf-748dd59e986f','导出',1)
GO
INSERT INTO dbo.Sys_Menu(MenuId,MenuName,Url,SortIndex,SuperMenu,MenuType,IsOffice,IsEnd,IsUsed)
VALUES('51ee983f-085e-4f02-b819-cab049d9cc26','施工质量周报','CQMS/ManageReport/WeekReport.aspx',14,'7ecf0229-8a0b-40ce-8b04-e556f7bd3394','Menu_CQMS',0,1,1)
GO
INSERT INTO dbo.Sys_ButtonToMenu(ButtonToMenuId,MenuId,ButtonName,SortIndex)VALUES('67c751e6-f383-43b1-b27f-a02650b35c43','51ee983f-085e-4f02-b819-cab049d9cc26','增加',1)
INSERT INTO dbo.Sys_ButtonToMenu(ButtonToMenuId,MenuId,ButtonName,SortIndex)VALUES('dff8612c-8286-4c19-87e3-0e6f0084fe76','51ee983f-085e-4f02-b819-cab049d9cc26','修改',2)
INSERT INTO dbo.Sys_ButtonToMenu(ButtonToMenuId,MenuId,ButtonName,SortIndex)VALUES('8a274c0e-c451-4e70-a00d-e4c424ff7bef','51ee983f-085e-4f02-b819-cab049d9cc26','删除',3)
INSERT INTO dbo.Sys_ButtonToMenu(ButtonToMenuId,MenuId,ButtonName,SortIndex)VALUES('73841c94-34ca-4b2a-a71a-f097e6213a89','51ee983f-085e-4f02-b819-cab049d9cc26','保存',4)
GO
INSERT INTO dbo.Sys_Menu(MenuId,MenuName,Url,SortIndex,SuperMenu,MenuType,IsOffice,IsEnd,IsUsed)
VALUES('8048c87a-c2b6-4a0d-bca9-f4f2dca42e5b','施工质量月报','CQMS/ManageReport/MonthReport.aspx',15,'7ecf0229-8a0b-40ce-8b04-e556f7bd3394','Menu_CQMS',0,1,1)
GO
INSERT INTO dbo.Sys_ButtonToMenu(ButtonToMenuId,MenuId,ButtonName,SortIndex)VALUES('447eaa20-f042-4f1f-8601-2dfbdbb2a2ea','8048c87a-c2b6-4a0d-bca9-f4f2dca42e5b','增加',1)
INSERT INTO dbo.Sys_ButtonToMenu(ButtonToMenuId,MenuId,ButtonName,SortIndex)VALUES('d6ae28c6-653b-4ce7-afec-d9b895d3ae02','8048c87a-c2b6-4a0d-bca9-f4f2dca42e5b','修改',2)
INSERT INTO dbo.Sys_ButtonToMenu(ButtonToMenuId,MenuId,ButtonName,SortIndex)VALUES('7667b6ea-115c-401b-8039-ee9d54ffddfe','8048c87a-c2b6-4a0d-bca9-f4f2dca42e5b','删除',3)
INSERT INTO dbo.Sys_ButtonToMenu(ButtonToMenuId,MenuId,ButtonName,SortIndex)VALUES('379f3b5e-a31c-402b-b0fb-80ab0e6117b8','8048c87a-c2b6-4a0d-bca9-f4f2dca42e5b','保存',4)
GO
alter table [dbo].[Base_Unit] add UnitAttribute char(1)
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'单位属性1-集团公司2-子公司)' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Base_Unit', @level2type=N'COLUMN',@level2name=N'UnitAttribute'
GO
CREATE TABLE [dbo].[Report_WeekAndMonthReport](
[ReportId] [nvarchar](50) NOT NULL,
[Period] [int] NULL,
[StartDate] [datetime] NULL,
[EndDate] [datetime] NULL,
[ProjectId] [nvarchar](50) NULL,
[ReportType] [char](1) NULL,
CONSTRAINT [PK_Report_ReportMain] PRIMARY KEY CLUSTERED
(
[ReportId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
ALTER TABLE [dbo].[Report_WeekAndMonthReport] WITH CHECK ADD CONSTRAINT [FK_Report_WeekAndMonthReport_Base_Project] FOREIGN KEY([ProjectId])
REFERENCES [dbo].[Base_Project] ([ProjectId])
GO
ALTER TABLE [dbo].[Report_WeekAndMonthReport] CHECK CONSTRAINT [FK_Report_WeekAndMonthReport_Base_Project]
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'主键' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Report_WeekAndMonthReport', @level2type=N'COLUMN',@level2name=N'ReportId'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Report_WeekAndMonthReport', @level2type=N'COLUMN',@level2name=N'Period'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'开始时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Report_WeekAndMonthReport', @level2type=N'COLUMN',@level2name=N'StartDate'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'结束时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Report_WeekAndMonthReport', @level2type=N'COLUMN',@level2name=N'EndDate'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'项目Id' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Report_WeekAndMonthReport', @level2type=N'COLUMN',@level2name=N'ProjectId'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'报表类型1-周报、2-月报)' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Report_WeekAndMonthReport', @level2type=N'COLUMN',@level2name=N'ReportType'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'施工质量周报和月报表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Report_WeekAndMonthReport'
GO
CREATE TABLE [dbo].[Report_ThisWeekOrMonthContent](
[ContentId] [nvarchar](50) NOT NULL,
[ReportId] [nvarchar](50) NOT NULL,
[Contents] [nvarchar](500) NULL,
CONSTRAINT [PK_Report_ThisWeekOrMonthContent] PRIMARY KEY CLUSTERED
(
[ContentId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[Report_ThisWeekOrMonthContent] WITH CHECK ADD CONSTRAINT [FK_Report_ThisWeekOrMonthContent_Report_WeekAndMonthReport] FOREIGN KEY([ReportId])
REFERENCES [dbo].[Report_WeekAndMonthReport] ([ReportId])
GO
ALTER TABLE [dbo].[Report_ThisWeekOrMonthContent] CHECK CONSTRAINT [FK_Report_ThisWeekOrMonthContent_Report_WeekAndMonthReport]
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'主键' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Report_ThisWeekOrMonthContent', @level2type=N'COLUMN',@level2name=N'ContentId'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'报表Id' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Report_ThisWeekOrMonthContent', @level2type=N'COLUMN',@level2name=N'ReportId'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'本周(月)主要工作内容' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Report_ThisWeekOrMonthContent'
GO
CREATE TABLE [dbo].[Report_Comprehensive](
[ComprehensiveId] [nvarchar](50) NOT NULL,
[ReportId] [nvarchar](50) NULL,
[TotalCount] [int] NULL,
[EquipmentRate] [nvarchar](50) NULL,
[Others] [nvarchar](1000) NULL,
CONSTRAINT [PK_Report_Comprehensive] PRIMARY KEY CLUSTERED
(
[ComprehensiveId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[Report_Comprehensive] WITH CHECK ADD CONSTRAINT [FK_Report_Comprehensive_Report_WeekAndMonthReport] FOREIGN KEY([ReportId])
REFERENCES [dbo].[Report_WeekAndMonthReport] ([ReportId])
GO
ALTER TABLE [dbo].[Report_Comprehensive] CHECK CONSTRAINT [FK_Report_Comprehensive_Report_WeekAndMonthReport]
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'报表ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Report_Comprehensive', @level2type=N'COLUMN',@level2name=N'ReportId'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'设备共计台数' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Report_Comprehensive', @level2type=N'COLUMN',@level2name=N'TotalCount'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'报验比例' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Report_Comprehensive', @level2type=N'COLUMN',@level2name=N'EquipmentRate'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'其它报验' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Report_Comprehensive', @level2type=N'COLUMN',@level2name=N'Others'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'周(月)报综合管理' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Report_Comprehensive'
GO
CREATE TABLE [dbo].[Report_ConstructionProblems](
[ConstructionProblemsId] [nvarchar](50) NOT NULL,
[ReportId] [nvarchar](50) NOT NULL,
[UnitId] [nvarchar](50) NULL,
[ProblemDesrioption] [nvarchar](200) NULL,
[TreatmentMeasures] [nvarchar](200) NULL,
[ProcessingResults] [nvarchar](100) NULL,
[Remark] [nvarchar](500) NULL,
CONSTRAINT [PK_Report_ConstructionProblems] PRIMARY KEY CLUSTERED
(
[ConstructionProblemsId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[Report_ConstructionProblems] WITH CHECK ADD CONSTRAINT [FK_Report_ConstructionProblems_Base_Unit] FOREIGN KEY([UnitId])
REFERENCES [dbo].[Base_Unit] ([UnitId])
GO
ALTER TABLE [dbo].[Report_ConstructionProblems] CHECK CONSTRAINT [FK_Report_ConstructionProblems_Base_Unit]
GO
ALTER TABLE [dbo].[Report_ConstructionProblems] WITH CHECK ADD CONSTRAINT [FK_Report_ConstructionProblems_Report_WeekAndMonthReport] FOREIGN KEY([ReportId])
REFERENCES [dbo].[Report_WeekAndMonthReport] ([ReportId])
GO
ALTER TABLE [dbo].[Report_ConstructionProblems] CHECK CONSTRAINT [FK_Report_ConstructionProblems_Report_WeekAndMonthReport]
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'主键' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Report_ConstructionProblems', @level2type=N'COLUMN',@level2name=N'ConstructionProblemsId'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'报表Id' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Report_ConstructionProblems', @level2type=N'COLUMN',@level2name=N'ReportId'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'施工分包商' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Report_ConstructionProblems', @level2type=N'COLUMN',@level2name=N'UnitId'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'问题描述' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Report_ConstructionProblems', @level2type=N'COLUMN',@level2name=N'ProblemDesrioption'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'处理措施' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Report_ConstructionProblems', @level2type=N'COLUMN',@level2name=N'TreatmentMeasures'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'处理结果' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Report_ConstructionProblems', @level2type=N'COLUMN',@level2name=N'ProcessingResults'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'备注' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Report_ConstructionProblems', @level2type=N'COLUMN',@level2name=N'Remark'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'施工过程问题表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Report_ConstructionProblems'
GO
CREATE TABLE [dbo].[Report_NextQualityControl](
[NextQualityControlId] [nvarchar](50) NOT NULL,
[ReportId] [nvarchar](50) NOT NULL,
[NextQualityControlContent] [nvarchar](500) NULL,
CONSTRAINT [PK_Report_NextQualityControl] PRIMARY KEY CLUSTERED
(
[NextQualityControlId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[Report_NextQualityControl] WITH CHECK ADD CONSTRAINT [FK_Report_NextQualityControl_Report_WeekAndMonthReport] FOREIGN KEY([ReportId])
REFERENCES [dbo].[Report_WeekAndMonthReport] ([ReportId])
GO
ALTER TABLE [dbo].[Report_NextQualityControl] CHECK CONSTRAINT [FK_Report_NextQualityControl_Report_WeekAndMonthReport]
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'主键' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Report_NextQualityControl', @level2type=N'COLUMN',@level2name=N'NextQualityControlId'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'报表Id' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Report_NextQualityControl', @level2type=N'COLUMN',@level2name=N'ReportId'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'下周质量控制重点' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Report_NextQualityControl', @level2type=N'COLUMN',@level2name=N'NextQualityControlContent'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'下周质量控制重点表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Report_NextQualityControl'
GO
CREATE TABLE [dbo].[Report_ReportServer](
[ReportId] [nchar](3) NOT NULL,
[TabContent] [ntext] NULL,
[ReportName] [nvarchar](100) NULL,
[InitTabContent] [ntext] NULL,
CONSTRAINT [PK_Report_ReportServer] PRIMARY KEY CLUSTERED
(
[ReportId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'报表ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Report_ReportServer', @level2type=N'COLUMN',@level2name=N'ReportId'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'报表模板内容' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Report_ReportServer', @level2type=N'COLUMN',@level2name=N'TabContent'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'报表名称' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Report_ReportServer', @level2type=N'COLUMN',@level2name=N'ReportName'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'初始模板内容' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Report_ReportServer', @level2type=N'COLUMN',@level2name=N'InitTabContent'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'报表服务表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Report_ReportServer'
GO
CREATE TABLE [dbo].[Report_RowMaterialProblem](
[RowMaterialProblemId] [nvarchar](50) NOT NULL,
[ReportId] [nvarchar](50) NOT NULL,
[UnitId] [nvarchar](50) NULL,
[ProblemDesrioption] [nvarchar](200) NULL,
[TreatmentMeasures] [nvarchar](200) NULL,
[ProcessingResults] [nvarchar](100) NULL,
[Remark] [nvarchar](500) NULL,
CONSTRAINT [PK_Report_RowMaterialProblem] PRIMARY KEY CLUSTERED
(
[RowMaterialProblemId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[Report_RowMaterialProblem] WITH CHECK ADD CONSTRAINT [FK_Report_RowMaterialProblem_Report_WeekAndMonthReport] FOREIGN KEY([ReportId])
REFERENCES [dbo].[Report_WeekAndMonthReport] ([ReportId])
GO
ALTER TABLE [dbo].[Report_RowMaterialProblem] CHECK CONSTRAINT [FK_Report_RowMaterialProblem_Report_WeekAndMonthReport]
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'主键' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Report_RowMaterialProblem', @level2type=N'COLUMN',@level2name=N'RowMaterialProblemId'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'报表Id' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Report_RowMaterialProblem', @level2type=N'COLUMN',@level2name=N'ReportId'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'供应商' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Report_RowMaterialProblem', @level2type=N'COLUMN',@level2name=N'UnitId'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'问题描述' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Report_RowMaterialProblem', @level2type=N'COLUMN',@level2name=N'ProblemDesrioption'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'处理措施' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Report_RowMaterialProblem', @level2type=N'COLUMN',@level2name=N'TreatmentMeasures'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'处理结果' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Report_RowMaterialProblem', @level2type=N'COLUMN',@level2name=N'ProcessingResults'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'备注' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Report_RowMaterialProblem', @level2type=N'COLUMN',@level2name=N'Remark'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'原材料问题表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Report_RowMaterialProblem'
GO
CREATE VIEW [dbo].[View_Report_ConstructionProblems]
AS
SELECT C.ConstructionProblemsId,
C.ReportId,
C.UnitId,
C.ProblemDesrioption,
C.TreatmentMeasures,
C.ProcessingResults,
C.Remark,
U.UnitName
FROM dbo.Report_ConstructionProblems AS C
LEFT JOIN dbo.Base_Unit AS U ON U.UnitId=C.UnitId
GO
CREATE PROCEDURE [dbo].[Sp_ProcessControl_NondestructiveTestStatisc]
@projectId nvarchar(50),
@startDate datetime,
@endDate datetime
AS
select ROW_NUMBER() OVER (ORDER BY t.UnitId) AS Num,
Unit.UnitName,InspectionArea.InspectionAreaName,t.CheckNum,
t.TotalCheckNum,t.OKNum,t.TotalOKNum,
CAST(CAST((CASE ISNULL(t.CheckNum ,0)
WHEN 0 THEN 0
ELSE (1.0 * ISNULL(t.OKNum,0) / (1.0 * t.CheckNum))*100
END) AS DECIMAL(10,1)) as nvarchar(10)) +'%' AS OneOKRate,
t.TotalOneOKRate from
(SELECT
n.UnitId,n.InspectionAreaId,
(SELECT ISNULL(SUM(n1.PieceCount),0) FROM ProcessControl_NondestructiveTest AS n1
WHERE n.UnitId=n1.UnitId and n.InspectionAreaId=n1.InspectionAreaId
AND n1.NondestructiveTestDate>=@startDate
AND n1.NondestructiveTestDate<=@endDate) as CheckNum,--当期数量
ISNULL(SUM(n.PieceCount),0) AS TotalCheckNum, --累计数量
(SELECT ISNULL(SUM(n2.OnceQualifiedCount),0) FROM ProcessControl_NondestructiveTest AS n2
WHERE n.UnitId=n2.UnitId and n.InspectionAreaId=n2.InspectionAreaId AND (n2.NondestructiveTestDate>=@startDate
AND n2.NondestructiveTestDate<=@endDate)) AS OKNum, --当期一次合格数量
ISNULL(SUM(n.OnceQualifiedCount),0)AS TotalOKNum, --累计一次合格数量
ISNULL((LTRIM(CAST(SUM(n.OnceQualifiedCount)*1.0/
SUM(n.PieceCount)*100 AS DEC(10,2)))+'%'),0) AS TotalOneOKRate --累计一次合格率
FROM ProcessControl_NondestructiveTest n
WHERE n.ProjectId =@projectId
GROUP BY n.UnitId,n.InspectionAreaId) t
LEFT JOIN dbo.Base_Unit AS Unit ON Unit.UnitId= t.UnitId
LEFT JOIN Base_InspectionArea AS InspectionArea ON InspectionArea.InspectionAreaId= t.InspectionAreaId
GO