diff --git a/HikariCP连接池问题分析.md b/HikariCP连接池问题分析.md index 19b0347..dcf8125 100644 --- a/HikariCP连接池问题分析.md +++ b/HikariCP连接池问题分析.md @@ -140,5 +140,6 @@ hikari: + diff --git a/src/main/java/com/rj/controller/AudioStatisticsController.java b/src/main/java/com/rj/controller/AudioStatisticsController.java index 67a05c5..f18eb94 100644 --- a/src/main/java/com/rj/controller/AudioStatisticsController.java +++ b/src/main/java/com/rj/controller/AudioStatisticsController.java @@ -95,7 +95,7 @@ public class AudioStatisticsController { * 查询指定销售人员的统计数据 */ @Operation(summary = "查询指定销售人员的统计数据", description = "根据销售人员ID或电话号码查询指定日期范围内的录音统计数据") - @GetMapping("/sales") + @PostMapping("/sales") public Result getStatisticsBySales( @Parameter(description = "销售人员ID") @RequestParam(required = false) String salesId, @@ -141,27 +141,7 @@ public class AudioStatisticsController { } } - /** - * 查询指定项目的统计数据 - */ - @Operation(summary = "查询指定项目的统计数据", description = "查询指定项目在指定日期范围内的录音统计数据") - @GetMapping("/project/{projectId}") - public Result getStatisticsByProject( - @Parameter(description = "项目ID") - @PathVariable String projectId, - @Parameter(description = "开始日期,格式:yyyy-MM-dd") - @RequestParam @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate startDate, - @Parameter(description = "结束日期,格式:yyyy-MM-dd") - @RequestParam @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate endDate) { - try { - List statistics = audioStatisticsService.getStatisticsByProject(projectId, startDate, endDate); - Result result = Result.ok(statistics); - result.setMsg("查询成功"); - return result; - } catch (Exception e) { - return Result.error("查询失败:" + e.getMessage()); - } - } + /** * 查询指定日期的统计数据 diff --git a/src/main/java/com/rj/entity/AudioManagementStatistics.java b/src/main/java/com/rj/entity/AudioManagementStatistics.java index 8182702..966a4e2 100644 --- a/src/main/java/com/rj/entity/AudioManagementStatistics.java +++ b/src/main/java/com/rj/entity/AudioManagementStatistics.java @@ -61,42 +61,18 @@ public class AudioManagementStatistics implements Serializable { @TableField("sales_id") private String salesId; - @Schema(description = "销售人员姓名") - @TableField("sales_name") - private String salesName; - @Schema(description = "销售人员录音总时长(分钟)") - @TableField("sales_total_duration") + @TableField("personal_total_duration") private Long salesTotalDuration; @Schema(description = "销售人员录音数量") - @TableField("sales_recording_count") + @TableField("personal_recording_count") private Integer salesRecordingCount; @Schema(description = "销售人员录音平均时长(分钟)") - @TableField("sales_avg_duration") + @TableField("personal_avg_duration") private BigDecimal salesAvgDuration; - @Schema(description = "项目ID") - @TableField("project_id") - private String projectId; - - @Schema(description = "项目名称") - @TableField("project_name") - private String projectName; - - @Schema(description = "项目录音总时长(分钟)") - @TableField("project_total_duration") - private Long projectTotalDuration; - - @Schema(description = "项目录音数量") - @TableField("project_recording_count") - private Integer projectRecordingCount; - - @Schema(description = "项目录音平均时长(分钟)") - @TableField("project_avg_duration") - private BigDecimal projectAvgDuration; - @Schema(description = "统计日期") @TableField("statistics_date") private LocalDate statisticsDate; diff --git a/src/main/java/com/rj/example/AudioStatisticsExample.java b/src/main/java/com/rj/example/AudioStatisticsExample.java index d71efe8..4493fde 100644 --- a/src/main/java/com/rj/example/AudioStatisticsExample.java +++ b/src/main/java/com/rj/example/AudioStatisticsExample.java @@ -124,37 +124,6 @@ public class AudioStatisticsExample { } } - /** - * 示例5:查询指定项目的统计数据 - */ - public void exampleQueryProjectStatistics() { - System.out.println("=== 示例5:查询指定项目的统计数据 ==="); - - String projectId = "project001"; // 假设项目ID - LocalDate startDate = LocalDate.now().minusDays(30); // 最近30天 - LocalDate endDate = LocalDate.now().minusDays(1); - - List statistics = audioStatisticsService.getStatisticsByProject(projectId, startDate, endDate); - - System.out.println("项目ID: " + projectId); - System.out.println("查询到统计记录数: " + statistics.size()); - - // 计算该项目的总统计 - long totalDuration = 0; - int totalCount = 0; - - for (AudioManagementStatistics stat : statistics) { - totalDuration += stat.getProjectTotalDuration(); - totalCount += stat.getProjectRecordingCount(); - } - - System.out.println("项目总录音时长: " + totalDuration + "秒"); - System.out.println("项目总录音数量: " + totalCount); - if (totalCount > 0) { - System.out.println("项目平均录音时长: " + (totalDuration / totalCount) + "秒"); - } - } - /** * 示例6:批量生成历史统计数据 */ @@ -179,37 +148,5 @@ public class AudioStatisticsExample { System.out.println("批量生成完成,总记录数: " + totalCount); } - /** - * 运行所有示例 - */ - public void runAllExamples() { - System.out.println("开始运行门店录音统计功能示例..."); - System.out.println(); - - try { - exampleGenerateStatistics(); - System.out.println(); - - exampleQueryRecentStatistics(); - System.out.println(); - - exampleQueryDealershipStatistics(); - System.out.println(); - - exampleQuerySalesStatistics(); - System.out.println(); - - exampleQueryProjectStatistics(); - System.out.println(); - - exampleBatchGenerateStatistics(); - System.out.println(); - - } catch (Exception e) { - System.err.println("示例运行失败: " + e.getMessage()); - e.printStackTrace(); - } - - System.out.println("示例运行完成!"); - } + } diff --git a/src/main/java/com/rj/mapper/AudioManagementStatisticsMapper.java b/src/main/java/com/rj/mapper/AudioManagementStatisticsMapper.java index 075810c..05acf5a 100644 --- a/src/main/java/com/rj/mapper/AudioManagementStatisticsMapper.java +++ b/src/main/java/com/rj/mapper/AudioManagementStatisticsMapper.java @@ -46,7 +46,6 @@ public interface AudioManagementStatisticsMapper extends BaseMapper> getSalesStatisticsByDate(@Param("date") LocalDate date); - /** - * 按项目统计指定日期的录音数据 - * @param date 统计日期 - * @return 项目统计结果列表 - */ - @Select("SELECT " + - "project_id, " + - "project_name, " + - "SUM(duration) as total_duration_minutes, " + - "COUNT(*) as recording_count, " + - "AVG(duration) as avg_duration_minutes " + - "FROM audio_management " + - "WHERE DATE(recording_time) = #{date} " + - "AND project_id IS NOT NULL " + - "AND project_id != '' " + - "GROUP BY project_id, project_name") - List> getProjectStatisticsByDate(@Param("date") LocalDate date); - /** * 检查指定日期的统计数据是否已存在 * @param date 统计日期 @@ -99,12 +80,11 @@ public interface AudioManagementStatisticsMapper extends BaseMapper 0 THEN " + - " ROUND(SUM(sales_total_duration) / SUM(sales_recording_count), 2) " + + " WHEN SUM(personal_recording_count) > 0 THEN " + + " ROUND(SUM(personal_total_duration) / SUM(personal_recording_count), 2) " + " ELSE 0 " + "END as avg_duration " + "FROM audio_management_statistics " + diff --git a/src/main/java/com/rj/service/IAudioManagementStatisticsService.java b/src/main/java/com/rj/service/IAudioManagementStatisticsService.java index 1c8cd7a..52d914f 100644 --- a/src/main/java/com/rj/service/IAudioManagementStatisticsService.java +++ b/src/main/java/com/rj/service/IAudioManagementStatisticsService.java @@ -64,13 +64,4 @@ public interface IAudioManagementStatisticsService extends IService getStatisticsBySales(String salesId, String salesPhone, LocalDate startDate, LocalDate endDate); - - /** - * 查询指定项目的统计数据 - * @param projectId 项目ID - * @param startDate 开始日期 - * @param endDate 结束日期 - * @return 统计记录列表 - */ - List getStatisticsByProject(String projectId, LocalDate startDate, LocalDate endDate); } diff --git a/src/main/java/com/rj/service/impl/AudioManagementStatisticsServiceImpl.java b/src/main/java/com/rj/service/impl/AudioManagementStatisticsServiceImpl.java index c8d543e..24f6d22 100644 --- a/src/main/java/com/rj/service/impl/AudioManagementStatisticsServiceImpl.java +++ b/src/main/java/com/rj/service/impl/AudioManagementStatisticsServiceImpl.java @@ -44,9 +44,6 @@ public class AudioManagementStatisticsServiceImpl extends ServiceImpl> salesStatsList = baseMapper.getSalesStatisticsByDate(date); - // 查询该日期的项目录音统计数据 - List> projectStatsList = baseMapper.getProjectStatisticsByDate(date); - int count = 0; // 处理门店统计数据 @@ -102,9 +99,6 @@ public class AudioManagementStatisticsServiceImpl extends ServiceImpl projectStat = findProjectStatByDealership(projectStatsList, dealershipIdForProject); - - if (projectStat != null) { - // 设置项目信息 - Object projectIdObj = projectStat.get("project_id"); - statistics.setProjectId(projectIdObj != null ? projectIdObj.toString() : ""); - - Object projectNameObj = projectStat.get("project_name"); - statistics.setProjectName(projectNameObj != null ? projectNameObj.toString() : "未知项目"); - - // 设置项目录音统计数据 - Object projectTotalDurationObj = projectStat.get("total_duration_minutes"); - if (projectTotalDurationObj != null) { - statistics.setProjectTotalDuration(Long.valueOf(projectTotalDurationObj.toString())); - } else { - statistics.setProjectTotalDuration(0L); - } - - Object projectRecordingCountObj = projectStat.get("recording_count"); - if (projectRecordingCountObj != null) { - statistics.setProjectRecordingCount(Integer.valueOf(projectRecordingCountObj.toString())); - } else { - statistics.setProjectRecordingCount(0); - } - - // 计算项目平均时长 - if (statistics.getProjectRecordingCount() > 0 && statistics.getProjectTotalDuration() > 0) { - BigDecimal projectAvgDuration = BigDecimal.valueOf(statistics.getProjectTotalDuration()) - .divide(BigDecimal.valueOf(statistics.getProjectRecordingCount()), 2, RoundingMode.HALF_UP); - statistics.setProjectAvgDuration(projectAvgDuration); - } else { - statistics.setProjectAvgDuration(BigDecimal.ZERO); - } - } else { - // 如果没有找到对应的项目数据,设置为空 - statistics.setProjectId(""); - statistics.setProjectName(""); - statistics.setProjectTotalDuration(0L); - statistics.setProjectRecordingCount(0); - statistics.setProjectAvgDuration(BigDecimal.ZERO); - } - // 设置统计日期和时间 statistics.setStatisticsDate(date); statistics.setCreatedAt(LocalDateTime.now()); @@ -210,22 +159,6 @@ public class AudioManagementStatisticsServiceImpl extends ServiceImpl findProjectStatByDealership(List> projectStatsList, String dealershipId) { - // 这里需要根据业务逻辑来确定门店和项目的对应关系 - // 由于原始数据中可能没有直接的关联关系,这里返回第一个项目数据作为示例 - // 实际使用时需要根据具体的业务逻辑来调整 - if (!projectStatsList.isEmpty()) { - return projectStatsList.get(0); - } - return null; - } - @Override public int generateYesterdayStatistics() { LocalDate yesterday = LocalDate.now().minusDays(1); @@ -302,7 +235,6 @@ public class AudioManagementStatisticsServiceImpl extends ServiceImpl getStatisticsByProject(String projectId, LocalDate startDate, LocalDate endDate) { - LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); - queryWrapper.eq(AudioManagementStatistics::getProjectId, projectId) - .between(AudioManagementStatistics::getStatisticsDate, startDate, endDate) - .orderByAsc(AudioManagementStatistics::getStatisticsDate); - return list(queryWrapper); - } } diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 2517dac..e69de29 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1 +0,0 @@ -spring.application.name=Langchain4j-cst20250803 diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 6909f42..247ad43 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -224,10 +224,10 @@ springdoc: swagger: api: - base-url: http://localhost:8090 + base-url: http://localhost:8091 # http://localhost:9060/swagger-ui/index.html?urls.primaryName=public-api server: - port: 8090 + port: 8091 # Dify API 配置 dify: diff --git a/src/test/java/com/rj/service/AudioManagementStatisticsServiceTest.java b/src/test/java/com/rj/service/AudioManagementStatisticsServiceTest.java index 39e2fdb..55a557f 100644 --- a/src/test/java/com/rj/service/AudioManagementStatisticsServiceTest.java +++ b/src/test/java/com/rj/service/AudioManagementStatisticsServiceTest.java @@ -91,33 +91,11 @@ public class AudioManagementStatisticsServiceTest { // 打印销售人员统计信息 for (AudioManagementStatistics stat : statistics) { - System.out.println("销售人员: " + stat.getSalesName() + + System.out.println("销售人员ID: " + stat.getSalesId() + ", 日期: " + stat.getStatisticsDate() + ", 录音数量: " + stat.getSalesRecordingCount() + ", 总时长: " + stat.getSalesTotalDuration() + "秒" + ", 平均时长: " + stat.getSalesAvgDuration() + "秒"); } } - - @Test - public void testGetStatisticsByProject() { - // 测试查询指定项目的统计数据 - String projectId = "project001"; // 假设项目ID - LocalDate startDate = LocalDate.now().minusDays(30); // 最近30天 - LocalDate endDate = LocalDate.now().minusDays(1); - - List statistics = audioStatisticsService.getStatisticsByProject(projectId, startDate, endDate); - - assertNotNull(statistics, "统计列表不应该为null"); - System.out.println("查询到项目统计记录数: " + statistics.size()); - - // 打印项目统计信息 - for (AudioManagementStatistics stat : statistics) { - System.out.println("项目: " + stat.getProjectName() + - ", 日期: " + stat.getStatisticsDate() + - ", 录音数量: " + stat.getProjectRecordingCount() + - ", 总时长: " + stat.getProjectTotalDuration() + "秒" + - ", 平均时长: " + stat.getProjectAvgDuration() + "秒"); - } - } }