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 89c156a..56fbdd4 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 @@ -374,7 +374,7 @@ public class BabyStatisticsManagerController extends BaseController { // 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:@"+area_count_url+":orcl", "LYMS_ODS", "Welcome1", sql); + List> list = JdbcUtil.getOracleListDataBySql("oracle.jdbc.driver.OracleDriver", "jdbc:oracle:thin:@" + area_count_url + ":orcl", "LYMS_ODS", "Welcome1", sql); // List> list = new ArrayList<>(); // Map m1 = new HashMap<>(); // m1.put("1", "1"); @@ -445,7 +445,7 @@ public class BabyStatisticsManagerController extends BaseController { // 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:@"+area_count_url+":orcl", "LYMS_ODS", "Welcome1", sql); + List> list = JdbcUtil.getOracleListDataBySql("oracle.jdbc.driver.OracleDriver", "jdbc:oracle:thin:@" + area_count_url + ":orcl", "LYMS_ODS", "Welcome1", sql); // List> list = new ArrayList<>(); // Map m1 = new HashMap<>(); // m1.put("1", "1"); @@ -562,4 +562,15 @@ public class BabyStatisticsManagerController extends BaseController { } } + /** + * 儿保统计概率 + */ + @RequestMapping(value = "/babyStatisticalProbability", method = RequestMethod.GET) + @TokenRequired + @ResponseBody + public BaseObjectResponse babyStatisticalProbability(Integer babyMonthAge, HttpServletRequest request) { + + return babyStatisticsManagerFacade.babyStatisticalProbability(babyMonthAge, getUserId(request)); + + } } 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 45ae505..368f299 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 @@ -6,6 +6,7 @@ import com.lyms.platform.biz.service.BasicConfigService; import com.lyms.platform.common.constants.ErrorCodeConstants; import com.lyms.platform.common.enums.SexEnum; import com.lyms.platform.common.enums.YnEnums; +import com.lyms.platform.common.result.BaseObjectResponse; import com.lyms.platform.common.utils.DateUtil; import com.lyms.platform.common.utils.ExceptionUtils; import com.lyms.platform.common.utils.JsonUtil; @@ -639,7 +640,7 @@ public class BabyStatisticsManagerFacade { "END)"; // jdbc查oracle ExceptionUtils.catchException("babyStatisticsManagerBuildSourceList: " + sql); - List> list = JdbcUtil.getOracleListDataBySql("oracle.jdbc.driver.OracleDriver", "jdbc:oracle:thin:@"+area_count_url+":orcl", "LYMS_ODS", "Welcome1", sql); + List> list = JdbcUtil.getOracleListDataBySql("oracle.jdbc.driver.OracleDriver", "jdbc:oracle:thin:@" + area_count_url + ":orcl", "LYMS_ODS", "Welcome1", sql); // List> list = new ArrayList<>(); // Map m1 = new HashMap<>(); // m1.put("LB_NAME", "本院分娩"); @@ -795,7 +796,7 @@ public class BabyStatisticsManagerFacade { // jdbc查oracle ExceptionUtils.catchException("babyStatisticsManagerSelfConversionList: " + sql); - List> list = JdbcUtil.getOracleListDataBySql("oracle.jdbc.driver.OracleDriver", "jdbc:oracle:thin:@"+area_count_url+":orcl", "LYMS_ODS", "Welcome1", sql); + List> list = JdbcUtil.getOracleListDataBySql("oracle.jdbc.driver.OracleDriver", "jdbc:oracle:thin:@" + area_count_url + ":orcl", "LYMS_ODS", "Welcome1", sql); Collections.sort(list, new Comparator>() { @Override @@ -828,14 +829,11 @@ public class BabyStatisticsManagerFacade { Integer total = 0; List temp = new LinkedList<>(); for (Integer i = 0; i < 36; i++) { - if (CollectionUtils.isNotEmpty(list)) - { + if (CollectionUtils.isNotEmpty(list)) { int tempCount = 0; - for (int j = 0,len = list.size();j < len ;j++) - { - if (list.get(j).get("EXAMINE_MONTH") != null && Integer.valueOf(list.get(j).get("EXAMINE_MONTH").toString()) == i) - { - tempCount+=Integer.valueOf(list.get(j).get("CNT").toString()); + for (int j = 0, len = list.size(); j < len; j++) { + if (list.get(j).get("EXAMINE_MONTH") != null && Integer.valueOf(list.get(j).get("EXAMINE_MONTH").toString()) == i) { + tempCount += Integer.valueOf(list.get(j).get("CNT").toString()); break; } } @@ -844,14 +842,12 @@ public class BabyStatisticsManagerFacade { } - for (int j = 0,len = list.size();j < len ;j++) - { - if (list.get(j).get("EXAMINE_MONTH") == null || Integer.valueOf(list.get(j).get("EXAMINE_MONTH").toString()) > 36) - { - nocheckCount+=Integer.valueOf(list.get(j).get("CNT").toString()); + for (int j = 0, len = list.size(); j < len; j++) { + if (list.get(j).get("EXAMINE_MONTH") == null || Integer.valueOf(list.get(j).get("EXAMINE_MONTH").toString()) > 36) { + nocheckCount += Integer.valueOf(list.get(j).get("CNT").toString()); } - total+=Integer.valueOf(list.get(j).get("CNT").toString()); + total += Integer.valueOf(list.get(j).get("CNT").toString()); } @@ -867,66 +863,47 @@ public class BabyStatisticsManagerFacade { babyCount.add(total); percent.add("100%"); - if (CollectionUtils.isNotEmpty(temp)) - { + if (CollectionUtils.isNotEmpty(temp)) { int count = 0; - for(int i = 0; i < temp.size(); i++) - { - count+=temp.get(i); - if (i < 12) - { - resultOther.add(total-count); + for (int i = 0; i < temp.size(); i++) { + count += temp.get(i); + if (i < 12) { + resultOther.add(total - count); result.add(count); - if (i == 0) - { + if (i == 0) { babyCount.add(count); - percent.add(percent(count,total)); - } - else if (i == 2) - { + percent.add(percent(count, total)); + } else if (i == 2) { babyCount.add(count); - percent.add(percent(count,total)); - } - else if (i == 5) - { + percent.add(percent(count, total)); + } else if (i == 5) { babyCount.add(count); - percent.add(percent(count,total)); - } - else if (i == 11) - { + percent.add(percent(count, total)); + } else if (i == 11) { babyCount.add(count); - percent.add(percent(count,total)); + percent.add(percent(count, total)); } - } - else if (i == 17) - { - resultOther.add(total-count); + } else if (i == 17) { + resultOther.add(total - count); result.add(count); - } - else if (i == 24) - { - resultOther.add(total-count); + } else if (i == 24) { + resultOther.add(total - count); result.add(count); - } - else if (i == 29) - { - resultOther.add(total-count); + } else if (i == 29) { + resultOther.add(total - count); result.add(count); - } - else if (i == 35) - { - resultOther.add(total-count); + } else if (i == 35) { + resultOther.add(total - count); result.add(count); } - if (i >= 12) - { - nocheckCount+=temp.get(i); + if (i >= 12) { + nocheckCount += temp.get(i); } } } babyCount.add(nocheckCount); - percent.add(percent(nocheckCount,total)); + percent.add(percent(nocheckCount, total)); babyStatisticsManagerSelfConversionListResult.setResult(result); babyStatisticsManagerSelfConversionListResult.setResultOther(resultOther); @@ -938,13 +915,146 @@ public class BabyStatisticsManagerFacade { return babyStatisticsManagerSelfConversionListResult; } - private String percent(Integer count,Integer total) - { - if (total != null && total == 0) - { + private String percent(Integer count, Integer total) { + if (total != null && total == 0) { return new BigDecimal(0) + "%"; } return new BigDecimal((double) count * 100 / (double) total).setScale(2, BigDecimal.ROUND_HALF_UP) + "%"; } + public BaseObjectResponse babyStatisticalProbability(Integer babyMonthAge, Integer userId) { + String hospitaId = autoMatchFacade.getHospitalId(userId); + Map data = new HashMap<>(); + BabyModelQuery babyQuery = new BabyModelQuery(); + babyQuery.setHospitalId(hospitaId); + babyQuery.setYn(YnEnums.YES.getId()); + if (null != babyMonthAge) { + Date currentDate = DateUtil.formatDate(new Date()); + Date start = DateUtil.addMonth(currentDate, -babyMonthAge); + babyQuery.setBirthEnd(start); + Date end = DateUtil.addDay(DateUtil.addMonth(currentDate, -babyMonthAge - 1), 1); + babyQuery.setBirthStart(end); + List babyModels = babyService.queryBabyWithQuery(babyQuery); + BabyCheckModelQuery babyCheckModelQuery = new BabyCheckModelQuery(); + BabyCheckModelQuery babyCheckQuery = new BabyCheckModelQuery(); + //只查询1月龄做过检查的人数 + babyCheckQuery.setCheckMonth(1); + babyCheckQuery.setYn(YnEnums.YES.getId()); + babyCheckModelQuery.setYn(YnEnums.YES.getId()); + int probabilityCount = 0; + int managementRateChechkCount = 0; + if (CollectionUtils.isNotEmpty(babyModels)) { + for (BabyModel baby : babyModels) { + babyCheckModelQuery.setBuildId(baby.getId()); + int checkCount = babyCheckService.queryBabyCheckCount(babyCheckModelQuery); + //正常 + if (null == baby.getHighRisk() || baby.getHighRisk() != 1) { + if (babyMonthAge >= 1 && babyMonthAge <= 2 && checkCount >= 1) { + probabilityCount++; + } else if (babyMonthAge >= 3 && babyMonthAge <= 5 && checkCount >= 2) { + probabilityCount++; + } else if (babyMonthAge >= 6 && babyMonthAge <= 7 && checkCount >= 3) { + probabilityCount++; + } else if (babyMonthAge >= 8 && babyMonthAge <= 11 && checkCount >= 4) { + probabilityCount++; + } else if (babyMonthAge >= 12 && checkCount >= 5) { + } + //高儿计算规则 + } else { + if (babyMonthAge == 1 && checkCount >= 1) { + probabilityCount++; + } else if (babyMonthAge == 2 && checkCount >= 2) { + probabilityCount++; + } else if (babyMonthAge == 3 && checkCount >= 3) { + probabilityCount++; + } else if (babyMonthAge == 4 && checkCount >= 4) { + probabilityCount++; + } else if (babyMonthAge == 5 && checkCount >= 5) { + probabilityCount++; + } else if (babyMonthAge >= 6 && babyMonthAge <= 7 && checkCount >= 6) { + probabilityCount++; + } else if (babyMonthAge >= 8 && babyMonthAge <= 9 && checkCount >= 7) { + probabilityCount++; + } else if (babyMonthAge >= 10 && babyMonthAge <= 11 && checkCount >= 8) { + probabilityCount++; + } else if (babyMonthAge >= 12 && babyMonthAge <= 14 && checkCount >= 9) { + probabilityCount++; + } else if (babyMonthAge >= 15 && babyMonthAge <= 17 && checkCount >= 10) { + probabilityCount++; + } else if (babyMonthAge >= 18 && babyMonthAge <= 20 && checkCount >= 11) { + probabilityCount++; + } else if (babyMonthAge >= 21 && babyMonthAge <= 23 && checkCount >= 12) { + probabilityCount++; + } else if (babyMonthAge >= 24 && checkCount >= 13) { + probabilityCount++; + } + } + /**总管理率统计**/ + babyCheckQuery.setBuildId(baby.getId()); + int RateChechkCount = babyCheckService.queryBabyCheckCount(babyCheckQuery); + if (RateChechkCount != 0) { + managementRateChechkCount++; + } + } + } + data.put("standardCheckCount", probabilityCount); + data.put("standardTotalnumber", babyModels.size()); + data.put("standardPercentage", percent(probabilityCount, babyModels.size())); + data.put("managementRateChechkCount", managementRateChechkCount); + data.put("managementRateCount", babyModels.size()); + data.put("managementRatePercentage", percent(managementRateChechkCount, babyModels.size())); + } + return new BaseObjectResponse().setData(data); + + } + + /*** + *type 0表示正常 1表示高危 + */ + public void calculationRules(int checkCount, Integer babyMonthAge, Integer type, int probabilityCount) { + //正常儿童 + if (type == 1) { + if (babyMonthAge >= 1 && babyMonthAge <= 2 && checkCount >= 1) { + probabilityCount++; + } else if (babyMonthAge >= 3 && babyMonthAge <= 5 && checkCount >= 2) { + probabilityCount++; + } else if (babyMonthAge >= 6 && babyMonthAge <= 7 && checkCount >= 3) { + probabilityCount++; + } else if (babyMonthAge >= 8 && babyMonthAge <= 11 && checkCount >= 4) { + probabilityCount++; + } else if (babyMonthAge >= 12 && checkCount >= 5) { + + } + //高危儿 + } else if (type == 2) { + if (babyMonthAge == 1 && checkCount >= 1) { + probabilityCount++; + } else if (babyMonthAge == 2 && checkCount >= 2) { + probabilityCount++; + } else if (babyMonthAge == 3 && checkCount >= 3) { + probabilityCount++; + } else if (babyMonthAge == 4 && checkCount >= 4) { + probabilityCount++; + } else if (babyMonthAge == 5 && checkCount >= 5) { + probabilityCount++; + } else if (babyMonthAge >= 6 && babyMonthAge <= 7 && checkCount >= 6) { + probabilityCount++; + } else if (babyMonthAge >= 8 && babyMonthAge <= 9 && checkCount >= 7) { + probabilityCount++; + } else if (babyMonthAge >= 10 && babyMonthAge <= 11 && checkCount >= 8) { + probabilityCount++; + } else if (babyMonthAge >= 12 && babyMonthAge <= 14 && checkCount >= 9) { + probabilityCount++; + } else if (babyMonthAge >= 15 && babyMonthAge <= 17 && checkCount >= 10) { + probabilityCount++; + } else if (babyMonthAge >= 18 && babyMonthAge <= 20 && checkCount >= 11) { + probabilityCount++; + } else if (babyMonthAge >= 21 && babyMonthAge <= 23 && checkCount >= 12) { + probabilityCount++; + } else if (babyMonthAge >= 24 && checkCount >= 13) { + probabilityCount++; + } + } + } + }