Commit 249f93883cfe47a2835143da160399aeb6e0de38

Authored by litao
1 parent e3d9d9a5ac

产检医生统计、导出

Showing 5 changed files with 268 additions and 11 deletions

platform-operate-api/src/main/java/com/lyms/hospitalapi/pojo/ReportModel.java View file @ 249f938
  1 +package com.lyms.hospitalapi.pojo;
  2 +
  3 +import java.util.List;
  4 +import java.util.Map;
  5 +
  6 +/**
  7 + * 报表数据
  8 + * @Author: litao
  9 + * @Date: 2017/4/21 0021 9:42
  10 + * @Version: V1.0
  11 + */
  12 +public class ReportModel {
  13 + /** x轴数据 */
  14 + private List<String> xAxis;
  15 +
  16 + /** y轴数据 */
  17 + private List<String> yAxis;
  18 +
  19 + /** 数据列表 */
  20 + private List<Map<String, Object>> grid;
  21 +
  22 + /** 其他数据 */
  23 + private List<Object> data;
  24 +
  25 + private List<Map<String, List<Object>>> doctorInfo;
  26 +
  27 + public List<String> getxAxis() {
  28 + return xAxis;
  29 + }
  30 +
  31 + public void setxAxis(List<String> xAxis) {
  32 + this.xAxis = xAxis;
  33 + }
  34 +
  35 + public List<String> getyAxis() {
  36 + return yAxis;
  37 + }
  38 +
  39 + public void setyAxis(List<String> yAxis) {
  40 + this.yAxis = yAxis;
  41 + }
  42 +
  43 + public List<Map<String, Object>> getGrid() {
  44 + return grid;
  45 + }
  46 +
  47 + public void setGrid(List<Map<String, Object>> grid) {
  48 + this.grid = grid;
  49 + }
  50 +
  51 + public List<Object> getData() {
  52 + return data;
  53 + }
  54 +
  55 + public void setData(List<Object> data) {
  56 + this.data = data;
  57 + }
  58 +
  59 + public List<Map<String, List<Object>>> getDoctorInfo() {
  60 + return doctorInfo;
  61 + }
  62 +
  63 + public void setDoctorInfo(List<Map<String, List<Object>>> doctorInfo) {
  64 + this.doctorInfo = doctorInfo;
  65 + }
  66 +}
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/ReportController.java View file @ 249f938
... ... @@ -9,7 +9,7 @@
9 9 import org.springframework.web.bind.annotation.RequestMethod;
10 10 import org.springframework.web.bind.annotation.ResponseBody;
11 11  
12   -import java.util.Date;
  12 +import javax.servlet.http.HttpServletResponse;
13 13  
14 14 /**
15 15 * @Author: litao
16 16  
... ... @@ -39,7 +39,22 @@
39 39 return reportService.areaCountFacade(startDate, endDate, startWeek, endWeek, childBirth);
40 40 }
41 41  
  42 +
42 43 /**
  44 + * 产检次数分布统计 excel 导出
  45 + * @param startDate
  46 + * @param endDate
  47 + * @param startWeek
  48 + * @param endWeek
  49 + * @param childBirth
  50 + */
  51 + @RequestMapping(value = "/check/export", method = RequestMethod.GET)
  52 + public void exportCheck(String startDate, String endDate, Integer startWeek, Integer endWeek, Integer childBirth, HttpServletResponse resp) {
  53 + reportService.exportCheck(startDate, endDate, startWeek, endWeek, childBirth, resp);
  54 +
  55 + }
  56 +
  57 + /**
43 58 * 孕产妇明细查看
44 59 * @param startDate 建档开始时间
45 60 * @param endDate 建档结束时间
46 61  
... ... @@ -66,9 +81,9 @@
66 81 @RequestMapping(method = RequestMethod.GET,value = "/doctor")
67 82 @ResponseBody
68 83 public BaseObjectResponse doctorMedical(String startDate, String endDate, Integer childBirth) {
69   - return reportService.doctorMedical
70   - (startDate, endDate, childBirth);
  84 + return reportService.doctorMedical(startDate, endDate, childBirth);
71 85 }
  86 +
72 87  
73 88 }
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/IReportService.java View file @ 249f938
... ... @@ -2,6 +2,8 @@
2 2  
3 3 import com.lyms.platform.common.result.BaseObjectResponse;
4 4  
  5 +import javax.servlet.http.HttpServletResponse;
  6 +
5 7 /**
6 8 * 报表service
7 9 * @Author: litao
... ... @@ -42,5 +44,16 @@
42 44 * @return
43 45 */
44 46 BaseObjectResponse checkInfo(Integer childBirth, String startDate, String endDate, Integer startWeek, Integer endWeek, Integer number, String name);
  47 +
  48 + /**
  49 + * 导出Excel
  50 + * @param startDate
  51 + * @param endDate
  52 + * @param startWeek
  53 + * @param endWeek
  54 + * @param childBirth
  55 + * @param resp
  56 + */
  57 + void exportCheck(String startDate, String endDate, Integer startWeek, Integer endWeek, Integer childBirth, HttpServletResponse resp);
