From d91c0b2bfef4924869103cff06d2663e478c1028 Mon Sep 17 00:00:00 2001 From: caoqianming Date: Thu, 9 Mar 2023 09:46:34 +0800 Subject: [PATCH] =?UTF-8?q?=E7=9B=B8=E5=85=B3=E6=96=B9=E8=AE=BF=E5=AE=A2?= =?UTF-8?q?=E5=85=A5=E5=8E=82=E5=85=B3=E9=97=AD=E6=97=B6=E5=90=8C=E6=97=B6?= =?UTF-8?q?=E5=85=B3=E9=97=AD=E5=B7=A5=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/rpm/tasks.py | 5 +++++ apps/vm/tasks.py | 5 +++++ apps/wf/services.py | 14 ++++++++++++++ 3 files changed, 24 insertions(+) diff --git a/apps/rpm/tasks.py b/apps/rpm/tasks.py index 4401ceb5..ebecd493 100644 --- a/apps/rpm/tasks.py +++ b/apps/rpm/tasks.py @@ -21,3 +21,8 @@ def close_rpj_by_leave_time(): else: i.state = Rpj.RPJ_CLOSE i.save() + # 工单审批如果还未结束,直接关闭 + from apps.wf.models import Ticket + from apps.wf.services import WfService + if i.ticket and i.ticket.state != Ticket.TICKET_ACT_STATE_FINISH: + WfService.close_by_task(i.ticket, '相关方入厂时间到期') diff --git a/apps/vm/tasks.py b/apps/vm/tasks.py index f46ae2ff..2a797d75 100644 --- a/apps/vm/tasks.py +++ b/apps/vm/tasks.py @@ -21,3 +21,8 @@ def close_visit_by_leave_time(): else: i.state = Visit.V_CLOSE i.save() + # 工单审批如果还未结束,直接关闭 + from apps.wf.models import Ticket + from apps.wf.services import WfService + if i.ticket and i.ticket.state != Ticket.TICKET_ACT_STATE_FINISH: + WfService.close_by_task(i.ticket, '访客入厂时间到期') diff --git a/apps/wf/services.py b/apps/wf/services.py index 53f0bfed..2d5fd0b6 100755 --- a/apps/wf/services.py +++ b/apps/wf/services.py @@ -435,6 +435,20 @@ class WfService(object): if state.participant_type == State.PARTICIPANT_TYPE_ROBOT: run_task.delay(ticket_id=ticket.id) + @classmethod + def close_by_task(cls, ticket: Ticket, suggestion: str): + # 定时任务触发的工单关闭 + end_state = WfService.get_workflow_end_state(ticket.workflow) + ticket.state = end_state + ticket.participant_type = 0 + ticket.participant = 0 + ticket.act_state = Ticket.TICKET_ACT_STATE_CLOSED + ticket.save() + # 更新流转记录 + TicketFlow.objects.create(ticket=ticket, state=ticket.state, + ticket_data=WfService.get_ticket_all_field_value(ticket), + suggestion=suggestion, participant_type=State.PARTICIPANT_TYPE_ROBOT, + intervene_type=Transition.TRANSITION_INTERVENE_TYPE_CLOSE, transition=None) def send_ticket_notice_t(ticket: Ticket): """