好久没写博客,上一篇 没想到大家讨论还挻热烈,非常感谢大家关注和提出的一些建议和意见。
大家关注的还是两点:
1、现实流程会复杂得多;
2、流程平台需要复杂的设计(作图)工具。
我想说的是我这里不是做一个“大而全”的工作流平台,只是从最基本的地方入手,通过这样一些测试,让初学者发现工作流的一些原理。
了解这些原理后,你使用各种平台(如K2)开发就会清楚一些。
上篇算是一个概要设计,这篇简单的做一个数据库实现,本实现暂不包括“规则处理”,即由调用端决定下一手步骤和处理人。
兄弟刚离职,现在正找工作,关乎一家人是否有饭吃,所以时间不多,写得很粗糙,大家还请原谅则个!
用的sql server.
1、先建一个数据库MyData
2、执行一下结构脚本
GO
/****** Object: Table [dbo].[BaseUser] Script Date: 08/24/2012 11:50:20 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[BaseUser](
[ID] [int] IDENTITY(1,1) NOT NULL,
[UserName] [varchar](50) NOT NULL,
[PassWord] [varchar](50) NULL,
[UserDesc] [nvarchar](200) NULL,
[UnitID] [int] NULL,
[PostID] [int] NULL,
[LocationID] [int] NULL,
[Phone] [varchar](50) NULL,
[Email] [varchar](100) NULL,
[EnableFlag] [bit] NOT NULL,
CONSTRAINT [PK_MyUser] PRIMARY KEY CLUSTERED
(
[ID] 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
/****** Object: Table [dbo].[FlowStep] Script Date: 08/24/2012 11:50:20 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[FlowStep](
[ID] [int] IDENTITY(1,1) NOT NULL,
[StepID] [int] NOT NULL,
[FlowID] [int] NOT NULL,
[StepCode] [varchar](50) NOT NULL,
[StepName] [nvarchar](50) NOT NULL,
[IsJoin] [bit] NULL,
[Params] [xml] NULL,
[EnabeFlag] [bit] NOT NULL,
CONSTRAINT [PK_FlowStep] PRIMARY KEY CLUSTERED
(
[ID] 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
/****** Object: Table [dbo].[FlowInstance] Script Date: 08/24/2012 11:50:20 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[FlowInstance](
[ID] [int] IDENTITY(1,1) NOT NULL,
[FlowID] [int] NOT NULL,
[FlowName] [varchar](50) NOT NULL,
[UserID] [int] NOT NULL,
[UserName] [varchar](50) NOT NULL,
[ApplyUserName] [varchar](50) NULL,
[ApplyDateTime] [datetime] NULL,
[EndUserName] [varchar](50) NULL,
[EndDateTime] [datetime] NULL,
[StatusID] [int] NULL,
[StatusName] [varchar](50) NULL,
[ApplyStatus] [nvarchar](500) NULL,
CONSTRAINT [PK_FlowMain] PRIMARY KEY CLUSTERED
(
[ID] 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
/****** Object: Table [dbo].[FlowActionTraceData] Script Date: 08/24/2012 11:50:20 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[FlowActionTraceData](
[TraceID] [int] NOT NULL,
[Data] [xml] NULL,
CONSTRAINT [PK_FlowActionTraceData] PRIMARY KEY CLUSTERED
(
[TraceID] 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
/****** Object: Table [dbo].[FlowActionTrace] Script Date: 08/24/2012 11:50:20 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[FlowActionTrace](
[ID] [int] IDENTITY(1,1) NOT NULL,
[InstanceID] [int] NOT NULL,
[FlowID] [int] NOT NULL,
[FlowName] [nvarchar](50) NOT NULL,
[FlowCode] [varchar](50) NOT NULL,
[StepID] [int] NOT NULL,
[StepName] [nvarchar](50) NOT NULL,
[StepCode] [varchar](50) NOT NULL,
[ActionID] [int] NULL,
[ActionName] [nvarchar](50) NULL,
[ActionCode] [varchar](50) NULL,
[OwnerUserID] [int] NOT NULL,
[OwnerUserName] [varchar](50) NOT NULL,
[OwnerUserDesc] [nvarchar](50) NOT NULL,
[SubmitUserID] [int] NULL,
[SubmitUserName] [varchar](50) NULL,
[SubmitUserDesc] [nvarchar](50) NULL,
[ArriveTime] [datetime] NOT NULL,
[ReadTime] [datetime] NULL,
[SubmitTime] [datetime] NULL,
[PreID] [int] NOT NULL,
[SubmitMemo] [nvarchar](500) NULL,
CONSTRAINT [PK_FlowActionTrace] PRIMARY KEY CLUSTERED
(
[ID] 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
/****** Object: Table [dbo].[FlowAction] Script Date: 08/24/2012 11:50:20 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[FlowAction](
[ID] [int] IDENTITY(1,1) NOT NULL,
[ActionID] [int] NOT NULL,
[StepID] [int] NOT NULL,
[FlowID] [int] NOT NULL,
[ActionCode] [varchar](50) NOT NULL,
[ActionName] [nvarchar](50) NOT NULL,
[Params] [xml] NULL,
[EnableFlag] [bit] NOT NULL,
CONSTRAINT [PK_FlowAction] PRIMARY KEY CLUSTERED
(
[ID] 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
/****** Object: Table [dbo].[Flow] Script Date: 08/24/2012 11:50:20 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Flow](
[ID] [int] NOT NULL,
[FlowCode] [varchar](50) NOT NULL,
[FlowName] [nvarchar](50) NULL,
[FlowVersion] [varchar](50) NOT NULL,
[Params] [xml] NULL,
[EnableFlag] [bit] NOT NULL,
CONSTRAINT [PK_Flow_1] PRIMARY KEY CLUSTERED
(
[ID] 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
/****** Object: UserDefinedFunction [dbo].[f_splitstr] Script Date: 08/24/2012 11:50:20 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE function [dbo].[f_splitstr](@SourceSql varchar(8000),@StrSeprate varchar(100))
returns @temp table(F1 varchar(100))
as
begin
declare @ch as varchar(100)
set @SourceSql=@SourceSql+@StrSeprate
while(@SourceSql<>'')
begin
set @ch=left(@SourceSql,charindex(@StrSeprate,@SourceSql,1)-1)
insert @temp values(@ch)
set @SourceSql=stuff(@SourceSql,1,charindex(@StrSeprate,@SourceSql,1),'')
end
return
end
GO
/****** Object: UserDefinedFunction [dbo].[f_getstartstatus] Script Date: 08/24/2012 11:50:20 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date, ,>
-- Description: <Description, ,>
-- =============================================
CREATE FUNCTION [dbo].[f_getstartstatus]
(
@OwnerUserIDStr varchar(500),
@StepName nvarchar(50)
)
RETURNS nvarchar(500)
AS
BEGIN
declare @ret nvarchar(500)
set @ret=''
select @ret=@ret+e.UserDesc +'('+@StepName+');'
from f_splitstr(@OwnerUserIDStr,',') d
join dbo.BaseUser e on d.f1=e.ID
return @ret
END
GO
/****** Object: UserDefinedFunction [dbo].[f_getflowstatus] Script Date: 08/24/2012 11:50:20 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date, ,>
-- Description: <Description, ,>
-- =============================================
create FUNCTION [dbo].[f_getflowstatus]
(
@instanceid int
)
RETURNS nvarchar(500)
AS
BEGIN
declare @ret nvarchar(500)
set @ret=''
select @ret=@ret+OwnerUserDesc+'('+StepName+');'
from dbo.flowactiontrace
where InstanceID=@instanceid
and SubmitTime is null
return @ret
END
GO
/****** Object: StoredProcedure [dbo].[usp_FlowSubmit] Script Date: 08/24/2012 11:50:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
-- exec usp_FlowSubmit 10,3,3,0,'4/2,3',null
-- =============================================
CREATE PROCEDURE [dbo].[usp_FlowSubmit]
(
@TraceID int,--flowactiontrace的id
@AcionID int,--操作编号
@SubmitUserID int,--提交人编号
@IsEnd int,--是否结束步骤
@NextStr varchar(2000),--'1/3,4;3/5,6'
@Data nvarchar(max)
)
AS
BEGIN
SET NOCOUNT ON;
declare @flowid int
declare @stepid int
declare @actioncode varchar(50)
declare @actionname nvarchar(50)
declare @instanceid int
declare @submitusername varchar(50)
declare @submituserdesc nvarchar(50)
declare @isjoin bit
select @submitusername=username,
@submituserdesc=userdesc
from dbo.BaseUser
where ID=@SubmitUserID
select @instanceid=instanceid,
@flowid=flowid,
@stepid=stepid
from dbo.FlowActionTrace
where ID=@TraceID
select @actioncode=actioncode,
@actionname=actionname
from dbo.FlowAction
where ActionID=@AcionID and StepID=@stepid and FlowID=@flowid
select @isjoin =isjoin
from dbo.FlowStep
where StepID=@stepid and FlowID=@flowid
begin tran
--提交当前待办
update dbo.FlowActionTrace
set ActionID=@AcionID,
ActionCode=@actioncode,
ActionName=@actionname,
SubmitUserID=@SubmitUserID,
SubmitUserName=@submitusername,
SubmitUserDesc=@submituserdesc,
SubmitTime=GETDATE()
where ID=@TraceID
if(@Data is not null)
begin
insert into dbo.FlowActionTraceData(TraceID,Data)
values(@TraceID,@Data)
end
--如果不是会审,删除其他待办
if(@isjoin=0)
begin
delete dbo.FlowActionTrace
where StepID=@stepid and FlowID=@flowid and ID<>@TraceID
end
--更新主表状态
if(@IsEnd=1
and (select COUNT(*) from dbo.FlowActionTrace where FlowID=@flowid and SubmitTime is null)=0
)
begin
update dbo.FlowInstance
set EndUserName=@submitusername,
EndDateTime=GETDATE(),
StatusID=100,
StatusName='正常结束',
ApplyStatus=''
where ID=@instanceid
end
else --不是结束时插入待办,可能多个路线,一个路线可能多人
begin
declare @next varchar(500)
DECLARE db_cursor CURSOR FOR
select * FROM dbo.f_splitstr(@NextStr,';')
OPEN db_cursor
FETCH NEXT FROM db_cursor INTO @next
WHILE @@FETCH_STATUS=0
BEGIN
declare @nextstepid int --下一步骤
declare @OwnerUserIDStr varchar(500) --下一步骤处理人
set @nextstepid=convert(int,left(@next,charindex('/',@next,1)-1))
set @OwnerUserIDStr=right(@next,len(@next)-charindex('/',@next,1))
declare @nextstepcode varchar(50)
declare @nextstepname nvarchar(50)
select @nextstepcode=stepcode,
@nextstepname =stepname
from FlowStep where FlowID=@flowid and StepID=@nextstepid
--插入待办
INSERT INTO [FlowActionTrace]
([InstanceID]
,[FlowID]
,[FlowName]
,[FlowCode]
,[StepID]
,[StepName]
,[StepCode]
,[OwnerUserID]
,[OwnerUserName]
,[OwnerUserDesc]
,[ArriveTime],[PreID]
)
SELECT @instanceid,@FlowID,a.FlowName,a.FlowCode,
@nextstepid,@nextstepcode,@nextstepname,
b.ID,b.UserName,b.UserDesc,
getdate(),@TraceID
FROM dbo.Flow a,
(
select e.ID,e.UserName,e.UserDesc
from dbo.f_splitstr(@OwnerUserIDStr,',') d
join dbo.BaseUser e on d.f1=e.ID
)b WHERE a.id=@flowid
FETCH NEXT FROM db_cursor INTO @next
END
CLOSE db_cursor
DEALLOCATE db_cursor
--更新主表状态
update dbo.FlowInstance
set ApplyStatus=dbo.f_getflowstatus(@instanceid)
where ID=@instanceid
end
commit tran
END
GO
/****** Object: StoredProcedure [dbo].[usp_FlowStart] Script Date: 08/24/2012 11:50:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
-- exec usp_FlowStart 1,1,1,2,'2,3'
-- =============================================
CREATE PROCEDURE [dbo].[usp_FlowStart]
(
@FlowID int,--流程模板编号
@UserID int,--流程用户
@ApplyUserID int,--流程申请用户
@NextStepID int,--下一步骤
@OwnerUserIDStr varchar(500),--多个下手审批人,以‘,’分隔
@Data nvarchar(max)
)
AS
BEGIN
SET NOCOUNT ON;
declare @stepid int
declare @stepcode varchar(50)
declare @stepname nvarchar(50)
declare @actionid int
declare @actioncode varchar(50)
declare @actionname nvarchar(50)
select @stepid=stepid,
@stepcode=stepcode,
@stepname=stepname
from FlowStep where FlowID=@FlowID and StepID=1
select @actionid=actionid,
@actioncode=actioncode,
@actionname=actionname
from FlowAction where FlowID=@FlowID and StepID=1 and ActionID=1
declare @nextstepcode varchar(50)
declare @nextstepname nvarchar(50)
select @nextstepcode=stepcode,
@nextstepname=stepname
from FlowStep where FlowID=@FlowID and StepID=@NextStepID
begin tran
declare @instanceid int
--插入主表
INSERT INTO [FlowInstance]
([FlowID]
,[FlowName]
,[UserID]
,[UserName]
,[ApplyUserName]
,[ApplyDateTime]
,[StatusID]
,[StatusName]
,[ApplyStatus])--待办状态
SELECT @FlowID,a.FlowName,
@UserID,b.UserName,c.UserName,
GETDATE(),1,'流程中',dbo.f_getstartstatus(@OwnerUserIDStr,@nextstepname)
FROM dbo.Flow a,dbo.BaseUser b,dbo.BaseUser c
WHERE a.id=@FlowID and b.ID=@UserID and c.ID=@ApplyUserID
set @instanceid=@@identity
--插入申请日志
INSERT INTO [MyData].[dbo].[FlowActionTrace]
([InstanceID]
,[FlowID]
,[FlowName]
,[FlowCode]
,[StepID]
,[StepName]
,[StepCode]
,[ActionID]
,[ActionName]
,[ActionCode]
,[OwnerUserID]
,[OwnerUserName]
,[OwnerUserDesc]
,[SubmitUserID]
,[SubmitUserName]
,[SubmitUserDesc]
,[ArriveTime]
,[ReadTime]
,[SubmitTime])
SELECT @instanceid,@FlowID,a.FlowName,a.FlowCode,
@stepid,@stepcode,@stepname,
@actionid,@actioncode,@actionname,
b.ID,b.UserName,b.UserDesc,
b.ID,b.UserName,b.UserDesc,
getdate(),getdate(),getdate()
FROM dbo.Flow a,dbo.BaseUser b
where a.ID=@FlowID and b.ID=@ApplyUserID
declare @preid int
set @preid=@@IDENTITY
if(@Data is not null)
begin
insert into dbo.FlowActionTraceData(TraceID,Data)
values(@preid,@Data)
end
--插入待办
INSERT INTO [FlowActionTrace]
([InstanceID]
,[FlowID]
,[FlowName]
,[FlowCode]
,[StepID]
,[StepName]
,[StepCode]
,[OwnerUserID]
,[OwnerUserName]
,[OwnerUserDesc]
,[ArriveTime],[PreID]
)
SELECT @instanceid,@FlowID,a.FlowName,a.FlowCode,
@nextstepid,@nextstepcode,@nextstepname,
b.ID,b.UserName,b.UserDesc,
getdate(),@preid
FROM dbo.Flow a,
(
select e.ID,e.UserName,e.UserDesc
from dbo.f_splitstr(@OwnerUserIDStr,',') d
join dbo.BaseUser e on d.f1=e.ID
) b
WHERE a.id=@FlowID
commit tran
END
GO
/****** Object: Default [DF_MyUser_EnableFlag] Script Date: 08/24/2012 11:50:20 ******/
ALTER TABLE [dbo].[BaseUser] ADD CONSTRAINT [DF_MyUser_EnableFlag] DEFAULT ((1)) FOR [EnableFlag]
GO
/****** Object: Default [DF_FlowActionTrace_PreID] Script Date: 08/24/2012 11:50:20 ******/
ALTER TABLE [dbo].[FlowActionTrace] ADD CONSTRAINT [DF_FlowActionTrace_PreID] DEFAULT ((0)) FOR [PreID]
GO
3、执行一下数据脚本
insert BaseUser(ID,UserName,PassWord,UserDesc,UnitID,PostID,LocationID,Phone,Email,EnableFlag) values( 1 , 'aaa' , '123' , N'王小二' , NULL , NULL , NULL , NULL , NULL , 1 )
insert BaseUser(ID,UserName,PassWord,UserDesc,UnitID,PostID,LocationID,Phone,Email,EnableFlag) values( 2 , 'bbb' , '234' , N'张老三' , NULL , NULL , NULL , NULL , NULL , 1 )
insert BaseUser(ID,UserName,PassWord,UserDesc,UnitID,PostID,LocationID,Phone,Email,EnableFlag) values( 3 , 'ccc' , '345' , N'李家四' , NULL , NULL , NULL , NULL , NULL , 1 )
insert BaseUser(ID,UserName,PassWord,UserDesc,UnitID,PostID,LocationID,Phone,Email,EnableFlag) values( 4 , 'ddd' , '456' , N'刘大五' , NULL , NULL , NULL , NULL , NULL , 1 )
--插入流程模板表
insert Flow(ID,FlowCode,FlowName,FlowVersion,Params,EnableFlag) values( 1 , 'qinjia' , N'请假' , '1' , NULL , 1 )
insert FlowStep(ID,StepID,FlowID,StepCode,StepName,IsJoin,Params,EnabeFlag) values( 1 , 1 , 1 , 'apply' , N'请假申请' , 0 , NULL , 1 )
insert FlowStep(ID,StepID,FlowID,StepCode,StepName,IsJoin,Params,EnabeFlag) values( 2 , 2 , 1 , 'parent' , N'上级审批' , 0 , NULL , 1 )
insert FlowStep(ID,StepID,FlowID,StepCode,StepName,IsJoin,Params,EnabeFlag) values( 4 , 3 , 1 , 'manager' , N'经理审批' , 1 , NULL , 1 )
insert FlowStep(ID,StepID,FlowID,StepCode,StepName,IsJoin,Params,EnabeFlag) values( 5 , 4 , 1 , 'hrconfirm' , N'HR确认' , 0 , NULL , 1 )
insert FlowAction(ID,ActionID,StepID,FlowID,ActionCode,ActionName,Params,EnableFlag) values( 1 , 1 , 1 , 1 , 'applysubmit' , N'申请提交' , NULL , 1 )
insert FlowAction(ID,ActionID,StepID,FlowID,ActionCode,ActionName,Params,EnableFlag) values( 2 , 2 , 1 , 1 , 'applycancel' , N'申请取消' , NULL , 1 )
insert FlowAction(ID,ActionID,StepID,FlowID,ActionCode,ActionName,Params,EnableFlag) values( 3 , 3 , 2 , 1 , 'parentsubmit' , N'上级提交' , NULL , 1 )
insert FlowAction(ID,ActionID,StepID,FlowID,ActionCode,ActionName,Params,EnableFlag) values( 4 , 4 , 2 , 1 , 'parentreject' , N'上级驳回' , NULL , 1 )
insert FlowAction(ID,ActionID,StepID,FlowID,ActionCode,ActionName,Params,EnableFlag) values( 5 , 5 , 2 , 1 , 'parentcancel' , N'上级取消' , NULL , 1 )
insert FlowAction(ID,ActionID,StepID,FlowID,ActionCode,ActionName,Params,EnableFlag) values( 6 , 6 , 3 , 1 , 'managersubmit' , N'经理提交' , NULL , 1 )
insert FlowAction(ID,ActionID,StepID,FlowID,ActionCode,ActionName,Params,EnableFlag) values( 7 , 7 , 3 , 1 , 'managercancel' , N'经理取消' , NULL , 1 )
insert FlowAction(ID,ActionID,StepID,FlowID,ActionCode,ActionName,Params,EnableFlag) values( 10 , 8 , 4 , 1 , 'hrconfirmsubmit' , N'HR确认提交' , NULL , 1 )
insert FlowAction(ID,ActionID,StepID,FlowID,ActionCode,ActionName,Params,EnableFlag) values( 11 , 9 , 4 , 1 , 'hrconfirmcancel' , N'HR确认取消' , NULL , 1 )
4、发起一个流程
exec usp_FlowStart 1,1,1,2,'2,3',null
参数解释:
@FlowID int,--流程模板编号
@UserID int,--流程用户
@ApplyUserID int,--流程申请用户
@NextStepID int,--下一步骤
@OwnerUserIDStr varchar(500),--多个下手审批人,以‘,’分隔
@Data nvarchar(max) --表单数据,xml格式
5、读一下任务信息
查看应该可以看到FlowInstance一条数据,这是流程实例主表。
查看应该可以看到FlowActionTrace三条数据,即申请已办一条,待办两条,为什么待会是两条,因为上面的参数
'2,3'就表示下一步处理人是两个。
select * from dbo.FlowInstance
select * from dbo.FlowActionTrace
6、执行一个待办提交
exec usp_FlowSubmit 3,3,3,0,'3/2,3',null
参数解释:
@TraceID int,--flowactiontrace的id,选择一个submittime 为null的记录的id
@AcionID int,--操作编号,就是做的是哪种操作,一般1代表同意提交
@SubmitUserID int,--提交人编号
@IsEnd int,--是否结束步骤
@NextStr varchar(2000),--'1/3,4;3/5,6'这个结构表示“下一步骤编号/处理人编号串;下一步骤编号/处理人编号串”
@Data nvarchar(max)--表单数据,xml格式
大家会觉得组装下一步骤和下一步操作人很麻烦,我们做了组件后会使用更好结构的属性。
下和篇如果有兴趣就做一个简单dll和website demo,以便跑跑看。