|
@@ -0,0 +1,258 @@
|
|
|
+package com.hrsk.cloud.eg.domain.common;
|
|
|
+
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+
|
|
|
+import java.util.HashSet;
|
|
|
+import java.util.Set;
|
|
|
+import java.util.regex.Matcher;
|
|
|
+import java.util.regex.Pattern;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 复姓工具类
|
|
|
+ */
|
|
|
+public class UserNameUtil {
|
|
|
+
|
|
|
+ public static Set<String> DOUBLE_SURNAME_SET = new HashSet<>();
|
|
|
+
|
|
|
+ static {
|
|
|
+ DOUBLE_SURNAME_SET.add("单于");
|
|
|
+ DOUBLE_SURNAME_SET.add("叱干");
|
|
|
+ DOUBLE_SURNAME_SET.add("叱利");
|
|
|
+ DOUBLE_SURNAME_SET.add("车非");
|
|
|
+ DOUBLE_SURNAME_SET.add("车公");
|
|
|
+ DOUBLE_SURNAME_SET.add("车侯");
|
|
|
+ DOUBLE_SURNAME_SET.add("车长");
|
|
|
+ DOUBLE_SURNAME_SET.add("车绵");
|
|
|
+ DOUBLE_SURNAME_SET.add("独孤");
|
|
|
+ DOUBLE_SURNAME_SET.add("大野");
|
|
|
+ DOUBLE_SURNAME_SET.add("独吉");
|
|
|
+ DOUBLE_SURNAME_SET.add("达奚");
|
|
|
+ DOUBLE_SURNAME_SET.add("达官");
|
|
|
+ DOUBLE_SURNAME_SET.add("达仲");
|
|
|
+ DOUBLE_SURNAME_SET.add("达品");
|
|
|
+ DOUBLE_SURNAME_SET.add("哥舒");
|
|
|
+ DOUBLE_SURNAME_SET.add("哥夜");
|
|
|
+ DOUBLE_SURNAME_SET.add("哥翰");
|
|
|
+ DOUBLE_SURNAME_SET.add("哥汗");
|
|
|
+ DOUBLE_SURNAME_SET.add("赫连");
|
|
|
+ DOUBLE_SURNAME_SET.add("呼延");
|
|
|
+ DOUBLE_SURNAME_SET.add("贺兰");
|
|
|
+ DOUBLE_SURNAME_SET.add("黑齿");
|
|
|
+ DOUBLE_SURNAME_SET.add("斛律");
|
|
|
+ DOUBLE_SURNAME_SET.add("斛粟");
|
|
|
+ DOUBLE_SURNAME_SET.add("贺若");
|
|
|
+ DOUBLE_SURNAME_SET.add("贺奴");
|
|
|
+ DOUBLE_SURNAME_SET.add("贺远");
|
|
|
+ DOUBLE_SURNAME_SET.add("贺元");
|
|
|
+ DOUBLE_SURNAME_SET.add("夹谷");
|
|
|
+ DOUBLE_SURNAME_SET.add("吉胡");
|
|
|
+ DOUBLE_SURNAME_SET.add("吉利");
|
|
|
+ DOUBLE_SURNAME_SET.add("吉家");
|
|
|
+ DOUBLE_SURNAME_SET.add("可频");
|
|
|
+ DOUBLE_SURNAME_SET.add("慕容");
|
|
|
+ DOUBLE_SURNAME_SET.add("万俟");
|
|
|
+ DOUBLE_SURNAME_SET.add("万红");
|
|
|
+ DOUBLE_SURNAME_SET.add("万中");
|
|
|
+ DOUBLE_SURNAME_SET.add("抹捻");
|
|
|
+ DOUBLE_SURNAME_SET.add("纳兰");
|
|
|
+ DOUBLE_SURNAME_SET.add("纳西");
|
|
|
+ DOUBLE_SURNAME_SET.add("纳吉");
|
|
|
+ DOUBLE_SURNAME_SET.add("纳罕");
|
|
|
+ DOUBLE_SURNAME_SET.add("纳塞");
|
|
|
+ DOUBLE_SURNAME_SET.add("纳博");
|
|
|
+ DOUBLE_SURNAME_SET.add("纳称");
|
|
|
+ DOUBLE_SURNAME_SET.add("纳勉");
|
|
|
+ DOUBLE_SURNAME_SET.add("普周");
|
|
|
+ DOUBLE_SURNAME_SET.add("仆固");
|
|
|
+ DOUBLE_SURNAME_SET.add("仆散");
|
|
|
+ DOUBLE_SURNAME_SET.add("蒲察");
|
|
|
+ DOUBLE_SURNAME_SET.add("屈突");
|
|
|
+ DOUBLE_SURNAME_SET.add("屈卢");
|
|
|
+ DOUBLE_SURNAME_SET.add("钳耳");
|
|
|
+ DOUBLE_SURNAME_SET.add("是云");
|
|
|
+ DOUBLE_SURNAME_SET.add("索卢");
|
|
|
+ DOUBLE_SURNAME_SET.add("厍狄");
|
|
|
+ DOUBLE_SURNAME_SET.add("拓跋");
|
|
|
+ DOUBLE_SURNAME_SET.add("同蹄");
|
|
|
+ DOUBLE_SURNAME_SET.add("秃发");
|
|
|
+ DOUBLE_SURNAME_SET.add("完颜");
|
|
|
+ DOUBLE_SURNAME_SET.add("完明");
|
|
|
+ DOUBLE_SURNAME_SET.add("完忠");
|
|
|
+ DOUBLE_SURNAME_SET.add("宇文");
|
|
|
+ DOUBLE_SURNAME_SET.add("尉迟");
|
|
|
+ DOUBLE_SURNAME_SET.add("耶律");
|
|
|
+ DOUBLE_SURNAME_SET.add("耶红");
|
|
|
+ DOUBLE_SURNAME_SET.add("也先");
|
|
|
+ DOUBLE_SURNAME_SET.add("耶鲜");
|
|
|
+ DOUBLE_SURNAME_SET.add("耶闻");
|
|
|
+ DOUBLE_SURNAME_SET.add("长孙");
|
|
|
+ DOUBLE_SURNAME_SET.add("长南");
|
|
|
+ DOUBLE_SURNAME_SET.add("长北");
|
|
|
+ DOUBLE_SURNAME_SET.add("长西");
|
|
|
+ DOUBLE_SURNAME_SET.add("长红");
|
|
|
+ DOUBLE_SURNAME_SET.add("长元");
|
|
|
+ DOUBLE_SURNAME_SET.add("长秋");
|
|
|
+ DOUBLE_SURNAME_SET.add("长寸");
|
|
|
+ DOUBLE_SURNAME_SET.add("长李");
|
|
|
+ DOUBLE_SURNAME_SET.add("长云");
|
|
|
+ DOUBLE_SURNAME_SET.add("闻人");
|
|
|
+ DOUBLE_SURNAME_SET.add("巫马");
|
|
|
+ DOUBLE_SURNAME_SET.add("微生");
|
|
|
+ DOUBLE_SURNAME_SET.add("王孙");
|
|
|
+ DOUBLE_SURNAME_SET.add("无庸");
|
|
|
+ DOUBLE_SURNAME_SET.add("夏侯");
|
|
|
+ DOUBLE_SURNAME_SET.add("西门");
|
|
|
+ DOUBLE_SURNAME_SET.add("信平");
|
|
|
+ DOUBLE_SURNAME_SET.add("鲜于");
|
|
|
+ DOUBLE_SURNAME_SET.add("轩辕");
|
|
|
+ DOUBLE_SURNAME_SET.add("相里");
|
|
|
+ DOUBLE_SURNAME_SET.add("新垣");
|
|
|
+ DOUBLE_SURNAME_SET.add("徐离");
|
|
|
+ DOUBLE_SURNAME_SET.add("羊舌");
|
|
|
+ DOUBLE_SURNAME_SET.add("羊角");
|
|
|
+ DOUBLE_SURNAME_SET.add("延陵");
|
|
|
+ DOUBLE_SURNAME_SET.add("於陵");
|
|
|
+ DOUBLE_SURNAME_SET.add("伊祁");
|
|
|
+ DOUBLE_SURNAME_SET.add("吾丘");
|
|
|
+ DOUBLE_SURNAME_SET.add("乐正");
|
|
|
+ DOUBLE_SURNAME_SET.add("只斤");
|
|
|
+ DOUBLE_SURNAME_SET.add("诸葛");
|
|
|
+ DOUBLE_SURNAME_SET.add("颛孙");
|
|
|
+ DOUBLE_SURNAME_SET.add("仲孙");
|
|
|
+ DOUBLE_SURNAME_SET.add("仲长");
|
|
|
+ DOUBLE_SURNAME_SET.add("钟离");
|
|
|
+ DOUBLE_SURNAME_SET.add("宗政");
|
|
|
+ DOUBLE_SURNAME_SET.add("主父");
|
|
|
+ DOUBLE_SURNAME_SET.add("中叔");
|
|
|
+ DOUBLE_SURNAME_SET.add("左人");
|
|
|
+ DOUBLE_SURNAME_SET.add("左丘");
|
|
|
+ DOUBLE_SURNAME_SET.add("宰父");
|
|
|
+ DOUBLE_SURNAME_SET.add("长儿");
|
|
|
+ DOUBLE_SURNAME_SET.add("仉督");
|
|
|
+ DOUBLE_SURNAME_SET.add("百里");
|
|
|
+ DOUBLE_SURNAME_SET.add("北堂");
|
|
|
+ DOUBLE_SURNAME_SET.add("北野");
|
|
|
+ DOUBLE_SURNAME_SET.add("北宫");
|
|
|
+ DOUBLE_SURNAME_SET.add("辟闾");
|
|
|
+ DOUBLE_SURNAME_SET.add("孛尔");
|
|
|
+ DOUBLE_SURNAME_SET.add("淳于");
|
|
|
+ DOUBLE_SURNAME_SET.add("成公");
|
|
|
+ DOUBLE_SURNAME_SET.add("陈生");
|
|
|
+ DOUBLE_SURNAME_SET.add("褚师");
|
|
|
+ DOUBLE_SURNAME_SET.add("端木");
|
|
|
+ DOUBLE_SURNAME_SET.add("东方");
|
|
|
+ DOUBLE_SURNAME_SET.add("东郭");
|
|
|
+ DOUBLE_SURNAME_SET.add("东野");
|
|
|
+ DOUBLE_SURNAME_SET.add("东门");
|
|
|
+ DOUBLE_SURNAME_SET.add("第五");
|
|
|
+ DOUBLE_SURNAME_SET.add("大狐");
|
|
|
+ DOUBLE_SURNAME_SET.add("段干");
|
|
|
+ DOUBLE_SURNAME_SET.add("段阳");
|
|
|
+ DOUBLE_SURNAME_SET.add("带曰");
|
|
|
+ DOUBLE_SURNAME_SET.add("第二");
|
|
|
+ DOUBLE_SURNAME_SET.add("东宫");
|
|
|
+ DOUBLE_SURNAME_SET.add("公孙");
|
|
|
+ DOUBLE_SURNAME_SET.add("公冶");
|
|
|
+ DOUBLE_SURNAME_SET.add("公羊");
|
|
|
+ DOUBLE_SURNAME_SET.add("公良");
|
|
|
+ DOUBLE_SURNAME_SET.add("公西");
|
|
|
+ DOUBLE_SURNAME_SET.add("公孟");
|
|
|
+ DOUBLE_SURNAME_SET.add("高堂");
|
|
|
+ DOUBLE_SURNAME_SET.add("高阳");
|
|
|
+ DOUBLE_SURNAME_SET.add("公析");
|
|
|
+ DOUBLE_SURNAME_SET.add("公肩");
|
|
|
+ DOUBLE_SURNAME_SET.add("公坚");
|
|
|
+ DOUBLE_SURNAME_SET.add("郭公");
|
|
|
+ DOUBLE_SURNAME_SET.add("谷梁");
|
|
|
+ DOUBLE_SURNAME_SET.add("毌将");
|
|
|
+ DOUBLE_SURNAME_SET.add("公乘");
|
|
|
+ DOUBLE_SURNAME_SET.add("毌丘");
|
|
|
+ DOUBLE_SURNAME_SET.add("公户");
|
|
|
+ DOUBLE_SURNAME_SET.add("公广");
|
|
|
+ DOUBLE_SURNAME_SET.add("公仪");
|
|
|
+ DOUBLE_SURNAME_SET.add("公祖");
|
|
|
+ DOUBLE_SURNAME_SET.add("皇甫");
|
|
|
+ DOUBLE_SURNAME_SET.add("黄龙");
|
|
|
+ DOUBLE_SURNAME_SET.add("胡母");
|
|
|
+ DOUBLE_SURNAME_SET.add("何阳");
|
|
|
+ DOUBLE_SURNAME_SET.add("夹谷");
|
|
|
+ DOUBLE_SURNAME_SET.add("九方");
|
|
|
+ DOUBLE_SURNAME_SET.add("即墨");
|
|
|
+ DOUBLE_SURNAME_SET.add("梁丘");
|
|
|
+ DOUBLE_SURNAME_SET.add("闾丘");
|
|
|
+ DOUBLE_SURNAME_SET.add("洛阳");
|
|
|
+ DOUBLE_SURNAME_SET.add("陵尹");
|
|
|
+ DOUBLE_SURNAME_SET.add("冷富");
|
|
|
+ DOUBLE_SURNAME_SET.add("龙丘");
|
|
|
+ DOUBLE_SURNAME_SET.add("令狐");
|
|
|
+ DOUBLE_SURNAME_SET.add("林彭");
|
|
|
+ DOUBLE_SURNAME_SET.add("南宫");
|
|
|
+ DOUBLE_SURNAME_SET.add("南郭");
|
|
|
+ DOUBLE_SURNAME_SET.add("女娲");
|
|
|
+ DOUBLE_SURNAME_SET.add("南伯");
|
|
|
+ DOUBLE_SURNAME_SET.add("南容");
|
|
|
+ DOUBLE_SURNAME_SET.add("南门");
|
|
|
+ DOUBLE_SURNAME_SET.add("南野");
|
|
|
+ DOUBLE_SURNAME_SET.add("欧阳");
|
|
|
+ DOUBLE_SURNAME_SET.add("欧侯");
|
|
|
+ DOUBLE_SURNAME_SET.add("濮阳");
|
|
|
+ DOUBLE_SURNAME_SET.add("青阳");
|
|
|
+ DOUBLE_SURNAME_SET.add("漆雕");
|
|
|
+ DOUBLE_SURNAME_SET.add("亓官");
|
|
|
+ DOUBLE_SURNAME_SET.add("渠丘");
|
|
|
+ DOUBLE_SURNAME_SET.add("壤驷");
|
|
|
+ DOUBLE_SURNAME_SET.add("上官");
|
|
|
+ DOUBLE_SURNAME_SET.add("少室");
|
|
|
+ DOUBLE_SURNAME_SET.add("少叔");
|
|
|
+ DOUBLE_SURNAME_SET.add("司徒");
|
|
|
+ DOUBLE_SURNAME_SET.add("司马");
|
|
|
+ DOUBLE_SURNAME_SET.add("司空");
|
|
|
+ DOUBLE_SURNAME_SET.add("司寇");
|
|
|
+ DOUBLE_SURNAME_SET.add("士孙");
|
|
|
+ DOUBLE_SURNAME_SET.add("申屠");
|
|
|
+ DOUBLE_SURNAME_SET.add("申徒");
|
|
|
+ DOUBLE_SURNAME_SET.add("申鲜");
|
|
|
+ DOUBLE_SURNAME_SET.add("申叔");
|
|
|
+ DOUBLE_SURNAME_SET.add("夙沙");
|
|
|
+ DOUBLE_SURNAME_SET.add("叔先");
|
|
|
+ DOUBLE_SURNAME_SET.add("叔仲");
|
|
|
+ DOUBLE_SURNAME_SET.add("侍其");
|
|
|
+ DOUBLE_SURNAME_SET.add("叔孙");
|
|
|
+ DOUBLE_SURNAME_SET.add("澹台");
|
|
|
+ DOUBLE_SURNAME_SET.add("太史");
|
|
|
+ DOUBLE_SURNAME_SET.add("太叔");
|
|
|
+ DOUBLE_SURNAME_SET.add("太公");
|
|
|
+ DOUBLE_SURNAME_SET.add("屠岸");
|
|
|
+ DOUBLE_SURNAME_SET.add("唐古");
|
|
|
+ }
|
|
|
+
|
|
|
+ public static String parseUserFirstName(String userName){
|
|
|
+ if(StringUtils.isBlank(userName)){
|
|
|
+ return userName;
|
|
|
+ }
|
|
|
+ if(userName.length() > 2){
|
|
|
+ String firstName = userName.substring(0, 2);
|
|
|
+ if (DOUBLE_SURNAME_SET.contains(firstName)) {
|
|
|
+ return firstName;
|
|
|
+ }else{
|
|
|
+ return getFirstWord(userName);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return userName.substring(0,1);
|
|
|
+ }
|
|
|
+
|
|
|
+ public static String getFirstWord(String name){
|
|
|
+ return name.substring(0,1);
|
|
|
+ }
|
|
|
+
|
|
|
+ public static boolean checkChineseName(String name){
|
|
|
+ if(null == name || StringUtils.isBlank(name)){
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ String regex = "^[\u4e00-\u9fa5·]{2,12}$";
|
|
|
+ Pattern pattern = Pattern.compile(regex);
|
|
|
+ Matcher matcher = pattern.matcher(name);
|
|
|
+ return matcher.matches();
|
|
|
+ }
|
|
|
+
|
|
|
+}
|