/**
 * Copyright &copy; 2012-2016 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
 */
package com.younike.common.utils.string;


import com.google.common.collect.Maps;
import com.younike.common.spring.SpringContextHolder;
import com.younike.common.utils.date.DateUtils;
import com.younike.common.utils.encode.Encodes;
import com.younike.common.utils.text.StrFormatter;
import org.apache.commons.compress.utils.Lists;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringEscapeUtils;
import org.springframework.util.CollectionUtils;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import org.springframework.web.servlet.LocaleResolver;

import javax.servlet.http.HttpServletRequest;
import java.io.UnsupportedEncodingException;
import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * 字符串工具类, 继承org.apache.commons.lang3.StringUtils类
 *
 * @author ThinkGem
 * @version 2013-05-22
 */
public class StringUtils extends org.apache.commons.lang3.StringUtils {

    private static final char SEPARATOR = '_';
    private static final String CHARSET_NAME = "UTF-8";
    /**
     * 数字0
     */
    private final static int NUM_ZERO = 0;
    /**
     * 数字1
     */
    private final static int NUM_ONE = 1;
    /**
     * 数字-1
     */
    private final static int NUM_MINUS_ONE = -1;

    /**
     * 格式化文本, {} 表示占位符<br>
     * 此方法只是简单将占位符 {} 按照顺序替换为参数<br>
     * 如果想输出 {} 使用 \\转义 { 即可，如果想输出 {} 之前的 \ 使用双转义符 \\\\ 即可<br>
     * 例：<br>
     * 通常使用：format("this is {} for {}", "a", "b") -> this is a for b<br>
     * 转义{}： format("this is \\{} for {}", "a", "b") -> this is \{} for a<br>
     * 转义\： format("this is \\\\{} for {}", "a", "b") -> this is \a for b<br>
     *
     * @param template 文本模板，被替换的部分用 {} 表示
     * @param params   参数值
     * @return 格式化后的文本
     */
    public static String format(String template, Object... params) {
        if (isEmpty(params) || isEmpty(template)) {
            return template;
        }
        return StrFormatter.format(template, params);
    }

    /**
     * * 判断一个对象数组是否为空
     *
     * @param objects 要判断的对象数组
     *                * @return true：为空 false：非空
     */
    public static boolean isEmpty(Object[] objects) {
        return isNull(objects) || (objects.length == 0);
    }

    /**
     * 转换为字节数组
     *
     * @param str
     * @return
     */
    public static byte[] getBytes(String str) {
        if (str != null) {
            try {
                return str.getBytes(CHARSET_NAME);
            } catch (UnsupportedEncodingException e) {
                return null;
            }
        } else {
            return null;
        }
    }

    /**
     * 转换为Boolean类型 'true', 'on', 'y', 't', 'yes' or '1' (case insensitive) will
     * return true. Otherwise, false is returned.
     */
    public static Boolean toBoolean(final Object val) {
        if (val == null) {
            return false;
        }
        return BooleanUtils.toBoolean(val.toString()) || "1".equals(val.toString());
    }

    /**
     * 转换为字节数组
     *
     * @param bytes
     * @return
     */
    public static String toString(byte[] bytes) {
        try {
            return new String(bytes, CHARSET_NAME);
        } catch (UnsupportedEncodingException e) {
            return EMPTY;
        }
    }

    /**
     * 如果对象为空，则使用defaultVal值 see: ObjectUtils.toString(obj, defaultVal)
     *
     * @param obj
     * @param defaultVal
     * @return
     */
    public static String toString(final Object obj, final String defaultVal) {
        return obj == null ? defaultVal : obj.toString();
    }

    /**
     * 是否包含字符串
     *
     * @param str  验证字符串
     * @param strs 字符串组
     * @return 包含返回true
     */
    public static boolean inString(String str, String... strs) {
        if (str != null) {
            for (String s : strs) {
                if (str.equals(trim(s))) {
                    return true;
                }
            }
        }
        return false;
    }

    /**
     * 替换掉HTML标签方法
     */
    public static String replaceHtml(String html) {
        if (isBlank(html)) {
            return "";
        }
        String regEx = "<.+?>";
        Pattern p = Pattern.compile(regEx);
        Matcher m = p.matcher(html);
        String s = m.replaceAll("");
        return s;
    }

    /**
     * 替换为手机识别的HTML，去掉样式及属性，保留回车。
     *
     * @param html
     * @return
     */
    public static String replaceMobileHtml(String html) {
        if (html == null) {
            return "";
        }
        return html.replaceAll("<([a-z]+?)\\s+?.*?>", "<$1>");
    }

    /**
     * 替换为手机识别的HTML，去掉样式及属性，保留回车。
     *
     * @param txt
     * @return
     */
    public static String toHtml(String txt) {
        if (txt == null) {
            return "";
        }
        return replace(replace(Encodes.escapeHtml(txt), "\n", "<br/>"), "\t", "&nbsp; &nbsp; ");
    }

