Commit f4a97ab8909d419a40fafcd51e21efec7d78e2ac

Authored by litao@lymsh.com
1 parent 7e9f419987

bugbu

Showing 4 changed files with 26 additions and 7 deletions

platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/ReportController.java View file @ f4a97ab
... ... @@ -33,9 +33,10 @@
33 33 * 聊城曲线图
34 34 */
35 35 @ResponseBody
  36 + @TokenRequired
36 37 @RequestMapping(value = "/health/{parentId}", method = RequestMethod.GET)
37   - public BaseObjectResponse health(@PathVariable String parentId) {
38   - return reportService.health(parentId);
  38 + public BaseObjectResponse health(@PathVariable String parentId, HttpServletRequest request) {
  39 + return reportService.health(parentId, getUserId(request));
39 40 }
40 41  
41 42 /**
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/IReportService.java View file @ f4a97ab
... ... @@ -104,6 +104,6 @@
104 104  
105 105 void patientsExport2(String provinceId, String cityId, String areaId, String streetId, Integer ageType, Integer patientType, Date startDate, Date endDate, Integer userId, HttpServletResponse response);
106 106  
107   - BaseObjectResponse health(String parentId);
  107 + BaseObjectResponse health(String parentId, Integer userId);
108 108 }
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/BloodSugarServiceImpl.java View file @ f4a97ab
... ... @@ -231,6 +231,7 @@
231 231 Set<String> monthCountSet = new HashSet<>();
232 232 for (BloodSugar bloodSugar : bloodSugars) {
233 233 monthCountSet.add(DateUtil.getMonth(bloodSugar.getCreated())+"");
  234 +
234 235 if(bloodSugar.getBloodSugarType() == type) {
235 236 Map<String, Object> temp = new HashMap<>();
236 237 temp.put("bloodSugar", bloodSugar.getBloodSugar());
... ... @@ -241,7 +242,26 @@
241 242 dayCountSet.add(DateUtil.getyyyy_MM_dd(bloodSugar.getCreated()));
242 243 }
243 244 }
244   - return RespBuilder.buildSuccess("restList", restList, "count", bloodSugars.size(), "dayCount", dayCountSet.size(), "month", monthCountSet);
  245 +
  246 +
  247 + Date date = new Date();
  248 + Map<Integer, Object> monthAvgMap = new LinkedHashMap<>();
  249 + Map<Integer, Map<String, Object>> monthAvgTemp = new LinkedHashMap<>();
  250 + Map<Integer, Object> weekAvgMap = new LinkedHashMap<>();
  251 + Map<Integer, Map<String, Object>> weekAvgMapTemp = new LinkedHashMap<>();
  252 + Date weekStart = DateUtil.addWeek(date, -1);
  253 + Date monthStart = DateUtil.addMonth(date, -1);
  254 + List<BloodSugar> bloodSugarsWeek = mongoTemplate.find(Query.query(Criteria.where("parentId").is(parentId).and("bloodSugarType").is(type).and("created").gte(weekStart)).with(new Sort(Sort.Direction.DESC, "created")), BloodSugar.class);
  255 + for (BloodSugar bloodSugar : bloodSugarsWeek) {
  256 + if(monthAvgTemp.containsKey(bloodSugar.getBloodSugarType())) {
  257 + Map<String, Object> temp = monthAvgTemp.get(bloodSugar.getBloodSugarType());
  258 + temp.put("dayCount", Integer.parseInt(temp.get("count") + "") + 1); // 总共有记录的天数
  259 +// temp.put()
  260 +// monthAvgTemp.put(bloodSugar.getBloodSugarType(), )
  261 + }
  262 + }
  263 + List<BloodSugar> bloodSugarsMonth = mongoTemplate.find(Query.query(Criteria.where("parentId").is(parentId).and("bloodSugarType").is(type).and("created").gte(monthStart)).with(new Sort(Sort.Direction.DESC, "created")), BloodSugar.class);
  264 + return RespBuilder.buildSuccess("restList", restList, "count", bloodSugars.size(), "dayCount", dayCountSet.size(), "month", monthCountSet, "monthAvgMap", monthAvgMap, "weekAvgMap", weekAvgMap);
245 265 }
246 266  
247 267 }
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/ReportServiceImpl.java View file @ f4a97ab
... ... @@ -593,13 +593,11 @@
593 593 }
594 594  
595 595 @Override
596   - public BaseObjectResponse health(String parentId) {
  596 + public BaseObjectResponse health(String parentId, Integer userId) {
597 597 List<Map<String, Object>> restList = new ArrayList<>();
598 598 Patients p = mongoTemplate.findById(parentId, Patients.class);
599 599 AntExChuModel antExChuModel = mongoTemplate.findOne(Query.query(Criteria.where("parentId").is(parentId).and("yn").is(1).and("hospitalId").is("216")).with(new Sort(Sort.Direction.DESC, "checkTime")), AntExChuModel.class);
600 600 List<AntenatalExaminationModel> antexModels = mongoTemplate.find(Query.query(Criteria.where("parentId").is(parentId).and("yn").is(1)).with(new Sort(Sort.Direction.DESC, "checkTime")), AntenatalExaminationModel.class);
601   -
602   -// antExChuModels.get()
603 601  
604 602 for (AntenatalExaminationModel antexModel : antexModels) {
605 603 Map<String, Object> temp = new HashMap<>();