|
...
|
...
|
@@ -305,8 +305,29 @@ public class JeecgController2<T, t, b,w, V extends IService<t>, S extends IServi |
|
|
|
return Result.error("文件导入失败!");
|
|
|
|
}
|
|
|
|
|
|
|
|
//工资导入
|
|
|
|
// 去除列表中对象字段的空格
|
|
|
|
private void trimSpaces(List<T> list) {
|
|
|
|
for (T item : list) {
|
|
|
|
Field[] fields = item.getClass().getDeclaredFields();
|
|
|
|
for (Field field : fields) {
|
|
|
|
field.setAccessible(true); // 确保可以访问私有字段
|
|
|
|
try {
|
|
|
|
if (field.getType() == String.class) {
|
|
|
|
String value = (String) field.get(item);
|
|
|
|
if (value != null) {
|
|
|
|
// 去除空格并更新字段值
|
|
|
|
String trimmedValue = value.replaceAll("\\s", "");
|
|
|
|
field.set(item, trimmedValue);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (IllegalAccessException e) {
|
|
|
|
// 异常处理
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//工资导入
|
|
|
|
@Transactional
|
|
|
|
public Result<?> importExcelgz(HttpServletRequest request, HttpServletResponse response, Class<T> clazz, Class<b> base,Class<w> workTime) {
|
|
|
|
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
|
|
...
|
...
|
@@ -323,7 +344,8 @@ public class JeecgController2<T, t, b,w, V extends IService<t>, S extends IServi |
|
|
|
|
|
|
|
try {
|
|
|
|
List<T> list = ExcelImportUtil.importExcel(file.getInputStream(), clazz, params);
|
|
|
|
|
|
|
|
// 去除导入数据的空格
|
|
|
|
trimSpaces(list);
|
|
|
|
List<T> shuju = new ArrayList<>();
|
|
|
|
//update-begin-author:taoyan date:20190528 for:批量插入数据
|
|
|
|
long start = System.currentTimeMillis();
|
...
|
...
|
|