diff --git a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/BabyStatisticsManagerController.java b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/BabyStatisticsManagerController.java index f1a7a00..ea69bae 100644 --- a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/BabyStatisticsManagerController.java +++ b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/BabyStatisticsManagerController.java @@ -7,11 +7,14 @@ import com.lyms.platform.common.constants.ErrorCodeConstants; import com.lyms.platform.common.result.BaseListResponse; import com.lyms.platform.common.result.BaseObjectResponse; import com.lyms.platform.common.utils.BeanUtils; +import com.lyms.platform.common.utils.DateUtil; import com.lyms.platform.common.utils.ExcelUtil; import com.lyms.platform.common.utils.ExceptionUtils; +import com.lyms.platform.operate.web.facade.AutoMatchFacade; import com.lyms.platform.operate.web.facade.BabyStatisticsManagerFacade; import com.lyms.platform.operate.web.request.*; import com.lyms.platform.operate.web.result.*; +import com.lyms.platform.operate.web.utils.JdbcUtil; import org.apache.commons.lang.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; @@ -315,6 +318,147 @@ public class BabyStatisticsManagerController extends BaseController { return baseListResponse; } + @Autowired + private AutoMatchFacade autoMatchFacade; + + /** + * @auther HuJiaqi + * @createTime 2017年01月16日 13时54分 + * @discription 本院转化统计 + */ + @TokenRequired + @ResponseBody + @RequestMapping(value = "hujiaqiTest1", method = RequestMethod.POST, consumes = "application/json") + public List> hujiaqiTest1(HttpServletRequest httpServletRequest, BabyStatisticsManagerSelfConversionListRequest babyStatisticsManagerSelfConversionListRequest) { + String hospitalId; + babyStatisticsManagerSelfConversionListRequest.setOperatorId(((LoginContext) httpServletRequest.getAttribute("loginContext")).getId()); + hospitalId = autoMatchFacade.getHospitalId(babyStatisticsManagerSelfConversionListRequest.getOperatorId()); + String birthDateStart = null; + String birthDateEnd = null; + if (StringUtils.isNotEmpty(babyStatisticsManagerSelfConversionListRequest.getBirthDate())) { + birthDateStart = DateUtil.getyyyy_MM_dd(DateUtil.getSNDate(babyStatisticsManagerSelfConversionListRequest.getBirthDate())[0]); + birthDateEnd = DateUtil.getyyyy_MM_dd(DateUtil.getSNDate(babyStatisticsManagerSelfConversionListRequest.getBirthDate())[1]); + } + String sql = + "SELECT B.PROVINCE_ID," + + "B.PROVINCE," + + "B.CITY_ID," + + "B.CITY," + + "B.AREA_COUNTY_ID," + + "B.AREA_COUNTY," + + "B.HOSPITAL_NO," + + "B.HOSPITAL_NAME," + + "TRUNC(MONTHS_BETWEEN(C.EXAMINE_DATE,A.BIRTHDAY)) AS EXAMINE_MONTH," + + "COUNT(*) AS CNT" + + " FROM ODS_F_INFANT_RECORD A" + + " INNER JOIN ODS_D_HOSPITAL B ON A.HOSPITAL_NO=B.HOSPITAL_NO" + + " LEFT JOIN ODS_F_CHILD_PHYSICAL C ON A.RECORD_ID=C.RECORD_ID AND C.EXAMINE_HISTORY_NUM=1" + + " WHERE A.HOSPITAL_NO=A.BIRTH_HOSPITAL_NO" + + " AND B.YCY_STSTEM_ID='" + hospitalId + "'"; + // 这三个查询条件暂时没用,直接注释掉 + // "AND B.PROVINCE_ID="+ + // "AND B.CITY_ID="+ + // "AND B.AREA_COUNTY_ID="+'2015-01-19','YYYY-MM-DD') + if (StringUtils.isNotEmpty(babyStatisticsManagerSelfConversionListRequest.getBirthDate())) { + sql += " AND A.INSERT_DATE BETWEEN TO_DATE('" + birthDateStart + "','YYYY-MM-DD') AND TO_DATE('" + birthDateEnd + "','YYYY-MM-DD')"; + } + sql += " GROUP BY " + + "B.PROVINCE_ID," + + "B.PROVINCE," + + "B.CITY_ID," + + "B.CITY," + + "B.AREA_COUNTY_ID," + + "B.AREA_COUNTY," + + "B.HOSPITAL_NO," + + "B.HOSPITAL_NAME," + + "TRUNC(MONTHS_BETWEEN(C.EXAMINE_DATE,A.BIRTHDAY))"; + // jdbc查oracle +// List> list = JdbcUtil.getOracleListDataBySql("com.mysql.jdbc.Driver", "jdbc:oracle:thin:@127.0.0.1:1521:orcl", "LYMS_ODS", "Welcome1", sql); + ExceptionUtils.catchException("babyStatisticsManagerSelfConversionList: " + sql); + List> list = JdbcUtil.getOracleListDataBySql("oracle.jdbc.driver.OracleDriver", "jdbc:oracle:thin:@127.0.0.1:1521:orcl", "LYMS_ODS", "Welcome1", sql); + // List> list = new ArrayList<>(); + // Map m1 = new HashMap<>(); + // m1.put("1", "1"); + // m1.put("2", "2"); + // Map m2 = new HashMap<>(); + // m2.put("a", "a"); + // m2.put("b", "b"); + // list.add(m1); + // list.add(m2); + return list; + } + + @TokenRequired + @ResponseBody + @RequestMapping(value = "hujiaqiTest2", method = RequestMethod.POST, consumes = "application/json") + public List> hujiaqiTest2(HttpServletRequest httpServletRequest, BabyStatisticsManagerBuildSourceListRequest babyStatisticsManagerBuildSourceListRequest) { + String hospitalId; + babyStatisticsManagerBuildSourceListRequest.setOperatorId(((LoginContext) httpServletRequest.getAttribute("loginContext")).getId()); + hospitalId = autoMatchFacade.getHospitalId(babyStatisticsManagerBuildSourceListRequest.getOperatorId()); + String buildDateStart = null; + String buildDateEnd = null; + if (StringUtils.isNotEmpty(babyStatisticsManagerBuildSourceListRequest.getBuildDate())) { + buildDateStart = DateUtil.getyyyy_MM_dd(DateUtil.getSNDate(babyStatisticsManagerBuildSourceListRequest.getBuildDate())[0]); + buildDateEnd = DateUtil.getyyyy_MM_dd(DateUtil.getSNDate(babyStatisticsManagerBuildSourceListRequest.getBuildDate())[1]); + } + String sql = + "SELECT B.PROVINCE_ID," + + "B.PROVINCE," + + "B.CITY_ID," + + "B.CITY," + + "B.AREA_COUNTY_ID," + + "B.AREA_COUNTY," + + "B.HOSPITAL_NO," + + "B.HOSPITAL_NAME," + + "A.CHILD_CATEGORY_ID," + + "A.CHILD_CATEGORY," + + "(CASE WHEN A.BIRTH_HOSPITAL_NO=A.HOSPITAL_NO THEN '本院分娩'" + + " WHEN A.BIRTH_HOSPITAL_NO<>A.HOSPITAL_NO AND A.BIRTH_HOSPITAL_NO IS NOT NULL THEN '外院分娩'" + + " WHEN A.BIRTH_HOSPITAL_NO IS NULL THEN '未知'" + + "END) AS LB_NAME," + + "COUNT(*) AS CNT" + + " FROM ODS_F_INFANT_RECORD A" + + " INNER JOIN ODS_D_HOSPITAL B ON A.HOSPITAL_NO=B.HOSPITAL_NO" + + // 医院,判断本院外院使用 + " WHERE B.YCY_STSTEM_ID='" + hospitalId + "'"; + // 这三个查询条件暂时没用,直接注释掉 + // "AND B.PROVINCE_ID=" + + // "AND B.CITY_ID=" + + // "AND B.AREA_COUNTY_ID=" + if (StringUtils.isNotEmpty(babyStatisticsManagerBuildSourceListRequest.getBuildDate())) { + sql += " AND A.INSERT_DATE BETWEEN TO_DATE('" + buildDateStart + "','YYYY-MM-DD') AND TO_DATE('" + buildDateEnd + "','YYYY-MM-DD')"; + } + sql += " GROUP BY " + + "B.PROVINCE_ID," + + "B.PROVINCE," + + "B.CITY_ID," + + "B.CITY," + + "B.AREA_COUNTY_ID," + + "B.AREA_COUNTY," + + "B.HOSPITAL_NO," + + "B.HOSPITAL_NAME," + + "A.CHILD_CATEGORY_ID," + + "A.CHILD_CATEGORY," + + "(CASE WHEN A.BIRTH_HOSPITAL_NO=A.HOSPITAL_NO THEN '本院分娩'" + + "WHEN A.BIRTH_HOSPITAL_NO<>A.HOSPITAL_NO AND A.BIRTH_HOSPITAL_NO IS NOT NULL THEN '外院分娩'" + + "WHEN A.BIRTH_HOSPITAL_NO IS NULL THEN '未知'" + + "END)"; + // jdbc查oracle +// List> list = JdbcUtil.getOracleListDataBySql("com.mysql.jdbc.Driver", "jdbc:oracle:thin:@127.0.0.1:1521:orcl", "LYMS_ODS", "Welcome1", sql); + ExceptionUtils.catchException("babyStatisticsManagerBuildSourceList: " + sql); + List> list = JdbcUtil.getOracleListDataBySql("oracle.jdbc.driver.OracleDriver", "jdbc:oracle:thin:@127.0.0.1:1521:orcl", "LYMS_ODS", "Welcome1", sql); + // List> list = new ArrayList<>(); + // Map m1 = new HashMap<>(); + // m1.put("1", "1"); + // m1.put("2", "2"); + // Map m2 = new HashMap<>(); + // m2.put("a", "a"); + // m2.put("b", "b"); + // list.add(m1); + // list.add(m2); + return list; + } + @TokenRequired @RequestMapping(value = "babyStatisticsManagerBuildSourceListExcel", method = RequestMethod.POST) public void babyStatisticsManagerBuildSourceListExcel(HttpServletRequest httpServletRequest, @RequestBody BabyStatisticsManagerBuildSourceListRequest babyStatisticsManagerBuildSourceListRequest, HttpServletResponse httpServletResponse) { diff --git a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/BabyStatisticsManagerFacade.java b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/BabyStatisticsManagerFacade.java index 6956576..8548677 100644 --- a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/BabyStatisticsManagerFacade.java +++ b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/BabyStatisticsManagerFacade.java @@ -559,7 +559,33 @@ public class BabyStatisticsManagerFacade { // jdbc查oracle // List> list = JdbcUtil.getOracleListDataBySql("com.mysql.jdbc.Driver", "jdbc:oracle:thin:@127.0.0.1:1521:orcl", "LYMS_ODS", "Welcome1", sql); ExceptionUtils.catchException("babyStatisticsManagerBuildSourceList: " + sql); - List> list = JdbcUtil.getOracleListDataBySql("oracle.jdbc.driver.OracleDriver", "jdbc:oracle:thin:@192.168.1.32:1521:orcl", "LYMS_ODS", "Welcome1", sql); + // List> list = JdbcUtil.getOracleListDataBySql("oracle.jdbc.driver.OracleDriver", "jdbc:oracle:thin:@127.0.0.1:1521:orcl", "LYMS_ODS", "Welcome1", sql); + List> list = new ArrayList<>(); + Map m1 = new HashMap<>(); + m1.put("LB_NAME","本院分娩"); + m1.put("CNT",1594); + m1.put("CHILD_CATEGORY_ID",2); + Map m2 = new HashMap<>(); + m2.put("LB_NAME","未知"); + m2.put("CNT",630); + m2.put("CHILD_CATEGORY_ID",2); + Map m3 = new HashMap<>(); + m3.put("LB_NAME","外院分娩"); + m3.put("CNT",2); + m3.put("CHILD_CATEGORY_ID",2); + Map m4 = new HashMap<>(); + m4.put("LB_NAME","本院分娩"); + m4.put("CNT",172); + m4.put("CHILD_CATEGORY_ID",1); + Map m5 = new HashMap<>(); + m5.put("LB_NAME","未知"); + m5.put("CNT",7186); + m5.put("CHILD_CATEGORY_ID",1); + list.add(m1); + list.add(m2); + list.add(m3); + list.add(m4); + list.add(m5); // 构造返回list,这里写死的4条,因为高帆说只有4条 BabyStatisticsManagerBuildSourceListQueryModel babyStatisticsManagerBuildSourceListQueryModel1 = new BabyStatisticsManagerBuildSourceListQueryModel(); babyStatisticsManagerBuildSourceListQueryModel1.setLbName("本院分娩"); @@ -583,26 +609,26 @@ public class BabyStatisticsManagerFacade { String highRiskPercent4 = "-"; if (CollectionUtils.isNotEmpty(list)) { for (Map map : list) { - if ("本院分娩".equals(map.get("lbName"))) { - buildCnt1 += Integer.valueOf(map.get("cnt").toString()); - if ("2".equals(map.get("childCategoryId"))) { - highRiskCnt1 += Integer.valueOf(map.get("cnt").toString()); + if ("本院分娩".equals(map.get("LB_NAME"))) { + buildCnt1 += Integer.valueOf(map.get("CNT").toString()); + if ("2".equals(map.get("CHILD_CATEGORY_ID"))) { + highRiskCnt1 += Integer.valueOf(map.get("CNT").toString()); } - } else if ("外院分娩".equals(map.get("lbName"))) { - buildCnt2 += Integer.valueOf(map.get("cnt").toString()); - if ("2".equals(map.get("childCategoryId"))) { - highRiskCnt2 += Integer.valueOf(map.get("cnt").toString()); + } else if ("外院分娩".equals(map.get("LB_NAME"))) { + buildCnt2 += Integer.valueOf(map.get("CNT").toString()); + if ("2".equals(map.get("CHILD_CATEGORY_ID"))) { + highRiskCnt2 += Integer.valueOf(map.get("CNT").toString()); } - } else if ("未知".equals(map.get("lbName"))) { - buildCnt3 += Integer.valueOf(map.get("cnt").toString()); - if ("2".equals(map.get("childCategoryId"))) { - highRiskCnt3 += Integer.valueOf(map.get("cnt").toString()); + } else if ("未知".equals(map.get("LB_NAME"))) { + buildCnt3 += Integer.valueOf(map.get("CNT").toString()); + if ("2".equals(map.get("CHILD_CATEGORY_ID"))) { + highRiskCnt3 += Integer.valueOf(map.get("CNT").toString()); } } // 总计 - buildCnt4 += Integer.valueOf(map.get("cnt").toString()); - if ("2".equals(map.get("childCategoryId"))) { - highRiskCnt4 += Integer.valueOf(map.get("cnt").toString()); + buildCnt4 += Integer.valueOf(map.get("CNT").toString()); + if ("2".equals(map.get("CHILD_CATEGORY_ID"))) { + highRiskCnt4 += Integer.valueOf(map.get("CNT").toString()); } } highRiskPercent1 = Math.round((double) highRiskCnt1 * 1000 / (double) buildCnt1) / 10.0 + "%"; @@ -693,17 +719,17 @@ public class BabyStatisticsManagerFacade { List> list = JdbcUtil.getOracleListDataBySql("oracle.jdbc.driver.OracleDriver", "jdbc:oracle:thin:@192.168.1.32:1521:orcl", "LYMS_ODS", "Welcome1", sql); // List> list = new ArrayList<>(); // Map test1 = new HashMap<>(); - // test1.put("examineMonth", 2); - // test1.put("cnt", "2"); + // test1.put("EXAMINE_MONTH", 2); + // test1.put("CNT", "2"); // Map test2 = new HashMap<>(); - // test2.put("examineMonth", 3); - // test2.put("cnt", "3"); + // test2.put("EXAMINE_MONTH", 3); + // test2.put("CNT", "3"); // Map test3 = new HashMap<>(); - // test3.put("examineMonth", 1); - // test3.put("cnt", "1"); + // test3.put("EXAMINE_MONTH", 1); + // test3.put("CNT", "1"); // Map test4 = new HashMap<>(); - // test4.put("examineMonth", 0); - // test4.put("cnt", "5"); + // test4.put("EXAMINE_MONTH", 0); + // test4.put("CNT", "5"); // list.add(test1); // list.add(test2); // list.add(test3); @@ -715,12 +741,12 @@ public class BabyStatisticsManagerFacade { int i1; int i2; try { - i1 = Integer.valueOf(o1.get("examineMonth").toString()); + i1 = Integer.valueOf(o1.get("EXAMINE_MONTH").toString()); } catch (Exception e) { i1 = 0; } try { - i2 = Integer.valueOf(o2.get("examineMonth").toString()); + i2 = Integer.valueOf(o2.get("EXAMINE_MONTH").toString()); } catch (Exception e) { i2 = 0; } @@ -742,18 +768,18 @@ public class BabyStatisticsManagerFacade { int index = 0; for (Integer i = 0; i < 12 /*13*/; i++) { // try { -// while (!i.toString().equals(list.get(index).get("examineMonth").toString()) && index > Integer.valueOf(list.get(index).get("examineMonth").toString())) { +// while (!i.toString().equals(list.get(index).get("EXAMINE_MONTH").toString()) && index > Integer.valueOf(list.get(index).get("EXAMINE_MONTH").toString())) { // index++; // } // } catch (Exception e) { // index++; // } -// if (CollectionUtils.isEmpty(list) || list.size() /*< */>index || list.get(index) == null || !i.toString().equals(list.get(index).get("examineMonth").toString())) { +// if (CollectionUtils.isEmpty(list) || list.size() /*< */>index || list.get(index) == null || !i.toString().equals(list.get(index).get("EXAMINE_MONTH").toString())) { // result.add(0); // } else { // try { -// result.add(Integer.valueOf(list.get(index).get("cnt").toString())); -// total += Integer.valueOf(list.get(index).get("cnt").toString()); +// result.add(Integer.valueOf(list.get(index).get("CNT").toString())); +// total += Integer.valueOf(list.get(index).get("CNT").toString()); // index++; // } catch (Exception e) { // result.add(0); @@ -761,12 +787,12 @@ public class BabyStatisticsManagerFacade { // } // } - if (CollectionUtils.isEmpty(list)||i>list.size()-1 || list.get(i) == null || null == list.get(i).get("examineMonth")) { + if (CollectionUtils.isEmpty(list)||i>list.size()-1 || list.get(i) == null || null == list.get(i).get("EXAMINE_MONTH")) { result.add(0); } else { try { - result.add(Integer.valueOf(list.get(i).get("cnt").toString())); - total += Integer.valueOf(list.get(i).get("cnt").toString()); + result.add(Integer.valueOf(list.get(i).get("CNT").toString())); + total += Integer.valueOf(list.get(i).get("CNT").toString()); } catch (Exception e) { result.add(0); } @@ -778,17 +804,17 @@ public class BabyStatisticsManagerFacade { Integer check30 = 0; Integer check36 = 0; for (Map other : list) { - if (null!=other.get("examineMonth")&&"18".equals(other.get("examineMonth").toString())) { - check18 = Integer.valueOf(other.get("cnt").toString()); + if (null!=other.get("EXAMINE_MONTH")&&"18".equals(other.get("EXAMINE_MONTH").toString())) { + check18 = Integer.valueOf(other.get("CNT").toString()); } - if (null!=other.get("examineMonth")&&"24".equals(other.get("examineMonth").toString())) { - check24 = Integer.valueOf(other.get("cnt").toString()); + if (null!=other.get("EXAMINE_MONTH")&&"24".equals(other.get("EXAMINE_MONTH").toString())) { + check24 = Integer.valueOf(other.get("CNT").toString()); } - if (null!=other.get("examineMonth")&&"30".equals(other.get("examineMonth").toString())) { - check30 = Integer.valueOf(other.get("cnt").toString()); + if (null!=other.get("EXAMINE_MONTH")&&"30".equals(other.get("EXAMINE_MONTH").toString())) { + check30 = Integer.valueOf(other.get("CNT").toString()); } - if (null!=other.get("examineMonth")&&"36".equals(other.get("examineMonth").toString())) { - check36 = Integer.valueOf(other.get("cnt").toString()); + if (null!=other.get("EXAMINE_MONTH")&&"36".equals(other.get("EXAMINE_MONTH").toString())) { + check36 = Integer.valueOf(other.get("CNT").toString()); } } result.add(check18);