    /**
     * 缩略字符串（不区分中英文字符）
     *
     * @param str    目标字符串
     * @param length 截取长度
     * @return
     */
    public static String abbr(String str, int length) {
        if (str == null) {
            return "";
        }
        try {
            StringBuilder sb = new StringBuilder();
            int currentLength = 0;
            for (char c : replaceHtml(StringEscapeUtils.unescapeHtml4(str)).toCharArray()) {
                currentLength += String.valueOf(c).getBytes("GBK").length;
                if (currentLength <= length - 3) {
                    sb.append(c);
                } else {
                    sb.append("...");
                    break;
                }
            }
            return sb.toString();
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        return "";
    }

    public static String abbr2(String param, int length) {
        if (param == null) {
            return "";
        }
        StringBuffer result = new StringBuffer();
        int n = 0;
        char temp;
        boolean isCode = false; // 是不是HTML代码
        boolean isHTML = false; // 是不是HTML特殊字符,如&nbsp;
        for (int i = 0; i < param.length(); i++) {
            temp = param.charAt(i);
            if (temp == '<' ) {
                isCode = true;
            } else if (temp == '&' ) {
                isHTML = true;
            } else if (temp == '>' && isCode) {
                n = n - 1;
                isCode = false;
            } else if (temp == ';' && isHTML) {
                isHTML = false;
            }
            try {
                if (!isCode && !isHTML) {
                    n += String.valueOf(temp).getBytes("GBK").length;
                }
            } catch (UnsupportedEncodingException e) {
                e.printStackTrace();
            }

            if (n <= length - 3) {
                result.append(temp);
            } else {
                result.append("...");
                break;
            }
        }
        // 取出截取字符串中的HTML标记
        String temp_result = result.toString().replaceAll("(>)[^<>]*(<?)", "$1$2");
        // 去掉不需要结素标记的HTML标记
        temp_result = temp_result.replaceAll(
                "</?(AREA|BASE|BASEFONT|BODY|BR|COL|COLGROUP|DD|DT|FRAME|HEAD|HR|HTML|IMG|INPUT|ISINDEX|LI|LINK|META|OPTION|P|PARAM|TBODY|TD|TFOOT|TH|THEAD|TR|area|base|basefont|body|br|col|colgroup|dd|dt|frame|head|hr|html|img|input|isindex|li|link|meta|option|p|param|tbody|td|tfoot|th|thead|tr)[^<>]*/?>",
                "");
        // 去掉成对的HTML标记
        temp_result = temp_result.replaceAll("<([a-zA-Z]+)[^<>]*>(.*?)</\\1>", "$2");
        // 用正则表达式取出标记
        Pattern p = Pattern.compile("<([a-zA-Z]+)[^<>]*>");
        Matcher m = p.matcher(temp_result);
        List<String> endHTML = Lists.newArrayList();
        while (m.find()) {
            endHTML.add(m.group(1));
        }
        // 补全不成对的HTML标记
        for (int i = endHTML.size() - 1; i >= 0; i--) {
            result.append("</");
            result.append(endHTML.get(i));
            result.append(">");
        }
        return result.toString();
    }

    /**
     * 转换为Double类型
     */
    public static Double toDouble(Object val) {
        if (val == null) {
            return 0D;
        }
        try {
            return Double.valueOf(trim(val.toString()));
        } catch (Exception e) {
            return 0D;
        }
    }

    /**
     * 转换为Float类型
     */
    public static Float toFloat(Object val) {
        return toDouble(val).floatValue();
    }

    /**
     * 转换为Long类型
     */
    public static Long toLong(Object val) {
        return toDouble(val).longValue();
    }

    /**
     * 转换为Integer类型
     */
    public static Integer toInteger(Object val) {
        return toLong(val).intValue();
    }

    /**
     * 获得i18n字符串
     */
    public static String getMessage(String code, Object[] args) {
        LocaleResolver localLocaleResolver = SpringContextHolder.getBean(LocaleResolver.class);
        HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes())
                .getRequest();
        Locale localLocale = localLocaleResolver.resolveLocale(request);
        return SpringContextHolder.getApplicationContext().getMessage(code, args, localLocale);
    }

    /**
     * 获得用户远程地址
     */
    public static String getRemoteAddr(HttpServletRequest request) {
        String remoteAddr = request.getHeader("X-Real-IP");
        if (isNotBlank(remoteAddr)) {
            remoteAddr = request.getHeader("X-Forwarded-For");
        } else if (isNotBlank(remoteAddr)) {
            remoteAddr = request.getHeader("Proxy-Client-IP");
        } else if (isNotBlank(remoteAddr)) {
            remoteAddr = request.getHeader("WL-Proxy-Client-IP");
        }
        return remoteAddr != null ? remoteAddr : request.getRemoteAddr();
    }

    /**
     * 驼峰命名法工具
     *
     * @return toCamelCase(" hello_world ") == "helloWorld"
     * toCapitalizeCamelCase("hello_world") == "HelloWorld"
     * toUnderScoreCase("helloWorld") = "hello_world"
     */
    public static String toCamelCase(String s) {
        if (s == null) {
            return null;
        }

        s = s.toLowerCase();

        StringBuilder sb = new StringBuilder(s.length());
        boolean upperCase = false;
        for (int i = 0; i < s.length(); i++) {
            char c = s.charAt(i);

            if (c == SEPARATOR) {
                upperCase = true;
            } else if (upperCase) {
                sb.append(Character.toUpperCase(c));
                upperCase = false;
            } else {
                sb.append(c);
            }
        }

        return sb.toString();
    }

    /**
     * 驼峰命名法工具
     *
     * @return toCamelCase(" hello_world ") == "helloWorld"
     * toCapitalizeCamelCase("hello_world") == "HelloWorld"
     * toUnderScoreCase("helloWorld") = "hello_world"
     */
    public static String toCapitalizeCamelCase(String s) {
        if (s == null) {
            return null;
        }
        s = toCamelCase(s);
        return s.substring(0, 1).toUpperCase() + s.substring(1);
    }

    /**
     * 驼峰命名法工具
     *
     * @return toCamelCase(" hello_world ") == "helloWorld"
     * toCapitalizeCamelCase("hello_world") == "HelloWorld"
     * toUnderScoreCase("helloWorld") = "hello_world"
     */
    public static String toUnderScoreCase(String s) {
        if (s == null) {
            return null;
        }

        StringBuilder sb = new StringBuilder();
        boolean upperCase = false;
        for (int i = 0; i < s.length(); i++) {
            char c = s.charAt(i);

            boolean nextUpperCase = true;

            if (i < (s.length() - 1)) {
                nextUpperCase = Character.isUpperCase(s.charAt(i + 1));
            }

            if ((i > 0) && Character.isUpperCase(c)) {
                if (!upperCase || !nextUpperCase) {
                    sb.append(SEPARATOR);
                }
                upperCase = true;
            } else {
                upperCase = false;
            }

            sb.append(Character.toLowerCase(c));
        }

        return sb.toString();
    }

    /**
     * 转换为JS获取对象值，生成三目运算返回结果
     *
     * @param objectString 对象串 例如：row.user.id
     *                     返回：!row?'':!row.user?'':!row.user.id?'':row.user.id
     */
    public static String jsGetVal(String objectString) {
        StringBuilder result = new StringBuilder();
        StringBuilder val = new StringBuilder();
        String[] vals = split(objectString, ".");
        for (int i = 0; i < vals.length; i++) {
            val.append("." + vals[i]);
            result.append("!" + (val.substring(1)) + "?'':");
        }
        result.append(val.substring(1));
        return result.toString();
    }

    /**
     * 验证 参数一是否为参数二的整数倍
     */
    public static boolean checkNumMult(Integer par, Integer baseNum) {
        boolean result = false;
        if (par != null && par != null) {
            if (par.intValue() % baseNum.intValue() == 0) {
                result = true;
            }

        }
        return result;

    }

    /**
     * 生成编号
     */
    public static String getSomeNo(String noName, String currentNo) {
        StringBuilder result = new StringBuilder();

        if (StringUtils.equals("XH", noName)) {
            // 打包箱号（规则：XH+年份（2位）+00001）
            result.append("XH");
            result.append(DateUtils.getYear(), 2, 4);
            if (isEmpty(currentNo)) {
                result.append("00001");
            } else {
                Integer intcurrentNo = Integer.parseInt(currentNo.substring(4));
                String after = String.valueOf(intcurrentNo.intValue() + 1);
                StringBuilder csb = new StringBuilder();
                for (int i = 0; i < 5 - after.length(); i++) {
                    csb.append("0");
                }
                result.append(csb);
                result.append(after);
            }
        }

        return result.toString();

    }

