Commit 7f04b45697aed89c92ed29941d7994bf8c9b035e
Merge branch 'minhang' of http://222.66.0.204:8090/panzhaov5/bsth_control into minhang
Showing
2 changed files
with
432 additions
and
4 deletions
src/main/java/com/bsth/service/schedule/PeopleCarPlanServiceImpl.java
| ... | ... | @@ -5,6 +5,7 @@ import java.net.URLEncoder; |
| 5 | 5 | import java.sql.ResultSet; |
| 6 | 6 | import java.sql.SQLException; |
| 7 | 7 | import java.text.DecimalFormat; |
| 8 | +import java.text.NumberFormat; | |
| 8 | 9 | import java.text.ParseException; |
| 9 | 10 | import java.text.SimpleDateFormat; |
| 10 | 11 | import java.util.ArrayList; |
| ... | ... | @@ -17,7 +18,6 @@ import java.util.List; |
| 17 | 18 | import java.util.Map; |
| 18 | 19 | import java.util.Set; |
| 19 | 20 | |
| 20 | -import org.drools.compiler.lang.DRL5Expressions.type_return; | |
| 21 | 21 | import org.springframework.beans.factory.annotation.Autowired; |
| 22 | 22 | import org.springframework.jdbc.core.JdbcTemplate; |
| 23 | 23 | import org.springframework.jdbc.core.RowMapper; |
| ... | ... | @@ -759,6 +759,254 @@ public class PeopleCarPlanServiceImpl implements PeopleCarPlanService { |
| 759 | 759 | |
| 760 | 760 | return modelMap; |
| 761 | 761 | } |
| 762 | + | |
| 763 | + @Override | |
| 764 | + public Map<String, Object> scheduleAnaly_sum(Map<String, Object> map) { | |
| 765 | + DecimalFormat df = new DecimalFormat("00"); | |
| 766 | + NumberFormat nf = NumberFormat.getNumberInstance(); | |
| 767 | + nf.setMaximumFractionDigits(2); | |
| 768 | +// List<TTInfoDetail> ttList = new ArrayList<TTInfoDetail>(); | |
| 769 | + List<Long> ttList = new ArrayList<Long>(); | |
| 770 | + List<ScheduleRealInfo> list = new ArrayList<ScheduleRealInfo>(); | |
| 771 | + List<Map<String, Object>> resList = new ArrayList<Map<String, Object>>(); | |
| 772 | + List<Map<String, Object>> tempList = new ArrayList<Map<String, Object>>(); | |
| 773 | + Map<String, List<ScheduleRealInfo>> keyMap = new HashMap<String, List<ScheduleRealInfo>>(); | |
| 774 | + Map<String, Object> modelMap = new HashMap<String, Object>(); | |
| 775 | + | |
| 776 | + String company = ""; | |
| 777 | + if(map.get("company")!=null) | |
| 778 | + company=map.get("company").toString(); | |
| 779 | + String subCompany = ""; | |
| 780 | + if(map.get("subCompany")!=null) | |
| 781 | + subCompany=map.get("subCompany").toString(); | |
| 782 | + String page = map.get("page").toString(); | |
| 783 | + String line = map.get("line").toString(); | |
| 784 | + String startDate = map.get("startDate").toString(); | |
| 785 | + String endDate = map.get("endDate").toString(); | |
| 786 | + String nbbm = map.get("nbbm").toString(); | |
| 787 | + String type = map.get("type").toString(); | |
| 788 | + | |
| 789 | + if(startDate.length() == 0){ | |
| 790 | + startDate = new SimpleDateFormat("yyyy-MM-dd").format(new Date()); | |
| 791 | + } | |
| 792 | + if(endDate.length() == 0){ | |
| 793 | + endDate = new SimpleDateFormat("yyyy-MM-dd").format(new Date()); | |
| 794 | + } | |
| 795 | + try { | |
| 796 | + | |
| 797 | + String sql = "select * from bsth_c_s_sp_info_real where DATE_FORMAT(schedule_date,'%Y-%m-%d') >= '"+startDate+"' and DATE_FORMAT(schedule_date,'%Y-%m-%d') <= '"+endDate+"'"; | |
| 798 | + if(line.length() != 0){ | |
| 799 | + sql += " and xl_bm = '"+line+"'"; | |
| 800 | + } | |
| 801 | + if(nbbm.length() != 0){ | |
| 802 | + sql += " and cl_zbh like '%"+nbbm+"%'"; | |
| 803 | + } | |
| 804 | +// if(company.length() != 0){ | |
| 805 | + sql += " and gs_bm like '%"+company+"%' and fgs_bm like '%"+subCompany+"%'"; | |
| 806 | +// } | |
| 807 | + sql += " and bc_type != 'in' and bc_type != 'out'"; | |
| 808 | + | |
| 809 | + list = jdbcTemplate.query(sql, | |
| 810 | + new RowMapper<ScheduleRealInfo>(){ | |
| 811 | + @Override | |
| 812 | + public ScheduleRealInfo mapRow(ResultSet rs, int rowNum) throws SQLException { | |
| 813 | + ScheduleRealInfo schedule = new ScheduleRealInfo(); | |
| 814 | + schedule.setScheduleDateStr(rs.getString("schedule_date_Str")); | |
| 815 | + schedule.setRealExecDate(rs.getString("real_exec_date")); | |
| 816 | + schedule.setXlName(rs.getString("xl_name")); | |
| 817 | + schedule.setBcType(rs.getString("bc_type")); | |
| 818 | + schedule.setGsName(rs.getString("gs_name")); | |
| 819 | + schedule.setFgsName(rs.getString("fgs_name")); | |
| 820 | + schedule.setXlDir(rs.getString("xl_dir")); | |
| 821 | + schedule.setBcs(rs.getInt("bcs")); | |
| 822 | + schedule.setFcno(rs.getInt("fcno")); | |
| 823 | + schedule.setFcsj(rs.getString("fcsj")); | |
| 824 | + schedule.setFcsjActual(rs.getString("fcsj_actual")); | |
| 825 | + schedule.setZdsj(rs.getString("zdsj")); | |
| 826 | + schedule.setZdsjActual(rs.getString("zdsj_actual")); | |
| 827 | + schedule.setBcsj(rs.getInt("bcsj")); | |
| 828 | + schedule.setQdzName(rs.getString("qdz_name")); | |
| 829 | + schedule.setSpId(rs.getLong("sp_id")); | |
| 830 | + | |
| 831 | + if(schedule.getFcsj() != null && schedule.getZdsj() != null){ | |
| 832 | + String[] split1 = schedule.getFcsj().split(":"); | |
| 833 | + String[] split2 = schedule.getZdsj().split(":"); | |
| 834 | + int fcsj = Integer.valueOf(split1[0]) * 60 + Integer.valueOf(split1[1]); | |
| 835 | + int zdsj = Integer.valueOf(split2[0]) * 60 + Integer.valueOf(split2[1]); | |
| 836 | + if(zdsj < fcsj){ | |
| 837 | + zdsj += 1440; | |
| 838 | + schedule.setZdsj((zdsj/60>9?zdsj/60:"0"+zdsj/60) + ":" + (zdsj%60>9?zdsj%60:"0"+zdsj%60)); | |
| 839 | + } | |
| 840 | + schedule.setFcsjT((long)fcsj); | |
| 841 | + schedule.setZdsjT((long)zdsj); | |
| 842 | + } | |
| 843 | + if(schedule.getFcsjActual() != null && schedule.getZdsjActual() != null){ | |
| 844 | + String[] split3 = schedule.getFcsjActual().split(":"); | |
| 845 | + String[] split4 = schedule.getZdsjActual().split(":"); | |
| 846 | + int fcsjA = Integer.valueOf(split3[0]) * 60 + Integer.valueOf(split3[1]); | |
| 847 | + int zdsjA = Integer.valueOf(split4[0]) * 60 + Integer.valueOf(split4[1]); | |
| 848 | + if(fcsjA > zdsjA){ | |
| 849 | + zdsjA += 1440; | |
| 850 | + schedule.setZdsjActual((zdsjA/60>9?zdsjA/60:"0"+zdsjA/60) + ":" + (zdsjA%60>9?zdsjA%60:"0"+zdsjA%60)); | |
| 851 | + } | |
| 852 | + schedule.setFcsjActualTime((long)fcsjA); | |
| 853 | + schedule.setZdsjActualTime((long)zdsjA); | |
| 854 | + } | |
| 855 | + | |
| 856 | + return schedule; | |
| 857 | + } | |
| 858 | + }); | |
| 859 | + | |
| 860 | + } catch (Exception e) { | |
| 861 | + // TODO Auto-generated catch block | |
| 862 | + e.printStackTrace(); | |
| 863 | + } | |
| 864 | + | |
| 865 | + { | |
| 866 | + Map<String, Object> m0 = new HashMap<String, Object>(); | |
| 867 | + m0.put("time", "首~6:30"); | |
| 868 | + m0.put("upbc", "0");m0.put("dnbc", "0"); | |
| 869 | + m0.put("upys", "--");m0.put("dnys", "--"); | |
| 870 | + m0.put("pjys", "--"); | |
| 871 | + tempList.add(m0); | |
| 872 | + Map<String, Object> m1 = new HashMap<String, Object>(); | |
| 873 | + m1.put("time", "6:31~8:30"); | |
| 874 | + m1.put("upbc", "0");m1.put("dnbc", "0"); | |
| 875 | + m1.put("upys", "--");m1.put("dnys", "--"); | |
| 876 | + m1.put("pjys", "--"); | |
| 877 | + tempList.add(m1); | |
| 878 | + Map<String, Object> m2 = new HashMap<String, Object>(); | |
| 879 | + m2.put("time", "8:31~11:00"); | |
| 880 | + m2.put("upbc", "0");m2.put("dnbc", "0"); | |
| 881 | + m2.put("upys", "--");m2.put("dnys", "--"); | |
| 882 | + m2.put("pjys", "--"); | |
| 883 | + tempList.add(m2); | |
| 884 | + Map<String, Object> m3 = new HashMap<String, Object>(); | |
| 885 | + m3.put("time", "11:01~13:30"); | |
| 886 | + m3.put("upbc", "0");m3.put("dnbc", "0"); | |
| 887 | + m3.put("upys", "--");m3.put("dnys", "--"); | |
| 888 | + m3.put("pjys", "--"); | |
| 889 | + tempList.add(m3); | |
| 890 | + Map<String, Object> m4 = new HashMap<String, Object>(); | |
| 891 | + m4.put("time", "13:31~16:00"); | |
| 892 | + m4.put("upbc", "0");m4.put("dnbc", "0"); | |
| 893 | + m4.put("upys", "--");m4.put("dnys", "--"); | |
| 894 | + m4.put("pjys", "--"); | |
| 895 | + tempList.add(m4); | |
| 896 | + Map<String, Object> m5 = new HashMap<String, Object>(); | |
| 897 | + m5.put("time", "16:01~18:00"); | |
| 898 | + m5.put("upbc", "0");m5.put("dnbc", "0"); | |
| 899 | + m5.put("upys", "--");m5.put("dnys", "--"); | |
| 900 | + m5.put("pjys", "--"); | |
| 901 | + tempList.add(m5); | |
| 902 | + Map<String, Object> m6 = new HashMap<String, Object>(); | |
| 903 | + m6.put("time", "18:01~20:30"); | |
| 904 | + m6.put("upbc", "0");m6.put("dnbc", "0"); | |
| 905 | + m6.put("upys", "--");m6.put("dnys", "--"); | |
| 906 | + m6.put("pjys", "--"); | |
| 907 | + tempList.add(m6); | |
| 908 | + Map<String, Object> m7 = new HashMap<String, Object>(); | |
| 909 | + m7.put("time", "20:31~末"); | |
| 910 | + m7.put("upbc", "0");m7.put("dnbc", "0"); | |
| 911 | + m7.put("upys", "--");m7.put("dnys", "--"); | |
| 912 | + m7.put("pjys", "--"); | |
| 913 | + tempList.add(m7); | |
| 914 | + } | |
| 915 | + | |
| 916 | + //按时间段分组 | |
| 917 | + for(ScheduleRealInfo schedule : list){ | |
| 918 | + if(schedule.getFcsjActualTime()!=null && schedule.getZdsjActualTime()!=null){ | |
| 919 | + Long fcsjA = schedule.getFcsjActualTime(); | |
| 920 | + if(fcsjA <= 6*60+30){ | |
| 921 | + if(!keyMap.containsKey("首~6:30")) | |
| 922 | + keyMap.put("首~6:30", new ArrayList<ScheduleRealInfo>()); | |
| 923 | + keyMap.get("首~6:30").add(schedule); | |
| 924 | + } | |
| 925 | + if(fcsjA > 6*60+30 && fcsjA <= 8*60+30){ | |
| 926 | + if(!keyMap.containsKey("6:31~8:30")) | |
| 927 | + keyMap.put("6:31~8:30", new ArrayList<ScheduleRealInfo>()); | |
| 928 | + keyMap.get("6:31~8:30").add(schedule); | |
| 929 | + } | |
| 930 | + if(fcsjA > 8*60+30 && fcsjA <= 11*60){ | |
| 931 | + if(!keyMap.containsKey("8:31~11:00")) | |
| 932 | + keyMap.put("8:31~11:00", new ArrayList<ScheduleRealInfo>()); | |
| 933 | + keyMap.get("8:31~11:00").add(schedule); | |
| 934 | + } | |
| 935 | + if(fcsjA > 11*60 && fcsjA <= 13*60+30){ | |
| 936 | + if(!keyMap.containsKey("11:01~13:30")) | |
| 937 | + keyMap.put("11:01~13:30", new ArrayList<ScheduleRealInfo>()); | |
| 938 | + keyMap.get("11:01~13:30").add(schedule); | |
| 939 | + } | |
| 940 | + if(fcsjA > 13*60+30 && fcsjA <= 16*60){ | |
| 941 | + if(!keyMap.containsKey("13:31~16:00")) | |
| 942 | + keyMap.put("13:31~16:00", new ArrayList<ScheduleRealInfo>()); | |
| 943 | + keyMap.get("13:31~16:00").add(schedule); | |
| 944 | + } | |
| 945 | + if(fcsjA > 16*60 && fcsjA <= 18*60){ | |
| 946 | + if(!keyMap.containsKey("16:01~18:00")) | |
| 947 | + keyMap.put("16:01~18:00", new ArrayList<ScheduleRealInfo>()); | |
| 948 | + keyMap.get("16:01~18:00").add(schedule); | |
| 949 | + } | |
| 950 | + if(fcsjA > 18*60 && fcsjA <= 20*60+30){ | |
| 951 | + if(!keyMap.containsKey("18:01~20:30")) | |
| 952 | + keyMap.put("18:01~20:30", new ArrayList<ScheduleRealInfo>()); | |
| 953 | + keyMap.get("18:01~20:30").add(schedule); | |
| 954 | + } | |
| 955 | + if(fcsjA > 20*60+30){ | |
| 956 | + if(!keyMap.containsKey("20:31~末")) | |
| 957 | + keyMap.put("20:31~末", new ArrayList<ScheduleRealInfo>()); | |
| 958 | + keyMap.get("20:31~末").add(schedule); | |
| 959 | + } | |
| 960 | + } | |
| 961 | + } | |
| 962 | + | |
| 963 | + for(String key : keyMap.keySet()){ | |
| 964 | + Map<String, Object> m = null; | |
| 965 | + for(Map<String, Object> map2 : tempList){ | |
| 966 | + if(map2.get("time").toString().equals(key)){ | |
| 967 | + m = map2; | |
| 968 | + } | |
| 969 | + } | |
| 970 | + int upbc = 0, dnbc = 0; | |
| 971 | + long upys = 0, dnys = 0; | |
| 972 | + for(ScheduleRealInfo schedule : keyMap.get(key)){ | |
| 973 | + if(schedule.getXlDir().equals("0")){ | |
| 974 | + upbc++; | |
| 975 | + upys += schedule.getZdsjActualTime() - schedule.getFcsjActualTime(); | |
| 976 | + }else if(schedule.getXlDir().equals("1")){ | |
| 977 | + dnbc++; | |
| 978 | + dnys += schedule.getZdsjActualTime() - schedule.getFcsjActualTime(); | |
| 979 | + } | |
| 980 | + } | |
| 981 | + m.put("upbc", upbc); | |
| 982 | + m.put("dnbc", dnbc); | |
| 983 | + m.put("upys", nf.format((float)upys / upbc)); | |
| 984 | + m.put("dnys", nf.format((float)dnys / dnbc)); | |
| 985 | + m.put("pjys", nf.format((float) (upys + dnys) / (upbc + dnbc))); | |
| 986 | + } | |
| 987 | + | |
| 988 | + modelMap.put("dataList", tempList); | |
| 989 | + | |
| 990 | + //导出 | |
| 991 | + if(type.equals("export")){ | |
| 992 | + SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"), | |
| 993 | + sdfSimple = new SimpleDateFormat("yyyyMMdd"); | |
| 994 | + List<Iterator<?>> listI = new ArrayList<Iterator<?>>(); | |
| 995 | + Map<String,Object> m = new HashMap<String, Object>(); | |
| 996 | + ReportUtils ee = new ReportUtils(); | |
| 997 | + try { | |
| 998 | + listI.add(tempList.iterator()); | |
| 999 | + String path = this.getClass().getResource("/").getPath()+"static/pages/forms/"; | |
| 1000 | + ee.excelReplace(listI, new Object[] { m }, path+"mould/scheduleAnaly_sum.xls", | |
| 1001 | + path+"export/时刻表分析(汇总)" + sdfSimple.format(sdfMonth.parse(startDate)) + "-" + sdfSimple.format(sdfMonth.parse(endDate)) + ".xls"); | |
| 1002 | + } catch (Exception e) { | |
| 1003 | + // TODO: handle exception | |
| 1004 | + e.printStackTrace(); | |
| 1005 | + } | |
| 1006 | + } | |
| 1007 | + | |
| 1008 | + return modelMap; | |
| 1009 | + } | |
| 762 | 1010 | |
| 763 | 1011 | @Override |
| 764 | 1012 | public List<Map<String, Object>> getModel(Map<String, Object> map) { |
| ... | ... | @@ -908,6 +1156,181 @@ public class PeopleCarPlanServiceImpl implements PeopleCarPlanService { |
| 908 | 1156 | List<Long> longList1 = new ArrayList<Long>(); |
| 909 | 1157 | String companyName = "", subCompanyName = ""; |
| 910 | 1158 | for(ScheduleRealInfo schedule : keyMap.get(key)){ |
| 1159 | + if(schedule.getFcsjActual() == null || schedule.getFcsjActual().trim().length() == 0){ | |
| 1160 | + continue; | |
| 1161 | + } | |
| 1162 | + if(schedule.getGsName() != null && companyName.length() == 0) | |
| 1163 | + companyName = schedule.getGsName(); | |
| 1164 | + if(schedule.getFgsName() != null && subCompanyName.length() == 0) | |
| 1165 | + subCompanyName = schedule.getFgsName(); | |
| 1166 | + String[] split = schedule.getFcsj().split(":"); | |
| 1167 | + long min = Integer.valueOf(split[0])*60 + Integer.valueOf(split[1]); | |
| 1168 | + schedule.setFcsjT(min); | |
| 1169 | + if(schedule.getXlDir().equals("0")){ | |
| 1170 | + temp0.put(min, schedule); | |
| 1171 | + longList0.add(min); | |
| 1172 | + } else { | |
| 1173 | + temp1.put(min, schedule); | |
| 1174 | + longList1.add(min); | |
| 1175 | + } | |
| 1176 | + } | |
| 1177 | + if(longList0.size() == 0 || longList1.size() == 0){ | |
| 1178 | + continue; | |
| 1179 | + } | |
| 1180 | + if(longList0.size() != 0){ | |
| 1181 | + Collections.sort(longList0); | |
| 1182 | + ScheduleRealInfo shouban0 = temp0.get(longList0.get(0)); | |
| 1183 | + ScheduleRealInfo moban0 = temp0.get(longList0.get(longList0.size() - 1)); | |
| 1184 | + tempMap.put("qdzFirst0", shouban0.getQdzName()); | |
| 1185 | + tempMap.put("jhfcFirst0", shouban0.getFcsj()); | |
| 1186 | + tempMap.put("qdzLast0", moban0.getQdzName()); | |
| 1187 | + tempMap.put("jhfcLast0", moban0.getFcsj()); | |
| 1188 | + if(shouban0.getFcsjActual() != null){ | |
| 1189 | + String[] split = shouban0.getFcsjActual().split(":"); | |
| 1190 | + long min = Integer.valueOf(split[0])*60 + Integer.valueOf(split[1]); | |
| 1191 | + long delay = shouban0.getFcsjT() - min; | |
| 1192 | + tempMap.put("sjfcFirst0", shouban0.getFcsjActual()); | |
| 1193 | + if(delay > 0) | |
| 1194 | + tempMap.put("delayFirst0", "+" + delay); | |
| 1195 | + else | |
| 1196 | + tempMap.put("delayFirst0", delay); | |
| 1197 | + } else { | |
| 1198 | + tempMap.put("sjfcFirst0", "/"); | |
| 1199 | + tempMap.put("delayFirst0", "/"); | |
| 1200 | + } | |
| 1201 | + if(moban0.getFcsjActual() != null){ | |
| 1202 | + String[] split = moban0.getFcsjActual().split(":"); | |
| 1203 | + long min = Integer.valueOf(split[0])*60 + Integer.valueOf(split[1]); | |
| 1204 | + long delay = moban0.getFcsjT() - min; | |
| 1205 | + tempMap.put("sjfcLast0", moban0.getFcsjActual()); | |
| 1206 | + if(delay > 0) | |
| 1207 | + tempMap.put("delayLast0", "+" + delay); | |
| 1208 | + else | |
| 1209 | + tempMap.put("delayLast0", delay); | |
| 1210 | + } else { | |
| 1211 | + tempMap.put("sjfcLast0", "/"); | |
| 1212 | + tempMap.put("delayLast0", "/"); | |
| 1213 | + } | |
| 1214 | + }else{ | |
| 1215 | + tempMap.put("qdzFirst0", "--"); | |
| 1216 | + tempMap.put("jhfcFirst0", "/"); | |
| 1217 | + tempMap.put("qdzLast0", "--"); | |
| 1218 | + tempMap.put("jhfcLast0", "/"); | |
| 1219 | + tempMap.put("sjfcFirst0", "/"); | |
| 1220 | + tempMap.put("delayFirst0", "/"); | |
| 1221 | + tempMap.put("sjfcLast0", "/"); | |
| 1222 | + tempMap.put("delayLast0", "/"); | |
| 1223 | + } | |
| 1224 | + | |
| 1225 | + if(longList1.size() != 0){ | |
| 1226 | + Collections.sort(longList1); | |
| 1227 | + ScheduleRealInfo shouban1 = temp1.get(longList1.get(0)); | |
| 1228 | + ScheduleRealInfo moban1 = temp1.get(longList1.get(longList1.size() - 1)); | |
| 1229 | + tempMap.put("qdzFirst1", shouban1.getQdzName()); | |
| 1230 | + tempMap.put("jhfcFirst1", shouban1.getFcsj()); | |
| 1231 | + tempMap.put("qdzLast1", moban1.getQdzName()); | |
| 1232 | + tempMap.put("jhfcLast1", moban1.getFcsj()); | |
| 1233 | + if(shouban1.getFcsjActual() != null){ | |
| 1234 | + String[] split = shouban1.getFcsjActual().split(":"); | |
| 1235 | + long min = Integer.valueOf(split[0])*60 + Integer.valueOf(split[1]); | |
| 1236 | + long delay = shouban1.getFcsjT() - min; | |
| 1237 | + tempMap.put("sjfcFirst1", shouban1.getFcsjActual()); | |
| 1238 | + if(delay > 0) | |
| 1239 | + tempMap.put("delayFirst1", "+" + delay); | |
| 1240 | + else | |
| 1241 | + tempMap.put("delayFirst1", delay); | |
| 1242 | + } else { | |
| 1243 | + tempMap.put("sjfcFirst1", "/"); | |
| 1244 | + tempMap.put("delayFirst1", "/"); | |
| 1245 | + } | |
| 1246 | + if(moban1.getFcsjActual() != null){ | |
| 1247 | + String[] split = moban1.getFcsjActual().split(":"); | |
| 1248 | + long min = Integer.valueOf(split[0])*60 + Integer.valueOf(split[1]); | |
| 1249 | + long delay = moban1.getFcsjT() - min; | |
| 1250 | + tempMap.put("sjfcLast1", moban1.getFcsjActual()); | |
| 1251 | + if(delay > 0) | |
| 1252 | + tempMap.put("delayLast1", "+" + delay); | |
| 1253 | + else | |
| 1254 | + tempMap.put("delayLast1", delay); | |
| 1255 | + } else { | |
| 1256 | + tempMap.put("sjfcLast1", "/"); | |
| 1257 | + tempMap.put("delayLast1", "/"); | |
| 1258 | + } | |
| 1259 | + }else{ | |
| 1260 | + tempMap.put("qdzFirst1", "--"); | |
| 1261 | + tempMap.put("jhfcFirst1", "/"); | |
| 1262 | + tempMap.put("qdzLast1", "--"); | |
| 1263 | + tempMap.put("jhfcLast1", "/"); | |
| 1264 | + tempMap.put("sjfcFirst1", "/"); | |
| 1265 | + tempMap.put("delayFirst1", "/"); | |
| 1266 | + tempMap.put("sjfcLast1", "/"); | |
| 1267 | + tempMap.put("delayLast1", "/"); | |
| 1268 | + } | |
| 1269 | + | |
| 1270 | + tempMap.put("date", date); | |
| 1271 | + tempMap.put("company", companyName); | |
| 1272 | + tempMap.put("subCompany", subCompanyName); | |
| 1273 | + tempMap.put("line", key); | |
| 1274 | + resList.add(tempMap); | |
| 1275 | + } | |
| 1276 | + | |
| 1277 | + if(type.equals("export")){ | |
| 1278 | + SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"), | |
| 1279 | + sdfSimple = new SimpleDateFormat("yyyyMMdd"); | |
| 1280 | + List<Iterator<?>> listI = new ArrayList<Iterator<?>>(); | |
| 1281 | + Map<String,Object> m = new HashMap<String, Object>(); | |
| 1282 | + ReportUtils ee = new ReportUtils(); | |
| 1283 | + try { | |
| 1284 | + listI.add(resList.iterator()); | |
| 1285 | + String path = this.getClass().getResource("/").getPath()+"static/pages/forms/"; | |
| 1286 | + ee.excelReplace(listI, new Object[] { m }, path+"mould/firstAndLastBus.xls", | |
| 1287 | + path+"export/线路首末班" + sdfSimple.format(sdfMonth.parse(date)) + ".xls"); | |
| 1288 | + } catch (Exception e) { | |
| 1289 | + // TODO: handle exception | |
| 1290 | + e.printStackTrace(); | |
| 1291 | + } | |
| 1292 | + } | |
| 1293 | + | |
| 1294 | + return resList; | |
| 1295 | + } | |
| 1296 | + | |
| 1297 | + @Override | |
| 1298 | + public List<Map<String, Object>> firstAndLastBus_sum(Map<String, Object> map) { | |
| 1299 | + List<Map<String, Object>> resList = new ArrayList<Map<String, Object>>(); | |
| 1300 | + Map<String, List<ScheduleRealInfo>> keyMap = new HashMap<String, List<ScheduleRealInfo>>(); | |
| 1301 | + | |
| 1302 | + String company = map.get("company").toString(); | |
| 1303 | + String subCompany = map.get("subCompany").toString(); | |
| 1304 | + String line = map.get("line").toString(); | |
| 1305 | + String date = map.get("date").toString(); | |
| 1306 | + String type = map.get("type").toString(); | |
| 1307 | + | |
| 1308 | + if(date.length() == 0) | |
| 1309 | + date = new SimpleDateFormat("yyyy-MM-dd").format(new Date()); | |
| 1310 | + | |
| 1311 | + List<ScheduleRealInfo> list = this.getSchedule(company, subCompany, line, date); | |
| 1312 | + | |
| 1313 | + for(ScheduleRealInfo schedule : list){ | |
| 1314 | + if(schedule.getBcType().equals("in") || schedule.getBcType().equals("out")) | |
| 1315 | + continue; | |
| 1316 | + String key = schedule.getXlName(); | |
| 1317 | + if(key == null || key.trim().length() == 0) | |
| 1318 | + continue; | |
| 1319 | + if(!keyMap.containsKey(key)) | |
| 1320 | + keyMap.put(key, new ArrayList<ScheduleRealInfo>()); | |
| 1321 | + keyMap.get(key).add(schedule); | |
| 1322 | + } | |
| 1323 | + for(String key : keyMap.keySet()){ | |
| 1324 | + Map<String, Object> tempMap = new HashMap<String, Object>(); | |
| 1325 | + Map<Long, ScheduleRealInfo> temp0 = new HashMap<Long, ScheduleRealInfo>(); | |
| 1326 | + List<Long> longList0 = new ArrayList<Long>(); | |
| 1327 | + Map<Long, ScheduleRealInfo> temp1 = new HashMap<Long, ScheduleRealInfo>(); | |
| 1328 | + List<Long> longList1 = new ArrayList<Long>(); | |
| 1329 | + String companyName = "", subCompanyName = ""; | |
| 1330 | + for(ScheduleRealInfo schedule : keyMap.get(key)){ | |
| 1331 | + if(schedule.getFcsjActual() == null || schedule.getFcsjActual().trim().length() == 0){ | |
| 1332 | + continue; | |
| 1333 | + } | |
| 911 | 1334 | if(schedule.getGsName() != null && companyName.length() == 0) |
| 912 | 1335 | companyName = schedule.getGsName(); |
| 913 | 1336 | if(schedule.getFgsName() != null && subCompanyName.length() == 0) |
| ... | ... | @@ -923,6 +1346,9 @@ public class PeopleCarPlanServiceImpl implements PeopleCarPlanService { |
| 923 | 1346 | longList1.add(min); |
| 924 | 1347 | } |
| 925 | 1348 | } |
| 1349 | + if(longList0.size() == 0 || longList1.size() == 0){ | |
| 1350 | + continue; | |
| 1351 | + } | |
| 926 | 1352 | Collections.sort(longList0); |
| 927 | 1353 | Collections.sort(longList1); |
| 928 | 1354 | ScheduleRealInfo shouban0 = temp0.get(longList0.get(0)); |
| ... | ... | @@ -1015,7 +1441,7 @@ public class PeopleCarPlanServiceImpl implements PeopleCarPlanService { |
| 1015 | 1441 | |
| 1016 | 1442 | return resList; |
| 1017 | 1443 | } |
| 1018 | - | |
| 1444 | + | |
| 1019 | 1445 | @Override |
| 1020 | 1446 | public List<Map<String, Object>> commandState(Map<String, Object> map) { |
| 1021 | 1447 | List<Map<String, Object>> resList = new ArrayList<Map<String, Object>>(); | ... | ... |
src/main/resources/rules/shiftloop_fb_2.drl
| ... | ... | @@ -148,7 +148,8 @@ rule "Calcu_SchedulePlanRuleResult_wrap" |
| 148 | 148 | $self: schedulePlan |
| 149 | 149 | ) |
| 150 | 150 | eval($self.getIsHistoryPlanFirst() == true) // 是否使用历史排班标识 |
| 151 | - $sprr: SchedulePlanRuleResult($qyrq: qyrq) from scheduleRuleService.findLastByXl($xlId, $fromDate.toDate()) | |
| 151 | + $sprr: SchedulePlanRuleResult() from scheduleRuleService.findLastByXl($xlId, $fromDate.toDate()) | |
| 152 | + eval($sprr.getQyrq() != null) | |
| 152 | 153 | |
| 153 | 154 | then |
| 154 | 155 | // 创建班序历史结果数据 |
| ... | ... | @@ -159,7 +160,7 @@ rule "Calcu_SchedulePlanRuleResult_wrap" |
| 159 | 160 | |
| 160 | 161 | // 规则Md5编码 |
| 161 | 162 | String md5 = Md5Util.getMd5( |
| 162 | - String.valueOf($qyrq.getTime()) + "_" + | |
| 163 | + String.valueOf($sprr.getQyrq().getTime()) + "_" + | |
| 163 | 164 | $sprr.getGids() + "_" + $sprr.getEcids() |
| 164 | 165 | ); |
| 165 | 166 | |
| ... | ... | @@ -325,6 +326,7 @@ rule "Calcu_loop2_1_" // 路牌在时刻表中存在,就翻 |
| 325 | 326 | schedulePlanRuleResult.setScheduleDate($csd2.toDate()); |
| 326 | 327 | schedulePlanRuleResult.setTtinfoId($ttinfoId); |
| 327 | 328 | schedulePlanRuleResult.setTtinfoName($ttinfoName); |
| 329 | + schedulePlanRuleResult.setQyrq($sri.getQyrq().toDate()); | |
| 328 | 330 | |
| 329 | 331 | scheduleResult.getSchedulePlanRuleResults().add(schedulePlanRuleResult); |
| 330 | 332 | ... | ... |