diff --git a/dsBase/pom.xml b/dsBase/pom.xml index 624dd356..fc5b4f97 100644 --- a/dsBase/pom.xml +++ b/dsBase/pom.xml @@ -59,10 +59,11 @@ fst 3.0.4-jdk17 + - mysql - mysql-connector-java - 8.0.33 + org.postgresql + postgresql + 42.7.1 @@ -152,29 +153,7 @@ httpcore 4.4.15 - - - com.aliyun - dingtalk - 2.0.18 - - - - - com.github.binarywang - java-testdata-generator - 1.1.2 - - - com.aliyun - alibaba-dingtalk-service-sdk - 2.0.0 - - - org.postgresql - postgresql - 42.7.1 - + diff --git a/dsBase/src/main/java/com/dsideal/dsBase/Util/ChineseCharacterUtil.java b/dsBase/src/main/java/com/dsideal/dsBase/Util/ChineseCharacterUtil.java deleted file mode 100644 index e45ff242..00000000 --- a/dsBase/src/main/java/com/dsideal/dsBase/Util/ChineseCharacterUtil.java +++ /dev/null @@ -1,131 +0,0 @@ -package com.dsideal.dsBase.Util; - -import net.sourceforge.pinyin4j.PinyinHelper; -import net.sourceforge.pinyin4j.format.HanyuPinyinOutputFormat; -import net.sourceforge.pinyin4j.format.HanyuPinyinToneType; - -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -/** - * 获取首字母工具 - * - * @author - * @Date - */ -public class ChineseCharacterUtil { - - /** - * 获取汉字首字母或全拼大写字母 - * - * @param chinese 汉字 - * @param isFull 是否全拼 true:表示全拼 false表示:首字母 - * @return 全拼或者首字母大写字符窜 - */ - public static String getUpperCase(String chinese, boolean isFull) { - return convertHanzi2Pinyin(chinese, isFull).toUpperCase(); - } - - /** - * 获取汉字首字母或全拼小写字母 - * - * @param chinese 汉字 - * @param isFull 是否全拼 true:表示全拼 false表示:首字母 - * @return 全拼或者首字母小写字符窜 - */ - public static String getLowerCase(String chinese, boolean isFull) { - return convertHanzi2Pinyin(chinese, isFull).toLowerCase(); - } - - /** - * 将汉字转成拼音 - *

- * 取首字母或全拼 - * - * @param hanzi 汉字字符串 - * @param isFull 是否全拼 true:表示全拼 false表示:首字母 - * @return 拼音 - */ - private static String convertHanzi2Pinyin(String hanzi, boolean isFull) { - /*** - * ^[\u2E80-\u9FFF]+$ 匹配所有东亚区的语言 - * ^[\u4E00-\u9FFF]+$ 匹配简体和繁体 - * ^[\u4E00-\u9FA5]+$ 匹配简体 - */ - String regExp = "^[\u4E00-\u9FFF]+$"; - StringBuffer sb = new StringBuffer(); - if (hanzi == null || "".equals(hanzi.trim())) { - return ""; - } - String pinyin = ""; - for (int i = 0; i < hanzi.length(); i++) { - char unit = hanzi.charAt(i); - //是汉字,则转拼音 - if (match(String.valueOf(unit), regExp)) { - pinyin = convertSingleHanzi2Pinyin(unit); - if (isFull) { - sb.append(pinyin); - } else { - sb.append(pinyin.charAt(0)); - } - } else { - sb.append(unit); - } - } - return sb.toString(); - } - - /** - * 将单个汉字转成拼音 - * - * @param hanzi 汉字字符 - * @return 拼音 - */ - private static String convertSingleHanzi2Pinyin(char hanzi) { - HanyuPinyinOutputFormat outputFormat = new HanyuPinyinOutputFormat(); - outputFormat.setToneType(HanyuPinyinToneType.WITHOUT_TONE); - String[] res; - StringBuffer sb = new StringBuffer(); - try { - res = PinyinHelper.toHanyuPinyinStringArray(hanzi, outputFormat); - sb.append(res[0]);//对于多音字,只用第一个拼音 - } catch (Exception e) { - e.printStackTrace(); - return ""; - } - return sb.toString(); - } - - /*** - * 匹配 - *

- * 根据字符和正则表达式进行匹配 - * - * @param str 源字符串 - * @param regex 正则表达式 - * - * @return true:匹配成功 false:匹配失败 - */ - private static boolean match(String str, String regex) { - Pattern pattern = Pattern.compile(regex); - Matcher matcher = pattern.matcher(str); - return matcher.find(); - } - - public static String getColumnNameByMemo(String memo) { - String res; - if (memo.length() <= 3) res = convertHanzi2Pinyin(memo, true); - else - res = convertHanzi2Pinyin(memo, false); - - res = res.replace("\n", "").trim().replace("/", "_"); - res = res.replace("(", ""); - res = res.replace(")", ""); - // 正则表达式,匹配非字母、数字、下划线的字符 - String regex = "[^a-zA-Z0-9_]"; - // 使用replaceAll方法替换匹配的字符为空字符串,即删除这些字符 - res = res.replaceAll(regex, ""); - return res; - } -} -