feat: base wf 调用方法支持静态方法
This commit is contained in:
parent
5db4a99611
commit
3f2db2a4af
|
|
@ -163,9 +163,12 @@ class WfService(object):
|
||||||
destination_participant = 0
|
destination_participant = 0
|
||||||
|
|
||||||
elif destination_participant_type == State.PARTICIPANT_TYPE_FORMCODE: # 代码获取
|
elif destination_participant_type == State.PARTICIPANT_TYPE_FORMCODE: # 代码获取
|
||||||
module, func = destination_participant.rsplit(".", 1)
|
parts = destination_participant.split('.')
|
||||||
m = importlib.import_module(module)
|
try:
|
||||||
f = getattr(m, func)
|
m = importlib.import_module('.'.join(parts[:-1]))
|
||||||
|
except ModuleNotFoundError:
|
||||||
|
m = getattr(importlib.import_module('.'.join(parts[:-2])), parts[-2])
|
||||||
|
f = getattr(m, parts[-1])
|
||||||
destination_participant = f(state=state, ticket=ticket, new_ticket_data=new_ticket_data, handler=handler)
|
destination_participant = f(state=state, ticket=ticket, new_ticket_data=new_ticket_data, handler=handler)
|
||||||
|
|
||||||
elif destination_participant_type == State.PARTICIPANT_TYPE_DEPT: # 部门
|
elif destination_participant_type == State.PARTICIPANT_TYPE_DEPT: # 部门
|
||||||
|
|
@ -352,9 +355,12 @@ class WfService(object):
|
||||||
|
|
||||||
# 提交时可能进行的操作
|
# 提交时可能进行的操作
|
||||||
if transition.on_submit_func:
|
if transition.on_submit_func:
|
||||||
module, func = transition.on_submit_func.rsplit(".", 1)
|
parts = transition.on_submit_func.split('.')
|
||||||
m = importlib.import_module(module)
|
try:
|
||||||
f = getattr(m, func)
|
m = importlib.import_module('.'.join(parts[:-1]))
|
||||||
|
except ModuleNotFoundError:
|
||||||
|
m = getattr(importlib.import_module('.'.join(parts[:-2])), parts[-2])
|
||||||
|
f = getattr(m, parts[-1])
|
||||||
f(ticket=ticket, transition=transition, new_ticket_data=new_ticket_data)
|
f(ticket=ticket, transition=transition, new_ticket_data=new_ticket_data)
|
||||||
|
|
||||||
# 校验处理权限
|
# 校验处理权限
|
||||||
|
|
@ -474,9 +480,12 @@ class WfService(object):
|
||||||
state = ticket.state
|
state = ticket.state
|
||||||
# 如果目标状态有func,由func执行额外操作(比如发送通知)
|
# 如果目标状态有func,由func执行额外操作(比如发送通知)
|
||||||
if state.on_reach_func:
|
if state.on_reach_func:
|
||||||
module, func = state.on_reach_func.rsplit(".", 1)
|
parts = state.on_reach_func.split('.')
|
||||||
m = importlib.import_module(module)
|
try:
|
||||||
f = getattr(m, func)
|
m = importlib.import_module('.'.join(parts[:-1]))
|
||||||
|
except ModuleNotFoundError:
|
||||||
|
m = getattr(importlib.import_module('.'.join(parts[:-2])), parts[-2])
|
||||||
|
f = getattr(m, parts[-1])
|
||||||
f(ticket=ticket) # 同步执行
|
f(ticket=ticket) # 同步执行
|
||||||
|
|
||||||
# wf默认只发送通知
|
# wf默认只发送通知
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue