From 364ad3591360a27a13164be95fd3ac8b1c511928 Mon Sep 17 00:00:00 2001 From: litao Date: Tue, 6 Jun 2017 15:30:14 +0800 Subject: [PATCH] bug xiufu --- .../permission/dao/master/CouponMapper.java | 1 + .../main/resources/mainOrm/master/CouponMapper.xml | 16 +++++++++++ .../operate/web/controller/ReportController.java | 7 +++-- .../web/service/impl/ReportServiceImpl.java | 33 ++++++++++++++++++++-- 4 files changed, 52 insertions(+), 5 deletions(-) diff --git a/platform-biz-service/src/main/java/com/lyms/platform/permission/dao/master/CouponMapper.java b/platform-biz-service/src/main/java/com/lyms/platform/permission/dao/master/CouponMapper.java index 76b0125..2db269e 100644 --- a/platform-biz-service/src/main/java/com/lyms/platform/permission/dao/master/CouponMapper.java +++ b/platform-biz-service/src/main/java/com/lyms/platform/permission/dao/master/CouponMapper.java @@ -65,4 +65,5 @@ public interface CouponMapper { int findCouponInfoCount(Map param); + List doHospitalFilter(Map param); } diff --git a/platform-biz-service/src/main/resources/mainOrm/master/CouponMapper.xml b/platform-biz-service/src/main/resources/mainOrm/master/CouponMapper.xml index 06fa6ae..d54226c 100644 --- a/platform-biz-service/src/main/resources/mainOrm/master/CouponMapper.xml +++ b/platform-biz-service/src/main/resources/mainOrm/master/CouponMapper.xml @@ -335,4 +335,20 @@ ) a + + \ No newline at end of file diff --git a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/ReportController.java b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/ReportController.java index 2f9dcbc..4c96941 100644 --- a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/ReportController.java +++ b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/ReportController.java @@ -4,6 +4,7 @@ import com.lyms.platform.common.annotation.TokenRequired; import com.lyms.platform.common.base.BaseController; import com.lyms.platform.common.base.LoginContext; import com.lyms.platform.common.result.BaseObjectResponse; +import com.lyms.platform.common.utils.DateUtil; import com.lyms.platform.operate.web.service.IReportService; import com.lyms.platform.operate.web.utils.CollectionUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -208,7 +209,7 @@ public class ReportController extends BaseController { public BaseObjectResponse coupon(HttpServletRequest request, Date startDate, Date endDate, String provinceId, String cityId, String areaId, String hospitalId, String tempId, String couponType) { Map param = CollectionUtils.createMap("userId", getUserId(request), "startDate", startDate, - "endDate", endDate, "hospitalId", hospitalId, "provinceId", provinceId, "cityId", cityId, "areaId", + "endDate", DateUtil.addDay(endDate, 1), "hospitalId", hospitalId, "provinceId", provinceId, "cityId", cityId, "areaId", areaId, "tempId", tempId, "couponType", couponType); return reportService.coupon(param); } @@ -234,7 +235,7 @@ public class ReportController extends BaseController { String provinceId, String cityId, String areaId, String hospitalId, String tempId, String couponType, Integer page, Integer limit) { Map param = CollectionUtils.createMap("userId", getUserId(request), "startDate", startDate, - "endDate", endDate, "hospitalId", CollectionUtils.asList(hospitalId), "provinceId", provinceId, "cityId", cityId, "areaId", areaId, "type", type, + "endDate", DateUtil.addDay(endDate, 1), "hospitalId", CollectionUtils.asList(hospitalId), "provinceId", provinceId, "cityId", cityId, "areaId", areaId, "type", type, "tempId", tempId, "couponType", CollectionUtils.asList(couponType), "currentPage", page, "pageSize", limit); return reportService.couponInfo(param); } @@ -261,7 +262,7 @@ public class ReportController extends BaseController { String provinceId, String cityId, String areaId, String hospitalId, String tempId, String couponType, Integer page, Integer limit) { Map param = CollectionUtils.createMap("userId", getUserId(request), "startDate", startDate, - "endDate", endDate, "hospitalId", hospitalId, "provinceId", provinceId, "cityId", cityId, "areaId", areaId, "type", type, + "endDate", DateUtil.addDay(endDate, 1), "hospitalId", hospitalId, "provinceId", provinceId, "cityId", cityId, "areaId", areaId, "type", type, "tempId", tempId, "couponType", CollectionUtils.asList(couponType), "currentPage", page, "pageSize", limit); /*Map param = CollectionUtils.createMap("userId", "1000000185", "hospitalId", CollectionUtils.asList("216"), "type", type, "tempId", tempId, "couponType", CollectionUtils.asList("1,2,3,4,5,6,7,8"), "currentPage", page, "pageSize", limit);*/ diff --git a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/ReportServiceImpl.java b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/ReportServiceImpl.java index 4e00fc1..05b47b1 100644 --- a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/ReportServiceImpl.java +++ b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/ReportServiceImpl.java @@ -443,6 +443,9 @@ public class ReportServiceImpl extends BaseServiceImpl implements IReportService } else { param.put("hospitalId", CollectionUtils.asList((String) param.get("hospitalId"))); } + + doHospitalFilter(param); + param.put("status", 2); param.put("couponType", CollectionUtils.asList((String) param.get("couponType"))); @@ -462,8 +465,6 @@ public class ReportServiceImpl extends BaseServiceImpl implements IReportService map.put("area_name", areaName); xAxis.add(areaName); } - } else{ -// return RespBuilder.buildErro(ResponseCode.DATA_ERROR); } } @@ -474,10 +475,36 @@ public class ReportServiceImpl extends BaseServiceImpl implements IReportService reportModel.doMerge(); Map titleMap = parseTitle(couponReport); + transNullToZero(couponReport, titleMap); + return RespBuilder.buildSuccess("couponReport", couponReport, "couponReportMap", titleMap, "reportModel", reportModel); } + private void transNullToZero(List> couponReport, Map titleMap) { + if(org.apache.commons.collections.CollectionUtils.isNotEmpty(couponReport) + && org.apache.commons.collections.MapUtils.isNotEmpty(titleMap)) + for (Map coupon : couponReport) { + Set set = titleMap.keySet(); + for (String s : set) { + if(coupon.get(s) == null) { + coupon.put(s, 0); + } + } + } + } + + + + /** + * 根据省市区县过滤医院 + * @param param + */ + private void doHospitalFilter(Map param) { + List hospitalIds = couponMapper.doHospitalFilter(param); + param.put("hospitalId", hospitalIds); + } + private Map parseTitle(List> couponReport) { Map titleMap = new HashMap<>(); for (Map map : couponReport) { @@ -520,6 +547,7 @@ public class ReportServiceImpl extends BaseServiceImpl implements IReportService param.put("hospitalIds", CollectionUtils.asList((String) param.get("hospitalId"))); } + doHospitalFilter(param); String couponType = (String) param.get("couponType"); List enmus = new ArrayList<>(); @@ -539,6 +567,7 @@ public class ReportServiceImpl extends BaseServiceImpl implements IReportService if(StringUtils.isEmpty(param.get("hospitalId") + "")) { param.put("hospitalId", accessPermissionFacade.getCurrentUserHospPermissions(Integer.parseInt(param.get("userId") + ""))); /** 根据登陆人id 查询出来的医院 */ } + doHospitalFilter(param); List> couponInfos = couponMapper.findCouponInfo(param); for (Map couponInfo : couponInfos) { String desc = (String) couponReportMap.get(couponInfo.get("type") + "_" + couponInfo.get("coupon_order")); -- 1.8.3.1