修改统计单位为分钟
This commit is contained in:
2
pom.xml
2
pom.xml
@@ -10,7 +10,7 @@
|
||||
</parent>
|
||||
<groupId>com.cst</groupId>
|
||||
<artifactId>AIDriverEEBackend</artifactId>
|
||||
<version>1.251130.7-SNAPSHOT</version>
|
||||
<version>1.260131.1-SNAPSHOT</version>
|
||||
<name>Langchain4j-rj</name>
|
||||
<description>Langchain4j-rj20250803</description>
|
||||
<url/>
|
||||
|
||||
@@ -6,7 +6,7 @@ import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* 应用配置类
|
||||
*
|
||||
*
|
||||
* @author Auto Generated
|
||||
* @since 2025-01-01
|
||||
*/
|
||||
@@ -14,10 +14,26 @@ import org.springframework.context.annotation.Configuration;
|
||||
@Configuration
|
||||
@ConfigurationProperties(prefix = "app")
|
||||
public class AppConfig {
|
||||
|
||||
|
||||
/**
|
||||
* 应用时区,默认为 Asia/Shanghai
|
||||
*/
|
||||
private String timezone = "Asia/Shanghai";
|
||||
|
||||
/**
|
||||
* 调度器配置
|
||||
*/
|
||||
private SchedulerConfig scheduler = new SchedulerConfig();
|
||||
|
||||
/**
|
||||
* 调度器配置类
|
||||
*/
|
||||
@Data
|
||||
public static class SchedulerConfig {
|
||||
/**
|
||||
* 是否启用调度器,默认为 true
|
||||
*/
|
||||
private boolean start = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -29,9 +29,9 @@ public interface AudioManagementStatisticsMapper extends BaseMapper<AudioManagem
|
||||
@Select("SELECT " +
|
||||
"dealership_id, " +
|
||||
"dealership_name, " +
|
||||
"SUM(duration * 60) as total_duration_seconds, " +
|
||||
"SUM(duration) as total_duration_minutes, " +
|
||||
"COUNT(*) as recording_count, " +
|
||||
"AVG(duration * 60) as avg_duration_seconds " +
|
||||
"AVG(duration) as avg_duration_minutes " +
|
||||
"FROM audio_management " +
|
||||
"WHERE DATE(recording_time) = #{date} " +
|
||||
"AND dealership_id IS NOT NULL " +
|
||||
@@ -47,9 +47,9 @@ public interface AudioManagementStatisticsMapper extends BaseMapper<AudioManagem
|
||||
@Select("SELECT " +
|
||||
"sales_id, " +
|
||||
"sales_name, " +
|
||||
"SUM(duration * 60) as total_duration_seconds, " +
|
||||
"SUM(duration) as total_duration_minutes, " +
|
||||
"COUNT(*) as recording_count, " +
|
||||
"AVG(duration * 60) as avg_duration_seconds " +
|
||||
"AVG(duration) as avg_duration_minutes " +
|
||||
"FROM audio_management " +
|
||||
"WHERE DATE(recording_time) = #{date} " +
|
||||
"AND sales_id IS NOT NULL " +
|
||||
@@ -65,9 +65,9 @@ public interface AudioManagementStatisticsMapper extends BaseMapper<AudioManagem
|
||||
@Select("SELECT " +
|
||||
"project_id, " +
|
||||
"project_name, " +
|
||||
"SUM(duration * 60) as total_duration_seconds, " +
|
||||
"SUM(duration) as total_duration_minutes, " +
|
||||
"COUNT(*) as recording_count, " +
|
||||
"AVG(duration * 60) as avg_duration_seconds " +
|
||||
"AVG(duration) as avg_duration_minutes " +
|
||||
"FROM audio_management " +
|
||||
"WHERE DATE(recording_time) = #{date} " +
|
||||
"AND project_id IS NOT NULL " +
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.rj.scheduler;
|
||||
|
||||
import com.rj.config.AppConfig;
|
||||
import com.rj.service.IAudioManagementStatisticsService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -10,7 +11,7 @@ import java.time.LocalDate;
|
||||
|
||||
/**
|
||||
* 门店录音统计定时任务
|
||||
*
|
||||
*
|
||||
* @author 李中华 ,spllzh
|
||||
* @since 2025-08-07
|
||||
*/
|
||||
@@ -21,18 +22,27 @@ public class AudioStatisticsScheduler {
|
||||
@Autowired
|
||||
private IAudioManagementStatisticsService audioStatisticsService;
|
||||
|
||||
@Autowired
|
||||
private AppConfig appConfig;
|
||||
|
||||
/**
|
||||
* 每天凌晨2点执行门店录音统计
|
||||
* 统计昨天的录音数据
|
||||
*/
|
||||
// @Scheduled(cron = "0 0 2 * * ?")
|
||||
@Scheduled(cron = "0 0 2 * * ?")
|
||||
public void generateDailyAudioStatistics() {
|
||||
try {
|
||||
// 检查调度器是否启用
|
||||
if (!appConfig.getScheduler().isStart()) {
|
||||
log.info("调度器未启用,跳过门店录音统计任务执行");
|
||||
return;
|
||||
}
|
||||
|
||||
log.info("开始执行门店录音统计任务...");
|
||||
|
||||
|
||||
LocalDate yesterday = LocalDate.now().minusDays(1);
|
||||
int count = audioStatisticsService.generateStatisticsByDate(yesterday);
|
||||
|
||||
|
||||
log.info("门店录音统计任务执行完成,统计日期:{},生成记录数:{}", yesterday, count);
|
||||
} catch (Exception e) {
|
||||
log.error("门店录音统计任务执行失败", e);
|
||||
|
||||
@@ -64,7 +64,7 @@ public class AudioManagementStatisticsServiceImpl extends ServiceImpl<AudioManag
|
||||
statistics.setDealershipName(dealershipNameObj != null ? dealershipNameObj.toString() : "未知门店");
|
||||
|
||||
// 设置门店录音统计数据
|
||||
Object totalDurationObj = stat.get("total_duration_seconds");
|
||||
Object totalDurationObj = stat.get("total_duration_minutes");
|
||||
if (totalDurationObj != null) {
|
||||
statistics.setDealershipTotalDuration(Long.valueOf(totalDurationObj.toString()));
|
||||
} else {
|
||||
@@ -100,7 +100,7 @@ public class AudioManagementStatisticsServiceImpl extends ServiceImpl<AudioManag
|
||||
statistics.setSalesName(salesNameObj != null ? salesNameObj.toString() : "未知销售");
|
||||
|
||||
// 设置销售人员录音统计数据
|
||||
Object salesTotalDurationObj = salesStat.get("total_duration_seconds");
|
||||
Object salesTotalDurationObj = salesStat.get("total_duration_minutes");
|
||||
if (salesTotalDurationObj != null) {
|
||||
statistics.setSalesTotalDuration(Long.valueOf(salesTotalDurationObj.toString()));
|
||||
} else {
|
||||
@@ -144,7 +144,7 @@ public class AudioManagementStatisticsServiceImpl extends ServiceImpl<AudioManag
|
||||
statistics.setProjectName(projectNameObj != null ? projectNameObj.toString() : "未知项目");
|
||||
|
||||
// 设置项目录音统计数据
|
||||
Object projectTotalDurationObj = projectStat.get("total_duration_seconds");
|
||||
Object projectTotalDurationObj = projectStat.get("total_duration_minutes");
|
||||
if (projectTotalDurationObj != null) {
|
||||
statistics.setProjectTotalDuration(Long.valueOf(projectTotalDurationObj.toString()));
|
||||
} else {
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
# 应用时区配置
|
||||
app:
|
||||
timezone: Asia/Shanghai
|
||||
|
||||
scheduler:
|
||||
start: true
|
||||
# DashScope API配置
|
||||
dashscope:
|
||||
api:
|
||||
|
||||
Reference in New Issue
Block a user