|
@@ -0,0 +1,49 @@
|
|
|
+package com.winhc.bigdata.udf;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONPath;
|
|
|
+import com.aliyun.odps.udf.UDF;
|
|
|
+import org.apache.commons.lang.StringUtils;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Arrays;
|
|
|
+import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @Author: π
|
|
|
+ * @Date: 2020/5/14 16:26
|
|
|
+ * @Description: 比较两个字符串数组包含关系(company_id 字符串集合)
|
|
|
+ */
|
|
|
+public class CompareName2 extends UDF {
|
|
|
+
|
|
|
+ public Boolean evaluate(String ygName, String bgName) {
|
|
|
+ if (StringUtils.isBlank(ygName) || StringUtils.isBlank(bgName)) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ //原告 //被告
|
|
|
+ List<String> list1 = toList(ygName);
|
|
|
+ List<String> list2 = toList(bgName);
|
|
|
+ if (list1.isEmpty() || list2.isEmpty()) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ List<String> intersection = list1.stream().filter(list2::contains).collect(Collectors.toList());
|
|
|
+ return intersection.isEmpty();
|
|
|
+ }
|
|
|
+
|
|
|
+ public List<String> toList(String bgName) {
|
|
|
+ List<String> list = Arrays.stream(bgName.split(",", -1))
|
|
|
+ .filter(StringUtils::isNotBlank).distinct().collect(Collectors.toList());
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void main(String[] args) {
|
|
|
+ String yg_name = "11,22,,33,55";
|
|
|
+ String bg_name = "12,,54,77";
|
|
|
+ CompareName2 c = new CompareName2();
|
|
|
+ System.out.println(c.evaluate(yg_name, bg_name));
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+
|