|
@@ -0,0 +1,66 @@
|
|
|
+package com.winhc.bigdata.udf;
|
|
|
+
|
|
|
+import com.aliyun.odps.udf.UDF;
|
|
|
+import org.apache.commons.lang.StringUtils;
|
|
|
+
|
|
|
+import java.util.Arrays;
|
|
|
+import java.util.List;
|
|
|
+import java.util.regex.Pattern;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @Author: π
|
|
|
+ * @Description: 1. reg_capital_currency,actual_capital_currency 含有万或者. 把万和.去掉,
|
|
|
+ * 2. actual_capital_currency含有万,并且actual_capital_amount有值,你看下这种情况
|
|
|
+ * 应该actual_capital_amount都是乘10000
|
|
|
+ * 3. 加个注册资金大于实缴的逻辑
|
|
|
+ */
|
|
|
+public class ActualCapitalUpdate extends UDF {
|
|
|
+
|
|
|
+ private static final Pattern pattern = Pattern.compile(".*[万.].*");
|
|
|
+
|
|
|
+
|
|
|
+ public Boolean contain(String name) {
|
|
|
+ if (StringUtils.isBlank(name)) return false;
|
|
|
+ return pattern.matcher(name).matches();
|
|
|
+ }
|
|
|
+
|
|
|
+ public String replace(String name) {
|
|
|
+ if (StringUtils.isBlank(name)) return name;
|
|
|
+ return name.replaceAll("[万.]", "");
|
|
|
+ }
|
|
|
+
|
|
|
+ public List<String> evaluate(String reg_capital_currency, Long reg_capital_amount,
|
|
|
+ String actual_capital_currency, Long actual_capital_amount) {
|
|
|
+ String r1 = reg_capital_currency;
|
|
|
+ String r2 = actual_capital_currency;
|
|
|
+ Long r3 = actual_capital_amount;
|
|
|
+ if (StringUtils.isNotBlank(reg_capital_currency) && contain(reg_capital_currency)) {
|
|
|
+ r1 = replace(reg_capital_currency);
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(actual_capital_currency) && contain(actual_capital_currency)) {
|
|
|
+ r2 = replace(actual_capital_currency);
|
|
|
+ if (null != actual_capital_amount && actual_capital_currency.contains("万")) {
|
|
|
+ Long tmp = actual_capital_amount * 10000L;
|
|
|
+ if (reg_capital_amount != null && reg_capital_amount >= tmp) {
|
|
|
+ r3 = tmp;
|
|
|
+ } else {
|
|
|
+ r3 = null;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return Arrays.asList(r1, r2, null == r3 ? null : r3.toString());
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public static void main(String[] args) {
|
|
|
+ String s1 = ".万人民币";
|
|
|
+ Long s2 = 46690000000L;
|
|
|
+ String s3 = ".人民币";
|
|
|
+ Long s4 = 4843981L;
|
|
|
+ ActualCapitalUpdate r = new ActualCapitalUpdate();
|
|
|
+ System.out.println(r.evaluate(s1, s2, s3, s4));
|
|
|
+ }
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+
|