    /**
     * 判断字符串长度 value:字符串 checkLength:长度 mustFlag是否必须
     */
    public static boolean checkStrLength(String value, int checkLength, boolean mustFlag) {
        boolean checkFlag = false;

        if (mustFlag && StringUtils.isEmpty(value)) {
            checkFlag = false;
        } else if (!mustFlag && StringUtils.isEmpty(value)) {
            checkFlag = true;
        } else {
            int length = value.length();
            checkFlag = length <= checkLength;
        }

        return checkFlag;
    }

    /**
     * 判断Bigdecimal精度 value:字符串 checkLength:长度 mustFlag是否必须 返回值
     * "备注不能为空   备注超过256位"
     */
    public static String checkBigdeciLengthMsg(String msgName, BigDecimal value, Integer intnum, Integer decinum,
                                               boolean mustFlag) {
        String checkMsg = "";

        if (mustFlag && value == null) {
            checkMsg = msgName + "不能为空；";
        } else if (!mustFlag && value == null) {
        } else {
            if (value.compareTo(BigDecimal.ZERO) < 0) {
                checkMsg = msgName + "不能小于0";
            } else {
                String result = "";
                String intStr = String.valueOf(value.intValue());
                result += msgName;
                if (intStr.length() > intnum) {
                    result += "整数位不能大于" + intnum + "位";
                }

                int deciStr = value.scale();
                if (deciStr > decinum) {
                    if (isNotBlank(result)) {
                        result += "，";
                    }
                    result += "小数位不能大于" + decinum + "位";
                }

                if (equals(result, msgName)) {
                    result = "";
                }
                checkMsg = result;
            }
        }
        return checkMsg;
    }

    /**
     * 判断Integer精度 value:字符串 checkLength:长度 mustFlag是否必须 返回值 "备注不能为空   备注超过256位"
     */
    public static String checkIntLengthMsg(String msgName, Integer value, Integer intnum, boolean mustFlag) {
        String checkMsg = "";

        if (mustFlag && value == null) {
            checkMsg = msgName + "不能为空；";
        } else if (!mustFlag && value == null) {
        } else {

            String result = "";
            String intStr = String.valueOf(value);
            result += msgName;
            if (intStr.length() > value) {
                result += "不能大于" + intnum + "位";
            }
            if (equals(result, msgName)) {
                result = "";
            }
            checkMsg = result;
        }
        return checkMsg;
    }

    /**
     * 判断字符串是否是数字并且大于等于0
     */
    public static boolean isNumber(String value) {
        try {
            Double doubleValue = Double.valueOf(value.trim());
            return doubleValue >= 0;
        } catch (NumberFormatException e) {
            return false;
        }
    }

    /**
     * 判断金额
     */
    public static String checkAmount(String amount, int intnum, int decinum, String msg) {
        String result = "";

        try {
            Double doubleValue = Double.valueOf(amount.trim());
            if (doubleValue < 0) {
                result = msg + "不能小于0";
            } else {
                String[] amountStrList = amount.split("\\.");
                result += msg;
                if (amountStrList[0].length() > intnum) {
                    result += "整数位不能大于" + intnum + "位";
                }

                if (amountStrList.length > 1) {
                    if (amountStrList[1].length() > decinum) {
                        if (!equals(result, msg)) {
                            result += ",";
                        }
                        result += "小数位不能大于" + decinum + "位";
                    }
                }
                if (equals(result, msg)) {
                    result = "";
                }

            }
        } catch (Exception e) {
            result = msg + "格式不正确";
        }
        return result;
    }

    /**
     * 判断百分比0到1之间
     */
    public static String checkPencent(String pencent, int decinum, String msg) {
        String result = "";

        try {
            Double doubleValue = Double.valueOf(pencent.trim());
            if (doubleValue < 0) {
                result = msg + "不能小于0";
            } else if (doubleValue > 1) {
                result = msg + "不能大于1";
            } else {
                String[] amountStrList = pencent.split("\\.");
                result += msg;

                if (amountStrList.length > 1) {
                    if (amountStrList[1].length() > decinum) {
                        if (!equals(result, msg)) {
                            result += ",";
                        }
                        result += "小数位不能大于" + decinum + "位";
                    }
                }
                if (equals(result, msg)) {
                    result = "";
                }

            }
        } catch (Exception e) {
            result = msg + "格式不正确";
        }
        return result;
    }

    /**
     * 去除全角半角的前后空格
     *
     * @param str 源字符串
     * @return trim 后的字符串
     */
    public static String trim(String str) {
        if (str == null) {
            return "";
        } else {
            str = str.trim();
            if (str.startsWith("　") || str.startsWith(" ") || str.startsWith(" ")) {
                str = str.substring(1);
                return trim(str);
            } else if (str.endsWith("　") || str.endsWith(" ") || str.endsWith(" ")) {
                str = str.substring(0, str.length() - 1);
                return trim(str);
            } else {
                return str;
            }
        }
    }

    public static String trimString(String str) {

        return str == null ? null : StringUtils.trim(str);
    }

    public static String trimStringAll(String str) {
        if (str == null) {
            return null;
        }
        String a = str.replace(" ", "");
        String b = a.replace(" ", "");
        String c = b.replace("\n", "");
        String d = c.replace("\t", "");
        String e = d.replace("\r", "");
        return e;
    }

    public static String trimStringNR(String str) {
        if (str == null) {
            return null;
        }
        String a = str.replace("\n", "");
        String b = a.replace("\r", "");
        return b;
    }

    public static String trimStringNToBr(String str) {
        if (str == null) {
            return null;
        }
        String a = str.replace("\n", "<br>");
        String b = a.replace("\r", "");
        return b;
    }

    /**
     * 判断是否都是半角的英文和数字
     *
     * @param txt
     * @return boolean
     */
    public static boolean isHalfENGNum(String txt) {
        StringBuffer checkText = null;

        if (txt == null) {
            return true;
        }
        checkText = new StringBuffer(txt);
        for (int i = 0; i < checkText.length(); i++) {
            String subcheckText = checkText.substring(i, i + 1);
            if (!matches(subcheckText, "([a-zA-Z]+)") && !matches(subcheckText, "([0-9]+)")) {
                return false;
            }
        }
        return true;
    }

