Commit c21cccbff8965132fee5dd2b8c1b6411fc70d7b6
1 parent
f992eaea
添加时间段
Showing
1 changed file
with
115 additions
and
25 deletions
src/main/java/com/bsth/service/impl/BusIntervalServiceImpl.java
| ... | ... | @@ -73,7 +73,6 @@ public class BusIntervalServiceImpl implements BusIntervalService { |
| 73 | 73 | if(normal){ |
| 74 | 74 | sql += " and bc_type != 'in' and bc_type != 'out'"; |
| 75 | 75 | } |
| 76 | - System.out.println(sql); | |
| 77 | 76 | |
| 78 | 77 | list = jdbcTemplate.query(sql, |
| 79 | 78 | new RowMapper<ScheduleRealInfo>(){ |
| ... | ... | @@ -238,6 +237,7 @@ public class BusIntervalServiceImpl implements BusIntervalService { |
| 238 | 237 | |
| 239 | 238 | String sql = "select start_station_name, end_station_name from bsth_c_line where line_code = '"+line+"'"; |
| 240 | 239 | |
| 240 | + System.out.println(sql); | |
| 241 | 241 | list = jdbcTemplate.query(sql, |
| 242 | 242 | new RowMapper<Map<String, Object>>(){ |
| 243 | 243 | @Override |
| ... | ... | @@ -315,8 +315,10 @@ public class BusIntervalServiceImpl implements BusIntervalService { |
| 315 | 315 | String endDate = map.get("endDate").toString(); |
| 316 | 316 | String model = map.get("model").toString(); |
| 317 | 317 | String statu = map.get("statu").toString(); |
| 318 | -// String times = map.get("times").toString(); | |
| 318 | + String times1 = map.get("times1").toString(); | |
| 319 | + String times2 = map.get("times2").toString(); | |
| 319 | 320 | String type = map.get("type").toString(); |
| 321 | + int sfqr = Integer.valueOf(map.get("sfqr").toString()); | |
| 320 | 322 | |
| 321 | 323 | if(startDate.length() == 0){ |
| 322 | 324 | startDate = new SimpleDateFormat("yyyy-MM-dd").format(new Date()); |
| ... | ... | @@ -327,12 +329,18 @@ public class BusIntervalServiceImpl implements BusIntervalService { |
| 327 | 329 | if(statu.equals("0")){ |
| 328 | 330 | line = ""; |
| 329 | 331 | } |
| 330 | -// if(times.length() == 0){ | |
| 331 | -// times = "06:00-07:00"; | |
| 332 | -// } | |
| 333 | 332 | |
| 334 | - List<ScheduleRealInfo> list = this.getSchedule(company, subCompany, line, startDate, endDate, model, "", true); | |
| 333 | + List<ScheduleRealInfo> list = this.getSchedule(company, subCompany, line, | |
| 334 | + startDate, endDate, model, sfqr==1?times1+"-"+times2:"", true); | |
| 335 | 335 | |
| 336 | + long time1 = 0; | |
| 337 | + long time2 = 0; | |
| 338 | + if(sfqr == 1){ | |
| 339 | + String[] split1 = times1.split(":"); | |
| 340 | + String[] split2 = times2.split(":"); | |
| 341 | + time1 = Long.valueOf(split1[0])*60 + Long.valueOf(split1[1]); | |
| 342 | + time2 = Long.valueOf(split2[0])*60 + Long.valueOf(split2[1]); | |
| 343 | + } | |
| 336 | 344 | String[] date1 = startDate.split("-"); |
| 337 | 345 | String[] date2 = endDate.split("-"); |
| 338 | 346 | // startDate = date1[0] + "年" + date1[1] + "月" + date1[2] + "日"; |
| ... | ... | @@ -349,6 +357,15 @@ public class BusIntervalServiceImpl implements BusIntervalService { |
| 349 | 357 | // int endTime = Integer.valueOf(split[1].split(":")[0])*60 + Integer.valueOf(split[1].split(":")[1]); |
| 350 | 358 | |
| 351 | 359 | for(ScheduleRealInfo schedule : list){ |
| 360 | + String[] split1 = schedule.getFcsj().split(":"); | |
| 361 | + String[] split2 = schedule.getZdsj().split(":"); | |
| 362 | + long fcsj = Long.valueOf(split1[0])*60 + Long.valueOf(split1[1]); | |
| 363 | + long zdsj = Long.valueOf(split2[0])*60 + Long.valueOf(split2[1]); | |
| 364 | + if(sfqr == 1 && (zdsj < time1 || fcsj > time2)){ | |
| 365 | + continue; | |
| 366 | + } | |
| 367 | + if(schedule.getXlName() == null || schedule.getXlName().trim().length() == 0) | |
| 368 | + continue; | |
| 352 | 369 | String key = schedule.getXlBm() + "/" + schedule.getXlName() + "/" + schedule.getQdzName(); |
| 353 | 370 | if(!keyMap.containsKey(key)) |
| 354 | 371 | keyMap.put(key, new ArrayList<ScheduleRealInfo>()); |
| ... | ... | @@ -566,8 +583,11 @@ public class BusIntervalServiceImpl implements BusIntervalService { |
| 566 | 583 | String statu = map.get("statu").toString(); |
| 567 | 584 | String startDate = map.get("startDate").toString(); |
| 568 | 585 | String endDate = map.get("endDate").toString(); |
| 586 | + String times1 = map.get("times1").toString(); | |
| 587 | + String times2 = map.get("times2").toString(); | |
| 569 | 588 | String model = map.get("model").toString(); |
| 570 | 589 | String type = map.get("type").toString(); |
| 590 | + int sfqr = Integer.valueOf(map.get("sfqr").toString()); | |
| 571 | 591 | |
| 572 | 592 | if(startDate.length() == 0){ |
| 573 | 593 | startDate = new SimpleDateFormat("yyyy-MM-dd").format(new Date()); |
| ... | ... | @@ -588,6 +608,9 @@ public class BusIntervalServiceImpl implements BusIntervalService { |
| 588 | 608 | if(company.length() != 0){ |
| 589 | 609 | sql += " and gs_bm = '"+company+"' and fgs_bm = '"+subCompany+"'"; |
| 590 | 610 | } |
| 611 | + if(sfqr == 1){ | |
| 612 | + sql += " and zdsj >= '"+times1+"' and fcsj <= '"+times2+"'"; | |
| 613 | + } | |
| 591 | 614 | sql += " and bc_type != 'in' and bc_type != 'out' order by fcsj"; |
| 592 | 615 | |
| 593 | 616 | list = jdbcTemplate.query(sql, |
| ... | ... | @@ -698,7 +721,9 @@ public class BusIntervalServiceImpl implements BusIntervalService { |
| 698 | 721 | e.printStackTrace(); |
| 699 | 722 | } |
| 700 | 723 | |
| 701 | - | |
| 724 | + | |
| 725 | + long time1 = 0; | |
| 726 | + long time2 = 0; | |
| 702 | 727 | String[] date1 = startDate.split("-"); |
| 703 | 728 | String[] date2 = endDate.split("-"); |
| 704 | 729 | String date = ""; |
| ... | ... | @@ -710,6 +735,12 @@ public class BusIntervalServiceImpl implements BusIntervalService { |
| 710 | 735 | date = date1[0] + "年" + date1[1] + "月" + date1[2] + "日--" + |
| 711 | 736 | date2[0] + "年" + date2[1] + "月" + date2[2] + "日"; |
| 712 | 737 | } |
| 738 | + if(sfqr == 1){ | |
| 739 | + String[] split1 = times1.split(":"); | |
| 740 | + String[] split2 = times2.split(":"); | |
| 741 | + time1 = Long.valueOf(split1[0])*60 + Long.valueOf(split1[1]); | |
| 742 | + time2 = Long.valueOf(split2[0])*60 + Long.valueOf(split2[1]); | |
| 743 | + } | |
| 713 | 744 | |
| 714 | 745 | for(ChildTaskPlan cTask : cList){ |
| 715 | 746 | String key = cTask.getRemarks(); |
| ... | ... | @@ -719,6 +750,8 @@ public class BusIntervalServiceImpl implements BusIntervalService { |
| 719 | 750 | } |
| 720 | 751 | |
| 721 | 752 | for(ScheduleRealInfo schedule : list){ |
| 753 | + if(schedule.getXlName()==null || schedule.getXlName().trim().length()==0) | |
| 754 | + continue; | |
| 722 | 755 | if(model.length() != 0){ |
| 723 | 756 | for(Long tt : ttList) |
| 724 | 757 | if((long) tt == (long)schedule.getSpId()){ |
| ... | ... | @@ -744,6 +777,8 @@ public class BusIntervalServiceImpl implements BusIntervalService { |
| 744 | 777 | List<ScheduleRealInfo> list2 = keyMap.get(key); |
| 745 | 778 | long jhyysj = 0, sjyysj = 0; |
| 746 | 779 | long jhyssj = 0, sjyssj = 0; |
| 780 | + long jhyysj1 = 0, sjyysj1 = 0; | |
| 781 | + long jhyssj1 = 0, sjyssj1 = 0; | |
| 747 | 782 | double jhlc = 0, sjlc = 0; |
| 748 | 783 | for(ScheduleRealInfo schedule : list2){ |
| 749 | 784 | if(companyName.length() == 0 && schedule.getGsName() != null){ |
| ... | ... | @@ -766,20 +801,40 @@ public class BusIntervalServiceImpl implements BusIntervalService { |
| 766 | 801 | for(int i = 1; i < keyList.size(); i++){ |
| 767 | 802 | ScheduleRealInfo schedule1 = sortMap.get(keyList.get(i - 1)); |
| 768 | 803 | ScheduleRealInfo schedule2 = sortMap.get(keyList.get(i)); |
| 769 | - jhyysj += schedule2.getFcsjT() - schedule1.getFcsjT(); | |
| 770 | - | |
| 804 | + if(sfqr == 1 && time1 > schedule1.getFcsjT()){ | |
| 805 | + jhyysj += schedule2.getFcsjT() - time1; | |
| 806 | + }else if(sfqr == 1 && time2 < schedule2.getFcsjT()){ | |
| 807 | + jhyysj += time2 - schedule1.getFcsjT(); | |
| 808 | + }else{ | |
| 809 | + jhyysj += schedule2.getFcsjT() - schedule1.getFcsjT(); | |
| 810 | + } | |
| 811 | + jhyysj1 += schedule2.getFcsjT() - schedule1.getFcsjT(); | |
| 771 | 812 | long zdsj2 = schedule2.getZdsjT(); |
| 772 | 813 | long fcsj2 = schedule2.getFcsjT(); |
| 773 | 814 | if(fcsj2 > zdsj2) |
| 774 | 815 | zdsj2 += 1440l; |
| 775 | - jhyssj += zdsj2 - fcsj2; | |
| 816 | + if(sfqr == 1 && time1 > fcsj2){ | |
| 817 | + jhyssj += zdsj2 - time1; | |
| 818 | + }else if(sfqr == 1 && time2 < zdsj2){ | |
| 819 | + jhyssj += time2 - fcsj2; | |
| 820 | + }else{ | |
| 821 | + jhyssj += zdsj2 - fcsj2; | |
| 822 | + } | |
| 823 | + jhyssj1 += zdsj2 - fcsj2; | |
| 776 | 824 | jhlc += schedule2.getJhlc()==null?0:schedule2.getJhlc(); |
| 777 | 825 | if(i == 1){ |
| 778 | 826 | long zdsj1 = schedule1.getZdsjT(); |
| 779 | 827 | long fcsj1 = schedule1.getFcsjT(); |
| 780 | 828 | if(fcsj1 > zdsj1) |
| 781 | 829 | zdsj1 += 1440l; |
| 782 | - jhyssj += zdsj1 - fcsj1; | |
| 830 | + if(sfqr == 1 && time1 > fcsj1){ | |
| 831 | + jhyssj += zdsj1 - time1; | |
| 832 | + }else if(sfqr == 1 && time2 < zdsj1){ | |
| 833 | + jhyssj += time1 - fcsj1; | |
| 834 | + }else{ | |
| 835 | + jhyssj += zdsj1 - fcsj1; | |
| 836 | + } | |
| 837 | + jhyssj1 += zdsj1 - fcsj1; | |
| 783 | 838 | jhlc += schedule1.getJhlc()==null?0:schedule1.getJhlc(); |
| 784 | 839 | } |
| 785 | 840 | } |
| ... | ... | @@ -834,22 +889,45 @@ public class BusIntervalServiceImpl implements BusIntervalService { |
| 834 | 889 | Map<String, Object> m1 = mapList.get(i - 1); |
| 835 | 890 | Map<String, Object> m2 = mapList.get(i); |
| 836 | 891 | if(m1.get("fcsj") != null && m2.get("fcsj") != null){ |
| 837 | - sjyysj += Long.valueOf(m2.get("fcsj").toString()) - Long.valueOf(m1.get("fcsj").toString()); | |
| 892 | + long fcsj2 = Long.valueOf(m2.get("fcsj").toString()); | |
| 893 | + long fcsj1 = Long.valueOf(m1.get("fcsj").toString()); | |
| 894 | + if(sfqr == 1 && time1 > fcsj1){ | |
| 895 | + sjyysj += fcsj2 - time1; | |
| 896 | + }else if(sfqr == 1 && time2 < fcsj2){ | |
| 897 | + sjyysj += time2 - fcsj1; | |
| 898 | + }else{ | |
| 899 | + sjyysj += fcsj2 - fcsj1; | |
| 900 | + } | |
| 901 | + sjyysj1 += fcsj2 - fcsj1; | |
| 838 | 902 | } |
| 839 | - if(m2.get("fcsj") != null){ | |
| 903 | + if(m2.get("fcsj") != null && m2.get("zdsj") != null){ | |
| 840 | 904 | long zdsj = Long.valueOf(m2.get("zdsj").toString()); |
| 841 | 905 | long fcsj = Long.valueOf(m2.get("fcsj").toString()); |
| 842 | 906 | if(fcsj > zdsj) |
| 843 | 907 | zdsj += 1440l; |
| 844 | - sjyssj += zdsj - fcsj; | |
| 908 | + if(sfqr == 1 && time1 > fcsj){ | |
| 909 | + sjyssj += zdsj - time1; | |
| 910 | + }else if(sfqr == 1 && time2 < zdsj){ | |
| 911 | + sjyssj += zdsj - fcsj; | |
| 912 | + }else{ | |
| 913 | + sjyssj += zdsj - fcsj; | |
| 914 | + } | |
| 915 | + sjyssj1 += zdsj - fcsj; | |
| 845 | 916 | sjlc += Double.valueOf(m2.get("lc").toString()); |
| 846 | 917 | } |
| 847 | - if(i == 1 && m1.get("fcsj") != null){ | |
| 918 | + if(i == 1 && m1.get("fcsj") != null && m1.get("zdsj") != null){ | |
| 848 | 919 | long zdsj = Long.valueOf(m1.get("zdsj").toString()); |
| 849 | 920 | long fcsj = Long.valueOf(m1.get("fcsj").toString()); |
| 850 | 921 | if(fcsj > zdsj) |
| 851 | 922 | zdsj += 1440l; |
| 852 | - sjyssj += zdsj - fcsj; | |
| 923 | + if(sfqr == 1 && time1 > fcsj){ | |
| 924 | + sjyssj += zdsj - time1; | |
| 925 | + }else if(sfqr == 1 && time2 < zdsj){ | |
| 926 | + sjyssj += time2 - fcsj; | |
| 927 | + }else{ | |
| 928 | + sjyssj += zdsj - fcsj; | |
| 929 | + } | |
| 930 | + sjyssj1 += zdsj - fcsj; | |
| 853 | 931 | sjlc += Double.valueOf(m1.get("lc").toString()); |
| 854 | 932 | } |
| 855 | 933 | } |
| ... | ... | @@ -867,7 +945,7 @@ public class BusIntervalServiceImpl implements BusIntervalService { |
| 867 | 945 | tempMap.put("jhyycs", "0"); |
| 868 | 946 | } else { |
| 869 | 947 | tempMap.put("jhyysj", df.format((float)jhyysj / 60)); |
| 870 | - tempMap.put("jhyycs", df.format(jhlc == 0 ? 0 : jhlc / jhyysj * 60)); | |
| 948 | + tempMap.put("jhyycs", df.format(jhlc == 0 ? 0 : jhlc / jhyysj1 * 60)); | |
| 871 | 949 | } |
| 872 | 950 | |
| 873 | 951 | if(jhyssj == 0){ |
| ... | ... | @@ -875,7 +953,7 @@ public class BusIntervalServiceImpl implements BusIntervalService { |
| 875 | 953 | tempMap.put("jhyscs", "0"); |
| 876 | 954 | } else { |
| 877 | 955 | tempMap.put("jhyssj", df.format((float)jhyssj / 60)); |
| 878 | - tempMap.put("jhyscs", df.format(jhlc == 0 ? 0 : jhlc / jhyssj * 60)); | |
| 956 | + tempMap.put("jhyscs", df.format(jhlc == 0 ? 0 : jhlc / jhyssj1 * 60)); | |
| 879 | 957 | } |
| 880 | 958 | |
| 881 | 959 | if(sjyysj == 0){ |
| ... | ... | @@ -883,7 +961,7 @@ public class BusIntervalServiceImpl implements BusIntervalService { |
| 883 | 961 | tempMap.put("sjyycs", "0"); |
| 884 | 962 | } else { |
| 885 | 963 | tempMap.put("sjyysj", df.format((float)sjyysj / 60)); |
| 886 | - tempMap.put("sjyycs", df.format(sjlc == 0 ? 0 : sjlc / sjyysj * 60)); | |
| 964 | + tempMap.put("sjyycs", df.format(sjlc == 0 ? 0 : sjlc / sjyysj1 * 60)); | |
| 887 | 965 | } |
| 888 | 966 | |
| 889 | 967 | if(sjyssj == 0){ |
| ... | ... | @@ -891,8 +969,16 @@ public class BusIntervalServiceImpl implements BusIntervalService { |
| 891 | 969 | tempMap.put("sjyscs", "0"); |
| 892 | 970 | } else { |
| 893 | 971 | tempMap.put("sjyssj", df.format((float)sjyssj / 60)); |
| 894 | - tempMap.put("sjyscs", df.format(sjlc == 0 ? 0 : sjlc / sjyssj * 60)); | |
| 972 | + tempMap.put("sjyscs", df.format(sjlc == 0 ? 0 : sjlc / sjyssj1 * 60)); | |
| 895 | 973 | } |
| 974 | + if(!tempMap.get("jhyysj").equals("0")) | |
| 975 | + if(!tempMap.get("jhyycs").equals("0")) | |
| 976 | + if(!tempMap.get("jhyssj").equals("0")) | |
| 977 | + if(!tempMap.get("jhyscs").equals("0")) | |
| 978 | + if(!tempMap.get("sjyysj").equals("0")) | |
| 979 | + if(!tempMap.get("sjyycs").equals("0")) | |
| 980 | + if(!tempMap.get("sjyssj").equals("0")) | |
| 981 | + if(!tempMap.get("sjyscs").equals("0")) | |
| 896 | 982 | resList.add(tempMap); |
| 897 | 983 | } |
| 898 | 984 | Map<String, List<Map<String, Object>>> keyMap2 = new HashMap<String, List<Map<String, Object>>>(); |
| ... | ... | @@ -1124,7 +1210,7 @@ public class BusIntervalServiceImpl implements BusIntervalService { |
| 1124 | 1210 | endDate = new SimpleDateFormat("yyyy-MM-dd").format(new Date()); |
| 1125 | 1211 | } |
| 1126 | 1212 | if(times.length() == 0){ |
| 1127 | - times = "06:00-07:00"; | |
| 1213 | + times = "05:00-23:00"; | |
| 1128 | 1214 | } |
| 1129 | 1215 | |
| 1130 | 1216 | list = getSchedule(company, subCompany, line, startDate, endDate, model, times, true); |
| ... | ... | @@ -1387,6 +1473,7 @@ public class BusIntervalServiceImpl implements BusIntervalService { |
| 1387 | 1473 | String model = map.get("model").toString(); |
| 1388 | 1474 | String times = map.get("times").toString(); |
| 1389 | 1475 | String type = map.get("type").toString(); |
| 1476 | + int sfqr = Integer.valueOf(map.get("sfqr").toString()); | |
| 1390 | 1477 | |
| 1391 | 1478 | if(startDate.length() == 0){ |
| 1392 | 1479 | startDate = new SimpleDateFormat("yyyy-MM-dd").format(new Date()); |
| ... | ... | @@ -1395,10 +1482,10 @@ public class BusIntervalServiceImpl implements BusIntervalService { |
| 1395 | 1482 | endDate = new SimpleDateFormat("yyyy-MM-dd").format(new Date()); |
| 1396 | 1483 | } |
| 1397 | 1484 | if(times.length() == 0){ |
| 1398 | - times = "06:00-07:00"; | |
| 1485 | + times = "05:00-23:00"; | |
| 1399 | 1486 | } |
| 1400 | 1487 | |
| 1401 | - list = getSchedule(company, subCompany, line, startDate, endDate, model, times, true); | |
| 1488 | + list = getSchedule(company, subCompany, line, startDate, endDate, model, sfqr==1?times:"", true); | |
| 1402 | 1489 | |
| 1403 | 1490 | String[] date1 = startDate.split("-"); |
| 1404 | 1491 | String[] date2 = endDate.split("-"); |
| ... | ... | @@ -1417,7 +1504,7 @@ public class BusIntervalServiceImpl implements BusIntervalService { |
| 1417 | 1504 | |
| 1418 | 1505 | for(ScheduleRealInfo schedule : list){ |
| 1419 | 1506 | Long fcsj = schedule.getFcsjT(); |
| 1420 | - if(!(endTime!=0?fcsj>=startTime&&fcsj<endTime:fcsj>=startTime)){ | |
| 1507 | + if(sfqr == 1 && !(endTime!=0?fcsj>=startTime&&fcsj<endTime:fcsj>=startTime)){ | |
| 1421 | 1508 | continue; |
| 1422 | 1509 | } |
| 1423 | 1510 | String key = schedule.getXlName(); |
| ... | ... | @@ -1571,6 +1658,7 @@ public class BusIntervalServiceImpl implements BusIntervalService { |
| 1571 | 1658 | String endDate = map.get("endDate").toString(); |
| 1572 | 1659 | String times = map.get("times").toString(); |
| 1573 | 1660 | String type = map.get("type").toString(); |
| 1661 | + int sfqr = Integer.valueOf(map.get("sfqr").toString()); | |
| 1574 | 1662 | |
| 1575 | 1663 | if(startDate.length() == 0){ |
| 1576 | 1664 | startDate = new SimpleDateFormat("yyyy-MM-dd").format(new Date()); |
| ... | ... | @@ -1584,7 +1672,7 @@ public class BusIntervalServiceImpl implements BusIntervalService { |
| 1584 | 1672 | if(line.length() != 0){ |
| 1585 | 1673 | sql += " and xl_bm = '"+line+"'"; |
| 1586 | 1674 | } |
| 1587 | - if(times.length() != 0){ | |
| 1675 | + if(sfqr == 1 && times.length() != 0){ | |
| 1588 | 1676 | String[] split = times.split("-"); |
| 1589 | 1677 | String[] split0 = split[0].split(":"); |
| 1590 | 1678 | String[] split1 = split[1].split(":"); |
| ... | ... | @@ -1651,6 +1739,8 @@ public class BusIntervalServiceImpl implements BusIntervalService { |
| 1651 | 1739 | date = startDate + "--" + endDate; |
| 1652 | 1740 | |
| 1653 | 1741 | for(ScheduleRealInfo schedule : list){ |
| 1742 | + if(schedule.getXlName() == null || schedule.getXlName().trim().length() == 0) | |
| 1743 | + continue; | |
| 1654 | 1744 | String key = schedule.getGsName() + "/" + schedule.getFgsName() + "/" + schedule.getXlName(); |
| 1655 | 1745 | if(!keyMap.containsKey(key)) |
| 1656 | 1746 | keyMap.put(key, new ArrayList<ScheduleRealInfo>()); | ... | ... |