fix(excel): 字典/表字典分隔符从 _ 改为 , 解决含下划线值被截断
- ExcelAnnotationUtils split 分隔符由 _ 改为 , - AutoPoiDictConfig 去掉 --- escape 机制,改用 , 分隔 - 修复 username 等含下划线字段在 Excel 导入导出时被错误转换 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -27,8 +27,7 @@ import lombok.extern.slf4j.Slf4j;
|
|||||||
@Slf4j
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
public class AutoPoiDictConfig implements AutoPoiDictServiceI {
|
public class AutoPoiDictConfig implements AutoPoiDictServiceI {
|
||||||
final static String EXCEL_SPLIT_TAG = "_";
|
final static String EXCEL_SPLIT_TAG = ",";
|
||||||
final static String TEMP_EXCEL_SPLIT_TAG = "---";
|
|
||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
@Resource
|
@Resource
|
||||||
@@ -62,15 +61,8 @@ public class AutoPoiDictConfig implements AutoPoiDictServiceI {
|
|||||||
//update-begin---author:liusq Date:20230517 for:[issues/4917]excel 导出异常---
|
//update-begin---author:liusq Date:20230517 for:[issues/4917]excel 导出异常---
|
||||||
if(t!=null && t.getText()!=null && t.getValue()!=null){
|
if(t!=null && t.getText()!=null && t.getValue()!=null){
|
||||||
//update-end---author:liusq Date:20230517 for:[issues/4917]excel 导出异常---
|
//update-end---author:liusq Date:20230517 for:[issues/4917]excel 导出异常---
|
||||||
//update-begin---author:scott Date:20211220 for:[issues/I4MBB3]@Excel dicText字段的值有下划线时,导入功能不能正确解析---
|
|
||||||
if(t.getValue().contains(EXCEL_SPLIT_TAG)){
|
|
||||||
String val = t.getValue().replace(EXCEL_SPLIT_TAG,TEMP_EXCEL_SPLIT_TAG);
|
|
||||||
dictReplaces.add(t.getText() + EXCEL_SPLIT_TAG + val);
|
|
||||||
}else{
|
|
||||||
dictReplaces.add(t.getText() + EXCEL_SPLIT_TAG + t.getValue());
|
dictReplaces.add(t.getText() + EXCEL_SPLIT_TAG + t.getValue());
|
||||||
}
|
}
|
||||||
//update-end---author:20211220 Date:20211220 for:[issues/I4MBB3]@Excel dicText字段的值有下划线时,导入功能不能正确解析---
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (dictReplaces != null && dictReplaces.size() != 0) {
|
if (dictReplaces != null && dictReplaces.size() != 0) {
|
||||||
log.info("---AutoPoi--Get_DB_Dict------"+ dictReplaces.toString());
|
log.info("---AutoPoi--Get_DB_Dict------"+ dictReplaces.toString());
|
||||||
|
|||||||
+1
-1
@@ -13,7 +13,7 @@ public interface DictQuery {
|
|||||||
* @param dictTable 字典表名(来自 @ExcelColumn.dictTable())
|
* @param dictTable 字典表名(来自 @ExcelColumn.dictTable())
|
||||||
* @param dicCode 字典编码字段(来自 @ExcelColumn.dicCode())
|
* @param dicCode 字典编码字段(来自 @ExcelColumn.dicCode())
|
||||||
* @param dicText 字典文本字段(来自 @ExcelColumn.dicText())
|
* @param dicText 字典文本字段(来自 @ExcelColumn.dicText())
|
||||||
* @return 格式为 {"text_code", ...} 的数组,如 {"男_0", "女_1"};无结果返回 null 或空数组
|
* @return 格式为 {"text,code", ...} 的数组,如 {"男,0", "女,1"};无结果返回 null 或空数组
|
||||||
*/
|
*/
|
||||||
String[] query(String dictTable, String dicCode, String dicText);
|
String[] query(String dictTable, String dicCode, String dicText);
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -215,7 +215,7 @@ public final class ExcelAnnotationUtils {
|
|||||||
|
|
||||||
static boolean isValidDictDisplay(String[] replace, String value) {
|
static boolean isValidDictDisplay(String[] replace, String value) {
|
||||||
for (String s : replace) {
|
for (String s : replace) {
|
||||||
String[] arr = s.split("_");
|
String[] arr = s.split(",");
|
||||||
if (arr.length >= 2 && arr[0].equals(value)) {
|
if (arr.length >= 2 && arr[0].equals(value)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -359,7 +359,7 @@ public final class ExcelAnnotationUtils {
|
|||||||
|
|
||||||
private static String replaceValue(String[] replace, String value) {
|
private static String replaceValue(String[] replace, String value) {
|
||||||
for (String s : replace) {
|
for (String s : replace) {
|
||||||
String[] arr = s.split("_");
|
String[] arr = s.split(",");
|
||||||
if (arr.length == 2 && value.equals(arr[1])) {
|
if (arr.length == 2 && value.equals(arr[1])) {
|
||||||
return arr[0];
|
return arr[0];
|
||||||
}
|
}
|
||||||
@@ -398,7 +398,7 @@ public final class ExcelAnnotationUtils {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (String s : replace) {
|
for (String s : replace) {
|
||||||
String[] arr = s.split("_");
|
String[] arr = s.split(",");
|
||||||
if (arr.length >= 2) {
|
if (arr.length >= 2) {
|
||||||
displayToCode.put(arr[0], arr[1]);
|
displayToCode.put(arr[0], arr[1]);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user