修改日志管理代码,首页修改指标说明提示修改,
设置-功能按钮,设置-样式修改,知识库跳转,设置-全部字段必填,设置-将智能助手配置放菜单管理下
正在显示
6 个修改的文件
包含
140 行增加
和
13 行删除
| @@ -84,6 +84,8 @@ public class AiragChatsettingController extends JeecgController<AiragChatsetting | @@ -84,6 +84,8 @@ public class AiragChatsettingController extends JeecgController<AiragChatsetting | ||
| 84 | // 处理按钮ID为数组 | 84 | // 处理按钮ID为数组 |
| 85 | if (StringUtils.isNotBlank(airagChatsettingConfig.getButtonId())) { | 85 | if (StringUtils.isNotBlank(airagChatsettingConfig.getButtonId())) { |
| 86 | airagChatsettingConfig.setButtonIds(Arrays.asList(airagChatsettingConfig.getButtonId().split(","))); | 86 | airagChatsettingConfig.setButtonIds(Arrays.asList(airagChatsettingConfig.getButtonId().split(","))); |
| 87 | + }else{ | ||
| 88 | + airagChatsettingConfig.setButtonIds(Collections.emptyList()); | ||
| 87 | } | 89 | } |
| 88 | 90 | ||
| 89 | 91 |
| @@ -308,11 +308,27 @@ public class AiragLogController extends JeecgController<AiragLog, IAiragLogServi | @@ -308,11 +308,27 @@ public class AiragLogController extends JeecgController<AiragLog, IAiragLogServi | ||
| 308 | @AutoLog(value = "日志管理-获取统计信息") | 308 | @AutoLog(value = "日志管理-获取统计信息") |
| 309 | @Operation(summary="日志管理-获取统计信息") | 309 | @Operation(summary="日志管理-获取统计信息") |
| 310 | @GetMapping(value = "/getStatistics") | 310 | @GetMapping(value = "/getStatistics") |
| 311 | - public Result<Map<String, Object>> getStatistics( | 311 | + public Result<Map<String, Object>> getStatistics() { |
| 312 | + Map<String, Object> result = airagLogService.getStatistics(); | ||
| 313 | + return Result.OK(result); | ||
| 314 | + } | ||
| 315 | + | ||
| 316 | + @AutoLog(value = "日志管理-获取按钮统计信息") | ||
| 317 | + @Operation(summary="日志管理-获取按钮统计信息") | ||
| 318 | + @GetMapping(value = "/getButtonStats") | ||
| 319 | + public Result<List<Map<String, Object>>> getButtonStats( | ||
| 312 | @RequestParam(name = "rangeType", required = false) String rangeType, | 320 | @RequestParam(name = "rangeType", required = false) String rangeType, |
| 313 | @RequestParam(name = "startTime", required = false) String startTime, | 321 | @RequestParam(name = "startTime", required = false) String startTime, |
| 314 | @RequestParam(name = "endTime", required = false) String endTime) { | 322 | @RequestParam(name = "endTime", required = false) String endTime) { |
| 315 | - Map<String, Object> result = airagLogService.getStatistics(rangeType, startTime, endTime); | 323 | + List<Map<String, Object>> result = airagLogService.getButtonStats(rangeType, startTime, endTime); |
| 324 | + return Result.OK(result); | ||
| 325 | + } | ||
| 326 | + | ||
| 327 | + @AutoLog(value = "日志管理-获取问题输入统计信息") | ||
| 328 | + @Operation(summary="日志管理-获取文日输入统计信息") | ||
| 329 | + @GetMapping(value = "/getQuestionStatistics") | ||
| 330 | + public Result<Map<String, Object>> getQuestionStatistics() { | ||
| 331 | + Map<String, Object> result = airagLogService.getQuestionStatistics(); | ||
| 316 | return Result.OK(result); | 332 | return Result.OK(result); |
| 317 | } | 333 | } |
| 318 | } | 334 | } |
| @@ -30,4 +30,7 @@ public interface AiragLogMapper extends BaseMapper<AiragLog> { | @@ -30,4 +30,7 @@ public interface AiragLogMapper extends BaseMapper<AiragLog> { | ||
| 30 | @Param("startTime") String startTime, | 30 | @Param("startTime") String startTime, |
| 31 | @Param("endTime") String endTime | 31 | @Param("endTime") String endTime |
| 32 | ); | 32 | ); |
| 33 | + | ||
| 34 | + List<Map<String, Object>> getDailyCountForLast7Days(); | ||
| 35 | + List<Map<String, Object>> getDailyRejectedCountForLast7Days(); | ||
| 33 | } | 36 | } |
| @@ -103,4 +103,53 @@ | @@ -103,4 +103,53 @@ | ||
| 103 | ORDER BY total DESC | 103 | ORDER BY total DESC |
| 104 | LIMIT 7 | 104 | LIMIT 7 |
| 105 | </select> | 105 | </select> |
| 106 | + | ||
| 107 | + <select id="getDailyCountForLast7Days" resultType="java.util.Map"> | ||
| 108 | + SELECT | ||
| 109 | + DATE_FORMAT(date_range.date, '%Y-%m-%d') AS date, | ||
| 110 | + IFNULL(log_counts.count, 0) AS count | ||
| 111 | + FROM ( | ||
| 112 | + SELECT CURDATE() AS date | ||
| 113 | + UNION ALL SELECT DATE_SUB(CURDATE(), INTERVAL 1 DAY) | ||
| 114 | + UNION ALL SELECT DATE_SUB(CURDATE(), INTERVAL 2 DAY) | ||
| 115 | + UNION ALL SELECT DATE_SUB(CURDATE(), INTERVAL 3 DAY) | ||
| 116 | + UNION ALL SELECT DATE_SUB(CURDATE(), INTERVAL 4 DAY) | ||
| 117 | + UNION ALL SELECT DATE_SUB(CURDATE(), INTERVAL 5 DAY) | ||
| 118 | + UNION ALL SELECT DATE_SUB(CURDATE(), INTERVAL 6 DAY) | ||
| 119 | + ) date_range | ||
| 120 | + LEFT JOIN ( | ||
| 121 | + SELECT | ||
| 122 | + DATE(create_time) AS date, | ||
| 123 | + COUNT(*) AS count | ||
| 124 | + FROM airag_log | ||
| 125 | + WHERE create_time >= DATE_SUB(CURDATE(), INTERVAL 6 DAY) | ||
| 126 | + GROUP BY DATE(create_time) | ||
| 127 | + ) log_counts ON date_range.date = log_counts.date | ||
| 128 | + ORDER BY date_range.date ASC | ||
| 129 | + </select> | ||
| 130 | + | ||
| 131 | + <select id="getDailyRejectedCountForLast7Days" resultType="java.util.Map"> | ||
| 132 | + SELECT | ||
| 133 | + DATE_FORMAT(date_range.date, '%Y-%m-%d') AS date, | ||
| 134 | + IFNULL(log_counts.count, 0) AS count | ||
| 135 | + FROM ( | ||
| 136 | + SELECT CURDATE() AS date | ||
| 137 | + UNION ALL SELECT DATE_SUB(CURDATE(), INTERVAL 1 DAY) | ||
| 138 | + UNION ALL SELECT DATE_SUB(CURDATE(), INTERVAL 2 DAY) | ||
| 139 | + UNION ALL SELECT DATE_SUB(CURDATE(), INTERVAL 3 DAY) | ||
| 140 | + UNION ALL SELECT DATE_SUB(CURDATE(), INTERVAL 4 DAY) | ||
| 141 | + UNION ALL SELECT DATE_SUB(CURDATE(), INTERVAL 5 DAY) | ||
| 142 | + UNION ALL SELECT DATE_SUB(CURDATE(), INTERVAL 6 DAY) | ||
| 143 | + ) date_range | ||
| 144 | + LEFT JOIN ( | ||
| 145 | + SELECT | ||
| 146 | + DATE(create_time) AS date, | ||
| 147 | + COUNT(*) AS count | ||
| 148 | + FROM airag_log | ||
| 149 | + WHERE create_time >= DATE_SUB(CURDATE(), INTERVAL 6 DAY) | ||
| 150 | + AND answer_type = 3 <!-- 假设3表示拒绝回答 --> | ||
| 151 | + GROUP BY DATE(create_time) | ||
| 152 | + ) log_counts ON date_range.date = log_counts.date | ||
| 153 | + ORDER BY date_range.date ASC | ||
| 154 | + </select> | ||
| 106 | </mapper> | 155 | </mapper> |
| @@ -24,5 +24,9 @@ public interface IAiragLogService extends IService<AiragLog> { | @@ -24,5 +24,9 @@ public interface IAiragLogService extends IService<AiragLog> { | ||
| 24 | 24 | ||
| 25 | IPage<AiragLog> pageList(AiragLog airagLog, Page<AiragLog> page); | 25 | IPage<AiragLog> pageList(AiragLog airagLog, Page<AiragLog> page); |
| 26 | 26 | ||
| 27 | - Map<String, Object> getStatistics(String rangeType, String startTime, String endTime); | 27 | + Map<String, Object> getStatistics(); |
| 28 | + | ||
| 29 | + List<Map<String, Object>> getButtonStats(String rangeType, String startTime, String endTime); | ||
| 30 | + | ||
| 31 | + Map<String, Object> getQuestionStatistics(); | ||
| 28 | } | 32 | } |
| @@ -88,7 +88,7 @@ public class AiragLogServiceImpl extends ServiceImpl<AiragLogMapper, AiragLog> i | @@ -88,7 +88,7 @@ public class AiragLogServiceImpl extends ServiceImpl<AiragLogMapper, AiragLog> i | ||
| 88 | 88 | ||
| 89 | 89 | ||
| 90 | @Override | 90 | @Override |
| 91 | - public Map<String, Object> getStatistics(String rangeType, String startTime, String endTime) { | 91 | + public Map<String, Object> getStatistics() { |
| 92 | Map<String, Object> result = new HashMap<>(); | 92 | Map<String, Object> result = new HashMap<>(); |
| 93 | 93 | ||
| 94 | // 1. 获取今日问答次数 | 94 | // 1. 获取今日问答次数 |
| @@ -130,26 +130,79 @@ public class AiragLogServiceImpl extends ServiceImpl<AiragLogMapper, AiragLog> i | @@ -130,26 +130,79 @@ public class AiragLogServiceImpl extends ServiceImpl<AiragLogMapper, AiragLog> i | ||
| 130 | averageCount = Math.round(averageCount * 100.0) / 100.0; | 130 | averageCount = Math.round(averageCount * 100.0) / 100.0; |
| 131 | } | 131 | } |
| 132 | 132 | ||
| 133 | - // 7.获取按钮问题和按钮code次数,只获取有按钮code的问题(log.question) | ||
| 134 | - List<Map<String, Object>> buttonStats = airagLogMapper.getButtonRankList( | ||
| 135 | - rangeType, | ||
| 136 | - startTime, | ||
| 137 | - endTime | ||
| 138 | - ); | ||
| 139 | - | ||
| 140 | 133 | ||
| 141 | // 8. 获取最近12个月的月度数据 | 134 | // 8. 获取最近12个月的月度数据 |
| 142 | List<Map<String, Object>> monthlyData = airagLogMapper.getMonthlyCount(); | 135 | List<Map<String, Object>> monthlyData = airagLogMapper.getMonthlyCount(); |
| 143 | 136 | ||
| 144 | - // 9. 添加数据 | 137 | + // 9.获取近七日每日问答次数和近七日每日拒绝问答次数 |
| 138 | + List<Map<String, Object>> dailyCounts = airagLogMapper.getDailyCountForLast7Days(); | ||
| 139 | + List<Map<String, Object>> dailyRejectedCounts = airagLogMapper.getDailyRejectedCountForLast7Days(); | ||
| 140 | + | ||
| 141 | + | ||
| 142 | + // 10. 添加数据 | ||
| 145 | result.put("yesterdayCount", yesterdayCount); | 143 | result.put("yesterdayCount", yesterdayCount); |
| 146 | result.put("growthRate", Math.round(growthRate * 100.0) / 100.0); // 保留两位小数 | 144 | result.put("growthRate", Math.round(growthRate * 100.0) / 100.0); // 保留两位小数 |
| 147 | result.put("todayCount", todayCount); | 145 | result.put("todayCount", todayCount); |
| 148 | result.put("rejectedCount", rejectedCount); | 146 | result.put("rejectedCount", rejectedCount); |
| 149 | result.put("totalCount", totalCount); | 147 | result.put("totalCount", totalCount); |
| 150 | result.put("averageCount", averageCount); | 148 | result.put("averageCount", averageCount); |
| 151 | - result.put("buttonStats", buttonStats); | ||
| 152 | result.put("monthlyData", monthlyData); | 149 | result.put("monthlyData", monthlyData); |
| 150 | + result.put("dailyCounts", dailyCounts); | ||
| 151 | + result.put("dailyRejectedCounts", dailyRejectedCounts); | ||
| 152 | + | ||
| 153 | + return result; | ||
| 154 | + } | ||
| 155 | + | ||
| 156 | + @Override | ||
| 157 | + public List<Map<String, Object>> getButtonStats(String rangeType, String startTime, String endTime){ | ||
| 158 | + List<Map<String, Object>> buttonStats = airagLogMapper.getButtonRankList( | ||
| 159 | + rangeType, | ||
| 160 | + startTime, | ||
| 161 | + endTime | ||
| 162 | + ); | ||
| 163 | + return buttonStats; | ||
| 164 | + } | ||
| 165 | + | ||
| 166 | + | ||
| 167 | + @Override | ||
| 168 | + public Map<String, Object> getQuestionStatistics() { | ||
| 169 | + Map<String, Object> result = new HashMap<>(); | ||
| 170 | + | ||
| 171 | + // 1. 今日问题输入量 | ||
| 172 | + QueryWrapper<AiragLog> todayWrapper = new QueryWrapper<>(); | ||
| 173 | + todayWrapper.apply("DATE(create_time) = CURDATE()") | ||
| 174 | + .eq("code_type", 0); | ||
| 175 | + long todayCount = this.count(todayWrapper); | ||
| 176 | + | ||
| 177 | + // 2. 本周问题输入量 | ||
| 178 | + QueryWrapper<AiragLog> weekWrapper = new QueryWrapper<>(); | ||
| 179 | + weekWrapper.apply("YEARWEEK(create_time, 1) = YEARWEEK(CURDATE(), 1)") | ||
| 180 | + .eq("code_type", 0); | ||
| 181 | + long weekCount = this.count(weekWrapper); | ||
| 182 | + | ||
| 183 | + // 3. 本月问题输入量 | ||
| 184 | + QueryWrapper<AiragLog> monthWrapper = new QueryWrapper<>(); | ||
| 185 | + monthWrapper.apply("DATE_FORMAT(create_time, '%Y%m') = DATE_FORMAT(CURDATE(), '%Y%m')") | ||
| 186 | + .eq("code_type", 0); | ||
| 187 | + long monthCount = this.count(monthWrapper); | ||
| 188 | + | ||
| 189 | + // 4. 本年问题输入量 | ||
| 190 | + QueryWrapper<AiragLog> yearWrapper = new QueryWrapper<>(); | ||
| 191 | + yearWrapper.apply("YEAR(create_time) = YEAR(CURDATE())") | ||
| 192 | + .eq("code_type", 0); | ||
| 193 | + long yearCount = this.count(yearWrapper); | ||
| 194 | + | ||
| 195 | + // 5. 全部问题输入量 | ||
| 196 | + QueryWrapper<AiragLog> totalWrapper = new QueryWrapper<>(); | ||
| 197 | + totalWrapper.eq("code_type", 0); | ||
| 198 | + long totalCount = this.count(totalWrapper); | ||
| 199 | + | ||
| 200 | + // 6. 返回结果 | ||
| 201 | + result.put("todayCount", todayCount); | ||
| 202 | + result.put("weekCount", weekCount); | ||
| 203 | + result.put("monthCount", monthCount); | ||
| 204 | + result.put("yearCount", yearCount); | ||
| 205 | + result.put("totalCount", totalCount); | ||
| 153 | 206 | ||
| 154 | return result; | 207 | return result; |
| 155 | } | 208 | } |
-
请 注册 或 登录 后发表评论