Commit a18a74c44d8a3d4f8787637f16dd61b308ebee4a
Exists in
master
and in
6 other branches
Merge remote-tracking branch 'origin/master'
Showing 2 changed files
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/BloodPressureServiceImpl.java
View file @
a18a74c
| ... | ... | @@ -184,10 +184,9 @@ |
| 184 | 184 | |
| 185 | 185 | @Override |
| 186 | 186 | public List<Map<String, Object>> getAppInfo(String parentId) { |
| 187 | - List<BloodPressure> bloodPressure = mongoTemplate.find(Query.query(Criteria.where("pid").is(parentId)).with(new Sort(Sort.Direction.ASC, "modified")), BloodPressure.class); | |
| 187 | + List<BloodPressure> bloodPressure = mongoTemplate.find(Query.query(Criteria.where("pid").is(parentId)), BloodPressure.class); | |
| 188 | 188 | List<Map<String, Object>> restList = new ArrayList<>(); |
| 189 | 189 | if(CollectionUtils.isNotEmpty(bloodPressure)) { |
| 190 | - | |
| 191 | 190 | for(BloodPressure b:bloodPressure){ |
| 192 | 191 | Map<String, Map<String, Object>> infos = b.getInfos(); |
| 193 | 192 | Object[] keys = infos.keySet().toArray(); |
| ... | ... | @@ -203,6 +202,7 @@ |
| 203 | 202 | } |
| 204 | 203 | } |
| 205 | 204 | } |
| 205 | + CollectionUtils.sortListByMapKeyWithDate(restList, "createTime"); | |
| 206 | 206 | return restList; |
| 207 | 207 | } |
| 208 | 208 |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/utils/CollectionUtils.java
View file @
a18a74c
| 1 | 1 | package com.lyms.platform.operate.web.utils; |
| 2 | 2 | |
| 3 | +import com.lyms.platform.common.utils.DateUtil; | |
| 3 | 4 | import org.apache.commons.collections.MapUtils; |
| 4 | 5 | import org.apache.commons.lang3.StringUtils; |
| 5 | 6 | import org.springframework.util.Assert; |
| ... | ... | @@ -230,6 +231,16 @@ |
| 230 | 231 | } |
| 231 | 232 | restList.clear(); |
| 232 | 233 | restList.addAll(tempList); |
| 234 | + } | |
| 235 | + } | |
| 236 | + | |
| 237 | + public static void sortListByMapKeyWithDate(List<Map<String, Object>> list, final String key) { | |
| 238 | + if(CollectionUtils.isNotEmpty(list) && StringUtils.isNotEmpty(key)) { | |
| 239 | + Collections.sort(list, new Comparator<Map<String, Object>>() { | |
| 240 | + public int compare(Map<String, Object> o1, Map<String, Object> o2) { | |
| 241 | + return new Long(DateUtil.parseYMDHMS((String) o1.get(key)).getTime() - DateUtil.parseYMDHMS((String) o2.get(key)).getTime()).intValue(); | |
| 242 | + } | |
| 243 | + }); | |
| 233 | 244 | } |
| 234 | 245 | } |
| 235 | 246 | } |