154 lines
		
	
	
		
			7.2 KiB
		
	
	
	
		
			Transact-SQL
		
	
	
	
			
		
		
	
	
			154 lines
		
	
	
		
			7.2 KiB
		
	
	
	
		
			Transact-SQL
		
	
	
	
--员工管理
 | 
						||
INSERT INTO Sys_Menu(MenuId,MenuName,Url,SortIndex,SuperMenu,MenuType,IsOffice,IsEnd,IsUsed)
 | 
						||
VALUES('0E46F8F2-69DB-4F54-BCA0-1F3CBE57DA10','人员初步规划','Person/PersonPlan.aspx',80,'0','Menu_Person',1,1,1)
 | 
						||
GO
 | 
						||
INSERT INTO dbo.Sys_ButtonToMenu(ButtonToMenuId,MenuId,ButtonName,SortIndex)
 | 
						||
VALUES('34D71F63-D749-4307-9268-8348F3F81ACB','0E46F8F2-69DB-4F54-BCA0-1F3CBE57DA10','导入',1)
 | 
						||
GO	
 | 
						||
 | 
						||
CREATE TABLE [dbo].[Person_PersonPlan](
 | 
						||
	[PersonPlanId] [nvarchar](50) NOT NULL,
 | 
						||
	[DepartId] [nvarchar](50) NULL,
 | 
						||
	[UserId] [nvarchar](50) NULL,
 | 
						||
	[Major] [nvarchar](50) NULL,
 | 
						||
	[ProjectId] [nvarchar](50) NULL,
 | 
						||
	[PersonType] [nchar](10) NULL,
 | 
						||
	[Years] [int] NULL,
 | 
						||
	[Month1] [bit] NULL,
 | 
						||
	[Month2] [bit] NULL,
 | 
						||
	[Month3] [bit] NULL,
 | 
						||
	[Month4] [bit] NULL,
 | 
						||
	[Month5] [bit] NULL,
 | 
						||
	[Month6] [bit] NULL,
 | 
						||
	[Month7] [bit] NULL,
 | 
						||
	[Month8] [bit] NULL,
 | 
						||
	[Month9] [bit] NULL,
 | 
						||
	[Month10] [bit] NULL,
 | 
						||
	[Month11] [bit] NULL,
 | 
						||
	[Month12] [bit] NULL,
 | 
						||
	[Remark] [nvarchar](500) NULL,
 | 
						||
 CONSTRAINT [PK_Person_PersonPlan] PRIMARY KEY CLUSTERED 
 | 
						||
(
 | 
						||
	[PersonPlanId] 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].[Person_PersonPlan]  WITH CHECK ADD  CONSTRAINT [FK_Person_PersonPlan_Base_Depart] FOREIGN KEY([DepartId])
 | 
						||
REFERENCES [dbo].[Base_Depart] ([DepartId])
 | 
						||
GO
 | 
						||
 | 
						||
ALTER TABLE [dbo].[Person_PersonPlan] CHECK CONSTRAINT [FK_Person_PersonPlan_Base_Depart]
 | 
						||
GO
 | 
						||
 | 
						||
ALTER TABLE [dbo].[Person_PersonPlan]  WITH CHECK ADD  CONSTRAINT [FK_Person_PersonPlan_Base_Project] FOREIGN KEY([ProjectId])
 | 
						||
REFERENCES [dbo].[Base_Project] ([ProjectId])
 | 
						||
GO
 | 
						||
 | 
						||
ALTER TABLE [dbo].[Person_PersonPlan] CHECK CONSTRAINT [FK_Person_PersonPlan_Base_Project]
 | 
						||
GO
 | 
						||
 | 
						||
ALTER TABLE [dbo].[Person_PersonPlan]  WITH CHECK ADD  CONSTRAINT [FK_Person_PersonPlan_Sys_User] FOREIGN KEY([UserId])
 | 
						||
REFERENCES [dbo].[Sys_User] ([UserId])
 | 
						||
GO
 | 
						||
 | 
						||
ALTER TABLE [dbo].[Person_PersonPlan] CHECK CONSTRAINT [FK_Person_PersonPlan_Sys_User]
 | 
						||
GO
 | 
						||
 | 
						||
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'主键' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Person_PersonPlan', @level2type=N'COLUMN',@level2name=N'PersonPlanId'
 | 
						||
GO
 | 
						||
 | 
						||
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'部门Id' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Person_PersonPlan', @level2type=N'COLUMN',@level2name=N'DepartId'
 | 
						||
GO
 | 
						||
 | 
						||
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'人员Id' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Person_PersonPlan', @level2type=N'COLUMN',@level2name=N'UserId'
 | 
						||
GO
 | 
						||
 | 
						||
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'专业' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Person_PersonPlan', @level2type=N'COLUMN',@level2name=N'Major'
 | 
						||
GO
 | 
						||
 | 
						||
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'项目Id' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Person_PersonPlan', @level2type=N'COLUMN',@level2name=N'ProjectId'
 | 
						||
GO
 | 
						||
 | 
						||
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'人员类型(1-正式员工、2-外聘员工、3-中部人才)' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Person_PersonPlan', @level2type=N'COLUMN',@level2name=N'PersonType'
 | 
						||
GO
 | 
						||
 | 
						||
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'1月' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Person_PersonPlan', @level2type=N'COLUMN',@level2name=N'Month1'
 | 
						||
GO
 | 
						||
 | 
						||
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'2月' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Person_PersonPlan', @level2type=N'COLUMN',@level2name=N'Month2'
 | 
						||
GO
 | 
						||
 | 
						||
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'3月' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Person_PersonPlan', @level2type=N'COLUMN',@level2name=N'Month3'
 | 
						||
GO
 | 
						||
 | 
						||
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'4月' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Person_PersonPlan', @level2type=N'COLUMN',@level2name=N'Month4'
 | 
						||
GO
 | 
						||
 | 
						||
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'5月' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Person_PersonPlan', @level2type=N'COLUMN',@level2name=N'Month5'
 | 
						||
GO
 | 
						||
 | 
						||
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'6月' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Person_PersonPlan', @level2type=N'COLUMN',@level2name=N'Month6'
 | 
						||
GO
 | 
						||
 | 
						||
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'7月' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Person_PersonPlan', @level2type=N'COLUMN',@level2name=N'Month7'
 | 
						||
GO
 | 
						||
 | 
						||
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'8月' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Person_PersonPlan', @level2type=N'COLUMN',@level2name=N'Month8'
 | 
						||
GO
 | 
						||
 | 
						||
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'9月' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Person_PersonPlan', @level2type=N'COLUMN',@level2name=N'Month9'
 | 
						||
GO
 | 
						||
 | 
						||
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'10月' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Person_PersonPlan', @level2type=N'COLUMN',@level2name=N'Month10'
 | 
						||
GO
 | 
						||
 | 
						||
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'11月' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Person_PersonPlan', @level2type=N'COLUMN',@level2name=N'Month11'
 | 
						||
GO
 | 
						||
 | 
						||
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'12月' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Person_PersonPlan', @level2type=N'COLUMN',@level2name=N'Month12'
 | 
						||
GO
 | 
						||
 | 
						||
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'备注' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Person_PersonPlan', @level2type=N'COLUMN',@level2name=N'Remark'
 | 
						||
GO
 | 
						||
 | 
						||
CREATE VIEW View_Person_PersonPlan
 | 
						||
AS
 | 
						||
/******人员初步规划表******/
 | 
						||
SELECT p.PersonPlanId, 
 | 
						||
p.DepartId, 
 | 
						||
p.UserId, 
 | 
						||
p.Major, 
 | 
						||
p.ProjectId, 
 | 
						||
p.PersonType, 
 | 
						||
p.Years, 
 | 
						||
p.Month1, 
 | 
						||
p.Month2, 
 | 
						||
p.Month3, 
 | 
						||
p.Month4, 
 | 
						||
p.Month5, 
 | 
						||
p.Month6, 
 | 
						||
p.Month7, 
 | 
						||
p.Month8, 
 | 
						||
p.Month9, 
 | 
						||
p.Month10, 
 | 
						||
p.Month11, 
 | 
						||
p.Month12, 
 | 
						||
p.Remark,
 | 
						||
d.DepartName,
 | 
						||
u.UserName,
 | 
						||
pro.ProjectName,
 | 
						||
(CASE p.PersonType WHEN '1' THEN '正式员工' WHEN '2' THEN '外聘员工' WHEN '3' THEN '中部人才' END) AS PersonTypeName
 | 
						||
FROM Person_PersonPlan AS p
 | 
						||
LEFT JOIN Base_Depart AS d ON d.DepartId = p.DepartId
 | 
						||
LEFT JOIN Sys_User AS u ON u.UserId = p.UserId
 | 
						||
LEFT JOIN Base_Project AS pro ON pro.ProjectId = p.ProjectId
 | 
						||
GO
 | 
						||
ALTER TABLE [dbo].[Comprehensive_SpecialEquipment] DROP CONSTRAINT [FK_Comprehensive_SpecialEquipment_Base_Equipment]
 | 
						||
GO
 | 
						||
ALTER TABLE [dbo].[Comprehensive_SpecialEquipment]  WITH CHECK ADD  CONSTRAINT [FK_Comprehensive_SpecialEquipment_Base_SpecialEquipment] FOREIGN KEY([EquipmentId])
 | 
						||
REFERENCES [dbo].[Base_SpecialEquipment] ([SpecialEquipmentId])
 | 
						||
GO
 | 
						||
 | 
						||
ALTER TABLE [dbo].[Comprehensive_SpecialEquipment] CHECK CONSTRAINT [FK_Comprehensive_SpecialEquipment_Base_SpecialEquipment]
 | 
						||
GO |