USE [CallCenter_XinXiangXLX]
GO
/****** Object:  StoredProcedure [dbo].[P_GetHolidays]    Script Date: 06/25/2019 10:13:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

ALTER PROCEDURE [dbo].[P_GetHolidays] 
AS
BEGIN
	SET NOCOUNT ON;	
	declare @count int=0;	
	declare @count_Time int=0;
	--declare @count_GZR int=0;
	declare @count_Result int=0;
	--declare @count_zbdh int=0;	-- 有无值班电话	
	declare @HolidaysCode nvarchar(10)='GZR';--默认为工作日 code=GZR
	
	--读取是否是节假日
	SELECT @count = count(*) FROM T_Sys_WorkOFFDays where F_OffState=0 AND DATEDIFF(day,f_offDate,getdate())=0
	
	--是节假日读取时间 code=JJR
	if @count>0
		begin
			set @HolidaysCode='JJR';
		end
	
	--读取是否是节假日或工作日的工作时间
	SELECT @count_Time = count(*) FROM T_Sys_WorkTimes 
		WHERE F_HolidaysCode =@HolidaysCode 
			and Convert(varchar(20),getdate(),108)>=F_StartDate and Convert(varchar(20),getdate(),108)<=F_EndDate

	--判断是否是工作时间
	if @count>0
	begin
		set @count_Result=0
	end
	else 
	begin
		if(@count_Time > 0) 
			begin
			 set @count_Result=1 
			end
		else 
			 begin
			 set @count_Result=0
		end
	end
	
	--1是工作时间,0是非工作时间
	select @count_Result;
END