45 58 }
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/ReportServiceImpl.java View file @ 249f938
1 1 package com.lyms.platform.operate.web.service.impl;
2 2  
  3 +import com.lyms.hospitalapi.pojo.ReportModel;
3 4 import com.lyms.platform.common.result.BaseObjectResponse;
4 5 import com.lyms.platform.operate.web.dao.IReportDao;
5 6 import com.lyms.platform.operate.web.service.IReportService;
6 7 import com.lyms.platform.operate.web.utils.MathUtil;
  8 +import com.lyms.platform.operate.web.utils.ResponseUtil;
7 9 import org.apache.commons.lang.StringUtils;
8 10 import org.springframework.beans.factory.annotation.Autowired;
9 11 import org.springframework.stereotype.Service;
10 12  
  13 +import javax.servlet.http.HttpServletResponse;
11 14 import java.util.*;
12 15  
13 16 /**
14 17  
15 18  
16 19  
17 20  
18 21  
19 22  
... ... @@ -40,21 +43,155 @@
40 43 @Override
41 44 public BaseObjectResponse doctorMedical(String startDate, String endDate, Integer childBirth) {
42 45 BaseObjectResponse rest = new BaseObjectResponse();
43   - Map<String, Object> restMap = new HashMap<>();
  46 + ReportModel reportModel = new ReportModel();
44 47 List<Object> params = new ArrayList<>();
  48 + List<Object> doctorNames = new ArrayList<>();
  49 + List<Map<String, List<Object>>> doctorInfo = new ArrayList<>();
  50 +
45 51 List<Map<String, Object>> restList = reportDao.findList(getDoctorMedicalSql(startDate, endDate, childBirth, params), params);
46   - return null;
  52 +
  53 + List<Map<String, Object>> grid = createDoctorGrid(restList, doctorNames, doctorInfo);
  54 +
  55 + reportModel.setGrid(grid); /** 表格数据 */
  56 + reportModel.setData(doctorNames); /** 医生数据 */
  57 + reportModel.setDoctorInfo(doctorInfo); /** 医生数据详情 */
  58 + reportModel.setxAxis(Arrays.asList("产检人数", "两次(含)以上人数", "五次(含)以上人数"));
  59 + rest.setData(reportModel);
  60 + return rest;
47 61 }
48 62  
  63 + private List<Map<String,Object>> createDoctorGrid(List<Map<String, Object>> restList, List<Object> doctorNames, List<Map<String, List<Object>>> doctorInfo) {
  64 + List<Map<String,Object>> grid = new ArrayList<>();
  65 +// List<Object> inspectPeoples = new ArrayList<>(); /** 产检人数集合 */
  66 +// List<Object> twicePeoples = new ArrayList<>(); /** 产检人数集合 */
  67 +// List<Object> fiveTimesPeoples = new ArrayList<>(); /** 产检人数集合 */
  68 + for (Map<String, Object> map : restList) {
  69 + Map<String, Object> data = new HashMap<>();
  70 + Map<String,List<Object>> doctor = new HashMap<>();
  71 + List<Object> doctorList = new ArrayList<>();
  72 + Object doctorName = map.get("DOCTOR_NAME");
  73 + if(doctorName != null && StringUtils.isNotBlank(doctorName.toString())) {
  74 + data.put("doctorName", doctorName); /** 医生名称 */
  75 + } else {
  76 + data.put("doctorName", "");
  77 + }
  78 + doctorNames.add(doctorName);
  79 +
  80 + Object inspectTime = map.get("CJ_RC");
  81 + if(inspectTime != null && StringUtils.isNotBlank(inspectTime.toString())) {
  82 + data.put("inspectTime", inspectTime); /** 产检人次 */
  83 + }
  84 +
  85 + Object inspectPeople = map.get("CJ_RS");
  86 + if(inspectPeople != null && StringUtils.isNotBlank(inspectPeople.toString())) {
  87 + data.put("inspectPeople", inspectPeople); /** 产检人数 */
  88 + }
  89 +
  90 + Object twice = map.get("LIANGCI_RS");
  91 + if(twice != null && StringUtils.isNotBlank(twice.toString())) {
  92 + data.put("twice", twice); /** 两次以上人数 */
  93 + }
  94 +
  95 + Object fiveTimes = map.get("WUCI_RS");
  96 + if(fiveTimes != null && StringUtils.isNotBlank(fiveTimes.toString())) {
  97 + data.put("fiveTimes", fiveTimes); /** 五次以上人数 */
  98 + }
  99 + grid.add(data);
  100 +
  101 + doctorList.add(inspectPeople);
  102 + doctorList.add(twice);
  103 + doctorList.add(fiveTimes);
  104 + doctor.put(doctorName + "", doctorList);
  105 + doctorInfo.add(doctor);
  106 + }
  107 +
  108 + /** 把总计放到第一位 */
  109 + for (Map<String, Object> map : grid) {
  110 + if(map.containsKey("doctorName") && map.get("doctorName").toString().equals("总计")) {
  111 + grid.remove(map);
  112 + grid.add(0, map);
  113 + }
  114 + }
  115 +
  116 + /** 处理比例、产检人数统计 */
  117 + int i = 0;
  118 + for (Map<String, Object> map : grid) {
  119 + map.put("id", i++);
  120 +
  121 + if(map.containsKey("inspectPeople")) {
  122 +// inspectPeoples.add(map.get("inspectPeople"));
  123 + }
  124 +
  125 + if(map.containsKey("twice")) { /** 两次以上比例 */
  126 + map.put("twiceProportion", MathUtil.getProportion(map.get("twice"), map.get("inspectPeople")));
  127 +// twicePeoples.add(map.get("twice"));
  128 + }
  129 +
  130 + if(map.containsKey("fiveTimes")) { /** 五次以上比例 */
  131 + map.put("fiveTimeProportion", MathUtil.getProportion(map.get("fiveTimes"), map.get("inspectPeople")));
  132 +// fiveTimesPeoples.add(map.get("fiveTimes"));
  133 + }
  134 + }
  135 +
  136 +// peoples.put("fiveTimesPeoples", fiveTimesPeoples);
  137 +// peoples.put("twicePeoples", twicePeoples);
  138 +// peoples.put("inspectPeoples", inspectPeoples );
  139 + return grid;
  140 + }
  141 +
