Browse Source

feat(dict): 再种 5 个商机子表字典分组 (产品录入 20260825)

新增分组 (契约 code 对齐实体字段):
- locality_type 项目属地 (本地项目/异地项目, 主表 Opportunity.localityType 必填)
- follow_way 跟进方式 (5 项, OpportunityFollow.followWay)
- survey_seq 勘察次数 (第一/二/三次+三次以上封顶, OpportunitySiteSurvey.surveySeq)
- apply_way 申请方式 (工单申请/线下申请, OpportunitySiteSurvey.applyWay)
- customer_role 客户角色 (6 项, OpportunityCustomer.customerRole)

分组 16→21, item 144→163 (+19); 种子测试断言同步, 45 全绿
仍缺: attachment_type 商机资料类型 (未给值); industry_code 挂起待产品
master
luoweijian 2 weeks ago
parent
commit
e083071da6
  1. 31
      crm-dict/src/main/java/com/crm/dict/config/DictDataInitializer.java
  2. 23
      crm-dict/src/test/java/com/crm/dict/config/DictDataInitializerTest.java

31
crm-dict/src/main/java/com/crm/dict/config/DictDataInitializer.java

@ -221,7 +221,36 @@ public class DictDataInitializer implements CommandLineRunner {
new ItemSeed("close_reason_03", "竞争失败", "close_reason_03", 3, null, false),
new ItemSeed("close_reason_04", "重复商机", "close_reason_04", 4, null, false),
new ItemSeed("close_reason_05", "无效商机", "close_reason_05", 5, null, false),
new ItemSeed("close_reason_99", "其他", "close_reason_99", 6, null, false))));
new ItemSeed("close_reason_99", "其他", "close_reason_99", 6, null, false))),
new GroupSeed("locality_type", "项目属地", 17, "本地/异地分类标签(非地理坐标;票 03 locality_type;产品录入 20260825)",
List.of(
new ItemSeed("locality_type_01", "本地项目", "locality_type_01", 1, null, false),
new ItemSeed("locality_type_02", "异地项目", "locality_type_02", 2, null, false))),
new GroupSeed("follow_way", "跟进方式", 18, "跟进记录方式(票 09 follow.follow_way;产品录入 20260825)",
List.of(
new ItemSeed("follow_way_01", "电话沟通", "follow_way_01", 1, null, false),
new ItemSeed("follow_way_02", "上门拜访", "follow_way_02", 2, null, false),
new ItemSeed("follow_way_03", "微信对接", "follow_way_03", 3, null, false),
new ItemSeed("follow_way_04", "线上会议", "follow_way_04", 4, null, false),
new ItemSeed("follow_way_05", "展会沟通", "follow_way_05", 5, null, false))),
new GroupSeed("survey_seq", "勘察次数", 19, "手选四档枚举(“三次以上”是封顶档、非自增;票 08 P1-2;产品录入 20260825)",
List.of(
new ItemSeed("survey_seq_01", "第一次", "survey_seq_01", 1, null, false),
new ItemSeed("survey_seq_02", "第二次", "survey_seq_02", 2, null, false),
new ItemSeed("survey_seq_03", "第三次", "survey_seq_03", 3, null, false),
new ItemSeed("survey_seq_04", "三次以上", "survey_seq_04", 4, null, false))),
new GroupSeed("apply_way", "申请方式", 20, "现场勘察申请方式(票 08 apply_way;产品录入 20260825)",
List.of(
new ItemSeed("apply_way_01", "工单申请", "apply_way_01", 1, null, false),
new ItemSeed("apply_way_02", "线下申请", "apply_way_02", 2, null, false))),
new GroupSeed("customer_role", "客户角色", 21, "商机关联客户角色(票 13 opportunity_customer.customer_role;产品录入 20260825)",
List.of(
new ItemSeed("customer_role_01", "总包", "customer_role_01", 1, null, false),
new ItemSeed("customer_role_02", "工程商", "customer_role_02", 2, null, false),
new ItemSeed("customer_role_03", "投资方", "customer_role_03", 3, null, false),
new ItemSeed("customer_role_04", "设计院", "customer_role_04", 4, null, false),
new ItemSeed("customer_role_05", "集成商", "customer_role_05", 5, null, false),
new ItemSeed("customer_role_06", "投标公司", "customer_role_06", 6, null, false))));
@Override
public void run(String... args) {

23
crm-dict/src/test/java/com/crm/dict/config/DictDataInitializerTest.java

@ -31,26 +31,27 @@ class DictDataInitializerTest extends AbstractDictH2Test {
}
@Test
@DisplayName("首装:16 个内置分组 + 144 个内置项全部建库,ref_count 预建,种子默认项生效")
@DisplayName("首装:21 个内置分组 + 163 个内置项全部建库,ref_count 预建,种子默认项生效")
void firstRun_createsBuiltinDictsWithDefaults() {
initializer.run();
List<DictGroup> groups = dictGroupMapper.selectList(null);
assertThat(groups).hasSize(16);
assertThat(groups).hasSize(21);
assertThat(groups).extracting(DictGroup::getCode)
.containsExactlyInAnyOrder("lead_source", "customer_status", "industry",
"brand", "product", "scene", "opp_stage",
"opp_source", "opp_type", "bid_form", "result_tag", "design_config",
"pause_reason", "pool_reason", "project_role", "close_reason");
"pause_reason", "pool_reason", "project_role", "close_reason",
"locality_type", "follow_way", "survey_seq", "apply_way", "customer_role");
assertThat(groups).allMatch(g -> Boolean.TRUE.equals(g.getBuiltin()));
assertThat(groups).allMatch(g -> g.getStatus() == DictConstants.STATUS_ENABLED);
List<DictItem> items = dictItemMapper.selectList(null);
assertThat(items).hasSize(144); // 97 (旧) + 商机来源3 + 类型3 + 招标形式4 + 结果标签8 + 设计配置6 + 暂缓原因6 + 公海原因5 + 项目角色6 + 关闭原因6
assertThat(items).hasSize(163); // 144 + 属地2 + 跟进方式5 + 勘察次数4 + 申请方式2 + 客户角色6
assertThat(items).allMatch(i -> Boolean.TRUE.equals(i.getBuiltin()));
// 引用计数行预建(与新建接口同口径)
assertThat(dictRefCountMapper.selectCount(null)).isEqualTo(144);
assertThat(dictRefCountMapper.selectCount(null)).isEqualTo(163);
DictGroup statusGroup = groups.stream()
.filter(g -> g.getCode().equals("customer_status")).findFirst().orElseThrow();
DictItem potential = dictItemMapper.selectList(null).stream()
@ -71,9 +72,9 @@ class DictDataInitializerTest extends AbstractDictH2Test {
initializer.run();
initializer.run();
assertThat(dictGroupMapper.selectCount(null)).isEqualTo(16);
assertThat(dictItemMapper.selectCount(null)).isEqualTo(144);
assertThat(dictRefCountMapper.selectCount(null)).isEqualTo(144);
assertThat(dictGroupMapper.selectCount(null)).isEqualTo(21);
assertThat(dictItemMapper.selectCount(null)).isEqualTo(163);
assertThat(dictRefCountMapper.selectCount(null)).isEqualTo(163);
assertThat(dictGroupDefaultMapper.selectCount(null)).isEqualTo(1);
}
@ -197,11 +198,11 @@ class DictDataInitializerTest extends AbstractDictH2Test {
assertThat(dictItemMapper.selectList(null).stream()
.filter(i -> i.getGroupId().equals(userGroup.getId()))).isEmpty();
// 种子其他分组不受影响(继续正常导入):customer_status + industry + brand + product + scene + opp_stage + 8 商机分组
assertThat(dictGroupMapper.selectCount(null)).isEqualTo(16); // lead_source(用户) + 其余 15 个内置分组
assertThat(dictGroupMapper.selectCount(null)).isEqualTo(21); // lead_source(用户) + 其余 20 个内置分组
assertThat(dictGroupMapper.selectList(null).stream()
.filter(g -> g.getCode().equals("industry"))).hasSize(1);
assertThat(dictItemMapper.selectCount(null)).isEqualTo(106); // 144 - 渠道 38(用户分组整组跳过)
assertThat(dictRefCountMapper.selectCount(null)).isEqualTo(106);
assertThat(dictItemMapper.selectCount(null)).isEqualTo(125); // 163 - 渠道 38(用户分组整组跳过)
assertThat(dictRefCountMapper.selectCount(null)).isEqualTo(125);
assertThat(dictGroupDefaultMapper.selectCount(null)).isEqualTo(1); // customer_status 默认项
}

Loading…
Cancel
Save