From 29612764ae9a7a00810a87f67e595eab34deeb8b Mon Sep 17 00:00:00 2001 From: caoqianming Date: Thu, 21 Oct 2021 08:55:07 +0800 Subject: [PATCH] =?UTF-8?q?eval=20=E5=AE=89=E5=85=A8=E6=80=A7=E5=A4=84?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hb_server/apps/wf/models.py | 4 +++- hb_server/apps/wf/services.py | 2 +- hb_server/apps/wf/views.py | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/hb_server/apps/wf/models.py b/hb_server/apps/wf/models.py index 5427ed2..877165c 100644 --- a/hb_server/apps/wf/models.py +++ b/hb_server/apps/wf/models.py @@ -39,6 +39,7 @@ class State(CommonAModel): PARTICIPANT_TYPE_ROBOT = 6 PARTICIPANT_TYPE_FIELD = 7 PARTICIPANT_TYPE_PARENT_FIELD = 8 + PARTICIPANT_TYPE_FORMCODE = 9 state_participanttype_choices = ( (0, '无处理人'), (PARTICIPANT_TYPE_PERSONAL, '个人'), @@ -48,7 +49,8 @@ class State(CommonAModel): (PARTICIPANT_TYPE_VARIABLE, '变量'), (PARTICIPANT_TYPE_ROBOT, '脚本'), (PARTICIPANT_TYPE_FIELD, '工单的字段'), - (PARTICIPANT_TYPE_PARENT_FIELD, '父工单的字段') + (PARTICIPANT_TYPE_PARENT_FIELD, '父工单的字段'), + (PARTICIPANT_TYPE_FORMCODE, '代码获取') ) STATE_DISTRIBUTE_TYPE_ACTIVE = 1 # 主动接单 STATE_DISTRIBUTE_TYPE_DIRECT = 2 # 直接处理(当前为多人的情况,都可以处理,而不需要先接单) diff --git a/hb_server/apps/wf/services.py b/hb_server/apps/wf/services.py index 8df0377..c27dab8 100644 --- a/hb_server/apps/wf/services.py +++ b/hb_server/apps/wf/services.py @@ -119,7 +119,7 @@ class WfService(object): for i in transition.condition_expression: expression = i['expression'].format(**ticket_all_value) import datetime, time # 用于支持条件表达式中对时间的操作 - if eval(expression): + if eval(expression, {"__builtins__":None}, {'datetime':datetime, 'time':time}): destination_state = State.objects.get(pk=i['target_state']) return destination_state diff --git a/hb_server/apps/wf/views.py b/hb_server/apps/wf/views.py index f2cc372..67e3a12 100644 --- a/hb_server/apps/wf/views.py +++ b/hb_server/apps/wf/views.py @@ -15,6 +15,7 @@ from apps.wf.services import WfService from rest_framework.exceptions import APIException, PermissionDenied from rest_framework import status from django.db.models import Count + # Create your views here. class WorkflowViewSet(CreateUpdateModelAMixin, ModelViewSet): perms_map = {'get': '*', 'post': 'workflow_create',