();
+ threadLocal.set(sharedObject);
+ }
+
+ return threadLocal.get();
+ }//end of getThreadLocal()
+
+ /**
+ *
+ * 以在线程间共享对象中指定的键的名称存储对象
+ *
+ * @param key
+ * @param object
+ */
+ public static void add(String key, Object object) { // NOPMD
+ getThreadLocal().put(key, object);
+ }//end of add()
+
+ /**
+ *
+ * 从线程之间的共享对象导入与指定键相对应的对象
+ *
+ * @param key
+ * @return
+ */
+ public static Object get(String key) { // NOPMD
+ return getThreadLocal().get(key);
+ }//end of get()
+
+ /**
+ *
+ * 调查是否存在与线程间共享对象上指定的键相对应的对象
+ *
+ * @param key
+ * @return
+ */
+ public static boolean isExist(String key) {
+ Object object = getThreadLocal().get(key);
+ if (object != null) {
+ return true;
+ } else {
+ return false;
+ }
+ }//end of isExist()
+
+ /**
+ *
+ * 初始化线程之间的共享对象
+ *
+ */
+ public static void clearSharedObject() {
+ getThreadLocal().clear();
+ threadLocal.set(null);
+ }//end of clearSharedObject()
+
+ /**
+ *
+ *
+ * @return
+ */
+ public static String[] getThreadLocalKeys() {
+ String[] arrKeys = new String[getThreadLocal().size()];
+ Iterator keyIter = getThreadLocal().keySet().iterator();
+
+ int i = 0;
+ while (keyIter.hasNext()) {
+ arrKeys[i] = keyIter.next();
+ i++;
+ }
+
+ return arrKeys;
+ }//end of getThreadLocalKeys()
+
+ /**
+ *
+ *
+ * @return
+ */
+ public static int size() {
+ return getThreadLocal().size();
+ }//end of size()
+
+ /**
+ *
+ *
+ * @return
+ */
+ public static Object[] getThreadLocalValues() {
+ int size = size();
+
+ String[] arrKeys = getThreadLocalKeys();
+ Object[] values = new Object[size];
+
+ for (int i = 0; i < size; i++) {
+ values[i] = getThreadLocal().get(arrKeys[i]);
+ }
+
+ return values;
+ }//end of getThreadLocalValues()
+
+ /**
+ *
+ *
+ */
+ public static void toPrintString() {
+ int size = size();
+
+ StringBuffer str = new StringBuffer();
+ String[] keys = getThreadLocalKeys();
+ Object[] values = getThreadLocalValues();
+
+ for (int i = 0; i < size; i++) {
+ str.append(" " + keys[i] + " = " + values[i] + " \n");
+ }
+
+ LOGGER.info("{}", str.toString());
+ }//end of toPringString()
+
+}// end of ThreadLocalUtil.java
\ No newline at end of file
diff --git a/src/main/java/com/qiwu/inference/common/utils/TypeConvertUtil.java b/src/main/java/com/qiwu/inference/common/utils/TypeConvertUtil.java
new file mode 100644
index 0000000..aafeaa3
--- /dev/null
+++ b/src/main/java/com/qiwu/inference/common/utils/TypeConvertUtil.java
@@ -0,0 +1,329 @@
+package com.qiwu.inference.common.utils;
+
+import com.qiwu.inference.common.Constants;
+import org.springframework.util.StringUtils;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+public class TypeConvertUtil {
+ static char[] cnArr = new char[]{'一','二','三','四','五','六','七','八','九'};
+ static char[] chArr = new char [] {'十','百','千','万','亿'};
+
+ /**
+ * 将中文的{'一','二',...}转成数字{1,2,...}
+ * @param param
+ * @return Integer
+ */
+ public static Integer change2Integer(String param) {
+ String[] all = new String[]{"都", "统统", "全数", "所有", "全", "全部", "全都", "一起", "批量"};
+ String[] first = new String[]{"首个", "首位", "最前面", "开头", "首发", "起首"};
+ String[] middle = new String[]{"中间"};
+ String[] last = new String[]{"最后", "末位", "末尾", "最后面"};
+ String[] random = new String[]{"随机", "随便", "推荐"};
+ List allCh = Arrays.asList(all);
+ List firstCh = Arrays.asList(first);
+ List middleCh = Arrays.asList(middle);
+ List lastCh = Arrays.asList(last);
+ List randomCh = Arrays.asList(random);
+ if (randomCh.contains(param)) {
+ return Constants.REQ_RANDOM;
+ }
+ if (allCh.contains(param)) {
+ return Constants.REQ_ALL;
+ }
+ if (firstCh.contains(param)) {
+ return Constants.REQ_FIRST;
+ }
+ if (middleCh.contains(param)) {
+ return Constants.REQ_MIDDLE;
+ }
+ if (lastCh.contains(param)) {
+ return Constants.REQ_LAST;
+ }
+ param = param.replace("两","二");
+// List cnArrList = new String(cnArr).chars().mapToObj(c->(char)c).collect(Collectors.toList());
+// List chArrList = new String(chArr).chars().mapToObj(c->(char)c).collect(Collectors.toList());
+ boolean num = false;
+ int result = 0;
+ //存放一个单位的数字如:十万
+ int temp = 1;
+ //判断是否有chArr
+ int count = 0;
+ for (int i = 0; i < param.length(); i++) {
+ //判断是否是chArr
+ boolean b = true;
+ char c = param.charAt(i);
+ //非单位,即数字
+ for (int j = 0; j < cnArr.length; j++) {
+ if (c == cnArr[j]) {
+ //添加下一个单位之前,先把上一个单位值添加到结果中
+ if(0 != count){
+ result += temp;
+ count = 0;
+ }
+ // 下标+1,就是对应的值
+ temp = j + 1;
+ b = false;
+ num = true;
+ break;
+ }
+ }
+ if(b){
+ for (int j = 0; j < chArr.length; j++) {
+ if (c == chArr[j]) {
+ switch (j) {
+ case 0:
+ temp *= 10;
+ break;
+ case 1:
+ temp *= 100;
+ break;
+ case 2:
+ temp *= 1000;
+ break;
+ case 3:
+ temp *= 10000;
+ break;
+ case 4:
+ temp *= 100000000;
+ break;
+ default:
+ break;
+ }
+ count++;
+ }
+ }
+ }
+ //遍历到最后一个字符
+ if (i == param.length() - 1) {
+ //避免出现阿拉伯数字,没有找到返回为1的情况
+ if (num) {
+ result += temp;
+ } else {
+ result = 0;
+ }
+ }
+ }
+ return result;
+ }
+
+ /**
+ * 将数字转换为中文数字, 这里只写到了万
+ * @param intInput 需要转换的数学数字
+ */
+ public static String arabicNumToChineseNum(int intInput) {
+ String si = String.valueOf(intInput);
+ String sd = "";
+ if (si.length() == 1) {
+ if (intInput == 0) {
+ return sd;
+ }
+ sd += cnArr[intInput - 1];
+ return sd;
+ } else if (si.length() == 2) {
+ if ("1".equals(si.substring(0, 1))) {
+ sd += "十";
+ if (intInput % 10 == 0) {
+ return sd;
+ }
+ }
+ else {
+ sd += (cnArr[intInput / 10 - 1] + "十");
+ }
+ sd += arabicNumToChineseNum(intInput % 10);
+ } else if (si.length() == 3) {
+ sd += (cnArr[intInput / 100 - 1] + "百");
+ if (String.valueOf(intInput % 100).length() < 2) {
+ if (intInput % 100 == 0) {
+ return sd;
+ }
+ sd += "零";
+ }
+ sd += arabicNumToChineseNum(intInput % 100);
+ } else if (si.length() == 4) {
+ sd += (cnArr[intInput / 1000 - 1] + "千");
+ if (String.valueOf(intInput % 1000).length() < 3) {
+ if (intInput % 1000 == 0) {
+ return sd;
+ }
+ sd += "零";
+ }
+ sd += arabicNumToChineseNum(intInput % 1000);
+ } else if (si.length() == 5) {
+ sd += (cnArr[intInput / 10000 - 1] + "万");
+ if (String.valueOf(intInput % 10000).length() < 4) {
+ if (intInput % 10000 == 0) {
+ return sd;
+ }
+ sd += "零";
+ }
+ sd += arabicNumToChineseNum(intInput % 10000);
+ }
+
+ return sd;
+ }
+
+ /**
+ * 将中文数字替换成阿拉伯数字
+ * @param name
+ * @return String
+ */
+ public static String replaceChineseNum(String name) {
+ String nameStr = name.substring(0, 4);
+ String param = name.substring(4);
+ param = param.replace("两","二");
+ boolean num = false;
+ int result = 0;
+ //存放一个单位的数字如:十万
+ int temp = 1;
+ //判断是否有chArr
+ int count = 0;
+ for (int i = 0; i < param.length(); i++) {
+ //判断是否是chArr
+ boolean b = true;
+ char c = param.charAt(i);
+ //非单位,即数字
+ for (int j = 0; j < cnArr.length; j++) {
+ if (c == cnArr[j]) {
+ //添加下一个单位之前,先把上一个单位值添加到结果中
+ if(0 != count){
+ result += temp;
+ count = 0;
+ }
+ // 下标+1,就是对应的值
+ temp = j + 1;
+ b = false;
+ num = true;
+ break;
+ }
+ }
+ if(b){
+ for (int j = 0; j < chArr.length; j++) {
+ if (c == chArr[j]) {
+ switch (j) {
+ case 0:
+ temp *= 10;
+ break;
+ case 1:
+ temp *= 100;
+ break;
+ case 2:
+ temp *= 1000;
+ break;
+ case 3:
+ temp *= 10000;
+ break;
+ case 4:
+ temp *= 100000000;
+ break;
+ default:
+ break;
+ }
+ count++;
+ }
+ }
+ }
+ //遍历到最后一个字符
+ if (i == param.length() - 1) {
+ //避免出现阿拉伯数字的情况
+ if (num) {
+ result += temp;
+ } else {
+ result = Integer.parseInt(param);
+ }
+ }
+ }
+ return nameStr + result;
+ }
+
+ /**
+ * 提取中文的阿拉伯数字
+ * @param param
+ * @return Integer
+ */
+ public static Integer extractNum(String param) {
+ int i;
+ String regEx="[^0-9]";
+ Pattern p = Pattern.compile(regEx);
+ Matcher m = p.matcher(param);
+ if (!"".equals(m.replaceAll("").trim())) {
+ if (StringUtils.isEmpty(extractChinese(param))) {
+ if (param.length() > 9) {
+ return Constants.REQ_NON;
+ }
+ }
+ i = Integer.parseInt(m.replaceAll("").trim());
+ } else {
+ i = Constants.REQ_NON;
+ }
+ return i;
+ }
+
+ /**
+ * 提取字符串的中文
+ * @param param
+ * @return Integer
+ */
+ public static String extractChinese(String param) {
+ String regEx="[^(\\\\u4e00-\\\\u9fa5)]";
+ String result = "";
+ Matcher matcher = Pattern.compile(regEx).matcher(param);
+ while (matcher.find()) {
+ result += matcher.group(0);
+ }
+ return result;
+ }
+
+ /**
+ * 提取字符串的数字字符串
+ * @param param
+ * @return Integer
+ */
+ public static String extractNo(String param) {
+ String regEx="[^(\\\\u4e00-\\\\u9fa5)]";
+ return param.replaceAll(regEx, "");
+ }
+
+ /**
+ * {"未读", "已读"}中文转成数字
+ * @param param
+ * @return Integer
+ */
+ public static Integer readChineseToInteger(String param) {
+ String[] chs = {"未读", "已读"};
+ if (param.equals(chs[0])) {
+ return 0;
+ } else {
+ return 1;
+ }
+ }
+
+ /**
+ * 选择的序号
+ */
+ public static Object getNumFromList(List