Commit 8be41989d2ee8343b6fa729c87a9e3f6cfa56cef
1 parent
b2011fe4f2
Exists in
master
and in
6 other branches
统计
Showing 5 changed files with 114 additions and 21 deletions
- platform-biz-service/src/main/java/com/lyms/platform/permission/dao/master/CouponMapper.java
- platform-biz-service/src/main/resources/mainOrm/master/CouponMapper.xml
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/ReportController.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/IReportService.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/ReportServiceImpl.java
platform-biz-service/src/main/java/com/lyms/platform/permission/dao/master/CouponMapper.java
View file @
8be4198
... | ... | @@ -106,5 +106,10 @@ |
106 | 106 | List<Map<String,Object>> findUnUsedInfo(Map<String, Object> param); |
107 | 107 | |
108 | 108 | Integer findUnUsedInfoCount(Map<String, Object> param); |
109 | + | |
110 | + List<Map<String,Object>> findUnUsed(Map<String, Object> param); | |
111 | + | |
112 | + Integer findUnUsedCount(Map<String, Object> param); | |
113 | + | |
109 | 114 | } |
platform-biz-service/src/main/resources/mainOrm/master/CouponMapper.xml
View file @
8be4198
... | ... | @@ -532,8 +532,59 @@ |
532 | 532 | </foreach> and yn = 1 |
533 | 533 | </select> |
534 | 534 | |
535 | + <select id="findUnUsed" parameterType="map" resultType="map"> | |
536 | + 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, b.name as hospitalName | |
537 | + from coupon_info a, organization b | |
538 | + where a.create_hospital_id = b.id and a.status = 1 and a.create_hospital_id in | |
539 | + <foreach collection="hospitalIds" open="(" close=")" separator="," item="hid"> | |
540 | + #{hid} | |
541 | + </foreach> | |
542 | + and user_id in | |
543 | + <foreach collection="userIds" open="(" close=")" separator="," item="uid"> | |
544 | + #{uid} | |
545 | + </foreach> | |
546 | + <if test="provinceId != null and provinceId != ''"> | |
547 | + and b.province_id = #{provinceId} | |
548 | + </if> | |
549 | + <if test="cityId != null and cityId != '' "> | |
550 | + and b.city_id = #{cityId} | |
551 | + </if> | |
552 | + <if test="areaId != null and areaId != ''"> | |
553 | + and b.area_id = #{areaId} | |
554 | + </if> | |
555 | + group by a.create_hospital_id | |
556 | + <if test="page != null and limit != null"> | |
557 | + limit #{page}, #{limit} | |
558 | + </if> | |
559 | + </select> | |
560 | + | |
561 | + <select id="findUnUsedCount" parameterType="map" resultType="integer"> | |
562 | + select count(1) from ( | |
563 | + 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 | |
564 | + from coupon_info a, organization b | |
565 | + where a.create_hospital_id = b.id and a.status = 1 and a.create_hospital_id in | |
566 | + <foreach collection="hospitalIds" open="(" close=")" separator="," item="hid"> | |
567 | + #{hid} | |
568 | + </foreach> | |
569 | + and user_id in | |
570 | + <foreach collection="userIds" open="(" close=")" separator="," item="uid"> | |
571 | + #{uid} | |
572 | + </foreach> | |
573 | + <if test="provinceId != null and provinceId != ''"> | |
574 | + and b.province_id = #{provinceId} | |
575 | + </if> | |
576 | + <if test="cityId != null and cityId != '' "> | |
577 | + and b.city_id = #{cityId} | |
578 | + </if> | |
579 | + <if test="areaId != null and areaId != ''"> | |
580 | + and b.area_id = #{areaId} | |
581 | + </if> | |
582 | + group by a.create_hospital_id | |
583 | + ) a | |
584 | + </select> | |
585 | + | |
535 | 586 | <select id="findUnUsedInfo" parameterType="map" resultType="map"> |
536 | - 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 | |
587 | + select user_id as un_used_people, b.province_id, b.city_id, b.area_id, b.name as hospitalName | |
537 | 588 | from coupon_info a, organization b |
538 | 589 | where a.create_hospital_id = b.id and a.status = 1 and a.create_hospital_id in |
539 | 590 | <foreach collection="hospitalIds" open="(" close=")" separator="," item="hid"> |
... | ... | @@ -560,7 +611,7 @@ |
560 | 611 | |
561 | 612 | <select id="findUnUsedInfoCount" parameterType="map" resultType="integer"> |
562 | 613 | select count(1) from ( |
563 | - 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 | |
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 | |
564 | 615 | from coupon_info a, organization b |
565 | 616 | where a.create_hospital_id = b.id and a.status = 1 and a.create_hospital_id in |
566 | 617 | <foreach collection="hospitalIds" open="(" close=")" separator="," item="hid"> |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/ReportController.java
View file @
8be4198
... | ... | @@ -77,7 +77,7 @@ |
77 | 77 | @ResponseBody |
78 | 78 | @TokenRequired |
79 | 79 | public void unUsedExport(Date startDate, Date endDate, String provinceId, String cityId, String areaId, String hospitalId, HttpServletRequest request, HttpServletResponse response) { |
80 | - reportService.unSendExport(startDate, endDate, provinceId, cityId, areaId, hospitalId, getUserId(request), response); | |
80 | + reportService.unUsedExport(startDate, endDate, provinceId, cityId, areaId, hospitalId, getUserId(request), response); | |
81 | 81 | } |
82 | 82 | |
83 | 83 | /** |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/IReportService.java
View file @
8be4198
... | ... | @@ -93,5 +93,7 @@ |
93 | 93 | BaseObjectResponse unUsedInfo(Date startDate, Date endDate, String provinceId, String cityId, String areaId, String hospitalId, Integer page, Integer limit, Integer userId); |
94 | 94 | |
95 | 95 | BaseObjectResponse unUsed(Date startDate, Date endDate, String provinceId, String cityId, String areaId, String hospitalId, Integer page, Integer limit, Integer userId); |
96 | + | |
97 | + void unUsedExport(Date startDate, Date endDate, String provinceId, String cityId, String areaId, String hospitalId, Integer userId, HttpServletResponse response); | |
96 | 98 | } |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/ReportServiceImpl.java
View file @
8be4198
... | ... | @@ -570,20 +570,22 @@ |
570 | 570 | |
571 | 571 | @Override |
572 | 572 | public BaseObjectResponse unUsedInfo(Date startDate, Date endDate, String provinceId, String cityId, String areaId, String hospitalId, Integer page, Integer limit, Integer userId) { |
573 | - List<String> hospitalIds = getHospitalIds(userId, hospitalId); | |
574 | - if(CollectionUtils.isNotEmpty(hospitalIds)) { | |
575 | - List<Map<String, Object>> datas = couponMapper.findHospitalInfoByIds(hospitalIds); | |
576 | - List<Patients> patients = getPatients(hospitalIds, datas, startDate, endDate, provinceId, cityId, areaId, false); | |
577 | - Set<String> userIds = new HashSet<>(); | |
578 | - for (Patients patient : patients) { | |
579 | - userIds.add(patient.getPid()); | |
580 | - } | |
581 | - Map<String, Object> param = CollectionUtils.createMap("hospitalIds", hospitalIds, "userIds", userIds, "provinceId", provinceId, "cityId", cityId, "areaId", areaId, "page", page, "limit", limit); | |
582 | - List<Map<String, Object>> restList = couponMapper.findUnUsedInfo(param); | |
583 | - Integer count = couponMapper.findUnUsedInfoCount(param); | |
584 | - return RespBuilder.buildSuccess(new PageResult(count, page, limit, restList)); | |
573 | + List<String> hospitalIds = new ArrayList<>(); | |
574 | + hospitalIds.add(hospitalId); | |
575 | + List<Map<String, Object>> datas = couponMapper.findHospitalInfoByIds(hospitalIds); | |
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()); | |
585 | 580 | } |
586 | - return RespBuilder.buildSuccess(new PageResult(0, page, limit, null)); | |
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", map.get("city_id")); | |
585 | + map.put("areaName", map.get("area_id")); | |
586 | + } | |
587 | + Integer count = couponMapper.findUnUsedInfoCount(param); | |
588 | + return RespBuilder.buildSuccess(new PageResult(count, page, limit, restList)); | |
587 | 589 | } |
588 | 590 | |
589 | 591 | @Override |
590 | 592 | |
591 | 593 | |
... | ... | @@ -596,16 +598,50 @@ |
596 | 598 | for (Patients patient : patients) { |
597 | 599 | userIds.add(patient.getPid()); |
598 | 600 | } |
599 | - Map<String, Object> param = CollectionUtils.createMap("hospitalIds", hospitalIds, "userIds", userIds, "provinceId", provinceId, "cityId", cityId, "areaId", areaId, "page", page, "limit", limit); | |
600 | - System.out.println(param); | |
601 | - List<Map<String, Object>> restList = couponMapper.findUnUsedInfo(param); | |
602 | - Integer count = couponMapper.findUnUsedInfoCount(param); | |
601 | + Map<String, Object> param = CollectionUtils.createMap("hospitalIds", hospitalIds, "userIds", userIds, "provinceId", provinceId, "cityId", cityId, "areaId", areaId, "page", (page - 1) * limit, "limit", limit); | |
602 | + List<Map<String, Object>> restList = couponMapper.findUnUsed(param); | |
603 | + for (Map<String, Object> map : restList) { | |
604 | + map.put("cityName", map.get("city_id")); | |
605 | + map.put("areaName", map.get("area_id")); | |
606 | + } | |
607 | + Integer count = couponMapper.findUnUsedCount(param); | |
603 | 608 | return RespBuilder.buildSuccess(new PageResult(count, page, limit, restList)); |
604 | 609 | } |
605 | 610 | return RespBuilder.buildSuccess(new PageResult(0, page, limit, null)); |
606 | 611 | } |
607 | 612 | |
613 | + @Override | |
614 | + public void unUsedExport(Date startDate, Date endDate, String provinceId, String cityId, String areaId, String hospitalId, Integer userId, HttpServletResponse response) { | |
615 | + BaseObjectResponse rest = unUsed(startDate, endDate, provinceId, cityId, areaId, hospitalId, 1, Integer.MAX_VALUE, userId); | |
616 | + PageResult pageResult = (PageResult) rest.getData(); | |
617 | + List<Map<String, Object>> datas = (List<Map<String, Object>>) pageResult.getGrid(); | |
618 | + Map<String, String> cnames = new LinkedHashMap<>(); | |
619 | + cnames.put("id", "#"); | |
620 | + cnames.put("cityName", "地市名称"); | |
621 | + cnames.put("areaName", "区县名称"); | |
622 | + cnames.put("hospitalName", "医院名称"); | |
623 | + cnames.put("un_used_people", "未使用券人数"); | |
624 | + cnames.put("un_used_coupon_count", "未使用券产检次数"); | |
608 | 625 | |
626 | + List<Map<String,Object>> results = new ArrayList<>(); | |
627 | + if(org.apache.commons.collections.CollectionUtils.isNotEmpty(datas)) { | |
628 | + int i = 0; | |
629 | + for (Map<String, Object> data : datas) { | |
630 | + Map<String, Object> result = new LinkedHashMap<>(); | |
631 | + result.put("id", ++i); | |
632 | + result.put("cityName", data.get("cityName")); | |
633 | + result.put("areaName", data.get("areaName")); | |
634 | + result.put("hospitalName", data.get("hospitalName")); | |
635 | + result.put("un_used_people", data.get("un_used_people")); | |
636 | + result.put("un_used_coupon_count", data.get("un_used_coupon_count")); | |
637 | + results.add(result); | |
638 | + } | |
639 | + } | |
640 | + | |
641 | + ResponseUtil.responseExcel(cnames, results, response); | |
642 | + } | |
643 | + | |
644 | + | |
609 | 645 | @Override |
610 | 646 | public BaseObjectResponse unSendInfo(Date startDate, Date endDate, String provinceId, String cityId, String areaId, String hospitalId, Integer page, Integer limit, Integer userId) { |
611 | 647 | List<String> hospitalIds = getHospitalIds(userId, hospitalId); |
... | ... | @@ -664,7 +700,6 @@ |
664 | 700 | if(startDate != null && endDate != null) { |
665 | 701 | c.and("bookbuildingDate").gte(startDate).lt(DateUtil.addDay(endDate, 1)); |
666 | 702 | } |
667 | - | |
668 | 703 | List<Patients> patients = mongoTemplate.find(Query.query(c), Patients.class); |
669 | 704 | return patients; |
670 | 705 | } |