大模型分析结果保存
This commit is contained in:
@@ -106,6 +106,9 @@ public class PasswordUtil {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -90,6 +90,9 @@ public class ServiceManager {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -69,6 +69,9 @@ public class AliyunConfig {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -189,6 +189,9 @@ public class AuthController {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -328,6 +328,9 @@ public class MenuController {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -298,6 +298,9 @@ public class RoleController {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -304,6 +304,9 @@ public class UserRoleController {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -74,3 +74,6 @@ public class DifyWorkflowResponseDto {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -51,6 +51,42 @@ public class CustomerProfileAnalysis {
|
||||
@TableField("dealer_code")
|
||||
private String dealerCode;
|
||||
|
||||
/**
|
||||
* 经销商门店名称
|
||||
*/
|
||||
@TableField("dealer_name")
|
||||
private String dealerName;
|
||||
|
||||
/**
|
||||
* 大区
|
||||
*/
|
||||
@TableField("big_area")
|
||||
private String bigArea;
|
||||
|
||||
/**
|
||||
* 项目ID
|
||||
*/
|
||||
@TableField("project_id")
|
||||
private String projectId;
|
||||
|
||||
/**
|
||||
* 项目名称
|
||||
*/
|
||||
@TableField("project_name")
|
||||
private String projectName;
|
||||
|
||||
/**
|
||||
* 销售顾问ID
|
||||
*/
|
||||
@TableField("sales_person_id")
|
||||
private String salesPersonId;
|
||||
|
||||
/**
|
||||
* 销售顾问姓名
|
||||
*/
|
||||
@TableField("sales_person_name")
|
||||
private String salesPersonName;
|
||||
|
||||
/**
|
||||
* 商机ID
|
||||
*/
|
||||
|
||||
@@ -18,3 +18,6 @@ public interface CustomerProfileAnalysisMapper extends BaseMapper<CustomerProfil
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -55,6 +55,9 @@ public class LoginResponse {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -74,6 +74,9 @@ public class AudioStatisticsScheduler {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,536 @@
|
||||
package com.rj.scheduler;
|
||||
|
||||
import com.rj.entity.CustomerProfileAnalysis;
|
||||
import com.rj.service.biz.impl.CustomerProfileAnalysisServiceImpl;
|
||||
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.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
|
||||
/**
|
||||
* 客户画像分析数据定时生成器
|
||||
* 每天凌晨2:30插入模拟的客户画像分析数据
|
||||
*
|
||||
* Author: 李中华 wx: spllzh email(qq): 28668817@qq.com
|
||||
* Date: 2025/1/3
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class CustomerProfileMockInsertDataScheduler {
|
||||
|
||||
// @Autowired
|
||||
// private ICustomerProfileAnalysisService customerProfileAnalysisService;
|
||||
|
||||
@Autowired
|
||||
CustomerProfileAnalysisServiceImpl customerProfileAnalysisService;;
|
||||
|
||||
|
||||
|
||||
// 项目数据 - 来自适配准真实.sql的project_management JSON
|
||||
private static final String[][] PROJECTS = {
|
||||
{"1957424785875087363", "奔驰C级销售项目"},
|
||||
{"1957424785875087364", "奥迪A4L项目"},
|
||||
{"1957424785875087365", "宝马3系项目"},
|
||||
{"1957424785875087366", "雷克萨斯RX项目"},
|
||||
{"1957424785875087367", "保时捷911项目"},
|
||||
{"1957424785875087368", "威兹曼GT项目"}
|
||||
};
|
||||
|
||||
// 销售顾问数据 - 来自适配准真实.sql的sales_management JSON
|
||||
private static final String[][] SALES_PEOPLE = {
|
||||
{"1957424800000000001", "张明"},
|
||||
{"1957424800000000002", "李华"},
|
||||
{"1957424800000000003", "王强"},
|
||||
{"1957424800000000004", "刘芳"},
|
||||
{"1957424800000000005", "陈军"},
|
||||
{"1957424800000000006", "赵敏"},
|
||||
{"1957424800000000007", "孙丽"},
|
||||
{"1957424800000000008", "周涛"}
|
||||
};
|
||||
|
||||
// 经销商门店数据 - 来自适配准真实.sql的经销商门店JSON
|
||||
private static final String[][] DEALERSHIPS = {
|
||||
{"1957424710587330562", "广州奔驰4S店"},
|
||||
{"1957424711560409089", "北京奥迪4S店"},
|
||||
{"1957424714953601026", "上海宝马4S店"},
|
||||
{"1957424739267981313", "深圳雷克萨斯4S店"},
|
||||
{"1957424740000000001", "成都保时捷4S店"},
|
||||
{"1957424740000000017", "昆明威兹曼4S店"}
|
||||
};
|
||||
|
||||
// 大区数据 - 确保数据分布均衡
|
||||
private static final String[] BIG_AREAS = {
|
||||
"华北区", "华东区", "华南区", "华中区", "西南区", "西北区", "东北区"
|
||||
};
|
||||
|
||||
// 单向开口率数据 - 来自适配准真实.sql的单向开口率JSON
|
||||
private static final String[][] OPENING_RATES = {
|
||||
{"1957424800000000001", "沃尔沃M90续航亮点"},
|
||||
{"1957424800000000002", "lexus RX350智能互联"},
|
||||
{"1957424800000000003", "别克品牌主张"},
|
||||
{"1957424800000000004", "lexusRX470刹车问题"}
|
||||
};
|
||||
|
||||
// 客户姓名库
|
||||
private static final String[] CUSTOMER_NAMES = {
|
||||
"王小明", "李小红", "张伟", "刘敏", "陈强", "杨丽", "赵刚", "黄娟",
|
||||
"周杰", "吴芳", "徐磊", "孙静", "马超", "朱琳", "胡军", "郭娜",
|
||||
"何涛", "罗雪", "高飞", "梁梅", "宋波", "唐丽", "韩强", "冯敏",
|
||||
"邓伟", "曹静", "彭军", "蒋娜", "薛涛", "方丽", "石强", "顾敏"
|
||||
};
|
||||
|
||||
// 客户电话前缀
|
||||
private static final String[] PHONE_PREFIXES = {
|
||||
"138", "139", "150", "151", "152", "158", "159", "188", "189"
|
||||
};
|
||||
|
||||
// 购买类型
|
||||
private static final String[] PURCHASE_TYPES = {"新购", "置换", "增购"};
|
||||
|
||||
// 付款方式
|
||||
private static final String[] PAYMENT_WAYS = {"贷款", "全款", "分期"};
|
||||
|
||||
// 竞品品牌
|
||||
private static final String[] COMPETITOR_BRANDS = {"奔驰", "宝马", "奥迪", "雷克萨斯", "保时捷", "威兹曼"};
|
||||
|
||||
// 购车用途
|
||||
private static final String[] VEHICLE_USAGES = {"家用", "商用", "代步"};
|
||||
|
||||
// 实际驾驶人
|
||||
private static final String[] PRIMARY_DRIVERS = {"本人", "家人", "其他"};
|
||||
|
||||
// 教育水平
|
||||
private static final String[] EDUCATION_LEVELS = {"高中", "大专", "本科", "硕士", "博士"};
|
||||
|
||||
// 家庭结构
|
||||
private static final String[] FAMILY_COMPOSITIONS = {"单身", "已婚无子女", "已婚有子女", "离异"};
|
||||
|
||||
// 职业
|
||||
private static final String[] JOB_TITLES = {"教师", "工程师", "医生", "律师", "销售", "经理", "公务员", "自由职业"};
|
||||
|
||||
// 企业性质
|
||||
private static final String[] COMPANY_TYPES = {"民营企业", "国企", "外企", "事业单位", "政府机关"};
|
||||
|
||||
// 所属行业
|
||||
private static final String[] INDUSTRY_SECTORS = {"教育", "互联网", "金融", "制造业", "医疗", "房地产", "零售", "服务业"};
|
||||
|
||||
// 兴趣点
|
||||
private static final String[] INTEREST_FOCUSES = {"智能驾驶", "油耗", "空间", "外观", "内饰", "动力", "安全", "环保"};
|
||||
|
||||
// 顾虑点
|
||||
private static final String[] CONCERN_POINTS = {"保养成本", "保值率", "维修费用", "保险费用", "充电便利性", "续航里程"};
|
||||
|
||||
// 情感倾向
|
||||
private static final String[] EMOTION_TENDENCIES = {"积极", "中性", "消极"};
|
||||
|
||||
/**
|
||||
* 每天凌晨2:30执行客户画像数据生成任务
|
||||
*/
|
||||
@Scheduled(cron = "0 30 2 * * ?")
|
||||
public void generateDailyCustomerProfileData() {
|
||||
try {
|
||||
log.info("开始执行客户画像数据生成任务...");
|
||||
|
||||
// 生成昨天的数据
|
||||
LocalDateTime yesterday = LocalDateTime.now().minusDays(1);
|
||||
int count = generateCustomerProfileDataForDate(yesterday);
|
||||
|
||||
log.info("客户画像数据生成任务执行完成,生成日期:{},生成记录数:{}",
|
||||
yesterday.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")), count);
|
||||
|
||||
// 生成今天的数据
|
||||
LocalDateTime today = LocalDateTime.now().minusDays(0);
|
||||
int todayCount = generateCustomerProfileDataForDate(today);
|
||||
|
||||
log.info("客户画像数据生成任务执行完成,生成日期:{},生成记录数:{}",
|
||||
today.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")), todayCount);
|
||||
} catch (Exception e) {
|
||||
log.error("客户画像数据生成任务执行失败", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 为指定日期生成客户画像数据
|
||||
*
|
||||
* @param date 要生成数据的日期
|
||||
* @return 生成的记录数
|
||||
*/
|
||||
public int generateCustomerProfileDataForDate(LocalDateTime date) {
|
||||
try {
|
||||
log.info("开始为日期 {} 生成客户画像数据", date.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
|
||||
|
||||
// 每天生成20-50条记录,确保数据分布均匀
|
||||
int recordCount = ThreadLocalRandom.current().nextInt(30, 50);
|
||||
int successCount = 0;
|
||||
|
||||
for (int i = 0; i < recordCount; i++) {
|
||||
try {
|
||||
CustomerProfileAnalysis analysis = createRandomCustomerProfileAnalysis(date);
|
||||
boolean result = customerProfileAnalysisService.save(analysis);
|
||||
if (result) {
|
||||
successCount++;
|
||||
log.debug("成功生成第{}条客户画像数据 - 客户:{},门店:{},项目:{}",
|
||||
i + 1, analysis.getClientName(), analysis.getDealerName(), analysis.getProjectName());
|
||||
} else {
|
||||
log.warn("保存第{}条客户画像数据失败", i + 1);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("生成第{}条客户画像数据失败", i + 1, e);
|
||||
}
|
||||
}
|
||||
|
||||
log.info("为日期 {} 生成客户画像数据完成,成功生成记录数:{}",
|
||||
date.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")), successCount);
|
||||
return successCount;
|
||||
} catch (Exception e) {
|
||||
log.error("为日期 {} 生成客户画像数据失败", date.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")), e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建随机的客户画像分析数据
|
||||
*
|
||||
* @param baseDate 基础日期
|
||||
* @return 客户画像分析对象
|
||||
*/
|
||||
private CustomerProfileAnalysis createRandomCustomerProfileAnalysis(LocalDateTime baseDate) {
|
||||
CustomerProfileAnalysis analysis = new CustomerProfileAnalysis();
|
||||
ThreadLocalRandom random = ThreadLocalRandom.current();
|
||||
|
||||
// 基础字段
|
||||
analysis.setProfileAnalysisRecordId("AI_" + System.currentTimeMillis() + "_" + random.nextInt(1000, 9999));
|
||||
analysis.setAnalysisSceneType(random.nextInt(1, 5)); // 1-4随机
|
||||
analysis.setRelatedBusinessId("BIZ_" + System.currentTimeMillis() + "_" + random.nextInt(1000, 9999));
|
||||
|
||||
// 随机选择经销商、项目、销售顾问、开口率,确保分布均匀
|
||||
String[] dealership = DEALERSHIPS[random.nextInt(DEALERSHIPS.length)];
|
||||
String[] project = PROJECTS[random.nextInt(PROJECTS.length)];
|
||||
String[] salesPerson = SALES_PEOPLE[random.nextInt(SALES_PEOPLE.length)];
|
||||
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.setProjectId(project[0]);
|
||||
analysis.setProjectName(project[1]);
|
||||
|
||||
// 设置销售顾问信息
|
||||
analysis.setSalesPersonId(salesPerson[0]);
|
||||
analysis.setSalesPersonName(salesPerson[1]);
|
||||
|
||||
// 生成唯一ID
|
||||
long timestamp = System.currentTimeMillis();
|
||||
int randomSuffix = random.nextInt(1000, 9999);
|
||||
analysis.setOpportunityId("OPP_" + timestamp + "_" + randomSuffix);
|
||||
analysis.setClientId("CLIENT_" + timestamp + "_" + randomSuffix);
|
||||
|
||||
// 客户信息
|
||||
analysis.setClientName(CUSTOMER_NAMES[random.nextInt(CUSTOMER_NAMES.length)]);
|
||||
analysis.setClientPhone(generateRandomPhone());
|
||||
|
||||
// 沟通时间 - 在基础日期的随机时间
|
||||
LocalDateTime interactionTime = baseDate
|
||||
.withHour(random.nextInt(9, 18)) // 9-17点
|
||||
.withMinute(random.nextInt(0, 60))
|
||||
.withSecond(random.nextInt(0, 60));
|
||||
analysis.setInteractionDate(interactionTime);
|
||||
|
||||
// 客户画像信息字段
|
||||
analysis.setPurchaseDate(String.valueOf(random.nextInt(1, 91))); // 1-90天
|
||||
analysis.setPurchaseType(PURCHASE_TYPES[random.nextInt(PURCHASE_TYPES.length)]);
|
||||
analysis.setPaymentWay(PAYMENT_WAYS[random.nextInt(PAYMENT_WAYS.length)]);
|
||||
analysis.setCompetitorBrand(COMPETITOR_BRANDS[random.nextInt(COMPETITOR_BRANDS.length)]);
|
||||
analysis.setVehicleUsage(VEHICLE_USAGES[random.nextInt(VEHICLE_USAGES.length)]);
|
||||
analysis.setPrimaryDriver(PRIMARY_DRIVERS[random.nextInt(PRIMARY_DRIVERS.length)]);
|
||||
|
||||
// 预算范围
|
||||
int budgetMin = random.nextInt(20, 100);
|
||||
int budgetMax = budgetMin + random.nextInt(10, 50);
|
||||
analysis.setBudgetRange(budgetMin + "-" + budgetMax + "万");
|
||||
|
||||
// 教育水平
|
||||
analysis.setEducationLevel(EDUCATION_LEVELS[random.nextInt(EDUCATION_LEVELS.length)]);
|
||||
|
||||
// 家庭结构
|
||||
analysis.setFamilyComposition(FAMILY_COMPOSITIONS[random.nextInt(FAMILY_COMPOSITIONS.length)]);
|
||||
|
||||
// 月收入
|
||||
int incomeMin = random.nextInt(5, 30);
|
||||
int incomeMax = incomeMin + random.nextInt(5, 20);
|
||||
analysis.setMonthlyIncome(incomeMin + "-" + incomeMax + "万");
|
||||
|
||||
// 职业信息
|
||||
analysis.setJobTitle(JOB_TITLES[random.nextInt(JOB_TITLES.length)]);
|
||||
analysis.setCompanyType(COMPANY_TYPES[random.nextInt(COMPANY_TYPES.length)]);
|
||||
analysis.setIndustrySector(INDUSTRY_SECTORS[random.nextInt(INDUSTRY_SECTORS.length)]);
|
||||
|
||||
// 兴趣和顾虑
|
||||
analysis.setInterestFocus(INTEREST_FOCUSES[random.nextInt(INTEREST_FOCUSES.length)]);
|
||||
analysis.setConcernPoint(CONCERN_POINTS[random.nextInt(CONCERN_POINTS.length)]);
|
||||
analysis.setPurchaseQualification(random.nextBoolean() ? "是" : "否");
|
||||
|
||||
// 其他信息 - 利用新字段生成更详细的备注
|
||||
analysis.setNotes(String.format("客户在%s门店咨询%s项目,销售顾问%s接待,关注点:%s,购车意向明确",
|
||||
dealership[1], project[1], salesPerson[1], openingRate[1]));
|
||||
analysis.setCurrentBrand(COMPETITOR_BRANDS[random.nextInt(COMPETITOR_BRANDS.length)]);
|
||||
analysis.setHomeAddress(generateRandomAddress());
|
||||
analysis.setFamilySize(String.valueOf(random.nextInt(1, 6))); // 1-5人
|
||||
analysis.setHobby("运动、旅游、音乐");
|
||||
|
||||
// 实体情感分析字段 - 随机生成情感倾向
|
||||
generateEntityEmotions(analysis, random);
|
||||
|
||||
// 系统字段
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
analysis.setCreatedAt(now);
|
||||
analysis.setUpdatedAt(now);
|
||||
analysis.setRecordVersion(0);
|
||||
analysis.setIsDeleted(0);
|
||||
analysis.setCreateSqlby("sched"); // 限制在8个字符以内
|
||||
analysis.setUpdateSqlby("sched"); // 限制在8个字符以内
|
||||
|
||||
// 数据验证
|
||||
validateCustomerProfileAnalysis(analysis);
|
||||
|
||||
// 调试日志 - 输出生成的数据信息
|
||||
log.debug("生成客户画像数据完成 - ID: {}, 客户: {}, 门店: {}, 项目: {}, 销售顾问: {}",
|
||||
analysis.getId(), analysis.getClientName(), analysis.getDealerName(),
|
||||
analysis.getProjectName(), analysis.getSalesPersonName());
|
||||
|
||||
return analysis;
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成实体情感分析数据
|
||||
*/
|
||||
private void generateEntityEmotions(CustomerProfileAnalysis analysis, ThreadLocalRandom random) {
|
||||
String[] emotions = EMOTION_TENDENCIES;
|
||||
String[] reasons = {"客户对此方面表示满意", "客户对此方面持中性态度", "客户对此方面存在疑虑"};
|
||||
|
||||
// 品牌情感
|
||||
int brandEmotion = random.nextInt(emotions.length);
|
||||
analysis.setEntityBrand(emotions[brandEmotion]);
|
||||
analysis.setEntityBrandReason(reasons[brandEmotion]);
|
||||
|
||||
// 外观设计情感
|
||||
int designEmotion = random.nextInt(emotions.length);
|
||||
analysis.setEntityDesign(emotions[designEmotion]);
|
||||
analysis.setEntityDesignReason(reasons[designEmotion]);
|
||||
|
||||
// 颜色情感
|
||||
int colorEmotion = random.nextInt(emotions.length);
|
||||
analysis.setEntityColor(emotions[colorEmotion]);
|
||||
analysis.setEntityColorReason(reasons[colorEmotion]);
|
||||
|
||||
// 尺寸情感
|
||||
int sizeEmotion = random.nextInt(emotions.length);
|
||||
analysis.setEntitySize(emotions[sizeEmotion]);
|
||||
analysis.setEntitySizeReason(reasons[sizeEmotion]);
|
||||
|
||||
// 空间情感
|
||||
int spaceEmotion = random.nextInt(emotions.length);
|
||||
analysis.setEntitySpace(emotions[spaceEmotion]);
|
||||
analysis.setEntitySpaceReason(reasons[spaceEmotion]);
|
||||
|
||||
// 内饰情感
|
||||
int interiorEmotion = random.nextInt(emotions.length);
|
||||
analysis.setEntityInterior(emotions[interiorEmotion]);
|
||||
analysis.setEntityInteriorReason(reasons[interiorEmotion]);
|
||||
|
||||
// 音响情感
|
||||
int audioEmotion = random.nextInt(emotions.length);
|
||||
analysis.setEntityAudio(emotions[audioEmotion]);
|
||||
analysis.setEntityAudioReason(reasons[audioEmotion]);
|
||||
|
||||
// 车机情感
|
||||
int ivinfoEmotion = random.nextInt(emotions.length);
|
||||
analysis.setEntityIvinfo(emotions[ivinfoEmotion]);
|
||||
analysis.setEntityIvinfoReason(reasons[ivinfoEmotion]);
|
||||
|
||||
// 智驾情感
|
||||
int fsdEmotion = random.nextInt(emotions.length);
|
||||
analysis.setEntityFsd(emotions[fsdEmotion]);
|
||||
analysis.setEntityFsdReason(reasons[fsdEmotion]);
|
||||
|
||||
// 续航情感
|
||||
int mileageEmotion = random.nextInt(emotions.length);
|
||||
analysis.setEntityMileage(emotions[mileageEmotion]);
|
||||
analysis.setEntityMileageReason(reasons[mileageEmotion]);
|
||||
|
||||
// 安全情感
|
||||
int safetyEmotion = random.nextInt(emotions.length);
|
||||
analysis.setEntitySafety(emotions[safetyEmotion]);
|
||||
analysis.setEntitySafetyReason(reasons[safetyEmotion]);
|
||||
|
||||
// 环保情感
|
||||
int ecoEmotion = random.nextInt(emotions.length);
|
||||
analysis.setEntityEco(emotions[ecoEmotion]);
|
||||
analysis.setEntityEcoReason(reasons[ecoEmotion]);
|
||||
|
||||
// 绿牌/路权情感
|
||||
int liscenseEmotion = random.nextInt(emotions.length);
|
||||
analysis.setEntityLiscense(emotions[liscenseEmotion]);
|
||||
analysis.setEntityLiscenseReason(reasons[liscenseEmotion]);
|
||||
|
||||
// 价格情感
|
||||
int priceEmotion = random.nextInt(emotions.length);
|
||||
analysis.setEntityPrice(emotions[priceEmotion]);
|
||||
analysis.setEntityPriceReason(reasons[priceEmotion]);
|
||||
|
||||
// 购车权益情感
|
||||
int benefitEmotion = random.nextInt(emotions.length);
|
||||
analysis.setEntityBenefit(emotions[benefitEmotion]);
|
||||
analysis.setEntityBenefitReason(reasons[benefitEmotion]);
|
||||
|
||||
// 用车成本情感
|
||||
int costEmotion = random.nextInt(emotions.length);
|
||||
analysis.setEntityCost(emotions[costEmotion]);
|
||||
analysis.setEntityCostReason(reasons[costEmotion]);
|
||||
|
||||
// 性价比情感
|
||||
int valueEmotion = random.nextInt(emotions.length);
|
||||
analysis.setEntityValue(emotions[valueEmotion]);
|
||||
analysis.setEntityValueReason(reasons[valueEmotion]);
|
||||
|
||||
// 动力情感
|
||||
int powerEmotion = random.nextInt(emotions.length);
|
||||
analysis.setEntityPower(emotions[powerEmotion]);
|
||||
analysis.setEntityPowerReason(reasons[powerEmotion]);
|
||||
|
||||
// 操控情感
|
||||
int controlEmotion = random.nextInt(emotions.length);
|
||||
analysis.setEntityControl(emotions[controlEmotion]);
|
||||
analysis.setEntityControlReason(reasons[controlEmotion]);
|
||||
|
||||
// 置换政策情感
|
||||
int tradeinEmotion = random.nextInt(emotions.length);
|
||||
analysis.setEntityTradein(emotions[tradeinEmotion]);
|
||||
analysis.setEntityTradeinReason(reasons[tradeinEmotion]);
|
||||
|
||||
// 金融方案情感
|
||||
int financeEmotion = random.nextInt(emotions.length);
|
||||
analysis.setEntityFinance(emotions[financeEmotion]);
|
||||
analysis.setEntityFinanceReason(reasons[financeEmotion]);
|
||||
|
||||
// 质保情感
|
||||
int warrantyEmotion = random.nextInt(emotions.length);
|
||||
analysis.setEntityWarranty(emotions[warrantyEmotion]);
|
||||
analysis.setEntityWarrantyReason(reasons[warrantyEmotion]);
|
||||
|
||||
// 交付时间情感
|
||||
int deliveryEmotion = random.nextInt(emotions.length);
|
||||
analysis.setEntityDelivery(emotions[deliveryEmotion]);
|
||||
analysis.setEntityDeliveryReason(reasons[deliveryEmotion]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证客户画像分析数据的完整性
|
||||
*
|
||||
* @param analysis 客户画像分析对象
|
||||
*/
|
||||
private void validateCustomerProfileAnalysis(CustomerProfileAnalysis analysis) {
|
||||
if (analysis == null) {
|
||||
throw new IllegalArgumentException("客户画像分析对象不能为空");
|
||||
}
|
||||
|
||||
// 验证必填字段
|
||||
if (analysis.getProfileAnalysisRecordId() == null || analysis.getProfileAnalysisRecordId().trim().isEmpty()) {
|
||||
throw new IllegalArgumentException("AI分析记录ID不能为空");
|
||||
}
|
||||
|
||||
if (analysis.getDealerCode() == null || analysis.getDealerCode().trim().isEmpty()) {
|
||||
throw new IllegalArgumentException("经销商编码不能为空");
|
||||
}
|
||||
|
||||
if (analysis.getDealerName() == null || analysis.getDealerName().trim().isEmpty()) {
|
||||
throw new IllegalArgumentException("经销商门店名称不能为空");
|
||||
}
|
||||
|
||||
if (analysis.getProjectId() == null || analysis.getProjectId().trim().isEmpty()) {
|
||||
throw new IllegalArgumentException("项目ID不能为空");
|
||||
}
|
||||
|
||||
if (analysis.getProjectName() == null || analysis.getProjectName().trim().isEmpty()) {
|
||||
throw new IllegalArgumentException("项目名称不能为空");
|
||||
}
|
||||
|
||||
if (analysis.getSalesPersonId() == null || analysis.getSalesPersonId().trim().isEmpty()) {
|
||||
throw new IllegalArgumentException("销售顾问ID不能为空");
|
||||
}
|
||||
|
||||
if (analysis.getSalesPersonName() == null || analysis.getSalesPersonName().trim().isEmpty()) {
|
||||
throw new IllegalArgumentException("销售顾问姓名不能为空");
|
||||
}
|
||||
|
||||
if (analysis.getClientName() == null || analysis.getClientName().trim().isEmpty()) {
|
||||
throw new IllegalArgumentException("客户姓名不能为空");
|
||||
}
|
||||
|
||||
if (analysis.getClientPhone() == null || analysis.getClientPhone().trim().isEmpty()) {
|
||||
throw new IllegalArgumentException("客户电话不能为空");
|
||||
}
|
||||
|
||||
if (analysis.getInteractionDate() == null) {
|
||||
throw new IllegalArgumentException("沟通时间不能为空");
|
||||
}
|
||||
|
||||
log.debug("客户画像分析数据验证通过 - 客户:{},门店:{},项目:{},销售顾问:{}",
|
||||
analysis.getClientName(), analysis.getDealerName(),
|
||||
analysis.getProjectName(), analysis.getSalesPersonName());
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成随机手机号
|
||||
*/
|
||||
private String generateRandomPhone() {
|
||||
ThreadLocalRandom random = ThreadLocalRandom.current();
|
||||
String prefix = PHONE_PREFIXES[random.nextInt(PHONE_PREFIXES.length)];
|
||||
StringBuilder phone = new StringBuilder(prefix);
|
||||
for (int i = 0; i < 8; i++) {
|
||||
phone.append(random.nextInt(0, 10));
|
||||
}
|
||||
return phone.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成随机地址
|
||||
*/
|
||||
private String generateRandomAddress() {
|
||||
String[] cities = {"北京市", "上海市", "广州市", "深圳市", "成都市", "杭州市", "南京市", "武汉市"};
|
||||
String[] districts = {"朝阳区", "海淀区", "西城区", "东城区", "丰台区", "石景山区", "通州区", "昌平区"};
|
||||
ThreadLocalRandom random = ThreadLocalRandom.current();
|
||||
|
||||
String city = cities[random.nextInt(cities.length)];
|
||||
String district = districts[random.nextInt(districts.length)];
|
||||
String street = "某某街道" + random.nextInt(1, 100) + "号";
|
||||
|
||||
return city + district + street;
|
||||
}
|
||||
|
||||
/**
|
||||
* 手动触发数据生成任务(用于测试或补录数据)
|
||||
*
|
||||
* @param date 要生成数据的日期
|
||||
* @return 生成的记录数
|
||||
*/
|
||||
public int manualGenerateData(LocalDateTime date) {
|
||||
try {
|
||||
log.info("手动执行客户画像数据生成任务,生成日期:{}", date.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
|
||||
int count = generateCustomerProfileDataForDate(date);
|
||||
log.info("手动客户画像数据生成任务执行完成,生成日期:{},生成记录数:{}",
|
||||
date.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")), count);
|
||||
return count;
|
||||
} catch (Exception e) {
|
||||
log.error("手动客户画像数据生成任务执行失败,生成日期:{}", date.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")), e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
package com.rj.scheduler;
|
||||
|
||||
/**
|
||||
* Author: 李中华 wx: spllzh email(qq): 28668817@qq.com
|
||||
* Date: 2025/9/20 9:30
|
||||
**/
|
||||
public class CustomerProfileStatisticScheduler {
|
||||
}
|
||||
@@ -39,3 +39,6 @@ public interface ICustomerProfileAnalysisService extends IService<CustomerProfil
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -22,9 +22,12 @@ public class CustomerProfileAnalysisServiceImpl extends ServiceImpl<CustomerProf
|
||||
@Override
|
||||
public boolean saveCustomerProfileAnalysis(CustomerProfileAnalysis analysis) {
|
||||
try {
|
||||
log.info("保存客户画像分析结果开始,参数:{}", analysis);
|
||||
boolean result = this.save(analysis);
|
||||
if (result) {
|
||||
log.info("客户画像分析结果保存成功,ID: {}", analysis.getId());
|
||||
CustomerProfileAnalysis ai17583471414673961 = this.getByProfileAnalysisRecordId(analysis.getProfileAnalysisRecordId());
|
||||
log.info("获取AI_1758347141467_3961结果:{}", ai17583471414673961);
|
||||
} else {
|
||||
log.error("客户画像分析结果保存失败");
|
||||
}
|
||||
@@ -71,3 +74,6 @@ public class CustomerProfileAnalysisServiceImpl extends ServiceImpl<CustomerProf
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -37,6 +37,9 @@ public interface IMenuService extends IService<Menu> {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -37,6 +37,9 @@ public interface IUserRoleService extends IService<UserRole> {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -41,6 +41,9 @@ public class MenuServiceImpl extends ServiceImpl<MenuMapper, Menu> implements IM
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -41,6 +41,9 @@ public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements IR
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -41,6 +41,9 @@ public class UserRoleServiceImpl extends ServiceImpl<UserRoleMapper, UserRole> i
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -51,6 +51,9 @@ spring:
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -11,3 +11,6 @@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -27,6 +27,9 @@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
|
||||
-- customer_profile_analysis.sql
|
||||
|
||||
|
||||
CREATE TABLE `customer_business`.`customer_profile_analysis` (
|
||||
`id` VARCHAR(36) NOT NULL COMMENT '主键UUID',
|
||||
`profile_analysis_record_id` VARCHAR(255) NOT NULL COMMENT 'AI分析记录ID',
|
||||
@@ -5,6 +9,11 @@ CREATE TABLE `customer_business`.`customer_profile_analysis` (
|
||||
`interaction_date` DATETIME NOT NULL COMMENT '沟通时间:AI通话录音-通话开始时间 企微会话-语料消息截至时间 面谈-语料消息截至时间',
|
||||
`related_business_id` VARCHAR(255) NOT NULL COMMENT '业务ID:根据分析不同传不同的值 1-unionId 2-通话ID 3-客流ID 4-试驾ID',
|
||||
`dealer_code` VARCHAR(36) DEFAULT NULL COMMENT '经销商编码',
|
||||
`dealer_name` VARCHAR(100) DEFAULT NULL COMMENT '经销商门店名称',
|
||||
`project_id` VARCHAR(36) DEFAULT NULL COMMENT '项目ID',
|
||||
`project_name` VARCHAR(100) DEFAULT NULL COMMENT '项目名称',
|
||||
`sales_person_id` VARCHAR(36) DEFAULT NULL COMMENT '销售顾问ID',
|
||||
`sales_person_name` VARCHAR(50) DEFAULT NULL COMMENT '销售顾问姓名',
|
||||
`opportunity_id` VARCHAR(36) DEFAULT NULL COMMENT '商机ID',
|
||||
`client_id` VARCHAR(36) DEFAULT NULL COMMENT '客户ID',
|
||||
`client_name` VARCHAR(100) DEFAULT NULL COMMENT '客户姓名',
|
||||
|
||||
@@ -0,0 +1,192 @@
|
||||
# Customer Profile Analysis 表字段分类
|
||||
|
||||
## 1. 主键和基础标识字段 (Primary Key & Basic Identity Fields)
|
||||
| 字段名 | 类型 | 是否必填 | 说明 |
|
||||
|--------|------|----------|------|
|
||||
| `id` | VARCHAR(36) | NOT NULL | 主键UUID |
|
||||
| `profile_analysis_record_id` | VARCHAR(255) | NOT NULL | AI分析记录ID |
|
||||
| `analysis_scene_type` | TINYINT UNSIGNED | NOT NULL | 分析类型:1-企微会话 2-AI通话录音 3-AI铭牌(客流) 4-AI铭牌(试驾) |
|
||||
| `related_business_id` | VARCHAR(255) | NOT NULL | 业务ID:根据分析不同传不同的值 1-unionId 2-通话ID 3-客流ID 4-试驾ID |
|
||||
|
||||
## 2. 时间相关字段 (Time Related Fields)
|
||||
| 字段名 | 类型 | 是否必填 | 说明 |
|
||||
|--------|------|----------|------|
|
||||
| `interaction_date` | DATETIME | NOT NULL | 沟通时间:AI通话录音-通话开始时间 企微会话-语料消息截至时间 面谈-语料消息截至时间 |
|
||||
| `created_at` | DATETIME | NOT NULL | 创建时间 |
|
||||
| `updated_at` | DATETIME | NOT NULL | 更新时间 |
|
||||
|
||||
## 3. 经销商和组织信息字段 (Dealer & Organization Fields)
|
||||
| 字段名 | 类型 | 是否必填 | 说明 |
|
||||
|--------|------|----------|------|
|
||||
| `dealer_code` | VARCHAR(36) | NULL | 经销商编码 |
|
||||
| `dealer_name` | VARCHAR(100) | NULL | 经销商门店名称 |
|
||||
| `big_area` | VARCHAR(50) | NULL | 大区 |
|
||||
| `project_id` | VARCHAR(36) | NULL | 项目ID |
|
||||
| `project_name` | VARCHAR(100) | NULL | 项目名称 |
|
||||
|
||||
## 4. 销售团队信息字段 (Sales Team Fields)
|
||||
| 字段名 | 类型 | 是否必填 | 说明 |
|
||||
|--------|------|----------|------|
|
||||
| `sales_person_id` | VARCHAR(36) | NULL | 销售顾问ID |
|
||||
| `sales_person_name` | VARCHAR(50) | NULL | 销售顾问姓名 |
|
||||
|
||||
## 5. 商机和客户信息字段 (Opportunity & Customer Fields)
|
||||
| 字段名 | 类型 | 是否必填 | 说明 |
|
||||
|--------|------|----------|------|
|
||||
| `opportunity_id` | VARCHAR(36) | NULL | 商机ID |
|
||||
| `client_id` | VARCHAR(36) | NULL | 客户ID |
|
||||
| `client_name` | VARCHAR(100) | NULL | 客户姓名 |
|
||||
| `client_phone` | VARCHAR(20) | NULL | 客户电话 |
|
||||
|
||||
## 6. 购车意向信息字段 (Purchase Intention Fields)
|
||||
| 字段名 | 类型 | 是否必填 | 说明 |
|
||||
|--------|------|----------|------|
|
||||
| `purchase_date` | VARCHAR(50) | NULL | 预购日期(示例值:天数) |
|
||||
| `purchase_type` | VARCHAR(20) | NULL | 购买类型(示例值:新购/置换/增购) |
|
||||
| `payment_way` | VARCHAR(20) | NULL | 付款方式(示例值:贷款/全款/分期) |
|
||||
| `competitor_brand` | VARCHAR(50) | NULL | 竞品品牌(示例值:奔驰/宝马/奥迪) |
|
||||
| `vehicle_usage` | VARCHAR(20) | NULL | 购车用途(示例值:家用/商用/代步) |
|
||||
| `primary_driver` | VARCHAR(20) | NULL | 实际驾驶人(示例值:本人/家人/其他) |
|
||||
| `budget_range` | VARCHAR(50) | NULL | 购车预算(示例值:具体预算范围) |
|
||||
| `purchase_qualification` | VARCHAR(10) | NULL | 购车资质(示例值:是否) |
|
||||
|
||||
## 7. 客户个人背景信息字段 (Customer Background Fields)
|
||||
| 字段名 | 类型 | 是否必填 | 说明 |
|
||||
|--------|------|----------|------|
|
||||
| `education_level` | VARCHAR(20) | NULL | 教育水平(示例值:本科/硕士/高中) |
|
||||
| `family_composition` | VARCHAR(50) | NULL | 家庭结构(示例值:已婚有子女/单身) |
|
||||
| `monthly_income` | VARCHAR(50) | NULL | 家庭月收入(示例值:具体收入区间) |
|
||||
| `job_title` | VARCHAR(50) | NULL | 职业(示例值:教师/工程师/医生) |
|
||||
| `company_type` | VARCHAR(50) | NULL | 企业性质(示例值:民营企业/国企/外企) |
|
||||
| `industry_sector` | VARCHAR(50) | NULL | 所属行业(示例值:教育/互联网/金融) |
|
||||
| `home_address` | VARCHAR(200) | NULL | 详细地址(非枚举,示例值) |
|
||||
| `family_size` | VARCHAR(10) | NULL | 家庭人数(非枚举,示例值) |
|
||||
| `hobby` | VARCHAR(200) | NULL | 个人爱好(非枚举,示例值) |
|
||||
|
||||
## 8. 客户关注点和偏好字段 (Customer Focus & Preference Fields)
|
||||
| 字段名 | 类型 | 是否必填 | 说明 |
|
||||
|--------|------|----------|------|
|
||||
| `interest_focus` | VARCHAR(200) | NULL | 兴趣点(示例值:智能驾驶/油耗/空间) |
|
||||
| `concern_point` | VARCHAR(200) | NULL | 顾虑点(示例值:保养成本/保值率) |
|
||||
| `current_brand` | VARCHAR(50) | NULL | 保有品牌(非枚举,示例值) |
|
||||
|
||||
## 9. 备注和扩展信息字段 (Notes & Extended Information Fields)
|
||||
| 字段名 | 类型 | 是否必填 | 说明 |
|
||||
|--------|------|----------|------|
|
||||
| `notes` | VARCHAR(500) | NULL | 备注(非枚举,保留名称) |
|
||||
|
||||
## 10. 实体情感分析字段 (Entity Sentiment Analysis Fields)
|
||||
|
||||
### 10.1 品牌和设计相关情感
|
||||
| 字段名 | 类型 | 是否必填 | 说明 |
|
||||
|--------|------|----------|------|
|
||||
| `entity_brand` | VARCHAR(10) | NULL | 品牌情感倾向:积极/中性/消极 |
|
||||
| `entity_brand_reason` | VARCHAR(500) | NULL | 品牌情感倾向原因 |
|
||||
| `entity_design` | VARCHAR(10) | NULL | 外观设计情感倾向:积极/中性/消极 |
|
||||
| `entity_design_reason` | VARCHAR(500) | NULL | 外观设计情感倾向原因 |
|
||||
| `entity_color` | VARCHAR(10) | NULL | 颜色情感倾向:积极/中性/消极 |
|
||||
| `entity_color_reason` | VARCHAR(500) | NULL | 颜色情感倾向原因 |
|
||||
|
||||
### 10.2 车辆尺寸和空间相关情感
|
||||
| 字段名 | 类型 | 是否必填 | 说明 |
|
||||
|--------|------|----------|------|
|
||||
| `entity_size` | VARCHAR(10) | NULL | 尺寸情感倾向:积极/中性/消极 |
|
||||
| `entity_size_reason` | VARCHAR(500) | NULL | 尺寸情感倾向原因 |
|
||||
| `entity_space` | VARCHAR(10) | NULL | 空间情感倾向:积极/中性/消极 |
|
||||
| `entity_space_reason` | VARCHAR(500) | NULL | 空间情感倾向原因 |
|
||||
|
||||
### 10.3 内饰和配置相关情感
|
||||
| 字段名 | 类型 | 是否必填 | 说明 |
|
||||
|--------|------|----------|------|
|
||||
| `entity_interior` | VARCHAR(10) | NULL | 内饰情感倾向:积极/中性/消极 |
|
||||
| `entity_interior_reason` | VARCHAR(500) | NULL | 内饰情感倾向原因 |
|
||||
| `entity_audio` | VARCHAR(10) | NULL | 音响情感倾向:积极/中性/消极 |
|
||||
| `entity_audio_reason` | VARCHAR(500) | NULL | 音响情感倾向原因 |
|
||||
| `entity_ivinfo` | VARCHAR(10) | NULL | 车机情感倾向:积极/中性/消极 |
|
||||
| `entity_ivinfo_reason` | VARCHAR(500) | NULL | 车机情感倾向原因 |
|
||||
|
||||
### 10.4 智能驾驶和续航相关情感
|
||||
| 字段名 | 类型 | 是否必填 | 说明 |
|
||||
|--------|------|----------|------|
|
||||
| `entity_fsd` | VARCHAR(10) | NULL | 智驾情感倾向:积极/中性/消极 |
|
||||
| `entity_fsd_reason` | VARCHAR(500) | NULL | 智驾情感倾向原因 |
|
||||
| `entity_mileage` | VARCHAR(10) | NULL | 续航情感倾向:积极/中性/消极 |
|
||||
| `entity_mileage_reason` | VARCHAR(500) | NULL | 续航情感倾向原因 |
|
||||
|
||||
### 10.5 安全和环保相关情感
|
||||
| 字段名 | 类型 | 是否必填 | 说明 |
|
||||
|--------|------|----------|------|
|
||||
| `entity_safety` | VARCHAR(10) | NULL | 安全情感倾向:积极/中性/消极 |
|
||||
| `entity_safety_reason` | VARCHAR(500) | NULL | 安全情感倾向原因 |
|
||||
| `entity_eco` | VARCHAR(10) | NULL | 环保情感倾向:积极/中性/消极 |
|
||||
| `entity_eco_reason` | VARCHAR(500) | NULL | 环保情感倾向原因 |
|
||||
| `entity_liscense` | VARCHAR(10) | NULL | 绿牌/路权情感倾向:积极/中性/消极 |
|
||||
| `entity_liscense_reason` | VARCHAR(500) | NULL | 绿牌/路权情感倾向原因 |
|
||||
|
||||
### 10.6 价格和成本相关情感
|
||||
| 字段名 | 类型 | 是否必填 | 说明 |
|
||||
|--------|------|----------|------|
|
||||
| `entity_price` | VARCHAR(10) | NULL | 价格情感倾向:积极/中性/消极 |
|
||||
| `entity_price_reason` | VARCHAR(500) | NULL | 价格情感倾向原因 |
|
||||
| `entity_benefit` | VARCHAR(10) | NULL | 购车权益情感倾向:积极/中性/消极 |
|
||||
| `entity_benefit_reason` | VARCHAR(500) | NULL | 购车权益情感倾向原因 |
|
||||
| `entity_cost` | VARCHAR(10) | NULL | 用车成本情感倾向:积极/中性/消极 |
|
||||
| `entity_cost_reason` | VARCHAR(500) | NULL | 用车成本情感倾向原因 |
|
||||
| `entity_value` | VARCHAR(10) | NULL | 性价比情感倾向:积极/中性/消极 |
|
||||
| `entity_value_reason` | VARCHAR(500) | NULL | 性价比情感倾向原因 |
|
||||
|
||||
### 10.7 动力和操控相关情感
|
||||
| 字段名 | 类型 | 是否必填 | 说明 |
|
||||
|--------|------|----------|------|
|
||||
| `entity_power` | VARCHAR(10) | NULL | 动力情感倾向:积极/中性/消极 |
|
||||
| `entity_power_reason` | VARCHAR(500) | NULL | 动力情感倾向原因 |
|
||||
| `entity_control` | VARCHAR(10) | NULL | 操控情感倾向:积极/中性/消极 |
|
||||
| `entity_control_reason` | VARCHAR(500) | NULL | 操控情感倾向原因 |
|
||||
|
||||
### 10.8 服务和政策相关情感
|
||||
| 字段名 | 类型 | 是否必填 | 说明 |
|
||||
|--------|------|----------|------|
|
||||
| `entity_tradein` | VARCHAR(10) | NULL | 置换政策情感倾向:积极/中性/消极 |
|
||||
| `entity_tradein_reason` | VARCHAR(500) | NULL | 置换政策情感倾向原因 |
|
||||
| `entity_finance` | VARCHAR(10) | NULL | 金融方案情感倾向:积极/中性/消极 |
|
||||
| `entity_finance_reason` | VARCHAR(500) | NULL | 金融方案情感倾向原因 |
|
||||
| `entity_warranty` | VARCHAR(10) | NULL | 质保情感倾向:积极/中性/消极 |
|
||||
| `entity_warranty_reason` | VARCHAR(500) | NULL | 质保情感倾向原因 |
|
||||
| `entity_delivery` | VARCHAR(10) | NULL | 交付时间情感倾向:积极/中性/消极 |
|
||||
| `entity_delivery_reason` | VARCHAR(500) | NULL | 交付时间情感倾向原因 |
|
||||
|
||||
## 11. 系统管理字段 (System Management Fields)
|
||||
| 字段名 | 类型 | 是否必填 | 说明 |
|
||||
|--------|------|----------|------|
|
||||
| `created_by` | VARCHAR(36) | NULL | 创建人id |
|
||||
| `updated_by` | VARCHAR(36) | NULL | 更新人id |
|
||||
| `create_sqlby` | VARCHAR(8) | NULL | 创建sql人 |
|
||||
| `update_sqlby` | VARCHAR(8) | NULL | 更新人sql人 |
|
||||
| `record_version` | TINYINT UNSIGNED | DEFAULT 0 | 版本号(乐观锁) |
|
||||
| `is_deleted` | TINYINT UNSIGNED | NOT NULL DEFAULT 0 | 是否删除 |
|
||||
|
||||
## 字段分类总结
|
||||
|
||||
### 按功能分类:
|
||||
1. **基础标识字段** (4个):主键、分析记录ID、分析类型、业务ID
|
||||
2. **时间字段** (3个):交互时间、创建时间、更新时间
|
||||
3. **组织架构字段** (5个):经销商、大区、项目信息
|
||||
4. **人员信息字段** (2个):销售顾问信息
|
||||
5. **客户信息字段** (4个):商机、客户基本信息
|
||||
6. **购车意向字段** (8个):购车相关的意向和偏好
|
||||
7. **客户背景字段** (8个):个人背景和社会属性
|
||||
8. **关注偏好字段** (3个):兴趣点和顾虑点
|
||||
9. **备注字段** (1个):扩展备注信息
|
||||
10. **情感分析字段** (46个):各种实体的情感倾向和原因
|
||||
11. **系统管理字段** (6个):审计和版本控制
|
||||
|
||||
### 按数据来源分类:
|
||||
- **系统生成字段**:id、created_at、updated_at、record_version、is_deleted
|
||||
- **业务输入字段**:大部分业务相关字段
|
||||
- **AI分析字段**:所有entity_*字段
|
||||
- **用户输入字段**:客户基本信息、购车意向等
|
||||
|
||||
### 按更新频率分类:
|
||||
- **静态字段**:客户背景信息、组织架构信息
|
||||
- **动态字段**:情感分析结果、购车意向
|
||||
- **系统字段**:时间戳、版本号等
|
||||
@@ -1,4 +1,6 @@
|
||||
适配项目的JSON:
|
||||
filename: 适配准真实.sql
|
||||
|
||||
适配项目的JSON--开始
|
||||
{
|
||||
"project_management": [
|
||||
{
|
||||
@@ -27,8 +29,13 @@
|
||||
}
|
||||
]
|
||||
}
|
||||
适配项目的JSON--结束
|
||||
|
||||
适配销售顾问的JSON:
|
||||
|
||||
|
||||
|
||||
|
||||
适配销售顾问的JSON--开始
|
||||
{
|
||||
"sales_management": [
|
||||
{
|
||||
@@ -65,12 +72,15 @@
|
||||
}
|
||||
]
|
||||
}
|
||||
适配销售顾问的JSON--结束
|
||||
|
||||
|
||||
适配经销商门店的JSON*
|
||||
适配经销商门店的JSON ---开始
|
||||
{'1957424710587330562', '广州奔驰4S店'},{'1957424711560409089', '北京奥迪4S店'},{'1957424714953601026', '上海宝马4S店'},{'1957424739267981313', '深圳雷克萨斯4S店'},{'1957424740000000001', '成都保时捷4S店'},{'1957424740000000017', '昆明威兹曼4S店'},{}
|
||||
适配经销商门店的JSON --结束
|
||||
|
||||
适配单向开口率的JSON:
|
||||
|
||||
|
||||
适配单向开口率的JSON--开始
|
||||
{
|
||||
{
|
||||
"id": "1957424800000000001","name":"沃尔沃M90续航亮点"
|
||||
@@ -85,7 +95,7 @@
|
||||
"id": "1957424800000000004","name":"lexusRX470刹车问题"
|
||||
}
|
||||
}
|
||||
|
||||
适配单向开口率的JSON--结束
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,13 +1,16 @@
|
||||
package com.rj.service;
|
||||
|
||||
import com.rj.entity.CustomerProfileAnalysis;
|
||||
import com.rj.service.DifyWorkflowService.DifyWorkflowRequest;
|
||||
import com.rj.service.DifyWorkflowService.DifyWorkflowResponse;
|
||||
import com.rj.service.biz.impl.CustomerProfileAnalysisServiceImpl;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
@@ -25,11 +28,116 @@ public class DifyWorkflowServiceTest {
|
||||
@Autowired
|
||||
private DifyWorkflowService difyWorkflowService;
|
||||
|
||||
@Autowired
|
||||
CustomerProfileAnalysisServiceImpl customerProfileAnalysisService;;
|
||||
|
||||
@Test
|
||||
public void testSaveCustomerProfileAnalysis() {
|
||||
CustomerProfileAnalysis customerProfileAnalysis = new CustomerProfileAnalysis();
|
||||
|
||||
// 基本信息字段
|
||||
customerProfileAnalysis.setId("test_union_12365");
|
||||
customerProfileAnalysis.setProfileAnalysisRecordId("profile_record_001");
|
||||
customerProfileAnalysis.setAnalysisSceneType(1); // 1-企微会话
|
||||
customerProfileAnalysis.setInteractionDate(java.time.LocalDateTime.now());
|
||||
customerProfileAnalysis.setRelatedBusinessId("business_12345");
|
||||
|
||||
// 经销商信息
|
||||
customerProfileAnalysis.setDealerCode("DEALER001");
|
||||
customerProfileAnalysis.setDealerName("测试经销商门店");
|
||||
customerProfileAnalysis.setBigArea("华北区");
|
||||
|
||||
// 项目信息
|
||||
customerProfileAnalysis.setProjectId("PROJECT001");
|
||||
customerProfileAnalysis.setProjectName("测试项目");
|
||||
|
||||
// 销售顾问信息
|
||||
customerProfileAnalysis.setSalesPersonId("sales_001");
|
||||
customerProfileAnalysis.setSalesPersonName("张三");
|
||||
|
||||
// 商机和客户信息
|
||||
customerProfileAnalysis.setOpportunityId("OPP001");
|
||||
customerProfileAnalysis.setClientId("CLIENT001");
|
||||
customerProfileAnalysis.setClientName("李四");
|
||||
customerProfileAnalysis.setClientPhone("13800138000");
|
||||
|
||||
// 客户画像信息
|
||||
customerProfileAnalysis.setPurchaseDate("30天内");
|
||||
customerProfileAnalysis.setPurchaseType("新购");
|
||||
customerProfileAnalysis.setPaymentWay("贷款");
|
||||
customerProfileAnalysis.setCompetitorBrand("奔驰");
|
||||
customerProfileAnalysis.setVehicleUsage("家用");
|
||||
customerProfileAnalysis.setPrimaryDriver("本人");
|
||||
customerProfileAnalysis.setBudgetRange("30-40万");
|
||||
customerProfileAnalysis.setEducationLevel("本科");
|
||||
customerProfileAnalysis.setFamilyComposition("已婚有子女");
|
||||
customerProfileAnalysis.setMonthlyIncome("15000-25000");
|
||||
customerProfileAnalysis.setJobTitle("工程师");
|
||||
customerProfileAnalysis.setCompanyType("民营企业");
|
||||
customerProfileAnalysis.setIndustrySector("互联网");
|
||||
customerProfileAnalysis.setInterestFocus("智能驾驶");
|
||||
customerProfileAnalysis.setConcernPoint("保养成本");
|
||||
customerProfileAnalysis.setPurchaseQualification("是");
|
||||
customerProfileAnalysis.setNotes("客户对安全性能比较关注");
|
||||
customerProfileAnalysis.setCurrentBrand("大众");
|
||||
customerProfileAnalysis.setHomeAddress("北京市朝阳区");
|
||||
customerProfileAnalysis.setFamilySize("4人");
|
||||
customerProfileAnalysis.setHobby("旅游、运动");
|
||||
|
||||
// 实体情感分析字段
|
||||
customerProfileAnalysis.setEntityBrand("积极");
|
||||
customerProfileAnalysis.setEntityBrandReason("客户对品牌认知度较高");
|
||||
customerProfileAnalysis.setEntityDesign("积极");
|
||||
customerProfileAnalysis.setEntityDesignReason("喜欢外观设计");
|
||||
customerProfileAnalysis.setEntityColor("中性");
|
||||
customerProfileAnalysis.setEntityColorReason("对颜色没有特别偏好");
|
||||
customerProfileAnalysis.setEntityPrice("积极");
|
||||
customerProfileAnalysis.setEntityPriceReason("认为价格合理");
|
||||
customerProfileAnalysis.setEntitySpace("积极");
|
||||
customerProfileAnalysis.setEntitySpaceReason("空间满足需求");
|
||||
customerProfileAnalysis.setEntityInterior("积极");
|
||||
customerProfileAnalysis.setEntityInteriorReason("内饰舒适性良好");
|
||||
customerProfileAnalysis.setEntitySafety("积极");
|
||||
customerProfileAnalysis.setEntitySafetyReason("安全性能突出");
|
||||
customerProfileAnalysis.setEntityPower("中性");
|
||||
customerProfileAnalysis.setEntityPowerReason("动力够用");
|
||||
customerProfileAnalysis.setEntityControl("积极");
|
||||
customerProfileAnalysis.setEntityControlReason("操控性好");
|
||||
customerProfileAnalysis.setEntityTradein("积极");
|
||||
customerProfileAnalysis.setEntityTradeinReason("置换政策优惠");
|
||||
customerProfileAnalysis.setEntityFinance("积极");
|
||||
customerProfileAnalysis.setEntityFinanceReason("金融方案灵活");
|
||||
customerProfileAnalysis.setEntityWarranty("积极");
|
||||
customerProfileAnalysis.setEntityWarrantyReason("质保政策完善");
|
||||
customerProfileAnalysis.setEntityDelivery("积极");
|
||||
customerProfileAnalysis.setEntityDeliveryReason("交付时间合理");
|
||||
|
||||
// 系统字段
|
||||
customerProfileAnalysis.setCreatedBy("test_user");
|
||||
customerProfileAnalysis.setCreatedAt(java.time.LocalDateTime.now());
|
||||
customerProfileAnalysis.setUpdatedBy("test_user");
|
||||
customerProfileAnalysis.setUpdatedAt(java.time.LocalDateTime.now());
|
||||
customerProfileAnalysis.setCreateSqlby("test_sql_user");
|
||||
customerProfileAnalysis.setUpdateSqlby("test_sql_user");
|
||||
|
||||
// 保存到数据库
|
||||
customerProfileAnalysisService.save(customerProfileAnalysis);
|
||||
|
||||
System.out.println("客户画像分析数据保存成功!ID: " + customerProfileAnalysis.getId());
|
||||
|
||||
List<CustomerProfileAnalysis> savedRecords = customerProfileAnalysisService.list();
|
||||
assertFalse(savedRecords.isEmpty(), "数据库中应该有保存的记录");
|
||||
|
||||
System.out.println("手动生成成功,保存了 " + savedRecords + " 条记录");
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCallConsultingScenarioWorkflow() {
|
||||
// 准备测试数据
|
||||
Map<String, Object> inputs = new HashMap<>();
|
||||
inputs.put("unionId", "test_union_12345");
|
||||
inputs.put("unionId", "test_union_12346");
|
||||
inputs.put("consultantId", "consultant_67890");
|
||||
inputs.put("communicateDate", "2025-01-03 10:30:00");
|
||||
inputs.put("analysisScene", "sales_consultation");
|
||||
|
||||
Reference in New Issue
Block a user