Commit 9415b1b1d12e486fce66e0edf9b4e88c1895c0ea
1 parent
e3952cbc1e
Exists in
master
and in
1 other branch
统计
Showing 5 changed files with 135 additions and 7 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 @
9415b1b
| ... | ... | @@ -102,5 +102,9 @@ |
| 102 | 102 | Map<String,Object> findHospitalInfoById(String hospitalId); |
| 103 | 103 | |
| 104 | 104 | List<Map<String,Object>> findHospitalInfoByIds(List<String> hospitalIds); |
| 105 | + | |
| 106 | + List<Map<String,Object>> findUnUsedInfo(Map<String, Object> param); | |
| 107 | + | |
| 108 | + Integer findUnUsedInfoCount(Map<String, Object> param); | |
| 105 | 109 | } |
platform-biz-service/src/main/resources/mainOrm/master/CouponMapper.xml
View file @
9415b1b
| ... | ... | @@ -532,5 +532,56 @@ |
| 532 | 532 | </foreach> and yn = 1 |
| 533 | 533 | </select> |
| 534 | 534 | |
| 535 | + <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 | |
| 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="findUnUsedInfoCount" 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 | |
| 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 | </mapper> |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/ReportController.java
View file @
9415b1b
| ... | ... | @@ -60,6 +60,36 @@ |
| 60 | 60 | return reportService.unSendInfo(startDate, endDate, provinceId, cityId, areaId, hospitalId, page, limit, getUserId(request)); |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | + /** | |
| 64 | + * 未使用优惠券统计 | |
| 65 | + */ | |
| 66 | + @RequestMapping(value = "/coupon/unUsed", method = RequestMethod.GET) | |
| 67 | + @ResponseBody | |
| 68 | + @TokenRequired | |
| 69 | + public BaseObjectResponse unUsed(Date startDate, Date endDate, String provinceId, String cityId, String areaId, String hospitalId, Integer page, Integer limit, HttpServletRequest request) { | |
| 70 | + return reportService.unUsed(startDate, endDate, provinceId, cityId, areaId, hospitalId, page, limit, getUserId(request)); | |
| 71 | + } | |
| 72 | + | |
| 73 | + /** | |
| 74 | + * 未使用优惠券统计导出 | |
| 75 | + */ | |
| 76 | + @RequestMapping(value = "/coupon/unUsed/export", method = RequestMethod.GET) | |
| 77 | + @ResponseBody | |
| 78 | + @TokenRequired | |
| 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); | |
| 81 | + } | |
| 82 | + | |
| 83 | + /** | |
| 84 | + * 未使用优惠券统计详情 | |
| 85 | + */ | |
| 86 | + @RequestMapping(value = "/coupon/unUsed/info", method = RequestMethod.GET) | |
| 87 | + @ResponseBody | |
| 88 | + @TokenRequired | |
| 89 | + public BaseObjectResponse unUsedInfo(Date startDate, Date endDate, String provinceId, String cityId, String areaId, String hospitalId, Integer page, Integer limit, HttpServletRequest request) { | |
| 90 | + return reportService.unUsedInfo(startDate, endDate, provinceId, cityId, areaId, hospitalId, page, limit, getUserId(request)); | |
| 91 | + } | |
| 92 | + | |
| 63 | 93 | |
| 64 | 94 | /** |
| 65 | 95 | * 产检次数分布统计(已废弃 采用 getCheckNumber) |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/IReportService.java
View file @
9415b1b
| ... | ... | @@ -89,5 +89,9 @@ |
| 89 | 89 | BaseObjectResponse unSendInfo(Date startDate, Date endDate, String provinceId, String cityId, String areaId, String hospitalId, Integer page, Integer limit, Integer userId); |
| 90 | 90 | |
| 91 | 91 | void unSendExport(Date startDate, Date endDate, String provinceId, String cityId, String areaId, String hospitalId, Integer userId, HttpServletResponse response); |
| 92 | + | |
| 93 | + BaseObjectResponse unUsedInfo(Date startDate, Date endDate, String provinceId, String cityId, String areaId, String hospitalId, Integer page, Integer limit, Integer userId); | |
| 94 | + | |
| 95 | + BaseObjectResponse unUsed(Date startDate, Date endDate, String provinceId, String cityId, String areaId, String hospitalId, Integer page, Integer limit, Integer userId); | |
| 92 | 96 | } |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/ReportServiceImpl.java
View file @
9415b1b
| ... | ... | @@ -30,6 +30,7 @@ |
| 30 | 30 | import org.springframework.data.mongodb.core.query.Query; |
| 31 | 31 | import org.springframework.stereotype.Service; |
| 32 | 32 | import org.springframework.util.Assert; |
| 33 | +import scala.annotation.target.param; | |
| 33 | 34 | |
| 34 | 35 | import javax.servlet.http.HttpServletResponse; |
| 35 | 36 | import java.sql.PreparedStatement; |
| ... | ... | @@ -512,7 +513,7 @@ |
| 512 | 513 | Map<String, Integer> hospitalPatientCount = new HashMap<>(); |
| 513 | 514 | |
| 514 | 515 | if(CollectionUtils.isNotEmpty(hospitalIds)) { |
| 515 | - List<Patients> patients = getPatients(hospitalIds, datas, startDate, endDate, provinceId, cityId, areaId, hospitalId, userId); | |
| 516 | + List<Patients> patients = getPatients(hospitalIds, datas, startDate, endDate, provinceId, cityId, areaId, false); | |
| 516 | 517 | for (Patients patient : patients) { |
| 517 | 518 | if(hospitalPatientCount.containsKey(patient.getHospitalId())) { |
| 518 | 519 | hospitalPatientCount.put(patient.getHospitalId(), hospitalPatientCount.get(patient.getHospitalId()) + 1); |
| 519 | 520 | |
| 520 | 521 | |
| 521 | 522 | |
| 522 | 523 | |
| ... | ... | @@ -567,27 +568,65 @@ |
| 567 | 568 | ResponseUtil.responseExcel(cnames, results, response); |
| 568 | 569 | } |
| 569 | 570 | |
| 571 | + @Override | |
| 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)); | |
| 585 | + } | |
| 586 | + return RespBuilder.buildSuccess(new PageResult(0, page, limit, null)); | |
| 587 | + } | |
| 570 | 588 | |
| 571 | 589 | @Override |
| 590 | + public BaseObjectResponse unUsed(Date startDate, Date endDate, String provinceId, String cityId, String areaId, String hospitalId, Integer page, Integer limit, Integer userId) { | |
| 591 | + List<String> hospitalIds = getHospitalIds(userId, hospitalId); | |
| 592 | + if(CollectionUtils.isNotEmpty(hospitalIds)) { | |
| 593 | + List<Map<String, Object>> datas = couponMapper.findHospitalInfoByIds(hospitalIds); | |
| 594 | + List<Patients> patients = getPatients(hospitalIds, datas, startDate, endDate, provinceId, cityId, areaId, true); | |
| 595 | + Set<String> userIds = new HashSet<>(); | |
| 596 | + for (Patients patient : patients) { | |
| 597 | + userIds.add(patient.getPid()); | |
| 598 | + } | |
| 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); | |
| 603 | + return RespBuilder.buildSuccess(new PageResult(count, page, limit, restList)); | |
| 604 | + } | |
| 605 | + return RespBuilder.buildSuccess(new PageResult(0, page, limit, null)); | |
| 606 | + } | |
| 607 | + | |
| 608 | + | |
| 609 | + @Override | |
| 572 | 610 | public BaseObjectResponse unSendInfo(Date startDate, Date endDate, String provinceId, String cityId, String areaId, String hospitalId, Integer page, Integer limit, Integer userId) { |
| 573 | 611 | List<String> hospitalIds = getHospitalIds(userId, hospitalId); |
| 574 | 612 | List<Map<String, Object>> datas = couponMapper.findHospitalInfoByIds(hospitalIds); |
| 575 | 613 | if(CollectionUtils.isNotEmpty(hospitalIds)) { |
| 576 | - List<Patients> patients = getPatients(hospitalIds, datas, startDate, endDate, provinceId, cityId, areaId, hospitalId, userId); | |
| 614 | + List<Patients> patients = getPatients(hospitalIds, datas, startDate, endDate, provinceId, cityId, areaId, false); | |
| 577 | 615 | List<Map<String, Object>> restList = new ArrayList<>(); |
| 578 | 616 | List<Patients> pageRows = CollectionUtils.getPageIds(patients, page, limit); |
| 579 | 617 | for (Patients patient : pageRows) { |
| 580 | 618 | Map<String, Object> temp = new HashMap<>(); |
| 581 | 619 | temp.put("username", patient.getUsername()); |
| 582 | 620 | temp.put("phone", com.lyms.platform.common.utils.StringUtils.encryPhone(patient.getPhone())); |
| 621 | + temp.put("cardNo", com.lyms.platform.common.utils.StringUtils.encryCardNo(patient.getCardNo())); | |
| 583 | 622 | String residenceAddress = findName(patient.getProvinceRegisterId()) + findName(patient.getCityRegisterId()) + findName(patient.getAreaRegisterId()) + findName(patient.getStreetRegisterId()) + patient.getAddressRegister(); |
| 584 | 623 | temp.put("residenceAddress", residenceAddress.replace("null", "")); /** 居住地 */ |
| 585 | 624 | String householdAddress = findName(patient.getProvinceId()) + findName(patient.getCityId()) + findName(patient.getAreaId()) + findName(patient.getStreetId()) + patient.getAddress(); |
| 586 | 625 | temp.put("householdAddress", householdAddress.replace("null", "")); /** 户籍地 */ |
| 587 | 626 | temp.put("lastMenses", DateUtil.getyyyy_MM_dd(patient.getLastMenses())); |
| 588 | - temp.put("week", DateUtil.getWeekDesc(patient.getLastMenses(), new Date())); | |
| 589 | - temp.put("buildWeek", DateUtil.getWeekDesc(patient.getBookbuildingDate(), new Date())); | |
| 590 | - temp.put("buildWeek", DateUtil.getyyyy_MM_dd(patient.getBookbuildingDate())); | |
| 627 | + temp.put("week", DateUtil.getWeekDesc(patient.getLastMenses(), new Date())); /** 当前孕周 */ | |
| 628 | + temp.put("buildWeek", DateUtil.getWeekDesc(patient.getBookbuildingDate(), new Date())); /** 建档孕周 */ | |
| 629 | + temp.put("buildDate", DateUtil.getyyyy_MM_dd(patient.getBookbuildingDate())); /** 建档日期 */ | |
| 591 | 630 | temp.put("doctorName", couponMapper.getUserName(patient.getBookbuildingDoctor())); |
| 592 | 631 | temp.put("hospitalName", couponMapper.findHospitalNameById(patient.getHospitalId())); |
| 593 | 632 | restList.add(temp); |
| ... | ... | @@ -597,7 +636,7 @@ |
| 597 | 636 | } |
| 598 | 637 | return RespBuilder.buildSuccess("hospitalIds为null"); |
| 599 | 638 | } |
| 600 | - private List<Patients> getPatients(List<String> hospitalIds, List<Map<String, Object>> datas, Date startDate, Date endDate, String provinceId, String cityId, String areaId, String hospitalId, Integer userId) { | |
| 639 | + private List<Patients> getPatients(List<String> hospitalIds, List<Map<String, Object>> datas, Date startDate, Date endDate, String provinceId, String cityId, String areaId, boolean isSendCoupon) { | |
| 601 | 640 | Iterator<String> iterator = hospitalIds.iterator(); |
| 602 | 641 | while (iterator.hasNext()) { |
| 603 | 642 | String id = iterator.next(); |
| ... | ... | @@ -621,7 +660,7 @@ |
| 621 | 660 | } |
| 622 | 661 | } |
| 623 | 662 | Criteria c = new Criteria(); |
| 624 | - c.and("hospitalId").in(hospitalIds).and("isSendCoupon").ne(true).and("yn").ne(0); | |
| 663 | + c.and("hospitalId").in(hospitalIds).and("isSendCoupon").ne(!isSendCoupon).and("yn").ne(0); | |
| 625 | 664 | if(startDate != null && endDate != null) { |
| 626 | 665 | c.and("bookbuildingDate").gte(startDate).lt(DateUtil.addDay(endDate, 1)); |
| 627 | 666 | } |