Merge remote-tracking branch 'origin/master'

This commit is contained in:
jjLv 2025-05-12 09:28:29 +08:00
commit 3cb9a5023e
18 changed files with 192 additions and 74 deletions

View File

@ -26,7 +26,7 @@ import com.bonus.common.core.web.page.TableDataInfo;
/** /**
* 人员换卡历史记录Controller * 人员换卡历史记录Controller
* *
* @author xsheng * @author xsheng
* @date 2025-04-23 * @date 2025-04-23
*/ */
@ -85,7 +85,7 @@ public class AccCardHisController extends BaseController {
try { try {
return toAjax(accCardHisService.insertAccCardHis(accCardHis)); return toAjax(accCardHisService.insertAccCardHis(accCardHis));
} catch (Exception e) { } catch (Exception e) {
return error("系统错误, " + e.getMessage()); return error(e.getMessage());
} }
} }

View File

@ -53,7 +53,7 @@ public class AppletRecipeH5Controller extends BaseController {
startPage(); startPage();
return getDataTable(this.appletRecipeH5Service.getWeekRecipeDetailList(content)); return getDataTable(this.appletRecipeH5Service.getWeekRecipeDetailList(content));
} catch (Exception e) { } catch (Exception e) {
return getDataTable(null); throw new RuntimeException(e.toString());
} }
} }

View File

@ -91,7 +91,7 @@ public class MenuDishesController extends BaseController {
try { try {
return toAjax(menuDishesService.insertMenuDishes(menuDishes)); return toAjax(menuDishesService.insertMenuDishes(menuDishes));
} catch (Exception e) { } catch (Exception e) {
return error("系统错误, " + e.getMessage()); return error(e.getMessage());
} }
} }
//MenuDishesDTO //MenuDishesDTO
@ -105,7 +105,7 @@ public class MenuDishesController extends BaseController {
try { try {
return toAjax(menuDishesService.addMenuDishes(menuDishesDTO)); return toAjax(menuDishesService.addMenuDishes(menuDishesDTO));
} catch (Exception e) { } catch (Exception e) {
return error("系统错误, " + e.getMessage()); return error(e.getMessage());
} }
} }

View File

@ -83,7 +83,7 @@ public class MenuMaterialController extends BaseController {
try { try {
return toAjax(menuMaterialService.insertMenuMaterial(menuMaterial)); return toAjax(menuMaterialService.insertMenuMaterial(menuMaterial));
} catch (Exception e) { } catch (Exception e) {
return error("系统错误, " + e.getMessage()); return error(e.getMessage());
} }
} }
@ -101,7 +101,7 @@ public class MenuMaterialController extends BaseController {
try { try {
return toAjax(menuMaterialService.updateMenuMaterial(menuMaterial)); return toAjax(menuMaterialService.updateMenuMaterial(menuMaterial));
} catch (Exception e) { } catch (Exception e) {
return error("系统错误, " + e.getMessage()); return error( e.getMessage());
} }
} }

View File

@ -84,7 +84,7 @@ public class MenuNutritionTypeController extends BaseController {
try { try {
return toAjax(menuNutritionTypeService.insertMenuNutritionType(menuNutritionType)); return toAjax(menuNutritionTypeService.insertMenuNutritionType(menuNutritionType));
} catch (Exception e) { } catch (Exception e) {
return error("系统错误, " + e.getMessage()); return error(e.getMessage());
} }
} }
@ -100,7 +100,7 @@ public class MenuNutritionTypeController extends BaseController {
try { try {
return toAjax(menuNutritionTypeService.updateMenuNutritionType(menuNutritionType)); return toAjax(menuNutritionTypeService.updateMenuNutritionType(menuNutritionType));
} catch (Exception e) { } catch (Exception e) {
return error("系统错误, " + e.getMessage()); return error(e.getMessage());
} }
} }

View File

