Commit 842d3719cbef86fcc9e086b4ab2cef1671fe0037

Authored by hujiaqi
1 parent f00d11a744

导出excel

Showing 2 changed files with 211 additions and 41 deletions

platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/BabyStatisticsManagerController.java View file @ 842d371
... ... @@ -7,11 +7,14 @@
7 7 import com.lyms.platform.common.result.BaseListResponse;
8 8 import com.lyms.platform.common.result.BaseObjectResponse;
9 9 import com.lyms.platform.common.utils.BeanUtils;
  10 +import com.lyms.platform.common.utils.DateUtil;
10 11 import com.lyms.platform.common.utils.ExcelUtil;
11 12 import com.lyms.platform.common.utils.ExceptionUtils;
  13 +import com.lyms.platform.operate.web.facade.AutoMatchFacade;
12 14 import com.lyms.platform.operate.web.facade.BabyStatisticsManagerFacade;
13 15 import com.lyms.platform.operate.web.request.*;
14 16 import com.lyms.platform.operate.web.result.*;
  17 +import com.lyms.platform.operate.web.utils.JdbcUtil;
15 18 import org.apache.commons.lang.StringUtils;
16 19 import org.springframework.beans.factory.annotation.Autowired;
17 20 import org.springframework.stereotype.Controller;
... ... @@ -313,6 +316,147 @@
313 316 ExceptionUtils.catchException(e, "babyStatisticsManagerBuildSourceList异常");
314 317 }
315 318 return baseListResponse;
  319 + }
  320 +
  321 + @Autowired
  322 + private AutoMatchFacade autoMatchFacade;
  323 +
  324 + /**
  325 + * @auther HuJiaqi
  326 + * @createTime 2017年01月16日 13时54分
  327 + * @discription 本院转化统计
  328 + */
  329 + @TokenRequired
  330 + @ResponseBody
  331 + @RequestMapping(value = "hujiaqiTest1", method = RequestMethod.POST, consumes = "application/json")
  332 + public List<Map<String, Object>> hujiaqiTest1(HttpServletRequest httpServletRequest, BabyStatisticsManagerSelfConversionListRequest babyStatisticsManagerSelfConversionListRequest) {
  333 + String hospitalId;
  334 + babyStatisticsManagerSelfConversionListRequest.setOperatorId(((LoginContext) httpServletRequest.getAttribute("loginContext")).getId());
  335 + hospitalId = autoMatchFacade.getHospitalId(babyStatisticsManagerSelfConversionListRequest.getOperatorId());
  336 + String birthDateStart = null;
  337 + String birthDateEnd = null;
  338 + if (StringUtils.isNotEmpty(babyStatisticsManagerSelfConversionListRequest.getBirthDate())) {
  339 + birthDateStart = DateUtil.getyyyy_MM_dd(DateUtil.getSNDate(babyStatisticsManagerSelfConversionListRequest.getBirthDate())[0]);
  340 + birthDateEnd = DateUtil.getyyyy_MM_dd(DateUtil.getSNDate(babyStatisticsManagerSelfConversionListRequest.getBirthDate())[1]);
  341 + }
  342 + String sql =
  343 + "SELECT B.PROVINCE_ID," +
  344 + "B.PROVINCE," +
  345 + "B.CITY_ID," +
  346 + "B.CITY," +
  347 + "B.AREA_COUNTY_ID," +
  348 + "B.AREA_COUNTY," +
  349 + "B.HOSPITAL_NO," +
  350 + "B.HOSPITAL_NAME," +
  351 + "TRUNC(MONTHS_BETWEEN(C.EXAMINE_DATE,A.BIRTHDAY)) AS EXAMINE_MONTH," +
  352 + "COUNT(*) AS CNT" +
  353 + " FROM ODS_F_INFANT_RECORD A" +
  354 + " INNER JOIN ODS_D_HOSPITAL B ON A.HOSPITAL_NO=B.HOSPITAL_NO" +
  355 + " LEFT JOIN ODS_F_CHILD_PHYSICAL C ON A.RECORD_ID=C.RECORD_ID AND C.EXAMINE_HISTORY_NUM=1" +
  356 + " WHERE A.HOSPITAL_NO=A.BIRTH_HOSPITAL_NO" +
  357 + " AND B.YCY_STSTEM_ID='" + hospitalId + "'";
  358 + // 这三个查询条件暂时没用,直接注释掉
  359 + // "AND B.PROVINCE_ID="+
  360 + // "AND B.CITY_ID="+
  361 + // "AND B.AREA_COUNTY_ID="+'2015-01-19','YYYY-MM-DD')
  362 + if (StringUtils.isNotEmpty(babyStatisticsManagerSelfConversionListRequest.getBirthDate())) {
  363 + sql += " AND A.INSERT_DATE BETWEEN TO_DATE('" + birthDateStart + "','YYYY-MM-DD') AND TO_DATE('" + birthDateEnd + "','YYYY-MM-DD')";
  364 + }
  365 + sql += " GROUP BY " +
  366 + "B.PROVINCE_ID," +
  367 + "B.PROVINCE," +
  368 + "B.CITY_ID," +
  369 + "B.CITY," +
  370 + "B.AREA_COUNTY_ID," +
  371 + "B.AREA_COUNTY," +
  372 + "B.HOSPITAL_NO," +
  373 + "B.HOSPITAL_NAME," +
  374 + "TRUNC(MONTHS_BETWEEN(C.EXAMINE_DATE,A.BIRTHDAY))";
  375 + // jdbc查oracle
  376 +// List<Map<String, Object>> list = JdbcUtil.getOracleListDataBySql("com.mysql.jdbc.Driver", "jdbc:oracle:thin:@127.0.0.1:1521:orcl", "LYMS_ODS", "Welcome1", sql);
  377 + ExceptionUtils.catchException("babyStatisticsManagerSelfConversionList: " + sql);
  378 + List<Map<String, Object>> list = JdbcUtil.getOracleListDataBySql("oracle.jdbc.driver.OracleDriver", "jdbc:oracle:thin:@127.0.0.1:1521:orcl", "LYMS_ODS", "Welcome1", sql);
  379 + // List<Map<String, Object>> list = new ArrayList<>();
  380 + // Map<String, Object> m1 = new HashMap<>();
  381 + // m1.put("1", "1");
  382 + // m1.put("2", "2");
  383 + // Map<String, Object> m2 = new HashMap<>();
  384 + // m2.put("a", "a");
  385 + // m2.put("b", "b");
  386 + // list.add(m1);
  387 + // list.add(m2);
  388 + return list;
  389 + }
  390 +
  391 + @TokenRequired
  392 + @ResponseBody
  393 + @RequestMapping(value = "hujiaqiTest2", method = RequestMethod.POST, consumes = "application/json")
  394 + public List<Map<String, Object>> hujiaqiTest2(HttpServletRequest httpServletRequest, BabyStatisticsManagerBuildSourceListRequest babyStatisticsManagerBuildSourceListRequest) {
  395 + String hospitalId;
  396 + babyStatisticsManagerBuildSourceListRequest.setOperatorId(((LoginContext) httpServletRequest.getAttribute("loginContext")).getId());
  397 + hospitalId = autoMatchFacade.getHospitalId(babyStatisticsManagerBuildSourceListRequest.getOperatorId());
  398 + String buildDateStart = null;
  399 + String buildDateEnd = null;
  400 + if (StringUtils.isNotEmpty(babyStatisticsManagerBuildSourceListRequest.getBuildDate())) {
  401 + buildDateStart = DateUtil.getyyyy_MM_dd(DateUtil.getSNDate(babyStatisticsManagerBuildSourceListRequest.getBuildDate())[0]);
  402 + buildDateEnd = DateUtil.getyyyy_MM_dd(DateUtil.getSNDate(babyStatisticsManagerBuildSourceListRequest.getBuildDate())[1]);
  403 + }
  404 + String sql =
  405 + "SELECT B.PROVINCE_ID," +
  406 + "B.PROVINCE," +
  407 + "B.CITY_ID," +
  408 + "B.CITY," +
  409 + "B.AREA_COUNTY_ID," +
  410 + "B.AREA_COUNTY," +
  411 + "B.HOSPITAL_NO," +
  412 + "B.HOSPITAL_NAME," +
  413 + "A.CHILD_CATEGORY_ID," +
  414 + "A.CHILD_CATEGORY," +
  415 + "(CASE WHEN A.BIRTH_HOSPITAL_NO=A.HOSPITAL_NO THEN '本院分娩'" +
  416 + " WHEN A.BIRTH_HOSPITAL_NO<>A.HOSPITAL_NO AND A.BIRTH_HOSPITAL_NO IS NOT NULL THEN '外院分娩'" +
  417 + " WHEN A.BIRTH_HOSPITAL_NO IS NULL THEN '未知'" +
  418 + "END) AS LB_NAME," +
  419 + "COUNT(*) AS CNT" +
  420 + " FROM ODS_F_INFANT_RECORD A" +
  421 + " INNER JOIN ODS_D_HOSPITAL B ON A.HOSPITAL_NO=B.HOSPITAL_NO" +
  422 + // 医院,判断本院外院使用
  423 + " WHERE B.YCY_STSTEM_ID='" + hospitalId + "'";
  424 + // 这三个查询条件暂时没用,直接注释掉
  425 + // "AND B.PROVINCE_ID=" +
  426 + // "AND B.CITY_ID=" +
  427 + // "AND B.AREA_COUNTY_ID="
  428 + if (StringUtils.isNotEmpty(babyStatisticsManagerBuildSourceListRequest.getBuildDate())) {
  429 + sql += " AND A.INSERT_DATE BETWEEN TO_DATE('" + buildDateStart + "','YYYY-MM-DD') AND TO_DATE('" + buildDateEnd + "','YYYY-MM-DD')";
  430 + }
  431 + sql += " GROUP BY " +
  432 + "B.PROVINCE_ID," +
  433 + "B.PROVINCE," +
  434 + "B.CITY_ID," +
  435 + "B.CITY," +
  436 + "B.AREA_COUNTY_ID," +
  437 + "B.AREA_COUNTY," +
  438 + "B.HOSPITAL_NO," +
  439 + "B.HOSPITAL_NAME," +
  440 + "A.CHILD_CATEGORY_ID," +
  441 + "A.CHILD_CATEGORY," +
  442 + "(CASE WHEN A.BIRTH_HOSPITAL_NO=A.HOSPITAL_NO THEN '本院分娩'" +
  443 + "WHEN A.BIRTH_HOSPITAL_NO<>A.HOSPITAL_NO AND A.BIRTH_HOSPITAL_NO IS NOT NULL THEN '外院分娩'" +
  444 + "WHEN A.BIRTH_HOSPITAL_NO IS NULL THEN '未知'" +
  445 + "END)";
  446 + // jdbc查oracle
  447 +// List<Map<String, Object>> list = JdbcUtil.getOracleListDataBySql("com.mysql.jdbc.Driver", "jdbc:oracle:thin:@127.0.0.1:1521:orcl", "LYMS_ODS", "Welcome1", sql);
  448 + ExceptionUtils.catchException("babyStatisticsManagerBuildSourceList: " + sql);
  449 + List<Map<String, Object>> list = JdbcUtil.getOracleListDataBySql("oracle.jdbc.driver.OracleDriver", "jdbc:oracle:thin:@127.0.0.1:1521:orcl", "LYMS_ODS", "Welcome1", sql);
  450 + // List<Map<String, Object>> list = new ArrayList<>();
  451 + // Map<String, Object> m1 = new HashMap<>();
  452 + // m1.put("1", "1");
  453 + // m1.put("2", "2");
  454 + // Map<String, Object> m2 = new HashMap<>();
  455 + // m2.put("a", "a");
  456 + // m2.put("b", "b");
  457 + // list.add(m1);
  458 + // list.add(m2);
  459 + return list;
316 460 }
317 461  
318 462 @TokenRequired
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/BabyStatisticsManagerFacade.java View file @ 842d371
... ... @@ -559,7 +559,33 @@
559 559 // jdbc查oracle
560 560 // List<Map<String, Object>> list = JdbcUtil.getOracleListDataBySql("com.mysql.jdbc.Driver", "jdbc:oracle:thin:@127.0.0.1:1521:orcl", "LYMS_ODS", "Welcome1", sql);
561 561 ExceptionUtils.catchException("babyStatisticsManagerBuildSourceList: " + sql);
562   - List<Map<String, Object>> list = JdbcUtil.getOracleListDataBySql("oracle.jdbc.driver.OracleDriver", "jdbc:oracle:thin:@192.168.1.32:1521:orcl", "LYMS_ODS", "Welcome1", sql);
  562 + // List<Map<String, Object>> list = JdbcUtil.getOracleListDataBySql("oracle.jdbc.driver.OracleDriver", "jdbc:oracle:thin:@127.0.0.1:1521:orcl", "LYMS_ODS", "Welcome1", sql);
  563 + List<Map<String, Object>> list = new ArrayList<>();
  564 + Map<String,Object> m1 = new HashMap<>();
  565 + m1.put("LB_NAME","本院分娩");
  566 + m1.put("CNT",1594);
  567 + m1.put("CHILD_CATEGORY_ID",2);
  568 + Map<String,Object> m2 = new HashMap<>();
  569 + m2.put("LB_NAME","未知");
  570 + m2.put("CNT",630);
  571 + m2.put("CHILD_CATEGORY_ID",2);
  572 + Map<String,Object> m3 = new HashMap<>();
  573 + m3.put("LB_NAME","外院分娩");
  574 + m3.put("CNT",2);
  575 + m3.put("CHILD_CATEGORY_ID",2);
  576 + Map<String,Object> m4 = new HashMap<>();
  577 + m4.put("LB_NAME","本院分娩");
  578 + m4.put("CNT",172);
  579 + m4.put("CHILD_CATEGORY_ID",1);
  580 + Map<String,Object> m5 = new HashMap<>();
  581 + m5.put("LB_NAME","未知");
  582 + m5.put("CNT",7186);
  583 + m5.put("CHILD_CATEGORY_ID",1);
  584 + list.add(m1);
  585 + list.add(m2);
  586 + list.add(m3);
  587 + list.add(m4);
  588 + list.add(m5);