    /**
     * 正则表达式匹配<br>
     *
     * @param value
     * @param regexp
     * @return boolean
     */
    public static boolean matches(String value, String regexp) {
        if (isEmpty(value) || isEmpty(regexp)) {
            return false;
        } else {
            return value.matches(regexp);
        }
    }

    public static boolean isInteger(String value) {
        try {
            Integer.parseInt(value);
            return true;
        } catch (NumberFormatException e) {
            return false;
        }
    }

    /**
     * 判断字符串是否是浮点数
     */
    public static boolean isDouble(String value) {
        try {
            Double.parseDouble(value);
            return value.contains(".");
        } catch (NumberFormatException e) {
            return false;
        }
    }

    /**
     * 判断String型字符长度不能大于20位
     */
    public static boolean checkLength20(String value) {
        if (isEmpty(value)) {
            return false;
        } else {
            return value.trim().length() <= 20 && value.trim().length() >= 1;
        }
    }

    /**
     * 判断String型字符长度不能大于50位
     */
    public static boolean checkLength50(String value) {
        if (isEmpty(value)) {
            return false;
        } else {
            return value.trim().length() <= 50 && value.trim().length() >= 1;
        }
    }

    public static boolean checkLength11(String value) {
        if (isEmpty(value)) {
            return false;
        } else {
            return value.trim().length() <= 11 && value.trim().length() >= 1;
        }
    }

    public static boolean checkLength6(String value) {
        if (isEmpty(value)) {
            return false;
        } else {
            return value.trim().length() <= 6 && value.trim().length() >= 1;
        }
    }

    public static boolean AZ09(String str) {
        String regex = "^[A-Z0-9]+$";
        return match(regex, str);
    }

    public static boolean AZ09PointLine(String str) {
        String regex = "^[A-Z0-9.-]+$";
        return match(regex, str);
    }

    public static boolean checkSupplierNo(String str) {
        String regex = "^[A-Z]{1}[0-9]{4}$";
        return match(regex, str);
    }

    public static boolean checkLongitudeOrLatitude(String str) {
        String regex = "^[0-9]{1,4}(.[0-9]{0,8})?$";
        return match(regex, str);
    }

    public static boolean isBirthday(String str) {
        String regex = "^[0-9]{4}-[0-9]{2}-[0-9]{2}$";
        return match(regex, str);
    }

    public static boolean checkElement(String str) {
        String regex = "^商品编码：.+\\n+商品描述：.+\\n+申报要素：.+$";
        return match(regex, str);
    }

    /**
     * 验证邮箱
     *
     * @param str
     * @return 如果是符合的字符串, 返回 <b>true </b>,否则为 <b>false </b>
     */
    public static boolean isEmail(String str) {
        String regex = "^([\\w-\\.]+)@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.)|(([\\w-]+\\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$";
        return match(regex, str);
    }

    /**
     * 验证IP地址
     *
     * @param str
     * @return 如果是符合格式的字符串, 返回 <b>true </b>,否则为 <b>false </b>
     */
    public static boolean isIP(String str) {
        String num = "(25[0-5]|2[0-4]\\d|[0-1]\\d{2}|[1-9]?\\d)";
        String regex = "^" + num + "\\." + num + "\\." + num + "\\." + num + "$";
        return match(regex, str);
    }

    /**
     * 验证网址Url
     *
     * @param str
     * @return 如果是符合格式的字符串, 返回 <b>true </b>,否则为 <b>false </b>
     */
    public static boolean IsUrl(String str) {
        String regex = "http(s)?://([\\w-]+\\.)+[\\w-]+(/[\\w- ./?%&=]*)?";
        return match(regex, str);
    }

    /**
     * 验证联系方式
     *
     * @param str /(^0[1-9]{1}\d{9,10}$)|(^1[3,5,8]\d{9}$)/g
     * @return 如果是符合格式的字符串, 返回 <b>true </b>,否则为 <b>false </b>
     */
    public static boolean IsPhone(String str) {
        boolean flag = false;
        String regex = "^0[1-9]{1}\\d{9,10}$";
        String regex2 = "^1[3,5,8]\\d{9}$";
        if (match(regex, str) || match(regex2, str)) {
            flag = true;
        }
        return flag;
    }

    /**
     * 验证电话号码
     *
     * @param str
     * @return 如果是符合格式的字符串, 返回 <b>true </b>,否则为 <b>false </b>
     */
    public static boolean IsTelephone(String str) {
        String regex = "^(\\d{3,4}-)?\\d{6,8}$";
        return match(regex, str);
    }

    /**
     * 验证输入密码条件(字符与数据同时出现)
     *
     * @param str
     * @return 如果是符合格式的字符串, 返回 <b>true </b>,否则为 <b>false </b>
     */
    public static boolean IsPassword(String str) {
        String regex = "[A-Za-z]+[0-9]";
        return match(regex, str);
    }

    /**
     * 验证输入密码长度 (6-18位)
     *
     * @param str
     * @return 如果是符合格式的字符串, 返回 <b>true </b>,否则为 <b>false </b>
     */
    public static boolean IsPasswLength(String str) {
        String regex = "^\\d{6,18}$";
        return match(regex, str);
    }

    /**
     * 验证输入邮政编号
     *
     * @param str
     * @return 如果是符合格式的字符串, 返回 <b>true </b>,否则为 <b>false </b>
     */
    public static boolean IsPostalcode(String str) {
        String regex = "^\\d{6}$";
        return match(regex, str);
    }

    /**
     * 验证输入手机号码
     *
     * @param str
     * @return 如果是符合格式的字符串, 返回 <b>true </b>,否则为 <b>false </b>
     */
    public static boolean IsHandset(String str) {
        String regex = "^[1]+[3,5]+\\d{9}$";
        return match(regex, str);
    }

    /**
     * 验证输入身份证号
     *
     * @param str
     * @return 如果是符合格式的字符串, 返回 <b>true </b>,否则为 <b>false </b>
     */
    public static boolean IsIDcard(String str) {
        String regex = "(^\\d{18}$)|(^\\d{15}$)";
        return match(regex, str);
    }

    /**
     * 验证输入两位小数
     *
     * @param str
     * @return 如果是符合格式的字符串, 返回 <b>true </b>,否则为 <b>false </b>
     */
    public static boolean IsDecimal(String str) {
        String regex = "^[0-9]+(.[0-9]{2})?$";
        return match(regex, str);
    }

    /**
     * 验证输入一年的12个月
     *
     * @param str
     * @return 如果是符合格式的字符串, 返回 <b>true </b>,否则为 <b>false </b>
     */
    public static boolean IsMonth(String str) {
        String regex = "^(0?[[1-9]|1[0-2])$";
        return match(regex, str);
    }

