Bladeren bron

物料上传数量超过限制时给出提示修改

dongbw 7 jaren geleden
bovenliggende
commit
4712406aa1

+ 5 - 5
src/main/java/com/uas/platform/b2b/service/impl/BaseInfoServiceImpl.java

@@ -129,9 +129,9 @@ public class BaseInfoServiceImpl implements BaseInfoService {
 	private ProductStatusDao productStatusDao;
 
 	/**
-	 * 一次上传允许的最大数量 (前三行为标题  从0开始)
+	 * 一次上传允许的最大数量
 	 */
-	private final static Integer MAX_ROWNUM = 5002;
+	private final static Integer MAX_ROWNUM = 5000;
 
 	
 	/**
@@ -147,9 +147,6 @@ public class BaseInfoServiceImpl implements BaseInfoService {
 		Sheet sheet = workbook.getSheetAt(0);
 		String codePrefix = "PR" + DateUtils.format(new Date(), "yyMMddHHmmss") + StringUtil.getRandomNumber(3);
 		int rowNum = sheet.getLastRowNum();
-		if (rowNum > MAX_ROWNUM) {
-			throw new IllegalOperatorException("单次上传不超过5000条");
-		}
 		Row headerRow = sheet.getRow(0);
 		int total = 0;
 		if (headerRow != null) {
@@ -303,6 +300,9 @@ public class BaseInfoServiceImpl implements BaseInfoService {
 					modelMap.put("products", productsInfo);
 				}
 			}
+            if (total > MAX_ROWNUM) {
+                throw new IllegalOperatorException("单次上传不超过5000条");
+            }
 			if (!CollectionUtils.isEmpty(products)) {
 				try {
 					ProductUtils.paginationUpdate(products);

+ 5 - 6
src/main/java/com/uas/platform/b2b/service/impl/ProductUsersServiceImpl.java

@@ -68,9 +68,9 @@ public class ProductUsersServiceImpl implements ProductUsersService {
     private ProductTempDao productTempDao;
 
     /**
-     * 一次上传允许的最大数量 (前三行为标题 从0开始)
+     * 一次上传允许的最大数量
      */
-    private final static Integer MAX_ROWNUM = 5002;
+    private final static Integer MAX_ROWNUM = 5000;
 
     @Override
     public SPage<ProductUsers> findProductInfoByPageInfo(PageInfo pageInfo) {
@@ -181,9 +181,6 @@ public class ProductUsersServiceImpl implements ProductUsersService {
         String codePrefix = "PR" + DateUtils.format(new Date(), "yyMMddHHmmss") + StringUtil.getRandomNumber(3);
         Sheet sheet = workbook.getSheetAt(0);
         int rowNum = sheet.getLastRowNum();
-        if (rowNum > MAX_ROWNUM) {
-            throw new IllegalOperatorException("单次上传不超过5000条");
-        }
         Row headerRow = sheet.getRow(0);
         int total = 0;
         short isSale = Constant.YES;
@@ -301,7 +298,9 @@ public class ProductUsersServiceImpl implements ProductUsersService {
                     temps.add(temp);
                 }
             }
-
+            if (total > MAX_ROWNUM) {
+                throw new IllegalOperatorException("单次上传不超过5000条");
+            }
             modelMap.put("total", total);
             // 本地校验
             checkTempProducts(temps, modelMap);

+ 5 - 5
src/main/java/com/uas/platform/b2b/service/impl/PurcProductServiceImpl.java

@@ -40,9 +40,9 @@ public class PurcProductServiceImpl implements PurcProductService {
 	private ProductStatusDao productStatusDao;
 
 	/**
-	 * 一次上传允许的最大数量 (前三行为标题  从0开始)
+	 * 一次上传允许的最大数量
 	 */
-	private final static Integer MAX_ROWNUM = 5002;
+	private final static Integer MAX_ROWNUM = 5000;
 
 	/**
 	 * 批量导入物料资料
@@ -58,9 +58,6 @@ public class PurcProductServiceImpl implements PurcProductService {
 		Sheet sheet = workbook.getSheetAt(0);
 		String codePrefix = "PR" + DateUtils.format(new Date(), "yyMMddHHmmss") + StringUtil.getRandomNumber(3);
 		int rowNum = sheet.getLastRowNum();
-		if (rowNum > MAX_ROWNUM) {
-			throw new IllegalOperatorException("单次上传不超过5000条");
-		}
 		Row headerRow = sheet.getRow(0);
 		int total = 0;
 		if (headerRow != null) {
@@ -324,6 +321,9 @@ public class PurcProductServiceImpl implements PurcProductService {
 					modelMap.put("products", productsInfo);
 				}
 			}
+			if (total > MAX_ROWNUM) {
+				throw new IllegalOperatorException("单次上传不超过5000条");
+			}
 			if (!CollectionUtils.isEmpty(products) || !CollectionUtils.isEmpty(oldProducts)) {
 				try {
 				    products.addAll(oldProducts);