diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/controller/CookRecipeController.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/controller/CookRecipeController.java index 8fbc899..b783b1c 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/controller/CookRecipeController.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/controller/CookRecipeController.java @@ -164,12 +164,10 @@ public class CookRecipeController extends BaseController { return ObjectUtil.isNull(excel) ? AjaxResult.error("请选择导入文件 ^_^") : AjaxResult.success(this.cookRecipeService.recipeImportDishes(excel, recipeId)); }catch (Exception e){ - String message = e.toString(); - //取倒数第二个:之后的信息 - String finalMessage = message.substring(message.lastIndexOf(":") - 7); + String message = e.getMessage(); + String finalMessage = message.substring(message.lastIndexOf(":") + 1); String errorMes = finalMessage.replace("Error:", ""); - System.err.println("errorMes="+errorMes); - return error("导入失败:"+errorMes); + return error("导入失败:"+errorMes); } } diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/service/impl/CookRecipeServiceImpl.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/service/impl/CookRecipeServiceImpl.java index 7cfaaef..24e2eb3 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/service/impl/CookRecipeServiceImpl.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/service/impl/CookRecipeServiceImpl.java @@ -470,6 +470,9 @@ public class CookRecipeServiceImpl implements ICookRecipeService { readSheet.getCustomReadListenerList().add(cookRecipeImportListener); } } + if (CollectionUtils.isEmpty(listeners)) { + throw new ServiceException("导入文件格式错误,未找到菜谱信息"); + } excelReader.read(readSheets); notImportDishesNames.addAll( listeners.stream()