食堂-菜品导入-加入计价方式校验
This commit is contained in:
parent
ae9e074818
commit
ecc1bd8417
|
|
@ -307,7 +307,7 @@ public class CookDishesServiceImpl implements ICookDishesService {
|
||||||
private boolean validateData(MenuDishesImportDTO data, List<String> sqlDishesNameList, List<String> dishesNameList,
|
private boolean validateData(MenuDishesImportDTO data, List<String> sqlDishesNameList, List<String> dishesNameList,
|
||||||
ImportDishesContext context, List<Integer> salesModeKeys, List<String> materialTypeKeys) {
|
ImportDishesContext context, List<Integer> salesModeKeys, List<String> materialTypeKeys) {
|
||||||
// 校验价格
|
// 校验价格
|
||||||
if (data.getPrice().compareTo(BigDecimal.ZERO) <= 0) {
|
if (data.getPrice().compareTo(BigDecimal.ZERO) < 0) {
|
||||||
data.setFailReason("菜品价格为负数");
|
data.setFailReason("菜品价格为负数");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -318,12 +318,18 @@ public class CookDishesServiceImpl implements ICookDishesService {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// 校验菜品类别
|
// 校验菜品类别
|
||||||
if (CharSequenceUtil.isNotBlank(data.getDishesTypeName()) && context.getTypeMap().get(data.getDishesTypeName()) == null) {
|
if (CharSequenceUtil.isNotBlank(data.getDishesTypeName()) && context.getTypeMap().get(data.getDishesTypeName()) == null) {
|
||||||
data.setFailReason(data.getDishesTypeName() + "菜品类别不存在");
|
data.setFailReason(data.getDishesTypeName() + "菜品类别不存在");
|
||||||
return false;
|
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);
|
String uniqueName = generateUniqueName(data);
|
||||||
|
|
@ -335,12 +341,18 @@ public class CookDishesServiceImpl implements ICookDishesService {
|
||||||
data.setFailReason("菜品名称重复或已存在");
|
data.setFailReason("菜品名称重复或已存在");
|
||||||
return false;
|
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(50)) != 0 &&
|
||||||
data.getSpecificationOfWeighing().compareTo(BigDecimal.valueOf(100)) != 0) {
|
data.getSpecificationOfWeighing().compareTo(BigDecimal.valueOf(100)) != 0) {
|
||||||
data.setFailReason("规格称重填写错误");
|
data.setFailReason("称重菜品必须填写规格称重");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -356,6 +368,7 @@ public class CookDishesServiceImpl implements ICookDishesService {
|
||||||
private boolean validateMaterials(MenuDishesImportDTO data, Map<String, Long> materialMap, List<String> materialTypeKeys) {
|
private boolean validateMaterials(MenuDishesImportDTO data, Map<String, Long> materialMap, List<String> materialTypeKeys) {
|
||||||
if (CharSequenceUtil.isNotBlank(data.getMaterialNames())) {
|
if (CharSequenceUtil.isNotBlank(data.getMaterialNames())) {
|
||||||
String[] materials = data.getMaterialNames().replace(";", ";").split(";");
|
String[] materials = data.getMaterialNames().replace(";", ";").split(";");
|
||||||
|
// BigDecimal totalWeight = BigDecimal.ZERO;
|
||||||
for (String material : materials) {
|
for (String material : materials) {
|
||||||
String[] parts = material.split("&");
|
String[] parts = material.split("&");
|
||||||
if (parts.length != 3 || materialMap.get(parts[0]) == null || !materialTypeKeys.contains(parts[1]) || !NumberUtil.isNumber(parts[2])) {
|
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]);
|
data.setFailReason("原料重量为负数: " + parts[2]);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
// totalWeight = totalWeight.add(new BigDecimal(parts[2]));
|
||||||
}
|
}
|
||||||
|
// if (totalWeight.compareTo(data.getWeight()) < 0) {
|
||||||
|
// data.setFailReason("原料总重量小于标准重量,不符合要求");
|
||||||
|
// return false;
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue