Commit fcc1199f49b35e1b3a55d406c7b11e2990854698

Authored by litao
1 parent 0d5feb48cd

bug修复~

Showing 1 changed file with 31 additions and 41 deletions

platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/ReportServiceImpl.java View file @ fcc1199
... ... @@ -447,6 +447,8 @@
447 447  
448 448 List<Map<String, Object>> couponReport = new ArrayList<>();
449 449 List<String> hospitalId = (List<String>) param.get("hospitalId");
  450 + List<String> xAxis = new ArrayList<>();
  451 +
450 452 if(CollectionUtils.isNotEmpty(hospitalId)) {
451 453 List<Map<String, Object>> hospitalNames = couponMapper.findHospitalNames(hospitalId);
452 454 if(CollectionUtils.isNotEmpty(hospitalNames)) {
... ... @@ -456,7 +458,7 @@
456 458 Map<String, Object> usedInfo = couponMapper.findHospitalUsedInfo(param);
457 459 Map<String, Object> sendInfo = couponMapper.findHospitalSendInfo(param);
458 460  
459   - Map<String, Object> tempMap = packCouponMap(sendInfo, usedInfo, hNameMap, hid);
  461 + Map<String, Object> tempMap = packCouponMap(sendInfo, usedInfo, hNameMap, hid, xAxis, param);
460 462 if(MapUtils.isNotEmpty(tempMap)) {
461 463 couponReport.add(tempMap);
462 464 }
463 465  
... ... @@ -475,11 +477,18 @@
475 477 }
476 478 }
477 479 }
478   -
479   - List<String> xAxis = new ArrayList<>();
480 480 }
481 481  
482   - return RespBuilder.buildSuccess(couponReport);
  482 + ReportModel reportModel = new ReportModel();
  483 + reportModel.setxAxis(xAxis);
  484 + reportModel.setData(Arrays.asList("发放券数", "使用券数"));
  485 + reportModel.setSeries(createSeries(couponReport));
  486 + reportModel.doMerge();
  487 +
  488 + Map<String, Object> titleMap = parseTitle(couponReport);
  489 +
  490 + return RespBuilder.buildSuccess("couponReport", couponReport, "couponReportMap", titleMap, "reportModel", reportModel);
  491 + // return RespBuilder.buildSuccess(couponReport);
483 492 // if(org.apache.commons.collections.CollectionUtils.isNotEmpty(couponReport) &&
484 493 // org.apache.commons.collections.CollectionUtils.isNotEmpty(usedInfo)) {
485 494 // if(CollectionUtils.putAll(couponReport, usedInfo, "used_hospital_id", "used_hospital_id")) {
... ... @@ -514,7 +523,7 @@
514 523 // return RespBuilder.buildSuccess("couponReport", couponReport, "couponReportMap", titleMap, "reportModel", reportModel);
515 524 }
516 525  
517   - private Map<String, Object> packCouponMap(Map<String, Object> sendInfo, Map<String, Object> usedInfo, Map<String, Object> hNameMap, String hid) {
  526 + 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) {
518 527 if(MapUtils.isEmpty(sendInfo) && MapUtils.isEmpty(usedInfo)) return null;
519 528  
520 529 boolean flag = false; /** 本条数据是否有效 sendInfo和usedInfo其中一个有id就有效 */
... ... @@ -560,6 +569,14 @@
560 569 tempMap.put("people_send_count", 0);
561 570 tempMap.put("coupon_send_count", 0);
562 571 }
  572 +
  573 + if("0".equals(tempMap.get("people_send_count").toString()) &&
  574 + "0".equals(tempMap.get("coupon_send_count").toString())&&
  575 + "0".equals(tempMap.get("user_used_count").toString())&&
  576 + "0".equals(tempMap.get("coupon_used_count").toString())){
  577 + return null;
  578 + }
  579 +
563 580 tempMap.put("name", hNameMap.get(hid));
564 581 tempMap.put("hospitalId", hid);
565 582  
566 583  
... ... @@ -568,46 +585,19 @@
568 585 tempMap.put("province_id", provinceId);
569 586 tempMap.put("province_name", findName(provinceId));
570 587 tempMap.put("city_name", findName(cityId));
571   - tempMap.put("area_name", findName(areaId));
  588 + String areaName = findName(areaId);
  589 + tempMap.put("area_name", areaName);
  590 +
  591 + /** 没传区县 报表数据就为区域的 */
  592 + if(param.get("area_id") == null) {
  593 + xAxis.add(areaName);
  594 + } else { /** 传了区县 报表数据就为医院 */
  595 + xAxis.add((String) hNameMap.get(hid));
  596 + }
572 597 return tempMap;
573 598 }
574 599 return null;
575 600 }
576   -
577   - // 把发放人数/发放券数/使用人数/使用券数为null的设置为0
578   - private void transNullToZero(List<Map<String, Object>> couponReport) {
579   - if(org.apache.commons.collections.CollectionUtils.isNotEmpty(couponReport)) {
580   - for (Map<String, Object> coupon : couponReport) {
581   - if(coupon.get("coupon_send_count") == null) {
582   - coupon.put("coupon_send_count", 0);
583   - }
584   - if(coupon.get("coupon_used_count") == null) {
585   - coupon.put("coupon_used_count", 0);
586   - }
587   - if(coupon.get("people_send_count") == null) {
588   - coupon.put("people_send_count", 0);
589   - }
590   - if(coupon.get("user_used_count") == null) {
591   - coupon.put("user_used_count", 0);
592   - }
593   - }
594   - }
595   - }
596   -
597   - private void transNullToZero(List<Map<String, Object>> couponReport, Map<String, Object> titleMap) {
598   - if(org.apache.commons.collections.CollectionUtils.isNotEmpty(couponReport)
599   - && org.apache.commons.collections.MapUtils.isNotEmpty(titleMap))
600   - for (Map<String, Object> coupon : couponReport) {
601   - Set<String> set = titleMap.keySet();
602   - for (String s : set) {
603   - if(coupon.get(s) == null) {
604   - coupon.put(s, 0);
605   - }
606   - }
607   - }
608   - }
609   -
610   -
611 601  
612 602 /**
613 603 * 根据省市区县过滤医院