| | |
| | | import org.springframework.util.CollectionUtils; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.Comparator; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | |
| | | List<TOrderMeal> orderMeals = orderMealService.list(Wrappers.lambdaQuery(TOrderMeal.class) |
| | | .in(TOrderMeal::getBoardId, ids) |
| | | .isNotNull(TOrderMeal::getMealTime) |
| | | .orderByDesc(TOrderMeal::getMealTime)); |
| | | .orderByDesc(TOrderMeal::getCreateTime)); |
| | | for (TBoard board : list) { |
| | | List<TOrderMeal> collect = orderMeals.stream().filter(e -> board.getId().equals(e.getBoardId())).collect(Collectors.toList()); |
| | | List<TOrderMeal> collect = orderMeals.stream().filter(e -> board.getId().equals(e.getBoardId())).sorted(Comparator.comparing(TOrderMeal::getCreateTime).reversed()).collect(Collectors.toList()); |
| | | if(!CollectionUtils.isEmpty(collect)){ |
| | | board.setMealType(collect.get(0).getMealType()); |
| | | board.setMealPerson(collect.get(0).getMealPerson()); |
| | |
| | | BeanUtils.copyProperties(orderMealVO, tOrderMealExportExcel); |
| | | tOrderMealExportExcel.setCreateStrTime(DateUtils.localDateToString(orderMealVO.getMealTime())); |
| | | tOrderMealExportExcel.setGoodsList(orderMealVO.getGoodsList().stream().collect(Collectors.joining("\n"))); |
| | | orderMeals.add(tOrderMealExportExcel); |
| | | } |
| | | Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), TOrderMealExportExcel.class, orderMeals); |
| | | HttpServletResponse response = WebUtils.response(); |
| | |
| | | BeanUtils.copyProperties(orderSaleVO, orderSaleExportExcel); |
| | | orderSaleExportExcel.setCreateStrTime(DateUtils.localDateTimeToString(orderSaleVO.getCreateTime())); |
| | | orderSaleExportExcel.setGoodsAmount(orderSaleVO.getOrderSaleGoods().stream().map(TOrderSaleGoods::getThisSalePrice).reduce(BigDecimal::add).get()); |
| | | orderMeals.add(orderSaleExportExcel); |
| | | } |
| | | Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), TOrderSaleAndGoodsExportExcel.class, orderMeals); |
| | | HttpServletResponse response = WebUtils.response(); |
| | |
| | | BeanUtils.copyProperties(orderStockVO, orderStockExportExcel); |
| | | orderStockExportExcel.setGoodsAmount(orderStockVO.getOrderStockGoods().stream().map(TOrderStockGoods::getSalePrice).reduce(BigDecimal::add).get()); |
| | | orderStockExportExcel.setStockTime(DateUtils.localDateToString(orderStockVO.getStockTime())); |
| | | orderStockExportExcels.add(orderStockExportExcel); |
| | | } |
| | | Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), TOrderStockExportExcel.class, orderStockExportExcels); |
| | | HttpServletResponse response = WebUtils.response(); |
| | |
| | | import org.apache.poi.ss.usermodel.Workbook; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.util.CollectionUtils; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.ServletOutputStream; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.IOException; |
| | | import java.math.BigDecimal; |
| | | import java.net.URLEncoder; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | BeanUtils.copyProperties(orderMeal, orderMealVO); |
| | | List<TOrderMealGoods> list = orderMealGoodsService.list(Wrappers.lambdaQuery(TOrderMealGoods.class) |
| | | .eq(TOrderMealGoods::getOrderId, orderMeal.getId())); |
| | | if(!CollectionUtils.isEmpty(list)){ |
| | | Map<String, List<TOrderMealGoods>> map = list.stream().collect(Collectors.groupingBy(TOrderMealGoods::getTypeName)); |
| | | List<String> goodsList = new ArrayList<>(); |
| | | map.forEach((k,v)->{ |
| | | goodsList.add(k+":"+v.stream().map(item->item.getGoodsName()+" "+(item.getGoodsSalePrice().multiply(new BigDecimal(item.getGoodsCount())))).collect(Collectors.joining(","))); |
| | | }); |
| | | orderMealVO.setGoodsList(goodsList); |
| | | } |
| | | orderMealVO.setOrderMealGoods(list); |
| | | return AjaxResult.success(orderMealVO); |
| | | } |
| | |
| | | import java.net.URLEncoder; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | @GetMapping(value = "/getDetailById") |
| | | public AjaxResult<TOrderSaleVO> getDetailById(@RequestParam(value = "id") Long id) { |
| | | TOrderSale orderSale = orderSaleService.getById(id); |
| | | if(Objects.isNull(orderSale)){ |
| | | return AjaxResult.error("未查询到销售单"); |
| | | } |
| | | TOrderSaleVO orderSaleVO = new TOrderSaleVO(); |
| | | BeanUtils.copyProperties(orderSale, orderSaleVO); |
| | | List<TOrderSaleGoods> list = orderSaleGoodsService.list(Wrappers.lambdaQuery(TOrderSaleGoods.class) |
| | |
| | | @ApiModelProperty(value = "类型id") |
| | | @TableField("typeId") |
| | | private Long typeId; |
| | | @ApiModelProperty(value = "商品id") |
| | | @TableField("goodsId") |
| | | private Long goodsId; |
| | | |
| | | |
| | | } |
| | |
| | | @ApiModelProperty(value = "类型id") |
| | | @TableField("typeId") |
| | | private Long typeId; |
| | | |
| | | @ApiModelProperty(value = "商品id") |
| | | @TableField("goodsId") |
| | | private Long goodsId; |
| | | } |
| | |
| | | @Excel(name = "商品数量",width = 15) |
| | | @TableField("stockCount") |
| | | private Integer stockCount; |
| | | |
| | | @ApiModelProperty(value = "商品id") |
| | | @TableField("goodsId") |
| | | private Long goodsId; |
| | | } |
| | |
| | | @ApiModel(value = "销售订单DTO") |
| | | public class TOrderSaleDTO extends TOrderSale { |
| | | |
| | | @ApiModelProperty(value = "销售订单商品") |
| | | private List<TOrderSaleGoods> orderSaleGoods; |
| | | |
| | | } |
| | |
| | | @ApiModel(value = "进货订单DTO") |
| | | public class TOrderStockDTO extends TOrderStock { |
| | | |
| | | @ApiModelProperty(value = "进货订单商品") |
| | | private List<TOrderStockGoods> orderStockGoods; |
| | | |
| | | } |
| | |
| | | tOrderMealGoods.setGoodsSalePrice(typeGood.getSalePrice()); |
| | | tOrderMealGoods.setGoodsCount(1); |
| | | tOrderMealGoods.setTypeId(typeGood.getTypeId()); |
| | | tOrderMealGoods.setGoodsId(typeGood.getId()); |
| | | orderMealGoods.add(tOrderMealGoods); |
| | | } |
| | | } |
| | |
| | | tOrderStockGoods.setSalePrice(v.get(0).getGoodsSalePrice()); |
| | | tOrderStockGoods.setThisSalePrice(v.get(0).getThisSalePrice()); |
| | | tOrderStockGoods.setGoodsPicture(v.get(0).getGoodsPicture()); |
| | | tOrderStockGoods.setGoodsId(v.get(0).getGoodsId()); |
| | | tOrderStockGoods.setStockCount(v.stream().mapToInt(TOrderSaleGoods::getGoodsCount).sum()); |
| | | orderStockGoods.add(tOrderStockGoods); |
| | | }); |
| | |
| | | tOrderStockGoods.setSalePrice(v.get(0).getGoodsSalePrice()); |
| | | tOrderStockGoods.setThisSalePrice(v.get(0).getThisSalePrice()); |
| | | tOrderStockGoods.setGoodsPicture(v.get(0).getGoodsPicture()); |
| | | tOrderStockGoods.setGoodsId(v.get(0).getGoodsId()); |
| | | tOrderStockGoods.setStockCount(v.stream().mapToInt(TOrderSaleGoods::getGoodsCount).sum()); |
| | | orderStockGoods.add(tOrderStockGoods); |
| | | }); |
| | |
| | | tOrderStockGoods.setSalePrice(v.get(0).getGoodsSalePrice()); |
| | | tOrderStockGoods.setThisSalePrice(v.get(0).getThisSalePrice()); |
| | | tOrderStockGoods.setGoodsPicture(v.get(0).getGoodsPicture()); |
| | | tOrderStockGoods.setGoodsId(v.get(0).getGoodsId()); |
| | | tOrderStockGoods.setStockCount(v.stream().mapToInt(TOrderSaleGoods::getGoodsCount).sum()); |
| | | orderStockGoods1.add(tOrderStockGoods); |
| | | }); |
| | |
| | | tOrderStockGoods.setSalePrice(v.get(0).getGoodsSalePrice()); |
| | | tOrderStockGoods.setThisSalePrice(v.get(0).getThisSalePrice()); |
| | | tOrderStockGoods.setGoodsPicture(v.get(0).getGoodsPicture()); |
| | | tOrderStockGoods.setGoodsId(v.get(0).getGoodsId()); |
| | | tOrderStockGoods.setStockCount(v.stream().mapToInt(TOrderSaleGoods::getGoodsCount).sum()); |
| | | orderStockGoods.add(tOrderStockGoods); |
| | | }); |
| | |
| | | List<TOrderMeal> orderMeals = orderMealService.list(Wrappers.lambdaQuery(TOrderMeal.class) |
| | | .in(TOrderMeal::getGeneratorId, ids)); |
| | | List<Long> mealIds = orderMeals.stream().map(TOrderMeal::getId).collect(Collectors.toList()); |
| | | if(!CollectionUtils.isEmpty(mealIds)){ |
| | | List<TOrderMealGoods> mealGoods = orderMealGoodsService.list(Wrappers.lambdaQuery(TOrderMealGoods.class) |
| | | .in(TOrderMealGoods::getOrderId, mealIds)); |
| | | for (TDataGeneratorVO tDataGeneratorVO : list) { |
| | |
| | | BigDecimal money = mealGoods.stream().filter(e -> collect.contains(e.getOrderId())) |
| | | .reduce(BigDecimal.ZERO, (x, y) -> x.add(y.getGoodsSalePrice().multiply(new BigDecimal(y.getGoodsCount()))), BigDecimal::add); |
| | | tDataGeneratorVO.setTotalRevenue(money); |
| | | } |
| | | } |
| | | }else { |
| | | List<TOrderSale> orderSales = orderSaleService.list(Wrappers.lambdaQuery(TOrderSale.class) |
| | |
| | | // List<Long> collect = orderSales.stream().filter(e -> e.getGeneratorId().equals(tDataGeneratorVO.getId())).map(TOrderSale::getId).collect(Collectors.toList()); |
| | | // BigDecimal money = orderSaleGoods.stream().filter(e -> collect.contains(e.getOrderId())) |
| | | // .reduce(BigDecimal.ZERO, (x, y) -> x.add(y.getGoodsCostPrice().multiply(new BigDecimal(y.getGoodsCount()))), BigDecimal::add); |
| | | if(!CollectionUtils.isEmpty(orderSales)){ |
| | | BigDecimal money = orderSales.stream().map(TOrderSale::getPayMoney).reduce(BigDecimal::add).get(); |
| | | tDataGeneratorVO.setTotalRevenue(money); |
| | | } |
| | | } |
| | | } |
| | | pageInfo.setRecords(list); |
| | | return pageInfo; |
| | | } |
| | |
| | | orderMealGood.setGoodsCount(item.getGoodsCount()); |
| | | orderMealGood.setGoodsSalePrice(item1.getSalePrice().multiply(new BigDecimal(item.getGoodsCount()))); |
| | | orderMealGood.setCostPrice(item1.getCostPrice().multiply(new BigDecimal(item.getGoodsCount()))); |
| | | // orderMealGood.setTypeId(item1.getTypeId()); |
| | | orderMealGood.setTypeId(item1.getTypeId()); |
| | | orderMealGood.setGoodsId(item1.getId()); |
| | | orderMealGood.setTypeName(list1.stream().filter(item2 -> item2.getId().equals(item1.getTypeId())).findFirst().get().getTypeName()); |
| | | orderMealGoods.add(orderMealGood); |
| | | }); |
| | |
| | | orderMealGood.setGoodsPicture(item1.getGoodsPicture()); |
| | | orderMealGood.setGoodsCount(item.getGoodsCount()); |
| | | orderMealGood.setGoodsSalePrice(item1.getGoodsSalePrice().multiply(new BigDecimal(item.getGoodsCount()))); |
| | | // orderMealGood.setTypeId(item1.getTypeId()); |
| | | orderMealGood.setTypeId(item1.getTypeId()); |
| | | orderMealGood.setGoodsId(item1.getId()); |
| | | orderMealGood.setTypeName(list1.stream().filter(item2 -> item2.getId().equals(item1.getTypeId())).findFirst().get().getTypeName()); |
| | | orderMealGoods.add(orderMealGood); |
| | | }); |
| | |
| | | List<TOrderMealGoods> list1 = orderMealGoodsService.list(Wrappers.lambdaQuery(TOrderMealGoods.class) |
| | | .eq(TOrderMealGoods::getOrderId, tOrderMealVO.getId())); |
| | | tOrderMealVO.setOrderMealGoods(list1); |
| | | if(!CollectionUtils.isEmpty(list1)){ |
| | | Map<String, List<TOrderMealGoods>> map = list1.stream().collect(Collectors.groupingBy(TOrderMealGoods::getTypeName)); |
| | | List<String> goodsList = new ArrayList<>(); |
| | | map.forEach((k,v)->{ |
| | |
| | | }); |
| | | tOrderMealVO.setGoodsList(goodsList); |
| | | } |
| | | } |
| | | pageInfo.setRecords(list); |
| | | return pageInfo; |
| | | } |
| | |
| | | import com.ruoyi.system.query.TDataStatisticsQuery; |
| | | import com.ruoyi.system.query.TOrderMealQuery; |
| | | import com.ruoyi.system.query.TOrderSaleQuery; |
| | | import com.ruoyi.system.service.TGoodsService; |
| | | import com.ruoyi.system.service.TGoodsTypeService; |
| | | import com.ruoyi.system.service.TOrderSaleGoodsService; |
| | | import com.ruoyi.system.service.TOrderSaleService; |
| | |
| | | private TOrderSaleGoodsService orderSaleGoodsService; |
| | | @Autowired |
| | | private TGoodsTypeService goodsTypeService; |
| | | @Autowired |
| | | private TGoodsService goodsService; |
| | | @Override |
| | | public void add(TOrderSaleDTO dto) { |
| | | // 查询菜品分类 |
| | |
| | | <result column="typeName" property="typeName" /> |
| | | <result column="costPrice" property="costPrice" /> |
| | | <result column="typeId" property="typeId" /> |
| | | <result column="goodsId" property="goodsId" /> |
| | | </resultMap> |
| | | |
| | | <!-- 通用查询结果列 --> |
| | | <sql id="Base_Column_List"> |
| | | id, goodsNum, goodsName, goodsSalePrice, goodsPicture, goodsCount, orderId,typeName,costPrice,typeId |
| | | id, goodsNum, goodsName, goodsSalePrice, goodsPicture, goodsCount, orderId,typeName,costPrice,typeId,goodsId |
| | | </sql> |
| | | <select id="costTotal" resultType="java.math.BigDecimal"> |
| | | select sum(costPrice) from t_order_meal_goods |
| | |
| | | <result column="thisSalePrice" property="thisSalePrice" /> |
| | | <result column="goodsPicture" property="goodsPicture" /> |
| | | <result column="typeId" property="typeId" /> |
| | | <result column="goodsId" property="goodsId" /> |
| | | </resultMap> |
| | | |
| | | <!-- 通用查询结果列 --> |
| | | <sql id="Base_Column_List"> |
| | | id, orderId, goodsNum, goodsName, goodsCostPrice, goodsSalePrice, goodsCount, thisSalePrice, goodsPicture,typeId |
| | | id, orderId, goodsNum, goodsName, goodsCostPrice, goodsSalePrice, goodsCount, thisSalePrice, goodsPicture,typeId,goodsId |
| | | </sql> |
| | | <select id="costTotal" resultType="java.math.BigDecimal"> |
| | | select sum(goodsCostPrice) from t_order_meal_goods |
| | |
| | | <result column="goodsPicture" property="goodsPicture" /> |
| | | <result column="stockCount" property="stockCount" /> |
| | | <result column="thisSalePrice" property="thisSalePrice" /> |
| | | <result column="goodsId" property="goodsId" /> |
| | | </resultMap> |
| | | |
| | | <!-- 通用查询结果列 --> |
| | | <sql id="Base_Column_List"> |
| | | id, orderId, goodsNum, goodsName, costPrice, salePrice, goodsPicture, stockCount,thisSalePrice |
| | | id, orderId, goodsNum, goodsName, costPrice, salePrice, goodsPicture, stockCount,thisSalePrice,goodsId |
| | | </sql> |
| | | |
| | | </mapper> |