Commit 5c82ca8de2fec543084360d1f39b2a5a290d4818
Exists in
master
and in
8 other branches
Merge remote-tracking branch 'origin/master'
Showing 1 changed file
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/StatisticsController.java
View file @
5c82ca8
... | ... | @@ -509,6 +509,238 @@ |
509 | 509 | ResultUtils.buildSuccessResultAndWrite(response, result); |
510 | 510 | } |
511 | 511 | |
512 | + // TYPE 地区数据 | |
513 | + else if (type == 3) { | |
514 | + Map<String, String> cityPinyinMap = new HashMap<>(); | |
515 | + cityPinyinMap.put("南充", "nanchong"); | |
516 | + cityPinyinMap.put("衡水", "hengshui"); | |
517 | + cityPinyinMap.put("秦皇岛", "qinhuangdao"); | |
518 | + cityPinyinMap.put("邢台", "xingtai"); | |
519 | + String cityName = null; | |
520 | + AreaDataQuery query = new AreaDataQuery(); | |
521 | + query.setCityId(pid); | |
522 | + // 地图数据 | |
523 | + List<AreaData> provinceRiskList = statisticsService.queryRisksByProvince(query); | |
524 | + List<AreaData> provincePatientList = statisticsService.queryPatientsByProvince(query); | |
525 | + Map<String, String> kvData = new HashMap<>(); | |
526 | + Map<String, Integer> mapsData = new HashMap<>(); | |
527 | + Map<String, String> riskColorMap = new HashMap<>(); | |
528 | + | |
529 | + Option areaBarOption = buildyBarOption("建档及高危人数", null); | |
530 | + areaBarOption.getLegend().getData().add("近30天建档人数"); | |
531 | + areaBarOption.getLegend().getData().add("当前高危总人数"); | |
532 | + areaBarOption.getLegend().setOrient("horizontal"); | |
533 | + areaBarOption.getLegend().setLeft("3%"); | |
534 | + areaBarOption.getLegend().setTop("55px"); | |
535 | + areaBarOption.getTooltip().setShow(true); | |
536 | + areaBarOption.getGrid().setTop("90px"); | |
537 | + List<Object> areaBarSeriesList = new ArrayList<>(); | |
538 | + Series patientSeries = new Series(); | |
539 | + patientSeries.setName("近30天建档人数"); | |
540 | + patientSeries.setType("bar"); | |
541 | + normal.setPosition("right"); | |
542 | + patientSeries.setLabel(label); | |
543 | + List<Object> patientDataList = new ArrayList<>(); | |
544 | + patientSeries.setData(patientDataList); | |
545 | + Series riskSeries = new Series(); | |
546 | + riskSeries.setName("当前高危总人数"); | |
547 | + riskSeries.setType("bar"); | |
548 | + riskSeries.setLabel(label); | |
549 | + List<Object> riskDataList = new ArrayList<>(); | |
550 | + riskSeries.setData(riskDataList); | |
551 | + areaBarSeriesList.add(riskSeries); | |
552 | + areaBarSeriesList.add(patientSeries); | |
553 | + areaBarOption.setSeries(areaBarSeriesList); | |
554 | + | |
555 | + for (AreaData areaData:provinceRiskList) { | |
556 | + if (cityName == null) { | |
557 | + cityName = areaData.getCityName(); | |
558 | + } | |
559 | + String rigino = areaData.getAreaName(); | |
560 | + if (mapsData.get(rigino) == null) { | |
561 | + mapsData.put(rigino, areaData.getVal()); | |
562 | + kvData.put(rigino, areaData.getAreaId()); | |
563 | + } else { | |
564 | + mapsData.put(rigino, mapsData.get(rigino) + areaData.getVal()); | |
565 | + } | |
566 | + } | |
567 | + for (AreaData areaData:provincePatientList) { | |
568 | + if (cityName == null) { | |
569 | + cityName = areaData.getCityName(); | |
570 | + } | |
571 | + String rigino = areaData.getAreaName(); | |
572 | + if (mapsData.get(rigino) == null) { | |
573 | + riskDataList.add(0); | |
574 | + mapsData.put(rigino, areaData.getVal()); | |
575 | + kvData.put(rigino, areaData.getAreaId()); | |
576 | + } else { | |
577 | + riskDataList.add(mapsData.get(rigino)); | |
578 | + mapsData.put(rigino, mapsData.get(rigino) + areaData.getVal()); | |
579 | + } | |
580 | + areaBarOption.getyAxis().getData().add(rigino); | |
581 | + patientDataList.add(areaData.getVal()); | |
582 | + } | |
583 | + | |
584 | + List<Object> dataList = new ArrayList<>(); | |
585 | + Set<String> set = mapsData.keySet(); | |
586 | + for (String key:set) { | |
587 | + Data data = new Data(); | |
588 | + data.setName(key); | |
589 | + data.setValue(mapsData.get(key)); | |
590 | + dataList.add(data); | |
591 | + } | |
592 | + | |
593 | + Option option = buildMapOption(cityName + "孕妇建档及高危数", null); | |
594 | + option.getLegend().setTop("50px"); | |
595 | + List<Object> seriesList = new ArrayList<>(); | |
596 | + Series series = new Series(); | |
597 | + series.setName("建档及高危数"); | |
598 | + series.setType("map"); | |
599 | + series.setMapType(cityPinyinMap.get(cityName.replace("市","").replace("省",""))); | |
600 | + series.setRoam(false); | |
601 | + series.setData(dataList); | |
602 | + series.setLabel(label); | |
603 | + seriesList.add(series); | |
604 | + option.setSeries(seriesList); | |
605 | + | |
606 | + | |
607 | + // 高危数据 | |
608 | + List<AreaData> currentRiskList = statisticsService.queryRisks(query); | |
609 | + Option groupRiskOption = buildyBarOption("当前高危人数", null); | |
610 | + groupRiskOption.getTooltip().setShow(true); | |
611 | + List<Object> groupRiskSeriesList = new ArrayList<>(); | |
612 | + Series groupRiskSeries = new Series(); | |
613 | + groupRiskSeries.setName("高危人数"); | |
614 | + groupRiskSeries.setType("bar"); | |
615 | + mapsData.clear(); | |
616 | + for (AreaData areaData:currentRiskList) { | |
617 | + String groupName = areaData.getGroupName().replace("预警", ""); | |
618 | + if (mapsData.get(areaData.getRiskName()) == null) { | |
619 | + mapsData.put(areaData.getRiskName(),areaData.getVal()); | |
620 | + if (colormap.get(groupName) != null) { | |
621 | + riskColorMap.put(areaData.getRiskName(),colormap.get(groupName)); | |
622 | + } | |
623 | + } else { | |
624 | + mapsData.put(areaData.getRiskName(), mapsData.get(areaData.getRiskName()) + areaData.getVal()); | |
625 | + } | |
626 | + } | |
627 | + | |
628 | + // 按MAP的value排序 | |
629 | + List<Map.Entry<String, Integer>> listData = new ArrayList<Map.Entry<String, Integer>>(mapsData.entrySet()); | |
630 | + Collections.sort(listData, new Comparator<Map.Entry<String, Integer>>() { | |
631 | + public int compare(Map.Entry<String, Integer> o1, Map.Entry<String, Integer> o2) { | |
632 | + if (o2.getValue() != null && o1.getValue() != null && o2.getValue().compareTo(o1.getValue()) > 0) { | |
633 | + return -1; | |
634 | + } else { | |
635 | + return 1; | |
636 | + } | |
637 | + } | |
638 | + }); | |
639 | + | |
640 | + List<Object> groupRiskDataList = new ArrayList<>(); | |
641 | + int n = listData.size(); | |
642 | + for (Map.Entry<String, Integer> entry:listData) { | |
643 | + n--; | |
644 | + if (n>28) { | |
645 | + continue; | |
646 | + } | |
647 | + groupRiskOption.getyAxis().getData().add(entry.getKey()); | |
648 | + if (riskColorMap.containsKey(entry.getKey())) { | |
649 | + Data data = new Data(); | |
650 | + data.setValue(entry.getValue()); | |
651 | + data.setItemStyle(new ItemStyle(new Normal(true,riskColorMap.get(entry.getKey())),null)); | |
652 | + groupRiskDataList.add(data); | |
653 | + } else { | |
654 | + groupRiskDataList.add(entry.getValue()); | |
655 | + } | |
656 | + } | |
657 | + groupRiskSeries.setData(groupRiskDataList); | |
658 | + groupRiskSeriesList.add(groupRiskSeries); | |
659 | + groupRiskOption.setSeries(groupRiskSeriesList); | |
660 | + | |
661 | + Map<String, Map<String, Integer>> patientMonthMap = new HashMap<>(); | |
662 | + // 6. 按省或市或地区查询区域内近12个自然月每月产检中历史高危人数(按颜色分组) | |
663 | + query.setDays(12); | |
664 | + List<AreaData> riskMonthList = statisticsService.queryHrefYearRisks(query); | |
665 | + Map<String, Integer> rmap = new HashMap<>(); | |
666 | + for (AreaData areaData:riskMonthList) { | |
667 | + String month = buildMonth(areaData.getYear()); | |
668 | + if (rmap.containsKey(month)) { | |
669 | + rmap.put(month, rmap.get(month) + areaData.getVal()); | |
670 | + } else { | |
671 | + rmap.put(month, areaData.getVal()); | |
672 | + } | |
673 | + } | |
674 | + patientMonthMap.put("高危人数", rmap); | |
675 | + // 4. 按省或市或地区查询区域内近12个自然月每月建档人数 | |
676 | + List<AreaData> patientMonthList = statisticsService.queryMonthPatients(query); | |
677 | + Map<String, Integer> pmap = new HashMap<>(); | |
678 | + for (AreaData areaData:patientMonthList) { | |
679 | + String month = buildMonth(areaData.getYear()); | |
680 | + if (pmap.containsKey(month)) { | |
681 | + pmap.put(month, pmap.get(month) + areaData.getVal()); | |
682 | + } else { | |
683 | + pmap.put(month, areaData.getVal()); | |
684 | + } | |
685 | + } | |
686 | + patientMonthMap.put("建档人数", pmap); | |
687 | + Option patientMonthOption = buildLineOption("建档及高危人数", null, patientMonthMap, buildDefaultMonth(12)); | |
688 | + | |
689 | + // 按省或市或地区查询区域内近12个自然月每月初诊人数、复诊人数 | |
690 | + List<AreaData> reportMonthList = statisticsService.queryMonthReports(query); | |
691 | + Map<String, Map<String, Integer>> reportMonthMap = new HashMap<>(); | |
692 | + Map<String, Integer> firstmap = new HashMap<>(); | |
693 | + Map<String, Integer> secondmap = new HashMap<>(); | |
694 | + for (AreaData areaData:reportMonthList) { | |
695 | + String month = buildMonth(areaData.getYear()); | |
696 | + if (firstmap.containsKey(month)) { | |
697 | + firstmap.put(month, firstmap.get(month) + areaData.getVal()); | |
698 | + } else { | |
699 | + firstmap.put(month, areaData.getVal()); | |
700 | + } | |
701 | + if (secondmap.containsKey(month)) { | |
702 | + secondmap.put(month, secondmap.get(month) + areaData.getVal2()); | |
703 | + } else { | |
704 | + secondmap.put(month, areaData.getVal2()); | |
705 | + } | |
706 | + } | |
707 | + reportMonthMap.put("复诊人数", secondmap); | |
708 | + reportMonthMap.put("初诊人数", firstmap); | |
709 | + Option reportMonthOption = buildLineOption("初诊及复诊人数", null, reportMonthMap, buildDefaultMonth(12)); | |
710 | + | |
711 | + | |
712 | + // 近6个月高危数据(按颜色分组) | |
713 | + Map<String, Map<String, Integer>> groupRiskMonthMap = new HashMap<>(); | |
714 | + for (AreaData areaData:riskMonthList) { | |
715 | + String groupName = areaData.getGroupName().replace("预警", ""); | |
716 | + Map<String, Integer> grmap = groupRiskMonthMap.get(groupName); | |
717 | + if (grmap == null) { | |
718 | + grmap = new HashMap<>(); | |
719 | + groupRiskMonthMap.put(groupName, grmap); | |
720 | + } | |
721 | + String month = buildMonth(areaData.getYear()); | |
722 | + if (grmap.containsKey(month)) { | |
723 | + grmap.put(month, grmap.get(month) + areaData.getVal()); | |
724 | + } else { | |
725 | + grmap.put(month, areaData.getVal()); | |
726 | + } | |
727 | + } | |
728 | + Option groupRiskMonthOption = buildxBarOption("高危历史人数", null, groupRiskMonthMap, buildDefaultMonth(6), colormap); | |
729 | + | |
730 | + | |
731 | + result.put("type", 3); | |
732 | + result.put("cityName", cityName); | |
733 | + result.put("cityPinyin", cityPinyinMap.get(cityName.replace("市","").replace("省",""))); | |
734 | + result.put("kvData", kvData); | |
735 | + result.put("mapsOption", option); | |
736 | + result.put("areaBarOption", areaBarOption); | |
737 | + result.put("riskOption", groupRiskOption); | |
738 | + result.put("patientMonthOption", patientMonthOption); | |
739 | + result.put("reportMonthOption", reportMonthOption); | |
740 | + result.put("groupRiskMonthOption", groupRiskMonthOption); | |
741 | + ResultUtils.buildSuccessResultAndWrite(response, result); | |
742 | + } | |
743 | + | |
512 | 744 | } |
513 | 745 | |
514 | 746 |