Commit b65b92c9597f54fc0d60e4462cc17ab1601f3650
1 parent
2ea8cbd09e
Exists in
master
and in
6 other branches
报表数据增加
Showing 4 changed files with 54 additions and 21 deletions
- platform-common/src/main/java/com/lyms/platform/common/result/RespBuilder.java
- platform-operate-api/src/main/java/com/lyms/hospitalapi/pojo/ReportModel.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/ReportServiceImpl.java
- regional-etl/src/main/java/com/lyms/etl/service/impl/CouponServiceImpl.java
platform-common/src/main/java/com/lyms/platform/common/result/RespBuilder.java
View file @
b65b92c
| 1 | 1 | package com.lyms.platform.common.result; |
| 2 | 2 | |
| 3 | -import org.apache.commons.lang3.StringUtils; | |
| 4 | 3 | import org.springframework.util.Assert; |
| 5 | 4 | |
| 6 | 5 | import java.util.HashMap; |
| ... | ... | @@ -48,7 +47,7 @@ |
| 48 | 47 | return resp; |
| 49 | 48 | } |
| 50 | 49 | |
| 51 | - private static Map<String,Object> createMap(Object ... args){ | |
| 50 | + public static Map<String,Object> createMap(Object ... args){ | |
| 52 | 51 | Map<String,Object> map = new HashMap<>(); |
| 53 | 52 | for (int i = 0; i < args.length; i++) { |
| 54 | 53 | String key = args[i++].toString(); |
platform-operate-api/src/main/java/com/lyms/hospitalapi/pojo/ReportModel.java
View file @
b65b92c
| 1 | 1 | package com.lyms.hospitalapi.pojo; |
| 2 | 2 | |
| 3 | +import com.lymsh.platform.reportdata.model.echarts.Series; | |
| 4 | + | |
| 3 | 5 | import java.util.List; |
| 4 | 6 | import java.util.Map; |
| 5 | 7 | |
| 6 | 8 | |
| ... | ... | @@ -20,8 +22,11 @@ |
| 20 | 22 | private List<Map<String, Object>> grid; |
| 21 | 23 | |
| 22 | 24 | /** 其他数据 */ |
| 23 | - private List<Object> data; | |
| 25 | + private Object data; | |
| 24 | 26 | |
| 27 | + /** 封装对应x轴的值 返回到y轴 */ | |
| 28 | + private List<Series> series; | |
| 29 | + | |
| 25 | 30 | private List<Object> doctorInfo; |
| 26 | 31 | |
| 27 | 32 | public List<String> getxAxis() { |
| 28 | 33 | |
| ... | ... | @@ -48,11 +53,11 @@ |
| 48 | 53 | this.grid = grid; |
| 49 | 54 | } |
| 50 | 55 | |
| 51 | - public List<Object> getData() { | |
| 56 | + public Object getData() { | |
| 52 | 57 | return data; |
| 53 | 58 | } |
| 54 | 59 | |
| 55 | - public void setData(List<Object> data) { | |
| 60 | + public void setData(Object data) { | |
| 56 | 61 | this.data = data; |
| 57 | 62 | } |
| 58 | 63 | |
| ... | ... | @@ -62,6 +67,14 @@ |
| 62 | 67 | |
| 63 | 68 | public void setDoctorInfo(List<Object> doctorInfo) { |
| 64 | 69 | this.doctorInfo = doctorInfo; |
| 70 | + } | |
| 71 | + | |
| 72 | + public List<Series> getSeries() { | |
| 73 | + return series; | |
| 74 | + } | |
| 75 | + | |
| 76 | + public void setSeries(List<Series> series) { | |
| 77 | + this.series = series; | |
| 65 | 78 | } |
| 66 | 79 | } |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/ReportServiceImpl.java
View file @
b65b92c
| ... | ... | @@ -16,6 +16,7 @@ |
| 16 | 16 | import com.lyms.platform.operate.web.utils.SystemDataSource; |
| 17 | 17 | import com.lyms.platform.permission.dao.master.CouponMapper; |
| 18 | 18 | import com.lyms.platform.pojo.BasicConfig; |
| 19 | +import com.lymsh.platform.reportdata.model.echarts.Series; | |
| 19 | 20 | import org.apache.commons.lang.StringUtils; |
| 20 | 21 | import org.springframework.beans.factory.annotation.Autowired; |
| 21 | 22 | import org.springframework.data.mongodb.core.MongoTemplate; |
| ... | ... | @@ -258,7 +259,7 @@ |
| 258 | 259 | cnames.put("otherTimes", "≥13次"); |
| 259 | 260 | |
| 260 | 261 | @SuppressWarnings("unchecked") |
| 261 | - List<Map<String, Object>> grid = (List<Map<String, Object>>) ((Map<String, Object>) rest.getData()).get("grid"); | |
| 262 | + List<Map<String, Object>> grid = (List<Map<String, Object>>) ((Map<String, Object>) rest.getData()).get("grid"); | |
| 262 | 263 | List<Map<String,Object>> results = new ArrayList<>(); |
| 263 | 264 | for (Map<String, Object> map : grid) { |
| 264 | 265 | Map<String, Object> result = new LinkedHashMap<>(); |
| ... | ... | @@ -417,6 +418,7 @@ |
| 417 | 418 | |
| 418 | 419 | List<Map<String, Object>> couponReport = couponMapper.findReport(param); /** 优惠券统计详情(发放人数、发放券数、使用人数、使用券数) */ |
| 419 | 420 | List<Map<String, Object>> usedInfo = couponMapper.findUsedInfo(param); /** 优惠券使用详情 */ |
| 421 | + List<String> xAxis = new ArrayList<>(); | |
| 420 | 422 | |
| 421 | 423 | if(org.apache.commons.collections.CollectionUtils.isNotEmpty(couponReport) && |
| 422 | 424 | org.apache.commons.collections.CollectionUtils.isNotEmpty(usedInfo)) { |
| 423 | 425 | |
| 424 | 426 | |
| 425 | 427 | |
| 426 | 428 | |
| ... | ... | @@ -424,27 +426,44 @@ |
| 424 | 426 | for (Map<String, Object> map : couponReport) { |
| 425 | 427 | map.put("province_name", findName(map.get("province_id"))); |
| 426 | 428 | map.put("city_name", findName(map.get("city_id"))); |
| 427 | - map.put("area_name", findName(map.get("area_id"))); | |
| 429 | + | |
| 430 | + String areaName = findName(map.get("area_id")); | |
| 431 | + map.put("area_name", areaName); | |
| 432 | + xAxis.add(areaName); | |
| 428 | 433 | } |
| 429 | 434 | } else{ |
| 430 | 435 | return RespBuilder.buildErro(ResponseCode.DATA_ERROR); |
| 431 | 436 | } |
| 432 | 437 | } |
| 433 | - return RespBuilder.buildSuccess("couponReport", couponReport, "couponReportMap", couponReportMap); | |
| 438 | + | |
| 439 | + ReportModel reportModel = new ReportModel(); | |
| 440 | + reportModel.setxAxis(xAxis); | |
| 441 | + reportModel.setData(Arrays.asList("发放券数", "使用券数")); | |
| 442 | + reportModel.setSeries(createSeries(couponReport)); | |
| 443 | + | |
| 444 | + return RespBuilder.buildSuccess("couponReport", couponReport, "couponReportMap", couponReportMap, "reportModel", reportModel); | |
| 434 | 445 | } |
| 435 | 446 | |
| 447 | + private List<Series> createSeries(List<Map<String, Object>> couponReport) { | |
| 448 | + List<Series> seriesList = new ArrayList<>(); | |
| 449 | + for (Map<String, Object> coupon : couponReport) { | |
| 450 | + Series series = new Series(); | |
| 451 | + series.setName((String) coupon.get("area_name")); | |
| 452 | + series.setType("bar"); | |
| 453 | + series.setData(Arrays.asList(coupon.get("coupon_send_count"), coupon.get("people_send_count"))); | |
| 454 | + seriesList.add(series); | |
| 455 | + } | |
| 456 | + return seriesList; | |
| 457 | + } | |
| 458 | + | |
| 436 | 459 | @Override |
| 437 | 460 | public BaseObjectResponse couponInit(Map<String, Object> param) { |
| 438 | 461 | List<String> hospitalIds = Arrays.asList("216", "245"); /** 模拟根据登陆人id 查询出来的医院 */ |
| 439 | 462 | param.put("hospitalIds", hospitalIds); |
| 440 | 463 | return RespBuilder.buildSuccess("coupons", EnumUtil.toJson(CouponEnums.class, "code", "name"), |
| 441 | - "hTemp", couponMapper.findHospitals(param)); | |
| 464 | + "hTemp", couponMapper.findHospitals(param)); | |
| 442 | 465 | } |
| 443 | 466 | |
| 444 | - public static void main(String[] args) { | |
| 445 | - System.out.println(EnumUtil.toJson(CouponEnums.class, "code", "name")); | |
| 446 | - } | |
| 447 | - | |
| 448 | 467 | private String findName(Object id) { |
| 449 | 468 | if(id != null) { |
| 450 | 469 | BasicConfig basicConfig = mongoTemplate.findById(id, BasicConfig.class); |
| ... | ... | @@ -479,7 +498,7 @@ |
| 479 | 498 | } |
| 480 | 499 | |
| 481 | 500 | if(StringUtils.isNotBlank(hospitalId)) { |
| 482 | - sql.append("AND C.YCY_STSTEM_ID = ? "); | |
| 501 | + sql.append("AND C.YCY_STSTEM_ID = ? "); | |
| 483 | 502 | params.add(hospitalId); |
| 484 | 503 | } |
| 485 | 504 | |
| ... | ... | @@ -520,7 +539,6 @@ |
| 520 | 539 | return sql.toString(); |
| 521 | 540 | } |
| 522 | 541 | |
| 523 | - | |
| 524 | 542 | private List<Map<String, Object>> createGrid(List<Object> peopleList, List<Object> proportionList) { |
| 525 | 543 | List<Map<String, Object>> restList = new ArrayList<>(); |
| 526 | 544 | Map<String, Object> peoples = new LinkedHashMap<>(); |
| ... | ... | @@ -631,8 +649,8 @@ |
| 631 | 649 | sql.append("AND A.IS_CHILDBIRTH = ? "); |
| 632 | 650 | params.add(childBirth); |
| 633 | 651 | } |
| 634 | - | |
| 635 | - | |
| 652 | + | |
| 653 | + | |
| 636 | 654 | if(StringUtils.isNotBlank(hospitalId)) { |
| 637 | 655 | sql.append("AND C.YCY_STSTEM_ID= ? "); |
| 638 | 656 | params.add(hospitalId); |
| ... | ... | @@ -651,7 +669,7 @@ |
| 651 | 669 | } |
| 652 | 670 | |
| 653 | 671 | sql.append("GROUP BY B.EXAMINE_HISTORY_NUM ") |
| 654 | - .append("ORDER BY EXAMINE_HISTORY_NUM"); | |
| 672 | + .append("ORDER BY EXAMINE_HISTORY_NUM"); | |
| 655 | 673 | |
| 656 | 674 | return sql.toString(); |
| 657 | 675 | } |
regional-etl/src/main/java/com/lyms/etl/service/impl/CouponServiceImpl.java
View file @
b65b92c
| ... | ... | @@ -55,7 +55,7 @@ |
| 55 | 55 | } |
| 56 | 56 | batchInsert(couponInfos, 100); |
| 57 | 57 | |
| 58 | - setnx(hospitalIds); | |
| 58 | +// setnx(hospitalIds); | |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | /** |
| ... | ... | @@ -138,8 +138,11 @@ |
| 138 | 138 | HospitalCouponTemplateGroup hospitalCouponTemplateGroup = new HospitalCouponTemplateGroup(); |
| 139 | 139 | hospitalCouponTemplateGroup.setId(UUIDUtil.createId()); |
| 140 | 140 | hospitalCouponTemplateGroup.setHospitalId(hospitalId); |
| 141 | - hospitalCouponTemplateGroup.setCouponTemplateGroupId(couponInfoDao.findHospital(hospitalId).getCouponTemplateGroupId()); | |
| 142 | - couponInfoDao.saveHospitalGroup(hospitalCouponTemplateGroup); | |
| 141 | + HospitalCouponTemplateGroup hospital = couponInfoDao.findHospital(hospitalId); | |
| 142 | + if(hospital != null) { | |
| 143 | + hospitalCouponTemplateGroup.setCouponTemplateGroupId(hospital.getCouponTemplateGroupId()); | |
| 144 | + couponInfoDao.saveHospitalGroup(hospitalCouponTemplateGroup); | |
| 145 | + } | |
| 143 | 146 | } |
| 144 | 147 | } |
| 145 | 148 | } |