Переглянути джерело

增加物料、产品、我的个人库批量导入的必填字段判断

dongbw 8 роки тому
батько
коміт
12c00ebfb0

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

@@ -144,30 +144,36 @@ public class BaseInfoServiceImpl implements BaseInfoService {
 		if (headerRow != null) {
 			for (int r = 3; r <= rowNum; r++) {
 				Row row = sheet.getRow(r);
-				if (row != null && row.getCell(0) != null && row.getCell(0).getCellType() != Cell.CELL_TYPE_BLANK) {
+				if (row != null) {
 					total++;
 					Product product = new Product();
 
 					// 物料编号
-					if (row.getCell(0) != null) {
+					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());
 					}
 
 					// 物料名称
-					if (row.getCell(1) != null) {
+					if (row.getCell(1) != null && row.getCell(1).getCellType() != Cell.CELL_TYPE_BLANK) {
 						row.getCell(1).setCellType(Cell.CELL_TYPE_STRING);
 						product.setTitle(row.getCell(1).getStringCellValue().trim());
-					}
+					} else {
+                        modelMap.put("error", "第" + (r + 1) + "行物料名称未填写");
+                        return modelMap;
+                    }
 
 					// 物料规格
-					if (row.getCell(2) != null) {
+					if (row.getCell(2) != null && row.getCell(2).getCellType() != Cell.CELL_TYPE_BLANK) {
 						row.getCell(2).setCellType(Cell.CELL_TYPE_STRING);
 						product.setSpec(row.getCell(2).getStringCellValue().trim());
-					}
+					} else {
+                        modelMap.put("error", "第" + (r + 1) + "行物料规格未填写");
+                        return modelMap;
+                    }
 
 					// 原厂型号
-					if (row.getCell(3) != null) {
+					if (row.getCell(3) != null && row.getCell(3).getCellType() != Cell.CELL_TYPE_BLANK) {
 						row.getCell(3).setCellType(Cell.CELL_TYPE_STRING);
 						product.setCmpCode(row.getCell(3).getStringCellValue().trim());
 						if (product.getCode() == null) {
@@ -176,22 +182,31 @@ public class BaseInfoServiceImpl implements BaseInfoService {
 							String code = SystemSession.getUser().getEnterprise().getUu() + sdf.format(new Date());
 							product.setCode(code);
 						}
-					}
+					} else {
+                        modelMap.put("error", "第" + (r + 1) + "行物料型号未填写");
+                        return modelMap;
+                    }
 
 					// 品牌
-					if (row.getCell(4) != null) {
+					if (row.getCell(4) != null && row.getCell(4).getCellType() != Cell.CELL_TYPE_BLANK) {
 						row.getCell(4).setCellType(Cell.CELL_TYPE_STRING);
 						product.setBrand(row.getCell(4).getStringCellValue().trim());
-					}
+					} else {
+                        modelMap.put("error", "第" + (r + 1) + "行品牌未填写");
+                        return modelMap;
+                    }
 
 					// 单位
-					if (row.getCell(5) != null) {
+					if (row.getCell(5) != null && row.getCell(5).getCellType() != Cell.CELL_TYPE_BLANK) {
 						row.getCell(5).setCellType(Cell.CELL_TYPE_STRING);
 						if (null != row.getCell(5).getStringCellValue()
 								&& !row.getCell(5).getStringCellValue().trim().equals("")) {
 							product.setUnit(row.getCell(5).getStringCellValue());
 						}
-					}
+					} else {
+                        modelMap.put("error", "第" + (r + 1) + "行单位未填写");
+                        return modelMap;
+                    }
 					// 最小包装量
 					if (row.getCell(6) != null) {
 						row.getCell(6).setCellType(Cell.CELL_TYPE_STRING);

+ 2 - 2
src/main/java/com/uas/platform/b2b/service/impl/ProductServiceImpl.java

@@ -574,8 +574,8 @@ public class ProductServiceImpl implements ProductService {
                     info.setUseruu(productSaler.getEm_uu());
                     info.setErpid(productSaler.getPs_id());
 //                    info = productUsersDao.save(info);
-					Long id = ProductUtils.updateProductUsersOne(info);
-                    erpLogger.log("ERP个人物料信息同步", "关联物料id:" + id, 1);
+					ProductUtils.updateProductUsersOne(info);
+                    erpLogger.log("ERP个人物料信息同步", "关联物料id:" + product.getId(), 1);
                 }
             }
 		}

+ 23 - 8
src/main/java/com/uas/platform/b2b/service/impl/ProductUsersServiceImpl.java

@@ -173,7 +173,7 @@ public class ProductUsersServiceImpl implements ProductUsersService {
         if (headerRow != null) {
             for (int r = 3; r <= rowNum; r++) {
                 Row row = sheet.getRow(r);
-                if (row != null && row.getCell(0) != null && row.getCell(0).getCellType() != Cell.CELL_TYPE_BLANK) {
+                if (row != null) {
                     total++;
                     Product product = new Product();
                     // 物料编号
@@ -183,36 +183,51 @@ public class ProductUsersServiceImpl implements ProductUsersService {
                     }
 
                     // 物料名称
-                    if (row.getCell(1) != null) {
+                    if (row.getCell(1) != null && row.getCell(1).getCellType() != Cell.CELL_TYPE_BLANK) {
                         row.getCell(1).setCellType(Cell.CELL_TYPE_STRING);
                         product.setTitle(row.getCell(1).getStringCellValue().trim());
+                    } else {
+                        modelMap.put("error", "第" + (r + 1) + "行物料名称未填写");
+                        return modelMap;
                     }
 
                     // 物料规格
-                    if (row.getCell(2) != null) {
+                    if (row.getCell(2) != null && row.getCell(2).getCellType() != Cell.CELL_TYPE_BLANK) {
                         row.getCell(2).setCellType(Cell.CELL_TYPE_STRING);
                         product.setSpec(row.getCell(2).getStringCellValue().trim());
+                    } else {
+                        modelMap.put("error", "第" + (r + 1) + "行物料规格未填写");
+                        return modelMap;
                     }
 
                     // 原厂型号
-                    if (row.getCell(3) != null) {
+                    if (row.getCell(3) != null && row.getCell(3).getCellType() != Cell.CELL_TYPE_BLANK) {
                         row.getCell(3).setCellType(Cell.CELL_TYPE_STRING);
                         product.setCmpCode(row.getCell(3).getStringCellValue().trim());
+                    } else {
+                        modelMap.put("error", "第" + (r + 1) + "行物料型号未填写");
+                        return modelMap;
                     }
 
                     // 品牌
-                    if (row.getCell(4) != null) {
+                    if (row.getCell(4) != null && row.getCell(4).getCellType() != Cell.CELL_TYPE_BLANK) {
                         row.getCell(4).setCellType(Cell.CELL_TYPE_STRING);
                         product.setBrand(row.getCell(4).getStringCellValue().trim());
+                    } else {
+                        modelMap.put("error", "第" + (r + 1) + "行品牌未填写");
+                        return modelMap;
                     }
 
                     // 单位
-                    if (row.getCell(5) != null) {
+                    if (row.getCell(5) != null && row.getCell(5).getCellType() != Cell.CELL_TYPE_BLANK) {
                         row.getCell(5).setCellType(Cell.CELL_TYPE_STRING);
                         if (null != row.getCell(5).getStringCellValue()
                                 && !row.getCell(5).getStringCellValue().trim().equals("")) {
                             product.setUnit(row.getCell(5).getStringCellValue());
                         }
+                    } else {
+                        modelMap.put("error", "第" + (r + 1) + "行单位未填写");
+                        return modelMap;
                     }
                     // 最小包装量
                     if (row.getCell(6) != null) {
@@ -405,9 +420,9 @@ public class ProductUsersServiceImpl implements ProductUsersService {
             prod.setEnuu(enuu);
             prod.setPrid(id);
             prod.setDate(new Date());
-            Long prId = ProductUtils.updateProductUsersOne(prod);
+            ProductUtils.updateProductUsersOne(prod);
 //            prod = productUsersDao.save(prod);
-            logger.log("我的产品库", "新增了我产品信息", "id:" + prId);
+            logger.log("我的产品库", "新增了我产品信息", "物料id:" + id);
         }
     }
 

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

@@ -54,7 +54,7 @@ public class PurcProductServiceImpl implements PurcProductService {
 		if (headerRow != null) {
 			for (int r = 3; r <= rowNum; r++) {
 				Row row = sheet.getRow(r);
-				if (row != null && row.getCell(0) != null && row.getCell(0).getCellType() != Cell.CELL_TYPE_BLANK) {
+				if (row != null) {
 					total++;
 					Product product = new Product();
 					//TODO huangct 上传文件中存在必填信息缺失的情况处理
@@ -66,19 +66,25 @@ public class PurcProductServiceImpl implements PurcProductService {
 					}
 
 					// 物料名称
-					if (row.getCell(1) != null) {
+					if (row.getCell(1) != null && row.getCell(1).getCellType() != Cell.CELL_TYPE_BLANK) {
 						row.getCell(1).setCellType(Cell.CELL_TYPE_STRING);
 						product.setTitle(row.getCell(1).getStringCellValue().trim());
+					} else {
+						modelMap.put("error", "第" + (r + 1) + "行物料名称未填写");
+						return modelMap;
 					}
 
 					// 物料规格
-					if (row.getCell(2) != null) {
+					if (row.getCell(2) != null && row.getCell(2).getCellType() != Cell.CELL_TYPE_BLANK) {
 						row.getCell(2).setCellType(Cell.CELL_TYPE_STRING);
 						product.setSpec(row.getCell(2).getStringCellValue().trim());
+					} else {
+						modelMap.put("error", "第" + (r + 1) + "行物料规格未填写");
+						return modelMap;
 					}
 
 					// 原厂型号
-					if (row.getCell(3) != null) {
+					if (row.getCell(3) != null && row.getCell(3).getCellType() != Cell.CELL_TYPE_BLANK) {
 						row.getCell(3).setCellType(Cell.CELL_TYPE_STRING);
 						product.setCmpCode(row.getCell(3).getStringCellValue().trim());
 						if (product.getCode() == null) {
@@ -87,21 +93,30 @@ public class PurcProductServiceImpl implements PurcProductService {
 							String code = SystemSession.getUser().getEnterprise().getUu() + sdf.format(new Date());
 							product.setCode(code);
 						}
-					}
+					} else {
+                        modelMap.put("error", "第" + (r + 1) + "行物料型号未填写");
+                        return modelMap;
+                    }
 
 					// 品牌
-					if (row.getCell(4) != null) {
+					if (row.getCell(4) != null && row.getCell(4).getCellType() != Cell.CELL_TYPE_BLANK) {
 						row.getCell(4).setCellType(Cell.CELL_TYPE_STRING);
 						product.setBrand(row.getCell(4).getStringCellValue().trim());
+					} else {
+						modelMap.put("error", "第" + (r + 1) + "行品牌未填写");
+						return modelMap;
 					}
 
 					// 单位
-					if (row.getCell(5) != null) {
+					if (row.getCell(5) != null && row.getCell(5).getCellType() != Cell.CELL_TYPE_BLANK) {
 						row.getCell(5).setCellType(Cell.CELL_TYPE_STRING);
 						if (null != row.getCell(5).getStringCellValue()
 								&& !row.getCell(5).getStringCellValue().trim().equals("")) {
 							product.setUnit(row.getCell(5).getStringCellValue());
 						}
+					} else {
+						modelMap.put("error", "第" + (r + 1) + "行单位未填写");
+						return modelMap;
 					}
 					// 最小包装量
 					if (row.getCell(6) != null) {

BIN
src/main/resources/jxls-tpl/sale/upload_userproduct_example.xls


+ 1 - 1
src/main/resources/test/message.properties

@@ -12,4 +12,4 @@ msgInquiryForB2B=629edeb3-a87e-4a40-a5e5-51d9ae734f1b
 msgAutoInquiryForB2B=8cf71d56-09bb-4d60-993e-ed87ce72ec3b
 messageUrl=http://message.ubtob.com/sms/send
 
-messagePublicServiceDevUrl=http://192.168.253.12:24000/message
+messagePublicServiceDevUrl=http://218.17.158.219:24000/message/

+ 3 - 3
src/main/resources/test/sys.properties

@@ -12,8 +12,8 @@ reportUploadUrl=http://print.ubtob.com/report/fileUpload?userName=B2B%s
 
 #product service url
 ## test http://218.17.158.219:24000
-productServiceUrl=http://218.17.158.219:24000
+#productServiceUrl=http://218.17.158.219:24000
+productServiceUrl=http://192.168.253.102:8080
 
 #inquiry service url
-inquiryServiceUrl=http://218.17.158.219:24000
-#inquiryServiceUrl=http://192.168.253.192:8080
+inquiryServiceUrl=http://218.17.158.219:24000