From c4e2c8bcd9552163f84654cad2d845d435e3a17c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E8=89=AF?= <841369634@qq.com> Date: Tue, 28 Apr 2026 16:23:58 +0800 Subject: [PATCH 01/16] perf: Optimize the compare --- apps/application/flow/compare/__init__.py | 48 +++++++++++++++++-- apps/application/flow/compare/compare.py | 3 -- .../flow/compare/contain_compare.py | 4 -- apps/application/flow/compare/end_with.py | 4 -- .../application/flow/compare/equal_compare.py | 4 -- apps/application/flow/compare/ge_compare.py | 4 -- apps/application/flow/compare/gt_compare.py | 4 -- .../flow/compare/is_not_null_compare.py | 4 -- apps/application/flow/compare/is_not_true.py | 4 -- .../flow/compare/is_null_compare.py | 4 -- apps/application/flow/compare/is_true.py | 4 -- apps/application/flow/compare/le_compare.py | 4 -- .../flow/compare/len_equal_compare.py | 4 -- .../flow/compare/len_ge_compare.py | 4 -- .../flow/compare/len_gt_compare.py | 4 -- .../flow/compare/len_le_compare.py | 4 -- .../flow/compare/len_lt_compare.py | 4 -- apps/application/flow/compare/lt_compare.py | 4 -- .../flow/compare/not_contain_compare.py | 4 -- .../flow/compare/not_equal_compare.py | 4 -- .../application/flow/compare/regex_compare.py | 4 -- apps/application/flow/compare/start_with.py | 4 -- .../flow/compare/wildcard_compare.py | 4 -- .../impl/base_condition_node.py | 15 +----- .../impl/base_loop_break_node.py | 15 +----- .../impl/base_loop_continue_node.py | 15 +----- ui/src/workflow/common/data.ts | 4 +- 27 files changed, 51 insertions(+), 133 deletions(-) diff --git a/apps/application/flow/compare/__init__.py b/apps/application/flow/compare/__init__.py index 4e99bfa7270..c676754495f 100644 --- a/apps/application/flow/compare/__init__.py +++ b/apps/application/flow/compare/__init__.py @@ -29,8 +29,46 @@ from .start_with import StartWithCompare from .wildcard_compare import WildcardCompare -compare_handle_list = [GECompare(), GTCompare(), ContainCompare(), EqualCompare(), LTCompare(), LECompare(), - LenLECompare(), LenGECompare(), LenEqualCompare(), LenGTCompare(), LenLTCompare(), - IsNullCompare(), - IsNotNullCompare(), NotContainCompare(), NotEqualCompare(), IsTrueCompare(), IsNotTrueCompare(), StartWithCompare(), - EndWithCompare(), RegexCompare(), WildcardCompare()] +_compare_handle_dict = { + 'is_null': IsNullCompare(), + 'is_not_null': IsNotNullCompare(), + 'contain': ContainCompare(), + 'not_contain': NotContainCompare(), + 'eq': EqualCompare(), + 'not_eq': NotEqualCompare(), + 'ge': GECompare(), + 'gt': GTCompare(), + 'lt': LTCompare(), + 'le': LECompare(), + 'len_eq': LenEqualCompare(), + 'len_ge': LenGECompare(), + 'len_gt': LenGTCompare(), + 'len_le': LenLECompare(), + 'len_lt': LenLTCompare(), + 'is_true': IsTrueCompare(), + 'is_not_true': IsNotTrueCompare(), + 'start_with': StartWithCompare(), + 'end_with': EndWithCompare(), + 'regex': RegexCompare(), + 'wildcard': WildcardCompare(), +} + + +def _do_compare(source_value, compare, target_value): + compare_handle = _compare_handle_dict.get(compare) + if compare_handle: + return compare_handle.compare(source_value, compare, target_value) + return False + + +def do_assertion(workflow_manage, field_list: List[str], compare: str, value): + try: + value = workflow_manage.generate_prompt(value) + except Exception: + pass + field_value = None + try: + field_value = workflow_manage.get_reference_field(field_list[0], field_list[1:]) + except Exception: + pass + return _do_compare(field_value, compare, value) diff --git a/apps/application/flow/compare/compare.py b/apps/application/flow/compare/compare.py index 6cbb4af0732..c91f076ed46 100644 --- a/apps/application/flow/compare/compare.py +++ b/apps/application/flow/compare/compare.py @@ -11,9 +11,6 @@ class Compare: - @abstractmethod - def support(self, node_id, fields: List[str], source_value, compare, target_value): - pass @abstractmethod def compare(self, source_value, compare, target_value): diff --git a/apps/application/flow/compare/contain_compare.py b/apps/application/flow/compare/contain_compare.py index b79b9cad728..7f453965599 100644 --- a/apps/application/flow/compare/contain_compare.py +++ b/apps/application/flow/compare/contain_compare.py @@ -13,10 +13,6 @@ class ContainCompare(Compare): - def support(self, node_id, fields: List[str], source_value, compare, target_value): - if compare == 'contain': - return True - def compare(self, source_value, compare, target_value): target_value = str(target_value) diff --git a/apps/application/flow/compare/end_with.py b/apps/application/flow/compare/end_with.py index a0fe1798956..9157c0beff0 100644 --- a/apps/application/flow/compare/end_with.py +++ b/apps/application/flow/compare/end_with.py @@ -13,10 +13,6 @@ class EndWithCompare(Compare): - def support(self, node_id, fields: List[str], source_value, compare, target_value): - if compare == 'end_with': - return True - def compare(self, source_value, compare, target_value): source_value = str(source_value) return source_value.endswith(str(target_value)) diff --git a/apps/application/flow/compare/equal_compare.py b/apps/application/flow/compare/equal_compare.py index b8d9f7eeead..7a879d58149 100644 --- a/apps/application/flow/compare/equal_compare.py +++ b/apps/application/flow/compare/equal_compare.py @@ -13,9 +13,5 @@ class EqualCompare(Compare): - def support(self, node_id, fields: List[str], source_value, compare, target_value): - if compare == 'eq': - return True - def compare(self, source_value, compare, target_value): return str(source_value) == str(target_value) diff --git a/apps/application/flow/compare/ge_compare.py b/apps/application/flow/compare/ge_compare.py index 84a223beef2..75b9574a9c0 100644 --- a/apps/application/flow/compare/ge_compare.py +++ b/apps/application/flow/compare/ge_compare.py @@ -13,10 +13,6 @@ class GECompare(Compare): - def support(self, node_id, fields: List[str], source_value, compare, target_value): - if compare == 'ge': - return True - def compare(self, source_value, compare, target_value): try: return float(source_value) >= float(target_value) diff --git a/apps/application/flow/compare/gt_compare.py b/apps/application/flow/compare/gt_compare.py index 2307aaae418..773771b913a 100644 --- a/apps/application/flow/compare/gt_compare.py +++ b/apps/application/flow/compare/gt_compare.py @@ -13,10 +13,6 @@ class GTCompare(Compare): - def support(self, node_id, fields: List[str], source_value, compare, target_value): - if compare == 'gt': - return True - def compare(self, source_value, compare, target_value): try: return float(source_value) > float(target_value) diff --git a/apps/application/flow/compare/is_not_null_compare.py b/apps/application/flow/compare/is_not_null_compare.py index 92306bed0b8..1b5a97f8b20 100644 --- a/apps/application/flow/compare/is_not_null_compare.py +++ b/apps/application/flow/compare/is_not_null_compare.py @@ -13,10 +13,6 @@ class IsNotNullCompare(Compare): - def support(self, node_id, fields: List[str], source_value, compare, target_value): - if compare == 'is_not_null': - return True - def compare(self, source_value, compare, target_value): try: return source_value is not None and len(source_value) > 0 diff --git a/apps/application/flow/compare/is_not_true.py b/apps/application/flow/compare/is_not_true.py index 78433a76d87..07eda98a2ee 100644 --- a/apps/application/flow/compare/is_not_true.py +++ b/apps/application/flow/compare/is_not_true.py @@ -13,10 +13,6 @@ class IsNotTrueCompare(Compare): - def support(self, node_id, fields: List[str], source_value, compare, target_value): - if compare == 'is_not_true': - return True - def compare(self, source_value, compare, target_value): try: return source_value is False diff --git a/apps/application/flow/compare/is_null_compare.py b/apps/application/flow/compare/is_null_compare.py index 09c115c98d9..d971d08dc7e 100644 --- a/apps/application/flow/compare/is_null_compare.py +++ b/apps/application/flow/compare/is_null_compare.py @@ -13,10 +13,6 @@ class IsNullCompare(Compare): - def support(self, node_id, fields: List[str], source_value, compare, target_value): - if compare == 'is_null': - return True - def compare(self, source_value, compare, target_value): try: return source_value is None or len(source_value) == 0 diff --git a/apps/application/flow/compare/is_true.py b/apps/application/flow/compare/is_true.py index e3f29ea2978..1eee0e1227f 100644 --- a/apps/application/flow/compare/is_true.py +++ b/apps/application/flow/compare/is_true.py @@ -13,10 +13,6 @@ class IsTrueCompare(Compare): - def support(self, node_id, fields: List[str], source_value, compare, target_value): - if compare == 'is_true': - return True - def compare(self, source_value, compare, target_value): try: return source_value is True diff --git a/apps/application/flow/compare/le_compare.py b/apps/application/flow/compare/le_compare.py index 0b1710a25dd..cf167ea2253 100644 --- a/apps/application/flow/compare/le_compare.py +++ b/apps/application/flow/compare/le_compare.py @@ -13,10 +13,6 @@ class LECompare(Compare): - def support(self, node_id, fields: List[str], source_value, compare, target_value): - if compare == 'le': - return True - def compare(self, source_value, compare, target_value): try: return float(source_value) <= float(target_value) diff --git a/apps/application/flow/compare/len_equal_compare.py b/apps/application/flow/compare/len_equal_compare.py index 203a0338fd2..ea87823d4b0 100644 --- a/apps/application/flow/compare/len_equal_compare.py +++ b/apps/application/flow/compare/len_equal_compare.py @@ -13,10 +13,6 @@ class LenEqualCompare(Compare): - def support(self, node_id, fields: List[str], source_value, compare, target_value): - if compare == 'len_eq': - return True - def compare(self, source_value, compare, target_value): try: return len(source_value) == int(target_value) diff --git a/apps/application/flow/compare/len_ge_compare.py b/apps/application/flow/compare/len_ge_compare.py index d1e45cd3419..cb289eb1499 100644 --- a/apps/application/flow/compare/len_ge_compare.py +++ b/apps/application/flow/compare/len_ge_compare.py @@ -13,10 +13,6 @@ class LenGECompare(Compare): - def support(self, node_id, fields: List[str], source_value, compare, target_value): - if compare == 'len_ge': - return True - def compare(self, source_value, compare, target_value): try: return len(source_value) >= int(target_value) diff --git a/apps/application/flow/compare/len_gt_compare.py b/apps/application/flow/compare/len_gt_compare.py index a3383138208..78e67173ed4 100644 --- a/apps/application/flow/compare/len_gt_compare.py +++ b/apps/application/flow/compare/len_gt_compare.py @@ -13,10 +13,6 @@ class LenGTCompare(Compare): - def support(self, node_id, fields: List[str], source_value, compare, target_value): - if compare == 'len_gt': - return True - def compare(self, source_value, compare, target_value): try: return len(source_value) > int(target_value) diff --git a/apps/application/flow/compare/len_le_compare.py b/apps/application/flow/compare/len_le_compare.py index 6bb73c0a149..3ca856df2d1 100644 --- a/apps/application/flow/compare/len_le_compare.py +++ b/apps/application/flow/compare/len_le_compare.py @@ -13,10 +13,6 @@ class LenLECompare(Compare): - def support(self, node_id, fields: List[str], source_value, compare, target_value): - if compare == 'len_le': - return True - def compare(self, source_value, compare, target_value): try: return len(source_value) <= int(target_value) diff --git a/apps/application/flow/compare/len_lt_compare.py b/apps/application/flow/compare/len_lt_compare.py index 92f99d47a2c..ae913d7548a 100644 --- a/apps/application/flow/compare/len_lt_compare.py +++ b/apps/application/flow/compare/len_lt_compare.py @@ -13,10 +13,6 @@ class LenLTCompare(Compare): - def support(self, node_id, fields: List[str], source_value, compare, target_value): - if compare == 'len_lt': - return True - def compare(self, source_value, compare, target_value): try: return len(source_value) < int(target_value) diff --git a/apps/application/flow/compare/lt_compare.py b/apps/application/flow/compare/lt_compare.py index c5ff3d6f610..7c87876835f 100644 --- a/apps/application/flow/compare/lt_compare.py +++ b/apps/application/flow/compare/lt_compare.py @@ -13,10 +13,6 @@ class LTCompare(Compare): - def support(self, node_id, fields: List[str], source_value, compare, target_value): - if compare == 'lt': - return True - def compare(self, source_value, compare, target_value): try: return float(source_value) < float(target_value) diff --git a/apps/application/flow/compare/not_contain_compare.py b/apps/application/flow/compare/not_contain_compare.py index 193aa1c1f78..3ddadb88048 100644 --- a/apps/application/flow/compare/not_contain_compare.py +++ b/apps/application/flow/compare/not_contain_compare.py @@ -13,10 +13,6 @@ class NotContainCompare(Compare): - def support(self, node_id, fields: List[str], source_value, compare, target_value): - if compare == 'not_contain': - return True - def compare(self, source_value, compare, target_value): target_value = str(target_value) diff --git a/apps/application/flow/compare/not_equal_compare.py b/apps/application/flow/compare/not_equal_compare.py index 7e7a055162e..0118c80e29f 100644 --- a/apps/application/flow/compare/not_equal_compare.py +++ b/apps/application/flow/compare/not_equal_compare.py @@ -13,9 +13,5 @@ class NotEqualCompare(Compare): - def support(self, node_id, fields: List[str], source_value, compare, target_value): - if compare == 'not_eq': - return True - def compare(self, source_value, compare, target_value): return str(source_value) != str(target_value) diff --git a/apps/application/flow/compare/regex_compare.py b/apps/application/flow/compare/regex_compare.py index 8fd98f3eca8..3097b2acea9 100644 --- a/apps/application/flow/compare/regex_compare.py +++ b/apps/application/flow/compare/regex_compare.py @@ -31,10 +31,6 @@ def compile_and_cache(regex): class RegexCompare(Compare): - def support(self, node_id, fields: List[str], source_value, compare, target_value): - if compare == 'regex': - return True - def compare(self, source_value, compare, target_value): match = compile_and_cache(str(target_value)) return bool(match(str(source_value))) diff --git a/apps/application/flow/compare/start_with.py b/apps/application/flow/compare/start_with.py index ccf0ae45b65..ccfc28fcdce 100644 --- a/apps/application/flow/compare/start_with.py +++ b/apps/application/flow/compare/start_with.py @@ -13,10 +13,6 @@ class StartWithCompare(Compare): - def support(self, node_id, fields: List[str], source_value, compare, target_value): - if compare == 'start_with': - return True - def compare(self, source_value, compare, target_value): source_value = str(source_value) return source_value.startswith(str(target_value)) diff --git a/apps/application/flow/compare/wildcard_compare.py b/apps/application/flow/compare/wildcard_compare.py index 65ea2c74a5a..363cb33bf13 100644 --- a/apps/application/flow/compare/wildcard_compare.py +++ b/apps/application/flow/compare/wildcard_compare.py @@ -33,10 +33,6 @@ def translate_and_compile_and_cache(wildcard): class WildcardCompare(Compare): - def support(self, node_id, fields: List[str], source_value, compare, target_value): - if compare == 'wildcard': - return True - def compare(self, source_value, compare, target_value): # 转成正则,性能更高 match = translate_and_compile_and_cache(str(target_value)) diff --git a/apps/application/flow/step_node/condition_node/impl/base_condition_node.py b/apps/application/flow/step_node/condition_node/impl/base_condition_node.py index 7e5a5e28e35..6e126e27b21 100644 --- a/apps/application/flow/step_node/condition_node/impl/base_condition_node.py +++ b/apps/application/flow/step_node/condition_node/impl/base_condition_node.py @@ -9,7 +9,7 @@ from typing import List from application.flow.i_step_node import NodeResult -from application.flow.compare import compare_handle_list +from application.flow.compare import do_assertion from application.flow.step_node.condition_node.i_condition_node import IConditionNode @@ -37,18 +37,7 @@ def branch_assertion(self, branch): return all(condition_list) if condition == 'and' else any(condition_list) def assertion(self, field_list: List[str], compare: str, value): - try: - value = self.workflow_manage.generate_prompt(value) - except Exception as e: - pass - field_value = None - try: - field_value = self.workflow_manage.get_reference_field(field_list[0], field_list[1:]) - except Exception as e: - pass - for compare_handler in compare_handle_list: - if compare_handler.support(field_list[0], field_list[1:], field_value, compare, value): - return compare_handler.compare(field_value, compare, value) + return do_assertion(self.workflow_manage, field_list, compare, value) def get_details(self, index: int, **kwargs): return { diff --git a/apps/application/flow/step_node/loop_break_node/impl/base_loop_break_node.py b/apps/application/flow/step_node/loop_break_node/impl/base_loop_break_node.py index e5e030e75d0..6e98cfa51ff 100644 --- a/apps/application/flow/step_node/loop_break_node/impl/base_loop_break_node.py +++ b/apps/application/flow/step_node/loop_break_node/impl/base_loop_break_node.py @@ -9,7 +9,7 @@ import time from typing import List, Dict -from application.flow.compare import compare_handle_list +from application.flow.compare import do_assertion from application.flow.i_step_node import NodeResult from application.flow.step_node.loop_break_node.i_loop_break_node import ILoopBreakNode @@ -37,18 +37,7 @@ def execute(self, condition, condition_list, **kwargs) -> NodeResult: _is_interrupt=lambda n, v, w: is_break) def assertion(self, field_list: List[str], compare: str, value): - try: - value = self.workflow_manage.generate_prompt(value) - except Exception as e: - pass - field_value = None - try: - field_value = self.workflow_manage.get_reference_field(field_list[0], field_list[1:]) - except Exception as e: - pass - for compare_handler in compare_handle_list: - if compare_handler.support(field_list[0], field_list[1:], field_value, compare, value): - return compare_handler.compare(field_value, compare, value) + return do_assertion(self.workflow_manage, field_list, compare, value) def get_details(self, index: int, **kwargs): return { diff --git a/apps/application/flow/step_node/loop_continue_node/impl/base_loop_continue_node.py b/apps/application/flow/step_node/loop_continue_node/impl/base_loop_continue_node.py index d3ee6de636e..8813cf12507 100644 --- a/apps/application/flow/step_node/loop_continue_node/impl/base_loop_continue_node.py +++ b/apps/application/flow/step_node/loop_continue_node/impl/base_loop_continue_node.py @@ -8,7 +8,7 @@ """ from typing import List -from application.flow.compare import compare_handle_list +from application.flow.compare import do_assertion from application.flow.i_step_node import NodeResult from application.flow.step_node.loop_continue_node.i_loop_continue_node import ILoopContinueNode @@ -27,18 +27,7 @@ def execute(self, condition, condition_list, **kwargs) -> NodeResult: return NodeResult({'is_continue': is_continue}, {}) def assertion(self, field_list: List[str], compare: str, value): - try: - value = self.workflow_manage.generate_prompt(value) - except Exception as e: - pass - field_value = None - try: - field_value = self.workflow_manage.get_reference_field(field_list[0], field_list[1:]) - except Exception as e: - pass - for compare_handler in compare_handle_list: - if compare_handler.support(field_list[0], field_list[1:], field_value, compare, value): - return compare_handler.compare(field_value, compare, value) + return do_assertion(self.workflow_manage, field_list, compare, value) def get_details(self, index: int, **kwargs): return { diff --git a/ui/src/workflow/common/data.ts b/ui/src/workflow/common/data.ts index 8512f3e2ddf..a726ae9ed5a 100644 --- a/ui/src/workflow/common/data.ts +++ b/ui/src/workflow/common/data.ts @@ -1135,8 +1135,8 @@ export const compareList = [ {value: 'is_not_true', label: t('workflow.compare.is_not_true')}, {value: 'start_with', label: 'startWith'}, {value: 'end_with', label: 'endWith'}, - { value: 'regex', label: t('workflow.compare.regex') }, - { value: 'wildcard', label: t('workflow.compare.wildcard') }, + {value: 'regex', label: t('workflow.compare.regex')}, + {value: 'wildcard', label: t('workflow.compare.wildcard')}, ] export const nodeDict: any = { [WorkflowType.AiChat]: aiChatNode, From e2fe120fb3ea4e641524ffed590e83ca0c3aeb85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E8=89=AF?= <841369634@qq.com> Date: Tue, 28 Apr 2026 17:50:36 +0800 Subject: [PATCH 02/16] =?UTF-8?q?perf:=20=E9=81=BF=E5=85=8D=20`=E5=88=A4?= =?UTF-8?q?=E6=96=AD=E5=99=A8`=20=E6=89=A7=E8=A1=8C=E6=89=80=E6=9C=89?= =?UTF-8?q?=E6=9D=A1=E4=BB=B6=E5=88=86=E6=94=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/application/flow/compare/__init__.py | 14 +++++++++++--- .../condition_node/impl/base_condition_node.py | 8 +------- .../loop_break_node/impl/base_loop_break_node.py | 7 +------ .../impl/base_loop_continue_node.py | 7 +------ 4 files changed, 14 insertions(+), 22 deletions(-) diff --git a/apps/application/flow/compare/__init__.py b/apps/application/flow/compare/__init__.py index c676754495f..b2daa117e6a 100644 --- a/apps/application/flow/compare/__init__.py +++ b/apps/application/flow/compare/__init__.py @@ -54,14 +54,14 @@ } -def _do_compare(source_value, compare, target_value): +def _compare(source_value, compare, target_value): compare_handle = _compare_handle_dict.get(compare) if compare_handle: return compare_handle.compare(source_value, compare, target_value) return False -def do_assertion(workflow_manage, field_list: List[str], compare: str, value): +def _assertion(workflow_manage, field_list: List[str], compare: str, value): try: value = workflow_manage.generate_prompt(value) except Exception: @@ -71,4 +71,12 @@ def do_assertion(workflow_manage, field_list: List[str], compare: str, value): field_value = workflow_manage.get_reference_field(field_list[0], field_list[1:]) except Exception: pass - return _do_compare(field_value, compare, value) + return _compare(field_value, compare, value) + + +def do_assertion(workflow_manage, condition, condition_list): + b = False if condition == 'and' else True + for row in condition_list: + if _assertion(workflow_manage, row.get('field'), row.get('compare'), row.get('value')) is b: + return b + return not b diff --git a/apps/application/flow/step_node/condition_node/impl/base_condition_node.py b/apps/application/flow/step_node/condition_node/impl/base_condition_node.py index 6e126e27b21..e0da03ace4c 100644 --- a/apps/application/flow/step_node/condition_node/impl/base_condition_node.py +++ b/apps/application/flow/step_node/condition_node/impl/base_condition_node.py @@ -31,13 +31,7 @@ def _execute(self, branch_list: List): return branch def branch_assertion(self, branch): - condition_list = [self.assertion(row.get('field'), row.get('compare'), row.get('value')) for row in - branch.get('conditions')] - condition = branch.get('condition') - return all(condition_list) if condition == 'and' else any(condition_list) - - def assertion(self, field_list: List[str], compare: str, value): - return do_assertion(self.workflow_manage, field_list, compare, value) + return do_assertion(self.workflow_manage, branch.get('condition'), branch.get('conditions')) def get_details(self, index: int, **kwargs): return { diff --git a/apps/application/flow/step_node/loop_break_node/impl/base_loop_break_node.py b/apps/application/flow/step_node/loop_break_node/impl/base_loop_break_node.py index 6e98cfa51ff..0dd15071a37 100644 --- a/apps/application/flow/step_node/loop_break_node/impl/base_loop_break_node.py +++ b/apps/application/flow/step_node/loop_break_node/impl/base_loop_break_node.py @@ -26,9 +26,7 @@ def save_context(self, details, workflow_manage): self.context['exception_message'] = details.get('err_message') def execute(self, condition, condition_list, **kwargs) -> NodeResult: - r = [self.assertion(row.get('field'), row.get('compare'), row.get('value')) for row in - condition_list] - is_break = all(r) if condition == 'and' else any(r) + is_break = do_assertion(self.workflow_manage, condition, condition_list) if is_break: self.node_params['is_result'] = True self.context['is_break'] = is_break @@ -36,9 +34,6 @@ def execute(self, condition, condition_list, **kwargs) -> NodeResult: _write_context=_write_context, _is_interrupt=lambda n, v, w: is_break) - def assertion(self, field_list: List[str], compare: str, value): - return do_assertion(self.workflow_manage, field_list, compare, value) - def get_details(self, index: int, **kwargs): return { 'name': self.node.properties.get('stepName'), diff --git a/apps/application/flow/step_node/loop_continue_node/impl/base_loop_continue_node.py b/apps/application/flow/step_node/loop_continue_node/impl/base_loop_continue_node.py index 8813cf12507..eb7b6fad144 100644 --- a/apps/application/flow/step_node/loop_continue_node/impl/base_loop_continue_node.py +++ b/apps/application/flow/step_node/loop_continue_node/impl/base_loop_continue_node.py @@ -18,17 +18,12 @@ def save_context(self, details, workflow_manage): self.context['exception_message'] = details.get('err_message') def execute(self, condition, condition_list, **kwargs) -> NodeResult: - condition_list = [self.assertion(row.get('field'), row.get('compare'), row.get('value')) for row in - condition_list] - is_continue = all(condition_list) if condition == 'and' else any(condition_list) + is_continue = do_assertion(self.workflow_manage, condition, condition_list) self.context['is_continue'] = is_continue if is_continue: return NodeResult({'is_continue': is_continue, 'branch_id': 'continue'}, {}) return NodeResult({'is_continue': is_continue}, {}) - def assertion(self, field_list: List[str], compare: str, value): - return do_assertion(self.workflow_manage, field_list, compare, value) - def get_details(self, index: int, **kwargs): return { 'name': self.node.properties.get('stepName'), From ee96680c2988910bb804a0f6c2a98bc63f621845 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E8=89=AF?= <841369634@qq.com> Date: Tue, 28 Apr 2026 17:57:44 +0800 Subject: [PATCH 03/16] =?UTF-8?q?perf:=20=E5=88=A4=E6=96=AD=E5=99=A8?= =?UTF-8?q?=EF=BC=8C=E6=B7=BB=E5=8A=A0=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/application/flow/compare/__init__.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/apps/application/flow/compare/__init__.py b/apps/application/flow/compare/__init__.py index b2daa117e6a..5d0b062ebda 100644 --- a/apps/application/flow/compare/__init__.py +++ b/apps/application/flow/compare/__init__.py @@ -7,6 +7,8 @@ @desc: """ +from common.utils.logger import maxkb_logger + from .contain_compare import * from .end_with import EndWithCompare from .equal_compare import * @@ -29,7 +31,7 @@ from .start_with import StartWithCompare from .wildcard_compare import WildcardCompare -_compare_handle_dict = { +_compare_handler_dict = { 'is_null': IsNullCompare(), 'is_not_null': IsNotNullCompare(), 'contain': ContainCompare(), @@ -55,10 +57,10 @@ def _compare(source_value, compare, target_value): - compare_handle = _compare_handle_dict.get(compare) - if compare_handle: - return compare_handle.compare(source_value, compare, target_value) - return False + compare_handler = _compare_handler_dict.get(compare) + if compare_handler is None: + raise RuntimeError(f"Unknown compare handler '{compare}'") + return compare_handler.compare(source_value, compare, target_value) def _assertion(workflow_manage, field_list: List[str], compare: str, value): From a41a3799b46431a1e61e83ef7cd9034e27e7c317 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E8=89=AF?= <841369634@qq.com> Date: Tue, 28 Apr 2026 18:08:51 +0800 Subject: [PATCH 04/16] =?UTF-8?q?=E5=B0=8F=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/application/flow/compare/__init__.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/apps/application/flow/compare/__init__.py b/apps/application/flow/compare/__init__.py index 5d0b062ebda..d3153ccb2cf 100644 --- a/apps/application/flow/compare/__init__.py +++ b/apps/application/flow/compare/__init__.py @@ -7,8 +7,6 @@ @desc: """ -from common.utils.logger import maxkb_logger - from .contain_compare import * from .end_with import EndWithCompare from .equal_compare import * From 71cff93c912f388bf0ae3d521feae41d6c6f0ff9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E8=89=AF?= <841369634@qq.com> Date: Tue, 28 Apr 2026 19:18:25 +0800 Subject: [PATCH 05/16] =?UTF-8?q?=E5=B0=8F=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/application/flow/compare/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/application/flow/compare/__init__.py b/apps/application/flow/compare/__init__.py index d3153ccb2cf..e5599fc0a63 100644 --- a/apps/application/flow/compare/__init__.py +++ b/apps/application/flow/compare/__init__.py @@ -38,8 +38,8 @@ 'not_eq': NotEqualCompare(), 'ge': GECompare(), 'gt': GTCompare(), - 'lt': LTCompare(), 'le': LECompare(), + 'lt': LTCompare(), 'len_eq': LenEqualCompare(), 'len_ge': LenGECompare(), 'len_gt': LenGTCompare(), From 7e357b7fd290bfc1e31e7c8697c0807d5ae99e68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E8=89=AF?= <841369634@qq.com> Date: Tue, 28 Apr 2026 20:18:44 +0800 Subject: [PATCH 06/16] clean import --- apps/application/flow/compare/compare.py | 2 -- apps/application/flow/compare/contain_compare.py | 2 -- apps/application/flow/compare/end_with.py | 2 -- apps/application/flow/compare/equal_compare.py | 2 -- apps/application/flow/compare/ge_compare.py | 2 -- apps/application/flow/compare/gt_compare.py | 2 -- apps/application/flow/compare/is_not_null_compare.py | 2 -- apps/application/flow/compare/is_not_true.py | 2 -- apps/application/flow/compare/is_null_compare.py | 2 -- apps/application/flow/compare/is_true.py | 2 -- apps/application/flow/compare/le_compare.py | 2 -- apps/application/flow/compare/len_equal_compare.py | 2 -- apps/application/flow/compare/len_ge_compare.py | 2 -- apps/application/flow/compare/len_gt_compare.py | 2 -- apps/application/flow/compare/len_le_compare.py | 2 -- apps/application/flow/compare/len_lt_compare.py | 2 -- apps/application/flow/compare/lt_compare.py | 2 -- apps/application/flow/compare/not_contain_compare.py | 2 -- apps/application/flow/compare/not_equal_compare.py | 2 -- apps/application/flow/compare/regex_compare.py | 1 - apps/application/flow/compare/start_with.py | 2 -- apps/application/flow/compare/wildcard_compare.py | 1 - 22 files changed, 42 deletions(-) diff --git a/apps/application/flow/compare/compare.py b/apps/application/flow/compare/compare.py index c91f076ed46..62eb4a7b910 100644 --- a/apps/application/flow/compare/compare.py +++ b/apps/application/flow/compare/compare.py @@ -7,8 +7,6 @@ @desc: """ from abc import abstractmethod -from typing import List - class Compare: diff --git a/apps/application/flow/compare/contain_compare.py b/apps/application/flow/compare/contain_compare.py index 7f453965599..a1c9215c4f7 100644 --- a/apps/application/flow/compare/contain_compare.py +++ b/apps/application/flow/compare/contain_compare.py @@ -6,8 +6,6 @@ @date:2024/6/11 10:02 @desc: """ -from typing import List - from application.flow.compare.compare import Compare diff --git a/apps/application/flow/compare/end_with.py b/apps/application/flow/compare/end_with.py index 9157c0beff0..b6ac45e6cb7 100644 --- a/apps/application/flow/compare/end_with.py +++ b/apps/application/flow/compare/end_with.py @@ -6,8 +6,6 @@ @date:2025/10/20 10:37 @desc: """ -from typing import List - from application.flow.compare import Compare diff --git a/apps/application/flow/compare/equal_compare.py b/apps/application/flow/compare/equal_compare.py index 7a879d58149..cb62215ec61 100644 --- a/apps/application/flow/compare/equal_compare.py +++ b/apps/application/flow/compare/equal_compare.py @@ -6,8 +6,6 @@ @date:2024/6/7 14:44 @desc: """ -from typing import List - from application.flow.compare import Compare diff --git a/apps/application/flow/compare/ge_compare.py b/apps/application/flow/compare/ge_compare.py index 75b9574a9c0..8ea93b8c3d7 100644 --- a/apps/application/flow/compare/ge_compare.py +++ b/apps/application/flow/compare/ge_compare.py @@ -6,8 +6,6 @@ @date:2024/6/11 9:52 @desc: 大于比较器 """ -from typing import List - from application.flow.compare import Compare diff --git a/apps/application/flow/compare/gt_compare.py b/apps/application/flow/compare/gt_compare.py index 773771b913a..0c280fee941 100644 --- a/apps/application/flow/compare/gt_compare.py +++ b/apps/application/flow/compare/gt_compare.py @@ -6,8 +6,6 @@ @date:2024/6/11 9:52 @desc: 大于比较器 """ -from typing import List - from application.flow.compare import Compare diff --git a/apps/application/flow/compare/is_not_null_compare.py b/apps/application/flow/compare/is_not_null_compare.py index 1b5a97f8b20..78bf653e000 100644 --- a/apps/application/flow/compare/is_not_null_compare.py +++ b/apps/application/flow/compare/is_not_null_compare.py @@ -6,8 +6,6 @@ @date:2024/6/28 10:45 @desc: """ -from typing import List - from application.flow.compare import Compare diff --git a/apps/application/flow/compare/is_not_true.py b/apps/application/flow/compare/is_not_true.py index 07eda98a2ee..61a90825c06 100644 --- a/apps/application/flow/compare/is_not_true.py +++ b/apps/application/flow/compare/is_not_true.py @@ -6,8 +6,6 @@ @date:2025/4/7 13:44 @desc: """ -from typing import List - from application.flow.compare import Compare diff --git a/apps/application/flow/compare/is_null_compare.py b/apps/application/flow/compare/is_null_compare.py index d971d08dc7e..1bc11189013 100644 --- a/apps/application/flow/compare/is_null_compare.py +++ b/apps/application/flow/compare/is_null_compare.py @@ -6,8 +6,6 @@ @date:2024/6/28 10:45 @desc: """ -from typing import List - from application.flow.compare import Compare diff --git a/apps/application/flow/compare/is_true.py b/apps/application/flow/compare/is_true.py index 1eee0e1227f..2854bbb2a25 100644 --- a/apps/application/flow/compare/is_true.py +++ b/apps/application/flow/compare/is_true.py @@ -6,8 +6,6 @@ @date:2025/4/7 13:38 @desc: """ -from typing import List - from application.flow.compare import Compare diff --git a/apps/application/flow/compare/le_compare.py b/apps/application/flow/compare/le_compare.py index cf167ea2253..76edeb88006 100644 --- a/apps/application/flow/compare/le_compare.py +++ b/apps/application/flow/compare/le_compare.py @@ -6,8 +6,6 @@ @date:2024/6/11 9:52 @desc: 小于比较器 """ -from typing import List - from application.flow.compare import Compare diff --git a/apps/application/flow/compare/len_equal_compare.py b/apps/application/flow/compare/len_equal_compare.py index ea87823d4b0..fad4b13fd7d 100644 --- a/apps/application/flow/compare/len_equal_compare.py +++ b/apps/application/flow/compare/len_equal_compare.py @@ -6,8 +6,6 @@ @date:2024/6/7 14:44 @desc: """ -from typing import List - from application.flow.compare import Compare diff --git a/apps/application/flow/compare/len_ge_compare.py b/apps/application/flow/compare/len_ge_compare.py index cb289eb1499..b6468449303 100644 --- a/apps/application/flow/compare/len_ge_compare.py +++ b/apps/application/flow/compare/len_ge_compare.py @@ -6,8 +6,6 @@ @date:2024/6/11 9:52 @desc: 大于比较器 """ -from typing import List - from application.flow.compare import Compare diff --git a/apps/application/flow/compare/len_gt_compare.py b/apps/application/flow/compare/len_gt_compare.py index 78e67173ed4..a732dc397d4 100644 --- a/apps/application/flow/compare/len_gt_compare.py +++ b/apps/application/flow/compare/len_gt_compare.py @@ -6,8 +6,6 @@ @date:2024/6/11 9:52 @desc: 大于比较器 """ -from typing import List - from application.flow.compare import Compare diff --git a/apps/application/flow/compare/len_le_compare.py b/apps/application/flow/compare/len_le_compare.py index 3ca856df2d1..8fa0d421c1b 100644 --- a/apps/application/flow/compare/len_le_compare.py +++ b/apps/application/flow/compare/len_le_compare.py @@ -6,8 +6,6 @@ @date:2024/6/11 9:52 @desc: 小于比较器 """ -from typing import List - from application.flow.compare import Compare diff --git a/apps/application/flow/compare/len_lt_compare.py b/apps/application/flow/compare/len_lt_compare.py index ae913d7548a..37d973bc357 100644 --- a/apps/application/flow/compare/len_lt_compare.py +++ b/apps/application/flow/compare/len_lt_compare.py @@ -6,8 +6,6 @@ @date:2024/6/11 9:52 @desc: 小于比较器 """ -from typing import List - from application.flow.compare import Compare diff --git a/apps/application/flow/compare/lt_compare.py b/apps/application/flow/compare/lt_compare.py index 7c87876835f..706708c6be7 100644 --- a/apps/application/flow/compare/lt_compare.py +++ b/apps/application/flow/compare/lt_compare.py @@ -6,8 +6,6 @@ @date:2024/6/11 9:52 @desc: 小于比较器 """ -from typing import List - from application.flow.compare import Compare diff --git a/apps/application/flow/compare/not_contain_compare.py b/apps/application/flow/compare/not_contain_compare.py index 3ddadb88048..b68dfff4ca7 100644 --- a/apps/application/flow/compare/not_contain_compare.py +++ b/apps/application/flow/compare/not_contain_compare.py @@ -6,8 +6,6 @@ @date:2024/6/11 10:02 @desc: """ -from typing import List - from application.flow.compare import Compare diff --git a/apps/application/flow/compare/not_equal_compare.py b/apps/application/flow/compare/not_equal_compare.py index 0118c80e29f..ee53168e2b4 100644 --- a/apps/application/flow/compare/not_equal_compare.py +++ b/apps/application/flow/compare/not_equal_compare.py @@ -6,8 +6,6 @@ @date:2026/3/17 9:41 @desc: """ -from typing import List - from application.flow.compare import Compare diff --git a/apps/application/flow/compare/regex_compare.py b/apps/application/flow/compare/regex_compare.py index 3097b2acea9..d929b3d75e0 100644 --- a/apps/application/flow/compare/regex_compare.py +++ b/apps/application/flow/compare/regex_compare.py @@ -7,7 +7,6 @@ @desc: """ import re -from typing import List from application.flow.compare import Compare from common.cache.mem_cache import MemCache diff --git a/apps/application/flow/compare/start_with.py b/apps/application/flow/compare/start_with.py index ccfc28fcdce..ed03da86977 100644 --- a/apps/application/flow/compare/start_with.py +++ b/apps/application/flow/compare/start_with.py @@ -6,8 +6,6 @@ @date:2025/10/20 10:37 @desc: """ -from typing import List - from application.flow.compare import Compare diff --git a/apps/application/flow/compare/wildcard_compare.py b/apps/application/flow/compare/wildcard_compare.py index 363cb33bf13..700671770ef 100644 --- a/apps/application/flow/compare/wildcard_compare.py +++ b/apps/application/flow/compare/wildcard_compare.py @@ -8,7 +8,6 @@ """ import fnmatch import re -from typing import List from application.flow.compare import Compare from common.cache.mem_cache import MemCache From 1eab9c06adfe9ef4bd6e3a43af8d5e372b58c0cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E8=89=AF?= <841369634@qq.com> Date: Wed, 29 Apr 2026 14:33:05 +0800 Subject: [PATCH 07/16] clean import --- apps/application/flow/compare/__init__.py | 30 +++++++++---------- .../flow/compare/contain_compare.py | 2 +- apps/application/flow/compare/end_with.py | 2 +- .../application/flow/compare/equal_compare.py | 2 +- apps/application/flow/compare/ge_compare.py | 6 ++-- apps/application/flow/compare/gt_compare.py | 6 ++-- .../flow/compare/is_not_null_compare.py | 2 +- apps/application/flow/compare/is_not_true.py | 4 +-- .../flow/compare/is_null_compare.py | 4 +-- apps/application/flow/compare/is_true.py | 4 +-- apps/application/flow/compare/le_compare.py | 6 ++-- .../flow/compare/len_equal_compare.py | 2 +- .../flow/compare/len_ge_compare.py | 4 +-- .../flow/compare/len_gt_compare.py | 4 +-- .../flow/compare/len_le_compare.py | 4 +-- .../flow/compare/len_lt_compare.py | 4 +-- apps/application/flow/compare/lt_compare.py | 6 ++-- .../flow/compare/not_contain_compare.py | 2 +- .../flow/compare/not_equal_compare.py | 2 +- .../application/flow/compare/regex_compare.py | 2 +- apps/application/flow/compare/start_with.py | 2 +- .../flow/compare/wildcard_compare.py | 2 +- 22 files changed, 51 insertions(+), 51 deletions(-) diff --git a/apps/application/flow/compare/__init__.py b/apps/application/flow/compare/__init__.py index e5599fc0a63..e9e6df17195 100644 --- a/apps/application/flow/compare/__init__.py +++ b/apps/application/flow/compare/__init__.py @@ -7,24 +7,24 @@ @desc: """ -from .contain_compare import * +from .contain_compare import ContainCompare from .end_with import EndWithCompare -from .equal_compare import * -from .ge_compare import * -from .gt_compare import * -from .is_not_null_compare import * +from .equal_compare import EqualCompare +from .ge_compare import GECompare +from .gt_compare import GTCompare +from .is_not_null_compare import IsNotNullCompare from .is_not_true import IsNotTrueCompare -from .is_null_compare import * +from .is_null_compare import IsNullCompare from .is_true import IsTrueCompare -from .le_compare import * -from .len_equal_compare import * -from .len_ge_compare import * -from .len_gt_compare import * -from .len_le_compare import * -from .len_lt_compare import * -from .lt_compare import * -from .not_contain_compare import * -from .not_equal_compare import * +from .le_compare import LECompare +from .len_equal_compare import LenEqualCompare +from .len_ge_compare import LenGECompare +from .len_gt_compare import LenGTCompare +from .len_le_compare import LenLECompare +from .len_lt_compare import LenLTCompare +from .lt_compare import LTCompare +from .not_contain_compare import NotContainCompare +from .not_equal_compare import NotEqualCompare from .regex_compare import RegexCompare from .start_with import StartWithCompare from .wildcard_compare import WildcardCompare diff --git a/apps/application/flow/compare/contain_compare.py b/apps/application/flow/compare/contain_compare.py index a1c9215c4f7..cd50d543a3a 100644 --- a/apps/application/flow/compare/contain_compare.py +++ b/apps/application/flow/compare/contain_compare.py @@ -6,7 +6,7 @@ @date:2024/6/11 10:02 @desc: """ -from application.flow.compare.compare import Compare +from .compare import Compare class ContainCompare(Compare): diff --git a/apps/application/flow/compare/end_with.py b/apps/application/flow/compare/end_with.py index b6ac45e6cb7..eae7e3a8a15 100644 --- a/apps/application/flow/compare/end_with.py +++ b/apps/application/flow/compare/end_with.py @@ -6,7 +6,7 @@ @date:2025/10/20 10:37 @desc: """ -from application.flow.compare import Compare +from .compare import Compare class EndWithCompare(Compare): diff --git a/apps/application/flow/compare/equal_compare.py b/apps/application/flow/compare/equal_compare.py index cb62215ec61..dad0cffa9fa 100644 --- a/apps/application/flow/compare/equal_compare.py +++ b/apps/application/flow/compare/equal_compare.py @@ -6,7 +6,7 @@ @date:2024/6/7 14:44 @desc: """ -from application.flow.compare import Compare +from .compare import Compare class EqualCompare(Compare): diff --git a/apps/application/flow/compare/ge_compare.py b/apps/application/flow/compare/ge_compare.py index 8ea93b8c3d7..bd85d0c3c52 100644 --- a/apps/application/flow/compare/ge_compare.py +++ b/apps/application/flow/compare/ge_compare.py @@ -6,7 +6,7 @@ @date:2024/6/11 9:52 @desc: 大于比较器 """ -from application.flow.compare import Compare +from .compare import Compare class GECompare(Compare): @@ -14,9 +14,9 @@ class GECompare(Compare): def compare(self, source_value, compare, target_value): try: return float(source_value) >= float(target_value) - except Exception as e: + except Exception: try: return str(source_value) >= str(target_value) - except Exception as _: + except Exception: pass return False diff --git a/apps/application/flow/compare/gt_compare.py b/apps/application/flow/compare/gt_compare.py index 0c280fee941..c83a1e765e0 100644 --- a/apps/application/flow/compare/gt_compare.py +++ b/apps/application/flow/compare/gt_compare.py @@ -6,7 +6,7 @@ @date:2024/6/11 9:52 @desc: 大于比较器 """ -from application.flow.compare import Compare +from .compare import Compare class GTCompare(Compare): @@ -14,9 +14,9 @@ class GTCompare(Compare): def compare(self, source_value, compare, target_value): try: return float(source_value) > float(target_value) - except Exception as e: + except Exception: try: return str(source_value) > str(target_value) - except Exception as _: + except Exception: pass return False diff --git a/apps/application/flow/compare/is_not_null_compare.py b/apps/application/flow/compare/is_not_null_compare.py index 78bf653e000..37fd4a72ea4 100644 --- a/apps/application/flow/compare/is_not_null_compare.py +++ b/apps/application/flow/compare/is_not_null_compare.py @@ -6,7 +6,7 @@ @date:2024/6/28 10:45 @desc: """ -from application.flow.compare import Compare +from .compare import Compare class IsNotNullCompare(Compare): diff --git a/apps/application/flow/compare/is_not_true.py b/apps/application/flow/compare/is_not_true.py index 61a90825c06..fabeec2cc41 100644 --- a/apps/application/flow/compare/is_not_true.py +++ b/apps/application/flow/compare/is_not_true.py @@ -6,7 +6,7 @@ @date:2025/4/7 13:44 @desc: """ -from application.flow.compare import Compare +from .compare import Compare class IsNotTrueCompare(Compare): @@ -14,5 +14,5 @@ class IsNotTrueCompare(Compare): def compare(self, source_value, compare, target_value): try: return source_value is False - except Exception as e: + except Exception: return False diff --git a/apps/application/flow/compare/is_null_compare.py b/apps/application/flow/compare/is_null_compare.py index 1bc11189013..240403ea605 100644 --- a/apps/application/flow/compare/is_null_compare.py +++ b/apps/application/flow/compare/is_null_compare.py @@ -6,7 +6,7 @@ @date:2024/6/28 10:45 @desc: """ -from application.flow.compare import Compare +from .compare import Compare class IsNullCompare(Compare): @@ -14,5 +14,5 @@ class IsNullCompare(Compare): def compare(self, source_value, compare, target_value): try: return source_value is None or len(source_value) == 0 - except Exception as e: + except Exception: return False diff --git a/apps/application/flow/compare/is_true.py b/apps/application/flow/compare/is_true.py index 2854bbb2a25..8cb4a45a2a5 100644 --- a/apps/application/flow/compare/is_true.py +++ b/apps/application/flow/compare/is_true.py @@ -6,7 +6,7 @@ @date:2025/4/7 13:38 @desc: """ -from application.flow.compare import Compare +from .compare import Compare class IsTrueCompare(Compare): @@ -14,5 +14,5 @@ class IsTrueCompare(Compare): def compare(self, source_value, compare, target_value): try: return source_value is True - except Exception as e: + except Exception: return False diff --git a/apps/application/flow/compare/le_compare.py b/apps/application/flow/compare/le_compare.py index 76edeb88006..8b115d84b33 100644 --- a/apps/application/flow/compare/le_compare.py +++ b/apps/application/flow/compare/le_compare.py @@ -6,7 +6,7 @@ @date:2024/6/11 9:52 @desc: 小于比较器 """ -from application.flow.compare import Compare +from .compare import Compare class LECompare(Compare): @@ -14,9 +14,9 @@ class LECompare(Compare): def compare(self, source_value, compare, target_value): try: return float(source_value) <= float(target_value) - except Exception as e: + except Exception: try: return str(source_value) <= str(target_value) - except Exception as _: + except Exception: pass return False diff --git a/apps/application/flow/compare/len_equal_compare.py b/apps/application/flow/compare/len_equal_compare.py index fad4b13fd7d..98a5314a292 100644 --- a/apps/application/flow/compare/len_equal_compare.py +++ b/apps/application/flow/compare/len_equal_compare.py @@ -6,7 +6,7 @@ @date:2024/6/7 14:44 @desc: """ -from application.flow.compare import Compare +from .compare import Compare class LenEqualCompare(Compare): diff --git a/apps/application/flow/compare/len_ge_compare.py b/apps/application/flow/compare/len_ge_compare.py index b6468449303..06dd566cf24 100644 --- a/apps/application/flow/compare/len_ge_compare.py +++ b/apps/application/flow/compare/len_ge_compare.py @@ -6,7 +6,7 @@ @date:2024/6/11 9:52 @desc: 大于比较器 """ -from application.flow.compare import Compare +from .compare import Compare class LenGECompare(Compare): @@ -14,5 +14,5 @@ class LenGECompare(Compare): def compare(self, source_value, compare, target_value): try: return len(source_value) >= int(target_value) - except Exception as e: + except Exception: return False diff --git a/apps/application/flow/compare/len_gt_compare.py b/apps/application/flow/compare/len_gt_compare.py index a732dc397d4..fae2668e0ba 100644 --- a/apps/application/flow/compare/len_gt_compare.py +++ b/apps/application/flow/compare/len_gt_compare.py @@ -6,7 +6,7 @@ @date:2024/6/11 9:52 @desc: 大于比较器 """ -from application.flow.compare import Compare +from .compare import Compare class LenGTCompare(Compare): @@ -14,5 +14,5 @@ class LenGTCompare(Compare): def compare(self, source_value, compare, target_value): try: return len(source_value) > int(target_value) - except Exception as e: + except Exception: return False diff --git a/apps/application/flow/compare/len_le_compare.py b/apps/application/flow/compare/len_le_compare.py index 8fa0d421c1b..41b9ee9f709 100644 --- a/apps/application/flow/compare/len_le_compare.py +++ b/apps/application/flow/compare/len_le_compare.py @@ -6,7 +6,7 @@ @date:2024/6/11 9:52 @desc: 小于比较器 """ -from application.flow.compare import Compare +from .compare import Compare class LenLECompare(Compare): @@ -14,5 +14,5 @@ class LenLECompare(Compare): def compare(self, source_value, compare, target_value): try: return len(source_value) <= int(target_value) - except Exception as e: + except Exception: return False diff --git a/apps/application/flow/compare/len_lt_compare.py b/apps/application/flow/compare/len_lt_compare.py index 37d973bc357..4a9b11654ca 100644 --- a/apps/application/flow/compare/len_lt_compare.py +++ b/apps/application/flow/compare/len_lt_compare.py @@ -6,7 +6,7 @@ @date:2024/6/11 9:52 @desc: 小于比较器 """ -from application.flow.compare import Compare +from .compare import Compare class LenLTCompare(Compare): @@ -14,5 +14,5 @@ class LenLTCompare(Compare): def compare(self, source_value, compare, target_value): try: return len(source_value) < int(target_value) - except Exception as e: + except Exception: return False diff --git a/apps/application/flow/compare/lt_compare.py b/apps/application/flow/compare/lt_compare.py index 706708c6be7..6720af7f17a 100644 --- a/apps/application/flow/compare/lt_compare.py +++ b/apps/application/flow/compare/lt_compare.py @@ -6,7 +6,7 @@ @date:2024/6/11 9:52 @desc: 小于比较器 """ -from application.flow.compare import Compare +from .compare import Compare class LTCompare(Compare): @@ -14,9 +14,9 @@ class LTCompare(Compare): def compare(self, source_value, compare, target_value): try: return float(source_value) < float(target_value) - except Exception as e: + except Exception: try: return str(source_value) < str(target_value) - except Exception as _: + except Exception: pass return False diff --git a/apps/application/flow/compare/not_contain_compare.py b/apps/application/flow/compare/not_contain_compare.py index b68dfff4ca7..99194e70364 100644 --- a/apps/application/flow/compare/not_contain_compare.py +++ b/apps/application/flow/compare/not_contain_compare.py @@ -6,7 +6,7 @@ @date:2024/6/11 10:02 @desc: """ -from application.flow.compare import Compare +from .compare import Compare class NotContainCompare(Compare): diff --git a/apps/application/flow/compare/not_equal_compare.py b/apps/application/flow/compare/not_equal_compare.py index ee53168e2b4..f53057ebfa9 100644 --- a/apps/application/flow/compare/not_equal_compare.py +++ b/apps/application/flow/compare/not_equal_compare.py @@ -6,7 +6,7 @@ @date:2026/3/17 9:41 @desc: """ -from application.flow.compare import Compare +from .compare import Compare class NotEqualCompare(Compare): diff --git a/apps/application/flow/compare/regex_compare.py b/apps/application/flow/compare/regex_compare.py index d929b3d75e0..eeb76a5256e 100644 --- a/apps/application/flow/compare/regex_compare.py +++ b/apps/application/flow/compare/regex_compare.py @@ -8,7 +8,7 @@ """ import re -from application.flow.compare import Compare +from .compare import Compare from common.cache.mem_cache import MemCache diff --git a/apps/application/flow/compare/start_with.py b/apps/application/flow/compare/start_with.py index ed03da86977..054ea9bd6cb 100644 --- a/apps/application/flow/compare/start_with.py +++ b/apps/application/flow/compare/start_with.py @@ -6,7 +6,7 @@ @date:2025/10/20 10:37 @desc: """ -from application.flow.compare import Compare +from .compare import Compare class StartWithCompare(Compare): diff --git a/apps/application/flow/compare/wildcard_compare.py b/apps/application/flow/compare/wildcard_compare.py index 700671770ef..43c903a9360 100644 --- a/apps/application/flow/compare/wildcard_compare.py +++ b/apps/application/flow/compare/wildcard_compare.py @@ -9,7 +9,7 @@ import fnmatch import re -from application.flow.compare import Compare +from .compare import Compare from common.cache.mem_cache import MemCache From 96cde90b9f434de3f381e455c1148b2380f8468e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E8=89=AF?= <841369634@qq.com> Date: Wed, 29 Apr 2026 14:33:15 +0800 Subject: [PATCH 08/16] clean import --- .../flow/step_node/loop_break_node/impl/base_loop_break_node.py | 2 +- .../loop_continue_node/impl/base_loop_continue_node.py | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/apps/application/flow/step_node/loop_break_node/impl/base_loop_break_node.py b/apps/application/flow/step_node/loop_break_node/impl/base_loop_break_node.py index 0dd15071a37..f82289729da 100644 --- a/apps/application/flow/step_node/loop_break_node/impl/base_loop_break_node.py +++ b/apps/application/flow/step_node/loop_break_node/impl/base_loop_break_node.py @@ -7,7 +7,7 @@ @desc: """ import time -from typing import List, Dict +from typing import Dict from application.flow.compare import do_assertion from application.flow.i_step_node import NodeResult diff --git a/apps/application/flow/step_node/loop_continue_node/impl/base_loop_continue_node.py b/apps/application/flow/step_node/loop_continue_node/impl/base_loop_continue_node.py index eb7b6fad144..3c0393217c5 100644 --- a/apps/application/flow/step_node/loop_continue_node/impl/base_loop_continue_node.py +++ b/apps/application/flow/step_node/loop_continue_node/impl/base_loop_continue_node.py @@ -6,8 +6,6 @@ @date:2025/9/15 12:13 @desc: """ -from typing import List - from application.flow.compare import do_assertion from application.flow.i_step_node import NodeResult from application.flow.step_node.loop_continue_node.i_loop_continue_node import ILoopContinueNode From eefae5497b8559c0c5aceebdf63e7c1be347d9bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E8=89=AF?= <841369634@qq.com> Date: Wed, 29 Apr 2026 14:44:04 +0800 Subject: [PATCH 09/16] add import --- apps/application/flow/compare/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/application/flow/compare/__init__.py b/apps/application/flow/compare/__init__.py index e9e6df17195..ce0c430e1ad 100644 --- a/apps/application/flow/compare/__init__.py +++ b/apps/application/flow/compare/__init__.py @@ -6,6 +6,7 @@ @date:2024/6/7 14:43 @desc: """ +from typing import List from .contain_compare import ContainCompare from .end_with import EndWithCompare From a743744dc51bc8e5373cbcd302444d9334df088c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E8=89=AF?= <841369634@qq.com> Date: Wed, 29 Apr 2026 14:48:36 +0800 Subject: [PATCH 10/16] feat: support `len_not_eq` comparison --- apps/application/flow/compare/__init__.py | 2 ++ apps/application/flow/compare/is_not_true.py | 5 +---- .../flow/compare/len_equal_compare.py | 17 ++++++++++++--- .../flow/compare/len_not_equal_compare.py | 21 +++++++++++++++++++ .../flow/compare/not_contain_compare.py | 17 +++++---------- ui/src/locales/lang/en-US/workflow.ts | 1 + ui/src/locales/lang/zh-CN/workflow.ts | 1 + ui/src/locales/lang/zh-Hant/workflow.ts | 1 + ui/src/workflow/common/data.ts | 1 + 9 files changed, 47 insertions(+), 19 deletions(-) create mode 100644 apps/application/flow/compare/len_not_equal_compare.py diff --git a/apps/application/flow/compare/__init__.py b/apps/application/flow/compare/__init__.py index ce0c430e1ad..329b3e80286 100644 --- a/apps/application/flow/compare/__init__.py +++ b/apps/application/flow/compare/__init__.py @@ -23,6 +23,7 @@ from .len_gt_compare import LenGTCompare from .len_le_compare import LenLECompare from .len_lt_compare import LenLTCompare +from .len_not_equal_compare import LenNotEqualCompare from .lt_compare import LTCompare from .not_contain_compare import NotContainCompare from .not_equal_compare import NotEqualCompare @@ -42,6 +43,7 @@ 'le': LECompare(), 'lt': LTCompare(), 'len_eq': LenEqualCompare(), + 'len_not_eq': LenNotEqualCompare(), 'len_ge': LenGECompare(), 'len_gt': LenGTCompare(), 'len_le': LenLECompare(), diff --git a/apps/application/flow/compare/is_not_true.py b/apps/application/flow/compare/is_not_true.py index fabeec2cc41..43a42bbc726 100644 --- a/apps/application/flow/compare/is_not_true.py +++ b/apps/application/flow/compare/is_not_true.py @@ -12,7 +12,4 @@ class IsNotTrueCompare(Compare): def compare(self, source_value, compare, target_value): - try: - return source_value is False - except Exception: - return False + return source_value is False diff --git a/apps/application/flow/compare/len_equal_compare.py b/apps/application/flow/compare/len_equal_compare.py index 98a5314a292..f73cf5467ba 100644 --- a/apps/application/flow/compare/len_equal_compare.py +++ b/apps/application/flow/compare/len_equal_compare.py @@ -4,7 +4,7 @@ @Author:虎 @file: equal_compare.py @date:2024/6/7 14:44 - @desc: + @desc: 长度相等比较器 """ from .compare import Compare @@ -12,7 +12,18 @@ class LenEqualCompare(Compare): def compare(self, source_value, compare, target_value): + # 获取target_value的长度 try: - return len(source_value) == int(target_value) - except Exception as e: + target_length = int(target_value) + except Exception: return False + + # 获取source_value的长度 + try: + source_length = 0 if source_value is None else len(source_value) + except Exception: + # 可计算数字长度 + source_length = len(str(source_value)) + + # 长度等于比较 + return source_length == target_length diff --git a/apps/application/flow/compare/len_not_equal_compare.py b/apps/application/flow/compare/len_not_equal_compare.py new file mode 100644 index 00000000000..0c42cca1fa5 --- /dev/null +++ b/apps/application/flow/compare/len_not_equal_compare.py @@ -0,0 +1,21 @@ +# coding=utf-8 +""" + @project: maxkb + @Author:wangliang181230 + @file: equal_compare.py + @date:2026/4/28 20:17 + @desc: 长度不等于比较器 +""" +from .compare import Compare +from .len_equal_compare import LenEqualCompare + + +# 长度相等比较器 +lenEqualCompare = LenEqualCompare() + + +class LenNotEqualCompare(Compare): + + def compare(self, source_value, compare, target_value): + # 长度不等于比较 + return not lenEqualCompare.compare(source_value, compare, target_value) diff --git a/apps/application/flow/compare/not_contain_compare.py b/apps/application/flow/compare/not_contain_compare.py index 99194e70364..c0f98fd3a01 100644 --- a/apps/application/flow/compare/not_contain_compare.py +++ b/apps/application/flow/compare/not_contain_compare.py @@ -4,22 +4,15 @@ @Author:虎 @file: contain_compare.py @date:2024/6/11 10:02 - @desc: + @desc: 不包含比较器 """ from .compare import Compare +from .contain_compare import ContainCompare +# 包含比较器 +containCompare = ContainCompare() class NotContainCompare(Compare): def compare(self, source_value, compare, target_value): - target_value = str(target_value) - - if isinstance(source_value, str): - return target_value not in source_value - elif isinstance(source_value, list): - for item in source_value: - if str(item) == target_value: - return False - return True - else: - return target_value not in str(source_value) + return not containCompare.compare(source_value, compare, target_value) diff --git a/ui/src/locales/lang/en-US/workflow.ts b/ui/src/locales/lang/en-US/workflow.ts index beb02772c5a..25d34b92ad2 100644 --- a/ui/src/locales/lang/en-US/workflow.ts +++ b/ui/src/locales/lang/en-US/workflow.ts @@ -534,6 +534,7 @@ You are a master of problem optimization, adept at accurately inferring user int le: 'Less than or equal to', lt: 'Less than', len_eq: 'Length equal to', + len_not_eq: 'Length not equal to', len_ge: 'Length greater than or equal to', len_gt: 'Length greater than', len_le: 'Length less than or equal to', diff --git a/ui/src/locales/lang/zh-CN/workflow.ts b/ui/src/locales/lang/zh-CN/workflow.ts index 6ed79e52fc9..b68c09f9ee3 100644 --- a/ui/src/locales/lang/zh-CN/workflow.ts +++ b/ui/src/locales/lang/zh-CN/workflow.ts @@ -525,6 +525,7 @@ export default { le: '小于等于', lt: '小于', len_eq: '长度等于', + len_not_eq: '长度不等于', len_ge: '长度大于等于', len_gt: '长度大于', len_le: '长度小于等于', diff --git a/ui/src/locales/lang/zh-Hant/workflow.ts b/ui/src/locales/lang/zh-Hant/workflow.ts index 0513ea1c0e4..10a443aabaf 100644 --- a/ui/src/locales/lang/zh-Hant/workflow.ts +++ b/ui/src/locales/lang/zh-Hant/workflow.ts @@ -519,6 +519,7 @@ export default { le: '小於等於', lt: '小於', len_eq: '長度等於', + len_not_eq: '長度不等於', len_ge: '長度大於等於', len_gt: '長度大於', len_le: '長度小於等於', diff --git a/ui/src/workflow/common/data.ts b/ui/src/workflow/common/data.ts index a726ae9ed5a..d1eaa637675 100644 --- a/ui/src/workflow/common/data.ts +++ b/ui/src/workflow/common/data.ts @@ -1127,6 +1127,7 @@ export const compareList = [ {value: 'le', label: t('workflow.compare.le')}, {value: 'lt', label: t('workflow.compare.lt')}, {value: 'len_eq', label: t('workflow.compare.len_eq')}, + {value: 'len_not_eq', label: t('workflow.compare.len_not_eq')}, {value: 'len_ge', label: t('workflow.compare.len_ge')}, {value: 'len_gt', label: t('workflow.compare.len_gt')}, {value: 'len_le', label: t('workflow.compare.len_le')}, From 0eb250bf5255a7b81c18bf57191c0d35526ceb2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E8=89=AF?= <841369634@qq.com> Date: Wed, 29 Apr 2026 16:40:27 +0800 Subject: [PATCH 11/16] revert --- .../flow/compare/len_not_equal_compare.py | 20 +++++++++++++------ .../flow/compare/not_contain_compare.py | 17 +++++++++++----- 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/apps/application/flow/compare/len_not_equal_compare.py b/apps/application/flow/compare/len_not_equal_compare.py index 0c42cca1fa5..78dfe486937 100644 --- a/apps/application/flow/compare/len_not_equal_compare.py +++ b/apps/application/flow/compare/len_not_equal_compare.py @@ -7,15 +7,23 @@ @desc: 长度不等于比较器 """ from .compare import Compare -from .len_equal_compare import LenEqualCompare - - -# 长度相等比较器 -lenEqualCompare = LenEqualCompare() class LenNotEqualCompare(Compare): def compare(self, source_value, compare, target_value): + # 获取target_value的长度 + try: + target_length = int(target_value) + except Exception: + return False + + # 获取source_value的长度 + try: + source_length = 0 if source_value is None else len(source_value) + except Exception: + # 可计算数字长度 + source_length = len(str(source_value)) + # 长度不等于比较 - return not lenEqualCompare.compare(source_value, compare, target_value) + return source_length != target_length diff --git a/apps/application/flow/compare/not_contain_compare.py b/apps/application/flow/compare/not_contain_compare.py index c0f98fd3a01..99194e70364 100644 --- a/apps/application/flow/compare/not_contain_compare.py +++ b/apps/application/flow/compare/not_contain_compare.py @@ -4,15 +4,22 @@ @Author:虎 @file: contain_compare.py @date:2024/6/11 10:02 - @desc: 不包含比较器 + @desc: """ from .compare import Compare -from .contain_compare import ContainCompare -# 包含比较器 -containCompare = ContainCompare() class NotContainCompare(Compare): def compare(self, source_value, compare, target_value): - return not containCompare.compare(source_value, compare, target_value) + target_value = str(target_value) + + if isinstance(source_value, str): + return target_value not in source_value + elif isinstance(source_value, list): + for item in source_value: + if str(item) == target_value: + return False + return True + else: + return target_value not in str(source_value) From a5fb34b283e2dca5862bd4ee51ed1f74d0fdeedb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E8=89=AF?= <841369634@qq.com> Date: Wed, 29 Apr 2026 21:02:00 +0800 Subject: [PATCH 12/16] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=89=80=E6=9C=89?= =?UTF-8?q?=E9=95=BF=E5=BA=A6=E6=AF=94=E8=BE=83=E5=99=A8=EF=BC=8C=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E6=AF=94=E8=BE=83=E6=95=B0=E5=AD=97=E7=9A=84=E9=95=BF?= =?UTF-8?q?=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/application/flow/compare/len_ge_compare.py | 13 ++++++++++++- apps/application/flow/compare/len_gt_compare.py | 13 ++++++++++++- apps/application/flow/compare/len_le_compare.py | 13 ++++++++++++- apps/application/flow/compare/len_lt_compare.py | 13 ++++++++++++- 4 files changed, 48 insertions(+), 4 deletions(-) diff --git a/apps/application/flow/compare/len_ge_compare.py b/apps/application/flow/compare/len_ge_compare.py index 06dd566cf24..a5ea0fe9735 100644 --- a/apps/application/flow/compare/len_ge_compare.py +++ b/apps/application/flow/compare/len_ge_compare.py @@ -12,7 +12,18 @@ class LenGECompare(Compare): def compare(self, source_value, compare, target_value): + # 获取target_value的长度 try: - return len(source_value) >= int(target_value) + target_length = int(target_value) except Exception: return False + + # 获取source_value的长度 + try: + source_length = 0 if source_value is None else len(source_value) + except Exception: + # 可计算数字长度 + source_length = len(str(source_value)) + + # 长度大于等于比较 + return source_length >= target_length diff --git a/apps/application/flow/compare/len_gt_compare.py b/apps/application/flow/compare/len_gt_compare.py index fae2668e0ba..170a03ac741 100644 --- a/apps/application/flow/compare/len_gt_compare.py +++ b/apps/application/flow/compare/len_gt_compare.py @@ -12,7 +12,18 @@ class LenGTCompare(Compare): def compare(self, source_value, compare, target_value): + # 获取target_value的长度 try: - return len(source_value) > int(target_value) + target_length = int(target_value) except Exception: return False + + # 获取source_value的长度 + try: + source_length = 0 if source_value is None else len(source_value) + except Exception: + # 可计算数字长度 + source_length = len(str(source_value)) + + # 长度大于比较 + return source_length > target_length diff --git a/apps/application/flow/compare/len_le_compare.py b/apps/application/flow/compare/len_le_compare.py index 41b9ee9f709..61920c7d1ca 100644 --- a/apps/application/flow/compare/len_le_compare.py +++ b/apps/application/flow/compare/len_le_compare.py @@ -12,7 +12,18 @@ class LenLECompare(Compare): def compare(self, source_value, compare, target_value): + # 获取target_value的长度 try: - return len(source_value) <= int(target_value) + target_length = int(target_value) except Exception: return False + + # 获取source_value的长度 + try: + source_length = 0 if source_value is None else len(source_value) + except Exception: + # 可计算数字长度 + source_length = len(str(source_value)) + + # 长度小于等于比较 + return source_length <= target_length diff --git a/apps/application/flow/compare/len_lt_compare.py b/apps/application/flow/compare/len_lt_compare.py index 4a9b11654ca..e6248161e3f 100644 --- a/apps/application/flow/compare/len_lt_compare.py +++ b/apps/application/flow/compare/len_lt_compare.py @@ -12,7 +12,18 @@ class LenLTCompare(Compare): def compare(self, source_value, compare, target_value): + # 获取target_value的长度 try: - return len(source_value) < int(target_value) + target_length = int(target_value) except Exception: return False + + # 获取source_value的长度 + try: + source_length = 0 if source_value is None else len(source_value) + except Exception: + # 可计算数字长度 + source_length = len(str(source_value)) + + # 长度小于比较 + return source_length < target_length From 4f675b50f2662e6929f43ced605cc9bd22a886e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E8=89=AF?= <841369634@qq.com> Date: Thu, 30 Apr 2026 09:48:04 +0800 Subject: [PATCH 13/16] =?UTF-8?q?=E5=A4=8D=E7=94=A8=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../flow/compare/len_equal_compare.py | 45 +++++++++++++------ .../flow/compare/len_ge_compare.py | 20 +++------ .../flow/compare/len_gt_compare.py | 20 +++------ .../flow/compare/len_le_compare.py | 20 +++------ .../flow/compare/len_lt_compare.py | 20 +++------ .../flow/compare/len_not_equal_compare.py | 18 +++----- 6 files changed, 66 insertions(+), 77 deletions(-) diff --git a/apps/application/flow/compare/len_equal_compare.py b/apps/application/flow/compare/len_equal_compare.py index f73cf5467ba..5ce2d29f92b 100644 --- a/apps/application/flow/compare/len_equal_compare.py +++ b/apps/application/flow/compare/len_equal_compare.py @@ -4,26 +4,45 @@ @Author:虎 @file: equal_compare.py @date:2024/6/7 14:44 - @desc: 长度相等比较器 + @desc: 长度等于比较器 """ from .compare import Compare +def computeLength(source_value, target_value) -> list: + """ + 计算长度 + + Args: + source_value: 引用变量 + target_value: 目标长度字符串 + + Raises: + ValueError: 当 target_value 不是数字 或 小于0时,抛出该异常 + """ + # 获取target_value的长度 + target_length = int(target_value) if target_value else 0 + if target_length < 0: + raise ValueError("The target length must be greater than or equal to 0.") + + # 获取source_value的长度 + try: + source_length = len(source_value) if source_value is not None else 0 + except Exception: + # 可计算数字长度 + source_length = len(str(source_value)) + + return [source_length, target_length] + + class LenEqualCompare(Compare): def compare(self, source_value, compare, target_value): - # 获取target_value的长度 try: - target_length = int(target_value) - except Exception: - return False + # 计算长度 + source_length, target_length = computeLength(source_value, target_value) - # 获取source_value的长度 - try: - source_length = 0 if source_value is None else len(source_value) + # 长度等于 比较 + return source_length == target_length except Exception: - # 可计算数字长度 - source_length = len(str(source_value)) - - # 长度等于比较 - return source_length == target_length + return False diff --git a/apps/application/flow/compare/len_ge_compare.py b/apps/application/flow/compare/len_ge_compare.py index a5ea0fe9735..e364a0e8d44 100644 --- a/apps/application/flow/compare/len_ge_compare.py +++ b/apps/application/flow/compare/len_ge_compare.py @@ -4,26 +4,20 @@ @Author:虎 @file: lt_compare.py @date:2024/6/11 9:52 - @desc: 大于比较器 + @desc: 长度大于等于比较器 """ from .compare import Compare +from .len_equal_compare import computeLength class LenGECompare(Compare): def compare(self, source_value, compare, target_value): - # 获取target_value的长度 try: - target_length = int(target_value) - except Exception: - return False + # 计算长度 + source_length, target_length = computeLength(source_value, target_value) - # 获取source_value的长度 - try: - source_length = 0 if source_value is None else len(source_value) + # 长度大于等于 比较 + return source_length >= target_length except Exception: - # 可计算数字长度 - source_length = len(str(source_value)) - - # 长度大于等于比较 - return source_length >= target_length + return False diff --git a/apps/application/flow/compare/len_gt_compare.py b/apps/application/flow/compare/len_gt_compare.py index 170a03ac741..849e5177660 100644 --- a/apps/application/flow/compare/len_gt_compare.py +++ b/apps/application/flow/compare/len_gt_compare.py @@ -4,26 +4,20 @@ @Author:虎 @file: lt_compare.py @date:2024/6/11 9:52 - @desc: 大于比较器 + @desc: 长度大于比较器 """ from .compare import Compare +from .len_equal_compare import computeLength class LenGTCompare(Compare): def compare(self, source_value, compare, target_value): - # 获取target_value的长度 try: - target_length = int(target_value) - except Exception: - return False + # 计算长度 + source_length, target_length = computeLength(source_value, target_value) - # 获取source_value的长度 - try: - source_length = 0 if source_value is None else len(source_value) + # 长度大于 比较 + return source_length > target_length except Exception: - # 可计算数字长度 - source_length = len(str(source_value)) - - # 长度大于比较 - return source_length > target_length + return False diff --git a/apps/application/flow/compare/len_le_compare.py b/apps/application/flow/compare/len_le_compare.py index 61920c7d1ca..6875ac1ca14 100644 --- a/apps/application/flow/compare/len_le_compare.py +++ b/apps/application/flow/compare/len_le_compare.py @@ -4,26 +4,20 @@ @Author:虎 @file: lt_compare.py @date:2024/6/11 9:52 - @desc: 小于比较器 + @desc: 长度小于等于比较器 """ from .compare import Compare +from .len_equal_compare import computeLength class LenLECompare(Compare): def compare(self, source_value, compare, target_value): - # 获取target_value的长度 try: - target_length = int(target_value) - except Exception: - return False + # 计算长度 + source_length, target_length = computeLength(source_value, target_value) - # 获取source_value的长度 - try: - source_length = 0 if source_value is None else len(source_value) + # 长度小于等于 比较 + return source_length <= target_length except Exception: - # 可计算数字长度 - source_length = len(str(source_value)) - - # 长度小于等于比较 - return source_length <= target_length + return False diff --git a/apps/application/flow/compare/len_lt_compare.py b/apps/application/flow/compare/len_lt_compare.py index e6248161e3f..c47c06eea3e 100644 --- a/apps/application/flow/compare/len_lt_compare.py +++ b/apps/application/flow/compare/len_lt_compare.py @@ -4,26 +4,20 @@ @Author:虎 @file: lt_compare.py @date:2024/6/11 9:52 - @desc: 小于比较器 + @desc: 长度小于比较器 """ from .compare import Compare +from .len_equal_compare import computeLength class LenLTCompare(Compare): def compare(self, source_value, compare, target_value): - # 获取target_value的长度 try: - target_length = int(target_value) - except Exception: - return False + # 计算长度 + source_length, target_length = computeLength(source_value, target_value) - # 获取source_value的长度 - try: - source_length = 0 if source_value is None else len(source_value) + # 长度小于 比较 + return source_length < target_length except Exception: - # 可计算数字长度 - source_length = len(str(source_value)) - - # 长度小于比较 - return source_length < target_length + return False diff --git a/apps/application/flow/compare/len_not_equal_compare.py b/apps/application/flow/compare/len_not_equal_compare.py index 78dfe486937..38dd002137b 100644 --- a/apps/application/flow/compare/len_not_equal_compare.py +++ b/apps/application/flow/compare/len_not_equal_compare.py @@ -7,23 +7,17 @@ @desc: 长度不等于比较器 """ from .compare import Compare +from .len_equal_compare import computeLength class LenNotEqualCompare(Compare): def compare(self, source_value, compare, target_value): - # 获取target_value的长度 try: - target_length = int(target_value) - except Exception: - return False + # 计算长度 + source_length, target_length = computeLength(source_value, target_value) - # 获取source_value的长度 - try: - source_length = 0 if source_value is None else len(source_value) + # 长度不等于 比较 + return source_length != target_length except Exception: - # 可计算数字长度 - source_length = len(str(source_value)) - - # 长度不等于比较 - return source_length != target_length + return False From 75412c547cfc9839652c09908d6aed74b466b5fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E8=89=AF?= <841369634@qq.com> Date: Thu, 30 Apr 2026 09:52:45 +0800 Subject: [PATCH 14/16] =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=91=BD=E5=90=8D?= =?UTF-8?q?=E8=A7=84=E8=8C=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/application/flow/compare/len_equal_compare.py | 4 ++-- apps/application/flow/compare/len_ge_compare.py | 4 ++-- apps/application/flow/compare/len_gt_compare.py | 4 ++-- apps/application/flow/compare/len_le_compare.py | 4 ++-- apps/application/flow/compare/len_lt_compare.py | 4 ++-- apps/application/flow/compare/len_not_equal_compare.py | 4 ++-- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/apps/application/flow/compare/len_equal_compare.py b/apps/application/flow/compare/len_equal_compare.py index 5ce2d29f92b..413ab106f6e 100644 --- a/apps/application/flow/compare/len_equal_compare.py +++ b/apps/application/flow/compare/len_equal_compare.py @@ -9,7 +9,7 @@ from .compare import Compare -def computeLength(source_value, target_value) -> list: +def compute_length(source_value, target_value) -> list: """ 计算长度 @@ -40,7 +40,7 @@ class LenEqualCompare(Compare): def compare(self, source_value, compare, target_value): try: # 计算长度 - source_length, target_length = computeLength(source_value, target_value) + source_length, target_length = compute_length(source_value, target_value) # 长度等于 比较 return source_length == target_length diff --git a/apps/application/flow/compare/len_ge_compare.py b/apps/application/flow/compare/len_ge_compare.py index e364a0e8d44..41227d2efa7 100644 --- a/apps/application/flow/compare/len_ge_compare.py +++ b/apps/application/flow/compare/len_ge_compare.py @@ -7,7 +7,7 @@ @desc: 长度大于等于比较器 """ from .compare import Compare -from .len_equal_compare import computeLength +from .len_equal_compare import compute_length class LenGECompare(Compare): @@ -15,7 +15,7 @@ class LenGECompare(Compare): def compare(self, source_value, compare, target_value): try: # 计算长度 - source_length, target_length = computeLength(source_value, target_value) + source_length, target_length = compute_length(source_value, target_value) # 长度大于等于 比较 return source_length >= target_length diff --git a/apps/application/flow/compare/len_gt_compare.py b/apps/application/flow/compare/len_gt_compare.py index 849e5177660..c11c3eb9b86 100644 --- a/apps/application/flow/compare/len_gt_compare.py +++ b/apps/application/flow/compare/len_gt_compare.py @@ -7,7 +7,7 @@ @desc: 长度大于比较器 """ from .compare import Compare -from .len_equal_compare import computeLength +from .len_equal_compare import compute_length class LenGTCompare(Compare): @@ -15,7 +15,7 @@ class LenGTCompare(Compare): def compare(self, source_value, compare, target_value): try: # 计算长度 - source_length, target_length = computeLength(source_value, target_value) + source_length, target_length = compute_length(source_value, target_value) # 长度大于 比较 return source_length > target_length diff --git a/apps/application/flow/compare/len_le_compare.py b/apps/application/flow/compare/len_le_compare.py index 6875ac1ca14..0a7bef1a441 100644 --- a/apps/application/flow/compare/len_le_compare.py +++ b/apps/application/flow/compare/len_le_compare.py @@ -7,7 +7,7 @@ @desc: 长度小于等于比较器 """ from .compare import Compare -from .len_equal_compare import computeLength +from .len_equal_compare import compute_length class LenLECompare(Compare): @@ -15,7 +15,7 @@ class LenLECompare(Compare): def compare(self, source_value, compare, target_value): try: # 计算长度 - source_length, target_length = computeLength(source_value, target_value) + source_length, target_length = compute_length(source_value, target_value) # 长度小于等于 比较 return source_length <= target_length diff --git a/apps/application/flow/compare/len_lt_compare.py b/apps/application/flow/compare/len_lt_compare.py index c47c06eea3e..0871d167464 100644 --- a/apps/application/flow/compare/len_lt_compare.py +++ b/apps/application/flow/compare/len_lt_compare.py @@ -7,7 +7,7 @@ @desc: 长度小于比较器 """ from .compare import Compare -from .len_equal_compare import computeLength +from .len_equal_compare import compute_length class LenLTCompare(Compare): @@ -15,7 +15,7 @@ class LenLTCompare(Compare): def compare(self, source_value, compare, target_value): try: # 计算长度 - source_length, target_length = computeLength(source_value, target_value) + source_length, target_length = compute_length(source_value, target_value) # 长度小于 比较 return source_length < target_length diff --git a/apps/application/flow/compare/len_not_equal_compare.py b/apps/application/flow/compare/len_not_equal_compare.py index 38dd002137b..f95c35c2fc9 100644 --- a/apps/application/flow/compare/len_not_equal_compare.py +++ b/apps/application/flow/compare/len_not_equal_compare.py @@ -7,7 +7,7 @@ @desc: 长度不等于比较器 """ from .compare import Compare -from .len_equal_compare import computeLength +from .len_equal_compare import compute_length class LenNotEqualCompare(Compare): @@ -15,7 +15,7 @@ class LenNotEqualCompare(Compare): def compare(self, source_value, compare, target_value): try: # 计算长度 - source_length, target_length = computeLength(source_value, target_value) + source_length, target_length = compute_length(source_value, target_value) # 长度不等于 比较 return source_length != target_length From ce9714fed3263843c63c0e6430b3e65476d76028 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E8=89=AF?= <841369634@qq.com> Date: Thu, 30 Apr 2026 10:00:44 +0800 Subject: [PATCH 15/16] =?UTF-8?q?=E5=B0=8F=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/application/flow/compare/len_not_equal_compare.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/application/flow/compare/len_not_equal_compare.py b/apps/application/flow/compare/len_not_equal_compare.py index f95c35c2fc9..388791b12ae 100644 --- a/apps/application/flow/compare/len_not_equal_compare.py +++ b/apps/application/flow/compare/len_not_equal_compare.py @@ -2,7 +2,7 @@ """ @project: maxkb @Author:wangliang181230 - @file: equal_compare.py + @file: len_not_equal_compare.py @date:2026/4/28 20:17 @desc: 长度不等于比较器 """ From c62ae673e4b1dc3d61a775a126d3e98134aa1320 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E8=89=AF?= <841369634@qq.com> Date: Thu, 30 Apr 2026 10:14:02 +0800 Subject: [PATCH 16/16] =?UTF-8?q?=E5=B0=8F=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/application/flow/compare/len_equal_compare.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/application/flow/compare/len_equal_compare.py b/apps/application/flow/compare/len_equal_compare.py index 413ab106f6e..7479c5128ba 100644 --- a/apps/application/flow/compare/len_equal_compare.py +++ b/apps/application/flow/compare/len_equal_compare.py @@ -9,21 +9,21 @@ from .compare import Compare -def compute_length(source_value, target_value) -> list: +def compute_length(source_value, target_length) -> list: """ 计算长度 Args: source_value: 引用变量 - target_value: 目标长度字符串 + target_length: 目标长度字符串 Raises: ValueError: 当 target_value 不是数字 或 小于0时,抛出该异常 """ # 获取target_value的长度 - target_length = int(target_value) if target_value else 0 + target_length = int(target_length) if target_length else 0 if target_length < 0: - raise ValueError("The target length must be greater than or equal to 0.") + raise ValueError("The target length must be greater than or equal to 0") # 获取source_value的长度 try: