录音时长统计修改
This commit is contained in:
@@ -44,9 +44,6 @@ public class AudioManagementStatisticsServiceImpl extends ServiceImpl<AudioManag
|
||||
// 查询该日期的销售人员录音统计数据
|
||||
List<Map<String, Object>> salesStatsList = baseMapper.getSalesStatisticsByDate(date);
|
||||
|
||||
// 查询该日期的项目录音统计数据
|
||||
List<Map<String, Object>> projectStatsList = baseMapper.getProjectStatisticsByDate(date);
|
||||
|
||||
int count = 0;
|
||||
|
||||
// 处理门店统计数据
|
||||
@@ -102,9 +99,6 @@ public class AudioManagementStatisticsServiceImpl extends ServiceImpl<AudioManag
|
||||
Object salesIdObj = salesStat.get("sales_id");
|
||||
statistics.setSalesId(salesIdObj != null ? salesIdObj.toString() : "");
|
||||
|
||||
Object salesNameObj = salesStat.get("sales_name");
|
||||
statistics.setSalesName(salesNameObj != null ? salesNameObj.toString() : "未知销售");
|
||||
|
||||
// 设置销售人员录音统计数据
|
||||
Object salesTotalDurationObj = salesStat.get("total_duration_minutes");
|
||||
if (salesTotalDurationObj != null) {
|
||||
@@ -131,56 +125,11 @@ public class AudioManagementStatisticsServiceImpl extends ServiceImpl<AudioManag
|
||||
} else {
|
||||
// 如果没有找到对应的销售人员数据,设置为空
|
||||
statistics.setSalesId("");
|
||||
statistics.setSalesName("");
|
||||
statistics.setSalesTotalDuration(0L);
|
||||
statistics.setSalesRecordingCount(0);
|
||||
statistics.setSalesAvgDuration(BigDecimal.ZERO);
|
||||
}
|
||||
|
||||
// 查找该门店对应的项目统计数据
|
||||
String dealershipIdForProject = dealershipIdObj != null ? dealershipIdObj.toString() : "";
|
||||
Map<String, Object> 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<AudioManag
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据门店ID查找对应的项目统计数据
|
||||
* @param projectStatsList 项目统计列表
|
||||
* @param dealershipId 门店ID
|
||||
* @return 项目统计数据
|
||||
*/
|
||||
private Map<String, Object> findProjectStatByDealership(List<Map<String, Object>> 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<AudioManag
|
||||
Long totalDuration = null;
|
||||
Integer totalCount = null;
|
||||
BigDecimal avgDuration = null;
|
||||
String salesName = null;
|
||||
|
||||
// 获取总录音时长
|
||||
Object totalDurationObj = aggregateResult.get("total_duration");
|
||||
@@ -322,12 +254,6 @@ public class AudioManagementStatisticsServiceImpl extends ServiceImpl<AudioManag
|
||||
avgDuration = new BigDecimal(avgDurationObj.toString());
|
||||
}
|
||||
|
||||
// 获取销售人员姓名
|
||||
Object salesNameObj = aggregateResult.get("sales_name");
|
||||
if (salesNameObj != null) {
|
||||
salesName = salesNameObj.toString();
|
||||
}
|
||||
|
||||
// 将聚合统计结果设置到每条记录上
|
||||
for (AudioManagementStatistics stat : statisticsList) {
|
||||
// 设置总录音时长(汇总)
|
||||
@@ -346,23 +272,9 @@ public class AudioManagementStatisticsServiceImpl extends ServiceImpl<AudioManag
|
||||
} else {
|
||||
stat.setSalesAvgDuration(BigDecimal.ZERO);
|
||||
}
|
||||
|
||||
// 如果聚合结果中有销售人员姓名,且当前记录没有,则设置
|
||||
if (salesName != null && (stat.getSalesName() == null || stat.getSalesName().isEmpty())) {
|
||||
stat.setSalesName(salesName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return statisticsList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AudioManagementStatistics> getStatisticsByProject(String projectId, LocalDate startDate, LocalDate endDate) {
|
||||
LambdaQueryWrapper<AudioManagementStatistics> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(AudioManagementStatistics::getProjectId, projectId)
|
||||
.between(AudioManagementStatistics::getStatisticsDate, startDate, endDate)
|
||||
.orderByAsc(AudioManagementStatistics::getStatisticsDate);
|
||||
return list(queryWrapper);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user