📄 workflowprocess.asp
字号:
<%
'文件名:workflowprocess.asp
'作者:展亮
'功能:执行公文流程
'参数:form_name'表单名,flow_name'流程名
'开发时间:2003-11-2 20:52
%>
<%
set rs_process=server.createobject("adodb.recordset")
sub workflowprocess()
sql="select * from workflow_process_rec where iffinish='no'"
rs_process.open sql,oConn,1,1
while not rs_process.eof
set rs_flow=server.createobject("adodb.recordset")
sql="select * from workflow_flow_construction where flow_name='"&rs_process("flow_name")&"' and flow_no='"&rs_process("flow_no")&"'"
rs_flow.open sql,oConn,1
call do_flow(rs_flow)'执行流程
set rs_flow=nothing
rs_process.movenext
wend
set rs_process=nothing
end sub
%>
<%'执行流程
sub do_flow(rs_flow)
'response.write rs_flow("parent_no")&"-"&rs_flow("flow_no")&"<br>"
if rs_flow("action_type")="开始" then call do_star(rs_flow)
if rs_flow("action_type")="结束" then call do_end(rs_flow)
if rs_flow("action_type")="判断" then call do_if(rs_flow)
if rs_flow("action_type")="审批" then call do_check(rs_flow)
if rs_flow("action_type")="通知" then call do_tell(rs_flow)
if rs_flow("action_type")="归档" then call do_file(rs_flow)
end sub
%>
<%'开始流程
sub do_star(rs_flow)
flow_next(rs_flow)
flow_finished(rs_process("id"))
end sub
%>
<%'结束流程
sub do_end(rs_flow)
end sub
%>
<%'判断流程
sub do_if(rs_flow)
if rs_flow("judge_type")="审批判断" then
sql="select ifagree from workflow_check_rec where ifcheck='yes' and date_id="&rs_process("date_id")&" and flow_name='"&rs_flow("flow_name")&"' and flow_no="&rs_flow("parent_no")
set rs=server.createobject("adodb.recordset")
rs.open sql,oConn,1,1
if not rs.eof then
if rs("ifagree")=rs_flow("judge_result") then
flow_next(rs_flow) '执行下一流程
end if
flow_finished(rs_process("id"))
end if
set rs=nothing
end if
if rs_flow("judge_type")="表单判断" then
sql="select form_type from workflow_form_construction where form_arrno="&rs_flow("form_unit")&" and form_name=(select form_name from workflow_form_name where flow_name='"&rs_flow("flow_name")&"')"
set rs=server.createobject("adodb.recordset")
rs.open sql,oConn,1,1
if not rs.eof then
sql="select * from workflow_" & rs("form_type") & "_content where date_id="&rs_process("date_id")
set rs_content=server.createobject("adodb.recordset")
rs_content.open sql,oConn,1,1
if not rs_content.eof then
Select Case rs_flow("judge_symbol")
Case "前"
sql="SELECT * FROM workflow_flow_construction WHERE '"&rs_content("content")&"' like judge_value+'%' and id="&rs_flow("id")
Case "中"
sql="SELECT * FROM workflow_flow_construction WHERE '"&rs_content("content")&"' like '%'+judge_value+'%' and id="&rs_flow("id")
Case "后"
sql="SELECT * FROM workflow_flow_construction WHERE '"&rs_content("content")&"' like '%'+judge_value and id="&rs_flow("id")
Case Else
sql="SELECT * FROM workflow_flow_construction WHERE '"&rs_content("content")&"' "&rs_flow("judge_symbol")&" judge_value and id="&rs_flow("id")
End Select
set rs_mod=server.createobject("adodb.recordset")
rs_mod.open sql,oConn,1,1
if not rs_mod.eof then
flow_next(rs_flow) '如果条件成立,执行下一流程
end if
set rs_mod=nothing
end if
set rs_content=nothing
end if
set rs=nothing
end if
end sub
%>
<%'审批流程
dim UPManager_LIST()
dim MyNum
MyNum=1
Function GetManager_LIST(DepID)'函数递归把本人(部门)的主管全部取出到 UPManager_LIST 里面 MyNum为计数器
dim RS_BLRYLB
set RS_BLRYLB=server.CreateObject("adodb.recordset")
BLRYLB_dep_sql="Select * from tbioaDepartment where id ="&DepID'取出部门信息
RS_BLRYLB.Open BLRYLB_dep_sql,oConn,1,1
ParentID=RS_BLRYLB("ParentID")'上级菜单
ManagerID=RS_BLRYLB("ManagerID")'本级主管ID
ReDim Preserve UPManager_LIST(MyNum)
UPManager_LIST(MyNum)=ManagerID'主管写入数组
MyNum=MyNum+1
RS_BLRYLB.Close
set RS_BLRYLB=nothing
'Response.Write BLRYLB_dep_sql&"<br>:本="&DepID&" 上="&ParentID&" 主管ID="&ManagerID&"<br>"
if ParentID=0 then'顶部门
Exit Function
else
GetManager_LIST(ParentID)
end if
End Function
sub do_check(rs_flow)
if rs_flow("check_member")="负责人" then
GetManager_LIST Session("DepID")'调用
tmp_BLRYLB=","&rs_flow("blrylb")&","'取出用户列表
for i=1 to UBound(UPManager_LIST)
if InStr(tmp_BLRYLB,","&UPManager_LIST(i)&",") then'数组中包括有主管的ID就写入 没有就找更上级
'sql="update tbioaOffice_FlowPoint set LZBZ='1',BLRYLB='"&UPManager_LIST(i)&"' where LZBZ='3' and RecordID='" & sRecordID & "'"
'oConn.execute sql
'mastername=GetUserName(UPManager_LIST(i))
mastername=GetTableValue("tbioaUser","LoginName","ID",UPManager_LIST(i))
sql="insert into workflow_check_rec (date_id,checkusername,flow_name,flow_no) "
sql=sql&"Values("&rs_process("date_id")&",'"&mastername&"','"&rs_flow("flow_name")&"',"&rs_flow("flow_no")&")"
oConn.Execute sql
Exit For
end if
next
end if
'if rs_flow("check_member")="部门负责人" then
'end if
if rs_flow("check_member")="公司成员" then
sql="insert into workflow_check_rec (date_id,checkusername,flow_name,flow_no) "
sql=sql&"Values("&rs_process("date_id")&",'"&rs_flow("company_member")&"','"&rs_flow("flow_name")&"',"&rs_flow("flow_no")&")"
oConn.Execute sql
end if
set rs=server.createobject("adodb.recordset")
sql="select * from workflow_flow_construction where flow_name='"&rs_flow("flow_name")&"' and parent_no='"&rs_flow("flow_no")&"'"
rs.open sql,oConn,1
while not rs.eof
if rs("judge_type")="审批判断" then
sql = "Insert Into workflow_process_rec (date_id,flow_no,flow_name) Values( "
sql = sql & rs_process("date_id") & ", "
sql = sql & rs("flow_no") & ", "
sql = sql & "'" & rs("flow_name") & "')"
oConn.Execute sql
end if
rs.movenext
wend
set rs=nothing
flow_next(rs_flow) '执行下一流程
end sub
%>
<%'通知流程
sub do_tell(rs_flow)
if rs_flow("tell_type")="通知表单提交人" then
set rs_user=server.createobject("adodb.recordset")
sql="select username from workflow_date_id where date_id="&rs_process("date_id")
rs_user.open sql,oConn,1
sql="insert into workflow_tell_user (username,date_id,flow_name,flow_no) "
sql=sql&"Values('"&rs_user("username")&"',"&rs_process("date_id")&",'"&rs_flow("flow_name")&"',"&rs_flow("flow_no")&")"
oConn.Execute sql
set rs_user=nothing
end if
if rs_flow("tell_type")="通知所有人" then
set rs_user=server.createobject("adodb.recordset")
sql="select LoginName from tbioaUser"
rs_user.open sql,oConn,1
while not rs_user.eof
sql="insert into workflow_tell_user (username,date_id,flow_name,flow_no) "
sql=sql&"Values('"&rs_user("LoginName")&"',"&rs_process("date_id")&",'"&rs_flow("flow_name")&"',"&rs_flow("flow_no")&")"
oConn.Execute sql
rs_user.movenext
wend
set rs_user=nothing
end if
if rs_flow("tell_type")="通知指定人" then
sql="insert into workflow_tell_user (username,date_id,flow_name,flow_no) "
sql=sql&"Values('"&rs_flow("company_member")&"',"&rs_process("date_id")&",'"&rs_flow("flow_name")&"',"&rs_flow("flow_no")&")"
oConn.Execute sql
end if
if rs_flow("tell_type")="通知表单单元人员" then
sql="select form_type from workflow_form_construction where form_arrno="&rs_flow("form_unit")&" and form_name=(select form_name from workflow_form_name where flow_name='"&rs_flow("flow_name")&"')"
set rs=server.createobject("adodb.recordset")
rs.open sql,oConn,1,1 '取出表单单元类型
if not rs.eof then
select case rs("form_type") '判断指定用户单元类型
case "ft_member" '用户选择框
set rs_user=server.createobject("adodb.recordset")
sql="select * from workflow_ft_member_content where date_id="&rs_process("date_id")
rs_user.open sql,oConn,1,1 '取出该流程制定的用户
if not rs_user.eof then
userArr=split(rs_user("content"),",")
for i=0 to UBound(userarr)-1 '为用户创建收到公文
sql="insert into workflow_tell_user (username,date_id,flow_name,flow_no) "
sql=sql&"Values('"&userArr(i)&"',"&rs_process("date_id")&",'"&rs_flow("flow_name")&"',"&rs_flow("flow_no")&")"
oConn.Execute sql
next
end if
case "ft_group" '部门下拉菜单
set rs_user=server.createobject("adodb.recordset")
sql="select content from workflow_ft_group_content where date_id="&rs_process("date_id")
rs_user.open sql,oConn,1,1 '取出与流程对应的部门编号
sql="select loginname from tbioauser where Department="&rs_user("content")
set rs_user=server.createobject("adodb.recordset")
rs_user.open sql,oConn,1,1 '取出所有该部门的用户
do while not rs_user.eof '为用户创建收到公文
sql="insert into workflow_tell_user (username,date_id,flow_name,flow_no) "
sql=sql&"Values('"&rs_user("loginname")&"',"&rs_process("date_id")&",'"&rs_flow("flow_name")&"',"&rs_flow("flow_no")&")"
oConn.Execute sql
rs_user.movenext
loop
end select
end if
end if
end sub
%>
<%'归档流程
sub do_file(rs_flow)
end sub
%>
<%'标记流程为已执行
sub flow_finished(id)
sql="update workflow_process_rec set iffinish='yes' where id="&id
oConn.Execute sql
end sub
%>
<%'运行下一流程
sub flow_next(rs_flow)
set rs=server.createobject("adodb.recordset")
sql="select * from workflow_flow_construction where flow_name='"&rs_flow("flow_name")&"' and parent_no='"&rs_flow("flow_no")&"'"
rs.open sql,oConn,1
while not rs.eof
call do_flow(rs)
rs.movenext
wend
set rs=nothing
end sub
%>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -