Commit 4d4e0e39b0e5056d649b8573cc1b3ccd9a1f0ae5

Authored by litao
1 parent b28b9c5169

bug修复

Showing 4 changed files with 135 additions and 46 deletions

platform-biz-service/src/main/java/com/lyms/platform/permission/dao/master/CouponMapper.java View file @ 4d4e0e3
... ... @@ -64,5 +64,6 @@
64 64 List<Map<String,Object>> findCouponInfo(Map<String, Object> param);
65 65  
66 66 int findCouponInfoCount(Map<String, Object> param);
  67 +
67 68 }
platform-biz-service/src/main/resources/mainOrm/master/CouponMapper.xml View file @ 4d4e0e3
... ... @@ -135,39 +135,40 @@
135 135 </select>
136 136  
137 137 <select id="findReport" parameterType="map" resultType="map">
138   - select a.people_send_count, a.coupon_send_count, a.create_hospital_id, b.user_used_count, b.coupon_used_count, c.province_id, c.city_id, c.area_id, c.name
139   - from (
140   - select count(distinct(a.user_id)) as people_send_count, count(1) as coupon_send_count, a.create_hospital_id
141   - from coupon_info a, coupon_template b, coupon_type c, organization d, hospital_coupon_template_group e
142   - where a.create_hospital_id = d.id and a.create_hospital_id in
143   - <foreach collection="hospitalId" open="(" close=")" separator="," item="hid">
144   - #{hid}
145   - </foreach>
146   - and a.coupon_template_id = b.id and b.type_id = c.id and c.type in
147   - <foreach collection="couponType" open="(" close=")" separator="," item="type">
148   - #{type}
149   - </foreach>
150   - <if test="startDate != null">
151   - and a.create_date >= #{startDate}
152   - </if>
153   - <if test="endDate != null">
154   - and a.create_date <![CDATA[ <= ]]> #{endDate}
155   - </if>
156   - <if test="provinceId != null and provinceId != ''">
157   - and d.province_id = #{provinceId}
158   - </if>
159   - <if test="cityId != null and cityId != '' ">
160   - and d.city_id = #{cityId}
161   - </if>
162   - <if test="areaId != null and areaId != ''">
163   - and d.area_id = #{areaId}
164   - </if>
165   - <if test="tempId != null and tempId != ''">
166   - and e.coupon_template_group_id = #{tempId}
167   - </if>
168   - and a.create_hospital_id = e.hospital_id
169   - group by a.create_hospital_id
170   - ) a, (
  138 + select a.people_send_count, a.coupon_send_count, a.create_hospital_id, a.user_used_count, a.coupon_used_count, a.used_hospital_id, b.province_id, b.city_id, b.area_id, b.name from(
  139 + select a.people_send_count, a.coupon_send_count, a.create_hospital_id, b.user_used_count, b.coupon_used_count, b.used_hospital_id
  140 + from (
  141 + select count(distinct(a.user_id)) as people_send_count, count(1) as coupon_send_count, a.create_hospital_id
  142 + from coupon_info a, coupon_template b, coupon_type c, organization d, hospital_coupon_template_group e
  143 + where a.create_hospital_id = d.id and a.create_hospital_id in
  144 + <foreach collection="hospitalId" open="(" close=")" separator="," item="hid">
  145 + #{hid}
  146 + </foreach>
  147 + and a.coupon_template_id = b.id and b.type_id = c.id and c.type in
  148 + <foreach collection="couponType" open="(" close=")" separator="," item="type">
  149 + #{type}
  150 + </foreach>
  151 + <if test="startDate != null">
  152 + and a.create_date >= #{startDate}
  153 + </if>
  154 + <if test="endDate != null">
  155 + and a.create_date <![CDATA[ <= ]]> #{endDate}
  156 + </if>
  157 + <if test="provinceId != null and provinceId != ''">
  158 + and d.province_id = #{provinceId}
  159 + </if>
  160 + <if test="cityId != null and cityId != '' ">
  161 + and d.city_id = #{cityId}
  162 + </if>
  163 + <if test="areaId != null and areaId != ''">
  164 + and d.area_id = #{areaId}
  165 + </if>
  166 + <if test="tempId != null and tempId != ''">
  167 + and e.coupon_template_group_id = #{tempId}
  168 + </if>
  169 + and a.create_hospital_id = e.hospital_id
  170 + group by a.create_hospital_id
  171 + ) a left join (
171 172 select count(distinct(a.user_id)) as user_used_count, count(1) as coupon_used_count, a.used_hospital_id
172 173 from coupon_info a, coupon_template b, coupon_type c
173 174 where a.used_hospital_id in
... ... @@ -179,8 +180,57 @@
179 180 #{type}
180 181 </foreach>
181 182 group by a.used_hospital_id
182   - ) b, organization c
183   - where a.create_hospital_id = b.used_hospital_id and a.create_hospital_id = c.id
  183 + ) b
  184 + on a.create_hospital_id = b.used_hospital_id
  185 + union
  186 + select a.people_send_count, a.coupon_send_count, a.create_hospital_id, b.user_used_count, b.coupon_used_count, b.used_hospital_id
  187 + from (
  188 + select count(distinct(a.user_id)) as people_send_count, count(1) as coupon_send_count, a.create_hospital_id
  189 + from coupon_info a, coupon_template b, coupon_type c, organization d, hospital_coupon_template_group e
  190 + where a.create_hospital_id = d.id and a.create_hospital_id in
  191 + <foreach collection="hospitalId" open="(" close=")" separator="," item="hid">
  192 + #{hid}
  193 + </foreach>
  194 + and a.coupon_template_id = b.id and b.type_id = c.id and c.type in
  195 + <foreach collection="couponType" open="(" close=")" separator="," item="type">
  196 + #{type}
  197 + </foreach>
  198 + <if test="startDate != null">
  199 + and a.create_date >= #{startDate}
  200 + </if>
  201 + <if test="endDate != null">
  202 + and a.create_date <![CDATA[ <= ]]> #{endDate}
  203 + </if>
  204 + <if test="provinceId != null and provinceId != ''">
  205 + and d.province_id = #{provinceId}
  206 + </if>
  207 + <if test="cityId != null and cityId != '' ">
  208 + and d.city_id = #{cityId}
  209 + </if>
  210 + <if test="areaId != null and areaId != ''">
  211 + and d.area_id = #{areaId}
  212 + </if>
  213 + <if test="tempId != null and tempId != ''">
  214 + and e.coupon_template_group_id = #{tempId}
  215 + </if>
  216 + and a.create_hospital_id = e.hospital_id
  217 + group by a.create_hospital_id
  218 + ) a right join (
  219 + select count(distinct(a.user_id)) as user_used_count, count(1) as coupon_used_count, a.used_hospital_id
  220 + from coupon_info a, coupon_template b, coupon_type c
  221 + where a.used_hospital_id in
  222 + <foreach collection="hospitalId" open="(" close=")" separator="," item="hid">
  223 + #{hid}
  224 + </foreach>
  225 + and a.status = 2 and a.coupon_template_id = b.id and b.type_id = c.id and c.type in
  226 + <foreach collection="couponType" open="(" close=")" separator="," item="type">
  227 + #{type}
  228 + </foreach>
  229 + group by a.used_hospital_id
  230 + ) b
  231 + on a.create_hospital_id = b.used_hospital_id
  232 + )a, organization b
  233 + where a.create_hospital_id = b.id or a.used_hospital_id = b.id