563 589 // 构造返回list,这里写死的4条,因为高帆说只有4条
564 590 BabyStatisticsManagerBuildSourceListQueryModel babyStatisticsManagerBuildSourceListQueryModel1 = new BabyStatisticsManagerBuildSourceListQueryModel();
565 591 babyStatisticsManagerBuildSourceListQueryModel1.setLbName("本院分娩");
566 592  
567 593  
568 594  
... ... @@ -583,26 +609,26 @@
583 609 String highRiskPercent4 = "-";
584 610 if (CollectionUtils.isNotEmpty(list)) {
585 611 for (Map<String, Object> map : list) {
586   - if ("本院分娩".equals(map.get("lbName"))) {
587   - buildCnt1 += Integer.valueOf(map.get("cnt").toString());
588   - if ("2".equals(map.get("childCategoryId"))) {
589   - highRiskCnt1 += Integer.valueOf(map.get("cnt").toString());
  612 + if ("本院分娩".equals(map.get("LB_NAME"))) {
  613 + buildCnt1 += Integer.valueOf(map.get("CNT").toString());
  614 + if ("2".equals(map.get("CHILD_CATEGORY_ID"))) {
  615 + highRiskCnt1 += Integer.valueOf(map.get("CNT").toString());
590 616 }
591   - } else if ("外院分娩".equals(map.get("lbName"))) {
592   - buildCnt2 += Integer.valueOf(map.get("cnt").toString());
593   - if ("2".equals(map.get("childCategoryId"))) {
594   - highRiskCnt2 += Integer.valueOf(map.get("cnt").toString());
  617 + } else if ("外院分娩".equals(map.get("LB_NAME"))) {
  618 + buildCnt2 += Integer.valueOf(map.get("CNT").toString());
  619 + if ("2".equals(map.get("CHILD_CATEGORY_ID"))) {
  620 + highRiskCnt2 += Integer.valueOf(map.get("CNT").toString());
595 621 }
596   - } else if ("未知".equals(map.get("lbName"))) {
597   - buildCnt3 += Integer.valueOf(map.get("cnt").toString());
598   - if ("2".equals(map.get("childCategoryId"))) {
599   - highRiskCnt3 += Integer.valueOf(map.get("cnt").toString());
  622 + } else if ("未知".equals(map.get("LB_NAME"))) {
  623 + buildCnt3 += Integer.valueOf(map.get("CNT").toString());
  624 + if ("2".equals(map.get("CHILD_CATEGORY_ID"))) {
  625 + highRiskCnt3 += Integer.valueOf(map.get("CNT").toString());
600 626 }
601 627 }
602 628 // 总计
603   - buildCnt4 += Integer.valueOf(map.get("cnt").toString());
604   - if ("2".equals(map.get("childCategoryId"))) {
605   - highRiskCnt4 += Integer.valueOf(map.get("cnt").toString());
  629 + buildCnt4 += Integer.valueOf(map.get("CNT").toString());
  630 + if ("2".equals(map.get("CHILD_CATEGORY_ID"))) {
  631 + highRiskCnt4 += Integer.valueOf(map.get("CNT").toString());
606 632 }
607 633 }
608 634 highRiskPercent1 = Math.round((double) highRiskCnt1 * 1000 / (double) buildCnt1) / 10.0 + "%";
609 635  
610 636  
611 637  
... ... @@ -693,17 +719,17 @@
693 719 List<Map<String, Object>> list = JdbcUtil.getOracleListDataBySql("oracle.jdbc.driver.OracleDriver", "jdbc:oracle:thin:@192.168.1.32:1521:orcl", "LYMS_ODS", "Welcome1", sql);
694 720 // List<Map<String, Object>> list = new ArrayList<>();
695 721 // Map<String, Object> test1 = new HashMap<>();
696   - // test1.put("examineMonth", 2);
697   - // test1.put("cnt", "2");
  722 + // test1.put("EXAMINE_MONTH", 2);
  723 + // test1.put("CNT", "2");
698 724 // Map<String, Object> test2 = new HashMap<>();
699   - // test2.put("examineMonth", 3);
700   - // test2.put("cnt", "3");
  725 + // test2.put("EXAMINE_MONTH", 3);
  726 + // test2.put("CNT", "3");
701 727 // Map<String, Object> test3 = new HashMap<>();
702   - // test3.put("examineMonth", 1);
703   - // test3.put("cnt", "1");
  728 + // test3.put("EXAMINE_MONTH", 1);
  729 + // test3.put("CNT", "1");
704 730 // Map<String, Object> test4 = new HashMap<>();
705   - // test4.put("examineMonth", 0);
706   - // test4.put("cnt", "5");
  731 + // test4.put("EXAMINE_MONTH", 0);
  732 + // test4.put("CNT", "5");
707 733 // list.add(test1);
708 734 // list.add(test2);
709 735 // list.add(test3);
710 736  
... ... @@ -715,12 +741,12 @@
715 741 int i1;
716 742 int i2;
717 743 try {
718   - i1 = Integer.valueOf(o1.get("examineMonth").toString());
  744 + i1 = Integer.valueOf(o1.get("EXAMINE_MONTH").toString());
719 745 } catch (Exception e) {
720 746 i1 = 0;
721 747 }
722 748 try {
723   - i2 = Integer.valueOf(o2.get("examineMonth").toString());
  749 + i2 = Integer.valueOf(o2.get("EXAMINE_MONTH").toString());
724 750 } catch (Exception e) {
725 751 i2 = 0;
726 752 }
727 753  
728 754  
... ... @@ -742,18 +768,18 @@
742 768 int index = 0;
743 769 for (Integer i = 0; i < 12 /*13*/; i++) {
744 770 // try {
745   -// while (!i.toString().equals(list.get(index).get("examineMonth").toString()) && index > Integer.valueOf(list.get(index).get("examineMonth").toString())) {
  771 +// while (!i.toString().equals(list.get(index).get("EXAMINE_MONTH").toString()) && index > Integer.valueOf(list.get(index).get("EXAMINE_MONTH").toString())) {
746 772 // index++;
747 773 // }
748 774 // } catch (Exception e) {
749 775 // index++;
750 776 // }
751   -// if (CollectionUtils.isEmpty(list) || list.size() /*< */>index || list.get(index) == null || !i.toString().equals(list.get(index).get("examineMonth").toString())) {
  777 +// if (CollectionUtils.isEmpty(list) || list.size() /*< */>index || list.get(index) == null || !i.toString().equals(list.get(index).get("EXAMINE_MONTH").toString())) {
752 778 // result.add(0);
753 779 // } else {
754 780 // try {
755   -// result.add(Integer.valueOf(list.get(index).get("cnt").toString()));
756   -// total += Integer.valueOf(list.get(index).get("cnt").toString());
  781 +// result.add(Integer.valueOf(list.get(index).get("CNT").toString()));
  782 +// total += Integer.valueOf(list.get(index).get("CNT").toString());
757 783 // index++;
758 784 // } catch (Exception e) {
759 785 // result.add(0);
760 786  
... ... @@ -761,12 +787,12 @@
761 787 // }
762 788 // }
763 789  
764   - if (CollectionUtils.isEmpty(list)||i>list.size()-1 || list.get(i) == null || null == list.get(i).get("examineMonth")) {
  790 + if (CollectionUtils.isEmpty(list)||i>list.size()-1 || list.get(i) == null || null == list.get(i).get("EXAMINE_MONTH")) {
765 791 result.add(0);
766 792 } else {
767 793 try {
768   - result.add(Integer.valueOf(list.get(i).get("cnt").toString()));
769   - total += Integer.valueOf(list.get(i).get("cnt").toString());
  794 + result.add(Integer.valueOf(list.get(i).get("CNT").toString()));
  795 + total += Integer.valueOf(list.get(i).get("CNT").toString());
770 796 } catch (Exception e) {
771 797 result.add(0);
772 798 }
773 799  
774 800  
775 801  
... ... @@ -778,17 +804,17 @@
778 804 Integer check30 = 0;
779 805 Integer check36 = 0;
780 806 for (Map<String, Object> other : list) {
781   - if (null!=other.get("examineMonth")&&"18".equals(other.get("examineMonth").toString())) {
782   - check18 = Integer.valueOf(other.get("cnt").toString());
  807 + if (null!=other.get("EXAMINE_MONTH")&&"18".equals(other.get("EXAMINE_MONTH").toString())) {
  808 + check18 = Integer.valueOf(other.get("CNT").toString());
783 809 }
784   - if (null!=other.get("examineMonth")&&"24".equals(other.get("examineMonth").toString())) {
785   - check24 = Integer.valueOf(other.get("cnt").toString());
  810 + if (null!=other.get("EXAMINE_MONTH")&&"24".equals(other.get("EXAMINE_MONTH").toString())) {
  811 + check24 = Integer.valueOf(other.get("CNT").toString());
786 812 }
787   - if (null!=other.get("examineMonth")&&"30".equals(other.get("examineMonth").toString())) {
788   - check30 = Integer.valueOf(other.get("cnt").toString());
  813 + if (null!=other.get("EXAMINE_MONTH")&&"30".equals(other.get("EXAMINE_MONTH").toString())) {
  814 + check30 = Integer.valueOf(other.get("CNT").toString());
789 815 }
790   - if (null!=other.get("examineMonth")&&"36".equals(other.get("examineMonth").toString())) {
791   - check36 = Integer.valueOf(other.get("cnt").toString());
  816 + if (null!=other.get("EXAMINE_MONTH")&&"36".equals(other.get("EXAMINE_MONTH").toString())) {
  817 + check36 = Integer.valueOf(other.get("CNT").toString());
792 818 }
793 819 }
794 820 result.add(check18);