Commit 3a768ab5ef586e564ec412d6d36ecd8939fd728b
1 parent
325fdb2d63
Exists in
master
and in
6 other branches
滦平-统计左侧导出需求-院内高危统计报表 左 导出
Showing 2 changed files with 72 additions and 0 deletions
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/RiskReportController.java
View file @
3a768ab
... | ... | @@ -4,10 +4,13 @@ |
4 | 4 | import com.lyms.platform.common.base.BaseController; |
5 | 5 | import com.lyms.platform.common.base.LoginContext; |
6 | 6 | import com.lyms.platform.common.result.BaseResponse; |
7 | +import com.lyms.platform.common.utils.ExcelUtil; | |
7 | 8 | import com.lyms.platform.operate.web.facade.RiskReportFacade; |
8 | 9 | import com.lyms.platform.operate.web.request.RiskBabysQueryRequest; |
9 | 10 | import com.lyms.platform.operate.web.request.RiskPatientsCountRequest; |
10 | 11 | import com.lyms.platform.operate.web.request.RiskPatientsQueryRequest; |
12 | +import com.lyms.platform.operate.web.result.RiskReportResult; | |
13 | +import com.lyms.platform.operate.web.utils.CollectionUtils; | |
11 | 14 | import org.springframework.beans.factory.annotation.Autowired; |
12 | 15 | import org.springframework.stereotype.Controller; |
13 | 16 | import org.springframework.web.bind.annotation.RequestMapping; |
... | ... | @@ -17,6 +20,9 @@ |
17 | 20 | import javax.servlet.http.HttpServletRequest; |
18 | 21 | import javax.servlet.http.HttpServletResponse; |
19 | 22 | import javax.validation.Valid; |
23 | +import java.io.OutputStream; | |
24 | +import java.text.DecimalFormat; | |
25 | +import java.util.*; | |
20 | 26 | |
21 | 27 | |
22 | 28 | /** |
... | ... | @@ -54,6 +60,18 @@ |
54 | 60 | public BaseResponse queryRiskReportCount(@Valid RiskPatientsQueryRequest patientsQueryRequest,HttpServletRequest request) { |
55 | 61 | LoginContext loginState = (LoginContext) request.getAttribute("loginContext"); |
56 | 62 | return riskReportFacade.queryRiskReportCount(patientsQueryRequest,loginState.getId()); |
63 | + | |
64 | + } | |
65 | + /** | |
66 | + * 院内高危统计报表 左 导出 | |
67 | + * @return | |
68 | + */ | |
69 | + @RequestMapping(method = RequestMethod.GET, value = "/queryRiskReportCountExport") | |
70 | + @ResponseBody | |
71 | + @TokenRequired | |
72 | + public void queryRiskReportCountExport(@Valid RiskPatientsQueryRequest patientsQueryRequest,HttpServletRequest request, HttpServletResponse response) { | |
73 | + LoginContext loginState = (LoginContext) request.getAttribute("loginContext"); | |
74 | + riskReportFacade.queryRiskReportCountExport(patientsQueryRequest, loginState.getId(),response); | |
57 | 75 | |
58 | 76 | } |
59 | 77 |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/RiskReportFacade.java
View file @
3a768ab
... | ... | @@ -27,6 +27,7 @@ |
27 | 27 | import com.lyms.platform.query.BasicConfigQuery; |
28 | 28 | import com.lyms.platform.query.PatientsQuery; |
29 | 29 | import org.apache.commons.collections.CollectionUtils; |
30 | +import org.apache.commons.collections.MapUtils; | |
30 | 31 | import org.springframework.beans.factory.annotation.Autowired; |
31 | 32 | import org.springframework.beans.factory.annotation.Qualifier; |
32 | 33 | import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; |
... | ... | @@ -1479,6 +1480,59 @@ |
1479 | 1480 | return hids; |
1480 | 1481 | } |
1481 | 1482 | |
1483 | + public void queryRiskReportCountExport(RiskPatientsQueryRequest patientsQueryRequest, Integer id, HttpServletResponse response) { | |
1484 | + List<RiskReportResult> datas = queryRiskReportCount(patientsQueryRequest, id).getData(); | |
1485 | + List<Map<String,Object>> result=new ArrayList<>(); | |
1486 | + Integer count =0; | |
1487 | + if(CollectionUtils.isNotEmpty(datas)) { | |
1488 | + count+= dataTierSort(datas, "315107bd-91fe-42a1-9237-752f3c046a40", result); | |
1489 | + count+= dataTierSort(datas, "49a36aea-c5b6-4162-87d2-9eb3c6ec00c2", result); | |
1490 | + count+= dataTierSort(datas, "eb146c03-b19f-4e28-b85f-fda574b2283b", result); | |
1491 | + count+= dataTierSort(datas, "224b2329-cb82-4da3-a071-8527f8283aab", result); | |
1492 | + //自定义高危 | |
1493 | + count+= datas.get(datas.size()-1).getRiskCount(); | |
1494 | + result.add(MapUtil.beanToMap(datas.get(datas.size()-1))); | |
1495 | + } | |
1496 | + try { | |
1497 | + response.setContentType("application/octet-stream"); | |
1498 | + response.setHeader("Content-Disposition", "attachment;fileName=" + "高危人数统计.xls"); | |
1499 | + Map <String, String> cnames = new LinkedHashMap <>(); | |
1500 | + cnames.put("highRisk", "风险因素"); | |
1501 | + cnames.put("riskCount", "人次"); | |
1502 | + cnames.put("percent", "发病率"); | |
1503 | + final Integer finalCount = count; | |
1504 | + result.add(new HashMap(){{put("highRisk","合计");put("riskCount", finalCount);}}); | |
1505 | + OutputStream out = response.getOutputStream(); | |
1506 | + ExcelUtil.toExcel(out, result, cnames); | |
1507 | + } catch (IOException e) { | |
1508 | + ExceptionUtils.catchException(e, e.getMessage()); | |
1509 | + } | |
1510 | + | |
1511 | + } | |
1512 | + //高危分类 | |
1513 | + public int dataTierSort(List<RiskReportResult> datas,String riskColor,List<Map<String,Object>> result) { | |
1514 | + int count=0; | |
1515 | + for (RiskReportResult data : datas) { | |
1516 | + //黄色 | |
1517 | + if(data.getLevel()==1 && riskColor.equals(data.getHighRiskId())){ | |
1518 | + result.add(MapUtil.beanToMap(data)); | |
1519 | + count=data.getRiskCount(); | |
1520 | + for (RiskReportResult data2 : datas) { | |
1521 | + a(data,data2,datas,result); | |
1522 | + } | |
1523 | + } | |
1524 | + } | |
1525 | + return count; | |
1526 | + } | |
1527 | + //层级关系 | |
1528 | + public void a(RiskReportResult data,RiskReportResult data2,List<RiskReportResult> datas,List<Map<String,Object>> result){ | |
1529 | + if(data.getHighRiskId().equals(data2.getPid())){ | |
1530 | + result.add(MapUtil.beanToMap(data2)); | |
1531 | + for (RiskReportResult dataN : datas) { | |
1532 | + a(data2, dataN,datas,result); | |
1533 | + } | |
1534 | + } | |
1535 | + } | |
1482 | 1536 | |
1483 | 1537 | |
1484 | 1538 | //计算占比 |