当前位置: 首页 > wzjs >正文

温州市手机网站制作哪家好做网站还是app省钱

温州市手机网站制作哪家好,做网站还是app省钱,包装袋设计网站推荐,龙岩解除高风险区数据统计 Apache ECharts是一款基于JavaScript的数据可视化图表库,提供直观,生动,可交互,可个性定制的数据可视化图表。 入门案例 引入js文件(已提供) 为 ECharts 准备一个设置宽高的 DOM 初始化echart…

数据统计

Apache ECharts是一款基于JavaScript的数据可视化图表库,提供直观,生动,可交互,可个性定制的数据可视化图表。

入门案例

引入js文件(已提供)

为 ECharts 准备一个设置宽高的 DOM

初始化echarts实例

指定图表的配置项和数据

使用指定的配置项和数据显示图表

代码

<!DOCTYPE html>
<html><head><meta charset="utf-8" /><title>ECharts</title><!-- 引入刚刚下载的 ECharts 文件 --><script src="echarts.js"></script></head><body><!-- 为 ECharts 准备一个定义了宽高的 DOM --><div id="main" style="width: 600px;height:400px;"></div><script type="text/javascript">// 基于准备好的dom,初始化echarts实例var myChart = echarts.init(document.getElementById('main'));// 指定图表的配置项和数据var option = {title: {text: 'ECharts 入门示例'},tooltip: {},legend: {data: ['销量']},xAxis: {data: ['衬衫', '羊毛衫', '雪纺衫', '裤子', '高跟鞋', '袜子']},yAxis: {},series: [{name: '销量',type: 'bar',data: [5, 20, 36, 10, 10, 20]}]};// 使用刚指定的配置项和数据显示图表。myChart.setOption(option);</script></body>
</html>

营业额统计:

业务规则:

  • 营业额指订单状态为已完成的订单金额合计
  • 基于可视化报表的折线图展示营业额数据,X轴为日期,Y轴为营业额
  • 根据时间选择区间,展示每天的营业额数据

接口设计:

前端需要什么格式的数据,后端去适应前端返回该格式的数据

