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 1bb9120..42a3031 100644 --- a/platform-biz-service/src/main/resources/mainOrm/master/CouponMapper.xml +++ b/platform-biz-service/src/main/resources/mainOrm/master/CouponMapper.xml @@ -553,7 +553,7 @@ #{type} - and a.used_id in + and a.user_id in #{key} @@ -622,7 +622,7 @@ - and a.used_id in + and a.user_id in #{key} diff --git a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/OrgCouponService.java b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/OrgCouponService.java index 7e409d4..44d049b 100644 --- a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/OrgCouponService.java +++ b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/OrgCouponService.java @@ -2,7 +2,6 @@ package com.lyms.platform.operate.web.service; import com.lyms.platform.common.result.BaseObjectResponse; -import java.util.Date; import java.util.Map; public interface OrgCouponService extends IBaseService { diff --git a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/OrgCouponServiceImpl.java b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/OrgCouponServiceImpl.java index a416c52..7a5d657 100644 --- a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/OrgCouponServiceImpl.java +++ b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/OrgCouponServiceImpl.java @@ -20,6 +20,7 @@ import org.springframework.data.mongodb.core.MongoTemplate; import org.springframework.data.mongodb.core.query.Criteria; import org.springframework.data.mongodb.core.query.Query; import org.springframework.stereotype.Service; +import org.springframework.util.Assert; import java.util.*; @@ -38,12 +39,107 @@ public class OrgCouponServiceImpl extends BaseServiceImpl implements OrgCouponSe @Autowired private ApplyOrderService applyOrderService; + /** + * 优惠券统计报表key(type + "_" + coupon_order)所对应的header名称 + */ + private static final Map couponReportMap = new HashMap<>(); + + /** + * 优惠券类型描述map + */ + private static final Map couponDescMap = new HashMap<>(); + + private static final Map colorMap = new HashMap<>(); + + private static final Map> personCouponMap = new HashMap<>(); + + static { + colorMap.put("绿色预警", "#50e39f"); + colorMap.put("黄色预警", "#ffd84d"); + colorMap.put("橙色预警", "#f17d02"); + colorMap.put("红色预警", "#ff6767"); + colorMap.put("紫色预警", "#be75ff"); + + personCouponMap.put(1, Arrays.asList(1, 2)); + personCouponMap.put(2, Arrays.asList(7, 8)); + personCouponMap.put(3, Arrays.asList(3, 4, 5, 6)); + + /** 孕妇 */ + couponReportMap.put("1_1", "孕期建档券使用人次"); + couponReportMap.put("2_1", "首次产检券使用人次"); + couponReportMap.put("2_2", "产检券(二)券使用人次"); + couponReportMap.put("2_3", "产检券(三)券使用人次"); + couponReportMap.put("2_4", "产检券(四)券使用人次"); + couponReportMap.put("2_5", "产检券(五)券使用人次"); + couponReportMap.put("2_6", "产检券(六)券使用人次"); + couponReportMap.put("2_7", "产检券(七)券使用人次"); + couponReportMap.put("2_8", "产检券(八)券使用人次"); + couponReportMap.put("2_9", "产检券(九)券使用人次"); + couponReportMap.put("2_10", "产检券(十)券使用人次"); + couponReportMap.put("2_11", "产检券(十一)券使用人次"); + couponReportMap.put("2_12", "产检券(十二)券使用人次"); + /** 儿童 */ + couponReportMap.put("7_1", "儿童建档券使用人次"); + couponReportMap.put("8_1", "
儿童保健券(一)
使用人次
"); + couponReportMap.put("8_2", "
儿童保健券(二)
使用人次
"); + couponReportMap.put("8_3", "
儿童保健券(三)
使用人次
"); + couponReportMap.put("8_4", "
儿童保健券(四)
使用人次
"); + couponReportMap.put("8_5", "
儿童保健券(五)
使用人次
"); + couponReportMap.put("8_6", "
儿童保健券(六)
使用人次
"); + couponReportMap.put("8_7", "
儿童保健券(七)
使用人次
"); + couponReportMap.put("8_8", "
儿童保健券(八)
使用人次
"); + couponReportMap.put("8_9", "
儿童保健券(九)
使用人次
"); + couponReportMap.put("8_10", "
儿童保健券(十)
使用人次
"); + couponReportMap.put("8_11", "
儿童保健券(十一)
使用人次
"); + couponReportMap.put("8_12", "
儿童保健券(十二)
使用人次
"); + couponReportMap.put("9_1", "
新生儿访视券(一)
使用人次
"); + couponReportMap.put("9_2", "
新生儿访视券(二)
使用人次
"); + couponReportMap.put("9_3", "
新生儿访视券(三)
使用人次
"); + couponReportMap.put("9_4", "
新生儿访视券(四)
使用人次
"); + couponReportMap.put("9_5", "
新生儿访视券(五)
使用人次
"); + couponReportMap.put("9_6", "
新生儿访视券(六)
使用人次
"); + couponReportMap.put("9_7", "
新生儿访视券(七)
使用人次
"); + couponReportMap.put("9_8", "
新生儿访视券(八)
使用人次
"); + couponReportMap.put("9_9", "
新生儿访视券(九)
使用人次
"); + couponReportMap.put("10_1", "
血红蛋白检查券(一)
使用人次
"); + couponReportMap.put("10_2", "
血红蛋白检查券(二)
使用人次
"); + couponReportMap.put("10_3", "
血红蛋白检查券(三)
使用人次
"); + couponReportMap.put("10_4", "
血红蛋白检查券(四)
使用人次
"); + couponReportMap.put("10_5", "
血红蛋白检查券(五)
使用人次
"); + couponReportMap.put("10_6", "
血红蛋白检查券(六)
使用人次
"); + couponReportMap.put("10_7", "
血红蛋白检查券(七)
使用人次
"); + couponReportMap.put("10_8", "
血红蛋白检查券(八)
使用人次
"); + couponReportMap.put("10_9", "
血红蛋白检查券(九)
使用人次
"); + couponReportMap.put("10_10", "
血红蛋白检查券(十)
使用人次
"); + + couponReportMap.put("11_1", "
产筛券
使用人次
"); + /** 产后 */ + couponReportMap.put("3_1", "
产后建档券
使用人次
"); + couponReportMap.put("4_1", "
分娩券
使用人次
"); + couponReportMap.put("5_1", "
出院小结券
使用人次
"); + couponReportMap.put("6_1", "
42天访视券
使用人次
"); + couponReportMap.put("6_2", "
产后复查券(一)
使用人次
"); + couponReportMap.put("6_3", "
产后复查券(二)
使用人次
"); + couponReportMap.put("6_4", "
产后复查券(三)
使用人次
"); + couponReportMap.put("6_5", "
产后复查券(四)
使用人次
"); + couponReportMap.put("6_6", "
产后复查券(五)
使用人次
"); + + /** 1=孕妇建档 2=孕妇产检 3=产妇建档 4=产妇分娩 5=产妇出院小结 6=产妇产后复查 7=儿童建档 8=儿童保健 */ + couponDescMap.put(1, "孕妇建档券"); + couponDescMap.put(2, "孕妇产检券"); + couponDescMap.put(3, "产妇建档券"); + couponDescMap.put(4, "产妇分娩券"); + couponDescMap.put(5, "产妇出院小结券"); + couponDescMap.put(6, "产妇产后复查券"); + couponDescMap.put(7, "儿童建档券"); + couponDescMap.put(8, "儿童保健券"); + } + @Override public BaseObjectResponse orgCouponInfo(Map param) { Integer currentPage = (Integer) param.get("currentPage"); PageUtil.setPageInfo(param); String key = (String) param.get("key"); - System.out.println(key); List keys = new ArrayList(); if (StringUtils.isNotEmpty(key)) { Criteria criteria = new Criteria(); @@ -54,16 +150,47 @@ public class OrgCouponServiceImpl extends BaseServiceImpl implements OrgCouponSe } } param.put("keys", keys); - for (String ke : keys) { - System.out.println(ke); + Integer type = 4; + String coupon = (String) param.get("couponType"); /** 选中单个优惠券类型查询时 前端传的是 type_order 目前传入这种的只有使用统计 */ + if (StringUtils.isNotEmpty(coupon)) { + if (coupon.contains("_")) { + String[] split = (coupon + "").split("_"); /** type_order */ + List couponType = CollectionUtils.asList(split[0]); + String order = split[1]; + param.put("couponType", couponType); + param.put("coupon_order", order); + type = 4; + } else { + param.put("couponType", CollectionUtils.asList(coupon)); + } } - String coupon = (String) param.get("couponType"); - param.put("couponType", CollectionUtils.asList(coupon)); + + Assert.notNull(type, "type must not be null!"); + /** 使用详情统计 */ +// List> couponInfos = couponMapper.couponInfo(param); List> couponInfos = couponMapper.couponInfo2(param); String subTitle = null; + Set subTitleTempSet = new HashSet<>(); + if (CollectionUtils.isNotEmpty(couponInfos)) { for (Map couponInfo : couponInfos) { + String desc = (String) couponReportMap.get(couponInfo.get("type") + "_" + couponInfo.get("coupon_order")); + if (StringUtils.isNotBlank(desc)) { + /**
儿童保健券(五)
使用人次
*/ + String s = desc.replace("使用人次", "") + .replace("
", "") + .replace("
", "") + .replace("
", ""); + if (subTitleTempSet.add(s)) { + if (StringUtils.isEmpty(subTitle)) { + subTitle = s; + } else { + subTitle += "/" + s; + } + } + couponInfo.put("type_desc", s); + } Date useDate = (Date) couponInfo.get("use_date"); couponInfo.put("use_date", DateUtil.getyyyy_MM_dd(useDate)); /** 设置产检日期、姓名、产检孕周、产检第次、产检机构、产检医生、联系电话 */ @@ -77,7 +204,8 @@ public class OrgCouponServiceImpl extends BaseServiceImpl implements OrgCouponSe return RespBuilder.buildSuccess(pageResult); } - private void setUsedInfo(Integer type, String usedId, String sequence_id, Date useDate, String operatorUserId, Map map) { + private void setUsedInfo(Integer type, String usedId, String sequence_id, Date useDate, String + operatorUserId, Map map) { Date checkDate = null; /** 产检日期 */ String username = null; /** 姓名 */ String week = null; /** 产检孕周 = 产检时间 - 末次月经 */