From ecc1bd8417f62ebbd5b9b3181d7b69a2b6b53d67 Mon Sep 17 00:00:00 2001 From: jjLv <1981429112@qq.com> Date: Fri, 30 May 2025 14:50:29 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A3=9F=E5=A0=82-=E8=8F=9C=E5=93=81=E5=AF=BC?= =?UTF-8?q?=E5=85=A5-=E5=8A=A0=E5=85=A5=E8=AE=A1=E4=BB=B7=E6=96=B9?= =?UTF-8?q?=E5=BC=8F=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/CookDishesServiceImpl.java | 26 ++++++++++++++++--- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/service/impl/CookDishesServiceImpl.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/service/impl/CookDishesServiceImpl.java index 807bee1..3e27d29 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/service/impl/CookDishesServiceImpl.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/service/impl/CookDishesServiceImpl.java @@ -307,7 +307,7 @@ public class CookDishesServiceImpl implements ICookDishesService { private boolean validateData(MenuDishesImportDTO data, List sqlDishesNameList, List dishesNameList, ImportDishesContext context, List salesModeKeys, List materialTypeKeys) { // 校验价格 - if (data.getPrice().compareTo(BigDecimal.ZERO) <= 0) { + if (data.getPrice().compareTo(BigDecimal.ZERO) < 0) { data.setFailReason("菜品价格为负数"); return false; } @@ -318,12 +318,18 @@ public class CookDishesServiceImpl implements ICookDishesService { return false; } + // 校验菜品类别 if (CharSequenceUtil.isNotBlank(data.getDishesTypeName()) && context.getTypeMap().get(data.getDishesTypeName()) == null) { data.setFailReason(data.getDishesTypeName() + "菜品类别不存在"); return false; } - data.setTypeId(String.valueOf(context.getTypeMap().get(data.getDishesTypeName()))); + + if (CharSequenceUtil.isBlank(data.getDishesTypeName())){ + data.setTypeId("0"); + }else{ + data.setTypeId(String.valueOf(context.getTypeMap().get(data.getDishesTypeName()))); + } // 校验菜品名称 String uniqueName = generateUniqueName(data); @@ -335,12 +341,18 @@ public class CookDishesServiceImpl implements ICookDishesService { data.setFailReason("菜品名称重复或已存在"); return false; } + int two = 2; + int one = 1; + if(data.getSalesMode() == one && data.getWeight() == null ){ + data.setFailReason("按份菜品必须填写标准份量"); + return false; + } // 校验规格称重 - if (data.getSpecificationOfWeighing() != null && + if (data.getSalesMode() == two && data.getSpecificationOfWeighing() != null && data.getSpecificationOfWeighing().compareTo(BigDecimal.valueOf(50)) != 0 && data.getSpecificationOfWeighing().compareTo(BigDecimal.valueOf(100)) != 0) { - data.setFailReason("规格称重填写错误"); + data.setFailReason("称重菜品必须填写规格称重"); return false; } @@ -356,6 +368,7 @@ public class CookDishesServiceImpl implements ICookDishesService { private boolean validateMaterials(MenuDishesImportDTO data, Map materialMap, List materialTypeKeys) { if (CharSequenceUtil.isNotBlank(data.getMaterialNames())) { String[] materials = data.getMaterialNames().replace(";", ";").split(";"); +// BigDecimal totalWeight = BigDecimal.ZERO; for (String material : materials) { String[] parts = material.split("&"); if (parts.length != 3 || materialMap.get(parts[0]) == null || !materialTypeKeys.contains(parts[1]) || !NumberUtil.isNumber(parts[2])) { @@ -366,7 +379,12 @@ public class CookDishesServiceImpl implements ICookDishesService { data.setFailReason("原料重量为负数: " + parts[2]); return false; } +// totalWeight = totalWeight.add(new BigDecimal(parts[2])); } +// if (totalWeight.compareTo(data.getWeight()) < 0) { +// data.setFailReason("原料总重量小于标准重量,不符合要求"); +// return false; +// } } return true; }