优化+今日菜单
This commit is contained in:
@ -1,13 +1,13 @@
|
||||
package cn.iocoder.yudao.module.system.controller.admin.dishes.vo;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import java.math.BigDecimal;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
@ -52,4 +52,6 @@ public class DishesPageReqVO extends PageParam {
|
||||
private Long carteenId;
|
||||
@Schema(description = "分类编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五")
|
||||
private Long typeId;
|
||||
|
||||
private String weekTime;
|
||||
}
|
@ -78,4 +78,6 @@ public class DishesRespVO {
|
||||
@Schema(description = "菜品类型")
|
||||
@ExcelProperty("菜品类型")
|
||||
private String dishecTypeName;
|
||||
|
||||
private String weekTime;
|
||||
}
|
@ -63,4 +63,6 @@ public class DishesSaveReqVO {
|
||||
private List<DishesNutritionSaveReqVO> dishesNutritionList;
|
||||
@Schema(description = "菜品原材料", example = "1")
|
||||
private List<DishesRawSaveReqVO> dishesRawList;
|
||||
|
||||
private String weekTime;
|
||||
}
|
@ -25,6 +25,8 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
|
||||
@ -93,4 +95,10 @@ public class DishesAppController {
|
||||
// BeanUtils.toBean(list, DishesRespVO.class));
|
||||
// }
|
||||
|
||||
@GetMapping("/getToday")
|
||||
@Operation(summary = "获取今日菜品")
|
||||
public CommonResult<List<DishesRespVO>> getTodayDishes() {
|
||||
List<DishesDO> todayDishes = dishesService.getTodayDishes();
|
||||
return success(BeanUtils.toBean(todayDishes, DishesRespVO.class));
|
||||
}
|
||||
}
|
@ -76,4 +76,6 @@ public class DishesDO extends BaseDO {
|
||||
* 菜品总重量
|
||||
*/
|
||||
private BigDecimal dishesNumber;
|
||||
|
||||
private String weekTime;
|
||||
}
|
@ -65,5 +65,6 @@ public interface DishesService {
|
||||
|
||||
Map<Long,String> getDishName(List<Long> ids);
|
||||
|
||||
List<DishesDO> getTodayDishes();
|
||||
|
||||
}
|
@ -30,7 +30,10 @@ import org.springframework.validation.annotation.Validated;
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.TextStyle;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@ -68,20 +71,20 @@ public class DishesServiceImpl implements DishesService {
|
||||
BigDecimal dishesNumber = createReqVO.getDishesNumber();
|
||||
BigDecimal div = NumberUtil.div(dishesSumPrice, dishesNumber, 2);
|
||||
//避免计算出每克价格约 为0
|
||||
if(div.floatValue() <= 0.00f){
|
||||
if (div.floatValue() <= 0.00f) {
|
||||
dishes.setDishesBasePrice(new BigDecimal("0.01"));
|
||||
}else{
|
||||
} else {
|
||||
dishes.setDishesBasePrice(div);
|
||||
}
|
||||
dishesMapper.insert(dishes);
|
||||
List<DishesNutritionSaveReqVO> list = createReqVO.getDishesNutritionList();
|
||||
List<DishesRawSaveReqVO> dishesRawList = createReqVO.getDishesRawList();
|
||||
if(ObjUtil.isNotEmpty(list)){
|
||||
list.forEach(f-> f.setDishesId(dishes.getId()));
|
||||
if (ObjUtil.isNotEmpty(list)) {
|
||||
list.forEach(f -> f.setDishesId(dishes.getId()));
|
||||
dishesNutritionService.createDishesNutritionList(list);
|
||||
}
|
||||
if(ObjUtil.isNotEmpty(dishesRawList)){
|
||||
dishesRawList.forEach(f-> f.setDishesId(dishes.getId()));
|
||||
if (ObjUtil.isNotEmpty(dishesRawList)) {
|
||||
dishesRawList.forEach(f -> f.setDishesId(dishes.getId()));
|
||||
dishesRawService.createDishesRawList(dishesRawList);
|
||||
}
|
||||
// 返回
|
||||
@ -102,9 +105,9 @@ public class DishesServiceImpl implements DishesService {
|
||||
BigDecimal dishesNumber = new BigDecimal("50");
|
||||
BigDecimal div = NumberUtil.div(dishesSumPrice, dishesNumber, 2);
|
||||
//避免计算出每克价格约 为0
|
||||
if(div.floatValue() <= 0.00f){
|
||||
if (div.floatValue() <= 0.00f) {
|
||||
dishes.setDishesBasePrice(new BigDecimal("0.01"));
|
||||
}else{
|
||||
} else {
|
||||
dishes.setDishesBasePrice(div);
|
||||
}
|
||||
dishesMapper.insert(dishes);
|
||||
@ -125,20 +128,20 @@ public class DishesServiceImpl implements DishesService {
|
||||
BigDecimal dishesNumber = updateObj.getDishesNumber();
|
||||
BigDecimal div = NumberUtil.div(dishesSumPrice, dishesNumber, 2);
|
||||
//避免计算出每克价格约 为0
|
||||
if(div.floatValue() <= 0.00f){
|
||||
if (div.floatValue() <= 0.00f) {
|
||||
updateObj.setDishesBasePrice(new BigDecimal("0.01"));
|
||||
}else{
|
||||
} else {
|
||||
updateObj.setDishesBasePrice(div);
|
||||
}
|
||||
dishesMapper.updateById(updateObj);
|
||||
List<DishesNutritionSaveReqVO> list = updateReqVO.getDishesNutritionList();
|
||||
List<DishesRawSaveReqVO> dishesRawList = updateReqVO.getDishesRawList();
|
||||
if(ObjUtil.isNotEmpty(list)){
|
||||
list.forEach(f-> f.setDishesId(updateReqVO.getId()));
|
||||
if (ObjUtil.isNotEmpty(list)) {
|
||||
list.forEach(f -> f.setDishesId(updateReqVO.getId()));
|
||||
dishesNutritionService.updateDishesNutritionList(list);
|
||||
}
|
||||
if(ObjUtil.isNotEmpty(dishesRawList)){
|
||||
dishesRawList.forEach(f-> f.setDishesId(updateReqVO.getId()));
|
||||
if (ObjUtil.isNotEmpty(dishesRawList)) {
|
||||
dishesRawList.forEach(f -> f.setDishesId(updateReqVO.getId()));
|
||||
dishesRawService.updateDishesRawList(dishesRawList);
|
||||
}
|
||||
}
|
||||
@ -152,9 +155,9 @@ public class DishesServiceImpl implements DishesService {
|
||||
BigDecimal dishesNumber = new BigDecimal("50");
|
||||
BigDecimal div = NumberUtil.div(dishesSumPrice, dishesNumber, 2);
|
||||
//避免计算出每克价格约 为0
|
||||
if(div.floatValue() <= 0.00f){
|
||||
if (div.floatValue() <= 0.00f) {
|
||||
updateObj.setDishesBasePrice(new BigDecimal("0.01"));
|
||||
}else{
|
||||
} else {
|
||||
updateObj.setDishesBasePrice(div);
|
||||
}
|
||||
dishesMapper.updateById(updateObj);
|
||||
@ -188,7 +191,7 @@ public class DishesServiceImpl implements DishesService {
|
||||
@Override
|
||||
public List<DishesDO> getDishesList(List<Long> ids) {
|
||||
return dishesMapper.selectList(Wrappers.<DishesDO>lambdaQuery()
|
||||
.in(DishesDO::getId,ids));
|
||||
.in(DishesDO::getId, ids));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -216,11 +219,30 @@ public class DishesServiceImpl implements DishesService {
|
||||
return collect;
|
||||
}
|
||||
|
||||
public String getHearder(){
|
||||
@Override
|
||||
public List<DishesDO> getTodayDishes() {
|
||||
LocalDate today = LocalDate.now();
|
||||
String dayOfWeekInChinese = today.getDayOfWeek().getDisplayName(TextStyle.FULL, Locale.CHINESE);
|
||||
Long carteenId = deviceInfoService.getCarteen(getHearder());
|
||||
List<DishesDO> dishesDOS = dishesMapper.selectList(Wrappers.<DishesDO>lambdaQuery()
|
||||
.eq(DishesDO::getCarteenId, carteenId)
|
||||
.eq(DishesDO::getWeekTime,dayOfWeekInChinese));
|
||||
return dishesDOS;
|
||||
}
|
||||
|
||||
public String getHearder() {
|
||||
try {
|
||||
return httpServletRequest.getHeader("Authorization");
|
||||
} catch (Exception e) {
|
||||
throw exception(2000_10_001,"无法获取设备编码");
|
||||
throw exception(2000_10_001, "无法获取设备编码");
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
LocalDate today = LocalDate.now();
|
||||
String dayOfWeekInChinese = today.getDayOfWeek().getDisplayName(TextStyle.FULL, Locale.CHINESE);
|
||||
System.out.println("今天是:" + dayOfWeekInChinese);
|
||||
}
|
||||
|
||||
|
||||
}
|
Reference in New Issue
Block a user