正在显示
5 个修改的文件
包含
54 行增加
和
18 行删除
| @@ -132,7 +132,7 @@ public class AiragLogController extends JeecgController<AiragLog, IAiragLogServi | @@ -132,7 +132,7 @@ public class AiragLogController extends JeecgController<AiragLog, IAiragLogServi | ||
| 132 | for (AiragLog log : pageList.getRecords()) { | 132 | for (AiragLog log : pageList.getRecords()) { |
| 133 | if (log.getCodeType() == 0) { | 133 | if (log.getCodeType() == 0) { |
| 134 | // 输入框提问,按钮code为空 | 134 | // 输入框提问,按钮code为空 |
| 135 | - log.setCode(null); | 135 | + log.setCode("null"); |
| 136 | } else if (log.getCodeType() == 1) { | 136 | } else if (log.getCodeType() == 1) { |
| 137 | // 快捷按钮提问 | 137 | // 快捷按钮提问 |
| 138 | if (StringUtils.isNotBlank(log.getQuestion())) { | 138 | if (StringUtils.isNotBlank(log.getQuestion())) { |
| @@ -357,8 +357,11 @@ public class AiragLogController extends JeecgController<AiragLog, IAiragLogServi | @@ -357,8 +357,11 @@ public class AiragLogController extends JeecgController<AiragLog, IAiragLogServi | ||
| 357 | @AutoLog(value = "日志管理-获取统计信息") | 357 | @AutoLog(value = "日志管理-获取统计信息") |
| 358 | @Operation(summary="日志管理-获取统计信息") | 358 | @Operation(summary="日志管理-获取统计信息") |
| 359 | @GetMapping(value = "/getStatistics") | 359 | @GetMapping(value = "/getStatistics") |
| 360 | - public Result<Map<String, Object>> getStatistics() { | ||
| 361 | - Map<String, Object> result = airagLogService.getStatistics(); | 360 | + public Result<Map<String, Object>> getStatistics( |
| 361 | + @RequestParam(name = "rangeType", required = false) String rangeType, | ||
| 362 | + @RequestParam(name = "startTime", required = false) String startTime, | ||
| 363 | + @RequestParam(name = "endTime", required = false) String endTime) { | ||
| 364 | + Map<String, Object> result = airagLogService.getStatistics(rangeType, startTime, endTime); | ||
| 362 | return Result.OK(result); | 365 | return Result.OK(result); |
| 363 | } | 366 | } |
| 364 | } | 367 | } |
| @@ -24,7 +24,11 @@ public interface AiragLogMapper extends BaseMapper<AiragLog> { | @@ -24,7 +24,11 @@ public interface AiragLogMapper extends BaseMapper<AiragLog> { | ||
| 24 | 24 | ||
| 25 | int updataIfSaveKnowledge(@Param("param1") int ifSaveKnowledge, @Param("param2") String id); | 25 | int updataIfSaveKnowledge(@Param("param1") int ifSaveKnowledge, @Param("param2") String id); |
| 26 | 26 | ||
| 27 | - List<Map<String, Object>> getButtonRankList(); | ||
| 28 | - | ||
| 29 | List<Map<String, Object>> getMonthlyCount(); | 27 | List<Map<String, Object>> getMonthlyCount(); |
| 28 | + | ||
| 29 | + List<Map<String, Object>> getButtonRankList( | ||
| 30 | + @Param("rangeType") String rangeType, | ||
| 31 | + @Param("startTime") String startTime, | ||
| 32 | + @Param("endTime") String endTime | ||
| 33 | + ); | ||
| 30 | } | 34 | } |
| @@ -74,12 +74,39 @@ | @@ -74,12 +74,39 @@ | ||
| 74 | 74 | ||
| 75 | <select id="getButtonRankList" resultType="java.util.Map"> | 75 | <select id="getButtonRankList" resultType="java.util.Map"> |
| 76 | SELECT | 76 | SELECT |
| 77 | - b.button_name AS name, | ||
| 78 | - COUNT(l.id) AS total | 77 | + b.button_name AS name, |
| 78 | + COUNT(l.id) AS total | ||
| 79 | FROM airag_button b | 79 | FROM airag_button b |
| 80 | - LEFT JOIN airag_log l ON b.code = l.code | 80 | + LEFT JOIN airag_log l ON b.code = l.code |
| 81 | + <where> | ||
| 82 | + <if test="rangeType != null"> | ||
| 83 | + <choose> | ||
| 84 | + <when test="rangeType == 'today'"> | ||
| 85 | + AND DATE(l.create_time) = CURDATE() | ||
| 86 | + </when> | ||
| 87 | + <when test="rangeType == 'week'"> | ||
| 88 | + AND l.create_time >= DATE_SUB(CURDATE(), INTERVAL WEEKDAY(CURDATE()) DAY) | ||
| 89 | + AND l.create_time < DATE_ADD(DATE_SUB(CURDATE(), INTERVAL WEEKDAY(CURDATE()) DAY), INTERVAL 7 DAY) | ||
| 90 | + </when> | ||
| 91 | + <when test="rangeType == 'month'"> | ||
| 92 | + AND YEAR(l.create_time) = YEAR(CURDATE()) | ||
| 93 | + AND MONTH(l.create_time) = MONTH(CURDATE()) | ||
| 94 | + </when> | ||
| 95 | + <when test="rangeType == 'year'"> | ||
| 96 | + AND YEAR(l.create_time) = YEAR(CURDATE()) | ||
| 97 | + </when> | ||
| 98 | + </choose> | ||
| 99 | + </if> | ||
| 100 | + <!-- 当没有指定时间范围时,查询所有数据 --> | ||
| 101 | + <if test="rangeType == null and (startTime == null or endTime == null)"> | ||
| 102 | + AND 1=1 | ||
| 103 | + </if> | ||
| 104 | + <if test="startTime != null and endTime != null"> | ||
| 105 | + AND l.create_time BETWEEN #{startTime} AND #{endTime} | ||
| 106 | + </if> | ||
| 107 | + </where> | ||
| 81 | GROUP BY b.id, b.button_name | 108 | GROUP BY b.id, b.button_name |
| 82 | ORDER BY total DESC | 109 | ORDER BY total DESC |
| 83 | - LIMIT 7 | 110 | + LIMIT 7 |
| 84 | </select> | 111 | </select> |
| 85 | </mapper> | 112 | </mapper> |
| @@ -27,7 +27,7 @@ public interface IAiragLogService extends IService<AiragLog> { | @@ -27,7 +27,7 @@ public interface IAiragLogService extends IService<AiragLog> { | ||
| 27 | 27 | ||
| 28 | IPage<AiragLog> pageList(AiragLog airagLog, Page<AiragLog> page); | 28 | IPage<AiragLog> pageList(AiragLog airagLog, Page<AiragLog> page); |
| 29 | 29 | ||
| 30 | - Map<String, Object> getStatistics(); | 30 | + Map<String, Object> getStatistics(String rangeType, String startTime, String endTime); |
| 31 | 31 | ||
| 32 | // List<T> list(Page<AiragLog> page, QueryWrapper<AiragLog> queryWrapper); | 32 | // List<T> list(Page<AiragLog> page, QueryWrapper<AiragLog> queryWrapper); |
| 33 | } | 33 | } |
| @@ -101,7 +101,7 @@ public class AiragLogServiceImpl extends ServiceImpl<AiragLogMapper, AiragLog> i | @@ -101,7 +101,7 @@ public class AiragLogServiceImpl extends ServiceImpl<AiragLogMapper, AiragLog> i | ||
| 101 | 101 | ||
| 102 | 102 | ||
| 103 | @Override | 103 | @Override |
| 104 | - public Map<String, Object> getStatistics() { | 104 | + public Map<String, Object> getStatistics(String rangeType, String startTime, String endTime) { |
| 105 | Map<String, Object> result = new HashMap<>(); | 105 | Map<String, Object> result = new HashMap<>(); |
| 106 | 106 | ||
| 107 | // 1. 获取今日问答次数 | 107 | // 1. 获取今日问答次数 |
| @@ -144,12 +144,18 @@ public class AiragLogServiceImpl extends ServiceImpl<AiragLogMapper, AiragLog> i | @@ -144,12 +144,18 @@ public class AiragLogServiceImpl extends ServiceImpl<AiragLogMapper, AiragLog> i | ||
| 144 | } | 144 | } |
| 145 | 145 | ||
| 146 | // 7.获取按钮问题和按钮code次数,只获取有按钮code的问题(log.question) | 146 | // 7.获取按钮问题和按钮code次数,只获取有按钮code的问题(log.question) |
| 147 | - List<Map<String, Object>> buttonStats = airagLogMapper.getButtonRankList(); | 147 | + List<Map<String, Object>> buttonStats = airagLogMapper.getButtonRankList( |
| 148 | + rangeType, | ||
| 149 | + startTime, | ||
| 150 | + endTime | ||
| 151 | + ); | ||
| 152 | + // 8.对按钮进行今日本周本月本年的实时查询和根据选定日期范围内的查询 | ||
| 148 | 153 | ||
| 149 | - // 8. 获取最近12个月的月度数据 | 154 | + |
| 155 | + // 9. 获取最近12个月的月度数据 | ||
| 150 | List<Map<String, Object>> monthlyData = airagLogMapper.getMonthlyCount(); | 156 | List<Map<String, Object>> monthlyData = airagLogMapper.getMonthlyCount(); |
| 151 | 157 | ||
| 152 | - // 9. 添加前一天数据 | 158 | + // 10. 添加前一天数据 |
| 153 | result.put("yesterdayCount", yesterdayCount); | 159 | result.put("yesterdayCount", yesterdayCount); |
| 154 | result.put("growthRate", Math.round(growthRate * 100.0) / 100.0); // 保留两位小数 | 160 | result.put("growthRate", Math.round(growthRate * 100.0) / 100.0); // 保留两位小数 |
| 155 | result.put("todayCount", todayCount); | 161 | result.put("todayCount", todayCount); |
| @@ -162,9 +168,5 @@ public class AiragLogServiceImpl extends ServiceImpl<AiragLogMapper, AiragLog> i | @@ -162,9 +168,5 @@ public class AiragLogServiceImpl extends ServiceImpl<AiragLogMapper, AiragLog> i | ||
| 162 | return result; | 168 | return result; |
| 163 | } | 169 | } |
| 164 | 170 | ||
| 165 | - /* @Override | ||
| 166 | - public List<T> list(Page<AiragLog> page, QueryWrapper<AiragLog> queryWrapper) { | ||
| 167 | - | ||
| 168 | - }*/ | ||
| 169 | } | 171 | } |
| 170 | 172 |
-
请 注册 或 登录 后发表评论