Commit af598a43c8522f2bda8adc4694c35b8168aa4d76
1 parent
5aff5e8931
Exists in
master
and in
1 other branch
12333
Showing 2 changed files with 53 additions and 4 deletions
platform-common/src/main/java/com/lyms/platform/common/enums/BloodSugarEnums2.java
View file @
af598a4
| 1 | +package com.lyms.platform.common.enums; | |
| 2 | + | |
| 3 | +/** | |
| 4 | + * 血糖时间段枚举 | |
| 5 | + */ | |
| 6 | +public enum BloodSugarEnums2 { | |
| 7 | + | |
| 8 | + A(1, "空腹"), B(2, "早餐前"), C(3, "早餐后2h"), D(4, "午餐前"), E(5, "午餐后2h"), F(6, "晚餐前"), G(7, "晚餐后2h") ,H(8, "夜间"), I(9, "睡前"); | |
| 9 | + | |
| 10 | + BloodSugarEnums2(Integer id, String name) { | |
| 11 | + this.id = id; | |
| 12 | + this.name = name; | |
| 13 | + } | |
| 14 | + | |
| 15 | + private Integer id; | |
| 16 | + private String name; | |
| 17 | + | |
| 18 | + public static String getName(Integer id) { | |
| 19 | + if(id == null) { | |
| 20 | + return null; | |
| 21 | + } | |
| 22 | + BloodSugarEnums2[] values = BloodSugarEnums2.values(); | |
| 23 | + for (BloodSugarEnums2 value : values) { | |
| 24 | + if (value.getId() == id) { | |
| 25 | + return value.getName(); | |
| 26 | + } | |
| 27 | + } | |
| 28 | + return null; | |
| 29 | + } | |
| 30 | + | |
| 31 | + public Integer getId() { | |
| 32 | + return id; | |
| 33 | + } | |
| 34 | + | |
| 35 | + public void setId(Integer id) { | |
| 36 | + this.id = id; | |
| 37 | + } | |
| 38 | + | |
| 39 | + public String getName() { | |
| 40 | + return name; | |
| 41 | + } | |
| 42 | + | |
| 43 | + public void setName(String name) { | |
| 44 | + this.name = name; | |
| 45 | + } | |
| 46 | +} |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/BloodSugarServiceImpl.java
View file @
af598a4
| ... | ... | @@ -4,6 +4,7 @@ |
| 4 | 4 | import com.alibaba.fastjson.JSONObject; |
| 5 | 5 | import com.lyms.platform.biz.service.BloodSugarService; |
| 6 | 6 | import com.lyms.platform.common.enums.BloodSugarEnums; |
| 7 | +import com.lyms.platform.common.enums.BloodSugarEnums2; | |
| 7 | 8 | import com.lyms.platform.common.enums.YnEnums; |
| 8 | 9 | import com.lyms.platform.common.result.BaseResponse; |
| 9 | 10 | import com.lyms.platform.common.result.PageResult; |
| 10 | 11 | |
| ... | ... | @@ -146,14 +147,14 @@ |
| 146 | 147 | if(type == bloodSugar.getBloodSugarType()) { |
| 147 | 148 | bloodSugarAxis.add(0, bloodSugar.getBloodSugar()); |
| 148 | 149 | } |
| 149 | - for (BloodSugarEnums sugarEnums : BloodSugarEnums.values()) { | |
| 150 | + for (BloodSugarEnums2 sugarEnums : BloodSugarEnums2.values()) { | |
| 150 | 151 | if(sugarEnums.getId() == (bloodSugar.getBloodSugarType())) { |
| 151 | 152 | temp.put(sugarEnums.getId(), bloodSugar.getBloodSugar()); |
| 152 | 153 | } |
| 153 | 154 | } |
| 154 | 155 | } |
| 155 | 156 | } |
| 156 | - for (BloodSugarEnums sugarEnums : BloodSugarEnums.values()) { | |
| 157 | + for (BloodSugarEnums2 sugarEnums : BloodSugarEnums2.values()) { | |
| 157 | 158 | if(!temp.containsKey(sugarEnums.getId())) { |
| 158 | 159 | temp.put(sugarEnums.getId(), "--"); |
| 159 | 160 | } |
| ... | ... | @@ -255,7 +256,8 @@ |
| 255 | 256 | Date date = new Date(); |
| 256 | 257 | List<Map<String, Object>> weekAvgMap = new ArrayList<>(); |
| 257 | 258 | Map<Integer, Map<String, Object>> weekAvgMapTemp = new LinkedHashMap<>(); |
| 258 | - Date weekStart = DateUtil.addWeek(date, -1); | |
| 259 | + Date weekStart = DateUtil.getYmdDate(DateUtil.addDay(DateUtil.addWeek(date, -1), 1)); | |
| 260 | + System.out.println(weekStart.toLocaleString()); | |
| 259 | 261 | List<BloodSugar> bloodSugarsWeek = mongoTemplate.find(Query.query(Criteria.where("pid").is(parentId).and("created").gte(weekStart)).with(new Sort(Sort.Direction.DESC, "created")), BloodSugar.class); |
| 260 | 262 | for (BloodSugar bloodSugar : bloodSugarsWeek) { |
| 261 | 263 | if(weekAvgMapTemp.containsKey(bloodSugar.getBloodSugarType())) { |
| ... | ... | @@ -292,7 +294,8 @@ |
| 292 | 294 | // 月平均 |
| 293 | 295 | List<Map<String, Object>> monthAvgMap = new ArrayList<>(); |
| 294 | 296 | Map<Integer, Map<String, Object>> monthAvgTemp = new LinkedHashMap<>(); |
| 295 | - Date monthStart = DateUtil.addMonth(date, -1); | |
| 297 | +// Date monthStart = DateUtil.addMonth(date, -1); | |
| 298 | + Date monthStart = DateUtil.getYmdDate(DateUtil.addDay(DateUtil.addMonth(date, -1), 1)); | |
| 296 | 299 | List<BloodSugar> bloodSugarsMonth = mongoTemplate.find(Query.query(Criteria.where("pid").is(parentId).and("created").gte(monthStart)).with(new Sort(Sort.Direction.DESC, "created")), BloodSugar.class); |
| 297 | 300 | for (BloodSugar bloodSugar : bloodSugarsMonth) { |
| 298 | 301 | if(monthAvgTemp.containsKey(bloodSugar.getBloodSugarType())) { |