Commit 7b4038399f5bea29d49c9965cd233357d0b1596a

Authored by litao@lymsh.com
1 parent f3f2071ff9

优惠券

Showing 1 changed file with 84 additions and 66 deletions

platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/ReportServiceImpl.java View file @ 7b40383
... ... @@ -498,11 +498,11 @@
498 498 List<Map<String, Object>> couponReport = new ArrayList<>();
499 499 List<String> hospitalId = (List<String>) param.get("hospitalId");
500 500 List<String> xAxis = new ArrayList<>();
501   -
  501 + Map<String, Object> hNameMap = new HashMap<>();
502 502 if(CollectionUtils.isNotEmpty(hospitalId)) {
503 503 List<Map<String, Object>> hospitalNames = couponMapper.findHospitalNames(hospitalId);
504 504 if(CollectionUtils.isNotEmpty(hospitalNames)) {
505   - Map<String, Object> hNameMap = CollectionUtils.coverListToMap(hospitalNames, "id", "name");
  505 + hNameMap = CollectionUtils.coverListToMap(hospitalNames, "id", "name");
506 506 for (String hid : hospitalId) {
507 507 param.put("hid", hid);
508 508 Map<String, Object> usedInfo = couponMapper.findHospitalUsedInfo(param);
509 509  
510 510  
... ... @@ -539,45 +539,17 @@
539 539  
540 540 }
541 541  
542   -
543 542 ReportModel reportModel = new ReportModel();
544 543 reportModel.setxAxis(xAxis);
545 544 reportModel.setData(Arrays.asList("发放券数", "使用券数"));
546 545 reportModel.setSeries(createSeries(couponReport));
547 546 reportModel.doMerge();
548 547  
  548 + ReportModel reportModal = createReportModal(couponReport, param, hNameMap);
  549 +
549 550 Map<String, Object> titleMap = parseTitle(couponReport);
550 551 transNullToZero(couponReport, titleMap);
551 552  
552   -// /** titlemap 排序 */
553   -// Map<String, Object> temp = new LinkedHashMap<>();
554   -// Set<String> keys = titleMap.keySet();
555   -// for (String key : keys) {
556   -// if(key.startsWith("7")) {
557   -// temp.put(key, titleMap.get(key));
558   -// }
559   -// }
560   -// for (String key : keys) {
561   -// if(key.startsWith("9")) {
562   -// temp.put(key, titleMap.get(key));
563   -// }
564   -// }
565   -// for (String key : keys) {
566   -// if(key.startsWith("8")) {
567   -// temp.put(key, titleMap.get(key));
568   -// }
569   -// }
570   -// for (String key : keys) {
571   -// if(key.startsWith("10")) {
572   -// temp.put(key, titleMap.get(key));
573   -// }
574   -// }
575   -// for (String s : keys) {
576   -// if(!s.startsWith("10")||!s.startsWith("9")||!s.startsWith("8")||!s.startsWith("7")) {
577   -// temp.put(s, titleMap.get(s));
578   -// }
579   -// }
580   -
581 553 List<Map<String, Object>> couponReportMap = new ArrayList<>();
582 554 Set<Map.Entry<String, Object>> entries = titleMap.entrySet();
583 555 for (Map.Entry<String, Object> entry : entries) {
584 556  
585 557  
586 558  
587 559  
588 560  
589 561  
... ... @@ -586,51 +558,97 @@
586 558 m.put("value", entry.getKey());
587 559 couponReportMap.add(m);
588 560 }
589   -
590   - return RespBuilder.buildSuccess("couponReport", couponReport, "couponReportMap", couponReportMap, "reportModel", reportModel);
  561 +// return RespBuilder.buildSuccess("couponReport", couponReport, "couponReportMap", couponReportMap, "reportModel", reportModel);
  562 + return RespBuilder.buildSuccess("couponReport", couponReport, "couponReportMap", couponReportMap, "reportModel", reportModal);
591 563 }
592 564  
593   - private void setZeroDataByTemp(List<String> key, List<Map<String, Object>> couponReport) {
  565 + private ReportModel createReportModal(List<Map<String, Object>> couponReport, Map<String, Object> param, Map<String, Object> hNameMap) {
  566 + List<Map<String, Object>> temps = new ArrayList<>();
594 567 for (Map<String, Object> map : couponReport) {
595   - for (String s : key) {
596   - if(map.get(s) == null) {
597   - map.put(s, 0);
  568 + String province_id = (String) map.get("province_id");
  569 + String city_id = (String) map.get("city_id");
  570 + String area_id = (String) map.get("area_id");
  571 + Integer coupon_send_count = Integer.parseInt(map.get("coupon_send_count") + "");
  572 + Integer coupon_used_count = Integer.parseInt(map.get("coupon_used_count") + "");
  573 +
  574 + Map<String, Object> data = new HashMap<>();
  575 + data.put("send_count", coupon_send_count + "");
  576 + data.put("hospital_id", map.get("hospitalId") + "");
  577 + data.put("used_count", coupon_used_count + "");
  578 + data.put("hospital_name", hNameMap.get(map.get("hospitalId")));
  579 +
  580 + boolean exist = false;
  581 + for (Map<String, Object> temp : temps) {
  582 + if(StringUtils.isNotEmpty(province_id) && province_id.equals(temp.get("province_id")) &&
  583 + StringUtils.isNotEmpty(city_id) && city_id.equals(temp.get("city_id")) &&
  584 + StringUtils.isNotEmpty(area_id) && area_id.equals(temp.get("area_id"))) {
  585 + Integer send_count = Integer.parseInt(temp.get("send_count") + "");
  586 + Integer used_count = Integer.parseInt(temp.get("used_count") + "");
  587 + temp.put("send_count", send_count + coupon_send_count + "");
  588 + temp.put("used_count", used_count + coupon_used_count + "");
  589 + List<Map<String, Object>> datas = (List<Map<String, Object>>) temp.get("hospitals");
  590 + datas.add(data);
  591 + exist = true;
598 592 }
599 593 }
  594 + if(!exist) {
  595 + Map<String, Object> temp = new HashMap<>();
  596 + temp.put("province_id", province_id);
  597 + temp.put("city_id", city_id);
  598 + temp.put("area_id", area_id);
  599 + temp.put("area_name", (String) map.get("area_name"));
  600 + temp.put("send_count", coupon_send_count == null ? "0" : coupon_send_count.toString());
  601 + temp.put("used_count", coupon_used_count == null ? "0" : coupon_used_count.toString());
  602 + List<Map<String, Object>> datas = new ArrayList<>();
  603 + datas.add(data);
  604 + temp.put("hospitals", datas);
  605 + temps.add(temp);
  606 + }
600 607 }
601 608  
602   - /* if(CollectionUtils.isNotEmpty(couponReport)) {
603   - Map<String, Object> map = couponReport.get(0);
604   - // 类型排序:儿童建档券-新生儿访视券-儿保检查券-血红蛋白检查券 (7 9 8 10)
605   - Map<String, Object> temp = new LinkedHashMap<>();
606   - Set<String> keys = map.keySet();
607   - for (String s : keys) {
608   - if(s.startsWith("7")) {
609   - temp.put(s, map.get(s));
  609 + ReportModel reportModel = new ReportModel();
  610 + List<String> xAxis = new ArrayList<>();
  611 + List<Series> series = new ArrayList<>();
  612 + Series sendSeries = new Series();
  613 + sendSeries.setName("发放券数");
  614 + sendSeries.setType("bar");
  615 + sendSeries.setData(new ArrayList<>());
  616 + Series usedSeries = new Series();
  617 + usedSeries.setName("使用券数");
  618 + usedSeries.setType("bar");
  619 + usedSeries.setData(new ArrayList<>());
  620 + series.add(sendSeries);
  621 + series.add(usedSeries);
  622 + for (Map<String, Object> temp : temps) {
  623 + /** 没传区县 报表数据就为区域的 */
  624 + if(param.get("areaId") == null) {
  625 + xAxis.add((String) temp.get("area_name"));
  626 + sendSeries.getData().add(temp.get("send_count"));
  627 + usedSeries.getData().add(temp.get("used_count"));
  628 + } else { /** 传了区县 报表数据就为医院 */
  629 + List<Map<String, Object>> datas = (List<Map<String, Object>>) temp.get("hospitals");
  630 + for (Map<String, Object> data : datas) {
  631 + xAxis.add((String) data.get("hospital_name"));
  632 + sendSeries.getData().add(data.get("send_count"));
  633 + usedSeries.getData().add(data.get("used_count"));
610 634 }
611 635 }
612   - for (String s : keys) {
613   - if(s.startsWith("9")) {
614   - temp.put(s, map.get(s));
  636 + }
  637 + reportModel.setxAxis(xAxis);
  638 + reportModel.setData(Arrays.asList("发放券数", "使用券数"));
  639 + reportModel.setSeries(series);
  640 + reportModel.doMerge();
  641 + return reportModel;
  642 + }
  643 +
  644 + private void setZeroDataByTemp(List<String> key, List<Map<String, Object>> couponReport) {
  645 + for (Map<String, Object> map : couponReport) {
  646 + for (String s : key) {
  647 + if(map.get(s) == null) {
  648 + map.put(s, 0);
615 649 }
616 650 }
617   - for (String s : keys) {
618   - if(s.startsWith("8")) {
619   - temp.put(s, map.get(s));
620   - }
621   - }
622   - for (String s : keys) {
623   - if(s.startsWith("10")) {
624   - temp.put(s, map.get(s));
625   - }
626   - }
627   - for (String s : keys) {
628   - if(!s.startsWith("10")||!s.startsWith("9")||!s.startsWith("8")||!s.startsWith("7")) {
629   - temp.put(s, map.get(s));
630   - }
631   - }
632   - couponReport.set(0, temp);
633   - }*/
  651 + }
634 652 }
635 653  
636 654 private Map<String, Object> packCouponMap(Map<String, Object> sendInfo, Map<String, Object> usedInfo, Map<String, Object> hNameMap, String hid, List<String> xAxis, Map<String, Object> param) {