184 234 </select>
185 235  
186 236 <select id="findUsedInfo" parameterType="map" resultType="map">
... ... @@ -208,6 +258,7 @@
208 258 <foreach collection="hospitalIds" open="(" close=")" separator="," item="hid">
209 259 #{hid}
210 260 </foreach>
  261 + group by a.coupon_template_group_id,b.name
211 262 </select>
212 263  
213 264 <select id="findHospitalName" parameterType="map" resultType="map">
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/ReportController.java View file @ 4d4e0e3
... ... @@ -210,12 +210,11 @@
210 210 Map<String, Object> param = CollectionUtils.createMap("userId", getUserId(request), "startDate", startDate,
211 211 "endDate", endDate, "hospitalId", hospitalId, "provinceId", provinceId, "cityId", cityId, "areaId",
212 212 areaId, "tempId", tempId, "couponType", couponType);
213   - /*Map<String, Object> param = CollectionUtils.createMap("userId", getUserId(request),"hospitalId", "1000000094","tempId", tempId, "couponType", "1,2,3,4,5,6,7,8");*/
214 213 return reportService.coupon(param);
215 214 }
216 215  
217 216 /**
218   - * 优惠券相关统计详情
  217 + * 优惠券使用统计详情
219 218 * @param request
220 219 * @param startDate 开始时间
221 220 * @param endDate 结束时间
... ... @@ -237,8 +236,6 @@
237 236 Map<String, Object> param = CollectionUtils.createMap("userId", getUserId(request), "startDate", startDate,
238 237 "endDate", endDate, "hospitalId", CollectionUtils.asList(hospitalId), "provinceId", provinceId, "cityId", cityId, "areaId", areaId, "type", type,
239 238 "tempId", tempId, "couponType", CollectionUtils.asList(couponType), "currentPage", page, "pageSize", limit);
240   - /* Map<String, Object> param = CollectionUtils.createMap("userId", getUserId(request), "hospitalId", CollectionUtils.asList("216"), "type", type,
241   - "tempId", tempId, "couponType", CollectionUtils.asList("1,2,3,4,5,6,7,8"), "currentPage", page, "pageSize", limit);*/
242 239 return reportService.couponInfo(param);
243 240 }
244 241  
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/ReportServiceImpl.java View file @ 4d4e0e3
... ... @@ -445,8 +445,8 @@
445 445 param.put("status", 2);
446 446 param.put("couponType", CollectionUtils.asList((String) param.get("couponType")));
447 447  
448   -
449 448 List<Map<String, Object>> couponReport = couponMapper.findReport(param); /** 优惠券统计详情(发放人数、发放券数、使用人数、使用券数) */
  449 +
