From e470a01f2c765826c4c2a0df422edb4f59adf863 Mon Sep 17 00:00:00 2001 From: sxu <602087911@qq.com> Date: Wed, 16 Jul 2025 15:02:17 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=BC=E5=85=A5=E8=8F=9C=E8=B0=B1=E6=A0=BC?= =?UTF-8?q?=E5=BC=8F=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../core/cook/controller/CookRecipeController.java | 8 +++----- .../core/cook/service/impl/CookRecipeServiceImpl.java | 3 +++ 2 files changed, 6 insertions(+), 5 deletions(-) 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()