news 2026/2/12 20:04:04

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

作者头像

张小明

前端开发工程师

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/6 12:10:27

大数据时代 RabbitMQ 助力数据高效分发

大数据时代 RabbitMQ 助力数据高效分发 关键词:大数据时代、RabbitMQ、数据高效分发、消息队列、分布式系统 摘要:在大数据时代,数据的高效分发是众多企业和系统面临的重要挑战。RabbitMQ 作为一款强大的消息队列中间件,凭借其可靠、灵活等特性,在数据分发领域发挥着关键作…

作者头像 李华
网站建设 2026/2/6 4:58:23

C++万能类:any

std::any 是 C17 引入的一个极其重要的特性&#xff0c;它为 C 这种强类型语言带来了类似动态语言&#xff08;如 Python 变量&#xff09;的灵活性&#xff0c;同时保持了类型安全。 简单来说&#xff0c;std::any 是一个类型安全的容器&#xff0c;它可以存储“任意”类型的…

作者头像 李华
网站建设 2026/2/6 16:06:19

YOLOFuse是否收集用户数据?本地运行完全离线保障隐私

YOLOFuse是否收集用户数据&#xff1f;本地运行完全离线保障隐私 在安防监控、工业检测甚至自动驾驶等高敏感场景中&#xff0c;AI模型的“聪明”固然重要&#xff0c;但更关键的是——它是否值得信任。当一个目标检测系统接入摄像头时&#xff0c;我们不仅要问&#xff1a;它看…

作者头像 李华
网站建设 2026/2/9 1:36:05

springboot宠物分享网站

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

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

导师严选10个AI论文写作软件,助你轻松搞定本科论文!

导师严选10个AI论文写作软件&#xff0c;助你轻松搞定本科论文&#xff01; AI 工具&#xff0c;让论文写作不再难 对于很多本科生来说&#xff0c;撰写一篇高质量的论文是大学生活中的一大挑战。从选题到大纲&#xff0c;再到初稿和修改&#xff0c;每一个环节都需要大量的时间…

作者头像 李华