| | |
| | | result.put("timePoints", timePoints); |
| | | result.put("rowGroupBy", rowGroupBy); |
| | | |
| | | // 根据文档注意点3,添加排序逻辑 |
| | | if (!plantTable.isEmpty()) { |
| | | // 对聚合结果进行排序 |
| | | Collections.sort(plantTable, (map1, map2) -> { |
| | | String key1 = map1.keySet().iterator().next(); |
| | | String key2 = map2.keySet().iterator().next(); |
| | | |
| | | // 首先按rowGroupBy排序(processName或workshop) |
| | | int result1 = key1.compareTo(key2); |
| | | if (result1 != 0) { |
| | | return result1; |
| | | } |
| | | |
| | | // 如果rowGroupBy相同,再按plant排序 |
| | | Map<String, Object> detail1 = (Map<String, Object>) map1.get(key1); |
| | | Map<String, Object> detail2 = (Map<String, Object>) map2.get(key2); |
| | | |
| | | String plant1 = detail1.containsKey("plant") ? (String) detail1.get("plant") : ""; |
| | | String plant2 = detail2.containsKey("plant") ? (String) detail2.get("plant") : ""; |
| | | |
| | | return plant1.compareTo(plant2); |
| | | }); |
| | | } |
| | | |
| | | return result; |
| | | } |
| | | |