feat: 关闭工单时需要执行提交时调用方法
This commit is contained in:
parent
34d4884dad
commit
2db95349b2
|
@ -204,8 +204,8 @@ class OplCreateUpdateSerializer(CustomModelSerializer):
|
|||
if operation.state == Operation.OP_DONE:
|
||||
raise ParseError('作业已关闭不可创建许可')
|
||||
cate = validated_data['cate']
|
||||
if Opl.objects.filter(operation=operation, cate=cate).exists():
|
||||
raise ParseError('该类许可证已存在,不可重复申请')
|
||||
if Opl.objects.filter(operation=operation, cate=cate).exclude(ticket__act_state=5).exists():
|
||||
raise ParseError('该类有效许可证已存在,不可重复申请')
|
||||
return super().create(validated_data)
|
||||
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ from rest_framework import status
|
|||
from django.db.models import Count
|
||||
from rest_framework.serializers import Serializer
|
||||
from apps.utils.snowflake import idWorker
|
||||
|
||||
import importlib
|
||||
from apps.wf.tasks import run_task
|
||||
|
||||
# Create your views here.
|
||||
|
@ -465,6 +465,7 @@ class TicketViewSet(CreateUpdateCustomMixin, CreateModelMixin, ListModelMixin, R
|
|||
|
||||
@action(methods=['post'], detail=True, perms_map={'post': '*'},
|
||||
serializer_class=TicketCloseSerializer)
|
||||
@transaction.atomic
|
||||
def close(self, request, pk=None):
|
||||
"""
|
||||
关闭工单(创建人在初始状态)
|
||||
|
@ -484,6 +485,11 @@ class TicketViewSet(CreateUpdateCustomMixin, CreateModelMixin, ListModelMixin, R
|
|||
suggestion=suggestion, participant_type=State.PARTICIPANT_TYPE_PERSONAL,
|
||||
intervene_type=Transition.TRANSITION_INTERVENE_TYPE_CLOSE,
|
||||
participant=request.user, transition=None)
|
||||
if end_state.on_reach_func: # 如果有到达方法还需要进行处理
|
||||
module, func = end_state.on_reach_func.rsplit(".", 1)
|
||||
m = importlib.import_module(module)
|
||||
f = getattr(m, func)
|
||||
f(ticket=ticket) # 同步执行
|
||||
return Response()
|
||||
else:
|
||||
return Response('工单不可关闭', status=status.HTTP_400_BAD_REQUEST)
|
||||
|
|
Loading…
Reference in New Issue