Commit e2564331 by zhangxingmin

oss-v1版本

parent c02f3a24
......@@ -70,8 +70,8 @@ public class ApiExcelController implements ApiExcelFeignClient {
*/
@Override
public Result<ImportResult> importExcel(MultipartFile file, Integer headerRow,
Integer dataStartRow, String requiredFields) {
return apiExcelService.importExcel(file,headerRow,dataStartRow,requiredFields);
Integer dataStartRow, String requiredFields,Integer checkStartRow) {
return apiExcelService.importExcel(file,headerRow,dataStartRow,requiredFields,checkStartRow);
}
/**
......
......@@ -21,7 +21,7 @@ public interface ApiExcelService {
Result<ExportResult> export(List<?> dataList, ExportParam exportParam, Class<?> entityClass);
Result<ImportResult> importExcel(MultipartFile file, Integer headerRow,
Integer dataStartRow, String requiredFields);
Integer dataStartRow, String requiredFields,Integer checkStartRow);
Result<ImportResult> simpleImport(MultipartFile file);
}
......@@ -107,13 +107,13 @@ public class ApiExcelServiceImpl implements ApiExcelService {
*/
@Override
public Result<ImportResult> importExcel(MultipartFile file, Integer headerRow,
Integer dataStartRow, String requiredFields) {
Integer dataStartRow, String requiredFields,Integer checkStartRow) {
List<String> requiredFieldList = null;
if (requiredFields != null && !requiredFields.isEmpty()) {
requiredFieldList = Arrays.asList(requiredFields.split(","));
}
ImportResult importResult = excelImportService.genericImport(file, headerRow, dataStartRow, requiredFieldList);
ImportResult importResult = excelImportService.genericImport(file, headerRow, dataStartRow, requiredFieldList,checkStartRow);
return Result.success(importResult);
}
......
......@@ -62,7 +62,9 @@ public interface ApiExcelFeignClient {
@RequestPart("file") MultipartFile file,
@RequestParam(value = "headerRow", required = false) Integer headerRow,
@RequestParam(value = "dataStartRow", required = false) Integer dataStartRow,
@RequestParam(value = "requiredFields", required = false) String requiredFields);
@RequestParam(value = "requiredFields", required = false) String requiredFields,
@RequestParam(value = "checkStartRow", required = false) Integer checkStartRow
);
/**
* 简化导入接口
......
......@@ -40,8 +40,7 @@ public class ApiExcelFeignFallbackFactory implements FallbackFactory<ApiExcelFei
}
@Override
public Result<ImportResult> importExcel(MultipartFile file, Integer headerRow,
Integer dataStartRow, String requiredFields) {
public Result<ImportResult> importExcel(MultipartFile file, Integer headerRow, Integer dataStartRow, String requiredFields, Integer checkStartRow) {
return null;
}
......
......@@ -12,7 +12,7 @@ public interface ExcelImportService {
MultipartFile file,
Integer headerRow,
Integer dataStartRow,
List<String> requiredFields);
List<String> requiredFields,Integer checkStartRow);
ImportResult simpleImport(MultipartFile file);
}
......@@ -33,7 +33,7 @@ public class ExcelImportServiceImpl implements ExcelImportService {
public ImportResult genericImport(MultipartFile file,
Integer headerRow,
Integer dataStartRow,
List<String> requiredFields) {
List<String> requiredFields,Integer checkStartRow) {
ImportResult result = new ImportResult();
......@@ -66,7 +66,7 @@ public class ExcelImportServiceImpl implements ExcelImportService {
// 4. 数据验证
if (requiredFields != null && !requiredFields.isEmpty()) {
ValidationResult validationResult =
validateData(data, requiredFields, dataStartRowNum); // 传入dataStartRowNum
validateData(data, requiredFields, dataStartRowNum,checkStartRow); // 传入dataStartRowNum
result.setValid(validationResult.isValid());
result.setErrorMessages(validationResult.getErrors());
} else {
......@@ -96,7 +96,7 @@ public class ExcelImportServiceImpl implements ExcelImportService {
*/
@Override
public ImportResult simpleImport(MultipartFile file) {
return genericImport(file, 0, 1, null);
return genericImport(file, 0, 1, null,null);
}
/**
......@@ -278,13 +278,14 @@ public class ExcelImportServiceImpl implements ExcelImportService {
*/
public static ValidationResult validateData(List<Map<String, Object>> data,
List<String> requiredFields,
int dataStartRow) { // 新增参数
int dataStartRow,Integer checkStartRow) { // 新增参数
ValidationResult result = new ValidationResult();
result.setValid(true);
for (int i = 0; i < data.size(); i++) {
Map<String, Object> row = data.get(i);
int excelRowNum = dataStartRow + i + 1; // 计算Excel中的实际行号
// int excelRowNum = dataStartRow + i + 1; // 计算Excel中的实际行号
Integer excelRowNum = checkStartRow + i; // 计算Excel中的实际行号
// 检查必填字段
for (String field : requiredFields) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment