|
@@ -0,0 +1,28 @@
|
|
|
+package com.winhc.bigdata.udf.company;
|
|
|
+
|
|
|
+import com.aliyun.odps.udf.UDF;
|
|
|
+import com.aliyun.odps.utils.StringUtils;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @author: XuJiakai
|
|
|
+ * 2022/7/26 17:36
|
|
|
+ */
|
|
|
+public class RegNumberVerify extends UDF {
|
|
|
+
|
|
|
+ private static boolean isNumber(String val) {
|
|
|
+ try {
|
|
|
+ Double.parseDouble(val);
|
|
|
+ return true;
|
|
|
+ } catch (Exception e) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param val
|
|
|
+ * @return true 合法
|
|
|
+ */
|
|
|
+ public boolean evaluate(String val) {
|
|
|
+ return StringUtils.isNotBlank(val) && val.length() == 15 && isNumber(val.substring(0, 6));
|
|
|
+ }
|
|
|
+}
|