450 450 List<Map<String, Object>> usedInfo = couponMapper.findUsedInfo(param); /** 优惠券使用详情 */
451 451 List<String> xAxis = new ArrayList<>();
452 452  
453 453  
... ... @@ -471,9 +471,25 @@
471 471 reportModel.setData(Arrays.asList("发放券数", "使用券数"));
472 472 reportModel.setSeries(createSeries(couponReport));
473 473  
474   - return RespBuilder.buildSuccess("couponReport", couponReport, "couponReportMap", couponReportMap, "reportModel", reportModel);
  474 + Map<String, Object> titleMap = parseTitle(couponReport);
  475 +
  476 + return RespBuilder.buildSuccess("couponReport", couponReport, "couponReportMap", titleMap, "reportModel", reportModel);
475 477 }
476 478  
  479 + private Map<String,Object> parseTitle(List<Map<String, Object>> couponReport) {
  480 + Map<String, Object> titleMap = new HashMap<>();
  481 + for (Map<String, Object> map : couponReport) {
  482 + Set<String> set = map.keySet();
  483 + for (String s : set) {
  484 + if(couponReportMap.containsKey(s)) {
  485 + titleMap.put(s, couponReportMap.get(s));
  486 + }
  487 + }
  488 + }
  489 + return titleMap;
  490 + }
  491 +
  492 +
477 493 private List<Series> createSeries(List<Map<String, Object>> couponReport) {
478 494 List<Series> seriesList = new ArrayList<>();
479 495 for (Map<String, Object> coupon : couponReport) {
... ... @@ -496,8 +512,12 @@
496 512  
497 513 @Override
498 514 public BaseObjectResponse couponInit(Map<String, Object> param) {
499   - List<String> hospitalIds = Arrays.asList("216", "245"); /** 模拟根据登陆人id 查询出来的医院 */
500   - param.put("hospitalIds", hospitalIds);
  515 + if(StringUtils.isBlank((String) param.get("hospitalId"))) {
  516 + param.put("hospitalIds", accessPermissionFacade.getCurrentUserHospPermissions(Integer.parseInt(param.get("userId") + ""))); /** 模拟根据登陆人id 查询出来的医院 */
  517 + } else {
  518 + param.put("hospitalIds", CollectionUtils.asList((String) param.get("hospitalId")));
  519 + }
  520 +
501 521 return RespBuilder.buildSuccess("coupons", EnumUtil.toJson(CouponEnums.class, "code", "name"),
502 522 "hTemp", couponMapper.findHospitals(param));
503 523 }
... ... @@ -520,7 +540,7 @@
520 540 couponInfo.put("type_desc", s);
521 541 }
522 542  
523   - setAntexInfo(couponInfo);
  543 + setUsedInfo(couponInfo);
524 544 }
525 545 int count = couponMapper.findCouponInfoCount(param);
526 546 PageResult pageResult = new PageResult(count, (Integer) param.get("currentPage") ,(Integer) param.get("pageSize"), CollectionUtils.createMap("couponInfos", couponInfos));
527 547  
... ... @@ -610,9 +630,29 @@
610 630 ResponseUtil.responseExcel(cnames, results, response);
611 631 }
612 632  
613   - private void setAntexInfo(Map<String, Object> map) {
  633 + private void setUsedInfo(Map<String, Object> map) {
614 634 String sequenceId = (String) map.get("sequence_id");
615   - if(StringUtils.isEmpty(sequenceId)) return;
  635 + Integer type = (Integer) map.get("type");
  636 + if(StringUtils.isEmpty(sequenceId) || type == null) return;
  637 +
  638 + /**
  639 + * type
  640 + 1=孕妇建档 lyms_patient
  641 + 2=孕妇产检 lyms_antexc(初诊),lyms_antex(复诊)
  642 + 3=产妇建档
  643 + 4=产妇分娩 lyms_matdeliver
  644 + 5=产妇出院小结 lyms_discharge_abstract_mother
  645 + 6=产妇产后复查 lyms_postreview
  646 + 7=儿童建档 lyms_baby
  647 + 8=儿童保健 lyms_babycheck
  648 + */
  649 + if(type == 1) {
  650 + Patients patients = mongoTemplate.findOne(Query.query(Criteria.where("").is(sequenceId)), Patients.class);
  651 + if(patients != null) {
  652 + map.put("checkDate", patients.getCreated()); /** 产检日期 */
  653 + }
  654 + }
  655 +
616 656 AntExChuModel antexc = mongoTemplate.findOne(Query.query(Criteria.where("barCode").is(sequenceId)), AntExChuModel.class);
617 657 if(antexc != null) {
618 658 map.put("checkDate", antexc.getCheckTime()); /** 产检日期 */