    /**
     * 验证输入一个月的31天
     *
     * @param str
     * @return 如果是符合格式的字符串, 返回 <b>true </b>,否则为 <b>false </b>
     */
    public static boolean IsDay(String str) {
        String regex = "^((0?[1-9])|((1|2)[0-9])|30|31)$";
        return match(regex, str);
    }

    /**
     * 验证日期时间
     *
     * @param str
     * @return 如果是符合网址格式的字符串, 返回 <b>true </b>,否则为 <b>false </b>
     */
    public static boolean isDate(String str) {
        // 严格验证时间格式的(匹配[2002-01-31], [1997-04-30],
        // [2004-01-01])不匹配([2002-01-32], [2003-02-29], [04-01-01])
        // String regex =
        // "^((((19|20)(([02468][048])|([13579][26]))-02-29))|((20[0-9][0-9])|(19[0-9][0-9]))-((((0[1-9])|(1[0-2]))-((0[1-9])|(1\\d)|(2[0-8])))|((((0[13578])|(1[02]))-31)|(((01,3-9])|(1[0-2]))-(29|30)))))$";
        // 没加时间验证的YYYY-MM-DD
        // String regex =
        // "^((((1[6-9]|[2-9]\\d)\\d{2})-(0?[13578]|1[02])-(0?[1-9]|[12]\\d|3[01]))|(((1[6-9]|[2-9]\\d)\\d{2})-(0?[13456789]|1[012])-(0?[1-9]|[12]\\d|30))|(((1[6-9]|[2-9]\\d)\\d{2})-0?2-(0?[1-9]|1\\d|2[0-8]))|(((1[6-9]|[2-9]\\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00))-0?2-29-))$";
        // 加了时间验证的YYYY-MM-DD 00:00:00
        String regex = "^((((1[6-9]|[2-9]\\d)\\d{2})-(0?[13578]|1[02])-(0?[1-9]|[12]\\d|3[01]))|(((1[6-9]|[2-9]\\d)\\d{2})-(0?[13456789]|1[012])-(0?[1-9]|[12]\\d|30))|(((1[6-9]|[2-9]\\d)\\d{2})-0?2-(0?[1-9]|1\\d|2[0-8]))|(((1[6-9]|[2-9]\\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00))-0?2-29-)) (20|21|22|23|[0-1]?\\d):[0-5]?\\d:[0-5]?\\d$";
        return match(regex, str);
    }

    /**
     * 验证数字输入
     *
     * @param str
     * @return 如果是符合格式的字符串, 返回 <b>true </b>,否则为 <b>false </b>
     */
    public static boolean IsNumber(String str) {
        String regex = "^[0-9]*$";
        return match(regex, str);
    }

    /**
     * 验证非零的正整数
     *
     * @param str
     * @return 如果是符合格式的字符串, 返回 <b>true </b>,否则为 <b>false </b>
     */
    public static boolean IsIntNumber(String str) {
        String regex = "^\\+?[1-9][0-9]*$";
        return match(regex, str);
    }

    /**
     * 验证大写字母
     *
     * @param str
     * @return 如果是符合格式的字符串, 返回 <b>true </b>,否则为 <b>false </b>
     */
    public static boolean IsUpChar(String str) {
        String regex = "^[A-Z]+$";
        return match(regex, str);
    }

    /**
     * 验证小写字母
     *
     * @param str
     * @return 如果是符合格式的字符串, 返回 <b>true </b>,否则为 <b>false </b>
     */
    public static boolean IsLowChar(String str) {
        String regex = "^[a-z]+$";
        return match(regex, str);
    }

    /**
     * 验证验证输入字母
     *
     * @param str
     * @return 如果是符合格式的字符串, 返回 <b>true </b>,否则为 <b>false </b>
     */
    public static boolean IsLetter(String str) {
        String regex = "^[A-Za-z]+$";
        return match(regex, str);
    }

    /**
     * 验证验证输入汉字
     *
     * @param str
     * @return 如果是符合格式的字符串, 返回 <b>true </b>,否则为 <b>false </b>
     */
    public static boolean IsChinese(String str) {
        String regex = "^[\u4e00-\u9fa5]$";
        return match(regex, str);
    }

    /**
     * 验证验证输入英文
     *
     * @param str
     * @return 如果是符合格式的字符串, 返回 <b>true </b>,否则为 <b>false </b>
     */
    public static boolean IsEngLish(String str) {
        String regex = "^[\u4e00-\u9fa5],{0,}$";
        return !match(regex, str);
    }

    /**
     * 验证验证输入字符串
     *
     * @param str
     * @return 如果是符合格式的字符串, 返回 <b>true </b>,否则为 <b>false </b>
     */
    public static boolean IsLength(String str) {
        String regex = "^.{8,}$";
        return match(regex, str);
    }

    /**
     * @param regex 正则表达式字符串
     * @param str   要匹配的字符串
     * @return 如果str 符合 regex的正则表达式格式,返回true, 否则返回 false;
     */
    private static boolean match(String regex, String str) {
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(str);
        return matcher.matches();
    }

    /**
     * 查询在excel中是否存在相同的值
     *
     * @param value  待查询的值
     * @param values 待查询字段拼接集合
     * @return true则存在相同的，false则不存在相同的值
     */
    public static boolean hasSame(String value, String values) {
        boolean hasSame = false;
        int count = NUM_ZERO;
        String valueSearch = "|" + value + "|";
        while (values.indexOf(valueSearch) != NUM_MINUS_ONE) {
            values = values.substring(values.indexOf(valueSearch) + valueSearch.length());
            count++;
        }
        if (count > NUM_ONE) {
            hasSame = true;
        }
        return hasSame;
    }

    /**
     * 判断字符串长度 value:字符串 checkLength:长度 mustFlag是否必须 返回值"备注不能为空   备注超过256位"
     */
    public static String checkStrLengthMsg(String msgName, String value, int checkLength, boolean mustFlag) {
        String checkMsg = "";

        if (mustFlag && StringUtils.isEmpty(value)) {
            checkMsg = msgName + "不能为空；";
        } else if (!mustFlag && StringUtils.isEmpty(value)) {

        } else {
            int length = value.length();
            if (length > checkLength) {
                checkMsg = msgName + "超过" + checkLength + "位；";
            }
        }

        return checkMsg;
    }

    /**
     * 比较两个Integer类型是否相等,相等返回true不等返回false
     *
     * @param num1
     * @param num2
     * @return
     */
    public static boolean intEqual(Integer num1, Integer num2) {
        if (num1 == null && num2 == null) {
            return true;
        } else if ((num1 == null && num2 != null) || (num1 != null && num2 == null)) {
            return false;
        } else {
            return num1.compareTo(num2) == 0;
        }

    }

