wf 增加filter dept
This commit is contained in:
parent
57a3782a19
commit
0365b90b39
|
@ -3,7 +3,7 @@ from apps.opm.serializers import OplCloseSerializer
|
|||
from apps.wf.models import Ticket, Transition
|
||||
|
||||
|
||||
def get_op_manager(state, ticket, new_ticket_data, handler):
|
||||
def get_op_charger(state, ticket, new_ticket_data, handler):
|
||||
"""_summary_
|
||||
|
||||
Args:
|
||||
|
@ -32,7 +32,14 @@ def get_op_monitor(state, ticket, new_ticket_data, handler):
|
|||
def bind_opl(ticket: Ticket, transition: Transition, new_ticket_data: dict):
|
||||
opl = Opl.objects.get(id=new_ticket_data['opl'])
|
||||
ticket_data = ticket.ticket_data
|
||||
ticket_data.update({'level': opl.level})
|
||||
ticket_data.update({
|
||||
'level': opl.level,
|
||||
'monitor': opl.monitor.id,
|
||||
'workers': list(OplWorker.objects.filter(opl=opl).values_list('worker__id', flat=True)),
|
||||
'manager': opl.charger.id,
|
||||
'dept_ter': opl.operation.dept_ter,
|
||||
'dept_bus': opl.operation.dept_bus
|
||||
})
|
||||
ticket.ticket_data = ticket_data
|
||||
ticket.save()
|
||||
opl.ticket = ticket
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
# Generated by Django 3.2.12 on 2022-07-18 05:44
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('wf', '0003_ticket_belong_dept'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RemoveField(
|
||||
model_name='state',
|
||||
name='filter_policy',
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='state',
|
||||
name='filter_dept',
|
||||
field=models.CharField(default=0, max_length=20, verbose_name='部门字段过滤'),
|
||||
),
|
||||
]
|
|
@ -102,7 +102,8 @@ class State(CommonAModel):
|
|||
'表单字段', blank=True, default=dict, help_text='json格式字典存储,包括读写属性1:只读,2:必填,3:可选, 4:隐藏 示例:{"create_time":1,"title":2, "sn":1}, 内置特殊字段participant_info.participant_name:当前处理人信息(部门名称、角色名称),state.state_name:当前状态的状态名,workflow.workflow_name:工作流名称')
|
||||
distribute_type = models.IntegerField('分配方式', default=1, choices=state_distribute_choices,
|
||||
help_text='1.主动接单(如果当前处理人实际为多人的时候,需要先接单才能处理) 2.直接处理(即使当前处理人实际为多人,也可以直接处理) 3.随机分配(如果实际为多人,则系统会随机分配给其中一个人) 4.全部处理(要求所有参与人都要处理一遍,才能进入下一步)')
|
||||
filter_policy = models.IntegerField('参与人过滤策略', default=0, choices=state_filter_choices)
|
||||
# filter_policy = models.IntegerField('参与人过滤策略', default=0, choices=state_filter_choices)
|
||||
filter_dept = models.CharField('部门字段过滤', default=0, max_length=20)
|
||||
participant_cc = models.JSONField('抄送给', default=list, blank=True, help_text='抄送给(userid列表)')
|
||||
on_reach_func = models.CharField('到达时调用方法', max_length=100, null=True, blank=True)
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import importlib
|
||||
from apps.wf.serializers import TicketSimpleSerializer
|
||||
from apps.system.models import User
|
||||
from apps.system.models import Dept, User
|
||||
from apps.wf.models import CustomField, State, Ticket, TicketFlow, Transition, Workflow
|
||||
from rest_framework.exceptions import APIException, PermissionDenied, ValidationError
|
||||
from django.utils import timezone
|
||||
|
@ -173,29 +173,35 @@ class WfService(object):
|
|||
|
||||
elif destination_participant_type == State.PARTICIPANT_TYPE_POST: # 岗位
|
||||
user_queryset = User.objects.filter(posts__in=destination_participant)
|
||||
# 如果选择了岗位, 需要走过滤策略
|
||||
if state.filter_policy == 1:
|
||||
depts = get_parent_queryset(ticket.belong_dept)
|
||||
user_queryset = user_queryset.filter(depts__in=depts)
|
||||
elif state.filter_policy == 2:
|
||||
depts = get_parent_queryset(ticket.create_by.belong_dept)
|
||||
user_queryset = user_queryset.filter(depts__in=depts)
|
||||
elif state.filter_policy == 3:
|
||||
depts = get_parent_queryset(handler.belong_dept)
|
||||
user_queryset = user_queryset.filter(depts__in=depts)
|
||||
# 如果选择了岗位, 可能需要走过滤策略
|
||||
if state.filter_dept:
|
||||
dpts = Dept.objects.filter(id=new_ticket_data[state.filter_dept])
|
||||
user_queryset = user_queryset.filter(depts__in=dpts)
|
||||
# if state.filter_policy == 1:
|
||||
# depts = get_parent_queryset(ticket.belong_dept)
|
||||
# user_queryset = user_queryset.filter(depts__in=depts)
|
||||
# elif state.filter_policy == 2:
|
||||
# depts = get_parent_queryset(ticket.create_by.belong_dept)
|
||||
# user_queryset = user_queryset.filter(depts__in=depts)
|
||||
# elif state.filter_policy == 3:
|
||||
# depts = get_parent_queryset(handler.belong_dept)
|
||||
# user_queryset = user_queryset.filter(depts__in=depts)
|
||||
destination_participant = list(user_queryset.values_list('id', flat=True))
|
||||
elif destination_participant_type == State.PARTICIPANT_TYPE_ROLE: # 角色
|
||||
user_queryset = User.objects.filter(roles__in=destination_participant)
|
||||
# 如果选择了角色, 需要走过滤策略
|
||||
if state.filter_policy == 1:
|
||||
depts = get_parent_queryset(ticket.belong_dept)
|
||||
user_queryset = user_queryset.filter(depts__in=depts)
|
||||
elif state.filter_policy == 2:
|
||||
depts = get_parent_queryset(ticket.create_by.belong_dept)
|
||||
user_queryset = user_queryset.filter(depts__in=depts)
|
||||
elif state.filter_policy == 3:
|
||||
depts = get_parent_queryset(handler.belong_dept)
|
||||
user_queryset = user_queryset.filter(depts__in=depts)
|
||||
if state.filter_dept:
|
||||
dpts = Dept.objects.filter(id=new_ticket_data.get(state.filter_dept, '0'))
|
||||
user_queryset = user_queryset.filter(depts__in=dpts)
|
||||
# if state.filter_policy == 1:
|
||||
# depts = get_parent_queryset(ticket.belong_dept)
|
||||
# user_queryset = user_queryset.filter(depts__in=depts)
|
||||
# elif state.filter_policy == 2:
|
||||
# depts = get_parent_queryset(ticket.create_by.belong_dept)
|
||||
# user_queryset = user_queryset.filter(depts__in=depts)
|
||||
# elif state.filter_policy == 3:
|
||||
# depts = get_parent_queryset(handler.belong_dept)
|
||||
# user_queryset = user_queryset.filter(depts__in=depts)
|
||||
destination_participant = list(user_queryset.values_list('id', flat=True))
|
||||
if destination_participant_type != 0 and (not destination_participant):
|
||||
raise ParseError('未找到处理人,工单无法继续')
|
||||
|
|
Loading…
Reference in New Issue