有什么手机做网站的,2018年网站建设发言,福建省建设执业注册中心网站,网站开发需要英语销量排名Top10
需求分析和设计
产品原型
所谓销量排名#xff0c;销量指的是商品销售的数量。项目当中的商品主要包含两类#xff1a;一个是套餐#xff0c;一个是菜品#xff0c;所以销量排名其实指的就是菜品和套餐销售的数量排名。通过柱形图来展示销量排名#xff…销量排名Top10
需求分析和设计
产品原型
所谓销量排名销量指的是商品销售的数量。项目当中的商品主要包含两类一个是套餐一个是菜品所以销量排名其实指的就是菜品和套餐销售的数量排名。通过柱形图来展示销量排名这些销量是按照降序来排列并且只需要统计销量排名前十的商品。
业务规则
根据时间选择区间展示销量前10的商品包括菜品和套餐基于可视化报表的柱状图降序展示商品销量此处的销量为商品销售的份数
代码开发
VO设计
根据销量排名接口的返回结果设计VO 在sky-pojo模块SalesTop10ReportVO.java已定义
package com.sky.vo;import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;Data
Builder
NoArgsConstructor
AllArgsConstructor
public class SalesTop10ReportVO implements Serializable {//商品名称列表以逗号分隔例如鱼香肉丝,宫保鸡丁,水煮鱼private String nameList;//销量列表以逗号分隔例如260,215,200private String numberList;}Controller层
在ReportController中根据销量排名接口创建top10方法
/**
* 销量排名统计
* param begin
* param end
* return
*/
GetMapping(/top10)
ApiOperation(销量排名统计)
public ResultSalesTop10ReportVO top10(DateTimeFormat(pattern yyyy-MM-dd) LocalDate begin,DateTimeFormat(pattern yyyy-MM-dd) LocalDate end){return Result.success(reportService.getSalesTop10(begin,end));
}Service层接口
在ReportService接口中声明getSalesTop10方法
/**
* 查询指定时间区间内的销量排名top10
* param begin
* param end
* return
*/
SalesTop10ReportVO getSalesTop10(LocalDate begin, LocalDate end);Service层实现类
在ReportServiceImpl实现类中实现getSalesTop10方法
/*** 查询指定时间区间内的销量排名top10* param begin* param end* return* */public SalesTop10ReportVO getSalesTop10(LocalDate begin, LocalDate end){LocalDateTime beginTime LocalDateTime.of(begin, LocalTime.MIN);LocalDateTime endTime LocalDateTime.of(end, LocalTime.MAX);ListGoodsSalesDTO goodsSalesDTOList orderMapper.getSalesTop10(beginTime, endTime);String nameList StringUtils.join(goodsSalesDTOList.stream().map(GoodsSalesDTO::getName).collect(Collectors.toList()),,);String numberList StringUtils.join(goodsSalesDTOList.stream().map(GoodsSalesDTO::getNumber).collect(Collectors.toList()),,);return SalesTop10ReportVO.builder().nameList(nameList).numberList(numberList).build();}Mapper层
在OrderMapper接口中声明getSalesTop10方法
/**
* 查询商品销量排名
* param begin
* param end
*/
ListGoodsSalesDTO getSalesTop10(LocalDateTime begin, LocalDateTime end);在OrderMapper.xml文件中编写动态SQL
select idgetSalesTop10 resultTypecom.sky.dto.GoodsSalesDTOselect od.name name,sum(od.number) number from order_detail od ,orders owhere od.order_id o.idand o.status 5if testbegin ! nulland order_time gt; #{begin}/ifif testend ! nulland order_time lt; #{end}/ifgroup by nameorder by number desclimit 0, 10
/select