bugfix
This commit is contained in:
parent
c59e2dbaae
commit
c12553990b
@ -285,20 +285,12 @@ where backid=${backid}$
|
|||||||
node['id'] = node_id
|
node['id'] = node_id
|
||||||
ntype = node['type']
|
ntype = node['type']
|
||||||
status = ne.status
|
status = ne.status
|
||||||
if status == 'pending':
|
if ntype == 'start':
|
||||||
if ntype == 'human':
|
|
||||||
if ne.assignee is None:
|
|
||||||
await self.auto_assign(sor, inst, ne, node)
|
|
||||||
elif ntype == 'task':
|
|
||||||
await self.try_start_running(sor, inst, ne, node)
|
|
||||||
elif ntype == 'subflow':
|
|
||||||
await self.try_start_subflow(sor, inst, ne, node)
|
|
||||||
elif ntype == 'start':
|
|
||||||
await self.node_transfer(sor, dsl, inst, ne, node, flow_def)
|
|
||||||
await sor.U('node_execution', {
|
await sor.U('node_execution', {
|
||||||
'id': ne.id,
|
'id': ne.id,
|
||||||
'status': 'completed'
|
'status': 'completed'
|
||||||
})
|
})
|
||||||
|
await self.node_transfer(sor, dsl, inst, ne, node, flow_def)
|
||||||
elif ntype == 'end':
|
elif ntype == 'end':
|
||||||
flg = await self.is_ok_to_step_next(sor, node, edges, inst)
|
flg = await self.is_ok_to_step_next(sor, node, edges, inst)
|
||||||
if flg:
|
if flg:
|
||||||
@ -311,20 +303,40 @@ where backid=${backid}$
|
|||||||
'status': 'completed'
|
'status': 'completed'
|
||||||
})
|
})
|
||||||
break;
|
break;
|
||||||
elif status in ['done', 'cancelled', 'failed']:
|
else:
|
||||||
|
if status == 'pending':
|
||||||
|
if ntype == 'human':
|
||||||
|
if ne.assignee is None:
|
||||||
|
await self.auto_assign(sor, inst, ne, node)
|
||||||
|
elif ntype == 'task':
|
||||||
|
flg= self.is_ok_to_step_next(sor, node, edges, inst)
|
||||||
|
if flg:
|
||||||
|
await self.try_start_running(sor, inst, ne, node)
|
||||||
|
elif ntype == 'subflow':
|
||||||
|
flg= self.is_ok_to_step_next(sor, node, edges, inst)
|
||||||
|
if flg:
|
||||||
|
await self.try_start_subflow(sor, inst, ne, node)
|
||||||
|
elif status in ['done', 'cancelled']:
|
||||||
debug(f'节点完成,检查后续节点')
|
debug(f'节点完成,检查后续节点')
|
||||||
await self.node_transfer(sor, dsl, inst, ne, node, flow_def)
|
await self.node_transfer(sor, dsl, inst, ne, node, flow_def)
|
||||||
await sor.U('node_execution', {
|
await sor.U('node_execution', {
|
||||||
'id': ne.id,
|
'id': ne.id,
|
||||||
'status': 'completed'
|
'status': 'completed'
|
||||||
})
|
})
|
||||||
await self.check_instance_completed(sor, inst)
|
elif status == 'failed':
|
||||||
|
debug(f'节点执行失败,需要运维人员参与')
|
||||||
|
|
||||||
|
|
||||||
|
async def run_auto_task(self, ne):
|
||||||
|
env = ServerEnv()
|
||||||
|
users = get_org_users(ne.orgid)
|
||||||
|
if not users:
|
||||||
|
debug(f'{orgid=} 没有用户')
|
||||||
|
return
|
||||||
|
|
||||||
# ------------------------------
|
# ------------------------------
|
||||||
# Human task APIs
|
# Human task APIs
|
||||||
# ------------------------------
|
# ------------------------------
|
||||||
|
|
||||||
async def auto_assign(self, sor, inst, ne, node):
|
async def auto_assign(self, sor, inst, ne, node):
|
||||||
recs = await env.get_org_users(sor, inst.org_id, ne.role)
|
recs = await env.get_org_users(sor, inst.org_id, ne.role)
|
||||||
if recs:
|
if recs:
|
||||||
@ -334,11 +346,7 @@ where backid=${backid}$
|
|||||||
'assignee': recs[i].id
|
'assignee': recs[i].id
|
||||||
})
|
})
|
||||||
|
|
||||||
async def check_instance_completed(self, sor, inst):
|
async def instance_completed(self, sor, inst):
|
||||||
sql = "select * from node_execution where instance_id=${instance_id} and type='end'"
|
|
||||||
recs = await sor.sqlExe(sql, {'instance_id': inst.id})
|
|
||||||
if recs:
|
|
||||||
if recs[0].status == 'completed':
|
|
||||||
await sor.U('flow_instance', {
|
await sor.U('flow_instance', {
|
||||||
'id': inst.id,
|
'id': inst.id,
|
||||||
'status': 'completed'
|
'status': 'completed'
|
||||||
@ -455,7 +463,7 @@ where node_id in ${backnodes}$
|
|||||||
})
|
})
|
||||||
if join == 'all':
|
if join == 'all':
|
||||||
for r in recs:
|
for r in recs:
|
||||||
if r.status in ['pending', 'running']:
|
if r.status != 'completed':
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
if join == 'xor':
|
if join == 'xor':
|
||||||
@ -484,25 +492,17 @@ where instance_id=${instance_id}$
|
|||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
async def start_running(self, sor, node, edges, inst):
|
async def start_running(self, sor, ne, edges, inst):
|
||||||
flg= self.is_ok_to_step_next(sor, node, edges, inst)
|
|
||||||
if flg:
|
|
||||||
await sor.R('node_execution', {
|
await sor.R('node_execution', {
|
||||||
'id': node['id'],
|
'id': ne['id'],
|
||||||
'status': 'running',
|
'status': 'running',
|
||||||
'running_time': timestampstr()
|
'running_time': timestampstr()
|
||||||
})
|
})
|
||||||
try:
|
try:
|
||||||
out = await self.run_auto_task(node)
|
out = await self.run_auto_task(ne)
|
||||||
await sor.U('node_execution', {
|
|
||||||
'id': node['id'],
|
|
||||||
'status': 'done',
|
|
||||||
'stopping_at': timestampstr(),
|
|
||||||
'output_ctx': json.dumps(out, ensure_ascii=False)
|
|
||||||
})
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
await sor.U('node_execution', {
|
await sor.U('node_execution', {
|
||||||
'id': node['id'],
|
'id': ne['id'],
|
||||||
'status': 'failed',
|
'status': 'failed',
|
||||||
'stopping_at': timestampstr()
|
'stopping_at': timestampstr()
|
||||||
})
|
})
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user