news 2026/2/26 2:17:38

统计今天,近一周,当月,年份统计记录

作者头像

张小明

前端开发工程师

1.2k 24
文章封面图
统计今天,近一周,当月,年份统计记录

数据库

service层

publicList<ReportDayWeekMonthYear>getReportDayWeekMonthYear(ReportDayWeekMonthYearReqreq){LocalDatestartTimeLocalDate=LocalDate.parse(req.getStartTime(),DateTimeFormatter.ofPattern("yyyy-MM-dd"));LocalDateendTimeLocalDate=LocalDate.parse(req.getEndTime(),DateTimeFormatter.ofPattern("yyyy-MM-dd"));Durationduration=Duration.between(startTimeLocalDate.atStartOfDay(),endTimeLocalDate.atStartOfDay());StringtimeFormatParam;Stringtype;intscope;if(req.getFlag()==4){intyears=endTimeLocalDate.getYear()-startTimeLocalDate.getYear();intendMonth=endTimeLocalDate.getMonthValue();intstartMonth=startTimeLocalDate.getMonthValue();scope=endMonth-startMonth+1;System.out.println("month:"+scope);}else{scope=(int)duration.toDays()+1;}switch(req.getFlag()){case1:// 查询当日数据timeFormatParam="%Y-%m-%d";type="DAY";//scope = 1;break;case2:// 查询周数据timeFormatParam="%Y-%m-%d";type="DAY";//scope = 7;break;case3:// 查询月数据timeFormatParam="%Y-%m-%d";type="DAY";//scope = 30;break;case4:// 查询年数据timeFormatParam="%Y-%m";type="MONTH";//scope = 12;break;default:timeFormatParam="%Y-%m-%d";type="DAY";//scope = 1;break;}List<ReportDayWeekMonthYear>reportDayWeekMonthYear=xxlJobLogReportMapper.getReportDayWeekMonthYear(endTimeLocalDate,timeFormatParam,type,scope);for(ReportDayWeekMonthYeardayWeekMonthYear:reportDayWeekMonthYear){System.out.println(dayWeekMonthYear);}returnreportDayWeekMonthYear;}

mapper

select t1.curr_date as orderly_time,IFNULL(t2.fail_count,0)fail_count,IFNULL(t2.running_count,0)running_count,IFNULL(t2.suc_count,0)suc_count from(select date_format(date_add(#{endTimeLocalDate},interval-t.help_topic_id ${type}),#{timeFormatParam})as curr_date from mysql.help_topic t where t.help_topic_id&lt;#{scope})t1LEFTJOIN(<choose><when test="type != 'MONTH' ">SELECTDATE_FORMAT(trigger_day,#{timeFormatParam})formatime,running_count,suc_count,fail_countFROMxxl_job_log_report</when><otherwise>//count(列名)是统计分组后列的个数,//sum(列名)是将列的值相加SELECTDATE_FORMAT(trigger_day,'%Y-%m')formatime,sum(running_count)running_count,sum(suc_count)suc_count,sum(fail_count)fail_countFROMxxl_job_log_reportGROUPBYformatime</otherwise></choose>)t2ONt1.curr_date=t2.formatime
版权声明: 本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!
网站建设 2026/2/22 19:32:28

OBS直播教程:OBS怎么美颜?OBS怎么开美颜摄像头?

OBS直播教程&#xff1a;OBS怎么美颜&#xff1f;OBS怎么开美颜摄像头&#xff1f; OBS美颜插件如何下载&#xff1f;OBS美颜插件具体如何安装&#xff1f;OBS美颜插件如何使用&#xff1f;详细步骤如下&#xff1a; 第一步&#xff1a;下载OBS美颜插件安装包&#xff0c;并完…

作者头像 李华
网站建设 2026/2/23 9:55:25

python高校班主任辅导员管理系统vue

文章目录具体实现截图主要技术与实现手段系统设计与实现的思路系统设计方法java类核心代码部分展示结论源码lw获取/同行可拿货,招校园代理 &#xff1a;文章底部获取博主联系方式&#xff01;具体实现截图 本系统&#xff08;程序源码数据库调试部署讲解&#xff09;带文档1万…

作者头像 李华
网站建设 2026/2/24 22:02:35

TokenBrokerUI.dll文件损坏丢失找不到 打不开程序 下载方法

在使用电脑系统时经常会出现丢失找不到某些文件的情况&#xff0c;由于很多常用软件都是采用 Microsoft Visual Studio 编写的&#xff0c;所以这类软件的运行需要依赖微软Visual C运行库&#xff0c;比如像 QQ、迅雷、Adobe 软件等等&#xff0c;如果没有安装VC运行库或者安装…

作者头像 李华
网站建设 2026/2/25 17:16:14

YOLOFuse真实用户反馈:‘终于不用折腾环境了’

YOLOFuse真实用户反馈&#xff1a;“终于不用折腾环境了” 在智能安防、自动驾驶和夜间监控这些对感知能力要求极高的领域&#xff0c;单一模态的目标检测正逐渐暴露出它的局限性。白天光照充足时&#xff0c;RGB图像能清晰呈现目标的纹理与色彩&#xff1b;可一旦进入黄昏、浓…

作者头像 李华
网站建设 2026/2/25 2:36:33

Git常用命令

设置用户签名 基本语法 # 配置用户名和邮箱&#xff08;首次使用必须配置&#xff09; git config --global user.name 你的用户名 git config --global user.email 你的邮箱 # 查看配置信息 git config --list说明: 签名的作用是区分不同操作者身份。用户的签名信息在每一…

作者头像 李华
网站建设 2026/2/23 23:29:03

Git简介

Git概述 Git是一个免费的、开源的分布式版本控制系统,可以快速高效地处理从小型到大型的各种项目 特点 Git易于学习,占地面积小,性能极快。它具有廉价的本地库&#xff08;在本地的磁盘&#xff09; ,方便的暂存区域和多个工作流分支等特性。其性能优于Subversion、CVS、Perf…

作者头像 李华