|
@@ -271,11 +271,11 @@ public class ExcelUtil<T> |
|
@@ -271,11 +271,11 @@ public class ExcelUtil<T> |
|
271
|
}
|
271
|
}
|
|
272
|
else if (StringUtils.isNotEmpty(attr.readConverterExp()))
|
272
|
else if (StringUtils.isNotEmpty(attr.readConverterExp()))
|
|
273
|
{
|
273
|
{
|
|
274
|
- val = reverseByExp(Convert.toStr(val), attr.readConverterExp());
|
274
|
+ val = reverseByExp(Convert.toStr(val), attr.readConverterExp(), attr.separator());
|
|
275
|
}
|
275
|
}
|
|
276
|
else if (StringUtils.isNotEmpty(attr.dictType()))
|
276
|
else if (StringUtils.isNotEmpty(attr.dictType()))
|
|
277
|
{
|
277
|
{
|
|
278
|
- val = reverseDictByExp(attr.dictType(), Convert.toStr(val));
|
278
|
+ val = reverseDictByExp(Convert.toStr(val), attr.dictType(), attr.separator());
|
|
279
|
}
|
279
|
}
|
|
280
|
ReflectUtils.invokeSetter(entity, propertyName, val);
|
280
|
ReflectUtils.invokeSetter(entity, propertyName, val);
|
|
281
|
}
|
281
|
}
|
|
@@ -534,6 +534,7 @@ public class ExcelUtil<T> |
|
@@ -534,6 +534,7 @@ public class ExcelUtil<T> |
|
534
|
Object value = getTargetValue(vo, field, attr);
|
534
|
Object value = getTargetValue(vo, field, attr);
|
|
535
|
String dateFormat = attr.dateFormat();
|
535
|
String dateFormat = attr.dateFormat();
|
|
536
|
String readConverterExp = attr.readConverterExp();
|
536
|
String readConverterExp = attr.readConverterExp();
|
|
|
|
537
|
+ String separator = attr.separator();
|
|
537
|
String dictType = attr.dictType();
|
538
|
String dictType = attr.dictType();
|
|
538
|
if (StringUtils.isNotEmpty(dateFormat) && StringUtils.isNotNull(value))
|
539
|
if (StringUtils.isNotEmpty(dateFormat) && StringUtils.isNotNull(value))
|
|
539
|
{
|
540
|
{
|
|
@@ -541,11 +542,11 @@ public class ExcelUtil<T> |
|
@@ -541,11 +542,11 @@ public class ExcelUtil<T> |
|
541
|
}
|
542
|
}
|
|
542
|
else if (StringUtils.isNotEmpty(readConverterExp) && StringUtils.isNotNull(value))
|
543
|
else if (StringUtils.isNotEmpty(readConverterExp) && StringUtils.isNotNull(value))
|
|
543
|
{
|
544
|
{
|
|
544
|
- cell.setCellValue(convertByExp(Convert.toStr(value), readConverterExp));
|
545
|
+ cell.setCellValue(convertByExp(Convert.toStr(value), readConverterExp, separator));
|
|
545
|
}
|
546
|
}
|
|
546
|
else if (StringUtils.isNotEmpty(dictType))
|
547
|
else if (StringUtils.isNotEmpty(dictType))
|
|
547
|
{
|
548
|
{
|
|
548
|
- cell.setCellValue(convertDictByExp(dictType, Convert.toStr(value)));
|
549
|
+ cell.setCellValue(convertDictByExp(Convert.toStr(value), dictType, separator));
|
|
549
|
}
|
550
|
}
|
|
550
|
else
|
551
|
else
|
|
551
|
{
|
552
|
{
|
|
@@ -623,28 +624,36 @@ public class ExcelUtil<T> |
|
@@ -623,28 +624,36 @@ public class ExcelUtil<T> |
|
623
|
*
|
624
|
*
|
|
624
|
* @param propertyValue 参数值
|
625
|
* @param propertyValue 参数值
|
|
625
|
* @param converterExp 翻译注解
|
626
|
* @param converterExp 翻译注解
|
|
|
|
627
|
+ * @param separator 分隔符
|
|
626
|
* @return 解析后值
|
628
|
* @return 解析后值
|
|
627
|
- * @throws Exception
|
|
|
|
628
|
*/
|
629
|
*/
|
|
629
|
- public static String convertByExp(String propertyValue, String converterExp) throws Exception
|
|
|
|
630
|
- {
|
|
|
|
631
|
- try
|
630
|
+ public static String convertByExp(String propertyValue, String converterExp, String separator)
|
|
632
|
{
|
631
|
{
|
|
|
|
632
|
+ StringBuilder propertyString = new StringBuilder();
|
|
633
|
String[] convertSource = converterExp.split(",");
|
633
|
String[] convertSource = converterExp.split(",");
|
|
634
|
for (String item : convertSource)
|
634
|
for (String item : convertSource)
|
|
635
|
{
|
635
|
{
|
|
636
|
String[] itemArray = item.split("=");
|
636
|
String[] itemArray = item.split("=");
|
|
637
|
- if (itemArray[0].equals(propertyValue))
|
637
|
+ if (StringUtils.containsAny(separator, propertyValue))
|
|
638
|
{
|
638
|
{
|
|
639
|
- return itemArray[1];
|
639
|
+ for (String value : propertyValue.split(separator))
|
|
|
|
640
|
+ {
|
|
|
|
641
|
+ if (itemArray[0].equals(value))
|
|
|
|
642
|
+ {
|
|
|
|
643
|
+ propertyString.append(itemArray[1] + separator);
|
|
|
|
644
|
+ break;
|
|
640
|
}
|
645
|
}
|
|
641
|
}
|
646
|
}
|
|
642
|
}
|
647
|
}
|
|
643
|
- catch (Exception e)
|
648
|
+ else
|
|
|
|
649
|
+ {
|
|
|
|
650
|
+ if (itemArray[0].equals(propertyValue))
|
|
644
|
{
|
651
|
{
|
|
645
|
- throw e;
|
652
|
+ return itemArray[1];
|
|
646
|
}
|
653
|
}
|
|
647
|
- return propertyValue;
|
654
|
+ }
|
|
|
|
655
|
+ }
|
|
|
|
656
|
+ return StringUtils.stripEnd(propertyString.toString(), separator);
|
|
648
|
}
|
657
|
}
|
|
649
|
|
658
|
|
|
650
|
/**
|
659
|
/**
|
|
@@ -652,52 +661,62 @@ public class ExcelUtil<T> |
|
@@ -652,52 +661,62 @@ public class ExcelUtil<T> |
|
652
|
*
|
661
|
*
|
|
653
|
* @param propertyValue 参数值
|
662
|
* @param propertyValue 参数值
|
|
654
|
* @param converterExp 翻译注解
|
663
|
* @param converterExp 翻译注解
|
|
|
|
664
|
+ * @param separator 分隔符
|
|
655
|
* @return 解析后值
|
665
|
* @return 解析后值
|
|
656
|
- * @throws Exception
|
|
|
|
657
|
*/
|
666
|
*/
|
|
658
|
- public static String reverseByExp(String propertyValue, String converterExp) throws Exception
|
|
|
|
659
|
- {
|
|
|
|
660
|
- try
|
667
|
+ public static String reverseByExp(String propertyValue, String converterExp, String separator)
|
|
661
|
{
|
668
|
{
|
|
|
|
669
|
+ StringBuilder propertyString = new StringBuilder();
|
|
662
|
String[] convertSource = converterExp.split(",");
|
670
|
String[] convertSource = converterExp.split(",");
|
|
663
|
for (String item : convertSource)
|
671
|
for (String item : convertSource)
|
|
664
|
{
|
672
|
{
|
|
665
|
String[] itemArray = item.split("=");
|
673
|
String[] itemArray = item.split("=");
|
|
666
|
- if (itemArray[1].equals(propertyValue))
|
674
|
+ if (StringUtils.containsAny(separator, propertyValue))
|
|
667
|
{
|
675
|
{
|
|
668
|
- return itemArray[0];
|
676
|
+ for (String value : propertyValue.split(separator))
|
|
|
|
677
|
+ {
|
|
|
|
678
|
+ if (itemArray[1].equals(value))
|
|
|
|
679
|
+ {
|
|
|
|
680
|
+ propertyString.append(itemArray[0] + separator);
|
|
|
|
681
|
+ break;
|
|
669
|
}
|
682
|
}
|
|
670
|
}
|
683
|
}
|
|
671
|
}
|
684
|
}
|
|
672
|
- catch (Exception e)
|
685
|
+ else
|
|
673
|
{
|
686
|
{
|
|
674
|
- throw e;
|
687
|
+ if (itemArray[1].equals(propertyValue))
|
|
|
|
688
|
+ {
|
|
|
|
689
|
+ return itemArray[0];
|
|
|
|
690
|
+ }
|
|
675
|
}
|
691
|
}
|
|
676
|
- return propertyValue;
|
692
|
+ }
|
|
|
|
693
|
+ return StringUtils.stripEnd(propertyString.toString(), separator);
|
|
677
|
}
|
694
|
}
|
|
678
|
|
695
|
|
|
679
|
/**
|
696
|
/**
|
|
680
|
* 解析字典值
|
697
|
* 解析字典值
|
|
681
|
*
|
698
|
*
|
|
682
|
- * @param dictType 字典类型
|
|
|
|
683
|
* @param dictValue 字典值
|
699
|
* @param dictValue 字典值
|
|
|
|
700
|
+ * @param dictType 字典类型
|
|
|
|
701
|
+ * @param separator 分隔符
|
|
684
|
* @return 字典标签
|
702
|
* @return 字典标签
|
|
685
|
*/
|
703
|
*/
|
|
686
|
- public static String convertDictByExp(String dictType, String dictValue) throws Exception
|
704
|
+ public static String convertDictByExp(String dictValue, String dictType, String separator)
|
|
687
|
{
|
705
|
{
|
|
688
|
- return DictUtils.getDictLabel(dictType, dictValue);
|
706
|
+ return DictUtils.getDictLabel(dictType, dictValue, separator);
|
|
689
|
}
|
707
|
}
|
|
690
|
|
708
|
|
|
691
|
/**
|
709
|
/**
|
|
692
|
* 反向解析值字典值
|
710
|
* 反向解析值字典值
|
|
693
|
*
|
711
|
*
|
|
|
|
712
|
+ * @param dictLabel 字典标签
|
|
694
|
* @param dictType 字典类型
|
713
|
* @param dictType 字典类型
|
|
695
|
- * @param dictValue 字典标签
|
714
|
+ * @param separator 分隔符
|
|
696
|
* @return 字典值
|
715
|
* @return 字典值
|
|
697
|
*/
|
716
|
*/
|
|
698
|
- public static String reverseDictByExp(String dictType, String dictLabel) throws Exception
|
717
|
+ public static String reverseDictByExp(String dictLabel, String dictType, String separator)
|
|
699
|
{
|
718
|
{
|
|
700
|
- return DictUtils.getDictValue(dictType, dictLabel);
|
719
|
+ return DictUtils.getDictValue(dictType, dictLabel, separator);
|
|
701
|
}
|
720
|
}
|
|
702
|
|
721
|
|
|
703
|
/**
|
722
|
/**
|