Commit e675c4e3e814d9985d9234bb0aa4444d25353a84
1 parent
20855be8f8
Exists in
master
and in
6 other branches
血糖
Showing 2 changed files with 124 additions and 1 deletions
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/BloodPressureServiceImpl.java
View file @
e675c4e
... | ... | @@ -332,6 +332,13 @@ |
332 | 332 | return restList; |
333 | 333 | } |
334 | 334 | |
335 | + private int bloodPressureExceptionCount() | |
336 | + { | |
337 | + | |
338 | + int count = 0; | |
339 | + return count; | |
340 | + } | |
341 | + | |
335 | 342 | @Override |
336 | 343 | public BaseResponse initBloodPressure(Map<String, String> bloods) { |
337 | 344 | JSONArray array = JSONArray.parseArray(bloods.get("datas")); |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/BloodSugarServiceImpl.java
View file @
e675c4e
... | ... | @@ -26,6 +26,7 @@ |
26 | 26 | import com.lyms.platform.query.AntExChuQuery; |
27 | 27 | import com.lyms.platform.query.AntExRecordQuery; |
28 | 28 | import com.lyms.platform.query.BloodSugarQuery; |
29 | +import org.apache.commons.collections.MapUtils; | |
29 | 30 | import org.apache.commons.collections.map.HashedMap; |
30 | 31 | import org.springframework.beans.factory.annotation.Autowired; |
31 | 32 | import org.springframework.data.domain.Sort; |
32 | 33 | |
... | ... | @@ -446,10 +447,125 @@ |
446 | 447 | id = blood.getId(); |
447 | 448 | } |
448 | 449 | |
450 | + int exceptionCount = bloodSugarExceptionCount(pid); | |
451 | + | |
449 | 452 | return RespBuilder.buildSuccess("restList", restList, "count", bloodSugars.size(), |
450 | 453 | "dayCount", dayCountSet.size(), "month", |
451 | 454 | monthCountSet3, "monthAvgMap", monthAvgMap, |
452 | - "weekAvgMap", weekAvgMap,"newBloodVal",newBloodMap,"weightInfo",weightInfo,"isReport",isReport,"id",id); | |
455 | + "weekAvgMap", weekAvgMap,"newBloodVal",newBloodMap,"weightInfo",weightInfo,"isReport",isReport,"id",id,"exceptionCount",exceptionCount); | |
456 | + } | |
457 | + | |
458 | + private Map<String, List<BloodSugar>> sortMapByKey(Map<String, List<BloodSugar>> datas) { | |
459 | + if (MapUtils.isNotEmpty(datas)) { | |
460 | + Map<String, List<BloodSugar>> temp = new TreeMap<>(new Comparator<String>() { | |
461 | + @Override | |
462 | + public int compare(String o1, String o2) { | |
463 | + return o2.compareTo(o1); | |
464 | + } | |
465 | + }); | |
466 | + for (Map.Entry<String, List<BloodSugar>> entry : datas.entrySet()) { | |
467 | + temp.put(entry.getKey(), entry.getValue()); | |
468 | + } | |
469 | + return temp; | |
470 | + } | |
471 | + return datas; | |
472 | + } | |
473 | + /** | |
474 | + * 血糖连续出现异常的次数 | |
475 | + * @param pid | |
476 | + * @return | |
477 | + */ | |
478 | + private int bloodSugarExceptionCount(String pid) | |
479 | + { | |
480 | + Map<String, List<BloodSugar>> maps = new HashMap<>(); | |
481 | + | |
482 | + int count = 0; | |
483 | + List<BloodSugar> bloodSugars = mongoTemplate.find(Query.query(Criteria.where("pid").is(pid)).with(new Sort(Sort.Direction.DESC, "modified")), BloodSugar.class); | |
484 | + if (CollectionUtils.isNotEmpty(bloodSugars)) | |
485 | + { | |
486 | + for (BloodSugar bloodSugar : bloodSugars) | |
487 | + { | |
488 | + List<BloodSugar> bss = maps.get(bloodSugar.getCreatYmdDate()); | |
489 | + if (CollectionUtils.isEmpty(bss)) | |
490 | + { | |
491 | + bss = new ArrayList<>(); | |
492 | + } | |
493 | + bss.add(bloodSugar); | |
494 | + maps.put(bloodSugar.getCreatYmdDate(),bss); | |
495 | + } | |
496 | + } | |
497 | + | |
498 | + maps = sortMapByKey(maps); | |
499 | + if (maps.size() > 0) | |
500 | + { | |
501 | + for (String key : maps.keySet()) | |
502 | + { | |
503 | + boolean isBreak = false; | |
504 | + List<BloodSugar> bss = maps.get(key); | |
505 | + if (CollectionUtils.isNotEmpty(bss)) | |
506 | + { | |
507 | + for (BloodSugar bs : bss) | |
508 | + { | |
509 | + int status = getBloodSugarStatus(bs.getBloodSugarType(),Float.parseFloat(bs.getBloodSugar())); | |
510 | + if (status != 0) | |
511 | + { | |
512 | + isBreak = true; | |
513 | + count++; | |
514 | + break; | |
515 | + } | |
516 | + } | |
517 | + } | |
518 | + if (!isBreak || count >=5) | |
519 | + { | |
520 | + break; | |
521 | + } | |
522 | + } | |
523 | + } | |
524 | + | |
525 | + return count; | |
526 | + } | |
527 | + | |
528 | + | |
529 | + private int getBloodSugarStatus(int type,float bloodVal) | |
530 | + { | |
531 | + Integer status = 0; | |
532 | + if (type == 1) {//1-空腹 | |
533 | + if (3.3f <= bloodVal && bloodVal <= 5.3f) {//正常 | |
534 | + } else if (bloodVal < 3.3f) {//异常 | |
535 | + status = -1; | |
536 | + } else if (bloodVal > 5.3f) {//异常 | |
537 | + status = 1; | |
538 | + } | |
539 | + } else if (type == 2 || type == 4 || type == 6) {//"餐前"2, "餐后"3 "餐后"5, | |
540 | + if (3.3f <= bloodVal && bloodVal <= 5.3f) {//正常 | |
541 | + } else if (bloodVal < 3.3f) {//异常 | |
542 | + status = -1; | |
543 | + } else if (bloodVal > 5.3f) {//异常 | |
544 | + status = 1; | |
545 | + } | |
546 | + } else if (type == 3 || type == 5 || type == 7) {//餐后"3,餐后"5, "餐后"7, | |
547 | + if (4.4f <= bloodVal && bloodVal <= 6.7f) {//正常 | |
548 | + } else if (bloodVal < 4.4f) {//异常 | |
549 | + status = -1; | |
550 | + } else if (bloodVal > 6.7f) {//异常 | |
551 | + status = 1; | |
552 | + } | |
553 | + } else if (type == 8) {// "夜间"8, | |
554 | + if (4.4f <= bloodVal && bloodVal <= 6.7f) {//正常 | |
555 | + } else if (bloodVal < 4.4f) {//异常 | |
556 | + status = -1; | |
557 | + } else if (bloodVal > 6.7f) {//异常 | |
558 | + status = 1; | |
559 | + } | |
560 | + } else if (type == 9) {// "睡前"9, | |
561 | + if (4.4f <= bloodVal && bloodVal <= 6.7f) {//正常 | |
562 | + } else if (bloodVal < 4.4f) {//异常 | |
563 | + status = -1; | |
564 | + } else if (bloodVal > 6.7f) {//异常 | |
565 | + status = 1; | |
566 | + } | |
567 | + } | |
568 | + return status; | |
453 | 569 | } |
454 | 570 | |
455 | 571 |