|
@@ -36,8 +36,10 @@ import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
+import java.lang.reflect.Field;
|
|
|
import java.sql.Timestamp;
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.Arrays;
|
|
|
import java.util.List;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
@@ -102,6 +104,20 @@ public class BizFinancialSalaryZeroController extends BaseController {
|
|
|
{
|
|
|
ExcelUtil<BizFinancialSalaryDetailEmployee> util = new ExcelUtil<>(BizFinancialSalaryDetailEmployee.class);
|
|
|
List<BizFinancialSalaryDetailEmployee> detailList = util.importExcel(file.getInputStream());
|
|
|
+
|
|
|
+ // 获取 入Excel 表头字段
|
|
|
+ List<String> excelHeaders = util.readExcelHeaders(file.getInputStream());
|
|
|
+ // 获取实体类字段
|
|
|
+ Field[] entityFields = BizFinancialSalaryDetailEmployee.class.getDeclaredFields();
|
|
|
+ //获取导入表头
|
|
|
+ List<String> entityFieldNames = Arrays.stream(entityFields)
|
|
|
+ .map(Field::getName)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ //如果不存在模板中的字段,返回错误
|
|
|
+ if (!excelHeaders.containsAll(entityFieldNames)) {
|
|
|
+ return error("导入数据与模板不匹配!");
|
|
|
+ }
|
|
|
+
|
|
|
String message=bizFinancialSalaryService.importSalary(detailList,year,month,getTenantId()==null?0:getTenantId(),1);
|
|
|
return success(message);
|
|
|
}
|