49 142 @Override
50 143 public BaseObjectResponse checkInfo(Integer childBirth, String startDate, String endDate, Integer startWeek, Integer endWeek, Integer number, String name) {
51 144 return null;
52 145 }
53 146  
  147 + @Override
  148 + public void exportCheck(String startDate, String endDate, Integer startWeek, Integer endWeek, Integer childBirth, HttpServletResponse resp) {
  149 + BaseObjectResponse rest = areaCountFacade(startDate, endDate, startWeek, endWeek, childBirth);
  150 + Map<String, String> cnames = new LinkedHashMap<>();
  151 + cnames.put("desc", "产检人数");
  152 + cnames.put("count", "总计");
  153 + cnames.put("once", "1次");
  154 + cnames.put("twice", "2次");
  155 + cnames.put("threeTimes", "3次");
  156 + cnames.put("fourTimes", "4次");
  157 + cnames.put("fiveTimes", "5次");
  158 + cnames.put("sixTimes", "6次");
  159 + cnames.put("sevenTimes", "7次");
  160 + cnames.put("eightTimes", "8次");
  161 + cnames.put("nineTimes", "9次");
  162 + cnames.put("tenTimes", "10次");
  163 + cnames.put("elevenTimes", "11次");
  164 + cnames.put("twelveTimes", "12次");
  165 + cnames.put("otherTimes", "≥13次");
54 166  
  167 + List<Map<String, Object>> grid = (List<Map<String, Object>>) ((Map<String, Object>) rest.getData()).get("grid");
  168 + List<Map<String,Object>> results = new ArrayList<>();
  169 + for (Map<String, Object> map : grid) {
  170 + Map<String, Object> result = new LinkedHashMap<>();
  171 + result.put("desc", map.get("desc"));
  172 + result.put("count", map.get("count"));
  173 + result.put("once", map.get("once"));
  174 + result.put("twice", map.get("twice"));
  175 + result.put("threeTimes", map.get("threeTimes"));
  176 + result.put("fourTimes", map.get("fourTimes"));
  177 + result.put("fiveTimes", map.get("fiveTimes"));
  178 + result.put("sixTimes", map.get("sixTimes"));
  179 + result.put("sevenTimes", map.get("sevenTimes"));
  180 + result.put("eightTimes", map.get("eightTimes"));
  181 + result.put("nineTimes", map.get("nineTimes"));
  182 + result.put("tenTimes", map.get("tenTimes"));
  183 + result.put("elevenTimes", map.get("elevenTimes"));
  184 + result.put("twelveTimes", map.get("twelveTimes"));
  185 + result.put("otherTimes", map.get("otherTimes"));
  186 + results.add(result);
  187 + }
  188 + ResponseUtil.responseExcel(cnames,results, resp);
  189 + }
  190 +
  191 +
