Skip to content

Commit

Permalink
Merge branch 'hotfix'
Browse files Browse the repository at this point in the history
  • Loading branch information
blackholll committed Jul 15, 2018
2 parents 6fa49de + cbf109b commit ede66ea
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 10 deletions.
3 changes: 2 additions & 1 deletion apps/ticket/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,15 @@ def get(self, request, *args, **kwargs):
username = request_data.get('username', '')
create_start = request_data.get('create_start', '')
create_end = request_data.get('create_end', '')
workflow_ids = request_data.get('workflow_ids', '')
reverse = int(request_data.get('reverse', 1))
per_page = int(request_data.get('per_page', 10))
page = int(request_data.get('page', 1))
# 待办,关联的,创建
category = request_data.get('category')
ticket_result_restful_list, msg = TicketBaseService.get_ticket_list(sn=sn, title=title, username=username,
create_start=create_start, create_end=create_end,
category=category, reverse=reverse, per_page=per_page, page=page)
workflow_ids=workflow_ids,category=category, reverse=reverse, per_page=per_page, page=page)
if ticket_result_restful_list is not False:
data = dict(value=ticket_result_restful_list, per_page=msg['per_page'], page=msg['page'], total=msg['total'])
code, msg, = 0, ''
Expand Down
23 changes: 19 additions & 4 deletions docs/apis/ticket.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ GET

参数名 | 类型 | 必填 | 说明
---|---|---|---
sn | varchar | 否 | 流水号,支持根据sn的前几位模糊查询
title | varchar | 否 | 工单标题,模糊查询
create_start | varchar | 否 | 创建时间起
create_end | varchar | 否 | 创建时间止
workflow_ids | varchar | 否 | 工作流ids,逗号隔开多个工作流id
reverse | varchar | 否 | 是否按照创建时间倒序,0或者1
page| int | 否 | 页码,默认1
per_page| int | 否 | 每页个数,默认10
username | varchar | 是 | 用户名
Expand All @@ -24,10 +30,11 @@ category | varchar | 是 | 类型('all':所有工单, 'owner':我创建的工单
"data": {
"value": [{
"participant_info": {
"participant_type_id": 3,
"participant_type_id": 1,
"participant": "1",
"participant_name": "总部",
"participant_type_name": "部门"
"participant_name": "zhangsan",
"participant_type_name": "个人",
"participant_alias": "张三"
},
"gmt_created": "2018-05-15 07:16:38",
"parent_ticket_state_id": 0,
Expand Down Expand Up @@ -112,7 +119,15 @@ username | varchar | 是 | 请求用户的用户名
order_id: 0,
field_type_id: 1,
field_key: "model"
}],
},
{
field_attribute: 1,
order_id: 55,
name: "当前处理人",
value: "轨迹,王五",
field_key: "participant_info.participant_alias",
field_type_id: 5
}],
participant_type_id: 0,
title: "dfdsfsfsdf",
participant: "zhangsan",
Expand Down
4 changes: 2 additions & 2 deletions service/account/account_base_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@ def get_role_username_list(cls, role_id):
return [], ''
username_queryset = LoonUser.objects.filter(id__in=(user_id_list)).all()
username_list = []
for username in username_queryset:
username_list.append(username)
for username_obj in username_queryset:
username_list.append(username_obj.username)
return username_list, ''

@classmethod
Expand Down
26 changes: 23 additions & 3 deletions service/ticket/ticket_base_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,15 @@ def __init__(self):