    public static Integer objToInt(Object obj) {
        if (obj == null) {
            return null;
        } else {
            return Integer.parseInt(String.valueOf(obj));
        }

    }

    public static List<String> strSptoList(String str) {
        List<String> result = Lists.newArrayList();
        if (isEmpty(str)) {
            return result;
        } else {
            String[] strList = str.split(",");

            for (String strEach : strList) {
                if (isNotEmpty(strEach)) {
                    result.add(strEach);
                }
            }
        }
        return result;
    }

    public static List<Integer> strSptoListInt(String str) {
        List<Integer> result = Lists.newArrayList();
        if (isEmpty(str)) {
            return result;
        } else {
            String[] strList = str.split(",");

            for (String strEach : strList) {
                if (isNotEmpty(strEach)) {
                    result.add(Integer.parseInt(strEach));
                }
            }
        }
        return result;
    }

    public static List<String> strSptoListTrimAll(String str, String rex) {
        List<String> result = Lists.newArrayList();
        if (isEmpty(str)) {
            return result;
        } else {
            String[] strList = str.split(rex);
            for (String strEach : strList) {
                if (isNotEmpty(strEach)) {
                    result.add(trimStringAll(strEach));
                }
            }
        }
        return result;
    }

    //字符串拼接 如果为空 不拼接
    public static void strBuAppend(StringBuilder sb, String par) {
        if (par != null) {
            sb.append(par);
        }
    }

    public static List<Integer> listStrToInt(List<String> strList) {
        List<Integer> result = Lists.newArrayList();
        if (!CollectionUtils.isEmpty(strList)) {
            for (String str : strList) {
                if (isNotBlank(str)) {
                    result.add(Integer.parseInt(str));
                }
            }
        }
        return result;
    }

    public static List<String> listIntToStr(List<Integer> intList) {
        List<String> result = Lists.newArrayList();
        if (!CollectionUtils.isEmpty(intList)) {
            for (Integer intst : intList) {
                if (intst != null) {
                    result.add(String.valueOf(intst));
                }
            }
        }
        return result;
    }

    /**
     * 从session中获取当前页查询条件，repage时重新按条件查询列表页
     *
     * @param request
     * @param attributeName
     * @return
     */
    public static boolean checkSessionNotNull(HttpServletRequest request, String attributeName) {
        boolean result = false;
        result = request.getParameter("repage") != null && request.getSession().getAttribute(attributeName) != null;
        return result;
    }

    // 3. 检查字符串重复出现的词
    //
    // private void btnWord_Click(object sender, EventArgs e)
    // {
    // System.Text.RegularExpressions.MatchCollection matches =
    // System.Text.RegularExpressions.Regex.Matches(label1.Text,
    //
    // @"\b(?<word>\w+)\s+(\k<word>)\b",
    // System.Text.RegularExpressions.RegexOptions.Compiled |
    // System.Text.RegularExpressions.RegexOptions.IgnoreCase);
    // if (matches.Count != 0)
    // {
    // foreach (System.Text.RegularExpressions.Match match in matches)
    // {
    // string word = match.Groups["word"].Value;
    // MessageBox.Show(word.ToString(),"英文单词");
    // }
    // }
    // else { MessageBox.Show("没有重复的单词"); }
    //
    //
    // }
    //
    // 4. 替换字符串
    //
    // private void button1_Click(object sender, EventArgs e)
    // {
    //
    // string strResult =
    // System.Text.RegularExpressions.Regex.Replace(textBox1.Text,
    // @"[A-Za-z]\*?", textBox2.Text);
    // MessageBox.Show("替换前字符:" + "\n" + textBox1.Text + "\n" + "替换的字符:" + "\n"
    // + textBox2.Text + "\n" +
    //
    // "替换后的字符:" + "\n" + strResult,"替换");
    //
    // }
    //
    // 5. 拆分字符串
    //
    // private void button1_Click(object sender, EventArgs e)
    // {
    // //实例: 甲025-8343243乙0755-2228382丙029-32983298389289328932893289丁
    // foreach (string s in
    // System.Text.RegularExpressions.Regex.Split(textBox1.Text,@"\d{3,4}-\d*"))
    // {
    // textBox2.Text+=s; //依次输出 "甲乙丙丁"
    // }
    //
    // }

    /**
     * 文件地址分割
     * Param path 路径
     * return List<String>
     */
    public static List<String> pathSplit(String path) {
        List<String> list = new ArrayList<String>();
        if (StringUtils.isEmpty(path)) {
            return list;
        }
        String[] strArr = path.split("\\|");

        for (String str : strArr) {
            list.add(str);
        }
        return list;
    }

    @SuppressWarnings("unchecked")
    public static void setApiErrInfo(Map resultMap) {
        resultMap.put("flag", "1");
        resultMap.put("msg", "接口访问失败");
    }

    public static Map<String, String> getMapByResultI(int i) {
        Map<String, String> result = Maps.newHashMap();

        if (i > 0) {
            result.put("flag", "0");
            result.put("msg", "更新成功");
        } else {
            result.put("flag", "1");
            result.put("msg", "更新失败");
        }
        return result;
    }

    // 根据操作条数 返回操作信息
    public static Map<String, String> getMapByResultISucMsg(int i, String successMs) {
        Map<String, String> result = Maps.newHashMap();

        if (i > 0) {
            result.put("flag", "0");
            result.put("msg", successMs);
        } else {
            result.put("flag", "1");
            // TODO zhangyj
//			result.put("msg", ConstantErpweb.MSG_DATA_CHANGE);
        }
        return result;
    }

    // 根据操作条数 返回操作信息
    public static Map<String, String> getMapByResultISucMsg(int i, String successMs, String failMs) {
        Map<String, String> result = Maps.newHashMap();

        if (i > 0) {
            result.put("flag", "0");
            result.put("msg", successMs);
        } else {
            result.put("flag", "1");
            result.put("msg", failMs);
        }
        return result;
    }

    // 根据操作条数 返回操作信息
    public static Map<String, Object> getMapByResultISucMsgObj(int i, String successMs) {
        Map<String, Object> result = Maps.newHashMap();

        if (i > 0) {
            result.put("flag", "0");
            result.put("msg", successMs);
        } else {
            result.put("flag", "1");
            // TODO zhangyj
//			result.put("msg", ConstantErpweb.MSG_DATA_CHANGE);
        }
        return result;
    }

