录音统计
This commit is contained in:
173
src/main/java/com/rj/controller/AudioStatisticsController.java
Normal file
173
src/main/java/com/rj/controller/AudioStatisticsController.java
Normal file
@@ -0,0 +1,173 @@
|
||||
package com.rj.controller;
|
||||
|
||||
import com.rj.common.Result;
|
||||
import com.rj.entity.AudioManagementStatistics;
|
||||
import com.rj.scheduler.AudioStatisticsScheduler;
|
||||
import com.rj.service.IAudioManagementStatisticsService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 门店录音统计控制器
|
||||
*
|
||||
* @author 李中华 ,spllzh
|
||||
* @since 2025-08-07
|
||||
*/
|
||||
@Tag(name = "门店录音统计", description = "门店录音统计相关接口")
|
||||
@RestController
|
||||
@RequestMapping("/api/audio-statistics")
|
||||
public class AudioStatisticsController {
|
||||
|
||||
@Autowired
|
||||
private IAudioManagementStatisticsService audioStatisticsService;
|
||||
|
||||
@Autowired
|
||||
private AudioStatisticsScheduler audioStatisticsScheduler;
|
||||
|
||||
/**
|
||||
* 手动生成指定日期的统计数据
|
||||
*/
|
||||
@Operation(summary = "手动生成指定日期的统计数据", description = "手动触发指定日期的门店录音统计")
|
||||
@PostMapping("/generate")
|
||||
public Result generateStatistics(
|
||||
@Parameter(description = "统计日期,格式:yyyy-MM-dd")
|
||||
@RequestParam @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate date) {
|
||||
try {
|
||||
int count = audioStatisticsScheduler.manualGenerateStatistics(date);
|
||||
Result result = Result.ok(count);
|
||||
result.setMsg("统计生成成功");
|
||||
return result;
|
||||
} catch (Exception e) {
|
||||
return Result.error("统计生成失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询指定日期范围的统计数据
|
||||
*/
|
||||
@Operation(summary = "查询指定日期范围的统计数据", description = "查询指定日期范围内的门店录音统计数据")
|
||||
@GetMapping("/range")
|
||||
public Result getStatisticsByDateRange(
|
||||
@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<AudioManagementStatistics> statistics = audioStatisticsService.getStatisticsByDateRange(startDate, endDate);
|
||||
Result result = Result.ok(statistics);
|
||||
result.setMsg("查询成功");
|
||||
return result;
|
||||
} catch (Exception e) {
|
||||
return Result.error("查询失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询指定门店的统计数据
|
||||
*/
|
||||
@Operation(summary = "查询指定门店的统计数据", description = "查询指定门店在指定日期范围内的录音统计数据")
|
||||
@GetMapping("/dealership/{dealershipId}")
|
||||
public Result getStatisticsByDealership(
|
||||
@Parameter(description = "门店ID")
|
||||
@PathVariable Long dealershipId,
|
||||
@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<AudioManagementStatistics> statistics = audioStatisticsService.getStatisticsByDealership(dealershipId, startDate, endDate);
|
||||
Result result = Result.ok(statistics);
|
||||
result.setMsg("查询成功");
|
||||
return result;
|
||||
} catch (Exception e) {
|
||||
return Result.error("查询失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询指定销售人员的统计数据
|
||||
*/
|
||||
@Operation(summary = "查询指定销售人员的统计数据", description = "查询指定销售人员在指定日期范围内的录音统计数据")
|
||||
@GetMapping("/sales/{salesId}")
|
||||
public Result getStatisticsBySales(
|
||||
@Parameter(description = "销售人员ID")
|
||||
@PathVariable String salesId,
|
||||
@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<AudioManagementStatistics> statistics = audioStatisticsService.getStatisticsBySales(salesId, startDate, endDate);
|
||||
Result result = Result.ok(statistics);
|
||||
result.setMsg("查询成功");
|
||||
return result;
|
||||
} catch (Exception e) {
|
||||
return Result.error("查询失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询指定项目的统计数据
|
||||
*/
|
||||
@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<AudioManagementStatistics> statistics = audioStatisticsService.getStatisticsByProject(projectId, startDate, endDate);
|
||||
Result result = Result.ok(statistics);
|
||||
result.setMsg("查询成功");
|
||||
return result;
|
||||
} catch (Exception e) {
|
||||
return Result.error("查询失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询指定日期的统计数据
|
||||
*/
|
||||
@Operation(summary = "查询指定日期的统计数据", description = "查询指定日期的所有门店录音统计数据")
|
||||
@GetMapping("/date/{date}")
|
||||
public Result getStatisticsByDate(
|
||||
@Parameter(description = "统计日期,格式:yyyy-MM-dd")
|
||||
@PathVariable @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate date) {
|
||||
try {
|
||||
List<AudioManagementStatistics> statistics = audioStatisticsService.getStatisticsByDateRange(date, date);
|
||||
Result result = Result.ok(statistics);
|
||||
result.setMsg("查询成功");
|
||||
return result;
|
||||
} catch (Exception e) {
|
||||
return Result.error("查询失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取统计概览(最近7天)
|
||||
*/
|
||||
@Operation(summary = "获取统计概览", description = "获取最近7天的门店录音统计概览")
|
||||
@GetMapping("/overview")
|
||||
public Result getStatisticsOverview() {
|
||||
try {
|
||||
LocalDate endDate = LocalDate.now().minusDays(1); // 昨天
|
||||
LocalDate startDate = endDate.minusDays(6); // 7天前
|
||||
List<AudioManagementStatistics> statistics = audioStatisticsService.getStatisticsByDateRange(startDate, endDate);
|
||||
Result result = Result.ok(statistics);
|
||||
result.setMsg("查询成功");
|
||||
return result;
|
||||
} catch (Exception e) {
|
||||
return Result.error("查询失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user