Sfoglia il codice sorgente

上传物料excel非必填字段增加后端验证

dongbw 8 anni fa
parent
commit
df3979b32d

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

@@ -216,7 +216,11 @@ public class BaseInfoServiceImpl implements BaseInfoService {
 						row.getCell(6).setCellType(Cell.CELL_TYPE_STRING);
 						if (null != row.getCell(6).getStringCellValue().trim()
 								&& !row.getCell(6).getStringCellValue().trim().equals("")) {
-							product.setMinPack(Double.valueOf(row.getCell(6).getStringCellValue()));
+							try {
+								product.setMinPack(Double.valueOf(row.getCell(6).getStringCellValue()));
+							} catch (NumberFormatException e) {
+								throw new IllegalOperatorException("第" + (r + 1) + "行最小包装量填写不规范,请填数字");
+							}
 						}
 					}
 					// 最小订购量
@@ -224,7 +228,11 @@ public class BaseInfoServiceImpl implements BaseInfoService {
 						row.getCell(7).setCellType(Cell.CELL_TYPE_STRING);
 						if (null != row.getCell(7).getStringCellValue().trim()
 								&& !row.getCell(7).getStringCellValue().trim().equals("")) {
-							product.setMinOrder(Double.valueOf(row.getCell(7).getStringCellValue()));
+							try {
+								product.setMinOrder(Double.valueOf(row.getCell(7).getStringCellValue()));
+							} catch (NumberFormatException e) {
+								throw new IllegalOperatorException("第" + (r + 1) + "行最小订购量填写不规范,请填数字");
+							}
 						}
 					}
 					// 交货周期
@@ -232,7 +240,11 @@ public class BaseInfoServiceImpl implements BaseInfoService {
 						row.getCell(8).setCellType(Cell.CELL_TYPE_STRING);
 						if (null != row.getCell(8).getStringCellValue().trim()
 								&& !row.getCell(8).getStringCellValue().trim().equals("")) {
-							product.setLeadtime(Double.valueOf(row.getCell(8).getStringCellValue()));
+							try {
+								product.setLeadtime(Double.valueOf(row.getCell(8).getStringCellValue()));
+							} catch (NumberFormatException e) {
+								throw new IllegalOperatorException("第" + (r + 1) + "行交货周期填写不规范,请填数字");
+							}
 						}
 					}
 					// 交货提前期
@@ -240,7 +252,11 @@ public class BaseInfoServiceImpl implements BaseInfoService {
 						row.getCell(9).setCellType(Cell.CELL_TYPE_STRING);
 						if (null != row.getCell(9).getStringCellValue().trim()
 								&& !row.getCell(9).getStringCellValue().trim().equals("")) {
-							product.setLtinstock(Double.valueOf(row.getCell(9).getStringCellValue()));
+							try {
+								product.setLtinstock(Double.valueOf(row.getCell(9).getStringCellValue()));
+							} catch (NumberFormatException e) {
+								throw new IllegalOperatorException("第" + (r + 1) + "行交货提前期填写不规范,请填数字");
+							}
 						}
 					}
 					// 判断是否存在

+ 20 - 4
src/main/java/com/uas/platform/b2b/service/impl/ProductUsersServiceImpl.java

@@ -268,7 +268,11 @@ public class ProductUsersServiceImpl implements ProductUsersService {
                         row.getCell(6).setCellType(Cell.CELL_TYPE_STRING);
                         if (null != row.getCell(6).getStringCellValue().trim()
                                 && !row.getCell(6).getStringCellValue().trim().equals("")) {
-                            temp.setPr_minpack(Double.valueOf(row.getCell(6).getStringCellValue()));
+                            try {
+                                temp.setPr_minpack(Double.valueOf(row.getCell(6).getStringCellValue()));
+                            } catch (NumberFormatException e) {
+                                throw new IllegalOperatorException("第" + (r + 1) + "行最小包装量填写不规范,请填数字");
+                            }
                         }
                     }
                     // 最小订购量
@@ -276,7 +280,11 @@ public class ProductUsersServiceImpl implements ProductUsersService {
                         row.getCell(7).setCellType(Cell.CELL_TYPE_STRING);
                         if (null != row.getCell(7).getStringCellValue().trim()
                                 && !row.getCell(7).getStringCellValue().trim().equals("")) {
-                            temp.setPr_minorder(Double.valueOf(row.getCell(7).getStringCellValue()));
+                            try {
+                                temp.setPr_minorder(Double.valueOf(row.getCell(7).getStringCellValue()));
+                            } catch (NumberFormatException e) {
+                                throw new IllegalOperatorException("第" + (r + 1) + "行最小订购量填写不规范,请填数字");
+                            }
                         }
                     }
                     // 交货周期
