Commit 2105f54ed3467fcd4091c08524f4768eeb363bad
1 parent
ce78196f
营运出车率 去掉了sql的group by
Showing
1 changed file
with
49 additions
and
20 deletions
src/main/java/com/bsth/service/forms/impl/FormsServiceImpl.java
| ... | ... | @@ -735,6 +735,7 @@ public class FormsServiceImpl implements FormsService { |
| 735 | 735 | @Override |
| 736 | 736 | public List<Turnoutrate> turnoutrate(Map<String, Object> map) { |
| 737 | 737 | |
| 738 | + List<Turnoutrate> resList = new ArrayList<Turnoutrate>(); | |
| 738 | 739 | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); |
| 739 | 740 | SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy年MM月dd日"); |
| 740 | 741 | Date d = null; |
| ... | ... | @@ -752,22 +753,24 @@ public class FormsServiceImpl implements FormsService { |
| 752 | 753 | rq = rq2 + "-" + rq3; |
| 753 | 754 | |
| 754 | 755 | String sql = " select b.xlgs, a.gs_bm,a.gs_name, a.fgs_bm,a.fgs_name , a.xl_bm,b.sbc,b.sxl,b.scl,a.jbc ,a.jxl ,a.jcl,a.gslsbm,a.fgsbm,b.warrant_car,a.bc_type from " |
| 755 | - + " (select count(DISTINCT gs_bm) gslsbm, gs_bm, count(DISTINCT fgs_bm) fgsbm,fgs_bm,gs_name,fgs_name ,xl_bm, count(*) as jbc,COUNT(DISTINCT xl_bm) as jxl ,COUNT(DISTINCT cl_zbh) as jcl,bc_type" | |
| 756 | - + " from bsth_c_s_sp_info" + " where DATE_FORMAT(schedule_date,'%Y-%m-%d') BETWEEN '"+ map.get("startDate").toString() + "' " | |
| 756 | + + " (select count(DISTINCT gs_bm) gslsbm, gs_bm, count(DISTINCT fgs_bm) fgsbm,fgs_bm,gs_name,fgs_name ,xl_bm, count(*) as jbc,COUNT(DISTINCT xl_bm) as jxl ,COUNT(DISTINCT cl_zbh) as jcl,bc_type" | |
| 757 | + + " from bsth_c_s_sp_info" + " where DATE_FORMAT(schedule_date,'%Y-%m-%d') BETWEEN '"+ map.get("startDate").toString() + "' " | |
| 757 | 758 | + " and '" + map.get("endDate").toString() + "' and xl_bm='"+ map.get("line").toString() + "' " |
| 758 | 759 | + " AND gs_bm is not null " |
| 759 | 760 | + " AND bc_type NOT IN ('in', 'out')" |
| 760 | 761 | + " and gs_bm='"+ map.get("gsdmTurn").toString() + "'" |
| 761 | 762 | + " and fgs_bm='"+ map.get("fgsdmTurn").toString() + "'" |
| 762 | - + " GROUP BY gs_bm,fgs_bm,xl_bm,gs_name,fgs_name,bc_type ) a left JOIN (" | |
| 763 | +// + " GROUP BY gs_bm,fgs_bm,xl_bm,gs_name,fgs_name,bc_type " | |
| 764 | + + " ) a left JOIN (" | |
| 763 | 765 | + " SELECT COUNT(*) as xlgs,b.gs_bm,b.fgs_bm,b.xl_bm,b.gs_name,b.fgs_name, b.sbc,b.sxl ,b.scl,t.warrant_car " |
| 764 | - + " from bsth_c_line t RIGHT JOIN (select gs_bm,fgs_bm,xl_bm,gs_name,fgs_name, count(*) as sbc,COUNT(DISTINCT xl_bm) as sxl ,COUNT(DISTINCT cl_zbh) as scl,bc_type from bsth_c_s_sp_info_real " | |
| 766 | + + " from bsth_c_line t RIGHT JOIN (select gs_bm,fgs_bm,xl_bm,gs_name,fgs_name, count(*) as sbc,COUNT(DISTINCT xl_bm) as sxl ,COUNT(DISTINCT cl_zbh) as scl,bc_type from bsth_c_s_sp_info_real " | |
| 765 | 767 | + " where DATE_FORMAT(schedule_date,'%Y-%m-%d') BETWEEN '" + map.get("startDate").toString() + "' and '" |
| 766 | 768 | + map.get("endDate").toString() + "' and xl_bm='" + map.get("line").toString() |
| 767 | 769 | + "' AND gs_bm is not null " |
| 768 | 770 | + " AND bc_type NOT IN ('in', 'out')" |
| 769 | - + "GROUP BY gs_bm,fgs_bm,xl_bm,gs_name,fgs_name,bc_type) b ON t.company=b.gs_bm and t.branche_company = b.fgs_bm) b on " | |
| 770 | - + " a.gs_bm=b.gs_bm and a.fgs_bm=b.fgs_bm and a.xl_bm=b.xl_bm "; | |
| 771 | +// + " GROUP BY gs_bm,fgs_bm,xl_bm,gs_name,fgs_name,bc_type " | |
| 772 | + + " ) b ON t.company=b.gs_bm and t.branche_company = b.fgs_bm) b on " | |
| 773 | + + " a.gs_bm=b.gs_bm and a.fgs_bm=b.fgs_bm and a.xl_bm=b.xl_bm "; | |
| 771 | 774 | List<Turnoutrate> list = jdbcTemplate.query(sql, new RowMapper<Turnoutrate>() { |
| 772 | 775 | |
| 773 | 776 | @Override |
| ... | ... | @@ -782,6 +785,8 @@ public class FormsServiceImpl implements FormsService { |
| 782 | 785 | String result1 = numberFormat.format((float) scl / (float) jcl * 100); |
| 783 | 786 | String result2 = numberFormat.format((float) sbc / (float) jbc * 100); |
| 784 | 787 | tu.setRq(rq); |
| 788 | + if(arg0.getString("gs_name") == null || arg0.getString("gs_name").trim().length() == 0) | |
| 789 | + return tu; | |
| 785 | 790 | tu.setGs(arg0.getString("gs_name").toString()); |
| 786 | 791 | tu.setZhgs(arg0.getString("fgs_name").toString()); |
| 787 | 792 | // tu.setXl(arg0.getString("xlgs")!=null&&arg0.getString("xlgs").trim().length()!=0?arg0.getString("xlgs"):"0"); |
| ... | ... | @@ -801,14 +806,20 @@ public class FormsServiceImpl implements FormsService { |
| 801 | 806 | } |
| 802 | 807 | |
| 803 | 808 | }); |
| 809 | + | |
| 810 | + for(Turnoutrate t : list){ | |
| 811 | + if(t.getGs() != null && t.getGs().trim().length() != 0) | |
| 812 | + resList.add(t); | |
| 813 | + } | |
| 804 | 814 | |
| 805 | - return list; | |
| 815 | + return resList; | |
| 806 | 816 | } |
| 807 | 817 | |
| 808 | 818 | |
| 809 | 819 | //班次执行率统计表 |
| 810 | 820 | @Override |
| 811 | 821 | public List<Executionrate> executionrate(Map<String, Object> map) { |
| 822 | + List<Executionrate> resList = new ArrayList<Executionrate>(); | |
| 812 | 823 | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); |
| 813 | 824 | SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy年MM月dd日"); |
| 814 | 825 | Date d = null; |
| ... | ... | @@ -826,20 +837,22 @@ public class FormsServiceImpl implements FormsService { |
| 826 | 837 | rq = rq2 + "-" + rq3; |
| 827 | 838 | |
| 828 | 839 | String sql = " select b.xlgs, a.gs_bm,a.gs_name, a.fgs_bm,a.fgs_name , a.xl_bm,b.xl_name,b.sbc,b.sxl,b.scl,a.jbc ,a.jxl ,a.jcl,a.gslsbm,a.fgsbm,a.bc_type from " |
| 829 | - + " (select count(DISTINCT gs_bm) gslsbm, gs_bm, count(DISTINCT fgs_bm) fgsbm,fgs_bm,gs_name,fgs_name ,xl_bm, count(*) as jbc,COUNT(DISTINCT xl_bm) as jxl ,COUNT(DISTINCT cl_zbh) as jcl,bc_type" | |
| 830 | - + " from bsth_c_s_sp_info" + " where DATE_FORMAT(schedule_date,'%Y-%m-%d') BETWEEN '" | |
| 840 | + + " (select count(DISTINCT gs_bm) gslsbm, gs_bm, count(DISTINCT fgs_bm) fgsbm,fgs_bm,gs_name,fgs_name ,xl_bm, count(*) as jbc,COUNT(DISTINCT xl_bm) as jxl ,COUNT(DISTINCT cl_zbh) as jcl,bc_type" | |
| 841 | + + " from bsth_c_s_sp_info" + " where DATE_FORMAT(schedule_date,'%Y-%m-%d') BETWEEN '" | |
| 831 | 842 | + map.get("startDate").toString() + "' and '" + map.get("endDate").toString() + "' and xl_bm='" |
| 832 | 843 | + map.get("line").toString() + "' AND gs_bm is not null AND bc_type NOT IN ('in', 'out')" |
| 833 | 844 | + " and gs_bm='"+ map.get("gsdmEcecut").toString() + "'" |
| 834 | 845 | + " and fgs_bm='"+ map.get("fgsdmEcecut").toString() + "'" |
| 835 | - + " GROUP BY gs_bm,fgs_bm,xl_bm,gs_name,fgs_name,bc_type ) a left JOIN (" | |
| 846 | +// + " GROUP BY gs_bm,fgs_bm,xl_bm,gs_name,fgs_name,bc_type " | |
| 847 | + + " ) a left JOIN (" | |
| 836 | 848 | + "SELECT COUNT(*) as xlgs,b.gs_bm,b.fgs_bm,b.xl_bm,b.xl_name,b.gs_name,b.fgs_name, b.sbc,b.sxl ,b.scl " |
| 837 | 849 | + "from bsth_c_line t RIGHT JOIN (select gs_bm,fgs_bm,xl_bm,xl_name,gs_name,fgs_name, count(*) as sbc,COUNT(DISTINCT xl_bm) as sxl ,COUNT(DISTINCT cl_zbh) as scl,bc_type from bsth_c_s_sp_info_real " |
| 838 | 850 | + "where DATE_FORMAT(schedule_date,'%Y-%m-%d') BETWEEN '" + map.get("startDate").toString() + "' and '" |
| 839 | 851 | + map.get("endDate").toString() + "' and xl_bm='" + map.get("line").toString() |
| 840 | 852 | + "' AND gs_bm is not null AND bc_type NOT IN ('in', 'out') " |
| 841 | - + "GROUP BY gs_bm,fgs_bm,xl_bm,gs_name,fgs_name,bc_type) b ON t.company=b.gs_bm and t.branche_company = b.fgs_bm) b on " | |
| 842 | - + " a.gs_bm=b.gs_bm and a.fgs_bm=b.fgs_bm and a.xl_bm=b.xl_bm "; | |
| 853 | +// + " GROUP BY gs_bm,fgs_bm,xl_bm,gs_name,fgs_name,bc_type" | |
| 854 | + + " ) b ON t.company=b.gs_bm and t.branche_company = b.fgs_bm) b on " | |
| 855 | + + " a.gs_bm=b.gs_bm and a.fgs_bm=b.fgs_bm and a.xl_bm=b.xl_bm "; | |
| 843 | 856 | List<Executionrate> list = jdbcTemplate.query(sql, new RowMapper<Executionrate>() { |
| 844 | 857 | |
| 845 | 858 | @Override |
| ... | ... | @@ -854,6 +867,8 @@ public class FormsServiceImpl implements FormsService { |
| 854 | 867 | String result1 = numberFormat.format((float) scl / (float) jcl * 100); |
| 855 | 868 | String result2 = numberFormat.format((float) sbc / (float) jbc * 100); |
| 856 | 869 | tu.setRq(rq); |
| 870 | + if(arg0.getString("gs_name") == null || arg0.getString("gs_name").trim().length() == 0) | |
| 871 | + return tu; | |
| 857 | 872 | tu.setGs(arg0.getString("gs_name").toString()); |
| 858 | 873 | tu.setZhgs(arg0.getString("fgs_name").toString()); |
| 859 | 874 | // tu.setXl(arg0.getString("xlgs")!=null&&arg0.getString("xlgs").trim().length()!=0?arg0.getString("xlgs"):"0");//这个是根据公司判断线路有几条 |
| ... | ... | @@ -874,13 +889,19 @@ public class FormsServiceImpl implements FormsService { |
| 874 | 889 | } |
| 875 | 890 | |
| 876 | 891 | }); |
| 892 | + | |
| 893 | + for(Executionrate e : list){ | |
| 894 | + if(e.getGs() != null && e.getGs().trim().length() != 0) | |
| 895 | + resList.add(e); | |
| 896 | + } | |
| 877 | 897 | |
| 878 | - return list; | |
| 898 | + return resList; | |
| 879 | 899 | } |
| 880 | 900 | |
| 881 | 901 | // 营运线路名称统计表 |
| 882 | 902 | @Override |
| 883 | 903 | public List<Allline> allline(Map<String, Object> map) { |
| 904 | + List<Allline> resList = new ArrayList<Allline>(); | |
| 884 | 905 | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); |
| 885 | 906 | SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy年MM月dd日"); |
| 886 | 907 | Date d = null; |
| ... | ... | @@ -900,13 +921,14 @@ public class FormsServiceImpl implements FormsService { |
| 900 | 921 | rq = rq2 + "-" + rq3; |
| 901 | 922 | |
| 902 | 923 | String sql = " select b.xlgs, a.gs_bm,a.gs_name, a.fgs_bm,a.fgs_name , a.xl_bm,b.xl_name,b.sbc,b.sxl,b.scl,a.jbc ,a.jxl ,a.jcl,a.gslsbm,a.fgsbm,a.bc_type from " |
| 903 | - + " (select count(DISTINCT gs_bm) gslsbm, gs_bm, count(DISTINCT fgs_bm) fgsbm,fgs_bm,gs_name,fgs_name ,xl_bm, count(*) as jbc,COUNT(DISTINCT xl_bm) as jxl ,COUNT(DISTINCT cl_zbh) as jcl,bc_type" | |
| 904 | - + " from bsth_c_s_sp_info" + " where DATE_FORMAT(schedule_date,'%Y-%m-%d') BETWEEN '" | |
| 924 | + + " (select count(DISTINCT gs_bm) gslsbm, gs_bm, count(DISTINCT fgs_bm) fgsbm,fgs_bm,gs_name,fgs_name ,xl_bm, count(*) as jbc,COUNT(DISTINCT xl_bm) as jxl ,COUNT(DISTINCT cl_zbh) as jcl,bc_type" | |
| 925 | + + " from bsth_c_s_sp_info" + " where DATE_FORMAT(schedule_date,'%Y-%m-%d') BETWEEN '" | |
| 905 | 926 | + map.get("startDate").toString() + "' and '" + map.get("endDate").toString() + "' and xl_bm='" |
| 906 | 927 | + map.get("line").toString() + "' AND gs_bm is not null AND bc_type NOT IN ('in', 'out') " |
| 907 | 928 | + " and gs_bm='"+ map.get("gsdmAllline").toString() + "'" |
| 908 | 929 | + " and fgs_bm='"+ map.get("fgsdmAllline").toString() + "'" |
| 909 | - + " GROUP BY gs_bm,fgs_bm,xl_bm,gs_name,fgs_name,bc_type ) a left JOIN (" | |
| 930 | +// + " GROUP BY gs_bm,fgs_bm,xl_bm,gs_name,fgs_name,bc_type " | |
| 931 | + + " ) a left JOIN (" | |
| 910 | 932 | + "SELECT COUNT(*" |
| 911 | 933 | + ") as xlgs,b.gs_bm,b.fgs_bm,b.xl_bm,b." |
| 912 | 934 | + "xl_name,b.gs_name,b.fgs_name, b.sbc,b.sxl ,b.scl " |
| ... | ... | @@ -915,9 +937,9 @@ public class FormsServiceImpl implements FormsService { |
| 915 | 937 | + map.get("endDate").toString() + "' and xl_bm='" + map.get |
| 916 | 938 | ("line").toString() |
| 917 | 939 | + "' AND gs_bm is not null AND bc_type NOT IN ('in', 'out')" |
| 918 | - + "GROUP BY gs_bm,fgs_bm,xl_bm,gs_name,fgs_name,bc_type) b ON t.company=b.gs_bm and t.branche_company = b.fgs_bm) b on " | |
| 919 | - + " a.gs_bm=b.gs_bm and a.fgs_bm=b.fgs_bm and a.xl_bm=b.xl_bm "; | |
| 920 | - System.out.println(sql); | |
| 940 | +// + " GROUP BY gs_bm,fgs_bm,xl_bm,gs_name,fgs_name,bc_type" | |
| 941 | + + " ) b ON t.company=b.gs_bm and t.branche_company = b.fgs_bm) b on " | |
| 942 | + + " a.gs_bm=b.gs_bm and a.fgs_bm=b.fgs_bm and a.xl_bm=b.xl_bm "; | |
| 921 | 943 | List<Allline> list = jdbcTemplate.query(sql, new RowMapper<Allline>() { |
| 922 | 944 | |
| 923 | 945 | @Override |
| ... | ... | @@ -932,6 +954,8 @@ public class FormsServiceImpl implements FormsService { |
| 932 | 954 | String result1 = numberFormat.format((float) scl / (float) jcl * 100); |
| 933 | 955 | String result2 = numberFormat.format((float) sbc / (float) jbc * 100); |
| 934 | 956 | tu.setRq(rq); |
| 957 | + if(arg0.getString("gs_name") == null || arg0.getString("gs_name").trim().length() == 0) | |
| 958 | + return tu; | |
| 935 | 959 | tu.setGs(arg0.getString("gs_name").toString()); |
| 936 | 960 | tu.setZhgs(arg0.getString("fgs_name").toString()); |
| 937 | 961 | tu.setXl(arg0.getString("xl_name")); |
| ... | ... | @@ -951,7 +975,12 @@ public class FormsServiceImpl implements FormsService { |
| 951 | 975 | } |
| 952 | 976 | }); |
| 953 | 977 | |
| 954 | - return list; | |
| 978 | + for(Allline a : list){ | |
| 979 | + if(a.getGs() != null && a.getGs().trim().length() != 0) | |
| 980 | + resList.add(a); | |
| 981 | + } | |
| 982 | + | |
| 983 | + return resList; | |
| 955 | 984 | } |
| 956 | 985 | |
| 957 | 986 | @Override | ... | ... |