mirror of
https://gitee.com/dromara/RuoYi-Vue-Plus.git
synced 2026-09-18 09:35:29 +08:00
ruoyi-tpl 文件模板打印后台
This commit is contained in:
parent
61560691d9
commit
c9423283da
@ -102,7 +102,7 @@ public class NiceDoc implements Closeable {
|
|||||||
*
|
*
|
||||||
* @param entity
|
* @param entity
|
||||||
*/
|
*/
|
||||||
public void pushLabels(Object entity) {
|
public void pushLabels(Object entity) throws IllegalAccessException {
|
||||||
pushLabels(NiceUtils.entityToMap(entity));
|
pushLabels(NiceUtils.entityToMap(entity));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -3,6 +3,7 @@ package com.lizhw.tpl.module.docx.ttt;
|
|||||||
import org.apache.poi.util.StringUtil;
|
import org.apache.poi.util.StringUtil;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
|
import java.text.ParseException;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
@ -44,18 +45,14 @@ public class NiceUtils {
|
|||||||
* @param entity
|
* @param entity
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static Map<String, Object> entityToMap(Object entity) {
|
public static Map<String, Object> entityToMap(Object entity) throws IllegalAccessException {
|
||||||
Map<String, Object> map = new HashMap<>();
|
Map<String, Object> map = new HashMap<>();
|
||||||
for (Field field : entity.getClass().getDeclaredFields()) {
|
for (Field field : entity.getClass().getDeclaredFields()) {
|
||||||
try {
|
|
||||||
boolean flag = field.isAccessible();
|
boolean flag = field.isAccessible();
|
||||||
field.setAccessible(true);
|
field.setAccessible(true);
|
||||||
Object o = field.get(entity);
|
Object o = field.get(entity);
|
||||||
map.put(field.getName(), o);
|
map.put(field.getName(), o);
|
||||||
field.setAccessible(flag);
|
field.setAccessible(flag);
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
@ -66,7 +63,7 @@ public class NiceUtils {
|
|||||||
* @param entityList
|
* @param entityList
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static List<Map<String, Object>> listEntityToMap(List<Object> entityList) {
|
public static List<Map<String, Object>> listEntityToMap(List<Object> entityList) throws IllegalAccessException {
|
||||||
List<Map<String, Object>> list = new ArrayList<>();
|
List<Map<String, Object>> list = new ArrayList<>();
|
||||||
for (Object entity : entityList) {
|
for (Object entity : entityList) {
|
||||||
list.add(entityToMap(entity));
|
list.add(entityToMap(entity));
|
||||||
@ -121,18 +118,14 @@ public class NiceUtils {
|
|||||||
* @return 解析成功返回Date对象,解析失败抛出异常
|
* @return 解析成功返回Date对象,解析失败抛出异常
|
||||||
* @throws Exception 如果无法解析日期字符串
|
* @throws Exception 如果无法解析日期字符串
|
||||||
*/
|
*/
|
||||||
public static Date parseDate(String dateString, String[] formats) throws Exception {
|
public static Date parseDate(String dateString, String[] formats) throws ParseException {
|
||||||
for (String format : formats) {
|
for (String format : formats) {
|
||||||
SimpleDateFormat formatter = new SimpleDateFormat(format);
|
SimpleDateFormat formatter = new SimpleDateFormat(format);
|
||||||
formatter.setTimeZone(TimeZone.getTimeZone("UTC")); // 设置时区,根据需要调整
|
formatter.setTimeZone(TimeZone.getTimeZone("UTC")); // 设置时区,根据需要调整
|
||||||
try {
|
|
||||||
return formatter.parse(dateString);
|
return formatter.parse(dateString);
|
||||||
} catch (Exception e) {
|
|
||||||
// 当前格式不匹配,尝试下一个格式
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// 所有格式都不匹配,抛出异常
|
// 所有格式都不匹配,抛出异常
|
||||||
throw new Exception("无法解析日期: " + dateString);
|
throw new RuntimeException("无法解析日期: " + dateString);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user