修改为空报错问题
This commit is contained in:
@ -1,6 +1,7 @@
|
|||||||
package cn.iocoder.yudao.module.system.service.dishestype;
|
package cn.iocoder.yudao.module.system.service.dishestype;
|
||||||
|
|
||||||
import cn.hutool.core.map.MapUtil;
|
import cn.hutool.core.map.MapUtil;
|
||||||
|
import cn.hutool.core.util.ObjUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||||
@ -93,35 +94,37 @@ public class DishesTypeServiceImpl implements DishesTypeService {
|
|||||||
List<DishesTypeListRespVO> list=new ArrayList<>();
|
List<DishesTypeListRespVO> list=new ArrayList<>();
|
||||||
//获取订单id
|
//获取订单id
|
||||||
List<Long> collect = dishesTypeMapper.selectOrderIds(carteenId, startTime, endTime);
|
List<Long> collect = dishesTypeMapper.selectOrderIds(carteenId, startTime, endTime);
|
||||||
List<OrderDetail> orderDetailDOS = dishesTypeMapper.selectByIdAmdTypeName(collect);
|
if(ObjUtil.isNotEmpty(collect)){
|
||||||
orderDetailDOS.forEach(f-> f.setCreator(TimePeriodEnum.getTimePeriod(f.getCreateTime())));
|
List<OrderDetail> orderDetailDOS = dishesTypeMapper.selectByIdAmdTypeName(collect);
|
||||||
// 根据时间进行分组
|
orderDetailDOS.forEach(f-> f.setCreator(TimePeriodEnum.getTimePeriod(f.getCreateTime())));
|
||||||
Map<String, List<OrderDetail>> map = orderDetailDOS.stream()
|
// 根据时间进行分组
|
||||||
.collect(Collectors.groupingBy(OrderDetail::getCreator));
|
Map<String, List<OrderDetail>> map = orderDetailDOS.stream()
|
||||||
for (Map.Entry<String, List<OrderDetail>> en : map.entrySet()) {
|
.collect(Collectors.groupingBy(OrderDetail::getCreator));
|
||||||
DishesTypeListRespVO vo=new DishesTypeListRespVO();
|
for (Map.Entry<String, List<OrderDetail>> en : map.entrySet()) {
|
||||||
vo.setTime(en.getKey());
|
DishesTypeListRespVO vo=new DishesTypeListRespVO();
|
||||||
//集合根据菜品名称去重
|
vo.setTime(en.getKey());
|
||||||
List<OrderDetail> collect1 = new ArrayList<>(en.getValue().stream().collect(Collectors.toMap(
|
//集合根据菜品名称去重
|
||||||
OrderDetail::getDishesName,
|
List<OrderDetail> collect1 = new ArrayList<>(en.getValue().stream().collect(Collectors.toMap(
|
||||||
m -> m,
|
OrderDetail::getDishesName,
|
||||||
(oldValue, newValue) -> newValue
|
m -> m,
|
||||||
)).values());
|
(oldValue, newValue) -> newValue
|
||||||
//根据类型进行分组
|
)).values());
|
||||||
collect1.stream()
|
//根据类型进行分组
|
||||||
.collect(Collectors.groupingBy(OrderDetail::getDishUrl))
|
collect1.stream()
|
||||||
.forEach((v,k)-> {
|
.collect(Collectors.groupingBy(OrderDetail::getDishUrl))
|
||||||
Map<String, String> map1 = MapUtil.builder(new HashMap<String, String>())
|
.forEach((v,k)-> {
|
||||||
.put("dishesName", StrUtil.join(",",k.stream()
|
Map<String, String> map1 = MapUtil.builder(new HashMap<String, String>())
|
||||||
.map(OrderDetail::getDishesName)
|
.put("dishesName", StrUtil.join(",",k.stream()
|
||||||
.collect(Collectors.toList())))
|
.map(OrderDetail::getDishesName)
|
||||||
.put("typeName", v)
|
.collect(Collectors.toList())))
|
||||||
.map();
|
.put("typeName", v)
|
||||||
vo.getDishesTypeName().add(map1);
|
.map();
|
||||||
});
|
vo.getDishesTypeName().add(map1);
|
||||||
list.add(vo);
|
});
|
||||||
|
list.add(vo);
|
||||||
|
}
|
||||||
|
list.sort(Comparator.comparing(DishesTypeListRespVO::getTime));
|
||||||
}
|
}
|
||||||
list.sort(Comparator.comparing(DishesTypeListRespVO::getTime));
|
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user