Commit a0c31c02cd31f72e5b17b902bbb718ff33ba5d53

Authored by jiangjiazhi

Merge remote-tracking branch 'origin/master'

Showing 1 changed file

platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/BabyStatisticsManagerFacade.java View file @ a0c31c0
... ... @@ -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  
... ... @@ -840,105 +819,110 @@
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;
849   - 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++;
  823 +
  824 + int nocheckCount = 0;
  825 + Integer total = 0;
  826 + List<Integer> temp = new LinkedList<>();
  827 + for (Integer i = 0; i < 36; i++) {
  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 || Integer.valueOf(list.get(j).get("EXAMINE_MONTH").toString()) > 36)
  847 + {
  848 + nocheckCount+=Integer.valueOf(list.get(j).get("CNT").toString());
  849 + }
  850 +
  851 + total+=Integer.valueOf(list.get(j).get("CNT").toString());
898 852 }
899   - temp.remove(0);
900 853  
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 854  
  855 + //检查人数
  856 + List<Integer> result = new ArrayList<>();
908 857 // 未检查人数
909 858 List<Integer> resultOther = new ArrayList<>();
910   - for (Integer i : result) {
911   - resultOther.add(total - i);
912   - }
913 859  
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 860  
920   - Integer checkOther = total - result.get(11);
921   -
922 861 List<Integer> babyCount = new ArrayList<>();
  862 +
923 863 List<String> percent = new ArrayList<>();
924 864 babyCount.add(total);
925 865 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 866  
  867 + if (CollectionUtils.isNotEmpty(temp))
  868 + {
  869 + int count = 0;
  870 + for(int i = 0; i < temp.size(); i++)
  871 + {
  872 + count+=temp.get(i);
  873 + if (i < 12)
  874 + {
  875 + resultOther.add(total-count);
  876 + result.add(count);
  877 + if (i == 0)
  878 + {
  879 + babyCount.add(count);
  880 + percent.add(percent(count,total));
  881 + }
  882 + else if (i == 2)
  883 + {
  884 + babyCount.add(count);
  885 + percent.add(percent(count,total));
  886 + }
  887 + else if (i == 5)
  888 + {
  889 + babyCount.add(count);
  890 + percent.add(percent(count,total));
  891 + }
  892 + else if (i == 11)
  893 + {
  894 + babyCount.add(count);
  895 + percent.add(percent(count,total));
  896 + }
  897 + }
  898 + else if (i == 17)
  899 + {
  900 + resultOther.add(total-count);
  901 + result.add(count);
  902 + }
  903 + else if (i == 24)
  904 + {
  905 + resultOther.add(total-count);
  906 + result.add(count);
  907 + }
  908 + else if (i == 29)
  909 + {
  910 + resultOther.add(total-count);
  911 + result.add(count);
  912 + }
  913 + else if (i == 35)
  914 + {
  915 + resultOther.add(total-count);
  916 + result.add(count);
  917 + }
  918 + if (i >= 12)
  919 + {
  920 + nocheckCount+=temp.get(i);
  921 + }
  922 + }
  923 + }
  924 + babyCount.add(nocheckCount);
  925 + percent.add(percent(nocheckCount,total));
942 926 babyStatisticsManagerSelfConversionListResult.setResult(result);
943 927 babyStatisticsManagerSelfConversionListResult.setResultOther(resultOther);
944 928 babyStatisticsManagerSelfConversionListResult.setBabyCount(babyCount);
... ... @@ -947,6 +931,11 @@
947 931 babyStatisticsManagerSelfConversionListResult.setErrorcode(ErrorCodeConstants.SUCCESS);
948 932 babyStatisticsManagerSelfConversionListResult.setErrormsg(ErrorCodeConstants.SUCCESS_DESCRIPTION);
949 933 return babyStatisticsManagerSelfConversionListResult;
  934 + }
  935 +
  936 + private String percent(Integer count,Integer total)
  937 + {
  938 + return new BigDecimal((double) count * 100 / (double) total).setScale(2, BigDecimal.ROUND_HALF_UP) + "%";
950 939 }
951 940 }