Browse Source

批量上架英文品牌的中文符号切换成中文。

yujia 7 years ago
parent
commit
578a1f7216

+ 43 - 0
src/main/java/com/uas/platform/b2c/core/utils/StringUtilB2C.java

@@ -273,4 +273,47 @@ public class StringUtilB2C {
 			return a.equals(b);
 		}
 	}
+
+
+	/**
+	 * 中文的标点 转化为英文的标点,全角转半角
+	 *
+	 * @param input
+	 * @return
+	 */
+	public static String toEnglish(String input) {
+		if (StringUtils.isEmpty(input)) {
+			return null;
+		} else {
+            /*正则转换中文标点*/
+			input = input.replaceAll("\\:", ":")
+					.replaceAll("\\。", ".")
+					.replaceAll("\\“", "\"")
+					.replaceAll("\\”", "\"")
+					.replaceAll("\\【", "[")
+					.replaceAll("\\】", "]")
+					.replaceAll("\\《", "<")
+					.replaceAll("\\》", ">")
+					.replaceAll("\\,", ", ")
+					.replaceAll("\\?", "?")
+					.replaceAll("\\、", ", ")
+					.replaceAll("\\;", ";")
+					.replaceAll("\\(", "(")
+					.replaceAll("\\)", ")")
+					.replaceAll("\\‘", "'")
+					.replaceAll("\\’", "'")
+					.replaceAll("\\『", "[")
+					.replaceAll("\\』", "]")
+					.replaceAll("\\「", "[")
+					.replaceAll("\\」", "]")
+					.replaceAll("\\﹃", "[")
+					.replaceAll("\\﹄", "]")
+					.replaceAll("\\〔", "{")
+					.replaceAll("\\〕", "}")
+					.replaceAll("\\—", "-")
+					.replaceAll("\\·", ".");
+            /*正则转换全角为半角*/
+            return input;
+		}
+	}
 }

+ 2 - 3
src/main/java/com/uas/platform/b2c/prod/commodity/model/ReleaseProductByBatch.java

@@ -8,7 +8,6 @@ import com.uas.platform.b2c.core.utils.StringUtilB2C;
 import com.uas.platform.b2c.prod.commodity.constant.DoubleConstant;
 import com.uas.platform.b2c.prod.commodity.constant.ErrorInfoConstant;
 import com.uas.platform.b2c.prod.commodity.type.ReleaseConstant;
-import com.uas.platform.b2c.prod.commodity.util.GoodsUtil;
 import com.uas.platform.b2c.trade.order.StringConstant.Currency;
 import org.apache.commons.collections.CollectionUtils;
 import org.codehaus.jackson.annotate.JsonIgnore;
@@ -518,8 +517,8 @@ public class ReleaseProductByBatch implements Serializable {
 				throw new RuntimeException(e + "指定字符集不支持");
 			}
 		}
-		setBrandNameEn(StringUtilB2C.getStr(value));
-		setB2cBranden(StringUtilB2C.getStr(value));
+		setBrandNameEn(StringUtilB2C.toEnglish(StringUtilB2C.getStr(value)));
+		setB2cBranden(StringUtilB2C.toEnglish(StringUtilB2C.getStr(value)));
 	}
 
 	public void setCodeByExcel(Object value) {