55 192 private List<Map<String, Object>> createGrid(List<Object> peopleList, List<Object> proportionList) {
56 193 List<Map<String, Object>> restList = new ArrayList<>();
57   - Map<String, Object> peoples = new HashMap<>();
  194 + Map<String, Object> peoples = new LinkedHashMap<>();
58 195 peoples.put("desc", peopleList.get(0)); /** 产检人数 */
59 196 peoples.put("count", peopleList.get(1));/** 总计 */
60 197 peoples.put("once", peopleList.get(2));
61 198  
... ... @@ -69,9 +206,10 @@
69 206 peoples.put("tenTimes", peopleList.get(11));
70 207 peoples.put("elevenTimes", peopleList.get(12));
71 208 peoples.put("twelveTimes", peopleList.get(13));
  209 + peoples.put("otherTimes", peopleList.get(14));
72 210 restList.add(peoples);
73 211  
74   - Map<String, Object> proportion = new HashMap<>();
  212 + Map<String, Object> proportion = new LinkedHashMap<>();
75 213 proportion.put("desc", proportionList.get(0)); /** 占比 */
76 214 proportion.put("count", proportionList.get(1));/** 总计 */
77 215 proportion.put("once", proportionList.get(2));
... ... @@ -86,6 +224,7 @@
86 224 proportion.put("tenTimes", proportionList.get(11));
87 225 proportion.put("elevenTimes", proportionList.get(12));
88 226 proportion.put("twelveTimes", proportionList.get(13));
  227 + proportion.put("otherTimes", proportionList.get(13));
89 228 restList.add(proportion);
90 229 return restList;
91 230 }
... ... @@ -95,8 +234,8 @@
95 234 proportions.add("占比");
96 235 int countPeople = Integer.parseInt(peopleList.get(1).toString());
97 236 proportions.add("100%");
98   - for (int i = 1; i < peopleList.size(); i++) {
99   - proportions.add(MathUtil.doubleFormat(Double.parseDouble(MathUtil.division(Integer.valueOf(peopleList.get(i).toString()) * 100, countPeople))) + "%");
  237 + for (int i = 2; i < peopleList.size(); i++) {
  238 + proportions.add(MathUtil.getProportion(peopleList.get(i), countPeople));
100 239 }
101 240 return proportions;
102 241 }
... ... @@ -105,6 +244,7 @@
105 244 List<Object> peoples = new ArrayList<>();
106 245 peoples.add("产检人数");
107 246 int countPeople = 0; /** 体检所有人数 */
  247 + int otherPeople = 0; /** 大于或等于13的所有人数 */
108 248  
109 249 /** 通过下标循环取map里面数据 有就设置value 没有就设置0 */
110 250 for(int i = 1; i <= 30; i++) {
... ... @@ -115,7 +255,7 @@
115 255 countPeople += Integer.valueOf(count);
116 256 }
117 257 }
118   - if(i <= 13) {
  258 + if(i < 13) {
119 259 if(StringUtils.isNotBlank(count)) {
120 260 peoples.add(count);
121 261 } else {
122 262  
... ... @@ -123,10 +263,11 @@
123 263 }
124 264 } else {
125 265 if(StringUtils.isNotBlank(count)) {
126   - peoples.set(12, Integer.valueOf(peoples.get(12).toString()) + Integer.valueOf(count) + "");
  266 + otherPeople += Integer.valueOf(count);
127 267 }
128 268 }
129 269 }
  270 + peoples.add(otherPeople + "");
130 271 peoples.add(1, countPeople + "");
131 272 return peoples;
132 273 }
platform-operate-api/src/main/java/com/lyms/platform/operate/web/utils/MathUtil.java View file @ 249f938
1 1 package com.lyms.platform.operate.web.utils;
2 2  
  3 +import org.apache.commons.lang.StringUtils;
  4 +
3 5 import java.text.DecimalFormat;
4 6  
5 7 /**
... ... @@ -33,6 +35,26 @@
33 35 public static String doubleFormat(Double d) {
34 36 DecimalFormat df = new DecimalFormat("######0.00");
35 37 return df.format(d);
  38 + }
  39 +
  40 + /**
  41 + * 计算所占比例
  42 + * @param obj
  43 + * @param count
  44 + * @return
  45 + */
  46 + public static String getProportion(Object obj, Integer count) {
  47 + if(obj != null && StringUtils.isNumeric(obj.toString()) && count != null && count != 0) {
  48 + Double division = Double.parseDouble(division(Integer.parseInt(obj.toString()), count)) * 100;
  49 + return doubleFormat(division) + "%";
  50 + }
  51 + return "0.00%";
  52 + }
  53 +
  54 + public static String getProportion(Object obj, Object count) {
  55 + if(StringUtils.isNotBlank("count") && StringUtils.isNumeric(count.toString()))
  56 + return getProportion(obj, Integer.parseInt(count.toString()));
  57 + return "0.00%";
36 58 }
37 59  
38 60 }