jsk 预定餐
This commit is contained in:
parent
0bfc6b84b5
commit
908dbaaef0
|
|
@ -6,7 +6,7 @@ import com.bonus.core.menu.utils.NutritionEntity;
|
|||
|
||||
import java.util.Map;
|
||||
|
||||
public interface MenuDishesService extends IService<MenuDishes> {
|
||||
public interface MenuDishesService {
|
||||
// Long addMenuDishes(MenuDishesAddDTO dishesAddDTO, Integer customId);
|
||||
//
|
||||
// Page<MenuDishesPageVO> getMenuDishesPage(String content);
|
||||
|
|
|
|||
|
|
@ -16,6 +16,8 @@ import com.bonus.core.menu.utils.NutritionEntity;
|
|||
import com.bonus.core.menu.utils.NutritionEntityUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
|
@ -23,7 +25,7 @@ import java.util.Map;
|
|||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
public class MenuDishesServiceImpl extends ServiceImpl<MenuDishesMapper, MenuDishes> implements MenuDishesService {
|
||||
public class MenuDishesServiceImpl implements MenuDishesService {
|
||||
private static final Logger log = LoggerFactory.getLogger(MenuDishesServiceImpl.class);
|
||||
|
||||
// @Lazy
|
||||
|
|
@ -115,9 +117,9 @@ public class MenuDishesServiceImpl extends ServiceImpl<MenuDishesMapper, MenuDis
|
|||
// name = "yunshitangTaskExecutor"
|
||||
// )
|
||||
// private AsyncTaskExecutor asyncTaskExecutor;
|
||||
// @Autowired
|
||||
// @Lazy
|
||||
// private MenuDishesMapper menuDishesMapper;
|
||||
@Autowired
|
||||
@Lazy
|
||||
private MenuDishesMapper menuDishesMapper;
|
||||
// @Autowired
|
||||
// @Lazy
|
||||
// private MenuaiServiceApi menuaiServiceApi;
|
||||
|
|
@ -182,6 +184,33 @@ public class MenuDishesServiceImpl extends ServiceImpl<MenuDishesMapper, MenuDis
|
|||
// @Transactional(
|
||||
// rollbackFor = {Exception.class}
|
||||
// )
|
||||
|
||||
@Override
|
||||
public NutritionEntity getNutrientInfo(Map<Long, Double> dishesQuantityMap) {
|
||||
LogUtil.info("查询营养信息", dishesQuantityMap);
|
||||
if (CollUtil.isNotEmpty(dishesQuantityMap)) {
|
||||
List<Long> dishesIdList = ListUtil.toList(dishesQuantityMap.keySet());
|
||||
List<MenuDishes> menuDishesList = this.getMenuDishesList(dishesIdList);
|
||||
if (CollUtil.isNotEmpty(menuDishesList)) {
|
||||
List<NutritionEntity> nutritionEntityList = (List)menuDishesList.stream().map((item) -> {
|
||||
Double weight = (Double)dishesQuantityMap.get(item.getDishesId());
|
||||
NutritionEntity nutritionEntity = (NutritionEntity) BeanUtil.copyProperties(item, NutritionEntity.class, new String[0]);
|
||||
nutritionEntity.setWeight(weight);
|
||||
nutritionEntity.setBaseWeight(item.getWeight());
|
||||
return nutritionEntity;
|
||||
}).collect(Collectors.toList());
|
||||
return NutritionEntityUtil.countNutrition(nutritionEntityList);
|
||||
}
|
||||
}
|
||||
|
||||
return new NutritionEntity();
|
||||
}
|
||||
|
||||
public List<MenuDishes> getMenuDishesList(List<Long> dishesIdList) {
|
||||
return null;
|
||||
// menuDishesMapper.list((Wrapper)((LambdaQueryWrapper<MenuDishes>) Wrappers.lambdaQuery(MenuDishes.class)
|
||||
// .in(MenuDishes::getDishesId, dishesIdList)).eq(MenuDishes::getDelFlag, LeConstants.COMMON_NO));
|
||||
}
|
||||
// public Long addMenuDishes(MenuDishesAddDTO dishesAddDTO, Integer customId) {
|
||||
// Long count = ((MenuDishesMapper)this.baseMapper).selectCount((Wrapper)((LambdaQueryWrapper)Wrappers.lambdaQuery(MenuDishes.class).eq(MenuDishes::getDishesName, dishesAddDTO.getDishesName())).eq(MenuDishes::getDelFlag, DelFlagEnum.DEL_FALSE.key()));
|
||||
// if (count != null && count > 0L) {
|
||||
|
|
@ -2551,31 +2580,6 @@ public class MenuDishesServiceImpl extends ServiceImpl<MenuDishesMapper, MenuDis
|
|||
// }, Collectors.mapping(DishesLabelDto::getName, Collectors.toList())));
|
||||
// }
|
||||
|
||||
@Override
|
||||
public NutritionEntity getNutrientInfo(Map<Long, Double> dishesQuantityMap) {
|
||||
LogUtil.info("查询营养信息", dishesQuantityMap);
|
||||
if (CollUtil.isNotEmpty(dishesQuantityMap)) {
|
||||
List<Long> dishesIdList = ListUtil.toList(dishesQuantityMap.keySet());
|
||||
List<MenuDishes> menuDishesList = this.getMenuDishesList(dishesIdList);
|
||||
if (CollUtil.isNotEmpty(menuDishesList)) {
|
||||
List<NutritionEntity> nutritionEntityList = (List)menuDishesList.stream().map((item) -> {
|
||||
Double weight = (Double)dishesQuantityMap.get(item.getDishesId());
|
||||
NutritionEntity nutritionEntity = (NutritionEntity) BeanUtil.copyProperties(item, NutritionEntity.class, new String[0]);
|
||||
nutritionEntity.setWeight(weight);
|
||||
nutritionEntity.setBaseWeight(item.getWeight());
|
||||
return nutritionEntity;
|
||||
}).collect(Collectors.toList());
|
||||
return NutritionEntityUtil.countNutrition(nutritionEntityList);
|
||||
}
|
||||
}
|
||||
|
||||
return new NutritionEntity();
|
||||
}
|
||||
|
||||
public List<MenuDishes> getMenuDishesList(List<Long> dishesIdList) {
|
||||
return this.list((Wrapper)((LambdaQueryWrapper<MenuDishes>) Wrappers.lambdaQuery(MenuDishes.class)
|
||||
.in(MenuDishes::getDishesId, dishesIdList)).eq(MenuDishes::getDelFlag, LeConstants.COMMON_NO));
|
||||
}
|
||||
//
|
||||
// public void updateDishesNutrition(List<Long> materialIds) {
|
||||
// List<MenuUpdateDishesModel> menuUpdateDishesModels = this.menuMaterialDishesService.selectDishesList(materialIds);
|
||||
|
|
|
|||
Reference in New Issue