修改统计单位为分钟

This commit is contained in:
zhonghua.li
2026-02-03 21:42:00 +08:00
parent aca05abd73
commit ec16419f1f
6 changed files with 44 additions and 17 deletions

View File

@@ -10,7 +10,7 @@
</parent> </parent>
<groupId>com.cst</groupId> <groupId>com.cst</groupId>
<artifactId>AIDriverEEBackend</artifactId> <artifactId>AIDriverEEBackend</artifactId>
<version>1.251130.7-SNAPSHOT</version> <version>1.260131.1-SNAPSHOT</version>
<name>Langchain4j-rj</name> <name>Langchain4j-rj</name>
<description>Langchain4j-rj20250803</description> <description>Langchain4j-rj20250803</description>
<url/> <url/>

View File

@@ -6,7 +6,7 @@ import org.springframework.context.annotation.Configuration;
/** /**
* 应用配置类 * 应用配置类
* *
* @author Auto Generated * @author Auto Generated
* @since 2025-01-01 * @since 2025-01-01
*/ */
@@ -14,10 +14,26 @@ import org.springframework.context.annotation.Configuration;
@Configuration @Configuration
@ConfigurationProperties(prefix = "app") @ConfigurationProperties(prefix = "app")
public class AppConfig { public class AppConfig {
/** /**
* 应用时区,默认为 Asia/Shanghai * 应用时区,默认为 Asia/Shanghai
*/ */
private String timezone = "Asia/Shanghai"; private String timezone = "Asia/Shanghai";
/**
* 调度器配置
*/
private SchedulerConfig scheduler = new SchedulerConfig();
/**
* 调度器配置类
*/
@Data
public static class SchedulerConfig {
/**
* 是否启用调度器,默认为 true
*/
private boolean start = true;
}
} }

View File