@ -26,6 +26,7 @@ import com.bonus.common.security.annotation.Logical;
import com.bonus.common.security.annotation.RequiresPermissions; import com.bonus.common.security.annotation.RequiresPermissions;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import net.bytebuddy.implementation.bytecode.Throw;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -188,8 +189,12 @@ public class MenuRecipeController extends BaseController {
@ApiOperation("批量导入菜谱中的菜品信息") @ApiOperation("批量导入菜谱中的菜品信息")
@Transactional @Transactional
public AjaxResult recipeImportDishes(@RequestParam("file") MultipartFile excel, @RequestParam("recipeId") Long recipeId) { public AjaxResult recipeImportDishes(@RequestParam("file") MultipartFile excel, @RequestParam("recipeId") Long recipeId) {
return ObjectUtil.isNull(excel) ? AjaxResult.error("请选择导入文件 ^_^") : try{
AjaxResult.success(this.menuRecipeService.recipeImportDishes(excel, recipeId)); return ObjectUtil.isNull(excel) ? AjaxResult.error("请选择导入文件 ^_^") :
AjaxResult.success(this.menuRecipeService.recipeImportDishes(excel, recipeId));
}catch (Exception e){
throw new ServiceException(e.toString());
}
} }
@PostMapping({"/generateRecipe"}) @PostMapping({"/generateRecipe"})

View File

@ -96,4 +96,5 @@ public interface MenuDishesMapper extends BaseMapper<MenuDishes> {
MenuDishes getDishMessageByDishesId(String dishesId); MenuDishes getDishMessageByDishesId(String dishesId);
List<MapBean> getDishesType(MapBean mapBean); List<MapBean> getDishesType(MapBean mapBean);
List<MapBean> getDishesTypeByList(@Param("key")String key,@Param("keyList")List<String> keyList);
} }

View File

@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bonus.canteen.core.android.vo.UserInfoVo; import com.bonus.canteen.core.android.vo.UserInfoVo;
import com.bonus.canteen.core.menu.domain.MapBean;
import com.bonus.canteen.core.menu.domain.MenuRecipe; import com.bonus.canteen.core.menu.domain.MenuRecipe;
import com.bonus.canteen.core.menu.domain.MenuRecipeDetail; import com.bonus.canteen.core.menu.domain.MenuRecipeDetail;
import com.bonus.canteen.core.menu.domain.MenuRecipeDishes; import com.bonus.canteen.core.menu.domain.MenuRecipeDishes;
@ -31,6 +32,7 @@ import com.bonus.common.houqin.utils.id.Id;
import com.bonus.common.security.utils.SecurityUtils; import com.bonus.common.security.utils.SecurityUtils;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import org.hibernate.validator.internal.util.StringHelper;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@ -60,6 +62,9 @@ public class AppletRecipeH5ServiceImpl extends ServiceImpl<MenuRecipeMapper, Men
@Resource @Resource
private MenuRecipeMapper menuRecipeMapper; private MenuRecipeMapper menuRecipeMapper;
@Resource
private MenuDishesMapper menuDishesMapper;
@Override @Override
public List<AppletWeekCanteenVO> getWeekMealList(AppletWeekCanteenDTO content) { public List<AppletWeekCanteenVO> getWeekMealList(AppletWeekCanteenDTO content) {
//人员范围 暂时不用 //人员范围 暂时不用
@ -123,7 +128,19 @@ public class AppletRecipeH5ServiceImpl extends ServiceImpl<MenuRecipeMapper, Men
// } else { // } else {
// appletDishesDetailVO.setIsFavorites(2); // appletDishesDetailVO.setIsFavorites(2);
// } // }
if(appletDishesDetailVO != null && appletDishesDetailVO.getDishesDetailList() !=null && appletDishesDetailVO.getDishesDetailList().size()>0){
String tasteIds = appletDishesDetailVO.getDishesDetailList().get(0).getTasteIds();
if(!StringHelper.isNullOrEmptyString(tasteIds)){
List<String> list = Arrays.asList(tasteIds.split(","));
List<MapBean> mapBean = menuDishesMapper.getDishesTypeByList("dishes_taste",list);
System.err.println("mapBean="+mapBean);
String result = mapBean.stream()
.map(MapBean::getKey) // 提取每个 MapBean key
.collect(Collectors.joining(",")); // 用逗号连
appletDishesDetailVO.getDishesDetailList().get(0).setTasteIds(result);
}
// return menuDishesMapper.getDishesType(mapBean);
}
Long dishesId = ((AppletDishesSizeV2VO) appletDishesDetailVO.getDishesDetailList().get(0)).getDishesId(); Long dishesId = ((AppletDishesSizeV2VO) appletDishesDetailVO.getDishesDetailList().get(0)).getDishesId();
List materialList; List materialList;
if (appletDishesDetailVO.getMealType() == 1) { if (appletDishesDetailVO.getMealType() == 1) {
@ -150,6 +167,7 @@ public class AppletRecipeH5ServiceImpl extends ServiceImpl<MenuRecipeMapper, Men
@Override @Override
public List<AppletWeekRecipeVO> getWeekRecipeDetailList(AppletWeekRecipeDTO content) { public List<AppletWeekRecipeVO> getWeekRecipeDetailList(AppletWeekRecipeDTO content) {
try{
List<Long> recipeIdList = Lists.newArrayList(); List<Long> recipeIdList = Lists.newArrayList();
Set<Long> effIdSet = this.getShopstallIdListByCustId(content.getCustId(), false); Set<Long> effIdSet = this.getShopstallIdListByCustId(content.getCustId(), false);
if (ObjectUtil.isNull(content.getRecipeId())) { if (ObjectUtil.isNull(content.getRecipeId())) {
@ -208,6 +226,10 @@ public class AppletRecipeH5ServiceImpl extends ServiceImpl<MenuRecipeMapper, Men
return s2.getMealtimeType() - s1.getMealtimeType(); return s2.getMealtimeType() - s1.getMealtimeType();
})); }));
return resultList; return resultList;
}catch (Exception e){
throw new ServiceException(e.toString());
}
} }
@Transactional(rollbackFor = {Exception.class}) @Transactional(rollbackFor = {Exception.class})

