package com.dxhy.portrait.business.util;

import org.apache.commons.lang.StringUtils;

/**
 *
 * @author dxhy
 */
public class CompareNameUtils {

    /**
     * 购方名称、原名称与机构对比
     * 
     * @param gfName
     * @param orgName
     * @param extfl
     * @return
     */
    public static Boolean compareName(String gfName, String orgName, String extfl) {
        if (StringUtils.isEmpty(gfName)) {
            return false;
        }
        if (StringUtils.isEmpty(extfl) && StringUtils.isEmpty(orgName)) {
            return false;
        }
        gfName = changeBrackets(gfName);
        orgName = changeBrackets(orgName);
        extfl = changeBrackets(extfl);
        if (gfName.equals(orgName) || gfName.equals(extfl)) {
            return true;
        }
        return false;
    }

    /**
     * 购方名称与机构对比
     * 
     * @param gfName
     * @param orgName
     * @return
     */
    public static Boolean compareName(String gfName, String orgName) {
        if (StringUtils.isNotBlank(gfName) && StringUtils.isNotBlank(orgName)
            && changeBrackets(gfName).equals(changeBrackets(orgName))) {
            return true;
        }
        return false;
    }

    /**
     * 统一中英文括号
     * 
     * @param paramString
     * @return
     */
    public static String changeBrackets(String paramString) {
        return paramString.replace("（", "(").replace("(", "(").replace("）", ")").replace(")", ")");
    }

}
