blackholll / loonflow

基于django的工作流引擎,工单(a workflow engine base on django python)
MIT License
1.95k stars 689 forks source link

接单功能中,状态的分配方式设置为“主动接单”后,请求“获取工单可以做的操作”接口报500 #132

Closed AngelLiang closed 4 years ago

AngelLiang commented 4 years ago

环境:

问题:

在测试接单功能中,按照接单接口文档做以下操作

使用接口获取工单当前可以做的的操作后,如果data.value.is_accept==true,则需要用户先接单才能处理,即页面显示接单按钮, 用户点击后调用接单接口,将工单的当前处理人设置该用户

配置好工作流、状态和流转后。我设置一个状态的分配方式为“主动接单”方式: 图片

图片

根据上面接口文档的场景说明,我理解是这样的,【草稿 -> 开启】这一流转需要先进行接单,要判断是否进行接单,则可以通过“获取工单可以做的操作”接口进行查询。但是此时我请求该接口报500错误。

图片

改回直接处理,则请求正常。 图片 图片

blackholll commented 4 years ago

看下loonflow的日志。 默认是在当前启动用户的家目录下 loonflow.log

AngelLiang commented 4 years ago

找到原因了,报错出现在这一行:

https://github.com/blackholll/loonflow/blob/2e27f0aceefac19207c8abe6a68c996c2f8eb858/apps/ticket/views.py#L202

报错原因是:AttributeError: 'str' object has no attribute 'get'

Traceback (most recent call last):
  File "/home/xxx/.local/share/virtualenvs/loonflow-R0_p_wxo/lib/python3.6/site-packages/django/core/handlers/exception.py", line 35, in inner
    response = get_response(request)
  File "/home/xxx/.local/share/virtualenvs/loonflow-R0_p_wxo/lib/python3.6/site-packages/django/core/handlers/base.py", line 128, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/home/xxx/.local/share/virtualenvs/loonflow-R0_p_wxo/lib/python3.6/site-packages/django/core/handlers/base.py", line 126, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/home/xxx/.local/share/virtualenvs/loonflow-R0_p_wxo/lib/python3.6/site-packages/django/views/generic/base.py", line 69, in view
    return self.dispatch(request, *args, **kwargs)
  File "/home/xxx/loonflow/apps/loon_base_view.py", line 31, in dispatch
    return handler(request, *args, **kwargs)
  File "/home/xxx/loonflow/apps/ticket/views.py", line 204, in get
    code, data, msg = 0, dict(value=result.get('transition_dict_list')), ''
AttributeError: 'str' object has no attribute 'get'

往上寻找相关方法的实现:

https://github.com/blackholll/loonflow/blob/2e27f0aceefac19207c8abe6a68c996c2f8eb858/apps/ticket/views.py#L198

进入ticket_base_service_ins.get_ticket_transition方法,其中接单条件语句后返回的这一行:

https://github.com/blackholll/loonflow/blob/2e27f0aceefac19207c8abe6a68c996c2f8eb858/service/ticket/ticket_base_service.py#L1027

因为返回的格式不是(bool, dict)格式,而导致后面的错误。

改为

return True, dict(transition_dict_list=transition_dict_list)

响应正常。

请确认。

blackholll commented 4 years ago

你用的不是1.0.5版本吧 https://github.com/blackholll/loonflow/blob/r1.0.5/service/ticket/ticket_base_service.py

image

AngelLiang commented 4 years ago

1027行,接单的条件分支,提前返回了。

图片

blackholll commented 4 years ago

是个bug, 明天修复下

blackholll commented 4 years ago

想了想, 为这个小bug就发个版本有点那啥, 你先自己改了用吧。 晚点如果其他问题一起修正发布吧

AngelLiang commented 4 years ago

好的,没事。我这边不急,不用受我影响。

blackholll commented 4 years ago

fixed in r1.0.8