fix: 优化生态流量查询返回字段全大写问题
This commit is contained in:
parent
8e70007bd3
commit
a3618ba688
@ -822,7 +822,7 @@ public class SdEngInfoBHServiceImpl extends ServiceImpl<SdEngInfoBHMapper, SdEng
|
||||
List<Map<String, Object>> rows = microservicDynamicSQLMapper.pageAllList(page, sql, paramMap);
|
||||
List<EngStbprpDataVo> list = new ArrayList<>();
|
||||
for (Map<String, Object> row : rows) {
|
||||
list.add(new EngStbprpDataVo(row));
|
||||
list.add(new EngStbprpDataVo(convertKeysToCamelCase(row)));
|
||||
}
|
||||
result.setData(list);
|
||||
result.setTotal(page == null ? list.size() : page.getTotal());
|
||||
@ -832,15 +832,44 @@ public class SdEngInfoBHServiceImpl extends ServiceImpl<SdEngInfoBHMapper, SdEng
|
||||
GroupingInfo[] groupInfos = loadOptions == null ? new GroupingInfo[0] : loadOptions.getGroup();
|
||||
String groupSql = buildStbprpDataGroupSql(detailSql, request.getGroup(), tableMetaList);
|
||||
List<Map<String, Object>> rows = microservicDynamicSQLMapper.pageAllList(null, groupSql, paramMap);
|
||||
List<Map<String, Object>> camelRows = new ArrayList<>();
|
||||
for (Map<String, Object> row : rows) {
|
||||
camelRows.add(convertKeysToCamelCase(row));
|
||||
}
|
||||
if (Boolean.TRUE.equals(request.getGroupResultFlat())) {
|
||||
result.setData((List<EngStbprpDataVo>) (List<?>) new GroupHelper().faltGroup(rows, Arrays.asList(groupInfos)));
|
||||
result.setData((List<EngStbprpDataVo>) (List<?>) new GroupHelper().faltGroup(camelRows, Arrays.asList(groupInfos)));
|
||||
} else {
|
||||
result.setData((List<EngStbprpDataVo>) (List<?>) new GroupHelper().group(rows, Arrays.asList(groupInfos)));
|
||||
result.setData((List<EngStbprpDataVo>) (List<?>) new GroupHelper().group(camelRows, Arrays.asList(groupInfos)));
|
||||
}
|
||||
result.setTotal((long) rows.size());
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将 Map 的 key 从 ORACLE 大写/下划线格式转为 camelCase
|
||||
*/
|
||||
private Map<String, Object> convertKeysToCamelCase(Map<String, Object> row) {
|
||||
if (CollUtil.isEmpty(row)) {
|
||||
return row;
|
||||
}
|
||||
Map<String, Object> result = new LinkedHashMap<>(row.size());
|
||||
for (Map.Entry<String, Object> entry : row.entrySet()) {
|
||||
String key = entry.getKey();
|
||||
if (key == null) {
|
||||
result.put(null, entry.getValue());
|
||||
continue;
|
||||
}
|
||||
// 如果已经是小写开头,说明已经是 camelCase,跳过转换
|
||||
if (Character.isLowerCase(key.charAt(0))) {
|
||||
result.put(key, entry.getValue());
|
||||
continue;
|
||||
}
|
||||
String camelKey = StrUtil.toCamelCase(key.toLowerCase());
|
||||
result.put(camelKey, entry.getValue());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private DataSourceResult<EngOperatVo> queryOperatSummaryList(DataSourceRequest dataSourceRequest,
|
||||
DataSourceLoadOptionsBase loadOptions) {
|
||||
StringBuilder sql = new StringBuilder();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user