xuhy
2024-10-28 f765a447c75772c7202dbbb2ff7595f1e1472d8a
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TDataGeneratorServiceImpl.java
@@ -118,6 +118,9 @@
                throw new ServiceException("该桌台信息不存在");
            }
            Integer orderCount = orderMealGeneratorCountDTO.getOrderCount();
            if(orderCount == 0){
                continue;
            }
            // 查询当前桌的用餐人数
            for (int i = 1; i <= orderCount; i++) {
                int random = getRandom(board.getMinPerson(), board.getMaxPerson());
@@ -137,15 +140,19 @@
                // 每种菜品分类需要几个菜的生成
                foundationConfigVOS.forEach(e -> {
                    int random1 = getRandom(e.getMinCount(), e.getMaxCount());
                    List<TGoods> typeGoods = goods.stream().filter(m -> e.getTypeId().equals(m.getTypeId())).collect(Collectors.toList());
                    typeGoods = randomSelection(typeGoods, random1);
                    List<TGoods> typeGoodsList = goods.stream().filter(m -> e.getTypeId().equals(m.getTypeId())).collect(Collectors.toList());
                    List<TGoods> typeGoods = randomSelection(typeGoodsList, random1);
                    if(typeGoods.size() != random1){
                        List<TGoods> goods1 = randomSelection(typeGoodsList, random1 - typeGoods.size());
                        typeGoods.addAll(goods1);
                    }
                    for (TGoods typeGood : typeGoods) {
                        int count = 0;
                        for (TOrderMealGoods good : orderMealGoods) {
                            if (good.getGoodsNum().equals(typeGood.getGoodsNum())) {
                                count+=1;
                                good.setGoodsCount(good.getGoodsCount() + 1);
                                good.setGoodsSalePrice(good.getGoodsSalePrice().add(typeGood.getSalePrice()));
//                                good.setGoodsSalePrice(good.getGoodsSalePrice().add(typeGood.getSalePrice()));
                                break; // 找到后直接跳出循环
                            }
                        }
@@ -474,7 +481,7 @@
            return;
        }
        // 删除上一次的数据生成
        if(Objects.nonNull(orderStockLast)){
        if(Objects.nonNull(orderStockLast) && Objects.nonNull(stockDataSet) && stockDataSets.size() > 1){
            orderStockService.removeById(orderStockLast);
        }
        orderSaleService.saveBatch(orderSales);