View File

@ -48,6 +48,7 @@ import com.google.common.collect.Lists;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.ObjectUtils;
import org.hibernate.validator.internal.util.StringHelper;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
@ -268,7 +269,7 @@ public class MenuDishesServiceImpl extends ServiceImpl<MenuDishesMapper, MenuDis
throw new ServiceException("菜品已存在"); throw new ServiceException("菜品已存在");
} }
menuDishesOne = menuDishesMapper.getOneByNum(menuDishesDTO); menuDishesOne = menuDishesMapper.getOneByNum(menuDishesDTO);
if(menuDishesOne !=null && menuDishesOne.getDishesId() != Long.parseLong(menuDishesDTO.getDishesId())){ if(menuDishesOne !=null && !StringHelper.isNullOrEmptyString(menuDishesDTO.getDishesNum())){
throw new ServiceException("编号已存在"); throw new ServiceException("编号已存在");
} }
Long dishesId = Id.next(); Long dishesId = Id.next();

View File

@ -70,9 +70,17 @@ public class MenuNutritionServiceImpl implements IMenuNutritionService {
*/ */
@Override @Override
public int insertMenuNutrition(MenuNutrition menuNutrition) { public int insertMenuNutrition(MenuNutrition menuNutrition) {
MenuNutrition existMenuNutrition = menuNutritionMapper.queryIfExistMenuNutrition(menuNutrition); // MenuNutrition existMenuNutrition = menuNutritionMapper.queryIfExistMenuNutrition(menuNutrition);
if (Objects.nonNull(existMenuNutrition)) { // if (Objects.nonNull(existMenuNutrition)) {
throw new ServiceException("应用编码或名称重复"); // throw new ServiceException("应用编码或名称重复");
// }
MenuNutrition getOneByCode =menuNutritionMapper.getOneByCode(menuNutrition);
if(getOneByCode != null){
throw new ServiceException("营养编码重复");
}
MenuNutrition getOneByName =menuNutritionMapper.getOneByName(menuNutrition);
if(getOneByName != null){
throw new ServiceException("营养名称重复");
} }
menuNutrition.setNutritionId(Id.next()); menuNutrition.setNutritionId(Id.next());
menuNutrition.setCreateBy(SecurityUtils.getUsername()); menuNutrition.setCreateBy(SecurityUtils.getUsername());

View File

@ -1417,9 +1417,10 @@ private IMenuRecipeDetailService menuRecipeDetailService;
@Override @Override
public Set<String> recipeImportDishes(MultipartFile excel, Long recipeId) { public Set<String> recipeImportDishes(MultipartFile excel, Long recipeId) {
ExcelReader excelReader = null; ExcelReader excelReader = null;
try {
Set<String> notImportDishesNames = new HashSet(); Set<String> notImportDishesNames = new HashSet();
List<MenuRecipeImportListener> listeners = new ArrayList(); List<MenuRecipeImportListener> listeners = new ArrayList();
try {
excelReader = EasyExcel.read(excel.getInputStream()).build(); excelReader = EasyExcel.read(excel.getInputStream()).build();
List<ReadSheet> readSheets = excelReader.excelExecutor().sheetList(); List<ReadSheet> readSheets = excelReader.excelExecutor().sheetList();
for (ReadSheet readSheet : readSheets) { for (ReadSheet readSheet : readSheets) {
@ -1437,14 +1438,16 @@ private IMenuRecipeDetailService menuRecipeDetailService;
.flatMap(listener -> listener.getNotImportDishesNames().stream()) .flatMap(listener -> listener.getNotImportDishesNames().stream())
.collect(Collectors.toList()) .collect(Collectors.toList())
); );
}catch (Exception var16) {
log.error("导入菜品失败", var16); return notImportDishesNames;
}catch (Exception e) {
// log.error("导入菜品失败", e);
throw new ServiceException(e.toString());
} finally { } finally {
if (excelReader != null) { if (excelReader != null) {
excelReader.finish(); excelReader.finish();
} }
} }
return notImportDishesNames;
} }
} }

View File

@ -4,6 +4,7 @@ import com.bonus.canteen.core.utils.BigDecimalSerializer;
import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode; import java.math.RoundingMode;
@ -88,6 +89,14 @@ public class AppletDishesSizeV2VO {
@ApiModelProperty("钠NRV(mg/100g)") @ApiModelProperty("钠NRV(mg/100g)")
private BigDecimal sodiumNrv; private BigDecimal sodiumNrv;
@Getter
@ApiModelProperty("餐品口味")
private String tasteIds;
public void setTasteIds(String tasteIds) {
this.tasteIds = tasteIds;
}
public Integer getMonthlySales() { public Integer getMonthlySales() {
return (Integer)Optional.ofNullable(this.monthlySales).orElse(0); return (Integer)Optional.ofNullable(this.monthlySales).orElse(0);
} }

View File

@ -52,9 +52,10 @@ public class SupermarketDeviceController extends BaseController {
@ApiOperation(value = "查询 - 双屏超市收银机") @ApiOperation(value = "查询 - 双屏超市收银机")
@SysLog(title = "超市", businessType = OperaType.INSERT, logType = 1,module = "商超管理->查询 -双屏超市收银机") @SysLog(title = "超市", businessType = OperaType.INSERT, logType = 1,module = "商超管理->查询 -双屏超市收银机")
@PostMapping("/list") @GetMapping("/list")
public TableDataInfo list(@RequestBody DeviceDTO dto) { public TableDataInfo list(DeviceDTO dto) {
try { try {
startPage();
return getDataTable(supermarketDeviceService.selectSupermarketDevice(dto)); return getDataTable(supermarketDeviceService.selectSupermarketDevice(dto));
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException("系统错误, " + e.getMessage()); throw new RuntimeException("系统错误, " + e.getMessage());

View File

@ -0,0 +1,27 @@
package com.bonus.canteen.core.utils.excel;
import com.bonus.canteen.core.menu.domain.MenuDishes;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
/**
* @author xliu
* @date 2025/5/9 11:20
*/
public class DifferenceCalculator {
public static Set<String> calculateDifference(Set<String> stringSet, List<MenuDishes> menuDishesList) {
// 从menuDishesList中提取所有dishesName的集合
Set<String> menuDishesNames = menuDishesList.stream()
.map(MenuDishes::getDishesName)
.collect(Collectors.toSet());
// 计算差集stringSet中有而menuDishesNames中没有的元素
Set<String> difference = new HashSet<>(stringSet);
difference.removeAll(menuDishesNames);
return difference;
}
}

View File

@ -13,6 +13,7 @@ import com.bonus.canteen.core.menu.dto.ImportRecipeDishesDto;
import com.bonus.canteen.core.menu.service.IMenuDishesService; import com.bonus.canteen.core.menu.service.IMenuDishesService;
import com.bonus.canteen.core.menu.service.IMenuRecipeDetailService; import com.bonus.canteen.core.menu.service.IMenuRecipeDetailService;
import com.bonus.canteen.core.menu.service.IMenuRecipeDishesService; import com.bonus.canteen.core.menu.service.IMenuRecipeDishesService;
import com.bonus.common.core.exception.ServiceException;
import com.bonus.common.houqin.utils.id.Id; import com.bonus.common.houqin.utils.id.Id;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -102,58 +103,68 @@ public class MenuRecipeImportListener extends AnalysisEventListener<Map<Integer,
@Override @Override
public void doAfterAllAnalysed(AnalysisContext analysisContext) { public void doAfterAllAnalysed(AnalysisContext analysisContext) {
HashSet<LocalDate> dates = new HashSet(this.dateMap.values()); try {
if (!dates.isEmpty()) { HashSet<LocalDate> dates = new HashSet(this.dateMap.values());
IMenuRecipeDetailService menuRecipeDetailService = SpringContextHolder.getBean(IMenuRecipeDetailService.class); if (!dates.isEmpty()) {
List<MenuRecipeDetail> byRecipeIdAndDates = menuRecipeDetailService.getByRecipeIdAndDatesAndIntervalId(this.recipeId, dates, this.mealtimeType); IMenuRecipeDetailService menuRecipeDetailService = SpringContextHolder.getBean(IMenuRecipeDetailService.class);
Map<LocalDate, MenuRecipeDetail> dateDetailMap = byRecipeIdAndDates.stream().collect(Collectors.groupingBy(MenuRecipeDetail::getApplyDate, Collectors.collectingAndThen(Collectors.toList(), (list) -> { List<MenuRecipeDetail> byRecipeIdAndDates = menuRecipeDetailService.getByRecipeIdAndDatesAndIntervalId(this.recipeId, dates, this.mealtimeType);
return list.get(0); Map<LocalDate, MenuRecipeDetail> dateDetailMap = byRecipeIdAndDates.stream().collect(Collectors.groupingBy(MenuRecipeDetail::getApplyDate, Collectors.collectingAndThen(Collectors.toList(), (list) -> {
}))); return list.get(0);
if (!this.dishesNames.isEmpty()) { })));
IMenuDishesService menuDishesService = SpringContextHolder.getBean(IMenuDishesService.class); if (!this.dishesNames.isEmpty()) {
List<MenuDishes> menuDishesList = menuDishesService.getByNames(this.dishesNames); IMenuDishesService menuDishesService = SpringContextHolder.getBean(IMenuDishesService.class);
Map<String, MenuDishes> nameMap = menuDishesList.stream().collect(Collectors.groupingBy(MenuDishes::getDishesName, Collectors.collectingAndThen(Collectors.toList(), (list) -> { List<MenuDishes> menuDishesList = menuDishesService.getByNames(this.dishesNames);
return list.get(0);
})));
IMenuRecipeDishesService menuRecipeDishesService = SpringContextHolder.getBean(IMenuRecipeDishesService.class);
List<MenuRecipeDishes> inserData = new ArrayList<>();
for (LocalDate date : dates) { Set<String> difference = DifferenceCalculator.calculateDifference(this.dishesNames, menuDishesList);
MenuRecipeDetail menuRecipeDetail = dateDetailMap.get(date); System.out.println("差集结果: " + difference);
if (menuRecipeDetail == null) { if (difference != null && difference.size() > 0) {
menuRecipeDetail = new MenuRecipeDetail(); throw new ServiceException("以下菜品不存在:" + difference);
menuRecipeDetail.setRecipeId(this.recipeId); }
menuRecipeDetail.setApplyDate(date); Map<String, MenuDishes> nameMap = menuDishesList.stream().collect(Collectors.groupingBy(MenuDishes::getDishesName, Collectors.collectingAndThen(Collectors.toList(), (list) -> {
menuRecipeDetail.setMealtimeType(this.mealtimeType); return list.get(0);
menuRecipeDetail.setDetailId(Id.next()); })));
menuRecipeDetailService.save(menuRecipeDetail); IMenuRecipeDishesService menuRecipeDishesService = SpringContextHolder.getBean(IMenuRecipeDishesService.class);
} else { List<MenuRecipeDishes> inserData = new ArrayList<>();
menuRecipeDishesService.deleteByDetailId(menuRecipeDetail.getDetailId());
}
List<ImportRecipeDishesDto> importRecipeDishesDtos = this.datas.get(date); for (LocalDate date : dates) {
MenuRecipeDetail finalMenuRecipeDetail = menuRecipeDetail; MenuRecipeDetail menuRecipeDetail = dateDetailMap.get(date);
List<MenuRecipeDishes> saveDatas = importRecipeDishesDtos.stream().filter(distinctByKey(ImportRecipeDishesDto::getDishesName)).map((importRecipeDishesDto) -> { if (menuRecipeDetail == null) {
MenuRecipeDishes menuRecipeDishes = null; menuRecipeDetail = new MenuRecipeDetail();
MenuDishes menuDishes = nameMap.get(importRecipeDishesDto.getDishesName()); menuRecipeDetail.setRecipeId(this.recipeId);
if (menuDishes != null) { menuRecipeDetail.setApplyDate(date);
menuRecipeDishes = BeanUtil.copyProperties(importRecipeDishesDto, MenuRecipeDishes.class, new String[0]); menuRecipeDetail.setMealtimeType(this.mealtimeType);
menuRecipeDishes.setDetailId(finalMenuRecipeDetail.getDetailId()); menuRecipeDetail.setDetailId(Id.next());
menuRecipeDishes.setSizeType(menuDishes.getSizeType()); menuRecipeDetailService.save(menuRecipeDetail);
menuRecipeDishes.setDishesId(menuDishes.getDishesId()); } else {
} else { menuRecipeDishesService.deleteByDetailId(menuRecipeDetail.getDetailId());
this.notImportDishesNames.add(importRecipeDishesDto.getDishesName()); }
}
return menuRecipeDishes; List<ImportRecipeDishesDto> importRecipeDishesDtos = this.datas.get(date);
}).filter(Objects::nonNull).collect(Collectors.toList()); MenuRecipeDetail finalMenuRecipeDetail = menuRecipeDetail;
inserData.addAll(saveDatas); List<MenuRecipeDishes> saveDatas = importRecipeDishesDtos.stream().filter(distinctByKey(ImportRecipeDishesDto::getDishesName)).map((importRecipeDishesDto) -> {
} MenuRecipeDishes menuRecipeDishes = null;
MenuDishes menuDishes = nameMap.get(importRecipeDishesDto.getDishesName());
if (menuDishes != null) {
menuRecipeDishes = BeanUtil.copyProperties(importRecipeDishesDto, MenuRecipeDishes.class, new String[0]);
menuRecipeDishes.setDetailId(finalMenuRecipeDetail.getDetailId());
menuRecipeDishes.setSizeType(menuDishes.getSizeType());
menuRecipeDishes.setDishesId(menuDishes.getDishesId());
} else {
this.notImportDishesNames.add(importRecipeDishesDto.getDishesName());
}
menuRecipeDishesService.saveBatch(inserData); return menuRecipeDishes;
} }).filter(Objects::nonNull).collect(Collectors.toList());
} inserData.addAll(saveDatas);
}
menuRecipeDishesService.saveBatch(inserData);
}
}
}catch (Exception e){
throw new RuntimeException(e);
}
} }
static <T> Predicate<T> distinctByKey(Function<? super T, ?> keyExtractor) { static <T> Predicate<T> distinctByKey(Function<? super T, ?> keyExtractor) {
@ -162,4 +173,5 @@ public class MenuRecipeImportListener extends AnalysisEventListener<Map<Integer,
return seen.putIfAbsent(keyExtractor.apply(t), Boolean.TRUE) == null; return seen.putIfAbsent(keyExtractor.apply(t), Boolean.TRUE) == null;
}; };
} }
} }

View File

@ -68,6 +68,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="cholesterol" column="cholesterol"/> <result property="cholesterol" column="cholesterol"/>
<result property="calcium" column="calcium"/> <result property="calcium" column="calcium"/>
<result property="sodium" column="sodium"/> <result property="sodium" column="sodium"/>
<result property="tasteIds" column="taste_id"/>
</collection> </collection>
</resultMap> </resultMap>
@ -97,7 +98,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
md.dietary_fiber, md.dietary_fiber,
md.cholesterol, md.cholesterol,
md.calcium, md.calcium,
md.sodium md.sodium,
md.taste_id
from from
menu_dishes_base mdb menu_dishes_base mdb
left join menu_dishes md on mdb.base_dishes_id = md.base_dishes_id left join menu_dishes md on mdb.base_dishes_id = md.base_dishes_id

View File

@ -387,6 +387,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
select dict_label as `key`,dict_value as `value` from sys_dict_data where is_default ='Y' and dict_type = #{key} order by dict_sort select dict_label as `key`,dict_value as `value` from sys_dict_data where is_default ='Y' and dict_type = #{key} order by dict_sort
</select> </select>
<select id="getDishesTypeByList" resultType="com.bonus.canteen.core.menu.domain.MapBean" >
select dict_label as `key`,dict_value as `value` from sys_dict_data where is_default ='Y'
and dict_type = #{key}
and dict_value in
<foreach collection="keyList" separator="," open="(" close=")" item="item">
#{item}
</foreach>
order by dict_sort
</select>
<select id="getOneByName" parameterType="com.bonus.canteen.core.menu.dto.MenuDishesDTO" resultMap="MenuDishesResult"> <select id="getOneByName" parameterType="com.bonus.canteen.core.menu.dto.MenuDishesDTO" resultMap="MenuDishesResult">
select * from menu_dishes where area_id = #{areaId} and ( select * from menu_dishes where area_id = #{areaId} and (
@ -395,9 +406,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select> </select>
<select id="getOneByNum" parameterType="com.bonus.canteen.core.menu.dto.MenuDishesDTO" resultMap="MenuDishesResult"> <select id="getOneByNum" parameterType="com.bonus.canteen.core.menu.dto.MenuDishesDTO" resultMap="MenuDishesResult">
select * from menu_dishes where area_id = #{areaId} and ( select * from menu_dishes where area_id = #{areaId}
dishes_num =#{dishesNum} <if test="dishesNum !=null and dishesNum !=''">
) limit 1 and dishes_num =#{dishesNum}
</if>
limit 1
</select> </select>
<insert id="addMenuDishesBase" parameterType="com.bonus.canteen.core.menu.dto.MenuDishesDTO"> <insert id="addMenuDishesBase" parameterType="com.bonus.canteen.core.menu.dto.MenuDishesDTO">

View File

@ -33,7 +33,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
LEFT JOIN alloc_area aaa ON aaa.area_id = aa.parent_id LEFT JOIN alloc_area aaa ON aaa.area_id = aa.parent_id
LEFT JOIN supermarket_info ac ON db.canteen_id = ac.supermarket_id LEFT JOIN supermarket_info ac ON db.canteen_id = ac.supermarket_id
where di.device_type = 53 where di.device_type = 53
<if test=""></if> <if test="keyWord !=null and keyWord !='' ">
and ( di.device_name LIKE CONCAT( '%', #{keyWord}, '%' )
OR di.device_num LIKE CONCAT( '%', #{keyWord}, '%' )
OR di.device_sn LIKE CONCAT( '%', #{keyWord}, '%' )
OR di.device_ip LIKE CONCAT( '%', #{keyWord}, '%' )
OR di.device_mac LIKE CONCAT( '%', #{keyWord}, '%' )
OR di.device_gateway LIKECONCAT( '%', #{keyWord}, '%' )
)
</if>
<if test="areaId !=null and areaId !=''">
and aa.area_id = #{areaId}
</if>
<if test="canteenId !=null and canteenId !=''">
and ac.supermarket_id = #{canteenId}
</if>
GROUP BY GROUP BY
di.device_id di.device_id
</select> </select>