news 2026/4/18 14:32:59

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

作者头像

张小明

前端开发工程师

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/4/18 9:41:42

Comsol Mie米氏散射:多极子分解仿真与案例分析

Comsol Mie米氏散射多极子分解仿真 包括单个散射体多极子分解、超表面周期性结构多极子分解 计算吸收截面&#xff0c;散射截面&#xff0c;消光截面 一共大概有5-6个案例&#xff0c;包会&#xff0c;不刀&#xff0c;爽快的来&#xff0c;直接发文件&#xff0c;同时fdtd多极…

作者头像 李华
网站建设 2026/4/18 6:38:20

無限鏡屋:當Python解釋器在自我模擬的量子世界中甦醒

無限鏡屋&#xff1a;當Python解釋器在自我模擬的量子世界中甦醒序幕&#xff1a;代碼的俄羅斯套娃在計算機科學的邊緣地帶&#xff0c;存在著一種近乎哲學的實踐——創建自指涉的系統。而我最近完成的項目&#xff0c;正是這種思想的終極體現&#xff1a;一個Python解釋器&…

作者头像 李华
网站建设 2026/4/17 13:38:13

汇川PLC AM系列脉冲控制伺服功能快案例分享

汇川plcam系列脉冲控制伺服功能快案例资料&#xff0c;总线控制已经很常见了&#xff0c;有时候需要用到脉冲控制&#xff0c;这个案例介绍了 脉冲的写法在自动化控制领域&#xff0c;总线控制虽说如今已经相当普遍&#xff0c;但在一些特定场景下&#xff0c;脉冲控制依然有着…

作者头像 李华
网站建设 2026/4/18 2:02:50

YOLOFuse与小鹏汽车合作设想:NGP夜视增强

YOLOFuse与小鹏汽车合作设想&#xff1a;NGP夜视增强 在智能驾驶的演进过程中&#xff0c;夜间行车安全始终是悬而未决的难题。即使是最先进的自动导航辅助驾驶&#xff08;NGP&#xff09;系统&#xff0c;在漆黑无光、浓雾弥漫或雨雪交加的环境中&#xff0c;依然可能“失明”…

作者头像 李华
网站建设 2026/4/18 2:01:06

YOLOFuse阿里云市场入驻:国内用户便捷购买

YOLOFuse阿里云市场入驻&#xff1a;国内用户便捷购买 在智能监控、无人系统和边境巡检等场景中&#xff0c;一个老生常谈的问题始终困扰着开发者&#xff1a;夜间或雾霾环境下&#xff0c;摄像头“看不清”&#xff0c;目标检测频频漏报。可见光图像在低照度下噪声大、对比度低…

作者头像 李华