Commit 8c07ed65ea8711c879e8d08b251c84ca14db4f0f
1 parent
abd292c1ca
Exists in
master
and in
6 other branches
优惠券统计接口
Showing 13 changed files with 338 additions and 13 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-common/src/main/java/com/lyms/platform/common/enums/CouponEnums.java
- platform-common/src/main/java/com/lyms/platform/common/result/RespBuilder.java
- platform-common/src/main/java/com/lyms/platform/common/result/ResponseCode.java
- platform-common/src/main/java/com/lyms/platform/common/utils/EnumUtil.java
- 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/controller/TestController.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/BookbuildingFacade.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/ReportServiceImpl.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/utils/CollectionUtils.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/utils/SystemDataSource.java
platform-biz-service/src/main/java/com/lyms/platform/permission/dao/master/CouponMapper.java
View file @
8c07ed6
... | ... | @@ -44,5 +44,15 @@ |
44 | 44 | |
45 | 45 | String findCityId(String hospitalId); |
46 | 46 | |
47 | + /** | |
48 | + * 查询报表详情(发放人数、发放券数、使用人数、使用券数) | |
49 | + * @param param | |
50 | + * @return | |
51 | + */ | |
52 | + List<Map<String,Object>> findReport(Map<String, Object> param); | |
53 | + | |
54 | + List<Map<String,Object>> findUsedInfo(Map<String, Object> param); | |
55 | + | |
56 | + List<Map<String, Object>> findHospitals(Map<String, Object> param); | |
47 | 57 | } |
platform-biz-service/src/main/resources/mainOrm/master/CouponMapper.xml
View file @
8c07ed6
... | ... | @@ -134,5 +134,62 @@ |
134 | 134 | where h.hospital_id=#{hospitalId} and ct.type=#{type} order by t.coupon_order ASC |
135 | 135 | </select> |
136 | 136 | |
137 | + <select id="findReport" parameterType="map" resultType="map"> | |
138 | + select a.people_send_count, a.coupon_send_count, a.used_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.used_hospital_id | |
141 | + from coupon_info a, coupon_template b, coupon_type c | |
142 | + where a.status = #{status} and a.used_hospital_id in | |
143 | + <foreach collection="hospitalIds" 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="couponTypes" open="(" close=")" separator="," item="type"> | |
148 | + #{type} | |
149 | + </foreach> | |
150 | + group by a.used_hospital_id | |
151 | + ) a, ( | |
152 | + select count(distinct(a.user_id)) as user_used_count, count(1) as coupon_used_count, a.used_hospital_id | |
153 | + from coupon_info a, coupon_template b, coupon_type c | |
154 | + where used_hospital_id in | |
155 | + <foreach collection="hospitalIds" open="(" close=")" separator="," item="hid"> | |
156 | + #{hid} | |
157 | + </foreach> | |
158 | + and status = #{status} and a.coupon_template_id = b.id and b.type_id = c.id and c.type in | |
159 | + <foreach collection="couponTypes" open="(" close=")" separator="," item="type"> | |
160 | + #{type} | |
161 | + </foreach> | |
162 | + group by used_hospital_id | |
163 | + ) b, organization c | |
164 | + where a.used_hospital_id = b.used_hospital_id and a.used_hospital_id = c.id | |
165 | + </select> | |
166 | + | |
167 | + <select id="findUsedInfo" parameterType="map" resultType="map"> | |
168 | + select count(1) as type_used_count, b.coupon_order, b.type, a.used_hospital_id | |
169 | + from coupon_info a, ( | |
170 | + select a.id, a.coupon_order, b.type, d.hospital_id | |
171 | + from coupon_template a, coupon_type b, hospital_coupon_template_group d | |
172 | + where a.group_id = d.coupon_template_group_id and b.id = a.type_id and d.hospital_id in | |
173 | + <foreach collection="hospitalIds" open="(" close=")" separator="," item="hid"> | |
174 | + #{hid} | |
175 | + </foreach> | |
176 | + and b.type in | |
177 | + <foreach collection="couponTypes" open="(" close=")" separator="," item="type"> | |
178 | + #{type} | |
179 | + </foreach> | |
180 | + ) b | |
181 | + where a.used_hospital_id = b.hospital_id and a.coupon_template_id = b.id and a.status = #{status} | |
182 | + group by b.coupon_order, b.type, a.used_hospital_id | |
183 | + </select> | |
184 | + | |
185 | + <select id="findHospitals" parameterType="map" resultType="map"> | |
186 | + select a.coupon_template_group_id as id, b.name | |
187 | + from hospital_coupon_template_group a, organization b | |
188 | + where a.hospital_id = b.id and a.hospital_id in | |
189 | + <foreach collection="hospitalIds" open="(" close=")" separator="," item="hid"> | |
190 | + #{hid} | |
191 | + </foreach> | |
192 | + </select> | |
193 | + | |
137 | 194 | </mapper> |
platform-common/src/main/java/com/lyms/platform/common/enums/CouponEnums.java
View file @
8c07ed6
... | ... | @@ -6,12 +6,17 @@ |
6 | 6 | * @Version: V1.0 |
7 | 7 | */ |
8 | 8 | public enum CouponEnums { |
9 | - | |
10 | - PRENATAL(1, "产检券"), | |
11 | - ANTENATAL(2, "产前券"), | |
12 | - POSTPARTUM(3, "产后券"), | |
13 | - REVIEW(4, "复查券"), | |
14 | - CHILD_HEALTH(5, "儿保券"); | |
9 | + /*** | |
10 | + * 1=孕妇建档 2=孕妇产检 3=产妇建档 4=产妇分娩 5=产妇出院小结 6=产妇产后复查 7=儿童建档 8=儿童保健 | |
11 | + */ | |
12 | + PRENATAL_FILE(1, "孕妇建档"), | |
13 | + ANTENATAL_CHECK(2, "孕妇产检"), | |
14 | + POSTPARTUM_FILE(3, "产妇建档"), | |
15 | + MATERNAL_DELIVER(4, "产妇分娩"), | |
16 | + MATERNAL_LEAVE_HOSPITAL(5, "产妇出院小结"), | |
17 | + MATERNAL_REVIEW(6, "产妇产后复查"), | |
18 | + CHILDREN_FILE(7, "儿童建档"), | |
19 | + CHILDREN_HEALTHCARE(8, "儿童保健"); | |
15 | 20 | |
16 | 21 | private Integer code; |
17 | 22 | private String name; |
platform-common/src/main/java/com/lyms/platform/common/result/RespBuilder.java
View file @
8c07ed6
1 | 1 | package com.lyms.platform.common.result; |
2 | 2 | |
3 | +import org.apache.commons.lang3.StringUtils; | |
4 | +import org.springframework.util.Assert; | |
5 | + | |
6 | +import java.util.HashMap; | |
7 | +import java.util.Map; | |
8 | + | |
3 | 9 | /** |
4 | 10 | * @Author: litao |
5 | 11 | * @Date: 2017/4/27 0027 10:45 |
6 | 12 | |
... | ... | @@ -10,9 +16,17 @@ |
10 | 16 | return buildSuccess(null); |
11 | 17 | } |
12 | 18 | |
13 | - public static BaseObjectResponse buildSuccess(Object data) { | |
19 | + public static BaseObjectResponse buildSuccess(Object ... data) { | |
20 | + Assert.notNull(data); | |
21 | + Assert.isTrue(data.length == 1 || data.length % 2 == 0, "length必须为偶数"); | |
22 | + | |
14 | 23 | BaseObjectResponse resp = new BaseObjectResponse(); |
15 | - resp.setData(data); | |
24 | + if(data.length == 1) { | |
25 | + resp.setData(data); | |
26 | + } else { | |
27 | + resp.setData(createMap(data)); | |
28 | + } | |
29 | + | |
16 | 30 | return resp; |
17 | 31 | } |
18 | 32 | |
... | ... | @@ -31,6 +45,18 @@ |
31 | 45 | resp.setErrormsg(ResponseCode.ERROR.getMsg()); |
32 | 46 | } |
33 | 47 | return resp; |
48 | + } | |
49 | + | |
50 | + private static Map<String,Object> createMap(Object ... args){ | |
51 | + Map<String,Object> map = new HashMap<>(); | |
52 | + for (int i = 0; i < args.length; i++) { | |
53 | + String key = args[i++].toString(); | |
54 | + Object value = args[i]; | |
55 | + if(value != null && StringUtils.isNotBlank(value.toString())) { | |
56 | + map.put(key, value); | |
57 | + } | |
58 | + } | |
59 | + return map; | |
34 | 60 | } |
35 | 61 | } |
platform-common/src/main/java/com/lyms/platform/common/result/ResponseCode.java
View file @
8c07ed6
... | ... | @@ -8,10 +8,12 @@ |
8 | 8 | public enum ResponseCode { |
9 | 9 | SUCCESS(0, "成功"), |
10 | 10 | ERROR(500, "系统错误,请联系管理员"), |
11 | + DATA_ERROR(3001, "数据错误"), | |
11 | 12 | |
12 | 13 | PERSON_NOT_FOUND(2001, "用户未查询到或type为空"), |
13 | 14 | PATIENT_NOT_FOUND(2002, "未查询到患者"), |
14 | 15 | |
16 | + HOSPITAL_TEMP_NOT_UNIQUE(4001, "请选择优惠券模板"), | |
15 | 17 | |
16 | 18 | COUPON_TEMP_NOT_FOUND(1006, "医院未绑定模板或无可生成的优惠券类型"), |
17 | 19 | COUPON_IS_CREATED(1007, "该用户已生成优惠券"), |
platform-common/src/main/java/com/lyms/platform/common/utils/EnumUtil.java
View file @
8c07ed6
1 | 1 | package com.lyms.platform.common.utils; |
2 | 2 | |
3 | +import com.lyms.platform.common.enums.CouponEnums; | |
3 | 4 | import org.apache.commons.beanutils.PropertyUtils; |
4 | 5 | |
5 | 6 | import java.security.InvalidParameterException; |
... | ... | @@ -39,7 +40,8 @@ |
39 | 40 | Object value = PropertyUtils.getProperty(ec,valueName); |
40 | 41 | if(key != null && value != null) { |
41 | 42 | Map<String, Object> tempMap = new HashMap<>(); |
42 | - tempMap.put(key.toString(), value); | |
43 | + tempMap.put("key", key.toString()); | |
44 | + tempMap.put("value", value); | |
43 | 45 | list.add(tempMap); |
44 | 46 | } |
45 | 47 | } |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/ReportController.java
View file @
8c07ed6
... | ... | @@ -5,6 +5,7 @@ |
5 | 5 | import com.lyms.platform.common.base.LoginContext; |
6 | 6 | import com.lyms.platform.common.result.BaseObjectResponse; |
7 | 7 | import com.lyms.platform.operate.web.service.IReportService; |
8 | +import com.lyms.platform.operate.web.utils.CollectionUtils; | |
8 | 9 | import org.springframework.beans.factory.annotation.Autowired; |
9 | 10 | import org.springframework.stereotype.Controller; |
10 | 11 | import org.springframework.web.bind.annotation.RequestMapping; |
... | ... | @@ -13,6 +14,8 @@ |
13 | 14 | |
14 | 15 | import javax.servlet.http.HttpServletRequest; |
15 | 16 | import javax.servlet.http.HttpServletResponse; |
17 | +import java.util.Date; | |
18 | +import java.util.Map; | |
16 | 19 | |
17 | 20 | /** |
18 | 21 | * @Author: litao |
... | ... | @@ -184,6 +187,38 @@ |
184 | 187 | LoginContext loginState = (LoginContext) request.getAttribute("loginContext"); |
185 | 188 | reportService.exportDoctor(startDate, endDate, childBirth, loginState.getId(), resp); |
186 | 189 | // reportService.exportDoctor(startDate, endDate, childBirth, 753, resp); |
190 | + } | |
191 | + | |
192 | + | |
193 | + /** | |
194 | + * 优惠券相关统计 | |
195 | + * @param request | |
196 | + * @param startDate 开始时间 | |
197 | + * @param endDate 结束时间 | |
198 | + * @param provinceId 省 | |
199 | + * @param cityId 市 | |
200 | + * @param areaId 区 | |
201 | + * @param hospitalId 医院id | |
202 | + * @param tempId 模板id | |
203 | + * @param couponType 优惠券类型 | |
204 | + * @return | |
205 | + */ | |
206 | + @ResponseBody | |
207 | + @TokenRequired | |
208 | + @RequestMapping(value = "/coupon", method = RequestMethod.GET) | |
209 | + public BaseObjectResponse coupon(HttpServletRequest request, Integer type, Date startDate, Date endDate, | |
210 | + String provinceId, String cityId, String areaId, String hospitalId, String tempId, String couponType) { | |
211 | + Map<String, Object> param = CollectionUtils.createMap("type", type, "userId", getUserId(request), "startDate", startDate, | |
212 | + "endDate", endDate, "hospitalType", hospitalId, "provinceId", provinceId, "cityId", cityId, "areaId", | |
213 | + areaId, "tempId", tempId, "couponType", couponType); | |
214 | + return reportService.couponInfo(param); | |
215 | + } | |
216 | + | |
217 | + @ResponseBody | |
218 | + @TokenRequired | |
219 | + @RequestMapping(value = "/init/coupon", method = RequestMethod.GET) | |
220 | + public BaseObjectResponse initCoupon(HttpServletRequest request) { | |
221 | + return reportService.couponInit(CollectionUtils.createMap("userId", getUserId(request))); | |
187 | 222 | } |
188 | 223 | |
189 | 224 | } |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/TestController.java
View file @
8c07ed6
... | ... | @@ -4,7 +4,6 @@ |
4 | 4 | import com.lyms.hospitalapi.qhdfy.QhdfyHisService; |
5 | 5 | import com.lyms.platform.biz.JdbcUtil; |
6 | 6 | import com.lyms.platform.biz.service.*; |
7 | -import com.lyms.platform.common.enums.CouponEnums; | |
8 | 7 | import com.lyms.platform.common.enums.YnEnums; |
9 | 8 | import com.lyms.platform.common.utils.CompressEncodeingUtil; |
10 | 9 | import com.lyms.platform.common.utils.DateUtil; |
... | ... | @@ -1042,7 +1041,7 @@ |
1042 | 1041 | public String initTicket() { |
1043 | 1042 | List<PatientCheckTicket> tickets = mongoTemplate.findAll(PatientCheckTicket.class); |
1044 | 1043 | for (PatientCheckTicket ticket : tickets) { |
1045 | - ticket.setCoupon(CouponEnums.PRENATAL); | |
1044 | +// ticket.setCoupon(CouponEnums.PRENATAL); | |
1046 | 1045 | mongoTemplate.save(ticket); |
1047 | 1046 | } |
1048 | 1047 | return "1"; |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/BookbuildingFacade.java
View file @
8c07ed6
... | ... | @@ -498,7 +498,7 @@ |
498 | 498 | // ticket.setId(areaCode.getAreaCode() + ticketPid + i); |
499 | 499 | ticket.setId(genSequenceIdService.poll(areaCode.getAreaCode())); |
500 | 500 | ticket.setPid(p.getPid()); |
501 | - ticket.setCoupon(CouponEnums.PRENATAL); | |
501 | +// ticket.setCoupon(CouponEnums.PRENATAL); | |
502 | 502 | // patientCheckTicketService.addTicket(ticket); |
503 | 503 | } |
504 | 504 | } |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/IReportService.java
View file @
8c07ed6
... | ... | @@ -3,6 +3,7 @@ |
3 | 3 | import com.lyms.platform.common.result.BaseObjectResponse; |
4 | 4 | |
5 | 5 | import javax.servlet.http.HttpServletResponse; |
6 | +import java.util.Map; | |
6 | 7 | |
7 | 8 | /** |
8 | 9 | * 报表service |
... | ... | @@ -65,5 +66,9 @@ |
65 | 66 | void exportDoctorInfo(String startDate, String endDate, Integer childBirth, Integer number, String name, Integer userId, HttpServletResponse resp); |
66 | 67 | |
67 | 68 | void exportCheckInfo(Integer childBirth, String startDate, String endDate, Integer startWeek, Integer endWeek, Integer number, String name, Integer userId, HttpServletResponse resp); |
69 | + | |
70 | + BaseObjectResponse couponInfo(Map<String, Object> param); | |
71 | + | |
72 | + BaseObjectResponse couponInit(Map<String, Object> userId); | |
68 | 73 | } |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/ReportServiceImpl.java
View file @
8c07ed6
1 | 1 | package com.lyms.platform.operate.web.service.impl; |
2 | 2 | |
3 | 3 | import com.lyms.hospitalapi.pojo.ReportModel; |
4 | +import com.lyms.platform.common.enums.CouponEnums; | |
4 | 5 | import com.lyms.platform.common.result.BaseObjectResponse; |
5 | 6 | import com.lyms.platform.common.result.PageResult; |
7 | +import com.lyms.platform.common.result.RespBuilder; | |
8 | +import com.lyms.platform.common.result.ResponseCode; | |
9 | +import com.lyms.platform.common.utils.EnumUtil; | |
6 | 10 | import com.lyms.platform.operate.web.dao.IReportDao; |
7 | 11 | import com.lyms.platform.operate.web.facade.AutoMatchFacade; |
8 | 12 | import com.lyms.platform.operate.web.service.IReportService; |
13 | +import com.lyms.platform.operate.web.utils.CollectionUtils; | |
9 | 14 | import com.lyms.platform.operate.web.utils.MathUtil; |
10 | 15 | import com.lyms.platform.operate.web.utils.ResponseUtil; |
11 | 16 | import com.lyms.platform.operate.web.utils.SystemDataSource; |
17 | +import com.lyms.platform.permission.dao.master.CouponMapper; | |
18 | +import com.lyms.platform.pojo.BasicConfig; | |
12 | 19 | import org.apache.commons.lang.StringUtils; |
13 | 20 | import org.springframework.beans.factory.annotation.Autowired; |
21 | +import org.springframework.data.mongodb.core.MongoTemplate; | |
14 | 22 | import org.springframework.stereotype.Service; |
15 | 23 | |
16 | 24 | import javax.servlet.http.HttpServletResponse; |
17 | 25 | |
... | ... | @@ -33,8 +41,29 @@ |
33 | 41 | @Autowired |
34 | 42 | AutoMatchFacade autoMatchFacade; |
35 | 43 | |
44 | + @Autowired | |
45 | + private CouponMapper couponMapper; | |
46 | + | |
47 | + @Autowired | |
48 | + private MongoTemplate mongoTemplate; | |
49 | + | |
36 | 50 | private static final Map<String, String> colorMap = new HashMap<>(); |
37 | 51 | |
52 | + /** | |
53 | + * 用户类型所对应的优惠券类型 | |
54 | + * 1=孕妇 2=儿童 3=产妇 | |
55 | + * 1=孕妇建档 2=孕妇产检 3=产妇建档 4=产妇分娩 5=产妇出院小结 6=产妇产后复查 7=儿童建档 8=儿童保健 | |
56 | + * 1 : (1, 2) | |
57 | + * 2 : (7, 8) | |
58 | + * 3 : (3, 4, 5, 6) | |
59 | + * */ | |
60 | + private static final Map<Integer, List<Integer>> personCouponMap = new HashMap<>(); | |
61 | + | |
62 | + /** | |
63 | + * 优惠券统计报表key(type + "_" + coupon_order)所对应的header名称 | |
64 | + */ | |
65 | + private static final Map<String, Object> couponReportMap = new HashMap<>(); | |
66 | + | |
38 | 67 | @Autowired |
39 | 68 | private SystemDataSource db; |
40 | 69 | |
... | ... | @@ -44,6 +73,26 @@ |
44 | 73 | colorMap.put("橙色预警", "#f17d02"); |
45 | 74 | colorMap.put("红色预警", "#ff6767"); |
46 | 75 | colorMap.put("紫色预警", "#be75ff"); |
76 | + | |
77 | + personCouponMap.put(1, Arrays.asList(1, 2)); | |
78 | + personCouponMap.put(2, Arrays.asList(7, 8)); | |
79 | + personCouponMap.put(3, Arrays.asList(3, 4, 5, 6)); | |
80 | + | |
81 | + /** 孕妇 */ | |
82 | + couponReportMap.put("1_1", "孕期建档券使用人次"); | |
83 | + couponReportMap.put("2_1", "首次产检券使用人次"); | |
84 | + couponReportMap.put("2_2", "孕中期一券使用人次"); | |
85 | + couponReportMap.put("2_3", "孕中期二券使用人次"); | |
86 | + couponReportMap.put("2_4", "孕晚期一券使用人次"); | |
87 | + couponReportMap.put("2_5", "孕晚期二券使用人次"); | |
88 | + /** 儿童 */ | |
89 | + couponReportMap.put("7_1", "儿童建档券使用人次"); | |
90 | + couponReportMap.put("8_1", "新生儿保健券使用人次"); | |
91 | + couponReportMap.put("8_2", "<div class='ag-double-line'>儿童保健券(一)<div>使用人次</div></div>"); | |
92 | + couponReportMap.put("8_3", "<div class='ag-double-line'>儿童保健券(二)<div>使用人次</div></div>"); | |
93 | + couponReportMap.put("8_4", "<div class='ag-double-line'>儿童保健券(三)<div><div>使用人次</div></div>"); | |
94 | + couponReportMap.put("8_5", "<div class='ag-double-line'>儿童保健券(四)<div>使用人次</div></div>"); | |
95 | + couponReportMap.put("8_6", "<div class='ag-double-line'>儿童保健券(五)<div>使用人次</div></div>"); | |
47 | 96 | } |
48 | 97 | |
49 | 98 | @Override |
... | ... | @@ -354,6 +403,55 @@ |
354 | 403 | } |
355 | 404 | |
356 | 405 | ResponseUtil.responseExcel(cnames,results, resp); |
406 | + } | |
407 | + | |
408 | + @Override | |
409 | + public BaseObjectResponse couponInfo(Map<String ,Object> param) { | |
410 | + List<String> hospitalIds = Arrays.asList("216", "245"); /** 模拟根据登陆人id 查询出来的医院 */ | |
411 | + | |
412 | + param.put("hospitalIds", hospitalIds); | |
413 | + param.put("status", 2); | |
414 | + param.put("couponTypes", CollectionUtils.asList((String) param.get("couponTypes"))); | |
415 | + | |
416 | + List<Map<String, Object>> couponReport = couponMapper.findReport(param); /** 优惠券统计详情(发放人数、发放券数、使用人数、使用券数) */ | |
417 | + List<Map<String, Object>> usedInfo = couponMapper.findUsedInfo(param); /** 优惠券使用详情 */ | |
418 | + | |
419 | + if(org.apache.commons.collections.CollectionUtils.isNotEmpty(couponReport) && | |
420 | + org.apache.commons.collections.CollectionUtils.isNotEmpty(usedInfo)) { | |
421 | + if(CollectionUtils.putAll(couponReport, usedInfo, "used_hospital_id", "used_hospital_id")) { | |
422 | + for (Map<String, Object> map : couponReport) { | |
423 | + map.put("province_name", findName(map.get("province_id"))); | |
424 | + map.put("city_name", findName(map.get("city_id"))); | |
425 | + map.put("area_name", findName(map.get("area_id"))); | |
426 | + } | |
427 | + return RespBuilder.buildSuccess("couponReport", couponReport, "couponReportMap", couponReportMap); | |
428 | + } else{ | |
429 | + return RespBuilder.buildErro(ResponseCode.DATA_ERROR); | |
430 | + } | |
431 | + } | |
432 | + return RespBuilder.buildSuccess(); | |
433 | + } | |
434 | + | |
435 | + @Override | |
436 | + public BaseObjectResponse couponInit(Map<String, Object> param) { | |
437 | + List<String> hospitalIds = Arrays.asList("216", "245"); /** 模拟根据登陆人id 查询出来的医院 */ | |
438 | + param.put("hospitalIds", hospitalIds); | |
439 | + return RespBuilder.buildSuccess("coupons", EnumUtil.toJson(CouponEnums.class, "code", "name"), | |
440 | + "hTemp", couponMapper.findHospitals(param)); | |
441 | + } | |
442 | + | |
443 | + public static void main(String[] args) { | |
444 | + System.out.println(EnumUtil.toJson(CouponEnums.class, "code", "name")); | |
445 | + } | |
446 | + | |
447 | + private String findName(Object id) { | |
448 | + if(id != null) { | |
449 | + BasicConfig basicConfig = mongoTemplate.findById(id, BasicConfig.class); | |
450 | + if(basicConfig != null) { | |
451 | + return basicConfig.getName(); | |
452 | + } | |
453 | + } | |
454 | + return null; | |
357 | 455 | } |
358 | 456 | |
359 | 457 | private String getDoctorInfoSql(String startDate, String endDate, Integer childBirth, Integer number, String name, String hospitalId, List<Object> params) { |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/utils/CollectionUtils.java
View file @
8c07ed6
1 | +package com.lyms.platform.operate.web.utils; | |
2 | + | |
3 | +import org.eclipse.jetty.util.StringUtil; | |
4 | +import org.springframework.util.Assert; | |
5 | + | |
6 | +import java.util.ArrayList; | |
7 | +import java.util.HashMap; | |
8 | +import java.util.List; | |
9 | +import java.util.Map; | |
10 | + | |
11 | +/** | |
12 | + * @Author: litao | |
13 | + * @Date: 2017/5/22 0022 10:44 | |
14 | + * @Version: V1.0 | |
15 | + */ | |
16 | +public class CollectionUtils { | |
17 | + private CollectionUtils(){} | |
18 | + | |
19 | + public static Map<String,Object> createMap(Object ... args){ | |
20 | + Assert.notNull(args, "参数不能为null"); | |
21 | + Assert.isTrue(args.length % 2 == 0, "length必须为偶数"); | |
22 | + | |
23 | + Map<String,Object> map = new HashMap<>(); | |
24 | + for (int i = 0; i < args.length; i++) { | |
25 | + String key = args[i++].toString(); | |
26 | + Object value = args[i]; | |
27 | + if(value != null && StringUtil.isNotBlank(value.toString())) { | |
28 | + map.put(key, value); | |
29 | + } | |
30 | + } | |
31 | + return map; | |
32 | + } | |
33 | + | |
34 | + /** | |
35 | + * 合并两个集合中 key 相同的数据 为一行 | |
36 | + * 以第一个集合为主 | |
37 | + * @param listOne | |
38 | + * @param listTwo | |
39 | + * @param oneKey | |
40 | + * @param twoKey | |
41 | + * @return 是否修改了 | |
42 | + */ | |
43 | + public static boolean putAll(List<Map<String, Object>> listOne, List<Map<String, Object>> listTwo, String oneKey, String twoKey) { | |
44 | + Assert.notNull(listOne); | |
45 | + Assert.notNull(listTwo); | |
46 | + Assert.notNull(oneKey); | |
47 | + Assert.notNull(twoKey); | |
48 | + return getIntersect(listOne, listTwo, oneKey, twoKey); | |
49 | + } | |
50 | + | |
51 | + private static boolean getIntersect(List<Map<String, Object>> listOne, List<Map<String, Object>> listTwo, String oneKey, String twoKey) { | |
52 | + boolean modified = false; | |
53 | + for (Map<String, Object> mapOne : listOne) { | |
54 | + for (Map<String, Object> mapTwo : listTwo) { | |
55 | + if(mapOne.get(oneKey).toString().equals(mapTwo.get(twoKey).toString())) { | |
56 | + putCouponInfo(mapOne, mapTwo); | |
57 | + modified = true; | |
58 | + } | |
59 | + } | |
60 | + } | |
61 | + return modified; | |
62 | + } | |
63 | + | |
64 | + private static void putCouponInfo(Map<String, Object> couponMap, Map<String, Object> couponInfoMap) { | |
65 | + /** key命名为 type + "_" + coupon_order */ | |
66 | + couponMap.put(couponInfoMap.get("type") + "_" + couponInfoMap.get("coupon_order"), couponInfoMap.get("type_used_count")); | |
67 | + } | |
68 | + | |
69 | + | |
70 | + public static <T> List<T> asList(String ids) { | |
71 | + return (List<T>) asList(ids, String.class); | |
72 | + } | |
73 | + | |
74 | + public static <T> List<T> asList(String ids, Class<T> clazz) { | |
75 | + Assert.notNull(ids); | |
76 | + Assert.notNull(clazz); | |
77 | + | |
78 | + List<T> list = new ArrayList<>(); | |
79 | + String[] id = ids.split(","); | |
80 | + for (String s : id) { | |
81 | + list.add((T) s); | |
82 | + } | |
83 | + return list; | |
84 | + } | |
85 | + | |
86 | +} |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/utils/SystemDataSource.java
View file @
8c07ed6