|
|
@@ -165,10 +165,8 @@ public class ProductUsersServiceImpl implements ProductUsersService {
|
|
|
@Override
|
|
|
public ModelMap releaseByWorkbook(Workbook workbook) throws Exception {
|
|
|
ModelMap modelMap = new ModelMap();
|
|
|
- List<ProductUsers> productUsers = new ArrayList<ProductUsers>();
|
|
|
List<String> alters = new ArrayList<String>();
|
|
|
List<String> existedProducts = new ArrayList<>();
|
|
|
- List<Product> products = new ArrayList<>();
|
|
|
Long enuu = SystemSession.getUser().getEnterprise().getUu();
|
|
|
Long useruu = SystemSession.getUser().getUserUU();
|
|
|
// 生成随机物料编码
|
|
|
@@ -179,18 +177,24 @@ public class ProductUsersServiceImpl implements ProductUsersService {
|
|
|
int rowNum = sheet.getLastRowNum();
|
|
|
Row headerRow = sheet.getRow(0);
|
|
|
int total = 0;
|
|
|
+ // 上传成功的个人产品数量
|
|
|
+ int successProductUser = 0;
|
|
|
if (headerRow != null) {
|
|
|
// 根据每次发送数据量,计算发送几次
|
|
|
int times = (int) Math.ceil((rowNum - 2) / ONE_TIME_DATA_SIZE);
|
|
|
int r = 3;
|
|
|
for (int i = 1; i <= times; i++) {
|
|
|
- for (; r <= (rowNum <= i * ONE_TIME_DATA_SIZE ? rowNum : i * ONE_TIME_DATA_SIZE); r++) {
|
|
|
+ // 每批次都需要重置用来保存的list
|
|
|
+ List<ProductUsers> productUsers = new ArrayList<ProductUsers>();
|
|
|
+ List<Product> products = new ArrayList<>();
|
|
|
+ int end = (int) (i * ONE_TIME_DATA_SIZE + 2);
|
|
|
+ for (; r <= (rowNum <= end ? rowNum : end); r++) {
|
|
|
Row row = sheet.getRow(r);
|
|
|
- if (row != null) {
|
|
|
+ if (row != null && row.getCell(1) != null && row.getCell(1).getCellType() != Cell.CELL_TYPE_BLANK) {
|
|
|
total++;
|
|
|
Product product = new Product();
|
|
|
// 物料编号
|
|
|
- if (row.getCell(0) != null && row.getCell(1).getCellType() != Cell.CELL_TYPE_BLANK) {
|
|
|
+ if (row.getCell(0) != null && row.getCell(0).getCellType() != Cell.CELL_TYPE_BLANK) {
|
|
|
row.getCell(0).setCellType(Cell.CELL_TYPE_STRING);
|
|
|
product.setCode(row.getCell(0).getStringCellValue().trim());
|
|
|
} else {
|
|
|
@@ -346,7 +350,6 @@ public class ProductUsersServiceImpl implements ProductUsersService {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- modelMap.put("total", total);
|
|
|
if (!CollectionUtils.isEmpty(products)) {
|
|
|
try {
|
|
|
List<Long> idList = ProductUtils.update(products);
|
|
|
@@ -364,26 +367,21 @@ public class ProductUsersServiceImpl implements ProductUsersService {
|
|
|
}
|
|
|
if (!CollectionUtils.isEmpty(productUsers)) {
|
|
|
ProductUtils.updateProductUsersByBatch(productUsers);
|
|
|
- modelMap.put("success", productUsers.size());
|
|
|
+ successProductUser = successProductUser + productUsers.size();
|
|
|
}
|
|
|
}
|
|
|
- if(alters.size() > 0)
|
|
|
- modelMap.put("alters", alters);
|
|
|
- if (existedProducts.size() > 0) {
|
|
|
- modelMap.put("existed", existedProducts);
|
|
|
- }
|
|
|
} catch (Exception e) {
|
|
|
modelMap.put("error", "物料添加失败");
|
|
|
}
|
|
|
- } else {
|
|
|
- modelMap.put("success", 0);
|
|
|
- if (existedProducts.size() > 0) {
|
|
|
- modelMap.put("existed", existedProducts);
|
|
|
- }
|
|
|
- if(alters.size() > 0)
|
|
|
- modelMap.put("alters", alters);
|
|
|
}
|
|
|
}
|
|
|
+ modelMap.put("total", total);
|
|
|
+ modelMap.put("success", successProductUser);
|
|
|
+ if(alters.size() > 0)
|
|
|
+ modelMap.put("alters", alters);
|
|
|
+ if (existedProducts.size() > 0) {
|
|
|
+ modelMap.put("existed", existedProducts);
|
|
|
+ }
|
|
|
}
|
|
|
return modelMap;
|
|
|
}
|