Commit d1722524bbe5c7493cf427671351aade6ba5fe1f
1 parent
c894f3b869
Exists in
master
and in
6 other branches
修复年龄bug
Showing 1 changed file with 8 additions and 3 deletions
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/MatDeliverFacade.java
View file @
d172252
| ... | ... | @@ -1844,9 +1844,14 @@ |
| 1844 | 1844 | // 年龄段 |
| 1845 | 1845 | if (com.lyms.platform.common.utils.StringUtils.isNotEmpty(startAge) && |
| 1846 | 1846 | com.lyms.platform.common.utils.StringUtils.isNotEmpty(endAge)) { |
| 1847 | - long startTime = System.currentTimeMillis() - Integer.parseInt(startAge) * 356 * 24 * 60 * 60 * 1000; | |
| 1848 | - long endTime = System.currentTimeMillis() - Integer.parseInt(endAge) * 356 * 24 * 60 * 60 * 1000; | |
| 1849 | - List<PersonModel> personModels = mongoTemplate.find(Query.query(Criteria.where("birth").gte(new Date(startTime)).and("birth").lte(new Date(endTime))), PersonModel.class); | |
| 1847 | + Calendar c = Calendar.getInstance(); | |
| 1848 | + c.setTime(new Date()); | |
| 1849 | + c.add(Calendar.YEAR, -Integer.parseInt(startAge)); | |
| 1850 | + Date startDate = c.getTime(); | |
| 1851 | + c.setTime(new Date()); | |
| 1852 | + c.add(Calendar.YEAR, - Integer.parseInt(endAge)); | |
| 1853 | + Date endDate = c.getTime(); | |
| 1854 | + List<PersonModel> personModels = mongoTemplate.find(Query.query(Criteria.where("birth").gte(endDate).lte(startDate)), PersonModel.class); | |
| 1850 | 1855 | for (PersonModel model : personModels) { |
| 1851 | 1856 | pids.add(model.getId()); |
| 1852 | 1857 | } |