Skip to content

Commit

Permalink
bugfix:random participant for role or dept
Browse files Browse the repository at this point in the history
  • Loading branch information
blackholll committed Nov 25, 2018
1 parent a956a24 commit 1a47f30
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions service/ticket/ticket_base_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -1527,11 +1527,11 @@ def get_ticket_state_participant_info(cls, state_id, ticket_id=0, ticket_req_dic
return False, msg
parent_ticket_id = ticket_obj.parent_ticket_id
creator = ticket_obj.creator
multi_all_person_dict = json.loads(ticket_obj.multi_all_person)
multi_all_person = json.loads(ticket_obj.multi_all_person)
else:
parent_ticket_id = ticket_req_dict.get('parent_ticket_id')
creator = ticket_req_dict.get('username')
multi_all_person = {}
multi_all_person = "{}"

state_obj, msg = WorkflowStateService.get_workflow_state_by_id(state_id)
participant_type_id, participant = state_obj.participant_type_id, state_obj.participant
Expand All @@ -1547,10 +1547,10 @@ def get_ticket_state_participant_info(cls, state_id, ticket_id=0, ticket_req_dic
update_field_list = field_info.get('update_field_list')
if participant in update_field_list and ticket_req_dict.get(participant):
# 请求数据中包含需要的字段则从请求数据中获取
participant = ticket_req_dict.get(participant)
destination_participant = ticket_req_dict.get(participant)
else:
# 处理工单时未提供字段的值,则从工单当前字段值中获取
participant, msg = cls.get_ticket_field_value(participant)
destination_participant, msg = cls.get_ticket_field_value(participant)
destination_participant_type_id = CONSTANT_SERVICE.PARTICIPANT_TYPE_PERSONAL
if len(destination_participant.split(',')) > 1:
destination_participant_type_id = CONSTANT_SERVICE.PARTICIPANT_TYPE_MULTI
Expand All @@ -1572,8 +1572,16 @@ def get_ticket_state_participant_info(cls, state_id, ticket_id=0, ticket_req_dic
if len(approver.split(',')) > 1:
destination_participant_type_id = CONSTANT_SERVICE.PARTICIPANT_TYPE_MULTI
destination_participant = approver
if destination_participant_type_id == CONSTANT_SERVICE.PARTICIPANT_TYPE_MULTI:
destination_participant_list = destination_participant.split(',')
if destination_participant_type_id in (CONSTANT_SERVICE.PARTICIPANT_TYPE_MULTI, CONSTANT_SERVICE.PARTICIPANT_TYPE_DEPT, CONSTANT_SERVICE.PARTICIPANT_TYPE_ROLE) \
and state_obj.distribute_type_id in (CONSTANT_SERVICE.STATE_DISTRIBUTE_TYPE_RANDOM, CONSTANT_SERVICE.STATE_DISTRIBUTE_TYPE_ALL):
# 处理人为角色,部门,或者角色都可能是为多个人,需要根据状态的分配方式计算实际的处理人
if destination_participant_type_id == CONSTANT_SERVICE.PARTICIPANT_TYPE_MULTI:
destination_participant_list = destination_participant.split(',')
elif destination_participant_type_id == CONSTANT_SERVICE.PARTICIPANT_TYPE_DEPT:
destination_participant_list, msg = AccountBaseService.get_dept_username_list(int(destination_participant))
elif destination_participant_type_id == CONSTANT_SERVICE.PARTICIPANT_TYPE_ROLE:
destination_participant_list, msg = AccountBaseService.get_role_username_list(int(destination_participant))

if state_obj.distribute_type_id == CONSTANT_SERVICE.STATE_DISTRIBUTE_TYPE_RANDOM:
# 如果是随机处理,则随机设置处理人
destination_participant = random.sample(destination_participant_list, 1)
Expand Down

0 comments on commit 1a47f30

Please sign in to comment.