Commit 9ca65bcd5948d966e6d8cc13f1cd3cc02d77a0a6
1 parent
25dc5cefcc
Exists in
master
and in
6 other branches
update code
Showing 1 changed file with 86 additions and 102 deletions
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/BabyStatisticsManagerFacade.java
View file @
9ca65bc
... | ... | @@ -777,7 +777,7 @@ |
777 | 777 | // "AND B.CITY_ID="+ |
778 | 778 | // "AND B.AREA_COUNTY_ID="+'2015-01-19','YYYY-MM-DD') |
779 | 779 | if (StringUtils.isNotEmpty(babyStatisticsManagerSelfConversionListRequest.getBirthDate())) { |
780 | - sql += " AND A.INSERT_DATE BETWEEN TO_DATE('" + birthDateStart + "','YYYY-MM-DD') AND TO_DATE('" + birthDateEnd + "','YYYY-MM-DD')"; | |
780 | + sql += " AND A.BIRTHDAY BETWEEN TO_DATE('" + birthDateStart + "','YYYY-MM-DD') AND TO_DATE('" + birthDateEnd + "','YYYY-MM-DD')"; | |
781 | 781 | } |
782 | 782 | sql += " GROUP BY " + |
783 | 783 | "B.PROVINCE_ID," + |
... | ... | @@ -793,27 +793,6 @@ |
793 | 793 | // jdbc查oracle |
794 | 794 | ExceptionUtils.catchException("babyStatisticsManagerSelfConversionList: " + sql); |
795 | 795 | List<Map<String, Object>> list = JdbcUtil.getOracleListDataBySql("oracle.jdbc.driver.OracleDriver", "jdbc:oracle:thin:@127.0.0.1:1521:orcl", "LYMS_ODS", "Welcome1", sql); |
796 | - // List<Map<String, Object>> list = new ArrayList<>(); | |
797 | - // Map<String, Object> test1 = new HashMap<>(); | |
798 | - // Map<String, Object> test2 = new HashMap<>(); | |
799 | - // Map<String, Object> test3 = new HashMap<>(); | |
800 | - // Map<String, Object> test4 = new HashMap<>(); | |
801 | - // Map<String, Object> test5 = new HashMap<>(); | |
802 | - // test4.put("EXAMINE_MONTH", 0); | |
803 | - // test4.put("CNT", "1"); | |
804 | - // test3.put("EXAMINE_MONTH", 1); | |
805 | - // test3.put("CNT", "2"); | |
806 | - // test1.put("EXAMINE_MONTH", 2); | |
807 | - // test1.put("CNT", "3"); | |
808 | - // test2.put("EXAMINE_MONTH", 3); | |
809 | - // test2.put("CNT", "4"); | |
810 | - // test5.put("EXAMINE_MONTH", 12); | |
811 | - // test5.put("CNT", "1"); | |
812 | - // list.add(test1); | |
813 | - // list.add(test2); | |
814 | - // list.add(test3); | |
815 | - // list.add(test4); | |
816 | - // list.add(test5); | |
817 | 796 | |
818 | 797 | Collections.sort(list, new Comparator<Map<String, Object>>() { |
819 | 798 | @Override |
820 | 799 | |
821 | 800 | |
822 | 801 | |
823 | 802 | |
824 | 803 | |
825 | 804 | |
826 | 805 | |
827 | 806 | |
828 | 807 | |
829 | 808 | |
830 | 809 | |
831 | 810 | |
832 | 811 | |
833 | 812 | |
834 | 813 | |
... | ... | @@ -840,105 +819,105 @@ |
840 | 819 | } |
841 | 820 | }); |
842 | 821 | |
843 | - // 检查人数 | |
844 | - List<Integer> temp = new ArrayList<>(); | |
845 | - Integer total = 0; | |
846 | 822 | ExceptionUtils.catchException("babyStatisticsManagerSelfConversionList list result :" + list); |
847 | - // 从0开始,没有也填充 | |
848 | - int index = 0; | |
823 | + | |
824 | + int nocheckCount = 0; | |
825 | + Integer total = 0; | |
826 | + List<Integer> temp = new LinkedList<>(); | |
849 | 827 | for (Integer i = 0; i < 37; i++) { |
850 | - try { | |
851 | - while (!i.toString().equals(list.get(index).get("EXAMINE_MONTH").toString()) && i > Integer.valueOf(list.get(index).get("EXAMINE_MONTH").toString())) { | |
852 | - index++; | |
828 | + if (CollectionUtils.isNotEmpty(list)) | |
829 | + { | |
830 | + int tempCount = 0; | |
831 | + for (int j = 0,len = list.size();j < len ;j++) | |
832 | + { | |
833 | + if (list.get(j).get("EXAMINE_MONTH") != null && Integer.valueOf(list.get(j).get("EXAMINE_MONTH").toString()) == i) | |
834 | + { | |
835 | + tempCount+=Integer.valueOf(list.get(j).get("CNT").toString()); | |
836 | + break; | |
837 | + } | |
853 | 838 | } |
854 | - } catch (Exception e) { | |
855 | - index++; | |
839 | + temp.add(tempCount); | |
856 | 840 | } |
857 | - if (CollectionUtils.isEmpty(list) || list.size() < index) { | |
858 | - temp.add(0); | |
859 | - } else if (list.size() < index && (list.get(index) == null || !i.toString().equals(list.get(index).get("EXAMINE_MONTH").toString()))) { | |
860 | - temp.add(0); | |
861 | - } else { | |
862 | - try { | |
863 | - temp.add(Integer.valueOf(list.get(index).get("CNT").toString())); | |
864 | - total += Integer.valueOf(list.get(index).get("CNT").toString()); | |
865 | - index++; | |
866 | - } catch (Exception e) { | |
867 | - temp.add(0); | |
868 | - index++; | |
869 | - } | |
870 | - } | |
871 | 841 | } |
872 | 842 | |
873 | - // Integer check18 = 0; | |
874 | - // Integer check24 = 0; | |
875 | - // Integer check30 = 0; | |
876 | - // Integer check36 = 0; | |
877 | - // for (Map<String, Object> other : list) { | |
878 | - // if (null != other.get("EXAMINE_MONTH") && "18".equals(other.get("EXAMINE_MONTH").toString())) { | |
879 | - // check18 = Integer.valueOf(other.get("CNT").toString()); | |
880 | - // } | |
881 | - // if (null != other.get("EXAMINE_MONTH") && "24".equals(other.get("EXAMINE_MONTH").toString())) { | |
882 | - // check24 = Integer.valueOf(other.get("CNT").toString()); | |
883 | - // } | |
884 | - // if (null != other.get("EXAMINE_MONTH") && "30".equals(other.get("EXAMINE_MONTH").toString())) { | |
885 | - // check30 = Integer.valueOf(other.get("CNT").toString()); | |
886 | - // } | |
887 | - // if (null != other.get("EXAMINE_MONTH") && "36".equals(other.get("EXAMINE_MONTH").toString())) { | |
888 | - // check36 = Integer.valueOf(other.get("CNT").toString()); | |
889 | - // } | |
890 | - // } | |
891 | - // result.add(check18); | |
892 | - // result.add(check24); | |
893 | - // result.add(check30); | |
894 | - // result.add(check36); | |
895 | 843 | |
896 | - for (int i = 1; i < temp.size(); i++) { | |
897 | - temp.set(i, temp.get(i) + temp.get(i - 1)); | |
844 | + for (int j = 0,len = list.size();j < len ;j++) | |
845 | + { | |
846 | + if (list.get(j).get("EXAMINE_MONTH") == null) | |
847 | + { | |
848 | + nocheckCount+=Integer.valueOf(list.get(j).get("CNT").toString()); | |
849 | + } | |
850 | + total+=Integer.valueOf(list.get(j).get("CNT").toString()); | |
898 | 851 | } |
899 | - temp.remove(0); | |
900 | 852 | |
901 | - List<Integer> result = new ArrayList<>(); | |
902 | - result.addAll(temp.subList(0, 12)); | |
903 | - result.add(temp.get(17)); | |
904 | - result.add(temp.get(23)); | |
905 | - result.add(temp.get(29)); | |
906 | - result.add(temp.get(35)); | |
907 | 853 | |
854 | + //检查人数 | |
855 | + List<Integer> result = new ArrayList<>(); | |
908 | 856 | // 未检查人数 |
909 | 857 | List<Integer> resultOther = new ArrayList<>(); |
910 | - for (Integer i : result) { | |
911 | - resultOther.add(total - i); | |
912 | - } | |
913 | 858 | |
914 | - // 下面的表格 | |
915 | - Integer check1 = result.get(0); | |
916 | - Integer check3 = result.get(2); | |
917 | - Integer check6 = result.get(5); | |
918 | - Integer check12 = result.get(11); | |
919 | 859 | |
920 | - Integer checkOther = total - result.get(11); | |
921 | - | |
922 | 860 | List<Integer> babyCount = new ArrayList<>(); |
861 | + | |
923 | 862 | List<String> percent = new ArrayList<>(); |
924 | 863 | babyCount.add(total); |
925 | 864 | percent.add("100%"); |
926 | - babyCount.add(check1); | |
927 | - // percent.add(Math.round((double) check1 * 100 / (double) total) / 1.00 + "%"); | |
928 | - percent.add(new BigDecimal((double) check1 * 100 / (double) total).setScale(2, BigDecimal.ROUND_HALF_UP) + "%"); | |
929 | - babyCount.add(check3); | |
930 | - // percent.add(Math.round((double) check3 * 100 / (double) total) / 1.00 + "%"); | |
931 | - percent.add(new BigDecimal((double) check3 * 100 / (double) total).setScale(2, BigDecimal.ROUND_HALF_UP) + "%"); | |
932 | - babyCount.add(check6); | |
933 | - // percent.add(Math.round((double) check6 * 100 / (double) total) / 1.00 + "%"); | |
934 | - percent.add(new BigDecimal((double) check6 * 100 / (double) total).setScale(2, BigDecimal.ROUND_HALF_UP) + "%"); | |
935 | - babyCount.add(check12); | |
936 | - // percent.add(Math.round((double) check12 * 100 / (double) total) / 1.00 + "%"); | |
937 | - percent.add(new BigDecimal((double) check12 * 100 / (double) total).setScale(2, BigDecimal.ROUND_HALF_UP) + "%"); | |
938 | - babyCount.add(checkOther); | |
939 | - // percent.add(Math.round((double) checkOther * 100 / (double) total) / 1.00 + "%"); | |
940 | - percent.add(new BigDecimal((double) checkOther * 100 / (double) total).setScale(2, BigDecimal.ROUND_HALF_UP) + "%"); | |
941 | 865 | |
866 | + if (CollectionUtils.isNotEmpty(temp)) | |
867 | + { | |
868 | + int count = 0; | |
869 | + for(int i = 0; i < temp.size(); i++) | |
870 | + { | |
871 | + count+=temp.get(i); | |
872 | + if (i < 12) | |
873 | + { | |
874 | + resultOther.add(total-count); | |
875 | + result.add(count); | |
876 | + if (i == 0) | |
877 | + { | |
878 | + babyCount.add(count); | |
879 | + percent.add(percent(count,total)); | |
880 | + } | |
881 | + else if (i == 2) | |
882 | + { | |
883 | + babyCount.add(count); | |
884 | + percent.add(percent(count,total)); | |
885 | + } | |
886 | + else if (i == 5) | |
887 | + { | |
888 | + babyCount.add(count); | |
889 | + percent.add(percent(count,total)); | |
890 | + } | |
891 | + else if (i == 11) | |
892 | + { | |
893 | + babyCount.add(count); | |
894 | + percent.add(percent(count,total)); | |
895 | + } | |
896 | + } | |
897 | + else if (i == 17) | |
898 | + { | |
899 | + resultOther.add(total-count); | |
900 | + result.add(count); | |
901 | + } | |
902 | + else if (i == 24) | |
903 | + { | |
904 | + resultOther.add(total-count); | |
905 | + result.add(count); | |
906 | + } | |
907 | + else if (i == 29) | |
908 | + { | |
909 | + resultOther.add(total-count); | |
910 | + result.add(count); | |
911 | + } | |
912 | + else if (i == 35) | |
913 | + { | |
914 | + resultOther.add(total-count); | |
915 | + result.add(count); | |
916 | + } | |
917 | + } | |
918 | + } | |
919 | + babyCount.add(nocheckCount); | |
920 | + percent.add(percent(nocheckCount,total)); | |
942 | 921 | babyStatisticsManagerSelfConversionListResult.setResult(result); |
943 | 922 | babyStatisticsManagerSelfConversionListResult.setResultOther(resultOther); |
944 | 923 | babyStatisticsManagerSelfConversionListResult.setBabyCount(babyCount); |
... | ... | @@ -947,6 +926,11 @@ |
947 | 926 | babyStatisticsManagerSelfConversionListResult.setErrorcode(ErrorCodeConstants.SUCCESS); |
948 | 927 | babyStatisticsManagerSelfConversionListResult.setErrormsg(ErrorCodeConstants.SUCCESS_DESCRIPTION); |
949 | 928 | return babyStatisticsManagerSelfConversionListResult; |
929 | + } | |
930 | + | |
931 | + private String percent(Integer count,Integer total) | |
932 | + { | |
933 | + return new BigDecimal((double) count * 100 / (double) total).setScale(2, BigDecimal.ROUND_HALF_UP) + "%"; | |
950 | 934 | } |
951 | 935 | } |