|
@@ -50,6 +50,7 @@ import com.ruoyi.common.core.domain.AjaxResult; |
|
@@ -50,6 +50,7 @@ import com.ruoyi.common.core.domain.AjaxResult; |
|
50
|
import com.ruoyi.common.core.text.Convert;
|
50
|
import com.ruoyi.common.core.text.Convert;
|
|
51
|
import com.ruoyi.common.exception.CustomException;
|
51
|
import com.ruoyi.common.exception.CustomException;
|
|
52
|
import com.ruoyi.common.utils.DateUtils;
|
52
|
import com.ruoyi.common.utils.DateUtils;
|
|
|
|
53
|
+import com.ruoyi.common.utils.DictUtils;
|
|
53
|
import com.ruoyi.common.utils.StringUtils;
|
54
|
import com.ruoyi.common.utils.StringUtils;
|
|
54
|
import com.ruoyi.common.utils.reflect.ReflectUtils;
|
55
|
import com.ruoyi.common.utils.reflect.ReflectUtils;
|
|
55
|
|
56
|
|
|
@@ -270,7 +271,11 @@ public class ExcelUtil<T> |
|
@@ -270,7 +271,11 @@ public class ExcelUtil<T> |
|
270
|
}
|
271
|
}
|
|
271
|
else if (StringUtils.isNotEmpty(attr.readConverterExp()))
|
272
|
else if (StringUtils.isNotEmpty(attr.readConverterExp()))
|
|
272
|
{
|
273
|
{
|
|
273
|
- val = reverseByExp(String.valueOf(val), attr.readConverterExp());
|
274
|
+ val = reverseByExp(Convert.toStr(val), attr.readConverterExp());
|
|
|
|
275
|
+ }
|
|
|
|
276
|
+ else if (StringUtils.isNotEmpty(attr.dictType()))
|
|
|
|
277
|
+ {
|
|
|
|
278
|
+ val = reverseDictByExp(attr.dictType(), Convert.toStr(val));
|
|
274
|
}
|
279
|
}
|
|
275
|
ReflectUtils.invokeSetter(entity, propertyName, val);
|
280
|
ReflectUtils.invokeSetter(entity, propertyName, val);
|
|
276
|
}
|
281
|
}
|
|
@@ -529,13 +534,18 @@ public class ExcelUtil<T> |
|
@@ -529,13 +534,18 @@ public class ExcelUtil<T> |
|
529
|
Object value = getTargetValue(vo, field, attr);
|
534
|
Object value = getTargetValue(vo, field, attr);
|
|
530
|
String dateFormat = attr.dateFormat();
|
535
|
String dateFormat = attr.dateFormat();
|
|
531
|
String readConverterExp = attr.readConverterExp();
|
536
|
String readConverterExp = attr.readConverterExp();
|
|
|
|
537
|
+ String dictType = attr.dictType();
|
|
532
|
if (StringUtils.isNotEmpty(dateFormat) && StringUtils.isNotNull(value))
|
538
|
if (StringUtils.isNotEmpty(dateFormat) && StringUtils.isNotNull(value))
|
|
533
|
{
|
539
|
{
|
|
534
|
cell.setCellValue(DateUtils.parseDateToStr(dateFormat, (Date) value));
|
540
|
cell.setCellValue(DateUtils.parseDateToStr(dateFormat, (Date) value));
|
|
535
|
}
|
541
|
}
|
|
536
|
else if (StringUtils.isNotEmpty(readConverterExp) && StringUtils.isNotNull(value))
|
542
|
else if (StringUtils.isNotEmpty(readConverterExp) && StringUtils.isNotNull(value))
|
|
537
|
{
|
543
|
{
|
|
538
|
- cell.setCellValue(convertByExp(String.valueOf(value), readConverterExp));
|
544
|
+ cell.setCellValue(convertByExp(Convert.toStr(value), readConverterExp));
|
|
|
|
545
|
+ }
|
|
|
|
546
|
+ else if (StringUtils.isNotEmpty(dictType))
|
|
|
|
547
|
+ {
|
|
|
|
548
|
+ cell.setCellValue(convertDictByExp(dictType, Convert.toStr(value)));
|
|
539
|
}
|
549
|
}
|
|
540
|
else
|
550
|
else
|
|
541
|
{
|
551
|
{
|
|
@@ -667,6 +677,30 @@ public class ExcelUtil<T> |
|
@@ -667,6 +677,30 @@ public class ExcelUtil<T> |
|
667
|
}
|
677
|
}
|
|
668
|
|
678
|
|
|
669
|
/**
|
679
|
/**
|
|
|
|
680
|
+ * 解析字典值
|
|
|
|
681
|
+ *
|
|
|
|
682
|
+ * @param dictType 字典类型
|
|
|
|
683
|
+ * @param dictValue 字典值
|
|
|
|
684
|
+ * @return 字典标签
|
|
|
|
685
|
+ */
|
|
|
|
686
|
+ public static String convertDictByExp(String dictType, String dictValue) throws Exception
|
|
|
|
687
|
+ {
|
|
|
|
688
|
+ return DictUtils.getDictLabel(dictType, dictValue);
|
|
|
|
689
|
+ }
|
|
|
|
690
|
+
|
|
|
|
691
|
+ /**
|
|
|
|
692
|
+ * 反向解析值字典值
|
|
|
|
693
|
+ *
|
|
|
|
694
|
+ * @param dictType 字典类型
|
|
|
|
695
|
+ * @param dictValue 字典标签
|
|
|
|
696
|
+ * @return 字典值
|
|
|
|
697
|
+ */
|
|
|
|
698
|
+ public static String reverseDictByExp(String dictType, String dictLabel) throws Exception
|
|
|
|
699
|
+ {
|
|
|
|
700
|
+ return DictUtils.getDictValue(dictType, dictLabel);
|
|
|
|
701
|
+ }
|
|
|
|
702
|
+
|
|
|
|
703
|
+ /**
|
|
670
|
* 编码文件名
|
704
|
* 编码文件名
|
|
671
|
*/
|
705
|
*/
|
|
672
|
public String encodingFilename(String filename)
|
706
|
public String encodingFilename(String filename)
|