典型功能-预警设置

预警设置

预警管理

T8平台提供了预警定义功能,根据客户需求定义个性化预警设置,简化预警设置的步骤:

提示

T8中的预警必须先定义存储过程再配置显示功能,操作类似于自定义查询报表。

 

 

过程定义

 

1、存储过程名称必须是"Sp_Alarm_"开头,默认传入参数为@CurrentUserID uniqueidentifier,--当前登录用户;@IsDetail bit=0 --为0表示查询概览,1表示查询明细。


Alter proc [dbo].[Sp_Alarm_TestAlarm]
(@CurrentUserID uniqueidentifier,--当前登录用户
@IsDetail bit=0)
as

set nocount on

if @IsDetail = 0
select '当日在职人数: ' + cast(COUNT(ID) as nvarchar(200)) + '人' from T_EMP_Employee where isnull(DimissionDate,'9999-12-31')>=getdate()

else
select EmpCode,EmpName,HireDate from T_EMP_Employee where isnull(DimissionDate,'9999-12-31')>=getdate()

 

 

2、存储过程主体部分当@IsDetail=0时查询的是概览信息,如“当日人数总数是多少”,返回的语句只有一条,一个字段;


if @IsDetail = 0
select '当日在职人数: ' + cast(COUNT(ID) as nvarchar(200)) + '人' from T_EMP_Employee where isnull(DimissionDate,'9999-12-31')>=getdate()

3、存储过程主体部分当@IsDetail=1时查询的详细信息,当前预警信息的明细记录,返回语句的记录可以有多条,多个字段;


select EmpCode,EmpName,HireDate from T_EMP_Employee where isnull(DimissionDate,'9999-12-31')>=getdate()

 

4、我们可以在set nocount on 与if @IsDetail=0之间写入自己的语句,对于较为复杂的预警一个语句写不完的情况可以在此完成。


set nocount on

declare @BeginDate datetime, @EndDate datetime
SELECT @BeginDate=CONVERT(CHAR(10),DATEADD(dd,-DAY(GETDATE())+1,GETDATE()),111)
SELECT @EndDate=CONVERT(CHAR(10),DATEADD(ms,-3,DATEADD(mm,DATEDIFF(m,0,getdate())+1,0)),111)+' 23:59:59'

if exists (select * from tempdb..sysobjects where id = object_id('tempdb..#Emp'))
drop table [dbo].[#Emp]

select EmpCode,EmpName,DeptID,BirthDate,isnull(HireDate,'1900-01-01') HireDate,isnull(DimissionDate,'9999-12-31') DimissionDate,
(case when EmpGender=1 then '男' else '女' end) as EmpGender into #Emp from T_EMP_Employee
where BirthDate is not null and isnull(HireDate,'1900-01-01')<@EndDate and isnull(DimissionDate,'9999-12-31')>@BeginDate

delete #Emp where HireDate>DimissionDate

delete #Emp where dateadd(yy,datediff(yy,BirthDate,@BeginDate),BirthDate) not between @BeginDate and @EndDate

if @IsDetail = 0


备注

一个预警对应一个存储过程,如果客户要求同一个预警不同用户看到的内容不一致,可以根据传入的参数@CurrentUserID来处理。

 

预警设置

 

1、进入二次开发预警管理菜单,选择新增。

2、选择前一步定义好的存储过程名,输入预警编码与预警名称;

3、添加列名称,预警中配置添加的列名称必须与存储过程查询明细中的列名称一致,预警中配置的列名称可以少于存储过程查询明细的字段名。

 

 

 

预警查询

 

1、点击T8HR下面的状态栏中的预警,进入预警显示界面。

2、查询预警明细,双击要查阅的预警明细即可。可以在多个预警明细信息之前切换查阅不同的预警信息。

 

 

参见

 
常用功能
 

 

posted on 2018-03-09 10:58  vclose  阅读(1376)  评论(0)    收藏  举报