Merge branch 'master' into rs0527

This commit is contained in:
sxu 2025-05-28 13:07:48 +08:00
commit b3e5e86c69
14 changed files with 491 additions and 121 deletions

View File

@ -41,7 +41,6 @@ public class CookDishesController extends BaseController {
* 查询菜品信息列表
*/
@ApiOperation(value = "查询菜品信息列表")
//@RequiresPermissions("cook:dishes:list")
@GetMapping("/list")
public TableDataInfo list(CookDishes cookDishes) {
startPage();
@ -53,8 +52,6 @@ public class CookDishesController extends BaseController {
* 导出菜品信息列表
*/
@ApiOperation(value = "导出菜品信息列表")
//@PreventRepeatSubmit
//@RequiresPermissions("cook:dishes:export")
@SysLog(title = "菜品信息", businessType = OperaType.EXPORT, logType = 1,module = "仓储管理->导出菜品信息")
@PostMapping("/export")
public void export(HttpServletResponse response, CookDishes cookDishes) {
@ -67,7 +64,6 @@ public class CookDishesController extends BaseController {
* 获取菜品信息详细信息
*/
@ApiOperation(value = "获取菜品信息详细信息")
//@RequiresPermissions("cook:dishes:query")
@GetMapping(value = "/{dishesId}")
public AjaxResult getInfo(@PathVariable("dishesId") Long dishesId) {
return success(cookDishesService.selectCookDishesByDishesId(dishesId));
@ -77,10 +73,8 @@ public class CookDishesController extends BaseController {
* 新增菜品信息
*/
@ApiOperation(value = "新增菜品信息")
//@PreventRepeatSubmit
//@RequiresPermissions("cook:dishes:add")
@SysLog(title = "菜品信息", businessType = OperaType.INSERT, logType = 1,module = "仓储管理->新增菜品信息")
@PostMapping
@PostMapping("/add")
public AjaxResult add(@RequestBody CookDishes cookDishes) {
try {
return toAjax(cookDishesService.insertCookDishes(cookDishes));
@ -93,8 +87,6 @@ public class CookDishesController extends BaseController {
* 修改菜品信息
*/
@ApiOperation(value = "修改菜品信息")
//@PreventRepeatSubmit
//@RequiresPermissions("cook:dishes:edit")
@SysLog(title = "菜品信息", businessType = OperaType.UPDATE, logType = 1,module = "仓储管理->修改菜品信息")
@PostMapping("/edit")
public AjaxResult edit(@RequestBody CookDishes cookDishes) {
@ -109,8 +101,6 @@ public class CookDishesController extends BaseController {
* 删除菜品信息
*/
@ApiOperation(value = "删除菜品信息")
//@PreventRepeatSubmit
//@RequiresPermissions("cook:dishes:remove")
@SysLog(title = "菜品信息", businessType = OperaType.DELETE, logType = 1,module = "仓储管理->删除菜品信息")
@PostMapping("/del/{dishesIds}")
public AjaxResult remove(@PathVariable Long[] dishesIds) {

View File

@ -2,6 +2,9 @@ package com.bonus.canteen.core.cook.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.bonus.canteen.core.common.utils.TreeNodeUtil;
import com.bonus.canteen.core.cook.vo.CookDishesTypeVO;
import com.bonus.common.log.enums.OperaType;
//import com.bonus.canteen.core.cook.common.annotation.PreventRepeatSubmit;
import io.swagger.annotations.Api;
@ -40,34 +43,18 @@ public class CookDishesTypeController extends BaseController {
/**
* 查询菜品类型信息列表
*/
@ApiOperation(value = "查询菜品类型信息列表")
//@RequiresPermissions("cook:type:list")
@ApiOperation(value = "获取所有菜品类别")
@GetMapping("/list")
public TableDataInfo list(CookDishesType cookDishesType) {
startPage();
List<CookDishesType> list = cookDishesTypeService.selectCookDishesTypeList(cookDishesType);
return getDataTable(list);
public AjaxResult list(CookDishesType cookDishesType) {
List<CookDishesTypeVO> list = cookDishesTypeService.selectList(cookDishesType);
return AjaxResult.success(TreeNodeUtil.assembleTree(list));
}
/**
* 导出菜品类型信息列表
*/
@ApiOperation(value = "导出菜品类型信息列表")
//@PreventRepeatSubmit
//@RequiresPermissions("cook:type:export")
@SysLog(title = "菜品类型信息", businessType = OperaType.EXPORT, logType = 1,module = "仓储管理->导出菜品类型信息")
@PostMapping("/export")
public void export(HttpServletResponse response, CookDishesType cookDishesType) {
List<CookDishesType> list = cookDishesTypeService.selectCookDishesTypeList(cookDishesType);
ExcelUtil<CookDishesType> util = new ExcelUtil<CookDishesType>(CookDishesType.class);
util.exportExcel(response, list, "菜品类型信息数据");
}
/**
* 获取菜品类型信息详细信息
*/
@ApiOperation(value = "获取菜品类型信息详细信息")
//@RequiresPermissions("cook:type:query")
@GetMapping(value = "/{dishesTypeId}")
public AjaxResult getInfo(@PathVariable("dishesTypeId") Long dishesTypeId) {
return success(cookDishesTypeService.selectCookDishesTypeByDishesTypeId(dishesTypeId));
@ -77,10 +64,8 @@ public class CookDishesTypeController extends BaseController {
* 新增菜品类型信息
*/
@ApiOperation(value = "新增菜品类型信息")
//@PreventRepeatSubmit
//@RequiresPermissions("cook:type:add")
@SysLog(title = "菜品类型信息", businessType = OperaType.INSERT, logType = 1,module = "仓储管理->新增菜品类型信息")
@PostMapping
@PostMapping("/add")
public AjaxResult add(@RequestBody CookDishesType cookDishesType) {
try {
return toAjax(cookDishesTypeService.insertCookDishesType(cookDishesType));
@ -93,8 +78,6 @@ public class CookDishesTypeController extends BaseController {
* 修改菜品类型信息
*/
@ApiOperation(value = "修改菜品类型信息")
//@PreventRepeatSubmit
//@RequiresPermissions("cook:type:edit")
@SysLog(title = "菜品类型信息", businessType = OperaType.UPDATE, logType = 1,module = "仓储管理->修改菜品类型信息")
@PostMapping("/edit")
public AjaxResult edit(@RequestBody CookDishesType cookDishesType) {
@ -109,8 +92,6 @@ public class CookDishesTypeController extends BaseController {
* 删除菜品类型信息
*/
@ApiOperation(value = "删除菜品类型信息")
//@PreventRepeatSubmit
//@RequiresPermissions("cook:type:remove")
@SysLog(title = "菜品类型信息", businessType = OperaType.DELETE, logType = 1,module = "仓储管理->删除菜品类型信息")
@PostMapping("/del/{dishesTypeIds}")
public AjaxResult remove(@PathVariable Long[] dishesTypeIds) {

View File

@ -1,6 +1,8 @@
package com.bonus.canteen.core.cook.domain;
import java.math.BigDecimal;
import java.util.List;
import com.bonus.common.core.annotation.Excel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@ -23,6 +25,8 @@ public class CookDishes extends BaseEntity {
/** 菜品id */
private Long dishesId;
private Long baseDishesId;
/** 类型(1-菜品,2-套餐) */
@Excel(name = "类型(1-菜品,2-套餐)")
@ApiModelProperty(value = "类型(1-菜品,2-套餐)")
@ -300,7 +304,7 @@ public class CookDishes extends BaseEntity {
/** 档口或店铺id */
@Excel(name = "档口或店铺id")
@ApiModelProperty(value = "档口或店铺id")
private Long shopstallId;
private Long stallId;
/** 隐藏标识(1隐藏,2展示) */
@Excel(name = "隐藏标识(1隐藏,2展示)")
@ -342,5 +346,21 @@ public class CookDishes extends BaseEntity {
@ApiModelProperty(value = "餐次id")
private String mealId;
@ApiModelProperty(value = "菜品食材列表")
private List<CookDishesMaterial> dishesMaterialList;
@ApiModelProperty(value = "食堂名称")
private String canteenName;
@ApiModelProperty(value = "档口名称")
private String stallName;
@ApiModelProperty(value = "区域名称")
private String areaName;
@ApiModelProperty(value = "菜品类型名称")
private String dishesTypeName;
@ApiModelProperty(value = "菜品类型id集合")
private List<Long> typeIds;
}

View File

@ -3,9 +3,11 @@ package com.bonus.canteen.core.cook.domain;
import com.bonus.common.core.annotation.Excel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import com.bonus.common.core.web.domain.BaseEntity;
/**
* 菜品类型信息对象 cook_dishes_type
*
@ -14,6 +16,7 @@ import com.bonus.common.core.web.domain.BaseEntity;
*/
@EqualsAndHashCode(callSuper = true)
@Data
@ToString
public class CookDishesType extends BaseEntity {
@ -52,5 +55,4 @@ public class CookDishesType extends BaseEntity {
@ApiModelProperty(value = "类别别称")
private String dishesAliasName;
}

View File

@ -2,6 +2,9 @@ package com.bonus.canteen.core.cook.mapper;
import java.util.List;
import com.bonus.canteen.core.cook.domain.CookDishes;
import com.bonus.canteen.core.cook.domain.CookDishesMaterial;
import com.bonus.canteen.core.utils.NutritionEntity;
import org.apache.ibatis.annotations.Param;
/**
* 菜品信息Mapper接口
@ -57,4 +60,68 @@ public interface CookDishesMapper {
* @return 结果
*/
public int deleteCookDishesByDishesIds(Long[] dishesIds);
/**
* 校验菜品名称是否唯一
*
* @param cookDishes 菜品名称
* @return 结果
*/
public int checkDishIsExist(CookDishes cookDishes);
/**
* 新增菜品信息
*
* @param cookDishes 菜品信息
* @return 结果
*/
int insertDishesName(CookDishes cookDishes);
/**
* 新增菜品信息
*
* @param dishesMaterialList 菜品信息
* @param dishesId 菜品id
*/
void insertDishesMaterial(@Param("list") List<CookDishesMaterial> dishesMaterialList,@Param("dishesId") Long dishesId);
/**
* 修改菜品信息
*
* @param cookDishes 菜品信息
*/
void updateDishesName(CookDishes cookDishes);
/**
* 删除菜品信息
*
* @param dishesId 菜品id
*/
void deleteDishesMaterialByDishesId(Long dishesId);
/**
* 根据菜品id查询菜品营养信息
*
* @param nutritionEntity 菜品营养信息
* @param dishesId 菜品id
* @return 菜品营养信息
*/
int updateFinalNutrition(@Param("bean") NutritionEntity nutritionEntity,@Param("dishesId") Long dishesId);
/**
* 根据菜品id查询菜品计划详情id
*
* @param dishesIds 菜品id
* @param applyDate 应用日期
* @return 菜品计划详情id列表
*/
List<Long> selectDishPlanDetailIdByDishId(@Param("dishesIds") Long[] dishesIds,@Param("applyDate") String applyDate);
/**
* 批量删除菜品信息
*
* @param detailIdList 菜品计划详情id列表
* @param dishesIds 菜品id
*/
void deleteCookDishesByDishPlanDetailIds(@Param("detailIdList") List<Long> detailIdList,@Param("dishesIds") Long[] dishesIds);
}

View File

@ -2,6 +2,8 @@ package com.bonus.canteen.core.cook.mapper;
import java.util.List;
import com.bonus.canteen.core.cook.domain.CookDishesType;
import com.bonus.canteen.core.cook.vo.CookDishesTypeVO;
import org.apache.ibatis.annotations.Param;
/**
* 菜品类型信息Mapper接口
@ -24,7 +26,7 @@ public interface CookDishesTypeMapper {
* @param cookDishesType 菜品类型信息
* @return 菜品类型信息集合
*/
public List<CookDishesType> selectCookDishesTypeList(CookDishesType cookDishesType);
public List<CookDishesTypeVO> selectCookDishesTypeList(CookDishesType cookDishesType);
/**
* 新增菜品类型信息
@ -57,4 +59,21 @@ public interface CookDishesTypeMapper {
* @return 结果
*/
public int deleteCookDishesTypeByDishesTypeIds(Long[] dishesTypeIds);
/**
* 检查菜品类型名称是否存在
*
* @param cookDishesType 菜品类型信息
* @return 结果
*/
public int checkIsExistByName(CookDishesType cookDishesType);
/**
* 检查菜品类型是否被使用
*
* @param dishesTypeIds 菜品类型信息
* @return 结果
*/
public int checkIsUse(@Param("dishesTypeIds") Long[] dishesTypeIds);
List<CookDishesTypeVO> selectList(CookDishesType cookDishesType);
}

View File

@ -1,8 +1,11 @@
package com.bonus.canteen.core.cook.mapper;
import java.util.List;
import com.bonus.canteen.core.cook.domain.CookDishesMaterial;
import com.bonus.canteen.core.cook.domain.CookNutrition;
import com.bonus.canteen.core.cook.vo.NutritionTypeVO;
import com.bonus.canteen.core.utils.NutritionEntity;
import org.apache.ibatis.annotations.Param;
/**
@ -81,4 +84,11 @@ public interface CookNutritionMapper {
* @return 结果
*/
public int checkIsExistByName(@Param("nutritionName") String nutritionName,@Param("nutritionId") Long nutritionId);
/**
* 获取食材营养信息
* @param i 食材信息
* @return 食材营养信息
*/
NutritionEntity getNutritionEntity(CookDishesMaterial i);
}

View File

@ -2,6 +2,7 @@ package com.bonus.canteen.core.cook.service;
import java.util.List;
import com.bonus.canteen.core.cook.domain.CookDishesType;
import com.bonus.canteen.core.cook.vo.CookDishesTypeVO;
/**
* 菜品类型信息Service接口
@ -24,7 +25,7 @@ public interface ICookDishesTypeService {
* @param cookDishesType 菜品类型信息
* @return 菜品类型信息集合
*/
public List<CookDishesType> selectCookDishesTypeList(CookDishesType cookDishesType);
public List<CookDishesTypeVO> selectCookDishesTypeList(CookDishesType cookDishesType);
/**
* 新增菜品类型信息
@ -57,4 +58,6 @@ public interface ICookDishesTypeService {
* @return 结果
*/
public int deleteCookDishesTypeByDishesTypeId(Long dishesTypeId);
List<CookDishesTypeVO> selectList(CookDishesType cookDishesType);
}

View File

@ -1,13 +1,23 @@
package com.bonus.canteen.core.cook.service.impl;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;
import com.bonus.canteen.core.cook.domain.CookDishesMaterial;
import com.bonus.canteen.core.cook.mapper.CookNutritionMapper;
import com.bonus.canteen.core.utils.Arith;
import com.bonus.canteen.core.utils.NutritionEntity;
import com.bonus.canteen.core.utils.NutritionEntityUtil;
import com.bonus.common.core.exception.ServiceException;
import com.bonus.common.core.utils.DateUtils;
import com.bonus.common.core.utils.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.bonus.canteen.core.cook.mapper.CookDishesMapper;
import com.bonus.canteen.core.cook.domain.CookDishes;
import com.bonus.canteen.core.cook.service.ICookDishesService;
import org.springframework.transaction.annotation.Transactional;
/**
* 菜品信息Service业务层处理
@ -19,7 +29,8 @@ import com.bonus.canteen.core.cook.service.ICookDishesService;
public class CookDishesServiceImpl implements ICookDishesService {
@Autowired
private CookDishesMapper cookDishesMapper;
@Autowired
private CookNutritionMapper cookNutritionMapper;
/**
* 查询菜品信息
*
@ -49,15 +60,28 @@ public class CookDishesServiceImpl implements ICookDishesService {
* @return 结果
*/
@Override
@Transactional(rollbackFor = Exception.class)
public int insertCookDishes(CookDishes cookDishes) {
cookDishes.setCreateTime(DateUtils.getNowDate());
try {
return cookDishesMapper.insertCookDishes(cookDishes);
checkParam(cookDishes,false);
//计算营养信息含量
//新增菜品名称
cookDishesMapper.insertDishesName(cookDishes);
//添加菜品
cookDishesMapper.insertCookDishes(cookDishes);
//添加菜品-原料关联关系
if (cookDishes.getDishesMaterialList() != null && !cookDishes.getDishesMaterialList().isEmpty()){
cookDishesMapper.insertDishesMaterial(cookDishes.getDishesMaterialList(), cookDishes.getDishesId());
calculateNutritionalInfo(cookDishes);
}
return 1;
} catch (Exception e) {
throw new ServiceException(e.getMessage());
}
}
/**
* 修改菜品信息
*
@ -65,15 +89,52 @@ public class CookDishesServiceImpl implements ICookDishesService {
* @return 结果
*/
@Override
@Transactional(rollbackFor = Exception.class)
public int updateCookDishes(CookDishes cookDishes) {
cookDishes.setUpdateTime(DateUtils.getNowDate());
try {
return cookDishesMapper.updateCookDishes(cookDishes);
checkParam(cookDishes,true);
//修改菜品名称
cookDishesMapper.updateDishesName(cookDishes);
//修改菜品
cookDishesMapper.updateCookDishes(cookDishes);
//删除菜品-原料关联关系
cookDishesMapper.deleteDishesMaterialByDishesId(cookDishes.getDishesId());
//添加菜品-原料关联关系
if (cookDishes.getDishesMaterialList() != null && !cookDishes.getDishesMaterialList().isEmpty()){
cookDishesMapper.insertDishesMaterial(cookDishes.getDishesMaterialList(), cookDishes.getDishesId());
calculateNutritionalInfo(cookDishes);
}
return 1;
} catch (Exception e) {
throw new ServiceException(e.getMessage());
}
}
public void checkParam(CookDishes cookDishes, boolean isUpdate) {
if (cookDishes.getDishesId() == null && isUpdate) {
throw new ServiceException("菜品ID不能为空");
}
if (StringUtils.isNull(cookDishes.getAreaId()) || cookDishes.getAreaId() == 0){
throw new ServiceException("区域不能为空");
}
if (StringUtils.isNull(cookDishes.getCanteenId()) || cookDishes.getCanteenId() == 0){
throw new ServiceException("食堂不能为空");
}
if (StringUtils.isNull(cookDishes.getStallId()) || cookDishes.getStallId() == 0){
throw new ServiceException("档口不能为空");
}
if (StringUtils.isNull(cookDishes.getTypeId()) || cookDishes.getTypeId() == 0){
throw new ServiceException("菜品分类不能为空");
}
if (StringUtils.isNull(cookDishes.getPrice()) || cookDishes.getPrice() == 0){
throw new ServiceException("菜品价格不能为空");
}
if (cookDishesMapper.checkDishIsExist(cookDishes) > 0) {
throw new ServiceException("菜品名称已存在");
}
}
/**
* 批量删除菜品信息
*
@ -82,6 +143,12 @@ public class CookDishesServiceImpl implements ICookDishesService {
*/
@Override
public int deleteCookDishesByDishesIds(Long[] dishesIds) {
//查询所有当天及之后的菜品计划detailId
List<Long> detailIdList = cookDishesMapper.selectDishPlanDetailIdByDishId(dishesIds, DateUtils.getDate());
//删除菜品计划cook_recipe_dishes 菜品计划菜品关联表
if (detailIdList != null && !detailIdList.isEmpty()){
cookDishesMapper.deleteCookDishesByDishPlanDetailIds(detailIdList,dishesIds);
}
return cookDishesMapper.deleteCookDishesByDishesIds(dishesIds);
}
@ -95,4 +162,47 @@ public class CookDishesServiceImpl implements ICookDishesService {
public int deleteCookDishesByDishesId(Long dishesId) {
return cookDishesMapper.deleteCookDishesByDishesId(dishesId);
}
private void calculateNutritionalInfo(CookDishes cookDishes) {
List<CookDishesMaterial> dishesMaterialList = cookDishes.getDishesMaterialList();
List<NutritionEntity> nutritionEntityList = new ArrayList<>();
for (CookDishesMaterial i : dishesMaterialList) {
NutritionEntity nutritionEntity = cookNutritionMapper.getNutritionEntity(i);
if (nutritionEntity != null) {
System.err.println(i.getMaterialId() + ",开始值:" + nutritionEntity.getCalcium());
nutritionEntity.setWeight(Double.valueOf(i.getWeight() + ""));
nutritionEntity.setBaseWeight(100.0);
nutritionEntityList.add(nutritionEntity);
}
}
NutritionEntity nutritionEntity = NutritionEntityUtil.countNutrition(nutritionEntityList);
if (!nutritionEntityList.isEmpty()) {
System.err.println("总和:" + nutritionEntity.getCalcium());
//计算营养成分
countNum(nutritionEntity, Double.valueOf(cookDishes.getWeight() + ""));
System.err.println("计算后:" + nutritionEntity.getCalcium());
cookDishesMapper.updateFinalNutrition(nutritionEntity, cookDishes.getDishesId());
}
}
private void countNum(NutritionEntity nutritionEntity, Double weight) {
Field[] fields = nutritionEntity.getClass().getDeclaredFields();
for (Field field : fields) {
field.setAccessible(true);
try {
Double value = (Double) field.get(nutritionEntity);
if (value != null) {
System.err.println("先前值----" + value);
double proportion = Arith.div(weight, 100);
value = Arith.mul(value, proportion);
field.set(nutritionEntity, value);
System.err.println("后来值++++" + value);
} else {
field.set(nutritionEntity, 0.00);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
}

View File

@ -1,6 +1,9 @@
package com.bonus.canteen.core.cook.service.impl;
import java.util.Collections;
import java.util.List;
import com.bonus.canteen.core.cook.vo.CookDishesTypeVO;
import com.bonus.common.core.exception.ServiceException;
import com.bonus.common.core.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
@ -38,7 +41,7 @@ public class CookDishesTypeServiceImpl implements ICookDishesTypeService {
* @return 菜品类型信息
*/
@Override
public List<CookDishesType> selectCookDishesTypeList(CookDishesType cookDishesType) {
public List<CookDishesTypeVO> selectCookDishesTypeList(CookDishesType cookDishesType) {
return cookDishesTypeMapper.selectCookDishesTypeList(cookDishesType);
}
@ -52,6 +55,7 @@ public class CookDishesTypeServiceImpl implements ICookDishesTypeService {
public int insertCookDishesType(CookDishesType cookDishesType) {
cookDishesType.setCreateTime(DateUtils.getNowDate());
try {
checkParam(cookDishesType, false);
return cookDishesTypeMapper.insertCookDishesType(cookDishesType);
} catch (Exception e) {
throw new ServiceException(e.getMessage());
@ -68,12 +72,34 @@ public class CookDishesTypeServiceImpl implements ICookDishesTypeService {
public int updateCookDishesType(CookDishesType cookDishesType) {
cookDishesType.setUpdateTime(DateUtils.getNowDate());
try {
checkParam(cookDishesType, true);
return cookDishesTypeMapper.updateCookDishesType(cookDishesType);
} catch (Exception e) {
throw new ServiceException(e.getMessage());
}
}
public void checkParam(CookDishesType cookDishesType, boolean isUpdate) {
if (isUpdate) {
if (cookDishesType.getDishesTypeId() == null) {
throw new ServiceException("菜品分类ID不能为空");
}
}
if (cookDishesType.getDishesTypeName() == null || cookDishesType.getDishesTypeName().isEmpty()) {
throw new ServiceException("菜品分类名称不能为空");
}
if (cookDishesTypeMapper.checkIsExistByName(cookDishesType) > 0){
throw new ServiceException("该菜品分类名称已存在");
}
if(cookDishesType.getParentId() == null || cookDishesType.getParentId() == 0) {
cookDishesType.setLevel(0L);
}else {
if(cookDishesType.getLevel() == null){
cookDishesType.setLevel(1L);
}
}
}
/**
* 批量删除菜品类型信息
*
@ -82,6 +108,10 @@ public class CookDishesTypeServiceImpl implements ICookDishesTypeService {
*/
@Override
public int deleteCookDishesTypeByDishesTypeIds(Long[] dishesTypeIds) {
// 判断该菜品类型信息是否被使用
if (cookDishesTypeMapper.checkIsUse(dishesTypeIds) > 0){
throw new ServiceException("该菜品类型信息被使用,不允许删除!");
}
return cookDishesTypeMapper.deleteCookDishesTypeByDishesTypeIds(dishesTypeIds);
}
@ -95,4 +125,9 @@ public class CookDishesTypeServiceImpl implements ICookDishesTypeService {
public int deleteCookDishesTypeByDishesTypeId(Long dishesTypeId) {
return cookDishesTypeMapper.deleteCookDishesTypeByDishesTypeId(dishesTypeId);
}
@Override
public List<CookDishesTypeVO> selectList(CookDishesType cookDishesType) {
return cookDishesTypeMapper.selectList(cookDishesType);
}
}

View File

@ -0,0 +1,21 @@
package com.bonus.canteen.core.cook.vo;
import com.bonus.canteen.core.common.domain.BaseTreeNode;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serializable;
/**
* @author 19814
*/
@EqualsAndHashCode(callSuper = true)
@Data
public class CookDishesTypeVO extends BaseTreeNode implements Serializable {
@ApiModelProperty(value = "菜品类型ID")
private Long dishesTypeId;
@ApiModelProperty(value = "菜品类型名称")
private String dishesTypeName;
}

View File

@ -60,7 +60,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="glycemicIndex" column="glycemic_index" />
<result property="sort" column="sort" />
<result property="canteenId" column="canteen_id" />
<result property="shopstallId" column="shopstall_id" />
<result property="stallId" column="shopstall_id" />
<result property="hideFlag" column="hide_flag" />
<result property="convertFlag" column="convert_flag" />
<result property="materialCost" column="material_cost" />
@ -73,90 +73,124 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="canteenName" column="canteen_name" />
<result property="stallName" column="stall_name" />
<result property="areaName" column="area_name" />
<result property="dishesTypeName" column="dishes_type_name" />
</resultMap>
<sql id="selectCookDishesVo">
select dishes_id, meal_type, custom_id, inventory_id, dishes_name, alias_name, bar_code, intro, cook_id, type_id, classify_id, effect_id, style_id, if_local_feature, dishes_depart, sequence, pungency_degree, sales_mode, size_type, size_json, weight, large_weight, little_weight, weight_deviation, price, unit_price, large_price, little_price, image_url, particulars, recommend, index_recommend, like_survey, like_batch, like_num, initial_score, calories, protein, fat, carbohydrate, dietary_fiber, cholesterol, calcium, sodium, purine, iron, iodine, kalium, vitamin_a, vitamin_c, vitamin_e, magnesium, zinc, glycemic_index, sort, canteen_id, shopstall_id, hide_flag, convert_flag, material_cost, gross_profit, gross_profit_rate, public_dishes, area_id, meal_id, create_by, create_time, update_by, update_time from cook_dishes
select dishes_id, meal_type, custom_id, inventory_id, dishes_name, alias_name, bar_code, intro, cook_id, type_id,cdt.dishes_type_name, classify_id,
effect_id, style_id, if_local_feature, dishes_depart, sequence, pungency_degree, sales_mode, size_type, size_json,
weight, large_weight, little_weight, weight_deviation, price, unit_price, large_price, little_price, image_url,
particulars, recommend, index_recommend, like_survey, like_batch, like_num, initial_score, calories, protein, fat,
carbohydrate, dietary_fiber, cholesterol, calcium, sodium, purine, iron, iodine, kalium, vitamin_a, vitamin_c,
vitamin_e, magnesium, zinc, glycemic_index, sort, cd.canteen_id,bc.canteen_name,cd.shopstall_id,bs.stall_name, hide_flag, convert_flag, material_cost,
gross_profit, gross_profit_rate, public_dishes, cd.area_id,ba.area_name, meal_id, cd.create_by, cd.create_time, cd.update_by, cd.update_time
from cook_dishes cd
left join basic_area ba on cd.area_id = ba.area_id
left join basic_canteen bc on cd.canteen_id = bc.canteen_id
left join basic_stall bs on cd.shopstall_id = bs.stall_id
left join cook_dishes_type cdt on cd.type_id = cdt.dishes_type_id
</sql>
<select id="selectCookDishesList" parameterType="com.bonus.canteen.core.cook.domain.CookDishes" resultMap="CookDishesResult">
<include refid="selectCookDishesVo"/>
<where>
<if test="mealType != null "> and meal_type = #{mealType}</if>
<if test="customId != null "> and custom_id = #{customId}</if>
<if test="inventoryId != null and inventoryId != ''"> and inventory_id = #{inventoryId}</if>
<if test="dishesName != null and dishesName != ''"> and dishes_name like concat('%', #{dishesName}, '%')</if>
<if test="aliasName != null and aliasName != ''"> and alias_name like concat('%', #{aliasName}, '%')</if>
<if test="barCode != null and barCode != ''"> and bar_code = #{barCode}</if>
<if test="intro != null and intro != ''"> and intro = #{intro}</if>
<if test="cookId != null "> and cook_id = #{cookId}</if>
<if test="typeId != null "> and type_id = #{typeId}</if>
<if test="classifyId != null "> and classify_id = #{classifyId}</if>
<if test="effectId != null "> and effect_id = #{effectId}</if>
<if test="styleId != null "> and style_id = #{styleId}</if>
<if test="ifLocalFeature != null "> and if_local_feature = #{ifLocalFeature}</if>
<if test="dishesDepart != null "> and dishes_depart = #{dishesDepart}</if>
<if test="sequence != null "> and sequence = #{sequence}</if>
<if test="pungencyDegree != null "> and pungency_degree = #{pungencyDegree}</if>
<if test="salesMode != null "> and sales_mode = #{salesMode}</if>
<if test="sizeType != null "> and size_type = #{sizeType}</if>
<if test="sizeJson != null and sizeJson != ''"> and size_json = #{sizeJson}</if>
<if test="weight != null "> and weight = #{weight}</if>
<if test="largeWeight != null "> and large_weight = #{largeWeight}</if>
<if test="littleWeight != null "> and little_weight = #{littleWeight}</if>
<if test="weightDeviation != null "> and weight_deviation = #{weightDeviation}</if>
<if test="price != null "> and price = #{price}</if>
<if test="unitPrice != null "> and unit_price = #{unitPrice}</if>
<if test="largePrice != null "> and large_price = #{largePrice}</if>
<if test="littlePrice != null "> and little_price = #{littlePrice}</if>
<if test="imageUrl != null and imageUrl != ''"> and image_url = #{imageUrl}</if>
<if test="particulars != null and particulars != ''"> and particulars = #{particulars}</if>
<if test="recommend != null and recommend != ''"> and recommend = #{recommend}</if>
<if test="indexRecommend != null "> and index_recommend = #{indexRecommend}</if>
<if test="likeSurvey != null "> and like_survey = #{likeSurvey}</if>
<if test="likeBatch != null "> and like_batch = #{likeBatch}</if>
<if test="likeNum != null "> and like_num = #{likeNum}</if>
<if test="initialScore != null "> and initial_score = #{initialScore}</if>
<if test="calories != null "> and calories = #{calories}</if>
<if test="protein != null "> and protein = #{protein}</if>
<if test="fat != null "> and fat = #{fat}</if>
<if test="carbohydrate != null "> and carbohydrate = #{carbohydrate}</if>
<if test="dietaryFiber != null "> and dietary_fiber = #{dietaryFiber}</if>
<if test="cholesterol != null "> and cholesterol = #{cholesterol}</if>
<if test="calcium != null "> and calcium = #{calcium}</if>
<if test="sodium != null "> and sodium = #{sodium}</if>
<if test="purine != null "> and purine = #{purine}</if>
<if test="iron != null "> and iron = #{iron}</if>
<if test="iodine != null "> and iodine = #{iodine}</if>
<if test="kalium != null "> and kalium = #{kalium}</if>
<if test="vitaminA != null "> and vitamin_a = #{vitaminA}</if>
<if test="vitaminC != null "> and vitamin_c = #{vitaminC}</if>
<if test="vitaminE != null "> and vitamin_e = #{vitaminE}</if>
<if test="magnesium != null "> and magnesium = #{magnesium}</if>
<if test="zinc != null "> and zinc = #{zinc}</if>
<if test="glycemicIndex != null "> and glycemic_index = #{glycemicIndex}</if>
<if test="sort != null "> and sort = #{sort}</if>
<if test="canteenId != null "> and canteen_id = #{canteenId}</if>
<if test="shopstallId != null "> and shopstall_id = #{shopstallId}</if>
<if test="hideFlag != null "> and hide_flag = #{hideFlag}</if>
<if test="convertFlag != null "> and convert_flag = #{convertFlag}</if>
<if test="materialCost != null "> and material_cost = #{materialCost}</if>
<if test="grossProfit != null "> and gross_profit = #{grossProfit}</if>
<if test="grossProfitRate != null "> and gross_profit_rate = #{grossProfitRate}</if>
<if test="publicDishes != null "> and public_dishes = #{publicDishes}</if>
<if test="areaId != null "> and area_id = #{areaId}</if>
<if test="mealId != null and mealId != ''"> and meal_id = #{mealId}</if>
<where>
and cd.del_flag = 0
<if test="typeIds != null and typeIds.size() > 0">
and cd.type_id in
<foreach collection="typeIds" item="typeId" separator="," open="(" close=")">
#{typeId}
</foreach>
</if>
<if test="mealType != null "> and cd.meal_type = #{mealType}</if>
<if test="customId != null "> and cd.custom_id = #{customId}</if>
<if test="inventoryId != null and inventoryId != ''"> and cd.inventory_id = #{inventoryId}</if>
<if test="dishesName != null and dishesName != ''"> and cd.dishes_name like concat('%', #{dishesName}, '%')</if>
<if test="aliasName != null and aliasName != ''"> and cd.alias_name like concat('%', #{aliasName}, '%')</if>
<if test="barCode != null and barCode != ''"> and cd.bar_code = #{barCode}</if>
<if test="intro != null and intro != ''"> and cd.intro = #{intro}</if>
<if test="cookId != null "> and cd.cook_id = #{cookId}</if>
<if test="typeId != null "> and cd.type_id = #{typeId}</if>
<if test="classifyId != null "> and cd.classify_id = #{classifyId}</if>
<if test="effectId != null "> and cd.effect_id = #{effectId}</if>
<if test="styleId != null "> and cd.style_id = #{styleId}</if>
<if test="ifLocalFeature != null "> and cd.if_local_feature = #{ifLocalFeature}</if>
<if test="dishesDepart != null "> and cd.dishes_depart = #{dishesDepart}</if>
<if test="sequence != null "> and cd.sequence = #{sequence}</if>
<if test="pungencyDegree != null "> and cd.pungency_degree = #{pungencyDegree}</if>
<if test="salesMode != null "> and cd.sales_mode = #{salesMode}</if>
<if test="sizeType != null "> and cd.size_type = #{sizeType}</if>
<if test="sizeJson != null and sizeJson != ''"> and cd.size_json = #{sizeJson}</if>
<if test="weight != null "> and cd.weight = #{weight}</if>
<if test="largeWeight != null "> and cd.large_weight = #{largeWeight}</if>
<if test="littleWeight != null "> and cd.little_weight = #{littleWeight}</if>
<if test="weightDeviation != null "> and cd.weight_deviation = #{weightDeviation}</if>
<if test="price != null "> and cd.price = #{price}</if>
<if test="unitPrice != null "> and cd.unit_price = #{unitPrice}</if>
<if test="largePrice != null "> and cd.large_price = #{largePrice}</if>
<if test="littlePrice != null "> and cd.little_price = #{littlePrice}</if>
<if test="imageUrl != null and imageUrl != ''"> and cd.image_url = #{imageUrl}</if>
<if test="particulars != null and particulars != ''"> and cd.particulars = #{particulars}</if>
<if test="recommend != null and recommend != ''"> and cd.recommend = #{recommend}</if>
<if test="indexRecommend != null "> and cd.index_recommend = #{indexRecommend}</if>
<if test="likeSurvey != null "> and cd.like_survey = #{likeSurvey}</if>
<if test="likeBatch != null "> and cd.like_batch = #{likeBatch}</if>
<if test="likeNum != null "> and cd.like_num = #{likeNum}</if>
<if test="initialScore != null "> and cd.initial_score = #{initialScore}</if>
<if test="calories != null "> and cd.calories = #{calories}</if>
<if test="protein != null "> and cd.protein = #{protein}</if>
<if test="fat != null "> and cd.fat = #{fat}</if>
<if test="carbohydrate != null "> and cd.carbohydrate = #{carbohydrate}</if>
<if test="dietaryFiber != null "> and cd.dietary_fiber = #{dietaryFiber}</if>
<if test="cholesterol != null "> and cd.cholesterol = #{cholesterol}</if>
<if test="calcium != null "> and cd.calcium = #{calcium}</if>
<if test="sodium != null "> and cd.sodium = #{sodium}</if>
<if test="purine != null "> and cd.purine = #{purine}</if>
<if test="iron != null "> and cd.iron = #{iron}</if>
<if test="iodine != null "> and cd.iodine = #{iodine}</if>
<if test="kalium != null "> and cd.kalium = #{kalium}</if>
<if test="vitaminA != null "> and cd.vitamin_a = #{vitaminA}</if>
<if test="vitaminC != null "> and cd.vitamin_c = #{vitaminC}</if>
<if test="vitaminE != null "> and cd.vitamin_e = #{vitaminE}</if>
<if test="magnesium != null "> and cd.magnesium = #{magnesium}</if>
<if test="zinc != null "> and cd.zinc = #{zinc}</if>
<if test="glycemicIndex != null "> and cd.glycemic_index = #{glycemicIndex}</if>
<if test="sort != null "> and cd.sort = #{sort}</if>
<if test="canteenId != null "> and cd.canteen_id = #{canteenId}</if>
<if test="stallId != null "> and cd.shopstall_id = #{stallId}</if>
<if test="hideFlag != null "> and cd.hide_flag = #{hideFlag}</if>
<if test="convertFlag != null "> and cd.convert_flag = #{convertFlag}</if>
<if test="materialCost != null "> and cd.material_cost = #{materialCost}</if>
<if test="grossProfit != null "> and cd.gross_profit = #{grossProfit}</if>
<if test="grossProfitRate != null "> and cd.gross_profit_rate = #{grossProfitRate}</if>
<if test="publicDishes != null "> and cd.public_dishes = #{publicDishes}</if>
<if test="areaId != null "> and cd.area_id = #{areaId}</if>
<if test="mealId != null and mealId != ''"> and cd.meal_id = #{mealId}</if>
</where>
</select>
<select id="selectCookDishesByDishesId" parameterType="Long" resultMap="CookDishesResult">
<include refid="selectCookDishesVo"/>
where dishes_id = #{dishesId}
where cd.dishes_id = #{dishesId}
</select>
<select id="checkDishIsExist" resultType="java.lang.Integer">
select count(1) from cook_dishes where dishes_name = #{dishesName} and area_id = #{areaId}
and canteen_id = #{canteenId} and shopstall_id = #{stallId}
<if test="dishesId != null">
and dishes_id != #{dishesId}
</if>
</select>
<select id="selectDishPlanDetailIdByDishId" resultType="java.lang.Long">
select recipe_detail_id from cook_recipe_detail where apply_date <![CDATA[ >= ]]> #{applyDate} and detail_type = '2'
</select>
<insert id="insertCookDishes" parameterType="com.bonus.canteen.core.cook.domain.CookDishes" useGeneratedKeys="true" keyProperty="dishesId">
insert into cook_dishes
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="baseDishesId != null">base_dishes_id,</if>
<if test="mealType != null">meal_type,</if>
<if test="customId != null">custom_id,</if>
<if test="inventoryId != null">inventory_id,</if>
@ -212,7 +246,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="glycemicIndex != null">glycemic_index,</if>
<if test="sort != null">sort,</if>
<if test="canteenId != null">canteen_id,</if>
<if test="shopstallId != null">shopstall_id,</if>
<if test="stallId != null">shopstall_id,</if>
<if test="hideFlag != null">hide_flag,</if>
<if test="convertFlag != null">convert_flag,</if>
<if test="materialCost != null">material_cost,</if>
@ -227,6 +261,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="updateTime != null">update_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="baseDishesId != null">#{baseDishesId},</if>
<if test="mealType != null">#{mealType},</if>
<if test="customId != null">#{customId},</if>
<if test="inventoryId != null">#{inventoryId},</if>
@ -282,7 +317,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="glycemicIndex != null">#{glycemicIndex},</if>
<if test="sort != null">#{sort},</if>
<if test="canteenId != null">#{canteenId},</if>
<if test="shopstallId != null">#{shopstallId},</if>
<if test="stallId != null">#{stallId},</if>
<if test="hideFlag != null">#{hideFlag},</if>
<if test="convertFlag != null">#{convertFlag},</if>
<if test="materialCost != null">#{materialCost},</if>
@ -297,6 +332,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="updateTime != null">#{updateTime},</if>
</trim>
</insert>
<insert id="insertDishesName" keyProperty="baseDishesId" useGeneratedKeys="true">
insert into cook_dishes_base (dishes_name, create_by, create_time, update_by, update_time)
values (#{dishesName}, #{createBy}, #{createTime}, #{updateBy}, #{updateTime})
</insert>
<insert id="insertDishesMaterial">
insert into cook_dishes_material (dishes_id, material_id, weight,material_type, create_by, create_time, update_by, update_time)
values
<foreach collection="list" item="item" separator=",">
(#{dishesId}, #{item.materialId}, #{item.weight},#{item.materialType}, #{item.createBy}, #{item.createTime}, #{item.updateBy}, #{item.updateTime})
</foreach>
</insert>
<update id="updateCookDishes" parameterType="com.bonus.canteen.core.cook.domain.CookDishes">
update cook_dishes
@ -356,7 +403,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="glycemicIndex != null">glycemic_index = #{glycemicIndex},</if>
<if test="sort != null">sort = #{sort},</if>
<if test="canteenId != null">canteen_id = #{canteenId},</if>
<if test="shopstallId != null">shopstall_id = #{shopstallId},</if>
<if test="stallId != null">shopstall_id = #{stallId},</if>
<if test="hideFlag != null">hide_flag = #{hideFlag},</if>
<if test="convertFlag != null">convert_flag = #{convertFlag},</if>
<if test="materialCost != null">material_cost = #{materialCost},</if>
@ -372,15 +419,60 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</trim>
where dishes_id = #{dishesId}
</update>
<update id="updateDishesName">
update cook_dishes_base
<set>
<if test="dishesName != null and dishesName != ''">dishes_name = #{dishesName},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
</set>
where base_dishes_id = #{baseDishesId}
</update>
<update id="updateFinalNutrition">
update cook_dishes
<trim prefix="SET" suffixOverrides=",">
<if test="bean.calories != null">calories = #{bean.calories},</if>
<if test="bean.protein != null">protein = #{bean.protein},</if>
<if test="bean.fat != null">fat = #{bean.fat},</if>
<if test="bean.carbohydrate != null">carbohydrate = #{bean.carbohydrate},</if>
<if test="bean.dietaryFiber != null">dietary_fiber = #{bean.dietaryFiber},</if>
<if test="bean.cholesterol != null">cholesterol = #{bean.cholesterol},</if>
<if test="bean.calcium != null">calcium = #{bean.calcium},</if>
<if test="bean.sodium != null">sodium = #{bean.sodium},</if>
<if test="bean.purine != null">purine = #{bean.purine},</if>
<if test="bean.iron != null">iron = #{bean.iron},</if>
<if test="bean.iodine != null">iodine = #{bean.iodine},</if>
<if test="bean.kalium != null">kalium = #{bean.kalium},</if>
<if test="bean.vitaminA != null">vitamin_a = #{bean.vitaminA},</if>
<if test="bean.vitaminC != null">vitamin_c = #{bean.vitaminC},</if>
<if test="bean.vitaminE != null">vitamin_e = #{bean.vitaminE},</if>
<if test="bean.magnesium != null">magnesium = #{bean.magnesium},</if>
<if test="bean.glycemicIndex != null">glycemic_index = #{bean.glycemicIndex},</if>
</trim>
where dishes_id = #{dishesId}
</update>
<delete id="deleteCookDishesByDishesId" parameterType="Long">
delete from cook_dishes where dishes_id = #{dishesId}
</delete>
<delete id="deleteCookDishesByDishesIds" parameterType="String">
delete from cook_dishes where dishes_id in
update cook_dishes set del_flag = '2' where dishes_id in
<foreach item="dishesId" collection="array" open="(" separator="," close=")">
#{dishesId}
</foreach>
</delete>
<delete id="deleteDishesMaterialByDishesId">
delete from cook_dishes_material where dishes_id = #{dishesId}
</delete>
<delete id="deleteCookDishesByDishPlanDetailIds">
delete from cook_dishes where dishes_id in
<foreach item="detailId" collection="dishesIds" open="(" separator="," close=")">
#{detailId}
</foreach>
and recipe_detail_id in
<foreach item="detailId" collection="detailIdList" open="(" separator="," close=")">
#{detailId}
</foreach>
</delete>
</mapper>

View File

@ -21,7 +21,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
select dishes_type_id, dishes_type_name, dishes_type_code, parent_id, level, area_id, dishes_alias_name, create_by, create_time, update_by, update_time from cook_dishes_type
</sql>
<select id="selectCookDishesTypeList" parameterType="com.bonus.canteen.core.cook.domain.CookDishesType" resultMap="CookDishesTypeResult">
<select id="selectCookDishesTypeList" parameterType="com.bonus.canteen.core.cook.vo.CookDishesTypeVO" resultMap="CookDishesTypeResult">
<include refid="selectCookDishesTypeVo"/>
<where>
<if test="dishesTypeName != null and dishesTypeName != ''"> and dishes_type_name like concat('%', #{dishesTypeName}, '%')</if>
@ -37,7 +37,23 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<include refid="selectCookDishesTypeVo"/>
where dishes_type_id = #{dishesTypeId}
</select>
<select id="checkIsExistByName" resultType="java.lang.Integer">
select count(1) from cook_dishes_type
where dishes_type_name = #{dishesTypeName}
<if test="dishesTypeId != null">and dishes_type_id != #{dishesTypeId}</if>
</select>
<select id="checkIsUse" resultType="java.lang.Integer">
select count(1) from cook_dishes
where type_id in
<foreach item="typeId" collection="dishesTypeIds" open="(" separator="," close=")">
#{typeId}
</foreach>
</select>
<select id="selectList" resultType="com.bonus.canteen.core.cook.vo.CookDishesTypeVO">
select dishes_type_id as dishesTypeId, dishes_type_name as dishesTypeName,dishes_type_id as id,parent_id as parentId
from cook_dishes_type
</select>
<insert id="insertCookDishesType" parameterType="com.bonus.canteen.core.cook.domain.CookDishesType" useGeneratedKeys="true" keyProperty="dishesTypeId">
insert into cook_dishes_type
<trim prefix="(" suffix=")" suffixOverrides=",">

View File

@ -158,6 +158,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
select count(1) from cook_nutrition where nutrition_name = #{nutritionName}
<if test="nutritionId != null"> and nutrition_id != #{nutritionId}</if>
</select>
<select id="getNutritionEntity" resultType="com.bonus.canteen.core.utils.NutritionEntity">
<include refid="selectCookNutritionVo"/>
where nutrition_id = (select nutrition_id from cook_material where material_id = #{materialId})
</select>
<insert id="insertCookNutrition" parameterType="com.bonus.canteen.core.cook.domain.CookNutrition" useGeneratedKeys="true" keyProperty="nutritionId">