|
@@ -189,13 +189,31 @@ public class TransUtil {
|
|
|
for (Map.Entry<String, Object> entry : metaData.entrySet()) {
|
|
|
String label = TransUtil.LABEL_MAPPING.get(entry.getKey());
|
|
|
if (label != null) {
|
|
|
- keyValue.put(label, entry.getValue());
|
|
|
+ Object value = entry.getValue();
|
|
|
+
|
|
|
+ // 处理字符串长度限制
|
|
|
+ if (value instanceof String) {
|
|
|
+ String strValue = (String) value;
|
|
|
+ if (strValue.length() > 255) {
|
|
|
+ // 根据业务需求选择处理方式:
|
|
|
+ // 1.直接截断(常用在非关键字段)
|
|
|
+ value = strValue.substring(0, 255);
|
|
|
+
|
|
|
+ // 2.抛出异常(严格场景)
|
|
|
+ // throw new IllegalArgumentException("Value exceeds 255 chars: " + entry.getKey());
|
|
|
+
|
|
|
+ // 3.日志警告(推荐组合使用)
|
|
|
+ // log.warn("Value truncated for key: {}", entry.getKey());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ keyValue.put(label, value);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 构建单条记录的VALUES
|
|
|
StringBuilder valueBuilder = new StringBuilder()
|
|
|
- .append(String.format("'%s', -1, -1, '%s', -1, '%s', 0, 0, '%s', '%s'",
|
|
|
+ .append(String.format("'%s', -1, 123, '%s', -1, '%s', 0, 0, '%s', '%s'",
|
|
|
metaId,
|
|
|
getCurrentDateTime(),
|
|
|
getCurrentDateTime(),
|