大模型分析结果展示
This commit is contained in:
@@ -111,5 +111,6 @@ public class PasswordUtil {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -95,5 +95,6 @@ public class ServiceManager {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -73,5 +73,6 @@ public class AliyunConfig {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -194,5 +194,6 @@ public class AuthController {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -333,5 +333,6 @@ public class MenuController {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -303,5 +303,6 @@ public class RoleController {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -309,5 +309,6 @@ public class UserRoleController {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -77,3 +77,4 @@ public class DifyWorkflowResponseDto {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -21,3 +21,4 @@ public interface CustomerProfileAnalysisMapper extends BaseMapper<CustomerProfil
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -60,5 +60,6 @@ public class LoginResponse {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -79,5 +79,6 @@ public class AudioStatisticsScheduler {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
146
src/main/java/com/rj/scheduler/CpaBrandCoreScheduler.java
Normal file
146
src/main/java/com/rj/scheduler/CpaBrandCoreScheduler.java
Normal file
@@ -0,0 +1,146 @@
|
||||
package com.rj.scheduler;
|
||||
|
||||
import com.rj.service.ICpaBrandScoreStatisticsService;
|
||||
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;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
/**
|
||||
* 经销商品牌得分统计定时任务调度器
|
||||
* 按不同周期执行统计任务,将结果保存到 cpa_brandcore_statistics 表
|
||||
*
|
||||
* Author: 李中华 wx: spllzh email(qq): 28668817@qq.com
|
||||
* Date: 2025/1/15
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class CpaBrandCoreScheduler {
|
||||
|
||||
@Autowired
|
||||
private ICpaBrandScoreStatisticsService cpaBrandScoreStatisticsService;
|
||||
|
||||
/**
|
||||
* 每天凌晨3点执行日统计任务
|
||||
* 统计昨天的数据
|
||||
*/
|
||||
@Scheduled(cron = "0 0 3 * * ?")
|
||||
public void generateDailyStatistics() {
|
||||
try {
|
||||
log.info("开始执行经销商品牌得分日统计任务...");
|
||||
|
||||
LocalDate yesterday = LocalDate.now().minusDays(1);
|
||||
int count = cpaBrandScoreStatisticsService.generateAndSaveStatistics("daily", yesterday, yesterday, "system");
|
||||
|
||||
log.info("经销商品牌得分日统计任务执行完成,统计日期:{},生成记录数:{}",
|
||||
yesterday.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")), count);
|
||||
} catch (Exception e) {
|
||||
log.error("经销商品牌得分日统计任务执行失败", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 每周一凌晨4点执行周统计任务
|
||||
* 统计上周的数据
|
||||
*/
|
||||
@Scheduled(cron = "0 0 4 * * MON")
|
||||
public void generateWeeklyStatistics() {
|
||||
try {
|
||||
log.info("开始执行经销商品牌得分周统计任务...");
|
||||
|
||||
LocalDate lastWeekStart = LocalDate.now().minusWeeks(1).with(java.time.DayOfWeek.MONDAY);
|
||||
LocalDate lastWeekEnd = lastWeekStart.plusDays(6);
|
||||
|
||||
int count = cpaBrandScoreStatisticsService.generateAndSaveStatistics("weekly", lastWeekStart, lastWeekEnd, "system");
|
||||
|
||||
log.info("经销商品牌得分周统计任务执行完成,统计周期:{} - {},生成记录数:{}",
|
||||
lastWeekStart.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")),
|
||||
lastWeekEnd.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")), count);
|
||||
} catch (Exception e) {
|
||||
log.error("经销商品牌得分周统计任务执行失败", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 每月1号凌晨5点执行月统计任务
|
||||
* 统计上个月的数据
|
||||
*/
|
||||
@Scheduled(cron = "0 0 5 1 * ?")
|
||||
public void generateMonthlyStatistics() {
|
||||
try {
|
||||
log.info("开始执行经销商品牌得分月统计任务...");
|
||||
|
||||
LocalDate lastMonthStart = LocalDate.now().minusMonths(1).withDayOfMonth(1);
|
||||
LocalDate lastMonthEnd = lastMonthStart.withDayOfMonth(lastMonthStart.lengthOfMonth());
|
||||
|
||||
int count = cpaBrandScoreStatisticsService.generateAndSaveStatistics("monthly", lastMonthStart, lastMonthEnd, "system");
|
||||
|
||||
log.info("经销商品牌得分月统计任务执行完成,统计周期:{} - {},生成记录数:{}",
|
||||
lastMonthStart.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")),
|
||||
lastMonthEnd.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")), count);
|
||||
} catch (Exception e) {
|
||||
log.error("经销商品牌得分月统计任务执行失败", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 每天凌晨6点执行总计统计任务
|
||||
* 统计所有历史数据
|
||||
*/
|
||||
@Scheduled(cron = "0 0 6 * * ?")
|
||||
public void generateTotalStatistics() {
|
||||
try {
|
||||
log.info("开始执行经销商品牌得分总计统计任务...");
|
||||
|
||||
int count = cpaBrandScoreStatisticsService.generateAndSaveStatistics("total", null, null, "system");
|
||||
|
||||
log.info("经销商品牌得分总计统计任务执行完成,生成记录数:{}", count);
|
||||
} catch (Exception e) {
|
||||
log.error("经销商品牌得分总计统计任务执行失败", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 手动触发统计任务(用于测试或补录数据)
|
||||
*
|
||||
* @param date 要统计的日期
|
||||
* @param statisticsType 统计类型
|
||||
* @return 生成的记录数
|
||||
*/
|
||||
public int manualGenerateStatistics(LocalDate date, String statisticsType) {
|
||||
try {
|
||||
log.info("手动执行经销商品牌得分统计任务,统计日期:{},统计类型:{}", date, statisticsType);
|
||||
int count = cpaBrandScoreStatisticsService.generateAndSaveStatistics(statisticsType, date, date, "manual");
|
||||
log.info("手动经销商品牌得分统计任务执行完成,统计日期:{},统计类型:{},生成记录数:{}",
|
||||
date, statisticsType, count);
|
||||
return count;
|
||||
} catch (Exception e) {
|
||||
log.error("手动经销商品牌得分统计任务执行失败,统计日期:{},统计类型:{}", date, statisticsType, e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 手动触发日期范围统计任务
|
||||
*
|
||||
* @param startDate 开始日期
|
||||
* @param endDate 结束日期
|
||||
* @param statisticsType 统计类型
|
||||
* @return 生成的记录数
|
||||
*/
|
||||
public int manualGenerateStatisticsByRange(LocalDate startDate, LocalDate endDate, String statisticsType) {
|
||||
try {
|
||||
log.info("手动执行经销商品牌得分统计任务,统计范围:{} - {},统计类型:{}", startDate, endDate, statisticsType);
|
||||
int count = cpaBrandScoreStatisticsService.generateAndSaveStatistics(statisticsType, startDate, endDate, "manual");
|
||||
log.info("手动经销商品牌得分统计任务执行完成,统计范围:{} - {},统计类型:{},生成记录数:{}",
|
||||
startDate, endDate, statisticsType, count);
|
||||
return count;
|
||||
} catch (Exception e) {
|
||||
log.error("手动经销商品牌得分统计任务执行失败,统计范围:{} - {},统计类型:{}", startDate, endDate, statisticsType, e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -54,12 +54,12 @@ public class CustomerProfileMockInsertDataScheduler {
|
||||
|
||||
// 经销商门店数据 - 来自适配准真实.sql的经销商门店JSON
|
||||
private static final String[][] DEALERSHIPS = {
|
||||
{"1957424710587330562", "广州奔驰4S店"},
|
||||
{"1957424711560409089", "北京奥迪4S店"},
|
||||
{"1957424714953601026", "上海宝马4S店"},
|
||||
{"1957424739267981313", "深圳雷克萨斯4S店"},
|
||||
{"1957424740000000001", "成都保时捷4S店"},
|
||||
{"1957424740000000017", "昆明威兹曼4S店"}
|
||||
{"华南区", "1957424710587330562", "广州奔驰4S店"},
|
||||
{"华北区", "1957424711560409089", "北京奥迪4S店"},
|
||||
{"华南区","1957424714953601026", "上海宝马4S店"},
|
||||
{"华南区","1957424739267981313", "深圳雷克萨斯4S店"},
|
||||
{"西南区","1957424740000000001", "成都保时捷4S店"},
|
||||
{"西南区","1957424740000000017", "昆明威兹曼4S店"}
|
||||
};
|
||||
|
||||
// 大区数据 - 确保数据分布均衡
|
||||
@@ -214,9 +214,10 @@ public class CustomerProfileMockInsertDataScheduler {
|
||||
String[] openingRate = OPENING_RATES[random.nextInt(OPENING_RATES.length)];
|
||||
|
||||
// 设置经销商信息
|
||||
analysis.setDealerCode(dealership[0]);
|
||||
analysis.setDealerName(dealership[1]);
|
||||
analysis.setBigArea(BIG_AREAS[random.nextInt(BIG_AREAS.length)]);
|
||||
analysis.setBigArea(dealership[0]);
|
||||
analysis.setDealerCode(dealership[1]);
|
||||
analysis.setDealerName(dealership[2]);
|
||||
|
||||
|
||||
// 设置项目信息
|
||||
analysis.setProjectId(project[0]);
|
||||
|
||||
@@ -42,3 +42,4 @@ public interface ICustomerProfileAnalysisService extends IService<CustomerProfil
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -77,3 +77,4 @@ public class CustomerProfileAnalysisServiceImpl extends ServiceImpl<CustomerProf
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -42,5 +42,6 @@ public interface IMenuService extends IService<Menu> {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -42,5 +42,6 @@ public interface IUserRoleService extends IService<UserRole> {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -46,5 +46,6 @@ public class MenuServiceImpl extends ServiceImpl<MenuMapper, Menu> implements IM
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -46,5 +46,6 @@ public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements IR
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -46,5 +46,6 @@ public class UserRoleServiceImpl extends ServiceImpl<UserRoleMapper, UserRole> i
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -56,5 +56,6 @@ spring:
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -14,3 +14,4 @@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -32,5 +32,6 @@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
42
src/main/sql/cpa_brandcore_statistics.sql
Normal file
42
src/main/sql/cpa_brandcore_statistics.sql
Normal file
@@ -0,0 +1,42 @@
|
||||
|
||||
-- 经销商品牌得分表
|
||||
CREATE TABLE `cpa_brandcore_statistics`
|
||||
(
|
||||
`id` VARCHAR(36) NOT NULL COMMENT '主键UUID',
|
||||
`dealer_code` VARCHAR(36) DEFAULT NULL COMMENT '经销商编码',
|
||||
`dealer_name` VARCHAR(100) DEFAULT NULL COMMENT '经销商名称',
|
||||
`big_area` VARCHAR(50) DEFAULT NULL COMMENT '大区',
|
||||
`statistics_date` DATE DEFAULT NULL COMMENT '统计日期(按日统计时使用)',
|
||||
`statistics_type` VARCHAR(20) NOT NULL COMMENT '统计类型:total-总计,daily-按日,weekly-按周,monthly-按月',
|
||||
`total_records` INT UNSIGNED DEFAULT 0 COMMENT '总记录数',
|
||||
`total_score` INT UNSIGNED DEFAULT 0 COMMENT '总得分',
|
||||
`average_score_percentage` DECIMAL(5, 2) DEFAULT 0.00 COMMENT '平均得分百分比',
|
||||
`positive_count` INT UNSIGNED DEFAULT 0 COMMENT '积极情感数量',
|
||||
`neutral_count` INT UNSIGNED DEFAULT 0 COMMENT '中性情感数量',
|
||||
`negative_count` INT UNSIGNED DEFAULT 0 COMMENT '消极情感数量',
|
||||
`positive_rate` DECIMAL(5, 2) DEFAULT 0.00 COMMENT '积极率百分比',
|
||||
`neutral_rate` DECIMAL(5, 2) DEFAULT 0.00 COMMENT '中性率百分比',
|
||||
`negative_rate` DECIMAL(5, 2) DEFAULT 0.00 COMMENT '消极率百分比',
|
||||
`earliest_interaction` DATETIME DEFAULT NULL COMMENT '最早交互时间',
|
||||
`latest_interaction` DATETIME DEFAULT NULL COMMENT '最晚交互时间',
|
||||
`created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`created_by` VARCHAR(36) DEFAULT NULL COMMENT '创建人',
|
||||
`updated_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
`updated_by` VARCHAR(36) DEFAULT NULL COMMENT '更新人',
|
||||
`is_deleted` TINYINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '是否删除(0-未删除,1-已删除)',
|
||||
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `uk_dealer_date_type` (`dealer_code`, `statistics_date`, `statistics_type`),
|
||||
KEY `idx_dealer_code` (`dealer_code`),
|
||||
KEY `idx_dealer_name` (`dealer_name`),
|
||||
KEY `idx_big_area` (`big_area`),
|
||||
KEY `idx_statistics_date` (`statistics_date`),
|
||||
KEY `idx_statistics_type` (`statistics_type`),
|
||||
KEY `idx_total_score` (`total_score`),
|
||||
KEY `idx_average_score_percentage` (`average_score_percentage`),
|
||||
KEY `idx_created_at` (`created_at`),
|
||||
KEY `idx_is_deleted` (`is_deleted`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='经销商品牌得分表';
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user