    // 根据操作条数 返回操作信息
    public static Map<String, Object> getMapByResultISucMsgObj(int i, String successMs, String failMs) {
        Map<String, Object> result = Maps.newHashMap();

        if (i > 0) {
            result.put("flag", "0");
            result.put("msg", successMs);
        } else {
            result.put("flag", "1");
            result.put("msg", failMs);
        }
        return result;
    }

    // 根据对象判断 返回值 为空 正确
    public static <T> Map<String, String> getMapByResultEntryNull(T entry) {
        Map<String, String> result = Maps.newHashMap();
        if (entry == null) {
            result.put("flag", "0");
        } else {
            result.put("flag", "1");
        }
        return result;
    }

    public static <T> Boolean getMapByResultEntryNullFlag(T entry) {
        return entry == null;
    }

    public static String bigToUsDol(BigDecimal inBig) {
        String Str = null;
        if (inBig != null) {
            NumberFormat currency = NumberFormat.getCurrencyInstance(Locale.US);
            currency.setMinimumFractionDigits(2);//设置数的小数部分所允许的最小位数(如果不足后面补0)
            currency.setMaximumFractionDigits(4);//设置数的小数部分所允许的最大位数(如果超过会四舍五入)
            Str = currency.format(inBig);//$0.01
        }
        return Str;
    }

    public static String bigToUsDolWithCountry(BigDecimal inBig) {
        String Str = null;
        if (inBig != null) {
            NumberFormat currency = NumberFormat.getCurrencyInstance(Locale.US);
            currency.setMinimumFractionDigits(2);//设置数的小数部分所允许的最小位数(如果不足后面补0)
            currency.setMaximumFractionDigits(4);//设置数的小数部分所允许的最大位数(如果超过会四舍五入)
            Str = currency.format(inBig);//￥12,343,171.60
            Str = "US" + Str;

        }
        return Str;
    }

    //Bigdecimal 相加
    public static BigDecimal bigListAdd(BigDecimal... parList) {
        BigDecimal result = BigDecimal.ZERO;
        Boolean nullflag = true;
        for (BigDecimal par : parList) {
            if (par != null) {
                nullflag = false;
                result = result.add(par);
            }
        }
        if (nullflag) {
            result = null;
        }
        return result;
    }

    public static BigDecimal decimalUpBy2_100(BigDecimal par) {
        BigDecimal result = BigDecimal.ZERO;
        if (par != null) {
            if (par.compareTo(new BigDecimal("2")) < 0) {
                result = par.setScale(3, BigDecimal.ROUND_HALF_UP);
            } else if (par.compareTo(new BigDecimal("100")) < 0) {
                result = par.setScale(2, BigDecimal.ROUND_HALF_UP);
            } else {
                result = par.setScale(1, BigDecimal.ROUND_HALF_UP);
            }
        }
        return result;
    }

    /**
     * @param price 价格(未税)
     * @param rate  税率 16
     * @return = price * ( 1+ 16/100)
     */
    public static BigDecimal decimalToTax(BigDecimal price, BigDecimal rate) {
        BigDecimal result = null;
        if (price != null && rate != null) {
            result = price.multiply(BigDecimal.ONE.add(rate.divide(new BigDecimal("100"))));
            result.setScale(3, BigDecimal.ROUND_HALF_UP);
        }
        return result;
    }

    public static List<String> strSptoList(String str, String rex) {
        List<String> result = Lists.newArrayList();
        if (isEmpty(str)) {
            return result;
        } else {
            String[] strList = str.split(rex);
            for (String strEach : strList) {
                if (isNotEmpty(strEach)) {
                    result.add(strEach);
                }
            }
        }
        return result;
    }

    //两个string拼接,拼接字符"/"
    public static Boolean inStrList(String valueA, String valueB) {
        if (isEmpty(valueA) || isEmpty(valueB)) {
            return false;
        } else {
            List<String> listStr = strSptoList(valueB);
            return listStr.contains(valueA);
        }
    }

    //添加百分号
    public static String concatPer(String strBig) {
        String result = "";
        if (isNotEmpty(strBig)) {
            result = strBig + "%";
        }
        return result;
    }

    //添加百分号并 乘以100
    public static String concatHunPer(String strBig) {
        String result = "";
        if (isNotEmpty(strBig)) {

            if (Double.valueOf(strBig).compareTo(0d) == 0) {
                result = "0";
            } else {
                BigDecimal big = new BigDecimal(strBig).multiply(new BigDecimal("100"));
                result = big.stripTrailingZeros().toPlainString();
            }
            result = result + "%";
        }
        return result;
    }

    //两个string拼接,拼接字符"/"
    public static String concatSla(String valueA, String valueB) {
        if (isEmpty(valueA) && isEmpty(valueB)) {
            return "";
        } else if (isEmpty(valueA)) {
            return valueB;
        } else if (isEmpty(valueB)) {
            return valueA;
        } else {
            return valueA + "/" + valueB;
        }
    }

    //去除多余0 并去除科学技术法显示
    public static String showBigdecimal(String strBig) {
        String result = "";
        try {
            if (isNotEmpty(strBig)) {
                if (Double.valueOf(strBig).compareTo(0d) == 0) {
                    result = "0";
                } else {
                    BigDecimal big = new BigDecimal(strBig);
                    result = big.stripTrailingZeros().toPlainString();
                }
            }
        } catch (Exception e) {
            System.out.println(strBig);
        }

        return result;
    }

    //去除多余0 并去除科学技术法显示
    public static String showBigdecimalFull2(String strBig) {
        String result = "";
        try {
            if (isNotEmpty(strBig)) {
                if (Double.valueOf(strBig).compareTo(0d) == 0) {
                    result = "0.00";
                } else {
                    BigDecimal big = new BigDecimal(strBig);
                    result = new DecimalFormat("#0.00###############").format(big);
                }
            }
        } catch (Exception e) {
            System.out.println(strBig);
        }

        return result;
    }

    //去除多余0 并去除科学技术法显示
    public static String showBigdecimalFull3(String strBig) {
        String result = "";
        try {
            if (isNotEmpty(strBig)) {
                if (Double.valueOf(strBig).compareTo(0d) == 0) {
                    result = "0.000";
                } else {
                    BigDecimal big = new BigDecimal(strBig);
                    result = new DecimalFormat("#0.000###############").format(big);
                }
            }
        } catch (Exception e) {
            System.out.println(strBig);
        }

        return result;
    }

    //显示Bigdecimal(保留n位小数并四舍五入)
    public static String showDecimalRHUN(String strBig, int n) {
        String result = "";
        if (isNotEmpty(strBig)) {
            BigDecimal big = new BigDecimal(strBig);
            big = big.setScale(n, BigDecimal.ROUND_HALF_UP);
            result = big.stripTrailingZeros().toPlainString();
        }
        return result;
    }

