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

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

数据库

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
http://www.jsqmd.com/news/177847/

相关文章:

  • 《创业之路》-778-致2026年元旦-人类开启星际文明的应用场景、技术路径
  • 8款AI论文写作工具测评:智能降重与高效创作功能分析
  • 重定向和“Linux下一切皆文件”的理解
  • 7#2#东地库,监控很掉线,找不到原因
  • 强烈安利!专科生必用8款AI论文工具测评
  • why Ch chose to stand with USSR in K war
  • 字节版 NotebookLM 悄悄上线;乐鑫、涂鸦争相推出 AI 硬件交互方案;2025 AI 语音输入工具盘点丨日报
  • java计算机毕业设计雄宗土特产销售网站 雄宗农特产品在线商城系统 雄宗特色农产品电商交易平台
  • 大学生HTML期末大作业——HTML+CSS+JavaScript美食网站(零食) - 详解
  • 统计今日、最近一周、最近一个月
  • 强烈安利8个AI论文写作软件,专科生搞定毕业论文!
  • 2025第三届数信杯
  • 【类定义系列五】类静态成员变量初始化
  • java计算机毕业设计信阳市多目的地同步导航系统 信阳都市圈多点路径智能规划小程序 豫南城市群多目标位置同步导航平台
  • 数据结构 字典树
  • 大数据领域 HDFS 的数据备份的最佳实践案例
  • 线段树讲解
  • 利用 ‘Vectorstore Retrievable Memory’:如何实现跨会话(Cross-session)的全局偏好召回?
  • Comsol Mie米氏散射:多极子分解仿真与案例分析
  • C:写一个函数返回参数二进制中1的个数
  • 巴菲特的护城河理论2.0:数字经济时代的竞争优势
  • 01-PGBegin
  • OBS直播教程:OBS怎么美颜?OBS怎么开美颜摄像头?
  • C++万能类:any
  • 02-PGBasicOperations
  • 02-PGBasicOperations
  • Claude-Opus-4.5 国内落地最佳实践:基于 API 网关的低延迟架构方案
  • SHEPWM特定谐波消除pwm 三相两电平 matlab/simulink2019a版本
  • python基础2
  • Goodbye 2025! Hello 2026!