feat: 工单回到创建中时更改作业状态
This commit is contained in:
parent
8a7ae2994e
commit
07822f093d
|
@ -70,6 +70,24 @@ def bind_opl(ticket: Ticket, transition: Transition, new_ticket_data: dict):
|
||||||
op.state = Operation.OP_AUDIT
|
op.state = Operation.OP_AUDIT
|
||||||
op.save()
|
op.save()
|
||||||
|
|
||||||
|
def correct_operation_state(ticket: Ticket):
|
||||||
|
"""
|
||||||
|
矫正作业状态, 工单状态回到开始时让作业回到创建中
|
||||||
|
"""
|
||||||
|
opl = Opl.objects.get(ticket=ticket)
|
||||||
|
op = opl.operation
|
||||||
|
if op.state == Operation.OP_AUDIT:
|
||||||
|
need_backs = []
|
||||||
|
for opl in Opl.objects.filter(operation=op):
|
||||||
|
if (opl.ticket is None) or (opl.ticket and opl.ticket.state.type == 1 and opl.ticket.act_state in [2, 3]): # 如果在初始状态且是撤回或退回
|
||||||
|
need_backs.append(True)
|
||||||
|
else:
|
||||||
|
need_backs.append(False)
|
||||||
|
if False in need_backs:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
Operation.objects.filter(id=op.id).update(state=Operation.OP_CREATE)
|
||||||
|
|
||||||
|
|
||||||
def t_submit_close_mtask(ticket: Ticket, transition: Transition, new_ticket_data: dict):
|
def t_submit_close_mtask(ticket: Ticket, transition: Transition, new_ticket_data: dict):
|
||||||
# 提交作业关闭时关闭作业监控
|
# 提交作业关闭时关闭作业监控
|
||||||
|
|
|
@ -6,9 +6,22 @@ from celery import shared_task
|
||||||
|
|
||||||
from apps.wf.models import Ticket
|
from apps.wf.models import Ticket
|
||||||
|
|
||||||
|
@shared_task(base=CustomTask)
|
||||||
|
def correct_operation_state():
|
||||||
|
"""
|
||||||
|
矫正作业状态
|
||||||
|
"""
|
||||||
|
for op in Operation.objects.filter(state=Operation.OP_AUDIT):
|
||||||
|
need_backs = []
|
||||||
|
for opl in Opl.objects.filter(operation=op):
|
||||||
|
if (opl.ticket is None) or (opl.ticket and opl.ticket.state.type == 1 and opl.ticket.act_state in [2, 3]): # 如果在初始状态且是撤回或退回
|
||||||
|
need_backs.append(True)
|
||||||
|
else:
|
||||||
|
need_backs.append(False)
|
||||||
|
if False in need_backs:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
Operation.objects.filter(id=op.id).update(state=Operation.OP_CREATE)
|
||||||
|
|
||||||
# @shared_task(base=CustomTask)
|
# @shared_task(base=CustomTask)
|
||||||
# def opl_audit_start(ticket_id):
|
# def opl_audit_start(ticket_id):
|
||||||
|
|
Loading…
Reference in New Issue