fix(mapper): 修复患者主信息查询的重复数据问题
- 在 getRegPatientMainInfo 查询中添加 DISTINCT ON 子句按 patient_id 去重
- 为分页功能添加 getRegPatientMainInfoCount 计数查询
- 修复 SQL 拼接条件的语法错误,将 ${ew.customSqlSegment} 替换为标准的动态 SQL 标签
- 调整字典标签查询逻辑,先查询指定表再回退到默认字典缓存
- 优化查询性能,避免不必要的数据重复和错误的 SQL 语法
- 添加缺失的 ORDER BY 子句确保查询结果的一致性
This commit is contained in:
@@ -117,10 +117,7 @@ public class DictAspect {
|
||||
|
||||
private String queryDictLabel(String dictTable, String dictCode, String dictText, String dictValue) {
|
||||
if (StringUtils.hasText(dictTable)) {
|
||||
// 场景 1:默认字典走DictUtils缓存
|
||||
return DictUtils.getDictLabel(dictCode, dictValue);
|
||||
} else {
|
||||
// 场景 2:查询指定表
|
||||
// 场景 1:查询指定表
|
||||
String sql = String.format("SELECT %s FROM %s WHERE %s::varchar = ? LIMIT 1", dictText, dictTable, dictCode);
|
||||
try {
|
||||
return jdbcTemplate.queryForObject(sql, String.class, dictValue);
|
||||
@@ -128,6 +125,9 @@ public class DictAspect {
|
||||
// 如果查询结果为空,返回 空字符串
|
||||
return "";
|
||||
}
|
||||
} else {
|
||||
// 场景 2:默认字典走DictUtils缓存
|
||||
return DictUtils.getDictLabel(dictCode, dictValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user