Commit 957aacf80d88eeeed19b11bb68d897ac8a03849a
1 parent
79d1f87942
Exists in
master
and in
1 other branch
统计
Showing 2 changed files with 36 additions and 46 deletions
platform-biz-service/src/main/resources/mainOrm/master/CouponMapper.xml
View file @
957aacf
| ... | ... | @@ -584,26 +584,12 @@ |
| 584 | 584 | </select> |
| 585 | 585 | |
| 586 | 586 | <select id="findUnUsedInfo" parameterType="map" resultType="map"> |
| 587 | - select user_id as un_used_people, b.province_id, b.city_id, b.area_id, b.name as hospitalName | |
| 588 | - from coupon_info a, organization b | |
| 589 | - where a.create_hospital_id = b.id and a.status = 1 and a.create_hospital_id in | |
| 590 | - <foreach collection="hospitalIds" open="(" close=")" separator="," item="hid"> | |
| 591 | - #{hid} | |
| 592 | - </foreach> | |
| 593 | - and user_id in | |
| 587 | + select a.user_id, b.coupon_order, c.type from coupon_info a, coupon_template b, coupon_type c | |
| 588 | + where a.coupon_template_id = b.id and b.type_id = c.id and a.status = 1 | |
| 589 | + and a.user_id in | |
| 594 | 590 | <foreach collection="userIds" open="(" close=")" separator="," item="uid"> |
| 595 | 591 | #{uid} |
| 596 | 592 | </foreach> |
| 597 | - <if test="provinceId != null and provinceId != ''"> | |
| 598 | - and b.province_id = #{provinceId} | |
| 599 | - </if> | |
| 600 | - <if test="cityId != null and cityId != '' "> | |
| 601 | - and b.city_id = #{cityId} | |
| 602 | - </if> | |
| 603 | - <if test="areaId != null and areaId != ''"> | |
| 604 | - and b.area_id = #{areaId} | |
| 605 | - </if> | |
| 606 | - group by a.create_hospital_id | |
| 607 | 593 | <if test="page != null and limit != null"> |
| 608 | 594 | limit #{page}, #{limit} |
| 609 | 595 | </if> |
| 610 | 596 | |
| ... | ... | @@ -611,26 +597,12 @@ |
| 611 | 597 | |
| 612 | 598 | <select id="findUnUsedInfoCount" parameterType="map" resultType="integer"> |
| 613 | 599 | select count(1) from ( |
| 614 | - select count(distinct(user_id)) as un_used_people, count(1) as un_used_coupon_count, b.province_id, b.city_id, b.area_id, a.create_hospital_id | |
| 615 | - from coupon_info a, organization b | |
| 616 | - where a.create_hospital_id = b.id and a.status = 1 and a.create_hospital_id in | |
| 617 | - <foreach collection="hospitalIds" open="(" close=")" separator="," item="hid"> | |
| 618 | - #{hid} | |
| 619 | - </foreach> | |
| 620 | - and user_id in | |
| 600 | + select a.user_id, b.coupon_order, c.type from coupon_info a, coupon_template b, coupon_type c | |
| 601 | + where a.coupon_template_id = b.id and b.type_id = c.id and a.status = 1 | |
| 602 | + and a.user_id in | |
| 621 | 603 | <foreach collection="userIds" open="(" close=")" separator="," item="uid"> |
| 622 | 604 | #{uid} |
| 623 | 605 | </foreach> |
| 624 | - <if test="provinceId != null and provinceId != ''"> | |
| 625 | - and b.province_id = #{provinceId} | |
| 626 | - </if> | |
| 627 | - <if test="cityId != null and cityId != '' "> | |
| 628 | - and b.city_id = #{cityId} | |
| 629 | - </if> | |
| 630 | - <if test="areaId != null and areaId != ''"> | |
| 631 | - and b.area_id = #{areaId} | |
| 632 | - </if> | |
| 633 | - group by a.create_hospital_id | |
| 634 | 606 | ) a |
| 635 | 607 | </select> |
| 636 | 608 |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/ReportServiceImpl.java
View file @
957aacf
| ... | ... | @@ -574,18 +574,36 @@ |
| 574 | 574 | hospitalIds.add(hospitalId); |
| 575 | 575 | List<Map<String, Object>> datas = couponMapper.findHospitalInfoByIds(hospitalIds); |
| 576 | 576 | List<Patients> patients = getPatients(hospitalIds, datas, startDate, endDate, provinceId, cityId, areaId, true); |
| 577 | - Set<String> userIds = new HashSet<>(); | |
| 578 | - for (Patients patient : patients) { | |
| 579 | - userIds.add(patient.getPid()); | |
| 577 | + if(CollectionUtils.isNotEmpty(patients)) { | |
| 578 | + Set<String> userIds = new HashSet<>(); | |
| 579 | + for (Patients patient : patients) { | |
| 580 | + userIds.add(patient.getPid()); | |
| 581 | + } | |
| 582 | + List<Map<String, Object>> list = couponMapper.findUnUsedInfo(CollectionUtils.createMap("userIds", userIds, "page", (page - 1) * limit, "limit", limit)); | |
| 583 | + List<Map<String, Object>> restList = new ArrayList<>(); | |
| 584 | + for (Map<String, Object> map : list) { | |
| 585 | + map.put("couponName", (couponReportMap.get(map.get("type") + "_" + map.get("coupon_order"))).toString() | |
| 586 | + .replaceAll("使用人次", "") | |
| 587 | + .replaceAll("<div class='ag-double-line'>", "") | |
| 588 | + .replaceAll("<div>", "") | |
| 589 | + .replaceAll("</div>", "")); | |
| 590 | + for (Patients patient : patients) { | |
| 591 | + if(patient.getPid().equals(map.get("user_id"))) { | |
| 592 | + map.put("username", patient.getUsername()); | |
| 593 | + map.put("phone", com.lyms.platform.common.utils.StringUtils.encryPhone(patient.getPhone())); | |
| 594 | + map.put("cardNo", com.lyms.platform.common.utils.StringUtils.encryCardNo(patient.getCardNo())); | |
| 595 | + map.put("week", DateUtil.getWeekDesc(patient.getLastMenses(), new Date())); | |
| 596 | + map.put("doctorName", couponMapper.getUserName(patient.getBookbuildingDoctor())); | |
| 597 | + map.put("hospitalName", couponMapper.findHospitalNameById(patient.getHospitalId())); | |
| 598 | + } | |
| 599 | + } | |
| 600 | + map.put("checkTime", "2017-02-22"); | |
| 601 | + restList.add(map); | |
| 602 | + } | |
| 603 | + Integer count = couponMapper.findUnUsedInfoCount(CollectionUtils.createMap("userIds", userIds)); | |
| 604 | + return RespBuilder.buildSuccess(new PageResult(count, page, limit, restList)); | |
| 580 | 605 | } |
| 581 | - Map<String, Object> param = CollectionUtils.createMap("hospitalId", hospitalId, "userIds", userIds, "provinceId", provinceId, "cityId", cityId, "areaId", areaId, "page", (page - 1) * limit, "limit", limit); | |
| 582 | - List<Map<String, Object>> restList = couponMapper.findUnUsedInfo(param); | |
| 583 | - for (Map<String, Object> map : restList) { | |
| 584 | - map.put("cityName", findName(map.get("city_id"))); | |
| 585 | - map.put("areaName", findName(map.get("area_id"))); | |
| 586 | - } | |
| 587 | - Integer count = couponMapper.findUnUsedInfoCount(param); | |
| 588 | - return RespBuilder.buildSuccess(new PageResult(count, page, limit, restList)); | |
| 606 | + return RespBuilder.buildSuccess(new PageResult(0, page, limit, null)); | |
| 589 | 607 | } |
| 590 | 608 | |
| 591 | 609 | @Override |
| ... | ... | @@ -742,7 +760,7 @@ |
| 742 | 760 | if(startDate != null && endDate != null) { |
| 743 | 761 | c.and("bookbuildingDate").gte(startDate).lt(DateUtil.addDay(endDate, 1)); |
| 744 | 762 | } |
| 745 | - List<Patients> patients = mongoTemplate.find(Query.query(c), Patients.class); | |
| 763 | + List<Patients> patients = mongoTemplate.find(Query.query(c).with(new Sort(Sort.Direction.DESC, "created")), Patients.class); | |
| 746 | 764 | return patients; |
| 747 | 765 | } |
| 748 | 766 |