导入统一校验

This commit is contained in:
2022-01-24 17:09:55 +08:00
parent b40371a84f
commit 3f0ad6f923
2 changed files with 155 additions and 1 deletions
@@ -253,9 +253,21 @@ public class ${entityName}Controller {
try {
List<${entityName}Page> list = ExcelImportUtil.importExcel(file.getInputStream(), ${entityName}Page.class, params);
for (${entityName}Page page : list) {
int lineNumber = i + 1;
${entityName} po = new ${entityName}();
BeanUtils.copyProperties(page, po);
${entityName?uncap_first}Service.saveMain(po, <#list subTables as sub>page.get${sub.entityName}List()<#if sub_has_next>,</#if></#list>);
try {
List<String> errorList = ValidUtil.validateReturnList(po);
if (!errorList.isEmpty()){
errorLines++;
errorMessage.add("第 " + lineNumber + " 行:"+ StringUtils.join(errorList,""));
}
${entityName?uncap_first}Service.saveMain(po, <#list subTables as sub>page.get${sub.entityName}List()<#if sub_has_next>,</#if></#list>);
} catch (Exception e) {
// 通过索引名判断出错信息
errorMessage.add("第 " + lineNumber + " 行:未知错误");
log.error(e.getMessage(), e);
}
}
return Result.OK("文件导入成功!数据行数:" + list.size());
} catch (Exception e) {