@classmethod
@auto_log
def get_ticket_list(cls, sn='', title='', username='', create_start='', create_end='', category='', reverse=1, per_page=10, page=1):
def get_ticket_list(cls, sn='', title='', username='', create_start='', create_end='',workflow_ids='', category='', reverse=1, per_page=10, page=1):
"""
工单列表
:param sn:
:param title:
:param username:
:param create_start: 创建时间起
:param create_end: 创建时间止
:param workflow_ids: 工作流id,str,逗号隔开
:param category: 查询类别(创建的,待办的,关联的:包括创建的、处理过的、曾经需要处理但是没有处理的)
:param reverse: 按照创建时间倒序
:param per_page:
Expand All @@ -51,6 +52,10 @@ def get_ticket_list(cls, sn='', title='', username='', create_start='', create_e
query_params &= Q(gmt_created__gte=create_start)
if create_end:
query_params &= Q(gmt_created__lte=create_end)
if workflow_ids:
workflow_id_str_list = workflow_ids.split(',')
workflow_id_list = [int(workflow_id_str) for workflow_id_str in workflow_id_str_list]
query_params &= Q(workflow_id__in=workflow_id_list)

if reverse:
order_by_str = '-gmt_created'
Expand Down Expand Up @@ -580,6 +585,8 @@ def get_ticket_base_filed_list(cls, ticket_id):
field_list.append(dict(field_key='title', name=u'标题', value=ticket_obj.title, order_id=20, field_type_id=CONSTANT_SERVICE.FIELD_TYPE_STR, field_attribute=CONSTANT_SERVICE.FIELD_ATTRIBUTE_RO))
field_list.append(dict(field_key='state_id', name=u'状态id', value=ticket_obj.state_id, order_id=40, field_type_id=CONSTANT_SERVICE.FIELD_TYPE_STR, field_attribute=CONSTANT_SERVICE.FIELD_ATTRIBUTE_RO))
field_list.append(dict(field_key='participant_info.participant_name', name=u'当前处理人', value=participant_info_dict['participant_name'], order_id=50, field_type_id=CONSTANT_SERVICE.FIELD_TYPE_STR, field_attribute=CONSTANT_SERVICE.FIELD_ATTRIBUTE_RO))
field_list.append(dict(field_key='participant_info.participant_alias', name=u'当前处理人', value=participant_info_dict['participant_alias'], order_id=55, field_type_id=CONSTANT_SERVICE.FIELD_TYPE_STR, field_attribute=CONSTANT_SERVICE.FIELD_ATTRIBUTE_RO))

field_list.append(dict(field_key='workflow.workflow_name', name=u'工作流名称', value=workflow_name, order_id=60, field_type_id=CONSTANT_SERVICE.FIELD_TYPE_STR, field_attribute=CONSTANT_SERVICE.FIELD_ATTRIBUTE_RO))

field_list.append(dict(field_key='creator', name=u'创建人', value=ticket_obj.creator, order_id=80, field_type_id=CONSTANT_SERVICE.FIELD_TYPE_STR, field_attribute=CONSTANT_SERVICE.FIELD_ATTRIBUTE_RO))
Expand Down Expand Up @@ -641,22 +648,35 @@ def get_ticket_format_participant_info(cls, ticket_id):
ticket_obj = TicketRecord.objects.filter(id=ticket_id, is_deleted=0).first()
participant = ticket_obj.participant
participant_name = ticket_obj.participant
participant_type_id= ticket_obj.participant_type_id
participant_type_id = ticket_obj.participant_type_id
participant_type_name = ''
participant_alias = ''
if participant_type_id == CONSTANT_SERVICE.PARTICIPANT_TYPE_PERSONAL:
participant_type_name = '个人'
participant_user_obj, msg = AccountBaseService.get_user_by_username(participant)
participant_alias = participant_user_obj.alias
elif participant_type_id == CONSTANT_SERVICE.PARTICIPANT_TYPE_MULTI:
participant_type_name = '多人'
# 依次获取人员信息
participant_name_list = participant_name.split(',')
participant_alias_list = []
for participant_name0 in participant_name_list:
participant_user_obj, msg = AccountBaseService.get_user_by_username(participant_name0)
participant_alias_list.append(participant_user_obj.alias)
participant_alias = ','.join(participant_alias_list)
elif participant_type_id == CONSTANT_SERVICE.PARTICIPANT_TYPE_DEPT:
participant_type_name = '部门'
dept_obj, msg = AccountBaseService.get_dept_by_id(int(ticket_obj.participant))
participant_name = dept_obj.name
participant_alias = participant_name
elif participant_type_id == CONSTANT_SERVICE.PARTICIPANT_TYPE_ROLE:
participant_type_name = '角色'
role_obj, msg = AccountBaseService.get_role_by_id(int(ticket_obj.participant))
participant_name = role_obj.name
participant_alias = participant_name
# 工单基础表中不存在参与人为其他类型的情况
return dict(participant=participant, participant_name=participant_name, participant_type_id=participant_type_id, participant_type_name=participant_type_name), ''
return dict(participant=participant, participant_name=participant_name, participant_type_id=participant_type_id,
participant_type_name=participant_type_name, participant_alias=participant_alias), ''

@classmethod
@auto_log
Expand Down

0 comments on commit ede66ea

Please sign in to comment.