98 lines
1.9 KiB
Java
98 lines
1.9 KiB
Java
package com.rj.scheduler;
|
|
|
|
import com.rj.service.IAudioManagementStatisticsService;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
import org.springframework.stereotype.Component;
|
|
|
|
import java.time.LocalDate;
|
|
|
|
/**
|
|
* 门店录音统计定时任务
|
|
*
|
|
* @author 李中华 ,spllzh
|
|
* @since 2025-08-07
|
|
*/
|
|
@Slf4j
|
|
@Component
|
|
public class AudioStatisticsScheduler {
|
|
|
|
@Autowired
|
|
private IAudioManagementStatisticsService audioStatisticsService;
|
|
|
|
/**
|
|
* 每天凌晨2点执行门店录音统计
|
|
* 统计昨天的录音数据
|
|
*/
|
|
@Scheduled(cron = "0 0 2 * * ?")
|
|
public void generateDailyAudioStatistics() {
|
|
try {
|
|
log.info("开始执行门店录音统计任务...");
|
|
|
|
LocalDate yesterday = LocalDate.now().minusDays(1);
|
|
int count = audioStatisticsService.generateStatisticsByDate(yesterday);
|
|
|
|
log.info("门店录音统计任务执行完成,统计日期:{},生成记录数:{}", yesterday, count);
|
|
} catch (Exception e) {
|
|
log.error("门店录音统计任务执行失败", e);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 手动触发统计任务(用于测试或补录数据)
|
|
* @param date 要统计的日期
|
|
* @return 生成的记录数
|
|
*/
|
|
public int manualGenerateStatistics(LocalDate date) {
|
|
try {
|
|
log.info("手动执行门店录音统计任务,统计日期:{}", date);
|
|
int count = audioStatisticsService.generateStatisticsByDate(date);
|
|
log.info("手动门店录音统计任务执行完成,统计日期:{},生成记录数:{}", date, count);
|
|
return count;
|
|
} catch (Exception e) {
|
|
log.error("手动门店录音统计任务执行失败,统计日期:{}", date, e);
|
|
throw e;
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|