Commit d968d404f1cb9c7561ae09d4380827c1be887aec
1 parent
ad385c4b8a
Exists in
master
and in
6 other branches
优惠券时间对比规则更改
Showing 9 changed files with 218 additions and 19 deletions
- platform-biz-service/src/main/java/com/lyms/platform/permission/service/impl/BabyPatientExtendEarServiceImpl.java
- platform-biz-service/src/main/java/com/lyms/platform/permission/service/impl/CouponServiceImpl.java
- platform-biz-service/src/main/resources/mainOrm/master/CouponMapper.xml
- platform-common/src/main/java/com/lyms/platform/common/enums/AbortionEnums.java
- platform-common/src/main/java/com/lyms/platform/common/utils/BasicConfigUtil.java
- platform-common/src/main/java/com/lyms/platform/common/utils/EnumUtil.java
- platform-common/src/main/java/com/lyms/platform/common/utils/PropertiesUtil.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/EarController.java
- platform-operate-api/src/main/resources/database.properties
platform-biz-service/src/main/java/com/lyms/platform/permission/service/impl/BabyPatientExtendEarServiceImpl.java
View file @
d968d40
1 | 1 | package com.lyms.platform.permission.service.impl; |
2 | 2 | |
3 | +import com.lyms.platform.common.enums.AbortionEnums; | |
3 | 4 | import com.lyms.platform.common.enums.FmTypeEnums; |
4 | 5 | import com.lyms.platform.common.result.BaseObjectResponse; |
5 | 6 | import com.lyms.platform.common.result.RespBuilder; |
6 | -import com.lyms.platform.common.utils.SystemConfig; | |
7 | +import com.lyms.platform.common.utils.EnumUtil; | |
7 | 8 | import com.lyms.platform.permission.dao.master.BabyPatientExtendEarMapper; |
8 | 9 | import com.lyms.platform.permission.model.BabyPatientExtendEar; |
9 | 10 | import com.lyms.platform.permission.model.BabyPatientExtendEarBirth; |
10 | 11 | import com.lyms.platform.permission.model.BabyPatientExtendEarFamily; |
11 | 12 | import com.lyms.platform.permission.model.BabyPatientExtendEarMother; |
12 | 13 | import com.lyms.platform.permission.service.BabyPatientExtendEarService; |
13 | -import net.sf.json.JSONArray; | |
14 | -import net.sf.json.JSONObject; | |
14 | +import com.lyms.platform.pojo.BasicConfig; | |
15 | 15 | import org.springframework.beans.factory.annotation.Autowired; |
16 | 16 | import org.springframework.data.mongodb.core.MongoTemplate; |
17 | +import org.springframework.data.mongodb.core.query.Criteria; | |
18 | +import org.springframework.data.mongodb.core.query.Query; | |
17 | 19 | import org.springframework.stereotype.Service; |
18 | 20 | |
21 | +import java.util.HashMap; | |
22 | +import java.util.List; | |
23 | +import java.util.Map; | |
24 | + | |
19 | 25 | @Service |
20 | 26 | public class BabyPatientExtendEarServiceImpl implements BabyPatientExtendEarService { |
21 | 27 | |
... | ... | @@ -34,12 +40,13 @@ |
34 | 40 | |
35 | 41 | @Override |
36 | 42 | public BaseObjectResponse getConfigs() { |
37 | - FmTypeEnums[] fmTypes = FmTypeEnums.values(); | |
38 | - for (FmTypeEnums fmType : fmTypes) { | |
39 | - JSONObject jsonObject = JSONObject.fromObject(fmType); | |
40 | - System.err.println(">> " + jsonObject); | |
41 | - } | |
42 | - return null; | |
43 | + Map<String, Object> restMap = new HashMap<>(); | |
44 | + restMap.put("fmType", EnumUtil.buildEnumJson(FmTypeEnums.class)); /** 分娩方式 */ | |
45 | + restMap.put("aborType", EnumUtil.buildEnumJson(AbortionEnums.class)); /** 流产方式 */ | |
46 | + List<BasicConfig> basicConfigs = mongoTemplate.find(Query.query(Criteria.where("").is("")), BasicConfig.class); | |
47 | + | |
48 | + | |
49 | + return RespBuilder.buildSuccess(restMap); | |
43 | 50 | } |
44 | 51 | |
45 | 52 | } |
platform-biz-service/src/main/java/com/lyms/platform/permission/service/impl/CouponServiceImpl.java
View file @
d968d40
... | ... | @@ -5,6 +5,8 @@ |
5 | 5 | import com.lyms.platform.common.result.RespBuilder; |
6 | 6 | import com.lyms.platform.common.result.ResponseCode; |
7 | 7 | import com.lyms.platform.common.utils.DateUtil; |
8 | +import com.lyms.platform.common.utils.PropertiesUtil; | |
9 | +import com.lyms.platform.common.utils.PropertiesUtils; | |
8 | 10 | import com.lyms.platform.permission.dao.master.CouponMapper; |
9 | 11 | import com.lyms.platform.permission.model.CouponInfo; |
10 | 12 | import com.lyms.platform.permission.model.Organization; |
... | ... | @@ -349,7 +351,7 @@ |
349 | 351 | Date startDate = null; |
350 | 352 | Date endDate = null; |
351 | 353 | if(typeMap.get(PREGNANT_WOMAN).contains(couponType)) {/** 孕妇: 根据末次月经对比 midDate = 末次月经时间 */ |
352 | - List<Patients> patients = mongoTemplate.find(Query.query(Criteria.where("type").is(1).and("hospitalId").is(hospitalId).and("pid").is(userId)), Patients.class); | |
354 | + List<Patients> patients = mongoTemplate.find(Query.query(Criteria.where("pid").is(userId)), Patients.class); | |
353 | 355 | if(CollectionUtils.isEmpty(patients)) { |
354 | 356 | BabyModel baby = mongoTemplate.findOne(Query.query(Criteria.where("pid").is(userId)), BabyModel.class); |
355 | 357 | if(baby != null) {/** 孕妇没查到就查儿童 */ |
... | ... | @@ -359,7 +361,7 @@ |
359 | 361 | return false; |
360 | 362 | } |
361 | 363 | } |
362 | - midDate = patients.get(0).getLastMenses(); | |
364 | + midDate = patients.get(0).getFmDate(); | |
363 | 365 | } else {/** 产妇或者儿童:根据分娩时间对比 midDate = 分娩时间 */ |
364 | 366 | List<Patients> patients = mongoTemplate.find(Query.query(Criteria.where("type").is(3).and("hospitalId").is(hospitalId).and("pid").is(userId)) |
365 | 367 | .with(new Sort(Sort.Direction.DESC, "fmDate")), Patients.class); |
366 | 368 | |
... | ... | @@ -375,10 +377,10 @@ |
375 | 377 | if(unitType == 1) { /** 孕周: startDate = lastMenses + start*7、 endDate = lastMenses + end*7 + 6*/ |
376 | 378 | startDate = DateUtils.addDays(midDate, start * 7); |
377 | 379 | endDate = DateUtils.addDays(midDate, end * 7 + 6); |
378 | - } else if(unitType == 2) { /** 天数 stratDate = lastMenses + start、 endDate = lastMenses + end */ | |
380 | + } else if(unitType == 2) { /** 天数 stratDate = 孕妇:fmDate/儿童:birth + start、 endDate = lastMenses + end */ | |
379 | 381 | startDate = DateUtils.addDays(midDate, start); |
380 | 382 | endDate = DateUtils.addDays(midDate, end); |
381 | - } else if(unitType == 3) { /** 月龄 startDate = lastMenses + start、 endDate = lastMenses + end + 1 如果是31号 计算出来的月份没有31号 取最后一天*/ | |
383 | + } else if(unitType == 3) { /** 月龄 startDate = fmDate/birth + start、 endDate = fmDate/birth + end + 1 如果是31号 计算出来的月份没有31号 取最后一天*/ | |
382 | 384 | startDate = DateUtils.addMonths(midDate, start); |
383 | 385 | endDate = DateUtils.addMonths(midDate, end + 1); |
384 | 386 | } |
385 | 387 | |
... | ... | @@ -398,11 +400,18 @@ |
398 | 400 | |
399 | 401 | Map<String, Object> restMap = new HashMap<>(); |
400 | 402 | restMap.put("topName", couponMapper.findTopName(hospitalId)); |
401 | - restMap.put("couponInfos", couponMapper.findInfo(param)); | |
402 | - restMap.put("url", url); | |
403 | - | |
403 | + List<Map<String, Object>> couponInfos = couponMapper.findInfo(param); | |
404 | + for (Map<String,Object> map : couponInfos) { | |
405 | + map.put("url", PropertiesUtil.getInstance().getDefault("or.code.url", map.get("sequence_id").toString())); | |
406 | + } | |
407 | + restMap.put("couponInfos", couponInfos); | |
404 | 408 | return RespBuilder.buildSuccess(restMap); |
405 | 409 | } |
410 | + | |
411 | + public static void main(String[] args) { | |
412 | + System.out.println(PropertiesUtils.getPropertyValue("or.code.url")); | |
413 | + } | |
414 | + | |
406 | 415 | |
407 | 416 | @Override |
408 | 417 | public BaseObjectResponse use(String hospitalId, String code, Integer userId) { |
platform-biz-service/src/main/resources/mainOrm/master/CouponMapper.xml
View file @
d968d40
... | ... | @@ -59,7 +59,7 @@ |
59 | 59 | </select> |
60 | 60 | |
61 | 61 | <select id="findInfo" parameterType="map" resultType="map"> |
62 | - select b.name, b.title, b.show_start, b.show_end, b.unit_type, b.content, a.sequence_id, a.status | |
62 | + select a.create_date, b.name, b.title, b.show_start, b.show_end, b.unit_type, b.content, a.sequence_id, a.status | |
63 | 63 | from coupon_info a, coupon_template b, coupon_type c |
64 | 64 | where a.user_id = #{userId} and a.create_hospital_id = #{hospitalId} and a.coupon_template_id = b.id and b.type_id=c.id |
65 | 65 | order by c.type, b.coupon_order |
platform-common/src/main/java/com/lyms/platform/common/enums/AbortionEnums.java
View file @
d968d40
1 | +package com.lyms.platform.common.enums; | |
2 | + | |
3 | +/** | |
4 | + * @Author: litao | |
5 | + * @Date: 2017/5/15 0015 14:17 | |
6 | + * @Version: V1.0 | |
7 | + */ | |
8 | +public enum AbortionEnums { | |
9 | + SPONTANEOUS("1", "自然流产"), | |
10 | + MEDICINE("2", "药物流产"), | |
11 | + ARTIFICIAL("3", "人工流产"); | |
12 | + | |
13 | + AbortionEnums(String id, String name) { | |
14 | + this.id = id; | |
15 | + this.name = name; | |
16 | + } | |
17 | + | |
18 | + private String id; | |
19 | + private String name; | |
20 | + | |
21 | + public String getId() { | |
22 | + return id; | |
23 | + } | |
24 | + | |
25 | + public void setId(String id) { | |
26 | + this.id = id; | |
27 | + } | |
28 | + | |
29 | + public String getName() { | |
30 | + return name; | |
31 | + } | |
32 | + | |
33 | + public void setName(String name) { | |
34 | + this.name = name; | |
35 | + } | |
36 | + | |
37 | +} |
platform-common/src/main/java/com/lyms/platform/common/utils/BasicConfigUtil.java
View file @
d968d40
platform-common/src/main/java/com/lyms/platform/common/utils/EnumUtil.java
View file @
d968d40
1 | +package com.lyms.platform.common.utils; | |
2 | + | |
3 | +import com.lyms.platform.common.enums.FmTypeEnums; | |
4 | +import org.apache.commons.beanutils.PropertyUtils; | |
5 | + | |
6 | +import java.security.InvalidParameterException; | |
7 | +import java.util.ArrayList; | |
8 | +import java.util.HashMap; | |
9 | +import java.util.List; | |
10 | +import java.util.Map; | |
11 | + | |
12 | +/** | |
13 | + * @Author: litao | |
14 | + * @Date: 2017/5/15 0015 11:01 | |
15 | + * @Version: V1.0 | |
16 | + */ | |
17 | +public class EnumUtil { | |
18 | + | |
19 | + private static final String DEFAULT_KEY_NAME = "id"; | |
20 | + private static final String DEFAULT_VALUE_NAME = "name"; | |
21 | + | |
22 | + public static <T> List<Map<String, Object>> buildEnumJson(Class<T> clazz) { | |
23 | + return buildEnumJson(clazz, DEFAULT_KEY_NAME, DEFAULT_VALUE_NAME); | |
24 | + } | |
25 | + | |
26 | + public static <T> List<Map<String, Object>> buildEnumJson(Class<T> clazz, String codeName, String valueName) { | |
27 | + List<Map<String, Object>> list = new ArrayList<>(); | |
28 | + | |
29 | + if (!clazz.isEnum()) { | |
30 | + throw new InvalidParameterException("请传入枚举类型参数"); | |
31 | + } | |
32 | + | |
33 | + org.springframework.util.Assert.notNull(codeName, "key不能为null"); | |
34 | + org.springframework.util.Assert.notNull(valueName, "value不能为null"); | |
35 | + | |
36 | + try { | |
37 | + T[] enumConstants = clazz.getEnumConstants(); | |
38 | + for (T ec : enumConstants) { | |
39 | + Object key = PropertyUtils.getProperty(ec,codeName); | |
40 | + Object value = PropertyUtils.getProperty(ec,valueName); | |
41 | + if(key != null && value != null) { | |
42 | + Map<String, Object> tempMap = new HashMap<>(); | |
43 | + tempMap.put(key.toString(), value); | |
44 | + list.add(tempMap); | |
45 | + } | |
46 | + } | |
47 | + } catch (Exception e) { | |
48 | + e.printStackTrace(); | |
49 | + } | |
50 | + return list; | |
51 | + } | |
52 | + | |
53 | +} |
platform-common/src/main/java/com/lyms/platform/common/utils/PropertiesUtil.java
View file @
d968d40
1 | +package com.lyms.platform.common.utils; | |
2 | + | |
3 | +import org.apache.commons.lang3.StringUtils; | |
4 | +import org.slf4j.Logger; | |
5 | +import org.slf4j.LoggerFactory; | |
6 | + | |
7 | +import java.text.MessageFormat; | |
8 | +import java.util.HashMap; | |
9 | +import java.util.Map; | |
10 | +import java.util.Properties; | |
11 | + | |
12 | +public class PropertiesUtil { | |
13 | + private static PropertiesUtil propertiesUtil; | |
14 | + private static Map<String,Properties> propertiesMap; | |
15 | + private static Logger logger = LoggerFactory.getLogger(PropertiesUtil.class); | |
16 | + | |
17 | + private static final String DEFAULT_DATABASE_NAME = "database"; | |
18 | + private static final String CONFIG_NAME = "config"; | |
19 | + | |
20 | + | |
21 | + public static PropertiesUtil getInstance() { | |
22 | + if(propertiesUtil == null) { | |
23 | + synchronized (PropertiesUtil.class) { | |
24 | + if(propertiesUtil == null) { | |
25 | + propertiesUtil = new PropertiesUtil(); | |
26 | + propertiesMap = new HashMap<>(); | |
27 | + } | |
28 | + } | |
29 | + } | |
30 | + return propertiesUtil; | |
31 | + } | |
32 | + | |
33 | + | |
34 | + /** | |
35 | + * 加载配置文件 不用带properties | |
36 | + * @param name | |
37 | + */ | |
38 | + private Properties load(String name) { | |
39 | + Properties properties = null; | |
40 | + try { | |
41 | + properties = propertiesMap.get(name); | |
42 | + if(properties == null) { | |
43 | + properties = new Properties(); | |
44 | + properties.load(PropertiesUtil.class.getResourceAsStream("/" + name + ".properties")); | |
45 | + propertiesMap.put(name, properties); | |
46 | + } | |
47 | + } catch (Exception e) { | |
48 | + logger.error("读取配置文件 {} 失败:", name, e.fillInStackTrace()); | |
49 | + } | |
50 | + return properties; | |
51 | + } | |
52 | + | |
53 | + public String get(String fileName, String keyName, String... params) { | |
54 | + String value = load(fileName).getProperty(keyName); | |
55 | + if(StringUtils.isNotBlank(value) && params != null) { | |
56 | + value = format(value, params); | |
57 | + } | |
58 | + return value; | |
59 | + } | |
60 | + | |
61 | + /** | |
62 | + * 默认读取 database 配置文件里面的 | |
63 | + * @param keyName | |
64 | + * @param params | |
65 | + * @return | |
66 | + */ | |
67 | + public String getDefault(String keyName, String... params) { | |
68 | + return get(DEFAULT_DATABASE_NAME, keyName, params); | |
69 | + } | |
70 | + | |
71 | + public String format(String key, String... params) { | |
72 | + return MessageFormat.format(key, params); | |
73 | + } | |
74 | + | |
75 | +} |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/EarController.java
View file @
d968d40
... | ... | @@ -2,7 +2,10 @@ |
2 | 2 | |
3 | 3 | import com.lyms.platform.common.annotation.TokenRequired; |
4 | 4 | import com.lyms.platform.common.base.BaseController; |
5 | +import com.lyms.platform.common.enums.FmTypeEnums; | |
5 | 6 | import com.lyms.platform.common.result.BaseObjectResponse; |
7 | +import com.lyms.platform.common.result.RespBuilder; | |
8 | +import com.lyms.platform.common.utils.EnumUtil; | |
6 | 9 | import com.lyms.platform.permission.model.BabyPatientExtendEar; |
7 | 10 | import com.lyms.platform.permission.model.BabyPatientExtendEarBirth; |
8 | 11 | import com.lyms.platform.permission.model.BabyPatientExtendEarFamily; |
9 | 12 | |
... | ... | @@ -45,10 +48,16 @@ |
45 | 48 | * 获取 添加儿童建档界面的 下拉列表数据 |
46 | 49 | * @return |
47 | 50 | */ |
48 | - @RequestMapping(method = RequestMethod.GET) | |
51 | + @RequestMapping(value = "/config", method = RequestMethod.GET) | |
49 | 52 | @ResponseBody |
50 | 53 | public BaseObjectResponse config() { |
51 | 54 | return babyPatientExtendEarService.getConfigs(); |
55 | + } | |
56 | + | |
57 | + @RequestMapping("/test") | |
58 | + @ResponseBody | |
59 | + public BaseObjectResponse test() { | |
60 | + return RespBuilder.buildSuccess(EnumUtil.buildEnumJson(FmTypeEnums.class)); | |
52 | 61 | } |
53 | 62 | } |
platform-operate-api/src/main/resources/database.properties
View file @
d968d40