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 8fa1ce6..f8fd47d 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 @@ -777,7 +777,7 @@ public class BabyStatisticsManagerFacade { // "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 += " AND A.BIRTHDAY BETWEEN TO_DATE('" + birthDateStart + "','YYYY-MM-DD') AND TO_DATE('" + birthDateEnd + "','YYYY-MM-DD')"; } sql += " GROUP BY " + "B.PROVINCE_ID," + @@ -793,27 +793,6 @@ public class BabyStatisticsManagerFacade { // jdbc查oracle 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 test1 = new HashMap<>(); - // Map test2 = new HashMap<>(); - // Map test3 = new HashMap<>(); - // Map test4 = new HashMap<>(); - // Map test5 = new HashMap<>(); - // test4.put("EXAMINE_MONTH", 0); - // test4.put("CNT", "1"); - // test3.put("EXAMINE_MONTH", 1); - // test3.put("CNT", "2"); - // test1.put("EXAMINE_MONTH", 2); - // test1.put("CNT", "3"); - // test2.put("EXAMINE_MONTH", 3); - // test2.put("CNT", "4"); - // test5.put("EXAMINE_MONTH", 12); - // test5.put("CNT", "1"); - // list.add(test1); - // list.add(test2); - // list.add(test3); - // list.add(test4); - // list.add(test5); Collections.sort(list, new Comparator>() { @Override @@ -840,105 +819,105 @@ public class BabyStatisticsManagerFacade { } }); - // 检查人数 - List temp = new ArrayList<>(); - Integer total = 0; ExceptionUtils.catchException("babyStatisticsManagerSelfConversionList list result :" + list); - // 从0开始,没有也填充 - int index = 0; + + int nocheckCount = 0; + Integer total = 0; + List temp = new LinkedList<>(); for (Integer i = 0; i < 37; i++) { - try { - while (!i.toString().equals(list.get(index).get("EXAMINE_MONTH").toString()) && i > Integer.valueOf(list.get(index).get("EXAMINE_MONTH").toString())) { - index++; - } - } catch (Exception e) { - index++; - } - if (CollectionUtils.isEmpty(list) || list.size() < index) { - temp.add(0); - } else if (list.size() < index && (list.get(index) == null || !i.toString().equals(list.get(index).get("EXAMINE_MONTH").toString()))) { - temp.add(0); - } else { - try { - temp.add(Integer.valueOf(list.get(index).get("CNT").toString())); - total += Integer.valueOf(list.get(index).get("CNT").toString()); - index++; - } catch (Exception e) { - temp.add(0); - index++; + 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()); + break; + } } + temp.add(tempCount); } } - // Integer check18 = 0; - // Integer check24 = 0; - // Integer check30 = 0; - // Integer check36 = 0; - // for (Map other : list) { - // if (null != other.get("EXAMINE_MONTH") && "18".equals(other.get("EXAMINE_MONTH").toString())) { - // check18 = 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("EXAMINE_MONTH") && "30".equals(other.get("EXAMINE_MONTH").toString())) { - // check30 = 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); - // result.add(check24); - // result.add(check30); - // result.add(check36); - for (int i = 1; i < temp.size(); i++) { - temp.set(i, temp.get(i) + temp.get(i - 1)); + for (int j = 0,len = list.size();j < len ;j++) + { + if (list.get(j).get("EXAMINE_MONTH") == null) + { + nocheckCount+=Integer.valueOf(list.get(j).get("CNT").toString()); + } + total+=Integer.valueOf(list.get(j).get("CNT").toString()); } - temp.remove(0); - List result = new ArrayList<>(); - result.addAll(temp.subList(0, 12)); - result.add(temp.get(17)); - result.add(temp.get(23)); - result.add(temp.get(29)); - result.add(temp.get(35)); + //检查人数 + List result = new ArrayList<>(); // 未检查人数 List resultOther = new ArrayList<>(); - for (Integer i : result) { - resultOther.add(total - i); - } - // 下面的表格 - Integer check1 = result.get(0); - Integer check3 = result.get(2); - Integer check6 = result.get(5); - Integer check12 = result.get(11); - - Integer checkOther = total - result.get(11); List babyCount = new ArrayList<>(); + List percent = new ArrayList<>(); babyCount.add(total); percent.add("100%"); - babyCount.add(check1); - // percent.add(Math.round((double) check1 * 100 / (double) total) / 1.00 + "%"); - percent.add(new BigDecimal((double) check1 * 100 / (double) total).setScale(2, BigDecimal.ROUND_HALF_UP) + "%"); - babyCount.add(check3); - // percent.add(Math.round((double) check3 * 100 / (double) total) / 1.00 + "%"); - percent.add(new BigDecimal((double) check3 * 100 / (double) total).setScale(2, BigDecimal.ROUND_HALF_UP) + "%"); - babyCount.add(check6); - // percent.add(Math.round((double) check6 * 100 / (double) total) / 1.00 + "%"); - percent.add(new BigDecimal((double) check6 * 100 / (double) total).setScale(2, BigDecimal.ROUND_HALF_UP) + "%"); - babyCount.add(check12); - // percent.add(Math.round((double) check12 * 100 / (double) total) / 1.00 + "%"); - percent.add(new BigDecimal((double) check12 * 100 / (double) total).setScale(2, BigDecimal.ROUND_HALF_UP) + "%"); - babyCount.add(checkOther); - // percent.add(Math.round((double) checkOther * 100 / (double) total) / 1.00 + "%"); - percent.add(new BigDecimal((double) checkOther * 100 / (double) total).setScale(2, BigDecimal.ROUND_HALF_UP) + "%"); + 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); + result.add(count); + if (i == 0) + { + babyCount.add(count); + percent.add(percent(count,total)); + } + else if (i == 2) + { + babyCount.add(count); + percent.add(percent(count,total)); + } + else if (i == 5) + { + babyCount.add(count); + percent.add(percent(count,total)); + } + else if (i == 11) + { + babyCount.add(count); + percent.add(percent(count,total)); + } + } + else if (i == 17) + { + resultOther.add(total-count); + result.add(count); + } + else if (i == 24) + { + resultOther.add(total-count); + result.add(count); + } + else if (i == 29) + { + resultOther.add(total-count); + result.add(count); + } + else if (i == 35) + { + resultOther.add(total-count); + result.add(count); + } + } + } + babyCount.add(nocheckCount); + percent.add(percent(nocheckCount,total)); babyStatisticsManagerSelfConversionListResult.setResult(result); babyStatisticsManagerSelfConversionListResult.setResultOther(resultOther); babyStatisticsManagerSelfConversionListResult.setBabyCount(babyCount); @@ -948,4 +927,9 @@ public class BabyStatisticsManagerFacade { babyStatisticsManagerSelfConversionListResult.setErrormsg(ErrorCodeConstants.SUCCESS_DESCRIPTION); return babyStatisticsManagerSelfConversionListResult; } + + private String percent(Integer count,Integer total) + { + return new BigDecimal((double) count * 100 / (double) total).setScale(2, BigDecimal.ROUND_HALF_UP) + "%"; + } }