mtm step list
This commit is contained in:
parent
439697d394
commit
faf524604b
|
@ -42,7 +42,7 @@ class ProcessViewSet(CreateUpdateModelAMixin, ModelViewSet):
|
|||
工序下的子工序
|
||||
"""
|
||||
process = self.get_object()
|
||||
serializer = self.serializer_class(instance=Step.objects.filter(process=process, is_deleted=True), many=True)
|
||||
serializer = self.serializer_class(instance=Step.objects.filter(process=process, is_deleted=False), many=True)
|
||||
return Response(serializer.data)
|
||||
|
||||
class StepViewSet(CreateModelMixin, UpdateModelMixin, RetrieveModelMixin, DestroyModelMixin, GenericViewSet):
|
||||
|
|
|
@ -55,7 +55,8 @@ class State(CommonAModel):
|
|||
sort = models.IntegerField('状态顺序', default=0, help_text='用于工单步骤接口时,step上状态的顺序(因为存在网状情况,所以需要人为设定顺序),值越小越靠前')
|
||||
type = models.IntegerField('状态类型', default=0, choices=type_choices, help_text='0.普通类型 1.初始状态(用于新建工单时,获取对应的字段必填及transition信息) 2.结束状态(此状态下的工单不得再处理,即没有对应的transition)')
|
||||
enable_retreat = models.BooleanField('允许撤回', default=False, help_text='开启后允许工单创建人在此状态直接撤回工单到初始状态')
|
||||
participant_type = models.IntegerField('参与者类型', choices=type2_choices, default=1, blank=True, help_text='0.无处理人,1.个人,2.多人,3.部门,4.角色,5.变量(支持工单创建人,创建人的leader),6.脚本,7.工单的字段内容(如表单中的"测试负责人",需要为用户名或者逗号隔开的多个用户名),8.父工单的字段内容。 初始状态请选择类型5,参与人填creator')
|
||||
participant_type = models.IntegerField('参与者类型', choices=type2_choices, default=1, blank=True, help_text='0.无处理人,1.个人,2.多人,3.部门,4.角色,5.变量(支持工单创建人,创建人的leader),6.脚本,7.工单的字段内容(如表单中的"测试负责人",需要为用户名或者逗号隔开的多个用户名),8.父工单的字段内容。 初始状态请选择类型5,参与人填create_by')
|
||||
participant = models.CharField('参与者', default='', blank=True, max_length=1000, help_text='可以为空(无处理人的情况,如结束状态)、username\多个username(以,隔开)\部门id\角色id\变量(create_by,create_by_tl)\脚本记录的id等,包含子工作流的需要设置处理人为loonrobot')
|
||||
state_fields = models.JSONField('表单字段', default=dict, help_text='json格式字典存储,包括读写属性1:只读,2:必填,3:可选. 示例:{"created_at":1,"title":2, "sn":1}, 内置特殊字段participant_info.participant_name:当前处理人信息(部门名称、角色名称),state.state_name:当前状态的状态名,workflow.workflow_name:工作流名称') # json格式存储,包括读写属性1:只读,2:必填,3:可选,4:不显示, 字典的字典
|
||||
|
||||
class Transition(CommonAModel):
|
||||
|
@ -114,6 +115,16 @@ class Ticket(CommonAModel):
|
|||
"""
|
||||
工单
|
||||
"""
|
||||
STATE_DISTRIBUTE_TYPE_ACTIVE = 1
|
||||
STATE_DISTRIBUTE_TYPE_DIRECT = 2
|
||||
STATE_DISTRIBUTE_TYPE_RANDOM = 3
|
||||
STATE_DISTRIBUTE_TYPE_ALL = 4
|
||||
act_state_choices =(
|
||||
(STATE_DISTRIBUTE_TYPE_ACTIVE, '主动接单'),
|
||||
(STATE_DISTRIBUTE_TYPE_DIRECT, '直接处理'),
|
||||
(STATE_DISTRIBUTE_TYPE_RANDOM, '随机分配'),
|
||||
(STATE_DISTRIBUTE_TYPE_ALL, '全部处理')
|
||||
)
|
||||
title = models.CharField('标题', max_length=500, blank=True, default='', help_text="工单标题")
|
||||
workflow = models.ForeignKey(Workflow, on_delete=models.CASCADE, verbose_name='关联工作流')
|
||||
sn = models.CharField('流水号', max_length=25, help_text="工单的流水号")
|
||||
|
@ -125,7 +136,9 @@ class Ticket(CommonAModel):
|
|||
add_node_man = models.CharField('加签人', max_length=50, default='', blank=True, help_text='加签操作的人,工单当前处理人处理完成后会回到该处理人,当处于加签状态下才有效')
|
||||
|
||||
participant_type = models.IntegerField('当前处理人类型', default=0, help_text='0.无处理人,1.个人,2.多人,3.部门,4.角色', choices=State.type2_choices)
|
||||
participant = models.CharField('当前处理人', max_length=1000, default='', blank=True, help_text='可以为空(无处理人的情况,如结束状态)、username\多个username(以,隔开)\部门id\角色id\脚本文件名等')
|
||||
participant = models.JSONField('当前处理人', null=True, blank=True, help_text='可以为空(无处理人的情况,如结束状态)、userid、userid列表')
|
||||
act_state = models.IntegerField('进行状态', default=1, help_text='当前工单的进行状态', choices=act_state_choices)
|
||||
multi_all_person = models.JSONField('全部处理的结果', default=dict, blank=True, help_text='需要当前状态处理人全部处理时实际的处理结果,json格式')
|
||||
|
||||
class TicketFlow(BaseModel):
|
||||
"""
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
from apps.system.models import User
|
||||
from apps.wf.models import CustomField, State, Ticket, Transition, Workflow
|
||||
from rest_framework.exceptions import APIException
|
||||
class WfService(object):
|
||||
|
@ -87,18 +88,41 @@ class WfService(object):
|
|||
return destination_state
|
||||
|
||||
@classmethod
|
||||
def get_ticket_state_participant_info(cls, state:State, ticket:Ticket, ticket_data:dict):
|
||||
def get_ticket_state_participant_info(cls, state:State, ticket:Ticket, ticket_data:dict={}):
|
||||
"""
|
||||
获取工单目标状态实际的处理人
|
||||
获取工单目标状态实际的处理人, 处理人类型
|
||||
"""
|
||||
if state.type == State.STATE_TYPE_START:
|
||||
"""
|
||||
回到初始状态
|
||||
"""
|
||||
return dict(destination_participant_type=State.PARTICIPANT_TYPE_PERSONAL,
|
||||
destination_participant=ticket.create_by,
|
||||
multi_all_person="{}")
|
||||
elif state.type == State.STATE_TYPE_END:
|
||||
"""
|
||||
到达结束状态
|
||||
"""
|
||||
|
||||
return dict(destination_participant_type=State.PARTICIPANT_TYPE_PERSONAL,
|
||||
destination_participant='',
|
||||
multi_all_person="{}")
|
||||
destination_participant_type, destination_participant = State.participant_type, State.participant
|
||||
|
||||
if destination_participant_type == State.PARTICIPANT_TYPE_FIELD:
|
||||
destination_participant = ticket_data.get(destination_participant, '') if destination_participant in ticket_data else Ticket.ticket_data.get(destination_participant, '')
|
||||
|
||||
if destination_participant_type == State.PARTICIPANT_TYPE_DEPT:#单部门
|
||||
destination_participant = User.objects.filter(dept=destination_participant).values_list('id')
|
||||
|
||||
if destination_participant_type == State.PARTICIPANT_TYPE_ROLE:#单角色
|
||||
destination_participant = User.objects.filter(roles=destination_participant).values_list('id')
|
||||
|
||||
if type(destination_participant) == list:
|
||||
destination_participant_type = State.PARTICIPANT_TYPE_MULTI
|
||||
destination_participant = list(set(destination_participant))
|
||||
else:
|
||||
destination_participant_type = State.PARTICIPANT_TYPE_PERSONAL
|
||||
|
||||
return dict(destination_participant_type)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue