优化商品导入Excel,获取真实的行数,剔除掉空白行

This commit is contained in:
季圣华
2023-02-12 18:14:35 +08:00
parent 71b53d0c90
commit 6999aac1ad
2 changed files with 29 additions and 2 deletions

View File

@@ -471,17 +471,19 @@ public class MaterialService {
}
Workbook workbook = Workbook.getWorkbook(file.getInputStream());
Sheet src = workbook.getSheet(0);
//获取真实的行数,剔除掉空白行
int rightRows = ExcelUtils.getRightRows(src);
List<Depot> depotList= depotService.getDepot();
int depotCount = depotList.size();
Map<String, Long> depotMap = parseDepotToMap(depotList);
User user = userService.getCurrentUser();
List<MaterialWithInitStock> mList = new ArrayList<>();
//单次导入超出1000条
if(src.getRows()>1002) {
if(rightRows > 1002) {
throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_IMPORT_OVER_LIMIT_CODE,
String.format(ExceptionConstants.MATERIAL_IMPORT_OVER_LIMIT_MSG));
}
for (int i = 2; i < src.getRows(); i++) {
for (int i = 2; i < rightRows; i++) {
String name = ExcelUtils.getContent(src, i, 0); //名称
String standard = ExcelUtils.getContent(src, i, 1); //规格
String model = ExcelUtils.getContent(src, i, 2); //型号