Commit 98a72001c95cacf076b92921197c959a327b1057
1 parent
6592f42c3c
Exists in
master
and in
6 other branches
优惠券报表开发
Showing 11 changed files with 123 additions and 97 deletions
- platform-biz-service/src/main/resources/mainOrm/master/CouponMapper.xml
- platform-common/src/main/java/com/lyms/platform/common/result/RespBuilder.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/service/impl/ReportServiceImpl.java
- regional-etl/src/main/java/com/lyms/etl/dao/ICouponInfoDao.java
- regional-etl/src/main/java/com/lyms/etl/datasource/DynamicDataSourceRegister.java
- regional-etl/src/main/java/com/lyms/etl/service/impl/CouponServiceImpl.java
- regional-etl/src/main/resources/application.properties
- regional-etl/src/main/resources/application.yml
- regional-etl/src/main/resources/logback.xml
- regional-etl/src/main/resources/mappers/CouponInfoMapper.xml
platform-biz-service/src/main/resources/mainOrm/master/CouponMapper.xml
View file @
98a7200
| ... | ... | @@ -109,13 +109,13 @@ |
| 109 | 109 | |
| 110 | 110 | <update id="invalid" parameterType="map"> |
| 111 | 111 | update coupon_info a inner join ( |
| 112 | - select a.id | |
| 113 | - from coupon_info a, coupon_template b, coupon_type c | |
| 114 | - where a.coupon_template_id = b.id and b.type_id = c.id and a.status=1 and c.type in | |
| 115 | - <foreach collection="couponTypes" open="(" close=")" separator="," item="type"> | |
| 116 | - #{type} | |
| 117 | - </foreach> | |
| 118 | - and a.user_id = #{personId} | |
| 112 | + select a.id | |
| 113 | + from coupon_info a, coupon_template b, coupon_type c | |
| 114 | + where a.coupon_template_id = b.id and b.type_id = c.id and a.status=1 and c.type in | |
| 115 | + <foreach collection="couponTypes" open="(" close=")" separator="," item="type"> | |
| 116 | + #{type} | |
| 117 | + </foreach> | |
| 118 | + and a.user_id = #{personId} | |
| 119 | 119 | ) b on a.id = b.id set a.status = 3 |
| 120 | 120 | </update> |
| 121 | 121 | |
| 122 | 122 | |
| 123 | 123 | |
| 124 | 124 | |
| 125 | 125 | |
| 126 | 126 | |
| ... | ... | @@ -135,52 +135,52 @@ |
| 135 | 135 | </select> |
| 136 | 136 | |
| 137 | 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 | |
| 138 | + select a.people_send_count, a.coupon_send_count, a.create_hospital_id, b.user_used_count, b.coupon_used_count, c.province_id, c.city_id, c.area_id, c.name | |
| 139 | 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, organization d, hospital_coupon_template_group e | |
| 142 | - where a.status = #{status} and a.used_hospital_id = d.id 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 | - <if test="startDate != null"> | |
| 151 | - and a.use_date >= #{startDate} | |
| 152 | - </if> | |
| 153 | - <if test="endDate != null"> | |
| 154 | - #and a.use_date <![CDATA[<]]>= #{endDate} | |
| 155 | - </if> | |
| 156 | - <if test="provinceId != null and provinceId != ''"> | |
| 157 | - and d.province_id = #{provinceId} | |
| 158 | - </if> | |
| 159 | - <if test="cityId != null and cityId != '' "> | |
| 160 | - and d.city_id = #{cityId} | |
| 161 | - </if> | |
| 162 | - <if test="areaId != null and areaId != ''"> | |
| 163 | - and d.area_id = #{areaId} | |
| 164 | - </if> | |
| 165 | - <if test="tempId != null and tempId != ''"> | |
| 166 | - and e.coupon_template_group_id = #{tempId} | |
| 167 | - </if> | |
| 168 | - and a.used_hospital_id = e.hospital_id | |
| 169 | - group by a.used_hospital_id | |
| 140 | + select count(distinct(a.user_id)) as people_send_count, count(1) as coupon_send_count, a.create_hospital_id | |
| 141 | + from coupon_info a, coupon_template b, coupon_type c, organization d, hospital_coupon_template_group e | |
| 142 | + where a.create_hospital_id = d.id and a.create_hospital_id in | |
| 143 | + <foreach collection="hospitalId" 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="couponType" open="(" close=")" separator="," item="type"> | |
| 148 | + #{type} | |
| 149 | + </foreach> | |
| 150 | + <if test="startDate != null"> | |
| 151 | + and a.create_date >= #{startDate} | |
| 152 | + </if> | |
| 153 | + <if test="endDate != null"> | |
| 154 | + and a.create_date <![CDATA[ <= ]]> #{endDate} | |
| 155 | + </if> | |
| 156 | + <if test="provinceId != null and provinceId != ''"> | |
| 157 | + and d.province_id = #{provinceId} | |
| 158 | + </if> | |
| 159 | + <if test="cityId != null and cityId != '' "> | |
| 160 | + and d.city_id = #{cityId} | |
| 161 | + </if> | |
| 162 | + <if test="areaId != null and areaId != ''"> | |
| 163 | + and d.area_id = #{areaId} | |
| 164 | + </if> | |
| 165 | + <if test="tempId != null and tempId != ''"> | |
| 166 | + and e.coupon_template_group_id = #{tempId} | |
| 167 | + </if> | |
| 168 | + and a.create_hospital_id = e.hospital_id | |
| 169 | + group by a.create_hospital_id | |
| 170 | 170 | ) a, ( |
| 171 | 171 | select count(distinct(a.user_id)) as user_used_count, count(1) as coupon_used_count, a.used_hospital_id |
| 172 | 172 | from coupon_info a, coupon_template b, coupon_type c |
| 173 | - where used_hospital_id in | |
| 174 | - <foreach collection="hospitalIds" open="(" close=")" separator="," item="hid"> | |
| 173 | + where a.used_hospital_id in | |
| 174 | + <foreach collection="hospitalId" open="(" close=")" separator="," item="hid"> | |
| 175 | 175 | #{hid} |
| 176 | 176 | </foreach> |
| 177 | - and status = #{status} and a.coupon_template_id = b.id and b.type_id = c.id and c.type in | |
| 178 | - <foreach collection="couponTypes" open="(" close=")" separator="," item="type"> | |
| 177 | + and a.status = 2 and a.coupon_template_id = b.id and b.type_id = c.id and c.type in | |
| 178 | + <foreach collection="couponType" open="(" close=")" separator="," item="type"> | |
| 179 | 179 | #{type} |
| 180 | 180 | </foreach> |
| 181 | - group by used_hospital_id | |
| 181 | + group by a.used_hospital_id | |
| 182 | 182 | ) b, organization c |
| 183 | - where a.used_hospital_id = b.used_hospital_id and a.used_hospital_id = c.id | |
| 183 | + where a.create_hospital_id = b.used_hospital_id and a.create_hospital_id = c.id | |
| 184 | 184 | </select> |
| 185 | 185 | |
| 186 | 186 | <select id="findUsedInfo" parameterType="map" resultType="map"> |
| 187 | 187 | |
| ... | ... | @@ -189,11 +189,11 @@ |
| 189 | 189 | select a.id, a.coupon_order, b.type, d.hospital_id |
| 190 | 190 | from coupon_template a, coupon_type b, hospital_coupon_template_group d |
| 191 | 191 | where a.group_id = d.coupon_template_group_id and b.id = a.type_id and d.hospital_id in |
| 192 | - <foreach collection="hospitalIds" open="(" close=")" separator="," item="hid"> | |
| 192 | + <foreach collection="hospitalId" open="(" close=")" separator="," item="hid"> | |
| 193 | 193 | #{hid} |
| 194 | 194 | </foreach> |
| 195 | 195 | and b.type in |
| 196 | - <foreach collection="couponTypes" open="(" close=")" separator="," item="type"> | |
| 196 | + <foreach collection="couponType" open="(" close=")" separator="," item="type"> | |
| 197 | 197 | #{type} |
| 198 | 198 | </foreach> |
| 199 | 199 | ) b |
| ... | ... | @@ -209,6 +209,5 @@ |
| 209 | 209 | #{hid} |
| 210 | 210 | </foreach> |
| 211 | 211 | </select> |
| 212 | - | |
| 213 | 212 | </mapper> |
platform-common/src/main/java/com/lyms/platform/common/result/RespBuilder.java
View file @
98a7200
| 1 | 1 | package com.lyms.platform.common.result; |
| 2 | 2 | |
| 3 | 3 | import org.apache.commons.lang3.StringUtils; |
| 4 | +import org.springframework.util.Assert; | |
| 4 | 5 | |
| 5 | 6 | import java.util.HashMap; |
| 6 | 7 | import java.util.Map; |
| 7 | 8 | |
| 8 | 9 | |
| 9 | 10 | |
| ... | ... | @@ -15,21 +16,19 @@ |
| 15 | 16 | return buildSuccess(null); |
| 16 | 17 | } |
| 17 | 18 | |
| 18 | - public static BaseObjectResponse buildSuccess(Object data) { | |
| 19 | + public static BaseObjectResponse buildSuccess(Object ... data) { | |
| 19 | 20 | BaseObjectResponse resp = new BaseObjectResponse(); |
| 20 | - resp.setData(data); | |
| 21 | - return resp; | |
| 22 | - /* BaseObjectResponse resp = new BaseObjectResponse(); | |
| 21 | + | |
| 23 | 22 | if(data != null) { |
| 24 | 23 | Assert.isTrue(data.length == 1 || data.length % 2 == 0, "length必须为偶数"); |
| 25 | 24 | |
| 26 | 25 | if(data.length == 1) { |
| 27 | - resp.setData(data); | |
| 26 | + resp.setData(data[0]); | |
| 28 | 27 | } else { |
| 29 | 28 | resp.setData(createMap(data)); |
| 30 | 29 | } |
| 31 | 30 | } |
| 32 | - return resp;*/ | |
| 31 | + return resp; | |
| 33 | 32 | } |
| 34 | 33 | |
| 35 | 34 | public static BaseObjectResponse buildErro(ResponseCode code) { |
| ... | ... | @@ -60,5 +59,6 @@ |
| 60 | 59 | } |
| 61 | 60 | return map; |
| 62 | 61 | } |
| 62 | + | |
| 63 | 63 | } |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/ReportController.java
View file @
98a7200
| ... | ... | @@ -209,7 +209,7 @@ |
| 209 | 209 | public BaseObjectResponse coupon(HttpServletRequest request, Date startDate, Date endDate, |
| 210 | 210 | String provinceId, String cityId, String areaId, String hospitalId, String tempId, String couponType) { |
| 211 | 211 | Map<String, Object> param = CollectionUtils.createMap("userId", getUserId(request), "startDate", startDate, |
| 212 | - "endDate", endDate, "hospitalIds", hospitalId, "provinceId", provinceId, "cityId", cityId, "areaId", | |
| 212 | + "endDate", endDate, "hospitalId", hospitalId, "provinceId", provinceId, "cityId", cityId, "areaId", | |
| 213 | 213 | areaId, "tempId", tempId, "couponType", couponType); |
| 214 | 214 | return reportService.couponInfo(param); |
| 215 | 215 | } |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/ReportServiceImpl.java
View file @
98a7200
| ... | ... | @@ -407,25 +407,26 @@ |
| 407 | 407 | |
| 408 | 408 | @Override |
| 409 | 409 | public BaseObjectResponse couponInfo(Map<String ,Object> param) { |
| 410 | - List<String> hospitalIds = Arrays.asList("216", "245"); /** 模拟根据登陆人id 查询出来的医院 */ | |
| 411 | - | |
| 412 | - param.put("hospitalIds", CollectionUtils.asList((String) param.get("hospitalIds"))); | |
| 410 | + if(StringUtils.isBlank((String) param.get("hospitalId"))) { | |
| 411 | + param.put("hospitalId", Arrays.asList("216", "245")); /** 模拟根据登陆人id 查询出来的医院 */ | |
| 412 | + } else { | |
| 413 | + param.put("hospitalId", CollectionUtils.asList((String) param.get("hospitalId"))); | |
| 414 | + } | |
| 413 | 415 | param.put("status", 2); |
| 414 | - param.put("couponTypes", CollectionUtils.asList((String) param.get("couponTypes"))); | |
| 416 | + param.put("couponType", CollectionUtils.asList((String) param.get("couponType"))); | |
| 415 | 417 | |
| 416 | 418 | List<Map<String, Object>> couponReport = couponMapper.findReport(param); /** 优惠券统计详情(发放人数、发放券数、使用人数、使用券数) */ |
| 417 | 419 | List<Map<String, Object>> usedInfo = couponMapper.findUsedInfo(param); /** 优惠券使用详情 */ |
| 418 | 420 | |
| 419 | 421 | if(org.apache.commons.collections.CollectionUtils.isNotEmpty(couponReport) && |
| 420 | 422 | org.apache.commons.collections.CollectionUtils.isNotEmpty(usedInfo)) { |
| 421 | - if(CollectionUtils.putAll(couponReport, usedInfo, "used_hospital_id", "used_hospital_id")) { | |
| 422 | - | |
| 423 | + if(CollectionUtils.putAll(couponReport, usedInfo, "create_hospital_id", "used_hospital_id")) { | |
| 423 | 424 | for (Map<String, Object> map : couponReport) { |
| 424 | 425 | map.put("province_name", findName(map.get("province_id"))); |
| 425 | 426 | map.put("city_name", findName(map.get("city_id"))); |
| 426 | 427 | map.put("area_name", findName(map.get("area_id"))); |
| 427 | 428 | } |
| 428 | -// return RespBuilder.buildSuccess("couponReport", couponReport, "couponReportMap", couponReportMap); | |
| 429 | + return RespBuilder.buildSuccess("couponReport", couponReport, "couponReportMap", couponReportMap); | |
| 429 | 430 | } else{ |
| 430 | 431 | return RespBuilder.buildErro(ResponseCode.DATA_ERROR); |
| 431 | 432 | } |
| ... | ... | @@ -437,9 +438,8 @@ |
| 437 | 438 | public BaseObjectResponse couponInit(Map<String, Object> param) { |
| 438 | 439 | List<String> hospitalIds = Arrays.asList("216", "245"); /** 模拟根据登陆人id 查询出来的医院 */ |
| 439 | 440 | param.put("hospitalIds", hospitalIds); |
| 440 | - /* return RespBuilder.buildSuccess("coupons", EnumUtil.toJson(CouponEnums.class, "code", "name"), | |
| 441 | - "hTemp", couponMapper.findHospitals(param));*/ | |
| 442 | - return RespBuilder.buildSuccess(); | |
| 441 | + return RespBuilder.buildSuccess("coupons", EnumUtil.toJson(CouponEnums.class, "code", "name"), | |
| 442 | + "hTemp", couponMapper.findHospitals(param)); | |
| 443 | 443 | } |
| 444 | 444 | |
| 445 | 445 | public static void main(String[] args) { |
regional-etl/src/main/java/com/lyms/etl/dao/ICouponInfoDao.java
View file @
98a7200
| ... | ... | @@ -4,6 +4,7 @@ |
| 4 | 4 | import com.lyms.etl.model.HospitalCouponTemplateGroup; |
| 5 | 5 | |
| 6 | 6 | import java.util.List; |
| 7 | +import java.util.Map; | |
| 7 | 8 | |
| 8 | 9 | /** |
| 9 | 10 | * @Author: litao |
| ... | ... | @@ -16,7 +17,7 @@ |
| 16 | 17 | |
| 17 | 18 | void save(CouponInfo couponInfo); |
| 18 | 19 | |
| 19 | - String findTempId(Integer number); | |
| 20 | + String findTempId(Map<String, Object> number); | |
| 20 | 21 | |
| 21 | 22 | HospitalCouponTemplateGroup findHospital(String hospitalId); |
| 22 | 23 |
regional-etl/src/main/java/com/lyms/etl/datasource/DynamicDataSourceRegister.java
View file @
98a7200
| ... | ... | @@ -32,40 +32,43 @@ |
| 32 | 32 | @Override |
| 33 | 33 | public void setEnvironment(Environment environment) { |
| 34 | 34 | initDefaultDataSource(environment); |
| 35 | - initCustomDataSources(environment); | |
| 35 | +// initCustomDataSources(environment); | |
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | /** |
| 39 | - * 初始化多数据源 | |
| 39 | + * 初始化主数据源(默认数据源) | |
| 40 | 40 | * @param environment |
| 41 | 41 | */ |
| 42 | - private void initCustomDataSources(Environment environment) { | |
| 42 | + @ConfigurationProperties | |
| 43 | + private void initDefaultDataSource(Environment environment) { | |
| 43 | 44 | try { |
| 44 | 45 | RelaxedPropertyResolver propertyResolver = new RelaxedPropertyResolver(environment, "spring.datasource"); |
| 45 | 46 | |
| 46 | - Map<String, Object> connProperties = propertyResolver.getSubProperties("."); | |
| 47 | - System.err.println("connProperties>>> " + connProperties); | |
| 48 | - List<String> customs = (List<String>) connProperties.get("customs"); | |
| 47 | + Map<String, Object> connProperties = propertyResolver.getSubProperties(".default."); | |
| 48 | + System.err.println("connProperties = [" + connProperties + "]"); | |
| 49 | + defaultDataSource = DruidDataSourceFactory.createDataSource(connProperties); | |
| 49 | 50 | } catch (Exception e) { |
| 50 | - LOG.error("初始化多数据源失败:", e.fillInStackTrace()); | |
| 51 | + LOG.error("初始化主数据源出错:", e.fillInStackTrace()); | |
| 51 | 52 | } |
| 52 | 53 | } |
| 53 | 54 | |
| 55 | + | |
| 54 | 56 | /** |
| 55 | - * 初始化主数据源(默认数据源) | |
| 57 | + * 初始化多数据源 | |
| 56 | 58 | * @param environment |
| 57 | 59 | */ |
| 58 | - @ConfigurationProperties | |
| 59 | - private void initDefaultDataSource(Environment environment) { | |
| 60 | + private void initCustomDataSources(Environment environment) { | |
| 60 | 61 | try { |
| 61 | 62 | RelaxedPropertyResolver propertyResolver = new RelaxedPropertyResolver(environment, "spring.datasource"); |
| 62 | 63 | |
| 63 | - Map<String, Object> connProperties = propertyResolver.getSubProperties("."); | |
| 64 | - defaultDataSource = DruidDataSourceFactory.createDataSource(connProperties); | |
| 64 | + Map<String, Object> connProperties = propertyResolver.getSubProperties(".default."); | |
| 65 | + System.err.println("connProperties>>> " + connProperties); | |
| 66 | + List<String> customs = (List<String>) connProperties.get("customs"); | |
| 65 | 67 | } catch (Exception e) { |
| 66 | - LOG.error("初始化主数据源出错:", e.fillInStackTrace()); | |
| 68 | + LOG.error("初始化多数据源失败:", e.fillInStackTrace()); | |
| 67 | 69 | } |
| 68 | 70 | } |
| 71 | + | |
| 69 | 72 | |
| 70 | 73 | @Override |
| 71 | 74 | public void registerBeanDefinitions(AnnotationMetadata annotationMetadata, BeanDefinitionRegistry beanDefinitionRegistry) { |
regional-etl/src/main/java/com/lyms/etl/service/impl/CouponServiceImpl.java
View file @
98a7200
| ... | ... | @@ -10,15 +10,15 @@ |
| 10 | 10 | import com.lyms.etl.service.ICouponInfoService; |
| 11 | 11 | import com.lyms.etl.util.UUIDUtil; |
| 12 | 12 | import org.apache.commons.collections4.CollectionUtils; |
| 13 | +import org.apache.commons.lang3.StringUtils; | |
| 14 | +import org.slf4j.Logger; | |
| 15 | +import org.slf4j.LoggerFactory; | |
| 13 | 16 | import org.springframework.beans.factory.annotation.Autowired; |
| 14 | 17 | import org.springframework.context.annotation.Profile; |
| 15 | 18 | import org.springframework.stereotype.Service; |
| 16 | 19 | import org.springframework.transaction.annotation.Transactional; |
| 17 | 20 | |
| 18 | -import java.util.ArrayList; | |
| 19 | -import java.util.HashSet; | |
| 20 | -import java.util.Set; | |
| 21 | -import java.util.List; | |
| 21 | +import java.util.*; | |
| 22 | 22 | |
| 23 | 23 | /** |
| 24 | 24 | * @Author: litao |
| ... | ... | @@ -28,6 +28,9 @@ |
| 28 | 28 | @Profile("coupon") |
| 29 | 29 | @Service |
| 30 | 30 | public class CouponServiceImpl implements ICouponInfoService { |
| 31 | + | |
| 32 | + private Logger LOG = LoggerFactory.getLogger(CouponServiceImpl.class); | |
| 33 | + | |
| 31 | 34 | @Autowired |
| 32 | 35 | private ICouponInfoDao couponInfoDao; |
| 33 | 36 | |
| 34 | 37 | |
| ... | ... | @@ -42,8 +45,13 @@ |
| 42 | 45 | List<CouponInfo> couponInfos = new ArrayList<>(); |
| 43 | 46 | Set<String> hospitalIds = new HashSet<>(); |
| 44 | 47 | List<PatientCheckTicket> patientCheckTickets = patientCheckTicketRepository.findAll(); |
| 48 | + LOG.info("本次共需要导入 [{}] 条数据", patientCheckTickets.size()); | |
| 45 | 49 | for (PatientCheckTicket checkTicket : patientCheckTickets) { |
| 46 | - couponInfos.add(createCouponInfo(checkTicket, hospitalIds)); | |
| 50 | + CouponInfo couponInfo = createCouponInfo(checkTicket, hospitalIds); | |
| 51 | + if(couponInfo != null) { | |
| 52 | + couponInfos.add(couponInfo); | |
| 53 | + LOG.info("正在创建第 [{}] 个优惠券", couponInfos.size()); | |
| 54 | + } | |
| 47 | 55 | } |
| 48 | 56 | batchInsert(couponInfos, 100); |
| 49 | 57 | |
| ... | ... | @@ -63,7 +71,7 @@ |
| 63 | 71 | couponInfo.setCreateDate(checkTicket.getCreated()); |
| 64 | 72 | couponInfo.setUseDate(checkTicket.getConsumeDate()); |
| 65 | 73 | couponInfo.setUserId(checkTicket.getPid()); |
| 66 | - couponInfo.setCouponTemplateId(parseSuffix(checkTicket.getId())); | |
| 74 | + couponInfo.setCouponTemplateId(parseSuffix(checkTicket.getId(), checkTicket.getHospitalId())); | |
| 67 | 75 | couponInfo.setCreateHospitalId(checkTicket.getHospitalId()); |
| 68 | 76 | couponInfo.setUsedHospitalId(checkTicket.getConsumeHospitalId()); |
| 69 | 77 | couponInfo.setStatus(checkTicket.getStatus()); |
| ... | ... | @@ -74,6 +82,9 @@ |
| 74 | 82 | } |
| 75 | 83 | hospitalIds.add(checkTicket.getHospitalId()); |
| 76 | 84 | |
| 85 | + if(StringUtils.isBlank(couponInfo.getCouponTemplateId())) { | |
| 86 | + return null; | |
| 87 | + } | |
| 77 | 88 | return couponInfo; |
| 78 | 89 | } |
| 79 | 90 | |
| 80 | 91 | |
| ... | ... | @@ -83,11 +94,13 @@ |
| 83 | 94 | * @param size |
| 84 | 95 | */ |
| 85 | 96 | private void batchInsert(List<CouponInfo> couponInfos, Integer size) { |
| 97 | + LOG.info("开始导入数据, 共 [{}] 条: ", couponInfos.size()); | |
| 86 | 98 | List<CouponInfo> commitList = new ArrayList<>(); |
| 87 | 99 | for (int i = 0; i < couponInfos.size(); i++) { |
| 88 | 100 | commitList.add(couponInfos.get(i)); |
| 89 | 101 | |
| 90 | 102 | if(i != 0 && commitList.size() % size == 0) { |
| 103 | + LOG.info("插入第 [{}] 条数据, 共 [{}] 条: ", i, couponInfos.size()); | |
| 91 | 104 | couponInfoDao.batchSave(commitList); |
| 92 | 105 | commitList.clear(); |
| 93 | 106 | } |
| 94 | 107 | |
| ... | ... | @@ -107,9 +120,12 @@ |
| 107 | 120 | return hospital == null ? false : true; |
| 108 | 121 | } |
| 109 | 122 | |
| 110 | - private String parseSuffix(String id) { | |
| 123 | + private String parseSuffix(String id, String hospitalId) { | |
| 111 | 124 | Integer number = Integer.parseInt(id.substring(id.length() - 1, id.length())); |
| 112 | - return couponInfoDao.findTempId(number); | |
| 125 | + Map<String, Object> map = new HashMap<>(); | |
| 126 | + map.put("number", number); | |
| 127 | + map.put("hospitalId", hospitalId); | |
| 128 | + return couponInfoDao.findTempId(map); | |
| 113 | 129 | } |
| 114 | 130 | |
| 115 | 131 | /** |
| ... | ... | @@ -122,7 +138,7 @@ |
| 122 | 138 | HospitalCouponTemplateGroup hospitalCouponTemplateGroup = new HospitalCouponTemplateGroup(); |
| 123 | 139 | hospitalCouponTemplateGroup.setId(UUIDUtil.createId()); |
| 124 | 140 | hospitalCouponTemplateGroup.setHospitalId(hospitalId); |
| 125 | - hospitalCouponTemplateGroup.setCouponTemplateGroupId("5150e962-2af9-11e7-9daf-8dc94911792e"); | |
| 141 | + hospitalCouponTemplateGroup.setCouponTemplateGroupId(couponInfoDao.findHospital(hospitalId).getCouponTemplateGroupId()); | |
| 126 | 142 | couponInfoDao.saveHospitalGroup(hospitalCouponTemplateGroup); |
| 127 | 143 | } |
| 128 | 144 | } |
regional-etl/src/main/resources/application.properties
View file @
98a7200
regional-etl/src/main/resources/application.yml
View file @
98a7200
| ... | ... | @@ -2,11 +2,19 @@ |
| 2 | 2 | datasource: |
| 3 | 3 | url: jdbc:mysql://119.90.57.26:3306/platform |
| 4 | 4 | username: platform |
| 5 | - password: platform123 | |
| 5 | + password: platform123 | |
| 6 | 6 | driver-class-name: com.mysql.jdbc.Driver |
| 7 | 7 | # 必须配置为字符类型 @see com.alibaba.druid.pool.DruidDataSourceFactory > value = (String)properties.get("init"); |
| 8 | 8 | init: "true" |
| 9 | 9 | |
| 10 | + default: | |
| 11 | + url: jdbc:mysql://119.90.57.26:3306/platform | |
| 12 | + username: platform | |
| 13 | + password: platform123 | |
| 14 | + driver-class-name: com.mysql.jdbc.Driver | |
| 15 | + # 必须配置为字符类型 @see com.alibaba.druid.pool.DruidDataSourceFactory > value = (String)properties.get("init"); | |
| 16 | + init: "true" | |
| 17 | + | |
| 10 | 18 | customs: |
| 11 | 19 | - ds1 |
| 12 | 20 | - ds2 |
| ... | ... | @@ -18,8 +26,6 @@ |
| 18 | 26 | database: platform |
| 19 | 27 | username: platform |
| 20 | 28 | password: platform123 |
| 21 | - profiles: | |
| 22 | - active: coupon | |
| 23 | 29 | server: |
| 24 | 30 | port: 8888 |
regional-etl/src/main/resources/logback.xml
View file @
98a7200
| ... | ... | @@ -18,8 +18,8 @@ |
| 18 | 18 | </encoder> |
| 19 | 19 | </appender> |
| 20 | 20 | <appender name="INFO" class="ch.qos.logback.core.rolling.RollingFileAppender"> |
| 21 | - <filter class="ch.qos.logback.classic.filter.LevelFilter"> | |
| 22 | - <level>INFO</level> | |
| 21 | + <filter class="ch.qos.logback.classic.filter.LevelFilter"> | |
| 22 | + <level>INFO</level> | |
| 23 | 23 | <onMatch>NEUTRAL</onMatch> |
| 24 | 24 | <onMismatch>DENY</onMismatch> |
| 25 | 25 | </filter> |
| ... | ... | @@ -146,7 +146,7 @@ |
| 146 | 146 | </filter> |
| 147 | 147 | </appender> |
| 148 | 148 | <appender name="INFO_CONSOLE" class="ch.qos.logback.core.ConsoleAppender"> |
| 149 | - <target>System.out</target> | |
| 149 | + <target>System.err</target> | |
| 150 | 150 | <encoder> |
| 151 | 151 | <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern> |
| 152 | 152 | </encoder> |
regional-etl/src/main/resources/mappers/CouponInfoMapper.xml
View file @
98a7200
| ... | ... | @@ -36,10 +36,11 @@ |
| 36 | 36 | insert into coupon_info(id, <include refid="columnList" />) values(#{id},#{sequenceId},#{createDate},#{useDate},#{userId},#{createUserId},#{couponTemplateId},#{createHospitalId},#{usedHospitalId},#{status}) |
| 37 | 37 | </insert> |
| 38 | 38 | |
| 39 | - <select id="findTempId" parameterType="integer" resultType="string"> | |
| 39 | + <select id="findTempId" parameterType="map" resultType="string"> | |
| 40 | 40 | SELECT a.id FROM |
| 41 | - coupon_template a, coupon_type b | |
| 42 | - WHERE a.type_id = b.id and b.type = 2 and a.coupon_order = #{number} | |
| 41 | + coupon_template a, coupon_type b, hospital_coupon_template_group c | |
| 42 | + WHERE a.type_id = b.id and b.type = 2 and a.coupon_order = #{number} and c.hospital_id = #{hospitalId} and c.coupon_template_group_id = a.group_id | |
| 43 | + and a.group_id = b.template_group_id | |
| 43 | 44 | order by a.coupon_order |
| 44 | 45 | </select> |
| 45 | 46 |