大模型分析结果保存

This commit is contained in:
spllzh
2025-09-21 10:01:00 +08:00
parent e83d803e70
commit a68f9a87bb
28 changed files with 964 additions and 15 deletions

View File

@@ -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");