ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TDataGeneratorController.java
@@ -104,7 +104,7 @@ @ApiOperation( value = "数据生成终止 shopId=店铺id type: 1=餐饮 2=进货") @GetMapping(value = "/stopGenerator") public AjaxResult<String> dataCoverage(@RequestParam(value = "shopId") Long shopId, public AjaxResult<String> stopGenerator(@RequestParam(value = "shopId") Long shopId, @RequestParam(value = "type") Integer type) { if(type == 1){ redisCache.setCacheObject(OrderNumConstants.MEAL+"_"+shopId,shopId); ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TOrderSaleController.java
@@ -155,8 +155,8 @@ TOrderSaleExportExcel orderSaleExportExcel = new TOrderSaleExportExcel(); BeanUtils.copyProperties(orderSaleVO, orderSaleExportExcel); orderSaleExportExcel.setCreateStrTime(DateUtils.localDateTimeToString(orderSaleVO.getCreateTime())); orderSaleExportExcel.setGoodsAmount(orderSaleVO.getOrderSaleGoods().stream().map(TOrderSaleGoods::getThisSalePrice).reduce(BigDecimal::add).get()); orderSaleExportExcel.setGoodsCount(orderSaleVO.getOrderSaleGoods().size()); orderSaleExportExcel.setGoodsAmount(orderSaleVO.getGoodsAmount()); orderSaleExportExcel.setGoodsCount(orderSaleVO.getGoodsCount()); orderMeals.add(orderSaleExportExcel); } Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), TOrderSaleExportExcel.class, orderMeals); ruoyi-system/src/main/java/com/ruoyi/system/export/TOrderSaleExportExcel.java
@@ -26,7 +26,7 @@ @Excel(width = 30,name = "支付方式",replace = {"现金_1","支付宝_2","微信_3","银行卡_4","其他_5"," _null"}) private Integer payType; @Excel(width = 30,name = "菜品数量") @Excel(width = 30,name = "货品数量") private Integer goodsCount; @Excel(width = 30,name = "货品总价") 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,8 +140,12 @@ // 每种菜品分类需要几个菜的生成 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) { @@ -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); ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TOrderSaleServiceImpl.java
@@ -22,10 +22,7 @@ import java.math.BigDecimal; import java.time.LocalDate; import java.time.LocalDateTime; import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.Objects; import java.util.*; import java.util.stream.Collectors; /** @@ -45,6 +42,8 @@ private TOrderStockGoodsService orderStockGoodsService; @Autowired private TOrderSaleGoodsMapper orderSaleGoodsMapper; @Autowired private TGoodsService goodsService; @Override public void add(TOrderSaleDTO dto) { // 查询菜品分类 @@ -58,6 +57,18 @@ } dto.setOrderMoney(sum); this.save(dto); List<TGoods> goods = goodsService.list(Wrappers.lambdaQuery(TGoods.class).eq(TGoods::getShopId,dto.getShopId())); List<TGoods> goodsList = new ArrayList<>(); for (TOrderSaleGoods orderSaleGood : orderSaleGoods) { goods.forEach(good -> { if(orderSaleGood.getGoodsNum().equals(good.getGoodsNum())){ good.setInventory(good.getInventory()-orderSaleGood.getGoodsCount()); goodsList.add(good); } }); } goodsService.updateBatchById(goodsList); // 查询进货数据 List<TOrderStockGoods> orderStockGoodsList = orderStockGoodsService.getListByTimeAndShopId(DateUtils.localDateToString(dto.getOrderTime()), dto.getShopId()); @@ -241,19 +252,54 @@ } List<TOrderSaleVO> list = this.baseMapper.exportOrderSale(query); List<Long> ids = list.stream().map(TOrderSaleVO::getId).collect(Collectors.toList()); List<TOrderSaleGoods> list1 = orderSaleGoodsService.list(Wrappers.lambdaQuery(TOrderSaleGoods.class) .in(TOrderSaleGoods::getOrderId,ids)); // 查询商品信息 for (TOrderSaleVO orderSaleVO : list) { List<TOrderSaleGoods> collect = list1.stream().filter(e -> e.getOrderId().equals(orderSaleVO.getId())).collect(Collectors.toList()); orderSaleVO.setOrderSaleGoods(collect); if(!CollectionUtils.isEmpty(ids)){ List<TOrderSaleGoods> list1 = orderSaleGoodsService.list(Wrappers.lambdaQuery(TOrderSaleGoods.class) .in(TOrderSaleGoods::getOrderId, ids)); list.forEach(e->{ List<TOrderSaleGoods> collect = list1.stream().filter(m -> m.getOrderId().equals(e.getId())).collect(Collectors.toList()); if(!CollectionUtils.isEmpty(collect)){ BigDecimal goodsAmount = BigDecimal.ZERO; Integer count = 0; for (TOrderSaleGoods tOrderSaleGoods : collect) { goodsAmount = goodsAmount.add(tOrderSaleGoods.getThisSalePrice().multiply(new BigDecimal(tOrderSaleGoods.getGoodsCount()))); count = count+tOrderSaleGoods.getGoodsCount(); } e.setGoodsAmount(goodsAmount); e.setGoodsCount(count); e.setOrderSaleGoods(collect); } }); } return list; } @Override public List<OrderTrendsVO> orderingTrends(TDataStatisticsQuery query) { return this.baseMapper.orderingTrends(query); List<OrderTrendsVO> orderTrendsVOS = this.baseMapper.orderingTrends(query); LocalDate localDate = DateUtils.stringToLocalDateTime(query.getEndTime()).toLocalDate(); for (int i = 0; i < 7; i++) { if(i == 0){ LocalDate finalLocalDate = localDate; OrderTrendsVO orderTrendsVO = orderTrendsVOS.stream().filter(e -> finalLocalDate.compareTo(DateUtils.stringToLocalDate(e.getDayTime())) == 0).findFirst().orElse(null); if(Objects.isNull(orderTrendsVO)){ orderTrendsVO = new OrderTrendsVO(); orderTrendsVO.setDayTime(DateUtils.localDateToString(localDate)); orderTrendsVO.setOrderCount(0); orderTrendsVOS.add(orderTrendsVO); } }else { localDate = localDate.minusDays(1); LocalDate finalLocalDate1 = localDate; OrderTrendsVO orderTrendsVO = orderTrendsVOS.stream().filter(e -> finalLocalDate1.compareTo(DateUtils.stringToLocalDate(e.getDayTime())) == 0).findFirst().orElse(null); if(Objects.isNull(orderTrendsVO)){ orderTrendsVO = new OrderTrendsVO(); orderTrendsVO.setDayTime(DateUtils.localDateToString(finalLocalDate1)); orderTrendsVO.setOrderCount(0); orderTrendsVOS.add(orderTrendsVO); } } } return orderTrendsVOS.stream().sorted(Comparator.comparing(OrderTrendsVO::getDayTime)).collect(Collectors.toList()); } @Override @@ -339,9 +385,6 @@ orderSale.setPayType(dto.getPayType()); orderSale.setPayMoney(dto.getPayMoney()); orderSale.setStatus(2); this.updateById(orderSale); } ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TOrderStockServiceImpl.java
@@ -61,7 +61,7 @@ dto.setIsCover(0); } this.save(dto); List<TGoods> goods = goodsService.list(Wrappers.lambdaQuery(TGoods.class)); List<TGoods> goods = goodsService.list(Wrappers.lambdaQuery(TGoods.class).eq(TGoods::getShopId,dto.getShopId())); List<TGoods> goodsUpdateList = new ArrayList<>(); // 添加商品 orderStockGoods.forEach(orderSaleGoods1 -> { ruoyi-system/src/main/resources/mapper/system/TOrderMealMapper.xml
@@ -318,7 +318,7 @@ LEFT JOIN t_order_meal tom ON tom.id = tomg.orderId <where> <if test="query.startTime != null and query.startTime != '' and query.endTime != null and query.endTime != ''"> AND (tom.createTime BETWEEN #{query.startTime} AND #{query.endTime}) AND (tom.mealTime BETWEEN #{query.startTime} AND #{query.endTime}) </if> <if test="query.goodsName != null and query.goodsName != ''"> AND tomg.goodsName like concat('%', #{query.goodsName}, '%') ruoyi-system/src/main/resources/mapper/system/TOrderSaleMapper.xml
@@ -142,6 +142,7 @@ AND isCover = 1 AND status = 2 </where> GROUP BY DATE_FORMAT(orderTime, '%Y-%m-%d') </select> <select id="getDataGeneratorSaleDetail" resultType="java.util.Map"> SELECT