Browse Source

增加爬虫上传文件行数限制

wangyc 8 years ago
parent
commit
987f12cafe

+ 6 - 0
src/main/java/com/uas/platform/b2c/prod/product/component/service/impl/ComponentSubmitServiceImpl.java

@@ -350,6 +350,8 @@ public class ComponentSubmitServiceImpl implements ComponentSubmitService {
 		Set<ComponentCrawlSubDetail> submitDetails = new HashSet<ComponentCrawlSubDetail>();
 		Sheet sheet = workbook.getSheetAt(0);
 		int rowNum = sheet.getLastRowNum();
+		if (rowNum > 10000)
+			throw new IllegalOperatorException("上传文件不可超过10000行");
 		Row headerRow = sheet.getRow(0);
 		if (headerRow.getCell(0) != null && headerRow.getCell(1) != null && headerRow.getCell(2) != null && headerRow.getCell(3) != null && headerRow.getCell(4) != null
 				&& headerRow.getCell(5) != null) {
@@ -534,6 +536,8 @@ public class ComponentSubmitServiceImpl implements ComponentSubmitService {
 		List<ComponentCrawl> components = new ArrayList<ComponentCrawl>();
 		Sheet sheet = workbook.getSheetAt(0);
 		int rowNum = sheet.getLastRowNum();
+		if (rowNum > 10000)
+			throw new IllegalOperatorException("上传文件不可超过10000行");
 		Row fourthRow = sheet.getRow(3);
 		if (fourthRow.getCell(1) != null && fourthRow.getCell(2) != null && fourthRow.getCell(3) != null && fourthRow.getCell(4) != null) {
 			// 商城类目
@@ -722,6 +726,8 @@ public class ComponentSubmitServiceImpl implements ComponentSubmitService {
 		List<ComponentCrawl> components = new ArrayList<ComponentCrawl>();
 		Sheet sheet = workbook.getSheetAt(0);
 		int rowNum = sheet.getLastRowNum();
+		if (rowNum > 10000)
+			throw new IllegalOperatorException("上传文件不可超过10000行");
 		Date date = new Date();
 		
 		KindCrawl kindCrawl = kindContrastDao.findOne(kindContrastId);