@@ -284,7 +292,11 @@ public class ProductUsersServiceImpl implements ProductUsersService {
                         row.getCell(8).setCellType(Cell.CELL_TYPE_STRING);
                         if (null != row.getCell(8).getStringCellValue().trim()
                                 && !row.getCell(8).getStringCellValue().trim().equals("")) {
-                            temp.setPr_leadtime(Double.valueOf(row.getCell(8).getStringCellValue()));
+                            try {
+                                temp.setPr_leadtime(Double.valueOf(row.getCell(8).getStringCellValue()));
+                            } catch (NumberFormatException e) {
+                                throw new IllegalOperatorException("第" + (r + 1) + "行交货周期填写不规范,请填数字");
+                            }
                         }
                     }
                     // 交货提前期
@@ -292,7 +304,11 @@ public class ProductUsersServiceImpl implements ProductUsersService {
                         row.getCell(9).setCellType(Cell.CELL_TYPE_STRING);
                         if (null != row.getCell(9).getStringCellValue().trim()
                                 && !row.getCell(9).getStringCellValue().trim().equals("")) {
-                            temp.setPr_ltinstock(Double.valueOf(row.getCell(9).getStringCellValue()));
+                            try {
+                                temp.setPr_ltinstock(Double.valueOf(row.getCell(9).getStringCellValue()));
+                            } catch (NumberFormatException e) {
+                                throw new IllegalOperatorException("第" + (r + 1) + "行交货提前期填写不规范,请填数字");
+                            }
                         }
                     }
                     temps.add(temp);

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

@@ -128,7 +128,11 @@ public class PurcProductServiceImpl implements PurcProductService {
 						row.getCell(6).setCellType(Cell.CELL_TYPE_STRING);
 						if (null != row.getCell(6).getStringCellValue().trim()
 								&& !row.getCell(6).getStringCellValue().trim().equals("")) {
-							product.setMinPack(Double.valueOf(row.getCell(6).getStringCellValue()));
+							try {
+								product.setMinPack(Double.valueOf(row.getCell(6).getStringCellValue()));
+							} catch (NumberFormatException e) {
+								throw new IllegalOperatorException("第" + (r + 1) + "行最小包装量填写不规范,请填数字");
+							}
 						}
 					}
 					// 最小订购量
@@ -136,7 +140,11 @@ public class PurcProductServiceImpl implements PurcProductService {
 						row.getCell(7).setCellType(Cell.CELL_TYPE_STRING);
 						if (null != row.getCell(7).getStringCellValue().trim()
 								&& !row.getCell(7).getStringCellValue().trim().equals("")) {
-							product.setMinOrder(Double.valueOf(row.getCell(7).getStringCellValue()));
+							try {
+								product.setMinOrder(Double.valueOf(row.getCell(7).getStringCellValue()));
+							} catch (NumberFormatException e) {
+								throw new IllegalOperatorException("第" + (r + 1) + "行最小订购量填写不规范,请填数字");
+							}
 						}
 					}
 					// 交货周期
@@ -144,7 +152,11 @@ public class PurcProductServiceImpl implements PurcProductService {
 						row.getCell(8).setCellType(Cell.CELL_TYPE_STRING);
 						if (null != row.getCell(8).getStringCellValue().trim()
 								&& !row.getCell(8).getStringCellValue().trim().equals("")) {
-							product.setLeadtime(Double.valueOf(row.getCell(8).getStringCellValue()));
+							try {
+								product.setLeadtime(Double.valueOf(row.getCell(8).getStringCellValue()));
+							} catch (NumberFormatException e) {
+								throw new IllegalOperatorException("第" + (r + 1) + "行交货周期填写不规范,请填数字");
+							}
 						}
 					}
 					// 交货提前期
@@ -152,7 +164,11 @@ public class PurcProductServiceImpl implements PurcProductService {
 						row.getCell(9).setCellType(Cell.CELL_TYPE_STRING);
 						if (null != row.getCell(9).getStringCellValue().trim()
 								&& !row.getCell(9).getStringCellValue().trim().equals("")) {
-							product.setLtinstock(Double.valueOf(row.getCell(9).getStringCellValue()));
+							try {
+								product.setLtinstock(Double.valueOf(row.getCell(9).getStringCellValue()));
+							} catch (NumberFormatException e) {
+								throw new IllegalOperatorException("第" + (r + 1) + "行交货提前期填写不规范,请填数字");
+							}
 						}
 					}
 					List<Product> prods = productDao.findByEnUUAndCode(SystemSession.getUser().getEnterprise().getUu(),