diff --git a/itsm/pipeline_plugins/components/collections/itsm_sign.py b/itsm/pipeline_plugins/components/collections/itsm_sign.py index 50888a7a..a80ecb68 100644 --- a/itsm/pipeline_plugins/components/collections/itsm_sign.py +++ b/itsm/pipeline_plugins/components/collections/itsm_sign.py @@ -25,7 +25,7 @@ import logging -from itsm.component.constants import NODE_APPROVE_RESULT +from itsm.component.constants import NODE_APPROVE_RESULT, TERMINATED from itsm.ticket.models import Ticket, Status, TicketGlobalVariable, SignTask from pipeline.component_framework.component import Component @@ -88,12 +88,12 @@ def schedule(self, data, parent_data, callback_data=None): operator = callback_data["operator"] fields = callback_data["fields"] source = callback_data["source"] - variables = data.outputs.get("variables") finish_condition = data.outputs.get("finish_condition") code_key = data.outputs.get("code_key") ticket = Ticket.objects.get(id=ticket_id) node_status = Status.objects.get(ticket_id=ticket_id, state_id=state_id) + state = ticket.state(state_id) try: ticket.do_in_sign_state(node_status, fields, operator, source) @@ -117,6 +117,15 @@ def schedule(self, data, parent_data, callback_data=None): data.set_outputs("params_%s" % field["key"], field["value"]) self.do_before_exit(ticket, state_id, operator) + if key_value[ + code_key[NODE_APPROVE_RESULT] + ] == "false" and state.get( + "enable_terminate_ticket_when_rejected", False + ): + logger.info( + "[sign] enable_terminate_ticket_when_rejected is true ticket closed" + ) + ticket.close(close_status=TERMINATED, operator="system") self.finish_schedule() finally: self.final_execute(node_status, operator) diff --git a/itsm/ticket/models/ticket.py b/itsm/ticket/models/ticket.py index 7bf283af..c4d6cdb9 100644 --- a/itsm/ticket/models/ticket.py +++ b/itsm/ticket/models/ticket.py @@ -2948,7 +2948,7 @@ def set_finished( # TODO: 临时处理, 后面会放在母子单解绑逻辑中 ticket.current_status = close_status ticket.node_status.filter(status__in=Status.RUNNING_STATUS).update( - status=FINISHED + status=close_status ) ticket.current_task_processors = "" ticket.current_processors = ""