症状:
series_info.body_part_examined 有 "胸部" 和 "膝关节" 两个不同的值study_info.body_part 只显示 "胸部",没有拼接成 "胸部+膝关节"根本原因:
autoGovernStudy() 方法在保存 study_info 后会自动修改 body_part 字段,把我们拼接好的多部位覆盖掉了。
1. processStudyWithTransaction()
- 收集所有文件的部位: [胸部, 膝关节]
- 拼接: "胸部+膝关节"
- 保存到数据库 ✅
2. autoGovernStudy() ❌ 问题在这里
- 读取 body_part: "胸部+膝关节"
- fixBodyPartEncoding("胸部+膝关节")
- intelligentlyIdentifyBodyPart() 可能只识别出"胸部"
- 重新设置: studyInfo.setBodyPart("胸部")
- updateById() ❌ 覆盖了拼接好的值!
结果: 数据库中只保存了 "胸部"
1. processStudyWithTransaction()
- 收集所有文件的部位: [胸部, 膝关节]
- 拼接: "胸部+膝关节"
- 保存到数据库 ✅
2. autoGovernStudy()
- 读取 body_part: "胸部+膝关节"
- 检测到包含 "+" 符号
- 跳过处理,保持原值 ✅
- 只更新其他字段(modality、studyDescription、governStatus)
结果: 数据库中保存 "胸部+膝关节" ✅
文件: DicomServiceImpl.java:647-665
修改内容:
// ⭐ 新增:检测多部位拼接格式
if (bodyPart != null && bodyPart.contains("+")) {
log.info("检测到多部位拼接格式,跳过自动治理: bodyPart={}", bodyPart);
// 跳过处理,保持原值
} else {
// 只有单个部位时才进行处理
bodyPart = fixBodyPartEncoding(bodyPart);
if ("未知部位".equals(bodyPart)) {
bodyPart = intelligentlyIdentifyBodyPart(studyInfo);
}
studyInfo.setBodyPart(bodyPart);
studyInfoMapper.updateById(studyInfo);
}
逻辑:
bodyPart 包含 "+",说明已经是多部位拼接格式,跳过处理# 停止应用
# 重新启动
mvn spring-boot:run
使用 /api/dicom/batch-upload-advanced 接口上传包含胸部和膝关节的文件。
应该看到:
INFO - 处理study: studyInstanceUid=..., 文件数=10
INFO - 文件 xxx.dcm 解析到部位: CHEST
INFO - 文件 xxx.dcm 解析到部位: CHEST
INFO - 文件 xxx.dcm 解析到部位: KNEE
INFO - 文件 xxx.dcm 解析到部位: KNEE
INFO - ✅ 最终解析的检查部位: CHEST+KNEE (来源: 4 个文件,去重后)
INFO - 部位列表: [CHEST, KNEE]
INFO - 💾 保存到 study_info.body_part: CHEST+KNEE
INFO - 创建study记录: studyId=...
INFO - 开始自动治理检查数据: studyId=...
INFO - 检测到多部位拼接格式,跳过自动治理: bodyPart=CHEST+KNEE ⭐
INFO - 自动治理完成(多部位,保持原值): studyId=..., bodyPart=CHEST+KNEE ⭐
SELECT
study_id,
body_part,
exam_item_name,
image_count
FROM study_info
ORDER BY create_time DESC
LIMIT 1;
预期结果:
study_id: STY001
body_part: CHEST+KNEE ✅ 或 胸部+膝关节 ✅
exam_item_name: 胸部CT+膝关节CT ✅
image_count: 10
SELECT
instance_number,
body_part_examined,
exam_item_name
FROM series_info
WHERE study_id = 'STY001'
ORDER BY instance_number;
预期结果:
| instance_number | body_part_examined | exam_item_name |
|-----------------|-------------------|----------------|
| 1 | CHEST | 胸部CT |
| 2 | CHEST | 胸部CT |
| 3 | KNEE | 膝关节CT |
| 4 | KNEE | 膝关节CT |
autoGovernStudy() 方法会覆盖拼接好的多部位 body_part
检测到 bodyPart 包含 "+" 时跳过自动治理
DicomServiceImpl.java:647-698
重启应用后重新上传文件夹,应该就能看到正确的多部位拼接了! 🎉