Commit 9425372fc833a8746391e6487e58799b1c293ebc
1 parent
a1b29ef04c
Exists in
master
and in
1 other branch
etl项目增加、代码逻辑修改
Showing 16 changed files with 503 additions and 43 deletions
- platform-biz-service/src/main/java/com/lyms/platform/permission/model/CouponInfo.java
- platform-biz-service/src/main/java/com/lyms/platform/permission/service/CouponService.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/result/ResponseCode.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/CouponController.java
- pom.xml
- regional-etl/src/main/java/com/lyms/etl/ApplicationRunner.java
- regional-etl/src/main/java/com/lyms/etl/dao/ICouponInfoDao.java
- regional-etl/src/main/java/com/lyms/etl/model/CouponInfo.java
- regional-etl/src/main/java/com/lyms/etl/service/ICouponInfoService.java
- regional-etl/src/main/java/com/lyms/etl/service/IEtlService.java
- regional-etl/src/main/java/com/lyms/etl/service/impl/CouponInfoServiceImpl.java
- regional-etl/src/main/java/com/lyms/etl/service/impl/EtlServiceImpl.java
- regional-etl/src/main/resources/application.yml
- regional-etl/src/main/resources/mappers/CouponInfoMapper.xml
platform-biz-service/src/main/java/com/lyms/platform/permission/model/CouponInfo.java
View file @
9425372
platform-biz-service/src/main/java/com/lyms/platform/permission/service/CouponService.java
View file @
9425372
| ... | ... | @@ -8,9 +8,9 @@ |
| 8 | 8 | * @Version: V1.0 |
| 9 | 9 | */ |
| 10 | 10 | public interface CouponService{ |
| 11 | - BaseObjectResponse create(String userId, String hospitalId, String type, Integer createUserId); | |
| 11 | + BaseObjectResponse create(String userId, String hospitalId, Integer createUserId); | |
| 12 | 12 | |
| 13 | - BaseObjectResponse validate(String userId, String code); | |
| 13 | + BaseObjectResponse validate(String userId, String code, Integer type); | |
| 14 | 14 | |
| 15 | 15 | BaseObjectResponse findList(String userId, String hospitalId); |
| 16 | 16 |
platform-biz-service/src/main/java/com/lyms/platform/permission/service/impl/CouponServiceImpl.java
View file @
9425372
| ... | ... | @@ -8,9 +8,12 @@ |
| 8 | 8 | import com.lyms.platform.permission.dao.master.CouponMapper; |
| 9 | 9 | import com.lyms.platform.permission.model.CouponInfo; |
| 10 | 10 | import com.lyms.platform.permission.service.CouponService; |
| 11 | +import com.lyms.platform.pojo.DischargeAbstractMotherModel; | |
| 12 | +import com.lyms.platform.pojo.MaternalDeliverModel; | |
| 11 | 13 | import com.lyms.platform.pojo.Patients; |
| 14 | +import com.lyms.platform.pojo.PersonModel; | |
| 12 | 15 | import org.apache.commons.collections.CollectionUtils; |
| 13 | -import org.apache.commons.lang3.StringUtils; | |
| 16 | +import org.apache.commons.collections.MapUtils; | |
| 14 | 17 | import org.apache.commons.lang3.time.DateUtils; |
| 15 | 18 | import org.slf4j.Logger; |
| 16 | 19 | import org.slf4j.LoggerFactory; |
| ... | ... | @@ -22,10 +25,7 @@ |
| 22 | 25 | import org.springframework.data.mongodb.core.query.Query; |
| 23 | 26 | import org.springframework.stereotype.Service; |
| 24 | 27 | |
| 25 | -import java.util.Date; | |
| 26 | -import java.util.HashMap; | |
| 27 | -import java.util.List; | |
| 28 | -import java.util.Map; | |
| 28 | +import java.util.*; | |
| 29 | 29 | |
| 30 | 30 | /** |
| 31 | 31 | * @Author: litao |
| ... | ... | @@ -37,6 +37,20 @@ |
| 37 | 37 | |
| 38 | 38 | private Logger logger = LoggerFactory.getLogger(CouponServiceImpl.class); |
| 39 | 39 | |
| 40 | + /** 1 = 孕妇 */ | |
| 41 | + private static final String PREGNANT_WOMAN = "1"; | |
| 42 | + | |
| 43 | + /** 2 = 儿童 */ | |
| 44 | + private static final String CHILDREN = "2"; | |
| 45 | + | |
| 46 | + /** 3_{?} = 产妇 */ | |
| 47 | + /** 产妇没有分娩记录且没有出院小结 */ | |
| 48 | + private static final String MATERNAL_NCHILDBIRTH_NHOSPITAL = "3_1"; | |
| 49 | + /** 产妇有分娩记录且没有出院小结 */ | |
| 50 | + private static final String MATERNAL_YCHILDBIRTH_NHOSPITAL = "3_2"; | |
| 51 | + /** 产妇有分娩记录且有出院小结 */ | |
| 52 | + private static final String MATERNAL_YCHILDBIRTH_YHOSPITAL = "3_3"; | |
| 53 | + | |
| 40 | 54 | @Value("${or.code.url}") |
| 41 | 55 | private String url; |
| 42 | 56 | |
| 43 | 57 | |
| 44 | 58 | |
| 45 | 59 | |
| 46 | 60 | |
| 47 | 61 | |
| ... | ... | @@ -49,34 +63,78 @@ |
| 49 | 63 | @Autowired |
| 50 | 64 | private MongoTemplate mongoTemplate; |
| 51 | 65 | |
| 66 | + /** | |
| 67 | + * 生成规则: | |
| 68 | + * 孕妇 建档、产检、分娩、出院小结、产后复查 | |
| 69 | + * 产妇 建档、出院小结、产后复查 | |
| 70 | + * 产妇没有分娩记录且没有出院小结: 分娩、出院小结、产后复查 | |
| 71 | + * 产妇有分娩记录且没有出院小结: 出院小结、产后复查 | |
| 72 | + * 产妇有分娩记录且有出院小结: 产后复查 | |
| 73 | + * 儿童 建档、儿童保健 | |
| 74 | + * 建档:统一处理,如果点击创建中配置了建档券,自动使用,使用日期为建档日期,使用人为建档人,建档机构为建档人机构 | |
| 75 | + */ | |
| 76 | + /** key>> 1=孕妇 2=儿童 3=产妇 */ | |
| 77 | + /** value>> 1=孕妇建档 2=孕妇产检 3=产妇建档 4=产妇分娩 5=产妇出院小结 6=产妇产后复查 7=儿童建档 8=儿童保健 */ | |
| 78 | + private Map<String, List<Integer>> typeMap = new HashMap<String,List<Integer>>() { | |
| 79 | + { | |
| 80 | + put(PREGNANT_WOMAN, Arrays.asList(1, 2, 4, 5, 6)); | |
| 81 | + put(CHILDREN, Arrays.asList(7, 8)); | |
| 82 | + put(MATERNAL_NCHILDBIRTH_NHOSPITAL, Arrays.asList(4, 5, 6)); | |
| 83 | + put(MATERNAL_YCHILDBIRTH_NHOSPITAL, Arrays.asList(5, 6)); | |
| 84 | + put(MATERNAL_YCHILDBIRTH_YHOSPITAL, Arrays.asList(6)); | |
| 85 | + } | |
| 86 | + }; | |
| 87 | + | |
| 52 | 88 | @Override |
| 53 | - public BaseObjectResponse create(String userId, String hospitalId, String userType, Integer createUserId) { | |
| 54 | - Map<String, Object> param = new HashMap<>(); | |
| 55 | - if(StringUtils.isBlank(userType)) { | |
| 56 | - Patients patients = mongoTemplate.findOne(Query.query(Criteria.where("pid").is(userId)), Patients.class); | |
| 57 | - if(patients == null || patients.getType() == null) return RespBuilder.buildErro(ResponseCode.PATIENTS_NOT_FOUND); | |
| 58 | - param.put("type", patients.getType()); | |
| 59 | - } else { | |
| 60 | - param.put("type", userType); | |
| 89 | + public BaseObjectResponse create(String userId, String hospitalId, Integer createUserId) { | |
| 90 | + if(isCreated(userId, hospitalId)) { | |
| 91 | + return RespBuilder.buildErro(ResponseCode.COUPON_IS_CREATED); | |
| 61 | 92 | } |
| 62 | 93 | |
| 94 | + /** 1=孕妇 2=儿童 3=产妇 */ | |
| 95 | + PersonModel person = mongoTemplate.findById(userId, PersonModel.class); | |
| 96 | + if(person == null || person.getType() == null) { | |
| 97 | + return RespBuilder.buildErro(ResponseCode.PERSON_NOT_FOUND); | |
| 98 | + } | |
| 99 | + | |
| 100 | + List<Integer> types = findTypeByPerson(person); | |
| 101 | + if(CollectionUtils.isEmpty(types)) { | |
| 102 | + return RespBuilder.buildErro(ResponseCode.PATIENT_NOT_FOUND); | |
| 103 | + } | |
| 104 | + | |
| 105 | + Map<String, Object> param = new HashMap<>(); | |
| 106 | + param.put("types", types); | |
| 63 | 107 | param.put("hospitalId", hospitalId); |
| 64 | 108 | List<Map<String,Object>> temps = couponMapper.findTemp(param); |
| 109 | + if(CollectionUtils.isEmpty(temps)) { | |
| 110 | + return RespBuilder.buildErro(ResponseCode.COUPON_TEMP_NOT_FOUND); | |
| 111 | + } | |
| 112 | + sendCoupon(temps, hospitalId, createUserId, userId); | |
| 113 | + return RespBuilder.buildSuccess(); | |
| 114 | + } | |
| 65 | 115 | |
| 66 | - if(CollectionUtils.isEmpty(temps)) return RespBuilder.buildErro(ResponseCode.COUPON_TEMP_NOT_FOUND); | |
| 116 | + private boolean isCreated(String userId, String hospitalId) { | |
| 117 | + Map<String, Object> param = new HashMap<>(); | |
| 118 | + param.put("userId", userId); | |
| 119 | + param.put("hospitalId", hospitalId); | |
| 120 | + List<CouponInfo> list = couponMapper.findList(param); | |
| 121 | + return CollectionUtils.isNotEmpty(list); | |
| 122 | + } | |
| 123 | + | |
| 124 | + private void sendCoupon(List<Map<String, Object>> temps, String hospitalId, Integer createUserId, String userId) { | |
| 67 | 125 | for (Map<String, Object> temp : temps) { |
| 68 | 126 | Object sendType = temp.get("send_type"); |
| 69 | 127 | if(sendType != null) {/** 1=全部发放 2=按有效时间发放 */ |
| 70 | - CouponInfo couponInfo = new CouponInfo(); | |
| 71 | - couponInfo.setCreateDate(new Date()); | |
| 72 | - couponInfo.setCreateHospitalId(hospitalId); | |
| 73 | - couponInfo.setCreateUserId(String.valueOf(createUserId)); | |
| 74 | - couponInfo.setSequenceId(genIdService.poll()); | |
| 75 | - couponInfo.setStatus(1); | |
| 76 | - couponInfo.setUserId(userId); | |
| 77 | - if(temp.get("coupon_template_id") != null) { | |
| 78 | - couponInfo.setCouponTemplateId(temp.get("coupon_template_id").toString()); | |
| 79 | - } | |
| 128 | + CouponInfo couponInfo = new CouponInfo(); | |
| 129 | + couponInfo.setCreateDate(new Date()); | |
| 130 | + couponInfo.setCreateHospitalId(hospitalId); | |
| 131 | + couponInfo.setCreateUserId(String.valueOf(createUserId)); | |
| 132 | + couponInfo.setSequenceId(genIdService.poll()); | |
| 133 | + couponInfo.setStatus(1); | |
| 134 | + couponInfo.setUserId(userId); | |
| 135 | + if(temp.get("coupon_template_id") != null) { | |
| 136 | + couponInfo.setCouponTemplateId(temp.get("coupon_template_id").toString()); | |
| 137 | + } | |
| 80 | 138 | if("1".equals(sendType.toString())) { |
| 81 | 139 | couponMapper.save(couponInfo); |
| 82 | 140 | } else if("2".equals(sendType.toString())) { |
| 83 | 141 | |
| 84 | 142 | |
| 85 | 143 | |
| ... | ... | @@ -93,14 +151,57 @@ |
| 93 | 151 | } |
| 94 | 152 | } |
| 95 | 153 | } |
| 96 | - return RespBuilder.buildSuccess(); | |
| 97 | 154 | } |
| 98 | 155 | |
| 156 | + private List<Integer> findTypeByPerson(PersonModel person) { | |
| 157 | + List<Integer> types = new ArrayList<>(); | |
| 158 | + | |
| 159 | + if(person.getType() == 1) { | |
| 160 | + return typeMap.get(PREGNANT_WOMAN); | |
| 161 | + } else if(person.getType() == 2) { | |
| 162 | + return typeMap.get(CHILDREN); | |
| 163 | + } else if(person.getType() == 3) { | |
| 164 | + /** 是否有分娩记录 */ | |
| 165 | + boolean isChildbirth = false; | |
| 166 | + /** 是否有出院小结 */ | |
| 167 | + boolean isHospital = false; | |
| 168 | + | |
| 169 | + List<Patients> patients = mongoTemplate.find(Query.query(Criteria.where("pid").is(person.getId())).with(new Sort(Sort.Direction.DESC, "lastMenses")), Patients.class); | |
| 170 | + if(CollectionUtils.isEmpty(patients)) { | |
| 171 | + return types; | |
| 172 | + } | |
| 173 | + List<MaternalDeliverModel> deliverModels = mongoTemplate.find(Query.query(Criteria.where("pid").is(patients.get(0).getId())), MaternalDeliverModel.class); | |
| 174 | + if(CollectionUtils.isNotEmpty(deliverModels)) { | |
| 175 | + isChildbirth = true; | |
| 176 | + } | |
| 177 | + | |
| 178 | + List<DischargeAbstractMotherModel> motherModels = mongoTemplate.find(Query.query(Criteria.where("patientId").is(patients.get(0).getId())), DischargeAbstractMotherModel.class); | |
| 179 | + if(CollectionUtils.isNotEmpty(motherModels)) { | |
| 180 | + isHospital = true; | |
| 181 | + } | |
| 182 | + types = parseType(isChildbirth, isHospital); | |
| 183 | + } | |
| 184 | + return types; | |
| 185 | + } | |
| 186 | + | |
| 187 | + private List<Integer> parseType(boolean isChildbirth, boolean isHospital) { | |
| 188 | + if(isChildbirth == false && isHospital == false) { | |
| 189 | + return typeMap.get(MATERNAL_NCHILDBIRTH_NHOSPITAL); | |
| 190 | + } else if(isChildbirth == true && isHospital == false) { | |
| 191 | + return typeMap.get(MATERNAL_YCHILDBIRTH_NHOSPITAL); | |
| 192 | + } else { | |
| 193 | + return typeMap.get(MATERNAL_YCHILDBIRTH_YHOSPITAL); | |
| 194 | + } | |
| 195 | + } | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 99 | 199 | @Override |
| 100 | - public BaseObjectResponse validate(String userId, String code) { | |
| 200 | + public BaseObjectResponse validate(String userId, String code, Integer type) { | |
| 101 | 201 | Map<String, Object> param = new HashMap<>(); |
| 102 | 202 | param.put("userId", userId); |
| 103 | 203 | param.put("code", code); |
| 204 | + param.put("type", type); | |
| 104 | 205 | List<CouponInfo> couponInfos = couponMapper.findList(param); |
| 105 | 206 | if(CollectionUtils.isEmpty(couponInfos)) |
| 106 | 207 | return RespBuilder.buildErro(ResponseCode.COUPON_NOT_FOUND); |
| ... | ... | @@ -116,6 +217,9 @@ |
| 116 | 217 | } |
| 117 | 218 | |
| 118 | 219 | Map<String, Object> data = couponMapper.findValidateParam(param); |
| 220 | + if(MapUtils.isEmpty(data)) { | |
| 221 | + return RespBuilder.buildErro(ResponseCode.COUPON_NOT_AVAILABLE); | |
| 222 | + } | |
| 119 | 223 | |
| 120 | 224 | if(!validateDate(userId, Integer.parseInt(data.get("actual_start").toString()), Integer.parseInt(data.get("actual_end").toString()), Integer.parseInt(data.get("unit_type").toString()), |
| 121 | 225 | data.get("create_hospital_id").toString(), Integer.parseInt(data.get("type").toString()))) |
platform-biz-service/src/main/resources/mainOrm/master/CouponMapper.xml
View file @
9425372
| ... | ... | @@ -22,7 +22,17 @@ |
| 22 | 22 | |
| 23 | 23 | <select id="findList" parameterType="map" resultMap="couponInfoMap"> |
| 24 | 24 | select id,<include refid="columnList" /> from coupon_info |
| 25 | - where user_id = #{userId} and sequence_id = #{code} | |
| 25 | + <where> | |
| 26 | + <if test="userId != null"> | |
| 27 | + and user_id = #{userId} | |
| 28 | + </if> | |
| 29 | + <if test="code != null"> | |
| 30 | + and sequence_id = #{code} | |
| 31 | + </if> | |
| 32 | + <if test="hospitalId != null"> | |
| 33 | + and create_hospital_id = #{hospitalId} | |
| 34 | + </if> | |
| 35 | + </where> | |
| 26 | 36 | </select> |
| 27 | 37 | |
| 28 | 38 | <insert id="save" parameterType="com.lyms.platform.permission.model.CouponInfo"> |
| ... | ... | @@ -32,7 +42,11 @@ |
| 32 | 42 | <select id="findTemp" parameterType="map" resultType="map"> |
| 33 | 43 | select b.id, b.id as coupon_template_id, b.actual_start, b.actual_end, b.unit_type, c.send_type, c.type from |
| 34 | 44 | hospital_coupon_template_group a, coupon_template b, coupon_type c |
| 35 | - where a.hospital_id = #{hospitalId} and a.coupon_template_group_id = b.group_id and b.type_id = c.id and c.type=#{type} | |
| 45 | + where a.hospital_id = #{hospitalId} and a.coupon_template_group_id = b.group_id and b.type_id = c.id and c.type in | |
| 46 | + /*(4, 5, 6)*/ | |
| 47 | + <foreach collection="types" open="(" close=")" separator="," item="type"> | |
| 48 | + #{type} | |
| 49 | + </foreach> | |
| 36 | 50 | order by b.coupon_order |
| 37 | 51 | </select> |
| 38 | 52 | |
| ... | ... | @@ -52,7 +66,7 @@ |
| 52 | 66 | select b.actual_start, b.actual_end, b.unit_type, a.create_hospital_id, c.type |
| 53 | 67 | from coupon_info a, coupon_template b, coupon_type c |
| 54 | 68 | where a.user_id = #{userId} and a.sequence_id = #{code} |
| 55 | - and a.coupon_template_id = b.id and b.type_id = c.id | |
| 69 | + and a.coupon_template_id = b.id and b.type_id = c.id and c.type = #{type} | |
| 56 | 70 | </select> |
| 57 | 71 | |
| 58 | 72 | <update id="use" parameterType="map"> |
platform-common/src/main/java/com/lyms/platform/common/result/ResponseCode.java
View file @
9425372
| ... | ... | @@ -9,9 +9,13 @@ |
| 9 | 9 | SUCCESS(0, "成功"), |
| 10 | 10 | ERROR(500, "系统错误,请联系管理员"), |
| 11 | 11 | |
| 12 | - PATIENTS_NOT_FOUND(2001, "Patients未查询到或type为空"), | |
| 12 | + PERSON_NOT_FOUND(2001, "用户未查询到或type为空"), | |
| 13 | + PATIENT_NOT_FOUND(2002, "未查询到患者"), | |
| 13 | 14 | |
| 14 | - COUPON_TEMP_NOT_FOUND(1006, "医院未绑定模板"), | |
| 15 | + | |
| 16 | + COUPON_TEMP_NOT_FOUND(1006, "医院未绑定模板或无可生成的优惠券类型"), | |
| 17 | + COUPON_IS_CREATED(1007, "该用户已生成产检券"), | |
| 18 | + COUPON_NOT_AVAILABLE(1008, "使用的产检券类型不正确"), | |
| 15 | 19 | |
| 16 | 20 | COUPON_NOT_FOUND(1001, "优惠券不存在"), |
| 17 | 21 | COUPON_NOT_UNIQUE(1002, "优惠券有多个"), |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/CouponController.java
View file @
9425372
| ... | ... | @@ -27,23 +27,22 @@ |
| 27 | 27 | private CouponService couponService; |
| 28 | 28 | |
| 29 | 29 | /** |
| 30 | - * 创建用户优惠券 | |
| 30 | + * 创建用户产检券 | |
| 31 | 31 | * @param userId |
| 32 | 32 | * @param hospitalId |
| 33 | - * @param type 1=孕妇 2=产妇 3=儿童 | |
| 34 | 33 | * @return |
| 35 | 34 | */ |
| 36 | 35 | @RequestMapping(method = RequestMethod.POST) |
| 37 | 36 | @ResponseBody |
| 38 | 37 | @TokenRequired |
| 39 | - public BaseObjectResponse create(String userId, String hospitalId, String type, HttpServletRequest request) { | |
| 38 | + public BaseObjectResponse create(String userId, String hospitalId, HttpServletRequest request) { | |
| 40 | 39 | LoginContext loginState = (LoginContext) request.getAttribute("loginContext"); |
| 41 | - return couponService.create(userId, hospitalId, type, loginState.getId()); | |
| 40 | + return couponService.create(userId, hospitalId, loginState.getId()); | |
| 42 | 41 | // return couponService.create(userId, hospitalId, 200); |
| 43 | 42 | } |
| 44 | 43 | |
| 45 | 44 | /** |
| 46 | - * 查询用户可用优惠券 | |
| 45 | + * 查询用户优惠券 | |
| 47 | 46 | * @param userId |
| 48 | 47 | * @param hospitalId |
| 49 | 48 | * @return |
| 50 | 49 | |
| ... | ... | @@ -55,10 +54,10 @@ |
| 55 | 54 | } |
| 56 | 55 | |
| 57 | 56 | |
| 58 | - @RequestMapping(method = RequestMethod.GET, value = "/validate/{userId}/{code}") | |
| 57 | + @RequestMapping(method = RequestMethod.GET, value = "/validate/{userId}/{code}/{type}") | |
| 59 | 58 | @ResponseBody |
| 60 | - public BaseObjectResponse validate(@PathVariable String userId, @PathVariable String code) { | |
| 61 | - return couponService.validate(userId, code); | |
| 59 | + public BaseObjectResponse validate(@PathVariable String userId, @PathVariable String code, @PathVariable Integer type) { | |
| 60 | + return couponService.validate(userId, code, type); | |
| 62 | 61 | } |
| 63 | 62 | |
| 64 | 63 | /** |
pom.xml
View file @
9425372
regional-etl/src/main/java/com/lyms/etl/ApplicationRunner.java
View file @
9425372
| 1 | +package com.lyms.etl; | |
| 2 | + | |
| 3 | +import com.lyms.etl.service.ICouponInfoService; | |
| 4 | +import org.mybatis.spring.annotation.MapperScan; | |
| 5 | +import org.slf4j.Logger; | |
| 6 | +import org.slf4j.LoggerFactory; | |
| 7 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 8 | +import org.springframework.boot.SpringApplication; | |
| 9 | +import org.springframework.boot.autoconfigure.SpringBootApplication; | |
| 10 | +import org.springframework.data.mongodb.core.MongoTemplate; | |
| 11 | +import org.springframework.data.mongodb.core.query.Criteria; | |
| 12 | +import org.springframework.data.mongodb.core.query.Query; | |
| 13 | +import org.springframework.web.bind.annotation.RequestMapping; | |
| 14 | +import org.springframework.web.bind.annotation.RestController; | |
| 15 | + | |
| 16 | +/** | |
| 17 | + * @Author: litao | |
| 18 | + * @Date: 2017/5/2 0002 20:29 | |
| 19 | + * @Version: V1.0 | |
| 20 | + */ | |
| 21 | +@SpringBootApplication | |
| 22 | +@MapperScan("com.lyms.etl.dao") | |
| 23 | +@RestController | |
| 24 | +public class ApplicationRunner { | |
| 25 | + | |
| 26 | + @Autowired | |
| 27 | + private MongoTemplate mongoTemplate; | |
| 28 | + | |
| 29 | + @Autowired | |
| 30 | + private ICouponInfoService couponInfoService; | |
| 31 | + | |
| 32 | + @RequestMapping("/") | |
| 33 | + public String test() { | |
| 34 | + System.out.println(mongoTemplate.find(Query.query(Criteria.where("key").is("SEQUENCE_QUEUE")), Object.class, "lyms_plantform_config")); | |
| 35 | + return "xxxxx"; | |
| 36 | + } | |
| 37 | + | |
| 38 | + @RequestMapping("/2") | |
| 39 | + public String test2() { | |
| 40 | + System.out.println(couponInfoService.find("2c4613d659a548b492b81fa6ab7ce4b6")); | |
| 41 | + return "xxxxx"; | |
| 42 | + } | |
| 43 | + | |
| 44 | + private static final Logger log = LoggerFactory.getLogger(ApplicationRunner.class); | |
| 45 | + | |
| 46 | + public static void main(String[] args) { | |
| 47 | + SpringApplication.run(ApplicationRunner.class, args); | |
| 48 | + log.info("etl started......"); | |
| 49 | + } | |
| 50 | +} |
regional-etl/src/main/java/com/lyms/etl/dao/ICouponInfoDao.java
View file @
9425372
regional-etl/src/main/java/com/lyms/etl/model/CouponInfo.java
View file @
9425372
| 1 | +package com.lyms.etl.model; | |
| 2 | + | |
| 3 | +import java.util.Date; | |
| 4 | +import java.util.UUID; | |
| 5 | + | |
| 6 | +/** | |
| 7 | + * 优惠券详情 | |
| 8 | + * @date: 2017-04-27 11:25:57 | |
| 9 | + */ | |
| 10 | +public class CouponInfo { | |
| 11 | + private String id; | |
| 12 | + | |
| 13 | + /** | |
| 14 | + * 12位优惠券id | |
| 15 | + */ | |
| 16 | + private String sequenceId; | |
| 17 | + | |
| 18 | + /** | |
| 19 | + * 创建时间 | |
| 20 | + */ | |
| 21 | + private Date createDate; | |
| 22 | + | |
| 23 | + /** | |
| 24 | + * 使用时间 | |
| 25 | + */ | |
| 26 | + private Date useDate; | |
| 27 | + | |
| 28 | + /** | |
| 29 | + * 所属用户id | |
| 30 | + */ | |
| 31 | + private String userId; | |
| 32 | + | |
| 33 | + /** | |
| 34 | + * 创建人id | |
| 35 | + */ | |
| 36 | + private String createUserId; | |
| 37 | + | |
| 38 | + /** | |
| 39 | + * 对应模板id | |
| 40 | + */ | |
| 41 | + private String couponTemplateId; | |
| 42 | + | |
| 43 | + /** | |
| 44 | + * 创建的医院id | |
| 45 | + */ | |
| 46 | + private String createHospitalId; | |
| 47 | + | |
| 48 | + /** | |
| 49 | + * 使用优惠券的医院id | |
| 50 | + */ | |
| 51 | + private String usedHospitalId; | |
| 52 | + | |
| 53 | + /** | |
| 54 | + * 状态:1:未使用 2:已使用 -1:禁用 | |
| 55 | + */ | |
| 56 | + private Integer status; | |
| 57 | + | |
| 58 | + /** | |
| 59 | + * 使用优惠券时操作人的id | |
| 60 | + */ | |
| 61 | + private String operatorUseId; | |
| 62 | + | |
| 63 | + public CouponInfo() { | |
| 64 | + id = UUID.randomUUID().toString().replace("-", ""); | |
| 65 | + } | |
| 66 | + | |
| 67 | + public String getId() { | |
| 68 | + return id; | |
| 69 | + } | |
| 70 | + | |
| 71 | + public void setId(String id) { | |
| 72 | + this.id = id; | |
| 73 | + } | |
| 74 | + public String getSequenceId() { | |
| 75 | + return sequenceId; | |
| 76 | + } | |
| 77 | + | |
| 78 | + public void setSequenceId(String sequenceId) { | |
| 79 | + this.sequenceId = sequenceId; | |
| 80 | + } | |
| 81 | + public Date getCreateDate() { | |
| 82 | + return createDate; | |
| 83 | + } | |
| 84 | + | |
| 85 | + public void setCreateDate(Date createDate) { | |
| 86 | + this.createDate = createDate; | |
| 87 | + } | |
| 88 | + public Date getUseDate() { | |
| 89 | + return useDate; | |
| 90 | + } | |
| 91 | + | |
| 92 | + public void setUseDate(Date useDate) { | |
| 93 | + this.useDate = useDate; | |
| 94 | + } | |
| 95 | + public String getUserId() { | |
| 96 | + return userId; | |
| 97 | + } | |
| 98 | + | |
| 99 | + public void setUserId(String userId) { | |
| 100 | + this.userId = userId; | |
| 101 | + } | |
| 102 | + public String getCouponTemplateId() { | |
| 103 | + return couponTemplateId; | |
| 104 | + } | |
| 105 | + | |
| 106 | + public void setCouponTemplateId(String couponTemplateId) { | |
| 107 | + this.couponTemplateId = couponTemplateId; | |
| 108 | + } | |
| 109 | + public String getCreateHospitalId() { | |
| 110 | + return createHospitalId; | |
| 111 | + } | |
| 112 | + | |
| 113 | + public void setCreateHospitalId(String createHospitalId) { | |
| 114 | + this.createHospitalId = createHospitalId; | |
| 115 | + } | |
| 116 | + public String getUsedHospitalId() { | |
| 117 | + return usedHospitalId; | |
| 118 | + } | |
| 119 | + | |
| 120 | + public void setUsedHospitalId(String usedHospitalId) { | |
| 121 | + this.usedHospitalId = usedHospitalId; | |
| 122 | + } | |
| 123 | + public Integer getStatus() { | |
| 124 | + return status; | |
| 125 | + } | |
| 126 | + | |
| 127 | + public String getCreateUserId() { | |
| 128 | + return createUserId; | |
| 129 | + } | |
| 130 | + | |
| 131 | + public void setCreateUserId(String createUserId) { | |
| 132 | + this.createUserId = createUserId; | |
| 133 | + } | |
| 134 | + | |
| 135 | + public void setStatus(Integer status) { | |
| 136 | + this.status = status; | |
| 137 | + } | |
| 138 | + | |
| 139 | + public String getOperatorUseId() { | |
| 140 | + return operatorUseId; | |
| 141 | + } | |
| 142 | + | |
| 143 | + public void setOperatorUseId(String operatorUseId) { | |
| 144 | + this.operatorUseId = operatorUseId; | |
| 145 | + } | |
| 146 | +} |
regional-etl/src/main/java/com/lyms/etl/service/ICouponInfoService.java
View file @
9425372
regional-etl/src/main/java/com/lyms/etl/service/IEtlService.java
View file @
9425372
regional-etl/src/main/java/com/lyms/etl/service/impl/CouponInfoServiceImpl.java
View file @
9425372
| 1 | +package com.lyms.etl.service.impl; | |
| 2 | + | |
| 3 | +import com.lyms.etl.dao.ICouponInfoDao; | |
| 4 | +import com.lyms.etl.model.CouponInfo; | |
| 5 | +import com.lyms.etl.service.ICouponInfoService; | |
| 6 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 7 | +import org.springframework.stereotype.Service; | |
| 8 | + | |
| 9 | +/** | |
| 10 | + * @Author: litao | |
| 11 | + * @Date: 2017/5/3 0003 11:45 | |
| 12 | + * @Version: V1.0 | |
| 13 | + */ | |
| 14 | +@Service | |
| 15 | +public class CouponInfoServiceImpl implements ICouponInfoService { | |
| 16 | + @Autowired | |
| 17 | + private ICouponInfoDao couponInfoDao; | |
| 18 | + | |
| 19 | + @Override | |
| 20 | + public CouponInfo find(String id) { | |
| 21 | + return couponInfoDao.find(id); | |
| 22 | + } | |
| 23 | +} |
regional-etl/src/main/java/com/lyms/etl/service/impl/EtlServiceImpl.java
View file @
9425372
regional-etl/src/main/resources/application.yml
View file @
9425372
| 1 | +server: | |
| 2 | + port: 8081 | |
| 3 | +spring: | |
| 4 | + datasource: | |
| 5 | + url: jdbc:mysql://119.90.57.26:3306/platform | |
| 6 | + username: platform | |
| 7 | + password: platform123 | |
| 8 | + driver-class-name: com.mysql.jdbc.Driver | |
| 9 | + | |
| 10 | + type: com.alibaba.druid.pool.DruidDataSource | |
| 11 | + # 初始化大小,最小,最大 | |
| 12 | + initialSize: 5 | |
| 13 | + minIdle: 5 | |
| 14 | + maxActive: 20 | |
| 15 | + # 配置获取连接等待超时的时间 | |
| 16 | + maxWait: 60000 | |
| 17 | + timeBetweenEvictionRunsMillis: 60000 | |
| 18 | + # 配置一个连接在池中最小生存的时间,单位是毫秒 | |
| 19 | + minEvictableIdleTimeMillis: 300000 | |
| 20 | + validationQuery: SELECT 1 FROM DUAL | |
| 21 | + testWhileIdle: true | |
| 22 | + testOnBorrow: false | |
| 23 | + testOnReturn: false | |
| 24 | + poolPreparedStatements: true | |
| 25 | + maxPoolPreparedStatementPerConnectionSize: 20 | |
| 26 | + # 配置监控统计拦截的filters,去掉后监控界面sql无法统计,'wall'用于防火墙 | |
| 27 | + filters: stat,wall,log4j | |
| 28 | + # 通过connectProperties属性来打开mergeSql功能;慢SQL记录 | |
| 29 | + # 合并多个DruidDataSource的监控数据 | |
| 30 | + useGlobalDataSourceStat: true | |
| 31 | + connectionProperties: | |
| 32 | + druid: | |
| 33 | + stat: | |
| 34 | + mergeSql: true | |
| 35 | + druid: | |
| 36 | + stat: | |
| 37 | + slowSqlMillis: 5000 | |
| 38 | + data: | |
| 39 | + mongodb: | |
| 40 | + host: 119.90.57.26 | |
| 41 | + port: 10001 | |
| 42 | + database: platform | |
| 43 | + username: platform | |
| 44 | + password: platform123 | |
| 45 | +mybatis: | |
| 46 | + typeAliasesPackage: com.lyms.etl.model | |
| 47 | + mapperLocations: classpath:mappers/*.xml |
regional-etl/src/main/resources/mappers/CouponInfoMapper.xml
View file @
9425372
| 1 | +<?xml version="1.0" encoding="UTF-8"?> | |
| 2 | +<!DOCTYPE mapper | |
| 3 | + PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | |
| 4 | + "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | |
| 5 | +<mapper namespace="com.lyms.etl.dao.ICouponInfoDao"> | |
| 6 | + | |
| 7 | + <resultMap type="CouponInfo" id="couponInfoMap"> | |
| 8 | + <result column="id" property="id"/> | |
| 9 | + <result column="sequence_id" property="sequenceId"/> | |
| 10 | + <result column="create_date" property="createDate"/> | |
| 11 | + <result column="use_date" property="useDate"/> | |
| 12 | + <result column="user_id" property="userId"/> | |
| 13 | + <result column="create_user_Id" property="createUserId"/> | |
| 14 | + <result column="coupon_template_id" property="couponTemplateId"/> | |
| 15 | + <result column="create_hospital_id" property="createHospitalId"/> | |
| 16 | + <result column="used_hospital_id" property="usedHospitalId"/> | |
| 17 | + <result column="status" property="status"/> | |
| 18 | + <result column="operator_use_id" property="operatorUseId"/> | |
| 19 | + </resultMap> | |
| 20 | + | |
| 21 | + <sql id="columnList"> | |
| 22 | + sequence_id,create_date,use_date,user_id,create_user_id,coupon_template_id,create_hospital_id,used_hospital_id,status | |
| 23 | + </sql> | |
| 24 | + | |
| 25 | + <select id="find" resultMap="couponInfoMap"> | |
| 26 | + select id, <include refid="columnList" /> from coupon_info where id = #{id} | |
| 27 | + </select> | |
| 28 | + | |
| 29 | +</mapper> |