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

项目-苍穹外卖(十五) Apache ECharts+数据统计

一、介绍

二、营业额统计

需求分析和设计:

Controller:

Service:

/*** 营业额统计* @param begindate* @param enddate* @return* */@Overridepublic TurnoverReportVO turnoverStatistics(LocalDate begindate, LocalDate enddate) {//创建时间集合List<LocalDate> datelist=new ArrayList<>();//加入起始时间datelist.add(begindate);//循环,直到将起始时间->结束时间期间的每一天都加入到集合中while(!begindate.equals(enddate)){begindate = begindate.plusDays(1);datelist.add(begindate);}//集合元素按照 a,b格式转化成字符串String dateList = StringUtils.join(datelist, ",");List<Double> turnoverList =new ArrayList<>();for (LocalDate localDate : datelist) {//根据日期查询营业额 (状态为已完成的订单的综合)LocalDateTime begin = LocalDateTime.of(localDate, LocalTime.MIN);//LocalTime.MIN 0点 0分 0秒LocalDateTime end = LocalDateTime.of(localDate, LocalTime.MAX);//LocalTime.MAX 59:59:5999Map map=new HashMap();map.put("begin",begin);map.put("end",end);map.put("status", Orders.COMPLETED);Double turnover =orderMapper.sumByMap(map);//当天没有营业额则置零turnover =  turnover==null?0.0:turnover;turnoverList.add(turnover);}//集合元素按照 a,b格式转化成字符串String turnoverlist = StringUtils.join(turnoverList, ",");return TurnoverReportVO.builder().turnoverList(turnoverlist).dateList(dateList).build();}

Mapper:

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

三、用户统计

需求分析和设计:

Controller:

    /*** 用户统计* @param begin* @param end* @return* */@ApiOperation("用户统计")@GetMapping("/userStatistics")public Result<UserReportVO> getUserStatistics(@DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate begin,@DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate end){log.info("用户统计:{},{}",begin,end);return Result.success(reportService.userStatistics(begin,end));}

Service: 

    /*** 用户统计* @param begin* @param end* @return* */@Overridepublic UserReportVO userStatistics(LocalDate begin, LocalDate end) {List<LocalDate> datelist=new ArrayList<>();datelist.add(begin);while(!begin.equals(end)){//日期计算,循环到enddate为止begin = begin.plusDays(1);datelist.add(begin);}//集合元素按照 a,b格式转化成字符串String dateList = StringUtils.join(datelist, ",");List<Double> newuserlist=new ArrayList<>();for (LocalDate localDate : datelist) {//根据日期查询新增用户 (状态为已完成的订单的综合)LocalDateTime begindate = LocalDateTime.of(localDate, LocalTime.MIN);//LocalTime.MIN 0点 0分 0秒LocalDateTime enddate = LocalDateTime.of(localDate, LocalTime.MAX);//LocalTime.MAX 59:59:5999Map map=new HashMap();map.put("begin",begindate);map.put("end",enddate);Double usercount= orderMapper.sumuserByMap(map);usercount= usercount==null?0:usercount;newuserlist.add(usercount);}String newuser = StringUtils.join(newuserlist, ",");List<Double> totalueserlist=new ArrayList<>();for (LocalDate localDate : datelist) {//根据日期查询总用户LocalDateTime enddate = LocalDateTime.of(localDate, LocalTime.MAX);//LocalTime.MAX 59:59:5999Map map=new HashMap();map.put("end",enddate);Double totalusercount= orderMapper.sumuserByMap(map);totalusercount= totalusercount==null?0:totalusercount;totalueserlist.add(totalusercount);}String totaluser = StringUtils.join(totalueserlist, ",");return UserReportVO.builder().newUserList(newuser).totalUserList(totaluser).dateList(dateList).build();}

Mapper:

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

四、订单统计 

需求分析和设计:

Controller:

/*** 订单统计* @param begin* @param end* @return* */@ApiOperation("订单统计")@GetMapping("/ordersStatistics")public Result<OrderReportVO> ordersStatistics(@DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate begin,@DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate end){log.info("订单统计:{},{}",begin,end);return Result.success(reportService.ordersStatistics(begin,end));}

Service:

  /*** 订单统计* @param begin* @param end* @return* */@Overridepublic OrderReportVO ordersStatistics(LocalDate begin, LocalDate end) {List<LocalDate> datelist=new ArrayList<>();datelist.add(begin);while(!begin.equals(end)){//日期计算,循环到enddate为止begin = begin.plusDays(1);datelist.add(begin);}//集合元素按照 a,b格式转化成字符串String dateList = StringUtils.join(datelist, ",");//每日订单数List<Double> orderslist =new ArrayList<>();for (LocalDate localDate : datelist) {LocalDateTime begindate = LocalDateTime.of(localDate, LocalTime.MIN);LocalDateTime enddate = LocalDateTime.of(localDate, LocalTime.MAX);Map map=new HashMap();map.put("begin",begindate);map.put("end",enddate);//每日订单数量Double ordercount = orderMapper.sumorderByMap(map);orderslist.add(ordercount);}//集合元素按照 a,b格式转化成字符串String orderCountList = StringUtils.join(orderslist, ",");//每日有效订单数List<Double> validorderslist =new ArrayList<>();for (LocalDate localDate : datelist) {LocalDateTime begindate = LocalDateTime.of(localDate, LocalTime.MIN);LocalDateTime enddate = LocalDateTime.of(localDate, LocalTime.MAX);Map map=new HashMap();map.put("begin",begindate);map.put("end",enddate);map.put("status",Orders.COMPLETED);//每日有效订单数量Double validordercount = orderMapper.sumorderByMap(map);validorderslist.add(validordercount);}//集合元素按照 a,b格式转化成字符串String validorderCountList = StringUtils.join(validorderslist, ",");//完成率Map map=new HashMap();map.put("end",LocalDateTime.now());Double total=orderMapper.sumorderByMap(map);int totalorder =total.intValue();Double valid=orderMapper.sumorderByMap(map);int validordercount=valid.intValue();Double orderCompletion=valid/total;return OrderReportVO.builder().orderCompletionRate(orderCompletion).orderCountList(orderCountList).validOrderCountList(validorderCountList).totalOrderCount(totalorder).validOrderCount(validordercount).dateList(dateList).build();}

Mapper:

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

五、销量排名

需求分析和设计:

Controller:

Service:

    /*** 查询销量top10* @param begin* @param end* @return* */@Overridepublic SalesTop10ReportVO getTop10(LocalDate begin, LocalDate end) {LocalDateTime begindate = LocalDateTime.of(begin, LocalTime.MIN);LocalDateTime enddate = LocalDateTime.of(end, LocalTime.MAX);//创建集合,将查询到的数据封装入对象存入集合List<GoodsSalesDTO> top10 = orderMapper.getTop10(begindate, enddate);//创建两个集合,将所需数据分别提取List<String> namelist=new ArrayList<>();List<Integer> numberList=new ArrayList<>();for (GoodsSalesDTO goodsSalesDTO : top10) {namelist.add(goodsSalesDTO.getName());numberList.add(goodsSalesDTO.getNumber());}String name = StringUtils.join(namelist, ",");String number = StringUtils.join(numberList, ",");return SalesTop10ReportVO.builder().nameList(name).numberList(number).build();}

Mapper:

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

相关文章:

项目-苍穹外卖(十五) Apache ECharts+数据统计

一、介绍 二、营业额统计 需求分析和设计&#xff1a; Controller: Service: /*** 营业额统计* param begindate* param enddate* return* */Overridepublic TurnoverReportVO turnoverStatistics(LocalDate begindate, LocalDate enddate) {//创建时间集合List<LocalDate&…...

Windows 10/11 使用 VSCode + SSH 免密远程连接 Ubuntu 服务器(指定端口)

摘要&#xff1a; 本文详细介绍如何在 Windows 系统上通过 VSCode Remote-SSH 免密登录远程 Ubuntu 服务器&#xff08;SSH 端口 2202&#xff09;&#xff0c;避免每次输入密码的繁琐操作&#xff0c;提高开发效率。 1. 环境准备 本地系统&#xff1a;Windows 10/11远程服务…...

【9】Strongswan collections —— enumerator

//以目录枚举为例子&#xff0c;说明enumerator&#xff0c;从源码剥离可运行 #include <stdio.h> #include <stdbool.h> #include <dirent.h> #include <errno.h> #include <string.h> #include <sys/types.h> #include <sys/stat.h&…...

大数据学习(88)-zookeeper实现的高可用(HA)

&#x1f34b;&#x1f34b;大数据学习&#x1f34b;&#x1f34b; &#x1f525;系列专栏&#xff1a; &#x1f451;哲学语录: 用力所能及&#xff0c;改变世界。 &#x1f496;如果觉得博主的文章还不错的话&#xff0c;请点赞&#x1f44d;收藏⭐️留言&#x1f4dd;支持一…...

Spring Data审计利器:@LastModifiedDate详解(依赖关系补充篇)!!!

&#x1f552; Spring Data审计利器&#xff1a;LastModifiedDate详解&#x1f525;&#xff08;依赖关系补充篇&#xff09; &#x1f50c; 核心依赖解析 使用LastModifiedDate必须知道的依赖关系 #mermaid-svg-qm1OUa9Era9ktbeK {font-family:"trebuchet ms",verd…...

Tweak Power:全方位电脑系统优化的高效工具

Tweak Power&#xff08;系统&#xff09; Tweak Power是一款功能强大的系统优化工具&#xff0c;专为提升Windows电脑的性能和稳定性而设计。它提供了全面的清理、优化和调整选项&#xff0c;帮助用户轻松管理系统资源、提高运行速度、延长设备寿命。 快速扫描并清理系统垃圾…...

CLion下载安装(Windows11)

目录 CLion工具下载安装其他 CLion CLion-2024.1.4.exe 工具 系统&#xff1a;Windows 11 下载 1.通过百度网盘分享的文件&#xff1a;CLion-2024.1.4.exe 链接&#xff1a;https://pan.baidu.com/s/1-zH0rZPCZtQ60IqdHA7Cew?pwdux5a 提取码&#xff1a;ux5a 安装 打开…...

如何用 Postman 进行高效的 Mock 测试?

Postman 是一个强大的 API 开发和测试工具&#xff0c;它可以让你轻松地创建和发送各种 HTTP 请求&#xff0c;查看响应结果&#xff0c;并进行调试和优化。但是有时候&#xff0c;你可能还没有开发好后端服务&#xff0c;或者想要模拟不同的响应场景&#xff0c;这时候就可以使…...

DeepSeek API集成开发指南——Flask示例实践

DeepSeek API集成开发指南——Flask示例实践 序言&#xff1a;智能化开发新范式 DeepSeek API提供了覆盖自然语言处理、代码生成等多领域的先进AI能力。本文将以一个功能完备的Flask示例系统为载体&#xff0c;详解API的集成方法与最佳实践。通过本案例&#xff0c;开发者可快…...

【天梯赛】L2-004 这是二叉搜索树吗(经典问题C++)

解题反思 //镜像树满足&#xff1a;左子树>根节点>右子树 //特殊&#xff1a;独腿二叉树&#xff0c;如pre {2&#xff0c;3&#xff0c;4}&#xff0c;递归函数用if(root tail) return&#xff1b;无法识别这种二叉树 // 用ismirror来将一般二叉树和镜像二叉搜索树的…...

Postman 全局 Header 如何设置?全局设置了解一下

在使用 Postman 设置全局请求头信息的关键步骤包括&#xff1a;在集合设置页面中添加所需的头部信息&#xff0c;并确保选择适当的类型和值&#xff1b;如果需要&#xff0c;可通过 JavaScript 脚本添加其他请求头&#xff1b;最后&#xff0c;验证设置是否成功生效。 Postman…...

科技赋能建筑业变革:中建海龙创新引领高质量发展新路径

在建筑工业化浪潮中&#xff0c;中建海龙科技有限公司&#xff08;以下简称“中建海龙”&#xff09;凭借深厚的技术积累与持续创新&#xff0c;成为推动行业转型升级的标杆企业。作为中国建筑国际集团旗下核心科技力量&#xff0c;中建海龙深耕模块化集成建筑&#xff08;MiC&…...

QT计算器开发

1.项目架构 1.图形化界面 ​ 2.widget.h​ #ifndef WIDGET_H #define WIDGET_H#include <QWidget> #include <QString> #include <QStack>QT_BEGIN_NAMESPACE namespace Ui { class Widget; } QT_END_NAMESPACEclass Widget : public QWidget {Q_OBJECTp…...

R语言对偏态换数据进行转换(对数、平方根、立方根)

我们进行研究的时候经常会遇见偏态数据&#xff0c;数据转换是统计分析和数据预处理中的一项基本技术。使用 R 时&#xff0c;了解如何正确转换数据有助于满足统计假设、标准化分布并提高分析的准确性。在 R 中实现和可视化最常见的数据转换&#xff1a;对数、平方根和立方根转…...

《Python实战进阶》No37: 强化学习入门:Q-Learning 与 DQN-加餐版1 Q-Learning算法可视化

在《Python实战进阶》No37: 强化学习入门&#xff1a;Q-Learning 与 DQN 这篇文章中&#xff0c;我们介绍了Q-Learning算法走出迷宫的代码实践&#xff0c;本文加餐&#xff0c;把Q-Learning算法通过代码可视化呈现。我尝试了使用Matplotlib实现&#xff0c;但局限于Matplotli…...

【漏洞修复】Android 10 系统源码中的 glibc、curl、openssl、cups、zlib 更新到最新版本

要将 Android 10 系统源码中的 glibc、curl、openssl、cups、zlib 更新到最新版本&#xff0c;需结合交叉编译、源码替换和系统兼容性适配。以下是具体步骤和相关库的版本信息及维护状态分析&#xff1a; 一、Android 10 默认版本及维护状态 库Android 10 默认版本维护状态最新…...

【云服务器】在 Linux(Ubuntu / CentOS 7)上快速搭建我的世界 Minecraft 服务器,并实现远程联机,详细教程

【云服务器】在 Linux&#xff08;Ubuntu / CentOS 7&#xff09;上快速搭建我的世界 Minecraft 服务器&#xff0c;并实现远程联机&#xff0c;详细教程 一、 服务器介绍二、下载 Minecraft 服务端二、安装 JRE 21三、安装 MCS manager 面板四、搭建服务器五、本地测试连接六、…...

docker torcherve打包mar包并部署模型

使用Docker打包深度网络模型mar包到服务端 参考链接&#xff1a;Docker torchserve 部署模型流程——以WSL部署YOLO-FaceV2为例_class myhandler(basehandler): def initialize(self,-CSDN博客 1、docker拉取环境镜像命令 docker images出现此提示为没有权限取执行命令&…...

【安当产品应用案例100集】042-基于安当KADP实现机密文件安全流转

一、客户需求 某集团公司客户&#xff0c;在系统业务流中&#xff0c;存在大量的内部文件流转的需求。内部业务文件有不同的安全密级&#xff0c;最初在文件流转时&#xff0c;公司内部规定点对点的文件传输&#xff0c;要使用加密工具加密后再发给需要的一方。这种方式虽然能…...

[Qt5] QMetaObject::invokeMethod使用

&#x1f4e2;博客主页&#xff1a;https://loewen.blog.csdn.net&#x1f4e2;欢迎点赞 &#x1f44d; 收藏 ⭐留言 &#x1f4dd; 如有错误敬请指正&#xff01;&#x1f4e2;本文由 丶布布原创&#xff0c;首发于 CSDN&#xff0c;转载注明出处&#x1f649;&#x1f4e2;现…...

软件设计原则之迪米特法则

迪米特法则&#xff08;Law of Demeter&#xff0c;LoD&#xff09; 核心思想&#xff1a; 一个对象应当尽可能少地了解其他对象&#xff0c;只与直接朋友交互&#xff08;如自身的成员变量、方法参数、方法内部创建的对象&#xff09;&#xff0c;避免通过复杂的调用链访问间…...

JSON5 格式标准 Data Exchange Format 官方文档 中英双语

Standard JSON5 标准 JSON5 1.0.0 / March 2018 1.0.0 / 三月 2018 The JSON5 Data Interchange FormatThe JSON5 数据交换格式 Abstract 摘要 The JSON5 Data Interchange Format is a proposed extension to JSON that aims to make it easier for humans to write an…...

附录C SLAC匹配过程命令定义与实际抓包

附录C SLAC匹配过程命令定义与实际抓包 ISO15118-3 附录A中规定了SLAC匹配过程中的请求命令及应答&#xff0c; 本文将会对比协议中的定义和实际抓包内容&#xff0c;以便读者获得直观的认识。 1 CM_SET_KEY.REQ 定义内容&#xff1a; 实际数据&#xff1a; 注意报文中的 08…...

【QT】新建QT工程(详细步骤)

新建QT工程 1.方法(1)点击new project按钮&#xff0c;弹出对话框&#xff0c;新建即可&#xff0c;步骤如下&#xff1a;(2) 点击文件菜单&#xff0c;选择新建文件或者工程&#xff0c;后续步骤如上 2.QT工程文件介绍(1).pro文件 --》QT工程配置文件(2)main.cpp --》QT工程主…...

安装Webpack并创建vue项目

1、新建一个工程目录 在E盘中进行新建项目 2、从命令行进入该目录,并执行NPM 的初始化命令 3、会看到目录中生成了一个“package.json”文件,它相当于NPM项目的说明书&#xff0c;里面记录了项目名称、版本、仓库地址等信息。 4、执行安装 Webpack 的命令 npm install webpac…...

如何快速解决django存储session变量时出现的django.db.utils.DatabaseError错误

我们在学习django进行web编程的时候&#xff0c;有时需要将一些全局变量信息存储在session中&#xff0c;但使用过程中&#xff0c;却发现会引起数据库的报错。通过查看django源码信息&#xff0c;发现其对session信息进行了ORM映射&#xff0c;如果数据库中不存在对应的表信息…...

04 单目标定实战示例

看文本文,您将获得以下技能: 1:使用opencv进行相机单目标定实战 2:标定结果参数含义和数值分析 3:Python绘制各标定板姿态,查看图像采集多样性 4:如果相机画幅旋转90,标定输入参数该如何设置? 5:图像尺寸缩放,标定结果输出有何影响? 6:单目标定结果应用类别…...

极速全场景 MPP数据库starrocks介绍

目录 一、引子 二、起源 &#xff08;一&#xff09;前身 &#xff08;二&#xff09;定位 三、特点 &#xff08;一&#xff09;高性能架构 &#xff08;二&#xff09;实时分析 &#xff08;三&#xff09;高并发与扩展性 &#xff08;四&#xff09;兼容性与生态 …...

RS232转Profinet网关技术,检漏仪新篇章!

RS232转Profinet网关技术&#xff0c;检漏仪新篇章&#xff01; 在现代医疗监控系统中&#xff0c;RS232转PROFINET网关扮演着至关重要的角色。这种转换设备能够将传统的RS232串行通讯接口无缝转换为PROFINET以太网通信接口&#xff0c;确保老旧设备与现代自动化系统之间的顺畅…...

Linux操作系统7- 线程同步与互斥7(RingQueue环形队列生产者消费者模型改进)

上篇文章&#xff1a;Linux操作系统7- 线程同步与互斥6&#xff08;POSIX信号量与环形队列生产者消费者模型&#xff09;-CSDN博客 本篇代码仓库&#xff1a;myLerningCode/l36 橘子真甜/Linux操作系统与网络编程学习 - 码云 - 开源中国 (gitee.com) 目录 一. 单生产单消费单保…...