55 lines
1.6 KiB
Python
55 lines
1.6 KiB
Python
from apps.opm.models import Operation, Opl, OplWorker
|
|
from apps.opm.serializers import OplCloseSerializer
|
|
from apps.wf.models import Ticket, Transition
|
|
|
|
|
|
def get_op_manager(state, ticket, new_ticket_data, handler):
|
|
"""_summary_
|
|
|
|
Args:
|
|
state (_type_): 工作流节点实例
|
|
ticket (_type_): 工单实例
|
|
new_ticket_data (_type_): 提交的工单数据
|
|
handler (_type_): 处理人实例
|
|
"""
|
|
opl = Opl.objects.filter(ticket=ticket).first()
|
|
if opl:
|
|
return [opl.charger.id]
|
|
|
|
|
|
def get_op_workers(state, ticket, new_ticket_data, handler):
|
|
opl = Opl.objects.filter(ticket=ticket).first()
|
|
if opl:
|
|
return list(OplWorker.objects.filter(opl=opl).values_list('worker__id', flat=True))
|
|
|
|
|
|
def get_op_monitor(state, ticket, new_ticket_data, handler):
|
|
opl = Opl.objects.filter(ticket=ticket).first()
|
|
if opl:
|
|
return [opl.monitor.id]
|
|
|
|
|
|
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.ticket_data = ticket_data
|
|
ticket.save()
|
|
opl.ticket = opl
|
|
opl.number = ticket.sn
|
|
opl.save()
|
|
|
|
|
|
def close_opl_submit(ticket: Ticket, transition: Transition, new_ticket_data: dict):
|
|
opl = Opl.objects.get(ticket=ticket)
|
|
serializer = OplCloseSerializer(instance=opl, data=new_ticket_data, partial=True)
|
|
serializer.is_valid(raise_exception=True)
|
|
serializer.save()
|
|
|
|
|
|
def give_perm_by_opl():
|
|
"""
|
|
根据许可证授予区域进入权限
|
|
"""
|
|
pass
|