@@ -29,9 +29,9 @@ public interface AudioManagementStatisticsMapper extends BaseMapper<AudioManagem
@Select("SELECT " + @Select("SELECT " +
"dealership_id, " + "dealership_id, " +
"dealership_name, " + "dealership_name, " +
"SUM(duration * 60) as total_duration_seconds, " + "SUM(duration) as total_duration_minutes, " +
"COUNT(*) as recording_count, " + "COUNT(*) as recording_count, " +
"AVG(duration * 60) as avg_duration_seconds " + "AVG(duration) as avg_duration_minutes " +
"FROM audio_management " + "FROM audio_management " +
"WHERE DATE(recording_time) = #{date} " + "WHERE DATE(recording_time) = #{date} " +
"AND dealership_id IS NOT NULL " + "AND dealership_id IS NOT NULL " +
@@ -47,9 +47,9 @@ public interface AudioManagementStatisticsMapper extends BaseMapper<AudioManagem
@Select("SELECT " + @Select("SELECT " +
"sales_id, " + "sales_id, " +
"sales_name, " + "sales_name, " +
"SUM(duration * 60) as total_duration_seconds, " + "SUM(duration) as total_duration_minutes, " +
"COUNT(*) as recording_count, " + "COUNT(*) as recording_count, " +
"AVG(duration * 60) as avg_duration_seconds " + "AVG(duration) as avg_duration_minutes " +
"FROM audio_management " + "FROM audio_management " +
"WHERE DATE(recording_time) = #{date} " + "WHERE DATE(recording_time) = #{date} " +
"AND sales_id IS NOT NULL " + "AND sales_id IS NOT NULL " +
@@ -65,9 +65,9 @@ public interface AudioManagementStatisticsMapper extends BaseMapper<AudioManagem
@Select("SELECT " + @Select("SELECT " +
"project_id, " + "project_id, " +
"project_name, " + "project_name, " +
"SUM(duration * 60) as total_duration_seconds, " + "SUM(duration) as total_duration_minutes, " +
"COUNT(*) as recording_count, " + "COUNT(*) as recording_count, " +
"AVG(duration * 60) as avg_duration_seconds " + "AVG(duration) as avg_duration_minutes " +
"FROM audio_management " + "FROM audio_management " +
"WHERE DATE(recording_time) = #{date} " + "WHERE DATE(recording_time) = #{date} " +
"AND project_id IS NOT NULL " + "AND project_id IS NOT NULL " +

View File

@@ -1,5 +1,6 @@
package com.rj.scheduler; package com.rj.scheduler;
import com.rj.config.AppConfig;
import com.rj.service.IAudioManagementStatisticsService; import com.rj.service.IAudioManagementStatisticsService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@@ -10,7 +11,7 @@ import java.time.LocalDate;
/** /**
* 门店录音统计定时任务 * 门店录音统计定时任务
* *
* @author 李中华 ,spllzh * @author 李中华 ,spllzh
* @since 2025-08-07 * @since 2025-08-07
*/ */
@@ -21,18 +22,27 @@ public class AudioStatisticsScheduler {
@Autowired @Autowired
private IAudioManagementStatisticsService audioStatisticsService; private IAudioManagementStatisticsService audioStatisticsService;
@Autowired
private AppConfig appConfig;
/** /**
* 每天凌晨2点执行门店录音统计 * 每天凌晨2点执行门店录音统计
* 统计昨天的录音数据 * 统计昨天的录音数据
*/ */
// @Scheduled(cron = "0 0 2 * * ?") @Scheduled(cron = "0 0 2 * * ?")
public void generateDailyAudioStatistics() { public void generateDailyAudioStatistics() {
try { try {
// 检查调度器是否启用
if (!appConfig.getScheduler().isStart()) {
log.info("调度器未启用,跳过门店录音统计任务执行");
return;
}
log.info("开始执行门店录音统计任务..."); log.info("开始执行门店录音统计任务...");
LocalDate yesterday = LocalDate.now().minusDays(1); LocalDate yesterday = LocalDate.now().minusDays(1);
int count = audioStatisticsService.generateStatisticsByDate(yesterday); int count = audioStatisticsService.generateStatisticsByDate(yesterday);
log.info("门店录音统计任务执行完成,统计日期:{},生成记录数:{}", yesterday, count); log.info("门店录音统计任务执行完成,统计日期:{},生成记录数:{}", yesterday, count);
} catch (Exception e) { } catch (Exception e) {
log.error("门店录音统计任务执行失败", e); log.error("门店录音统计任务执行失败", e);

View File

@@ -64,7 +64,7 @@ public class AudioManagementStatisticsServiceImpl extends ServiceImpl<AudioManag
statistics.setDealershipName(dealershipNameObj != null ? dealershipNameObj.toString() : "未知门店"); statistics.setDealershipName(dealershipNameObj != null ? dealershipNameObj.toString() : "未知门店");
// 设置门店录音统计数据 // 设置门店录音统计数据
Object totalDurationObj = stat.get("total_duration_seconds"); Object totalDurationObj = stat.get("total_duration_minutes");
if (totalDurationObj != null) { if (totalDurationObj != null) {
statistics.setDealershipTotalDuration(Long.valueOf(totalDurationObj.toString())); statistics.setDealershipTotalDuration(Long.valueOf(totalDurationObj.toString()));
} else { } else {
@@ -100,7 +100,7 @@ public class AudioManagementStatisticsServiceImpl extends ServiceImpl<AudioManag
statistics.setSalesName(salesNameObj != null ? salesNameObj.toString() : "未知销售"); statistics.setSalesName(salesNameObj != null ? salesNameObj.toString() : "未知销售");
// 设置销售人员录音统计数据 // 设置销售人员录音统计数据
Object salesTotalDurationObj = salesStat.get("total_duration_seconds"); Object salesTotalDurationObj = salesStat.get("total_duration_minutes");
if (salesTotalDurationObj != null) { if (salesTotalDurationObj != null) {
statistics.setSalesTotalDuration(Long.valueOf(salesTotalDurationObj.toString())); statistics.setSalesTotalDuration(Long.valueOf(salesTotalDurationObj.toString()));
} else { } else {
@@ -144,7 +144,7 @@ public class AudioManagementStatisticsServiceImpl extends ServiceImpl<AudioManag
statistics.setProjectName(projectNameObj != null ? projectNameObj.toString() : "未知项目"); statistics.setProjectName(projectNameObj != null ? projectNameObj.toString() : "未知项目");
// 设置项目录音统计数据 // 设置项目录音统计数据
Object projectTotalDurationObj = projectStat.get("total_duration_seconds"); Object projectTotalDurationObj = projectStat.get("total_duration_minutes");
if (projectTotalDurationObj != null) { if (projectTotalDurationObj != null) {
statistics.setProjectTotalDuration(Long.valueOf(projectTotalDurationObj.toString())); statistics.setProjectTotalDuration(Long.valueOf(projectTotalDurationObj.toString()));
} else { } else {

View File

@@ -2,7 +2,8 @@
# 应用时区配置 # 应用时区配置
app: app:
timezone: Asia/Shanghai timezone: Asia/Shanghai
scheduler:
start: true
# DashScope API配置 # DashScope API配置
dashscope: dashscope:
api: api: