Commit d0cd20f18233f35c35c9994381bee1fc6a297531
1 parent
c370abc530
Exists in
master
and in
6 other branches
改bug
Showing 3 changed files with 201 additions and 9 deletions
platform-biz-service/src/main/java/com/lyms/platform/permission/dao/master/CouponMapper.java
View file @
d0cd20f
platform-biz-service/src/main/resources/mainOrm/master/CouponMapper.xml
View file @
d0cd20f
| ... | ... | @@ -758,5 +758,13 @@ |
| 758 | 758 | </foreach> |
| 759 | 759 | order by a.user_id |
| 760 | 760 | </select> |
| 761 | + | |
| 762 | + <select id="findUsededId" parameterType="list" resultType="string"> | |
| 763 | + select used_id from coupon_info where used_id in | |
| 764 | + <foreach collection="list" item="id" open="(" separator="," close=")"> | |
| 765 | + #{id} | |
| 766 | + </foreach> | |
| 767 | + </select> | |
| 768 | + | |
| 761 | 769 | </mapper> |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/ReportServiceImpl.java
View file @
d0cd20f
| ... | ... | @@ -705,14 +705,155 @@ |
| 705 | 705 | return ""; |
| 706 | 706 | } |
| 707 | 707 | |
| 708 | - private List<String> getNeedUsedIds(List<Patients> patients, List<AntExChuModel> antExChuModels, List<AntenatalExaminationModel> antenatalExaminationModels, List<MaternalDeliverModel> maternalDeliverModels, List<DischargeAbstractMotherModel> deliverModels, List<PostReviewModel> postReviewModels) { | |
| 708 | + private List<String> getNeedUsedIds(List<Patients> patients, List<AntExChuModel> antExChuModels, List<AntenatalExaminationModel> antenatalExaminationModels, | |
| 709 | + List<MaternalDeliverModel> maternalDeliverModels, List<DischargeAbstractMotherModel> deliverModels, List<PostReviewModel> postReviewModels) { | |
| 709 | 710 | List<String> needUsedIds = new ArrayList<>(); |
| 710 | 711 | for (Patients patient : patients) { |
| 711 | 712 | needUsedIds.add(patient.getId()); |
| 712 | 713 | } |
| 714 | + for (AntExChuModel antExChuModel : antExChuModels) { | |
| 715 | + needUsedIds.add(antExChuModel.getId()); | |
| 716 | + } | |
| 717 | + for (AntenatalExaminationModel antenatalExaminationModel : antenatalExaminationModels) { | |
| 718 | + needUsedIds.add(antenatalExaminationModel.getId()); | |
| 719 | + } | |
| 720 | + for (MaternalDeliverModel maternalDeliverModel : maternalDeliverModels) { | |
| 721 | + needUsedIds.add(maternalDeliverModel.getId()); | |
| 722 | + } | |
| 723 | + for (DischargeAbstractMotherModel deliverModel : deliverModels) { | |
| 724 | + needUsedIds.add(deliverModel.getId()); | |
| 725 | + } | |
| 726 | + for (PostReviewModel postReviewModel : postReviewModels) { | |
| 727 | + needUsedIds.add(postReviewModel.getId()); | |
| 728 | + } | |
| 713 | 729 | return needUsedIds; |
| 714 | 730 | } |
| 715 | 731 | |
| 732 | + private boolean checkHospital(List<Patients> patients, List<AntExChuModel> antExChuModels, List<AntenatalExaminationModel> antenatalExaminationModels, | |
| 733 | + List<MaternalDeliverModel> maternalDeliverModels, List<DischargeAbstractMotherModel> deliverModels, List<PostReviewModel> postReviewModels, String hid, String usedId) { | |
| 734 | + for (Patients patient : patients) { | |
| 735 | + if(hid.equals(patient.getHospitalId()) && usedId.equals(patient.getId())) { | |
| 736 | + return true; | |
| 737 | + } | |
| 738 | + } | |
| 739 | + for (AntExChuModel antExChuModel : antExChuModels) { | |
| 740 | + for (Patients patient : patients) { | |
| 741 | + if(antExChuModel.getParentId().equals(patient.getId()) && patient.getHospitalId().equals(hid) && usedId.equals(antExChuModel.getId())) { | |
| 742 | + return true; | |
| 743 | + } | |
| 744 | + } | |
| 745 | + } | |
| 746 | + for (AntenatalExaminationModel antenatalExaminationModel : antenatalExaminationModels) { | |
| 747 | + for (Patients patient : patients) { | |
| 748 | + if(antenatalExaminationModel.getParentId().equals(patient.getId()) && patient.getHospitalId().equals(hid) && usedId.equals(antenatalExaminationModel.getId())) { | |
| 749 | + return true; | |
| 750 | + } | |
| 751 | + } | |
| 752 | + } | |
| 753 | + for (MaternalDeliverModel maternalDeliverModel : maternalDeliverModels) { | |
| 754 | + for (Patients patient : patients) { | |
| 755 | + if(maternalDeliverModel.getParentId().equals(patient.getId()) && patient.getHospitalId().equals(hid) && usedId.equals(maternalDeliverModel.getId())) { | |
| 756 | + return true; | |
| 757 | + } | |
| 758 | + } | |
| 759 | + } | |
| 760 | + for (DischargeAbstractMotherModel deliverModel : deliverModels) { | |
| 761 | + for (Patients patient : patients) { | |
| 762 | + if(deliverModel.getPatientId().equals(patient.getId()) && patient.getHospitalId().equals(hid) && usedId.equals(deliverModel.getId())) { | |
| 763 | + return true; | |
| 764 | + } | |
| 765 | + } | |
| 766 | + } | |
| 767 | + for (PostReviewModel postReviewModel : postReviewModels) { | |
| 768 | + for (Patients patient : patients) { | |
| 769 | + if(postReviewModel.getParentId().equals(patient.getId()) && patient.getHospitalId().equals(hid) && usedId.equals(postReviewModel.getId())) { | |
| 770 | + return true; | |
| 771 | + } | |
| 772 | + } | |
| 773 | + } | |
| 774 | + return false; | |
| 775 | + } | |
| 776 | + | |
| 777 | + private Patients getParentByUsedId(List<Patients> patients, List<AntExChuModel> antExChuModels, List<AntenatalExaminationModel> antenatalExaminationModels, | |
| 778 | + List<MaternalDeliverModel> maternalDeliverModels, List<DischargeAbstractMotherModel> deliverModels, List<PostReviewModel> postReviewModels, String usedId) { | |
| 779 | + for (Patients patient : patients) { | |
| 780 | + if(patient.getId().equals(usedId)) { | |
| 781 | + return patient; | |
| 782 | + } | |
| 783 | + } | |
| 784 | + for (AntExChuModel antExChuModel : antExChuModels) { | |
| 785 | + for (Patients patient : patients) { | |
| 786 | + if(antExChuModel.getParentId().equals(patient.getId())) { | |
| 787 | + return patient; | |
| 788 | + } | |
| 789 | + } | |
| 790 | + } | |
| 791 | + for (AntenatalExaminationModel antenatalExaminationModel : antenatalExaminationModels) { | |
| 792 | + for (Patients patient : patients) { | |
| 793 | + if(antenatalExaminationModel.getParentId().equals(patient.getId())) { | |
| 794 | + return patient; | |
| 795 | + } | |
| 796 | + } | |
| 797 | + } | |
| 798 | + for (MaternalDeliverModel maternalDeliverModel : maternalDeliverModels) { | |
| 799 | + for (Patients patient : patients) { | |
| 800 | + if(maternalDeliverModel.getParentId().equals(patient.getId())) { | |
| 801 | + return patient; | |
| 802 | + } | |
| 803 | + } | |
| 804 | + } | |
| 805 | + for (DischargeAbstractMotherModel deliverModel : deliverModels) { | |
| 806 | + for (Patients patient : patients) { | |
| 807 | + if(deliverModel.getPatientId().equals(patient.getId())) { | |
| 808 | + return patient; | |
| 809 | + } | |
| 810 | + } | |
| 811 | + } | |
| 812 | + for (PostReviewModel postReviewModel : postReviewModels) { | |
| 813 | + for (Patients patient : patients) { | |
| 814 | + if(postReviewModel.getParentId().equals(patient.getId())) { | |
| 815 | + return patient; | |
| 816 | + } | |
| 817 | + } | |
| 818 | + } | |
| 819 | + return null; | |
| 820 | + } | |
| 821 | + | |
| 822 | + private String getCheckTimeByUsedId(List<Patients> patients, List<AntExChuModel> antExChuModels, List<AntenatalExaminationModel> antenatalExaminationModels, | |
| 823 | + List<MaternalDeliverModel> maternalDeliverModels, List<DischargeAbstractMotherModel> deliverModels, List<PostReviewModel> postReviewModels, String usedId) { | |
| 824 | + for (Patients patient : patients) { | |
| 825 | + if(patient.getId().equals(usedId)) { | |
| 826 | + return DateUtil.getyyyy_MM_dd(patient.getBookbuildingDate()); | |
| 827 | + } | |
| 828 | + } | |
| 829 | + for (AntExChuModel antExChuModel : antExChuModels) { | |
| 830 | + if(antExChuModel.getId().equals(usedId)) { | |
| 831 | + return DateUtil.getyyyy_MM_dd(antExChuModel.getCheckTime()); | |
| 832 | + } | |
| 833 | + } | |
| 834 | + for (AntenatalExaminationModel antenatalExaminationModel : antenatalExaminationModels) { | |
| 835 | + if(antenatalExaminationModel.getId().equals(usedId)) { | |
| 836 | + return DateUtil.getyyyy_MM_dd(antenatalExaminationModel.getCheckDate()); | |
| 837 | + } | |
| 838 | + } | |
| 839 | + for (MaternalDeliverModel maternalDeliverModel : maternalDeliverModels) { | |
| 840 | + if(maternalDeliverModel.getId().equals(usedId)) { | |
| 841 | + return maternalDeliverModel.getDueDate(); | |
| 842 | + } | |
| 843 | + } | |
| 844 | + for (DischargeAbstractMotherModel deliverModel : deliverModels) { | |
| 845 | + if(deliverModel.getId().equals(usedId)) { | |
| 846 | + return DateUtil.getyyyy_MM_dd(deliverModel.getLeaveHospitalDate()); | |
| 847 | + } | |
| 848 | + } | |
| 849 | + for (PostReviewModel postReviewModel : postReviewModels) { | |
| 850 | + if(postReviewModel.getId().equals(usedId)) { | |
| 851 | + return DateUtil.getyyyy_MM_dd(postReviewModel.getCheckTime()); | |
| 852 | + } | |
| 853 | + } | |
| 854 | + return ""; | |
| 855 | + } | |
| 856 | + | |
| 716 | 857 | @Override |
| 717 | 858 | public BaseObjectResponse unUsed(Date startDate, Date endDate, String provinceId, String cityId, String areaId, String hospitalId, Integer page, Integer limit, Integer userId) { |
| 718 | 859 | List<String> hospitalIds = getHospitalIds(userId, hospitalId); |
| ... | ... | @@ -730,12 +871,6 @@ |
| 730 | 871 | for (Patients patient : patients) { |
| 731 | 872 | parentIds.add(patient.getId()); |
| 732 | 873 | } |
| 733 | - List<BabyModel> babyModels = mongoTemplate.find(Query.query(Criteria.where("yn").ne(0).and("parentId").in(parentIds)), BabyModel.class); | |
| 734 | - List<String> babyIds = new ArrayList<>(); | |
| 735 | - for (BabyModel babyModel : babyModels) { | |
| 736 | - babyIds.add(babyModel.getId()); | |
| 737 | - } | |
| 738 | - List<BabyCheckModel> babyCheckModels = mongoTemplate.find(Query.query(Criteria.where("yn").ne(0).and("buildId").in(babyModels)), BabyCheckModel.class); | |
| 739 | 874 | List<AntExChuModel> antExChuModels = mongoTemplate.find(Query.query(Criteria.where("yn").ne(0).and("parentId").in(parentIds)), AntExChuModel.class); |
| 740 | 875 | List<AntenatalExaminationModel> antenatalExaminationModels = mongoTemplate.find(Query.query(Criteria.where("yn").ne(0).and("parentId").in(parentIds)), AntenatalExaminationModel.class); |
| 741 | 876 | List<MaternalDeliverModel> maternalDeliverModels = mongoTemplate.find(Query.query(Criteria.where("yn").ne(0).and("parentId").in(parentIds)), MaternalDeliverModel.class); |
| 742 | 877 | |
| 743 | 878 | |
| 744 | 879 | |
| 745 | 880 | |
| 746 | 881 | |
| ... | ... | @@ -743,12 +878,59 @@ |
| 743 | 878 | List<PostReviewModel> postReviewModels = mongoTemplate.find(Query.query(Criteria.where("yn").ne(0).and("parentId").in(parentIds)), PostReviewModel.class); |
| 744 | 879 | |
| 745 | 880 | List<String> usedIds = getNeedUsedIds(patients, antExChuModels, antenatalExaminationModels, maternalDeliverModels, deliverModels, postReviewModels); |
| 881 | + List<Map<String, Object>> restList = new ArrayList<>(); | |
| 882 | + if(CollectionUtils.isNotEmpty(usedIds)) { | |
| 883 | + List<String> list = couponMapper.findUsededId(usedIds); | |
| 884 | + usedIds.removeAll(list); | |
| 746 | 885 | |
| 886 | + Map<String, String> hospitalNameCache = new HashMap<>(); | |
| 887 | + for (String hid : hids) { | |
| 888 | + boolean flag = false; | |
| 889 | + Set<String> unUsedIds = new HashSet<>(); // 未使用优惠券patientid | |
| 890 | + List<Map<String, Object>> un_used_coupons = new ArrayList<>(); // 未使用优惠券详情 | |
| 891 | + for (String usedId : usedIds) { | |
| 892 | + if(checkHospital(patients, antExChuModels, antenatalExaminationModels, maternalDeliverModels, deliverModels, postReviewModels, hid, usedId)) { | |
| 893 | + flag = true; | |
| 894 | + Patients p = getParentByUsedId(patients, antExChuModels, antenatalExaminationModels, maternalDeliverModels, deliverModels, postReviewModels, usedId); | |
| 895 | + if(p != null) { | |
| 896 | + unUsedIds.add(p.getId()); | |
| 897 | + Map<String, Object> map = new HashMap<>(); | |
| 747 | 898 | |
| 899 | + map.put("username", p.getUsername()); | |
| 900 | + map.put("phone", com.lyms.platform.common.utils.StringUtils.encryPhone(p.getPhone())); | |
| 901 | + map.put("cardNo", com.lyms.platform.common.utils.StringUtils.encryCardNo(p.getCardNo())); | |
| 902 | + map.put("week", DateUtil.getWeekDesc(p.getLastMenses(), new Date())); | |
| 903 | + map.put("doctorName", couponMapper.getUserName(p.getBookbuildingDoctor())); | |
| 904 | + String hName = hospitalNameCache.get(p.getHospitalId()); | |
| 905 | + if(StringUtils.isNotEmpty(hName)) { | |
| 906 | + hName = couponMapper.findHospitalNameById(p.getHospitalId()); | |
| 907 | + } | |
| 908 | + map.put("hospitalName", hName); | |
| 909 | + map.put("checkTime", getCheckTimeByUsedId(patients, antExChuModels, antenatalExaminationModels, maternalDeliverModels, deliverModels, postReviewModels, usedId)); | |
| 910 | + un_used_coupons.add(map); | |
| 911 | + } | |
| 912 | + } | |
| 748 | 913 | |
| 914 | + } | |
| 915 | + if(flag) { | |
| 916 | + Map<String, Object> hospitalInfo = couponMapper.findHospitalInfoById(hid); | |
| 917 | + hospitalInfo.put("cityName", hospitalInfo.get("city_id")); | |
| 918 | + hospitalInfo.put("areaName", hospitalInfo.get("area_id")); | |
| 919 | + hospitalInfo.put("un_used_coupons", un_used_coupons); | |
| 920 | + hospitalInfo.put("un_used_coupon_count", un_used_coupons.size()); | |
| 921 | + hospitalInfo.put("unUsedIds", unUsedIds); | |
| 922 | + hospitalInfo.put("un_used_people", unUsedIds.size()); | |
| 923 | + hospitalInfo.put("hospitalId", hid); | |
| 924 | + hospitalInfo.put("hospitalName", hospitalInfo.get("name")); | |
| 925 | + restList.add(hospitalInfo); | |
| 926 | + } | |
| 927 | + } | |
| 928 | + } | |
| 749 | 929 | |
| 750 | - return null; | |
| 751 | 930 | |
| 931 | + | |
| 932 | + return RespBuilder.buildSuccess(new PageResult(restList.size(), page, limit, restList)); | |
| 933 | + | |
| 752 | 934 | /*List<String> userIds = new ArrayList<>(); // 存储patientId |
| 753 | 935 | for (Patients patient : patients) { |
| 754 | 936 | userIds.add(patient.getPid()); |
| ... | ... | @@ -794,7 +976,7 @@ |
| 794 | 976 | continue; |
| 795 | 977 | } |
| 796 | 978 | String checkTime = getCheckTime((Integer) map.get("type"), (String) map.get("user_id"), patientId); |
| 797 | - if(StringUtils.isNotEmpty(checkTime)) { *//** 如果没有做检查 那么返回的时间就是空字符串 这里等于做了检查但是没用券 *//* | |
| 979 | + if(StringUtils.isNotEmpty(checkTime)) { * 如果没有做检查 那么返回的时间就是空字符串 这里等于做了检查但是没用券 | |
| 798 | 980 | unUsedIds.add(p.getId()); |
| 799 | 981 | unUsedCouponCount ++; |
| 800 | 982 | map.put("couponName", (couponReportMap.get(map.get("type") + "_" + map.get("coupon_order"))).toString() |