feat: base 提交时可变动工单title
This commit is contained in:
parent
f84ceaa95e
commit
00f2918d17
|
|
@ -11,7 +11,7 @@ import random
|
||||||
from apps.utils.queryset import get_parent_queryset
|
from apps.utils.queryset import get_parent_queryset
|
||||||
from apps.wf.tasks import run_task
|
from apps.wf.tasks import run_task
|
||||||
from rest_framework.exceptions import ParseError
|
from rest_framework.exceptions import ParseError
|
||||||
|
import time
|
||||||
|
|
||||||
class WfService(object):
|
class WfService(object):
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|
@ -338,6 +338,15 @@ class WfService(object):
|
||||||
act_state=Ticket.TICKET_ACT_STATE_DRAFT,
|
act_state=Ticket.TICKET_ACT_STATE_DRAFT,
|
||||||
belong_dept=handler.belong_dept,
|
belong_dept=handler.belong_dept,
|
||||||
ticket_data=save_ticket_data, participant_type=1, participant=handler.id) # 先创建出来
|
ticket_data=save_ticket_data, participant_type=1, participant=handler.id) # 先创建出来
|
||||||
|
|
||||||
|
sn = WfService.get_ticket_sn(ticket.workflow) # 流水号
|
||||||
|
ticket.sn = sn
|
||||||
|
ticket.save()
|
||||||
|
if not transition:
|
||||||
|
return ticket
|
||||||
|
just_created = True # 刚创建的工单不需要校验权限
|
||||||
|
|
||||||
|
if transition and transition.source_state.type == State.STATE_TYPE_START:
|
||||||
# 更新title和sn
|
# 更新title和sn
|
||||||
ticket_title = oinfo.get("title", "")
|
ticket_title = oinfo.get("title", "")
|
||||||
title_template = ticket.workflow.title_template
|
title_template = ticket.workflow.title_template
|
||||||
|
|
@ -347,13 +356,8 @@ class WfService(object):
|
||||||
ticket_title = title_template.format(**all_ticket_data)
|
ticket_title = title_template.format(**all_ticket_data)
|
||||||
except KeyError as e:
|
except KeyError as e:
|
||||||
raise ParseError(f"工单标题模板中存在未定义的变量:{e}")
|
raise ParseError(f"工单标题模板中存在未定义的变量:{e}")
|
||||||
sn = WfService.get_ticket_sn(ticket.workflow) # 流水号
|
|
||||||
ticket.sn = sn
|
|
||||||
ticket.title = ticket_title
|
ticket.title = ticket_title
|
||||||
ticket.save()
|
ticket.save(update_fields=["title"])
|
||||||
if not transition:
|
|
||||||
return ticket
|
|
||||||
just_created = True # 刚创建的工单不需要校验权限
|
|
||||||
|
|
||||||
source_state = ticket.state
|
source_state = ticket.state
|
||||||
source_ticket_data = ticket.ticket_data
|
source_ticket_data = ticket.ticket_data
|
||||||
|
|
@ -511,7 +515,7 @@ class WfService(object):
|
||||||
@classmethod
|
@classmethod
|
||||||
def send_ticket_notice(cls, ticketflow:TicketFlow):
|
def send_ticket_notice(cls, ticketflow:TicketFlow):
|
||||||
# 根据ticketflow发送通知
|
# 根据ticketflow发送通知
|
||||||
Thread(target=send_ticket_notice_t, args=(ticketflow,), daemon=True).start()
|
Thread(target=send_ticket_notice_t, args=(ticketflow.id,), daemon=True).start()
|
||||||
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
|
@ -547,11 +551,12 @@ class WfService(object):
|
||||||
participant=handler, transition=None)
|
participant=handler, transition=None)
|
||||||
cls.task_ticket(ticket=ticket)
|
cls.task_ticket(ticket=ticket)
|
||||||
|
|
||||||
def send_ticket_notice_t(ticketflow: TicketFlow):
|
def send_ticket_notice_t(ticketflowId: str):
|
||||||
"""
|
"""
|
||||||
发送通知
|
发送通知
|
||||||
"""
|
"""
|
||||||
ticket = ticketflow.ticket
|
time.sleep(3)
|
||||||
|
ticket = TicketFlow.objects.get(id=ticketflowId).ticket
|
||||||
params = {'workflow': ticket.workflow.name, 'state': ticket.state.name}
|
params = {'workflow': ticket.workflow.name, 'state': ticket.state.name}
|
||||||
if ticket.participant_type == 1:
|
if ticket.participant_type == 1:
|
||||||
# 发送短信通知
|
# 发送短信通知
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue