From c8b6e6431edf72cb37069597d3a0295709bcdc10 Mon Sep 17 00:00:00 2001 From: lisw Date: Tue, 9 Aug 2022 10:57:36 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=A7=84=E5=88=99=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E6=95=B0=E7=BB=84=E5=88=A4=E6=96=AD=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../guiderule/RuleConditionInfo.java | 4 +-- .../service/datax/runner/ExecuteUtils.java | 30 ++++++++++++++++++- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/ddp/ddp-common/ddp-model/src/main/java/com/fibo/ddp/common/model/strategyx/guiderule/RuleConditionInfo.java b/ddp/ddp-common/ddp-model/src/main/java/com/fibo/ddp/common/model/strategyx/guiderule/RuleConditionInfo.java index 3afe544..90e9f99 100644 --- a/ddp/ddp-common/ddp-model/src/main/java/com/fibo/ddp/common/model/strategyx/guiderule/RuleConditionInfo.java +++ b/ddp/ddp-common/ddp-model/src/main/java/com/fibo/ddp/common/model/strategyx/guiderule/RuleConditionInfo.java @@ -63,8 +63,8 @@ public class RuleConditionInfo @TableField(exist = false) private String TempParentId;//插入时临时父id - @TableField(exist = false) - private Integer valueType;//字段值类型 +// @TableField(exist = false) +// private Integer valueType;//字段值类型 @TableField(exist = false) private List loopGroupActions = new ArrayList<>();//循环组对应的条件 diff --git a/ddp/ddp-common/ddp-service/src/main/java/com/fibo/ddp/common/service/datax/runner/ExecuteUtils.java b/ddp/ddp-common/ddp-service/src/main/java/com/fibo/ddp/common/service/datax/runner/ExecuteUtils.java index 818a275..61eaf09 100644 --- a/ddp/ddp-common/ddp-service/src/main/java/com/fibo/ddp/common/service/datax/runner/ExecuteUtils.java +++ b/ddp/ddp-common/ddp-service/src/main/java/com/fibo/ddp/common/service/datax/runner/ExecuteUtils.java @@ -1,5 +1,6 @@ package com.fibo.ddp.common.service.datax.runner; +import cn.hutool.core.util.ArrayUtil; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; @@ -144,6 +145,33 @@ public class ExecuteUtils { result = !map.containsKey(paramOne); } break; + //数组之间的比较 + case "array contains": + JSONArray oneArray = JSON.parseArray(paramOne.toString()); + JSONArray twoArray; + if(paramTwo!=null){ + twoArray = (JSONArray) JSONArray.toJSON(paramTwo.toString().split(",")); + }else{ + return false; + } + List oneList = oneArray.toJavaList(String.class); + List twoList = twoArray.toJavaList(String.class); + //包含任意一个,则返回true + result = oneList.stream().anyMatch(item-> twoList.contains(item)); + break; + case "array not contains": + JSONArray oneArrayN = JSON.parseArray(paramOne.toString()); + JSONArray twoArrayN; + if(paramTwo!=null){ + twoArrayN = (JSONArray) JSONArray.toJSON(paramTwo.toString().split(",")); + }else{ + return false; + } + List oneListN = oneArrayN.toJavaList(String.class); + List twoListN = twoArrayN.toJavaList(String.class); + //全不包含,则返回true + result = oneListN.stream().allMatch(item-> !twoListN.contains(item)); + break; } return result; } @@ -223,7 +251,7 @@ public class ExecuteUtils { //如果是数组取length if (i == array.length - 2) { if ("length()".equals(array[array.length - 1])) { - return JSON.toJavaObject(JSON.parseObject(JSON.toJSONString(o)), ArrayList.class).size(); + return JSON.toJavaObject(JSON.parseArray(JSON.toJSONString(o)), ArrayList.class).size(); } } //未找到最后一个数组元素则将其识别为map