Commit 573ff7de01fffbb75674cea748d0b886b18b52aa
1 parent
1e6ed3f4c0
Exists in
master
and in
6 other branches
加排序
Showing 6 changed files with 119 additions and 24 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/PatientWeightServiceImpl.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 @
573ff7d
platform-biz-service/src/main/resources/mainOrm/master/CouponMapper.xml
View file @
573ff7d
... | ... | @@ -560,26 +560,26 @@ |
560 | 560 | |
561 | 561 | <select id="findUnUsedCount" parameterType="map" resultType="integer"> |
562 | 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 | |
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, b.name as hospitalName | |
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 | 583 | ) a |
584 | 584 | </select> |
585 | 585 | |
... | ... | @@ -634,5 +634,45 @@ |
634 | 634 | ) a |
635 | 635 | </select> |
636 | 636 | |
637 | + <select id="findUnUsedPeopleInfo" parameterType="map" resultType="string"> | |
638 | + select user_id from coupon_info a, organization b | |
639 | + where a.create_hospital_id = b.id and a.status = 1 and a.create_hospital_id = #{hospitalId} | |
640 | + and user_id in | |
641 | + <foreach collection="userIds" open="(" close=")" separator="," item="uid"> | |
642 | + #{uid} | |
643 | + </foreach> | |
644 | + <if test="provinceId != null and provinceId != ''"> | |
645 | + and b.province_id = #{provinceId} | |
646 | + </if> | |
647 | + <if test="cityId != null and cityId != '' "> | |
648 | + and b.city_id = #{cityId} | |
649 | + </if> | |
650 | + <if test="areaId != null and areaId != ''"> | |
651 | + and b.area_id = #{areaId} | |
652 | + </if> | |
653 | + <if test="page != null and limit != null"> | |
654 | + limit #{page}, #{limit} | |
655 | + </if> | |
656 | + </select> | |
657 | + | |
658 | + <select id="findUnUsedPeopleInfoCount" resultType="integer"> | |
659 | + select count(1) from ( | |
660 | + select user_id from coupon_info a, organization b | |
661 | + where a.create_hospital_id = b.id and a.status = 1 and a.create_hospital_id = #{hospitalId} | |
662 | + and user_id in | |
663 | + <foreach collection="userIds" open="(" close=")" separator="," item="uid"> | |
664 | + #{uid} | |
665 | + </foreach> | |
666 | + <if test="provinceId != null and provinceId != ''"> | |
667 | + and b.province_id = #{provinceId} | |
668 | + </if> | |
669 | + <if test="cityId != null and cityId != '' "> | |
670 | + and b.city_id = #{cityId} | |
671 | + </if> | |
672 | + <if test="areaId != null and areaId != ''"> | |
673 | + and b.area_id = #{areaId} | |
674 | + </if> | |
675 | + ) a | |
676 | + </select> | |
637 | 677 | </mapper> |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/ReportController.java
View file @
573ff7d
... | ... | @@ -81,6 +81,16 @@ |
81 | 81 | } |
82 | 82 | |
83 | 83 | /** |
84 | + * 未使用优惠券--人数统计详情 | |
85 | + */ | |
86 | + @RequestMapping(value = "/coupon/unUsed/people/info", method = RequestMethod.GET) | |
87 | + @ResponseBody | |
88 | + @TokenRequired | |
89 | + public BaseObjectResponse unUsedPeopleInfo(Date startDate, Date endDate, String provinceId, String cityId, String areaId, String hospitalId, Integer page, Integer limit, HttpServletRequest request) { | |
90 | + return reportService.unUsedPeopleInfo(startDate, endDate, provinceId, cityId, areaId, hospitalId, page, limit, getUserId(request)); | |
91 | + } | |
92 | + | |
93 | + /** | |
84 | 94 | * 未使用优惠券统计详情 |
85 | 95 | */ |
86 | 96 | @RequestMapping(value = "/coupon/unUsed/info", method = RequestMethod.GET) |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/IReportService.java
View file @
573ff7d
... | ... | @@ -95,5 +95,7 @@ |
95 | 95 | BaseObjectResponse unUsed(Date startDate, Date endDate, String provinceId, String cityId, String areaId, String hospitalId, Integer page, Integer limit, Integer userId); |
96 | 96 | |
97 | 97 | void unUsedExport(Date startDate, Date endDate, String provinceId, String cityId, String areaId, String hospitalId, Integer userId, HttpServletResponse response); |
98 | + | |
99 | + BaseObjectResponse unUsedPeopleInfo(Date startDate, Date endDate, String provinceId, String cityId, String areaId, String hospitalId, Integer page, Integer limit, Integer userId); | |
98 | 100 | } |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/PatientWeightServiceImpl.java
View file @
573ff7d
... | ... | @@ -214,7 +214,7 @@ |
214 | 214 | } |
215 | 215 | criteria.and("patientId").in(ids); |
216 | 216 | |
217 | - PageResult pageResult = findMongoPage(PatientWeight.class, new Query(criteria).with(new Sort(Sort.Direction.DESC, "checkTime")), page, limit); | |
217 | + PageResult pageResult = findMongoPage(PatientWeight.class, new Query(criteria).with(new Sort(Sort.Direction.DESC, "created")), page, limit); | |
218 | 218 | List<PatientWeight> patientWeights = (List<PatientWeight>) pageResult.getGrid(); |
219 | 219 | List<Map<String, Object>> restMap = new ArrayList<>(); |
220 | 220 | if(CollectionUtils.isNotEmpty(patientWeights)) { |
... | ... | @@ -558,7 +558,7 @@ |
558 | 558 | param.put("bregmatic", bregmatic); |
559 | 559 | param.put("bregmaticOther", bregmaticOther); |
560 | 560 | String s1 = HttpClientUtil.doPost(server.getAddress() + "/patient/weight/sync/update", param, "UTF-8"); |
561 | - System.out.println("add result>> " + s1); | |
561 | + System.out.println("add result>> " + s1 + "param: " + param); | |
562 | 562 | } |
563 | 563 | }).start(); |
564 | 564 | } |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/ReportServiceImpl.java
View file @
573ff7d
... | ... | @@ -581,8 +581,8 @@ |
581 | 581 | Map<String, Object> param = CollectionUtils.createMap("hospitalId", hospitalId, "userIds", userIds, "provinceId", provinceId, "cityId", cityId, "areaId", areaId, "page", (page - 1) * limit, "limit", limit); |
582 | 582 | List<Map<String, Object>> restList = couponMapper.findUnUsedInfo(param); |
583 | 583 | for (Map<String, Object> map : restList) { |
584 | - map.put("cityName", map.get("city_id")); | |
585 | - map.put("areaName", map.get("area_id")); | |
584 | + map.put("cityName", findName(map.get("city_id"))); | |
585 | + map.put("areaName", findName(map.get("area_id"))); | |
586 | 586 | } |
587 | 587 | Integer count = couponMapper.findUnUsedInfoCount(param); |
588 | 588 | return RespBuilder.buildSuccess(new PageResult(count, page, limit, restList)); |
... | ... | @@ -639,6 +639,46 @@ |
639 | 639 | } |
640 | 640 | |
641 | 641 | ResponseUtil.responseExcel(cnames, results, response); |
642 | + } | |
643 | + | |
644 | + @Override | |
645 | + public BaseObjectResponse unUsedPeopleInfo(Date startDate, Date endDate, String provinceId, String cityId, String areaId, String hospitalId, Integer page, Integer limit, Integer userId) { | |
646 | + List<String> hospitalIds = Arrays.asList(hospitalId); | |
647 | + List<Map<String, Object>> datas = couponMapper.findHospitalInfoByIds(hospitalIds); | |
648 | + List<Patients> patients = getPatients(hospitalIds, datas, startDate, endDate, provinceId, cityId, areaId, true); | |
649 | + if(CollectionUtils.isNotEmpty(patients)) { | |
650 | + Set<String> userIds = new HashSet<>(); | |
651 | + for (Patients patient : patients) { | |
652 | + userIds.add(patient.getPid()); | |
653 | + } | |
654 | + Map<String, Object> param = CollectionUtils.createMap("hospitalId", hospitalId, "userIds", userIds, "provinceId", provinceId, "cityId", cityId, "areaId", areaId, "page", (page - 1) * limit, "limit", limit); | |
655 | + List<String> pids = couponMapper.findUnUsedPeopleInfo(param); | |
656 | + if(CollectionUtils.isNotEmpty(pids)) { | |
657 | + Integer count = couponMapper.findUnUsedPeopleInfoCount(param); | |
658 | + List<Map<String, Object>> restList = new ArrayList<>(); | |
659 | + for (String pid : pids) { | |
660 | + Map<String, Object> temp = new HashMap<>(); | |
661 | + Patients pt = mongoTemplate.findOne(Query.query(Criteria.where("pid").is(pid)).with(new Sort(Sort.Direction.DESC, "created")), Patients.class); | |
662 | + if(pt != null) { | |
663 | + temp.put("username", pt.getUsername()); | |
664 | + temp.put("phone", com.lyms.platform.common.utils.StringUtils.encryPhone(pt.getPhone())); | |
665 | + temp.put("cardNo", com.lyms.platform.common.utils.StringUtils.encryCardNo(pt.getCardNo())); | |
666 | + String residenceAddress = findName(pt.getProvinceRegisterId()) + findName(pt.getCityRegisterId()) + findName(pt.getAreaRegisterId()) + findName(pt.getStreetRegisterId()) + pt.getAddressRegister(); | |
667 | + temp.put("residenceAddress", residenceAddress.replace("null", "")); /** 居住地 */ | |
668 | + String householdAddress = findName(pt.getProvinceId()) + findName(pt.getCityId()) + findName(pt.getAreaId()) + findName(pt.getStreetId()) + pt.getAddress(); | |
669 | + temp.put("householdAddress", householdAddress.replace("null", "")); /** 户籍地 */ | |
670 | + temp.put("week", DateUtil.getWeekDesc(pt.getLastMenses(), new Date())); /** 当前孕周 */ | |
671 | + temp.put("buildWeek", DateUtil.getWeekDesc(pt.getBookbuildingDate(), new Date())); /** 建档孕周 */ | |
672 | + temp.put("buildDate", DateUtil.getyyyy_MM_dd(pt.getBookbuildingDate())); /** 建档日期 */ | |
673 | + temp.put("doctorName", couponMapper.getUserName(pt.getBookbuildingDoctor())); | |
674 | + temp.put("hospitalName", couponMapper.findHospitalNameById(pt.getHospitalId())); | |
675 | + restList.add(temp); | |
676 | + } | |
677 | + } | |
678 | + return RespBuilder.buildSuccess(new PageResult(count, page, limit, restList)); | |
679 | + } | |
680 | + } | |
681 | + return RespBuilder.buildSuccess(new PageResult(0, page, limit, null)); | |
642 | 682 | } |
643 | 683 | |
644 | 684 |