vo已定义

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 TurnoverReportVO implements Serializable {//日期,以逗号分隔,例如:2022-10-01,2022-10-02,2022-10-03private String dateList;//营业额,以逗号分隔,例如:406.0,1520.0,75.0private String turnoverList;}
Controller层
package com.sky.controller.admin;import com.sky.result.Result;
import com.sky.service.ReportService;
import com.sky.vo.TurnoverReportVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.time.LocalDate;/*** 报表*/
@RestController
@RequestMapping("/admin/report")
@Slf4j
@Api(tags = "统计报表相关接口")
public class ReportController {@Autowiredprivate ReportService reportService;/*** 营业额数据统计** @param begin* @param end* @return*/@GetMapping("/turnoverStatistics")@ApiOperation("营业额数据统计")public Result<TurnoverReportVO> turnoverStatistics(@DateTimeFormat(pattern = "yyyy-MM-dd")LocalDate begin,@DateTimeFormat(pattern = "yyyy-MM-dd")LocalDate end) {return Result.success(reportService.getTurnover(begin, end));}}
 Service层接口
package com.sky.service;import com.sky.vo.TurnoverReportVO;
import java.time.LocalDate;public interface ReportService {/*** 根据时间区间统计营业额* @param beginTime* @param endTime* @return*/TurnoverReportVO getTurnover(LocalDate beginTime, LocalDate endTime);
}
service层实现类
package com.sky.service.impl;import com.sky.entity.Orders;
import com.sky.mapper.OrderMapper;
import com.sky.service.ReportService;
import com.sky.vo.TurnoverReportVO;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;@Service
@Slf4j
public class ReportServiceImpl implements ReportService {@Autowiredprivate OrderMapper orderMapper;/*** 根据时间区间统计营业额* @param begin* @param end* @return*/public TurnoverReportVO getTurnover(LocalDate begin, LocalDate end) {List<LocalDate> dateList = new ArrayList<>();dateList.add(begin);while (!begin.equals(end)){begin = begin.plusDays(1);//日期计算,获得指定日期后1天的日期dateList.add(begin);}List<Double> turnoverList = new ArrayList<>();for (LocalDate date : dateList) {LocalDateTime beginTime = LocalDateTime.of(date, LocalTime.MIN);LocalDateTime endTime = LocalDateTime.of(date, LocalTime.MAX);Map map = new HashMap();map.put("status", Orders.COMPLETED);map.put("begin",beginTime);map.put("end", endTime);Double turnover = orderMapper.sumByMap(map); turnover = turnover == null ? 0.0 : turnover;turnoverList.add(turnover);}//数据封装return TurnoverReportVO.builder().dateList(StringUtils.join(dateList,",")).turnoverList(StringUtils.join(turnoverList,",")).build();}
}
 Mapper层
	/*** 根据动态条件统计营业额* @param map*/Double sumByMap(Map map);

Mapper.xml

<select id="sumByMap" resultType="java.lang.Double">select sum(amount) from orders<where><if test="status != null">and status = #{status}</if><if test="begin != null">and order_time &gt;= #{begin}</if><if test="end != null">and order_time &lt;= #{end}</if></where>
</select>

用户统计

Controller层
/*** 用户数据统计* @param begin* @param end* @return*/@GetMapping("/userStatistics")@ApiOperation("用户数据统计")public Result<UserReportVO> userStatistics(@DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate begin,@DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate end){return Result.success(reportService.getUserStatistics(begin,end));            
}
Service层接口
	/*** 根据时间区间统计用户数量* @param begin* @param end* @return*/UserReportVO getUserStatistics(LocalDate begin, LocalDate end);
 Service层实现类

在ReportServiceImpl实现类中实现getUserStatistics方法:

	@Overridepublic UserReportVO getUserStatistics(LocalDate begin, LocalDate end) {List<LocalDate> dateList = new ArrayList<>();dateList.add(begin);while (!begin.equals(end)){begin = begin.plusDays(1);dateList.add(begin);}List<Integer> newUserList = new ArrayList<>(); //新增用户数List<Integer> totalUserList = new ArrayList<>(); //总用户数for (LocalDate date : dateList) {LocalDateTime beginTime = LocalDateTime.of(date, LocalTime.MIN);LocalDateTime endTime = LocalDateTime.of(date, LocalTime.MAX);//新增用户数量 select count(id) from user where create_time > ? and create_time < ?Integer newUser = getUserCount(beginTime, endTime);//总用户数量 select count(id) from user where  create_time < ?Integer totalUser = getUserCount(null, endTime);newUserList.add(newUser);totalUserList.add(totalUser);}return UserReportVO.builder().dateList(StringUtils.join(dateList,",")).newUserList(StringUtils.join(newUserList,",")).totalUserList(StringUtils.join(totalUserList,",")).build();}

在ReportServiceImpl实现类中创建私有方法getUserCount:

	/*** 根据时间区间统计用户数量* @param beginTime* @param endTime* @return*/private Integer getUserCount(LocalDateTime beginTime, LocalDateTime endTime) {Map map = new HashMap();map.put("begin",beginTime);map.put("end", endTime);return userMapper.countByMap(map);}
 Mapper层
	/*** 根据动态条件统计用户数量* @param map* @return*/Integer countByMap(Map map);

Mapper.xml

<select id="countByMap" resultType="java.lang.Integer">select count(id) from user<where><if test="begin != null">and create_time &gt;= #{begin}</if><if test="end != null">and create_time &lt;= #{end}</if></where>
</select>

订单统计

业务规则:

  • 有效订单指状态为 “已完成” 的订单
  • 基于可视化报表的折线图展示订单数据,X轴为日期,Y轴为订单数量
  • 根据时间选择区间,展示每天的订单总数和有效订单数
  • 展示所选时间区间内的有效订单数、总订单数、订单完成率,订单完成率 = 有效订单数 / 总订单数 * 100%
Controller层
/*** 订单数据统计* @param begin* @param end* @return*/@GetMapping("/ordersStatistics")@ApiOperation("用户数据统计")public Result<OrderReportVO> orderStatistics(@DateTimeFormat(pattern = "yyyy-MM-dd")LocalDate begin,@DateTimeFormat(pattern = "yyyy-MM-dd")LocalDate end){return Result.success(reportService.getOrderStatistics(begin,end));}
 Service层接口
/**
* 根据时间区间统计订单数量
* @param begin 
* @param end
* @return 
*/
OrderReportVO getOrderStatistics(LocalDate begin, LocalDate end);
 Service层实现类

在ReportServiceImpl实现类中实现getOrderStatistics方法:

/**
* 根据时间区间统计订单数量
* @param begin 
* @param end
* @return 
*/
public OrderReportVO getOrderStatistics(LocalDate begin, LocalDate end){List<LocalDate> dateList = new ArrayList<>();dateList.add(begin);while (!begin.equals(end)){begin = begin.plusDays(1);dateList.add(begin);}//每天订单总数集合List<Integer> orderCountList = new ArrayList<>();//每天有效订单数集合List<Integer> validOrderCountList = new ArrayList<>();for (LocalDate date : dateList) {LocalDateTime beginTime = LocalDateTime.of(date, LocalTime.MIN);LocalDateTime endTime = LocalDateTime.of(date, LocalTime.MAX);//查询每天的总订单数 select count(id) from orders where order_time > ? and order_time < ?Integer orderCount = getOrderCount(beginTime, endTime, null);//查询每天的有效订单数 select count(id) from orders where order_time > ? and order_time < ? and status = ?Integer validOrderCount = getOrderCount(beginTime, endTime, Orders.COMPLETED);orderCountList.add(orderCount);validOrderCountList.add(validOrderCount);}//时间区间内的总订单数Integer totalOrderCount = orderCountList.stream().reduce(Integer::sum).get();//时间区间内的总有效订单数Integer validOrderCount = validOrderCountList.stream().reduce(Integer::sum).get();//订单完成率Double orderCompletionRate = 0.0;if(totalOrderCount != 0){orderCompletionRate = validOrderCount.doubleValue() / totalOrderCount;}return OrderReportVO.builder().dateList(StringUtils.join(dateList, ",")).orderCountList(StringUtils.join(orderCountList, ",")).validOrderCountList(StringUtils.join(validOrderCountList, ",")).totalOrderCount(totalOrderCount).validOrderCount(validOrderCount).orderCompletionRate(orderCompletionRate).build();}

在ReportServiceImpl实现类中提供私有方法getOrderCount:

/**
* 根据时间区间统计指定状态的订单数量
* @param beginTime
* @param endTime
* @param status
* @return
*/
private Integer getOrderCount(LocalDateTime beginTime, LocalDateTime endTime, Integer status) {Map map = new HashMap();map.put("status", status);map.put("begin",beginTime);map.put("end", endTime);return orderMapper.countByMap(map);
}
Mapper层
/**
*根据动态条件统计订单数量
* @param map
*/
Integer countByMap(Map map);

Mapper.xml

<select id="countByMap" resultType="java.lang.Integer">select count(id) from orders<where><if test="status != null">and status = #{status}</if><if test="begin != null">and order_time &gt;= #{begin}</if><if test="end != null">and order_time &lt;= #{end}</if></where>
</select>

销量排名Top10

业务规则:

  • 根据时间选择区间,展示销量前10的商品(包括菜品和套餐)
  • 基于可视化报表的柱状图降序展示商品销量
  • 此处的销量为商品销售的份数
Controller层
/**
* 销量排名统计
* @param begin
* @param end
* @return
*/
@GetMapping("/top10")
@ApiOperation("销量排名统计")
public Result<SalesTop10ReportVO> top10(@DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate begin,@DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate end){return Result.success(reportService.getSalesTop10(begin,end));
}
Service层接口
/**
* 查询指定时间区间内的销量排名top10 
* @param begin
* @param end
* @return
*/
SalesTop10ReportVO getSalesTop10(LocalDate begin, LocalDate end);
Service层实现类
/*** 查询指定时间区间内的销量排名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);List<GoodsSalesDTO> 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层
/**
* 查询商品销量排名
* @param begin
* @param end	
*/
List<GoodsSalesDTO> getSalesTop10(LocalDateTime begin, LocalDateTime end);

Mapper.xml

<select id="getSalesTop10" resultType="com.sky.dto.GoodsSalesDTO">select od.name name,sum(od.number) number from order_detail od ,orders owhere od.order_id = o.idand o.status = 5<if test="begin != null">and order_time &gt;= #{begin}</if><if test="end != null">and order_time &lt;= #{end}</if>group by nameorder by number desclimit 0, 10
</select>


文章转载自:

http://WysULroZ.gcxfh.cn
http://M2pmTDwX.gcxfh.cn
http://fcR6fOpo.gcxfh.cn
http://47EiKdKS.gcxfh.cn
http://JhgpPWh7.gcxfh.cn
http://qYAVJN7C.gcxfh.cn
http://YX33jPzi.gcxfh.cn
http://Yu2ztu65.gcxfh.cn
http://ljaMzCKb.gcxfh.cn
http://QlvANk5n.gcxfh.cn
http://4Pip4fdV.gcxfh.cn
http://saB0mM2A.gcxfh.cn
http://V4HmPHCu.gcxfh.cn
http://4gXbgQYs.gcxfh.cn
http://2N64xbgk.gcxfh.cn
http://7N7NrHfE.gcxfh.cn
http://x43Is5uc.gcxfh.cn
http://3BKhnZxv.gcxfh.cn
http://QKa1NfRB.gcxfh.cn
http://d9xFtb3Y.gcxfh.cn
http://Ri9YvECY.gcxfh.cn
http://WE5LBZvz.gcxfh.cn
http://n74IPMOP.gcxfh.cn
http://6GXZ5Sy6.gcxfh.cn
http://4liB8SyJ.gcxfh.cn
http://R9ETcUIR.gcxfh.cn
http://lqoSnNlg.gcxfh.cn
http://zaouX8Og.gcxfh.cn
http://N5rh0d2q.gcxfh.cn
http://enItPaa6.gcxfh.cn
http://www.dtcms.com/wzjs/716207.html

相关文章:

  • 商城网站建设哪家公司好wordpress 模板 教程
  • 网站建站平台 开源世界足球排名前100名
  • 国外有没有网站是做潘多拉的wordpress 弹窗登陆
  • 网站运营托管方案设计网址有哪些
  • 如何给网站做优化代码微网站建设找哪家公司
  • 福建住房与城乡建设厅网站网站开发专业就业好不好
  • 网站建设最好公司浅笑云主机
  • 单机怎么做网站设计师分六个级别
  • 北京哪个网站建设最好上海网页制作模板
  • 黄冈网站推广都有哪些渠道做门名片设计网站
  • 网站设计需求方案山东网站建设服务
  • 网站设计思路方案百度免费推广有哪些方式
  • 兼职招聘网站警惕网站免费看手机
  • 招商网站建设大概多少钱荥阳做网站推广
  • 北京装修公司排名推荐北京seo多少钱
  • 从网络安全角度考量_写出建设一个大型电影网站规划方案阿里云域名查询系统
  • 网站服务器返回状态码404西安公司排行榜
  • 网站怎么做站群福州网站推广排名
  • 做相册的网站有哪些做写字楼的网站有哪些
  • 网站更新内容做公众号首图的网站
  • 网站建设黄荣网站建设标准简约
  • 合肥网站建设制作价格小程序怎么开发
  • 四川省住房城乡建设厅网站首页企业网站的cms
  • 网站上传文件 ftp江阴招聘网站建设学徒
  • 分分彩做号网站佛山建企业网站
  • 做时间轴的在线网站如何做局域网网站建设
  • 借贷网站建设方案福建省建设局网站实名制
  • 网站开发电脑内存要多少有了源码然后如何做网站
  • 做门户网站需要准备什么店铺推广策略
  • 免费申请com网站营销推广的平台