Commit 98bf3cb4c22a68e0eafc2aa8b7843a5a36c8631a

Authored by hujiaqi
1 parent 756637ba97

导出excel

Showing 2 changed files with 52 additions and 8 deletions

platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/BabyStatisticsManagerController.java View file @ 98bf3cb
... ... @@ -22,10 +22,7 @@
22 22  
23 23 import javax.servlet.http.HttpServletRequest;
24 24 import javax.servlet.http.HttpServletResponse;
25   -import java.util.ArrayList;
26   -import java.util.LinkedHashMap;
27   -import java.util.List;
28   -import java.util.Map;
  25 +import java.util.*;
29 26  
30 27 /**
31 28 * @auther HuJiaqi
... ... @@ -373,6 +370,53 @@
373 370 ExceptionUtils.catchException(e, "babyStatisticsManagerSelfConversionList异常");
374 371 }
375 372 return baseObjectResponse;
  373 + }
  374 +
  375 + @TokenRequired
  376 + @RequestMapping(value = "babyStatisticsManagerSelfConversionListExcel", method = RequestMethod.POST)
  377 + public void babyStatisticsManagerSelfConversionListExcel(HttpServletRequest httpServletRequest, @RequestBody BabyStatisticsManagerSelfConversionListRequest babyStatisticsManagerSelfConversionListRequest, HttpServletResponse httpServletResponse) {
  378 + try {
  379 + babyStatisticsManagerSelfConversionListRequest.setOperatorId(((LoginContext) httpServletRequest.getAttribute("loginContext")).getId());
  380 + babyStatisticsManagerSelfConversionListRequest.setExcel(true);
  381 + BabyStatisticsManagerSelfConversionListResult babyStatisticsManagerSelfConversionListResult = babyStatisticsManagerFacade.babyStatisticsManagerSelfConversionList(babyStatisticsManagerSelfConversionListRequest);
  382 + List<Map<String, Object>> list = new ArrayList<>();
  383 +
  384 + List<Integer> babyCount = babyStatisticsManagerSelfConversionListResult.getBabyCount();
  385 + List<String> percent = babyStatisticsManagerSelfConversionListResult.getPercent();
  386 +
  387 + Map<String, Object> babyCountMap = new HashMap<>();
  388 + babyCountMap.put("name", "儿童数量");
  389 + babyCountMap.put("total", babyCount.get(0));
  390 + babyCountMap.put("check1", babyCount.get(1));
  391 + babyCountMap.put("check3", babyCount.get(2));
  392 + babyCountMap.put("check6", babyCount.get(3));
  393 + babyCountMap.put("check12", babyCount.get(4));
  394 + babyCountMap.put("checkOther", babyCount.get(5));
  395 + Map<String, Object> percentMap = new HashMap<>();
  396 + percentMap.put("name", "占比");
  397 + percentMap.put("total", percent.get(0));
  398 + percentMap.put("check1", percent.get(1));
  399 + percentMap.put("check3", percent.get(2));
  400 + percentMap.put("check6", percent.get(3));
  401 + percentMap.put("check12", percent.get(4));
  402 + percentMap.put("checkOther", percent.get(5));
  403 + list.add(babyCountMap);
  404 + list.add(percentMap);
  405 +
  406 + Map<String, String> header = new LinkedHashMap<>();
  407 + header.put("name", "");
  408 + header.put("total", "本院分娩数");
  409 + header.put("check1", "1月内检查");
  410 + header.put("check3", "3月内检查");
  411 + header.put("check6", "6月内检查");
  412 + header.put("check12", "12月内检查");
  413 + header.put("checkOther", "1年内未检查");
  414 + httpServletResponse.setContentType("application/force-download");
  415 + httpServletResponse.setHeader("Content-Disposition", "attachment;filename=" + new String(("本院转化率统计.xls").getBytes("UTF-8"), "ISO-8859-1"));
  416 + ExcelUtil.toExcel(httpServletResponse.getOutputStream(), list, header);
  417 + } catch (Exception e) {
  418 + ExceptionUtils.catchException(e, "babyStatisticsManagerSelfConversionListExcel异常");
  419 + }
376 420 }
377 421  
378 422 }
platform-operate-api/src/main/java/com/lyms/platform/operate/web/request/BabyStatisticsManagerSelfConversionListRequest.java View file @ 98bf3cb
... ... @@ -11,7 +11,7 @@
11 11  
12 12 private Integer operatorId;
13 13  
14   - private String isExcel;
  14 + private boolean isExcel;
15 15  
16 16 public String getBirthDate() {
17 17 return birthDate;
18 18  
... ... @@ -29,12 +29,12 @@
29 29 this.operatorId = operatorId;
30 30 }
31 31  
32   - public String getIsExcel() {
  32 + public boolean isExcel() {
33 33 return isExcel;
34 34 }
35 35  
36   - public void setIsExcel(String isExcel) {
37   - this.isExcel = isExcel;
  36 + public void setExcel(boolean excel) {
  37 + isExcel = excel;
38 38 }
39 39 }