    //显示Bigdecimal(保留三位小数并向上进一)
    public static String showDecimalRU3(String strBig) {
        String result = "";
        if (isNotEmpty(strBig)) {
            BigDecimal big = new BigDecimal(strBig);
            big = big.setScale(3, BigDecimal.ROUND_UP);
            result = big.stripTrailingZeros().toPlainString();
        }
        return result;
    }

    //显示Bigdecimal(保留两位小数并四舍五入)
    public static String showDecimalRHU2(String strBig) {
        String result = "";
        if (isNotEmpty(strBig)) {
            BigDecimal big = new BigDecimal(strBig);
            big = big.setScale(2, BigDecimal.ROUND_HALF_UP);
            result = big.stripTrailingZeros().toPlainString();
        }
        return result;
    }

    //显示Bigdecimal(保留三位小数并四舍五入)
    public static String showDecimalRHU3(String strBig) {
        String result = "";
        if (isNotEmpty(strBig)) {
            BigDecimal big = new BigDecimal(strBig);
            big = big.setScale(3, BigDecimal.ROUND_HALF_UP);
            result = big.stripTrailingZeros().toPlainString();
        }
        return result;
    }

    //显示Bigdecimal(保留四位小数并四舍五入)
    public static String showDecimalRHU4(String strBig) {
        String result = "";
        if (isNotEmpty(strBig)) {
            BigDecimal big = new BigDecimal(strBig);
            big = big.setScale(4, BigDecimal.ROUND_HALF_UP);
            result = big.stripTrailingZeros().toPlainString();
        }
        return result;
    }

    //显示Bigdecimal(保留四位小数并四舍五入)
    public static String showDecimalRHU5(String strBig) {
        String result = "";
        if (isNotEmpty(strBig)) {
            BigDecimal big = new BigDecimal(strBig);
            big = big.setScale(5, BigDecimal.ROUND_HALF_UP);
            result = big.stripTrailingZeros().toPlainString();
        }
        return result;
    }

    //系统:显示箱数(保留整数位 直接进1)
    public static String showBoxNum(String strBig) {
        String result = "";
        if (isNotEmpty(strBig)) {
            BigDecimal big = new BigDecimal(strBig);
            big = big.setScale(0, BigDecimal.ROUND_UP);
            result = big.stripTrailingZeros().toPlainString();
        }
        return result;
    }

    //系统:显示体积重量(保留三位小数直接进1)
    public static String showVolume(String strBig) {
        String result = "";
        if (isNotEmpty(strBig)) {
            BigDecimal big = new BigDecimal(strBig);
            big = big.setScale(3, BigDecimal.ROUND_UP);
            result = big.stripTrailingZeros().toPlainString();
        }
        return result;
    }

    /**
     * 字符串长度（每个中文字符长度为2）
     *
     * @param value
     * @return
     */
    public static int chineseLength(String value) {
        int valueLength = 0;
        if (isEmpty(value)) {
            return valueLength;
        }
        String chinese = "[\u0391-\uFFE5]";
        /* 获取字段值的长度，如果含中文字符，则每个中文字符长度为2，否则为1 */
        for (int i = 0; i < value.length(); i++) {
            /* 获取一个字符 */
            String temp = value.substring(i, i + 1);
            /* 判断是否为中文字符 */
            if (temp.matches(chinese)) {
                /* 中文字符长度为2 */
                valueLength += 2;
            } else {
                /* 其他字符长度为1 */
                valueLength += 1;
            }
        }
        return valueLength;
    }

    public static String findMethPro(String value) {
        if (value.startsWith("get")) {
            String a = lowerCase(value.substring(3, 4));
            String b = value.substring(4);

            return a + b;
        } else {
            return value;
        }
    }

    /**
     * * 判断一个对象是否为空
     *
     * @param object Object
     * @return true：为空 false：非空
     */
    public static boolean isNull(Object object) {
        return object == null;
    }

    /**
     * * 判断一个对象是否非空
     *
     * @param object Object
     * @return true：非空 false：空
     */
    public static boolean isNotNull(Object object) {
        return !isNull(object);
    }

    public static void main(String[] args) {

        String a = "getProId";
        System.out.println(findMethPro(a));
    }

    /**
     * 是否包含字符串
     *
     * @param str  验证字符串
     * @param strs 字符串组
     * @return 包含返回true
     */
    public static boolean inStringIgnoreCase(String str, String... strs) {
        if (str != null && strs != null) {
            for (String s : strs) {
                if (str.equalsIgnoreCase(trim(s))) {
                    return true;
                }
            }
        }
        return false;
    }

    /**
     * 获取参数不为空值
     *
     * @param value defaultValue 要判断的value
     * @return value 返回值
     */
    public static <T> T nvl(T value, T defaultValue) {
        return value != null ? value : defaultValue;
    }

    public static boolean equalsAny(CharSequence string, CharSequence... searchStrings) {
        if (ArrayUtils.isNotEmpty(searchStrings)) {
            CharSequence[] var2 = searchStrings;
            int var3 = searchStrings.length;

            for (int var4 = 0; var4 < var3; ++var4) {
                CharSequence next = var2[var4];
                if (equals(string, next)) {
                    return true;
                }
            }
        }

        return false;
    }

    /**
     * 将下划线大写方式命名的字符串转换为驼峰式。如果转换前的下划线大写方式命名的字符串为空，则返回空字符串。 例如：HELLO_WORLD->HelloWorld
     *
     * @param name 转换前的下划线大写方式命名的字符串
     * @return 转换后的驼峰式命名的字符串
     */
    public static String convertToCamelCase(String name) {
        StringBuilder result = new StringBuilder();
        // 快速检查
        if (name == null || name.isEmpty()) {
            // 没必要转换
            return "";
        } else if (!name.contains("_")) {
            // 不含下划线，仅将首字母大写
            return name.substring(0, 1).toUpperCase() + name.substring(1);
        }
        // 用下划线将原始字符串分割
        String[] camels = name.split("_");
        for (String camel : camels) {
            // 跳过原始字符串中开头、结尾的下换线或双重下划线
            if (camel.isEmpty()) {
                continue;
            }
            // 首字母大写
            result.append(camel.substring(0, 1).toUpperCase());
            result.append(camel.substring(1).toLowerCase());
        }
        return result.toString();
    }

    /**
     * 去除空格后判断是否为空
     * @param str
     * @return
     */
    public static boolean trimIsEmpty(String str) {
        if (str == null) {
            return true;
        }
        return isEmpty(str.trim());
    }
}
