Commit e3d75abfdaee07e6ef9c9dd7b58acff4750539d6
1 parent
a290c423
行驶时间车速
Showing
1 changed file
with
83 additions
and
47 deletions
src/main/java/com/bsth/service/impl/BusIntervalServiceImpl.java
| ... | ... | @@ -421,10 +421,10 @@ public class BusIntervalServiceImpl implements BusIntervalService { |
| 421 | 421 | long fcsj1 = fcsjs.get(i - 1); |
| 422 | 422 | long fcsj2 = fcsjs.get(i); |
| 423 | 423 | Long time = fcsj1/60; |
| 424 | - if(!timeMap0.containsKey(time) && !timeMap1.containsKey(time)){ | |
| 424 | + if(!timeMap0.containsKey(time)){ | |
| 425 | 425 | timeMap0.put(time, new ArrayList<Long>()); |
| 426 | - timeMap1.put(time, new ArrayList<Long>()); | |
| 427 | - timeList.add(time); | |
| 426 | + if(!timeList.contains(time)) | |
| 427 | + timeList.add(time); | |
| 428 | 428 | } |
| 429 | 429 | timeMap0.get(time).add(fcsj2 - fcsj1); |
| 430 | 430 | } |
| ... | ... | @@ -432,6 +432,11 @@ public class BusIntervalServiceImpl implements BusIntervalService { |
| 432 | 432 | long fcsj1 = fcsjAs.get(i - 1); |
| 433 | 433 | long fcsj2 = fcsjAs.get(i); |
| 434 | 434 | Long time = fcsj1/60; |
| 435 | + if(!timeMap1.containsKey(time)){ | |
| 436 | + timeMap1.put(time, new ArrayList<Long>()); | |
| 437 | + if(!timeList.contains(time)) | |
| 438 | + timeList.add(time); | |
| 439 | + } | |
| 435 | 440 | if(timeMap1.containsKey(time)){ |
| 436 | 441 | timeMap1.get(time).add(fcsj2 - fcsj1); |
| 437 | 442 | } |
| ... | ... | @@ -440,9 +445,8 @@ public class BusIntervalServiceImpl implements BusIntervalService { |
| 440 | 445 | for(int i = 1; i < fcsjs.size(); i++){ |
| 441 | 446 | long fcsj1 = fcsjs.get(i - 1); |
| 442 | 447 | long fcsj2 = fcsjs.get(i); |
| 443 | - if(!temp0.containsKey(key) && !temp1.containsKey(key)){ | |
| 448 | + if(!temp0.containsKey(key)){ | |
| 444 | 449 | temp0.put(key, new ArrayList<Long>()); |
| 445 | - temp1.put(key, new ArrayList<Long>()); | |
| 446 | 450 | if(!keyList.contains(key)) |
| 447 | 451 | keyList.add(key); |
| 448 | 452 | } |
| ... | ... | @@ -451,6 +455,12 @@ public class BusIntervalServiceImpl implements BusIntervalService { |
| 451 | 455 | for(int i = 1; i < fcsjAs.size(); i++){ |
| 452 | 456 | long fcsj1 = fcsjAs.get(i - 1); |
| 453 | 457 | long fcsj2 = fcsjAs.get(i); |
| 458 | + if(!temp1.containsKey(key)){ | |
| 459 | + temp1.put(key, new ArrayList<Long>()); | |
| 460 | + if(!keyList.contains(key)) | |
| 461 | + keyList.add(key); | |
| 462 | + } | |
| 463 | + System.out.println("key:"+key+" fcsj2:"+fcsj2+" fcsj1:"+fcsj2+" temp1:"+temp1.get(key)+" tem0:"+temp0.get(key)); | |
| 454 | 464 | temp1.get(key).add(fcsj2 - fcsj1); |
| 455 | 465 | } |
| 456 | 466 | } |
| ... | ... | @@ -461,14 +471,16 @@ public class BusIntervalServiceImpl implements BusIntervalService { |
| 461 | 471 | Map<String, Object> tempMap = new HashMap<String, Object>(); |
| 462 | 472 | List<Long> fcsjs = new ArrayList<Long>(); |
| 463 | 473 | List<Long> fcsjAs = new ArrayList<Long>(); |
| 464 | - for(Long l : timeMap0.get(time)){ | |
| 465 | - if(l < 90) | |
| 466 | - fcsjs.add(l); | |
| 467 | - } | |
| 468 | - for(Long l : timeMap1.get(time)){ | |
| 469 | - if(l < 90) | |
| 470 | - fcsjAs.add(l); | |
| 471 | - } | |
| 474 | + if(timeMap0.containsKey(time)) | |
| 475 | + for(Long l : timeMap0.get(time)){ | |
| 476 | + if(l < 90) | |
| 477 | + fcsjs.add(l); | |
| 478 | + } | |
| 479 | + if(timeMap1.containsKey(time)) | |
| 480 | + for(Long l : timeMap1.get(time)){ | |
| 481 | + if(l < 90) | |
| 482 | + fcsjAs.add(l); | |
| 483 | + } | |
| 472 | 484 | Collections.sort(fcsjs); |
| 473 | 485 | Collections.sort(fcsjAs); |
| 474 | 486 | String[] split = key.split("/"); |
| ... | ... | @@ -495,7 +507,8 @@ public class BusIntervalServiceImpl implements BusIntervalService { |
| 495 | 507 | tempMap.put("deviation", df.format(Double.valueOf(tempMap.get("sjInterval").toString()) |
| 496 | 508 | - Double.valueOf(tempMap.get("jhInterval").toString()))); |
| 497 | 509 | } |
| 498 | - tempList.add(tempMap); | |
| 510 | + if(fcsjs.size() != 0 || fcsjAs.size() != 0) | |
| 511 | + tempList.add(tempMap); | |
| 499 | 512 | } |
| 500 | 513 | } |
| 501 | 514 | } |
| ... | ... | @@ -504,11 +517,24 @@ public class BusIntervalServiceImpl implements BusIntervalService { |
| 504 | 517 | List<Long> sortList = new ArrayList<Long>(); |
| 505 | 518 | Map<Long, List<Map<String, Object>>> sortMap = new HashMap<Long, List<Map<String, Object>>>(); |
| 506 | 519 | for(Map<String, Object> m : tempList){ |
| 507 | - Long sort = Long.valueOf(m.get("times").toString().substring(0, 2)); | |
| 520 | + String times = m.get("times").toString(); | |
| 521 | + Long sort = Long.valueOf(times.substring(0, 2)); | |
| 508 | 522 | if(!sortMap.containsKey(sort)){ |
| 509 | 523 | sortMap.put(sort, new ArrayList<Map<String, Object>>()); |
| 510 | 524 | sortList.add(sort); |
| 511 | 525 | } |
| 526 | + String[] split = times.split("-"); | |
| 527 | + String[] split0 = split[0].split(":"); | |
| 528 | + String[] split1 = split[1].split(":"); | |
| 529 | + int t0 = Integer.valueOf(split0[0]); | |
| 530 | + int t1 = Integer.valueOf(split1[0]); | |
| 531 | + if(t0 >= 24){ | |
| 532 | + t0 = t0 - 24; | |
| 533 | + } | |
| 534 | + if(t1 >= 24){ | |
| 535 | + t1 = t1 - 24; | |
| 536 | + } | |
| 537 | + m.put("times", (t0>9?t0:("0"+t0))+":"+split0[1]+"-"+(t1>9?t1:("0"+t1))+":"+split1[1]); | |
| 512 | 538 | sortMap.get(sort).add(m); |
| 513 | 539 | } |
| 514 | 540 | Collections.sort(sortList); |
| ... | ... | @@ -531,14 +557,16 @@ public class BusIntervalServiceImpl implements BusIntervalService { |
| 531 | 557 | Map<String, Object> tempMap = new HashMap<String, Object>(); |
| 532 | 558 | List<Long> fcsjs = new ArrayList<Long>(); |
| 533 | 559 | List<Long> fcsjAs = new ArrayList<Long>(); |
| 534 | - for(Long l : temp0.get(key)){ | |
| 535 | - if(l < 90) | |
| 536 | - fcsjs.add(l); | |
| 537 | - } | |
| 538 | - for(Long l : temp1.get(key)){ | |
| 539 | - if(l < 90) | |
| 540 | - fcsjAs.add(l); | |
| 541 | - } | |
| 560 | + if(temp0.containsKey(key)) | |
| 561 | + for(Long l : temp0.get(key)){ | |
| 562 | + if(l < 90) | |
| 563 | + fcsjs.add(l); | |
| 564 | + } | |
| 565 | + if(temp0.containsKey(key)) | |
| 566 | + for(Long l : temp1.get(key)){ | |
| 567 | + if(l < 90) | |
| 568 | + fcsjAs.add(l); | |
| 569 | + } | |
| 542 | 570 | Collections.sort(fcsjs); |
| 543 | 571 | Collections.sort(fcsjAs); |
| 544 | 572 | long fcsj = 0l; |
| ... | ... | @@ -563,7 +591,8 @@ public class BusIntervalServiceImpl implements BusIntervalService { |
| 563 | 591 | tempMap.put("deviation", df.format(Double.valueOf(tempMap.get("sjInterval").toString()) |
| 564 | 592 | - Double.valueOf(tempMap.get("jhInterval").toString()))); |
| 565 | 593 | } |
| 566 | - resList.add(tempMap); | |
| 594 | + if(fcsjs.size() != 0 || fcsjAs.size() != 0) | |
| 595 | + resList.add(tempMap); | |
| 567 | 596 | } |
| 568 | 597 | } |
| 569 | 598 | } |
| ... | ... | @@ -601,6 +630,7 @@ public class BusIntervalServiceImpl implements BusIntervalService { |
| 601 | 630 | Map<String, List<ChildTaskPlan>> cMap = new HashMap<String, List<ChildTaskPlan>>(); |
| 602 | 631 | Map<String, Object> modelMap = new HashMap<String, Object>(); |
| 603 | 632 | Set<Long> tsSet = new HashSet<Long>(); |
| 633 | + Set<Long> ttSet = new HashSet<Long>(); | |
| 604 | 634 | |
| 605 | 635 | String company = map.get("company").toString(); |
| 606 | 636 | String subCompany = map.get("subCompany").toString(); |
| ... | ... | @@ -639,7 +669,9 @@ public class BusIntervalServiceImpl implements BusIntervalService { |
| 639 | 669 | } |
| 640 | 670 | where += " and bc_type != 'in' and bc_type != 'out' and bc_type != 'ldks'"; |
| 641 | 671 | |
| 642 | - String sql = "select * from bsth_c_s_sp_info_real where DATE_FORMAT(schedule_date,'%Y-%m-%d') >= '"+startDate+"'" | |
| 672 | + String sql = "select id, schedule_date_Str, real_exec_date, xl_name, lp_name, bcs, bcsj, jhlc," | |
| 673 | + + " fcsj, fcsj_actual, zdsj, zdsj_actual, qdz_name, zdz_name, xl_dir, status, remarks, gs_name, fgs_name, sp_id" | |
| 674 | + + " from bsth_c_s_sp_info_real where DATE_FORMAT(schedule_date,'%Y-%m-%d') >= '"+startDate+"'" | |
| 643 | 675 | + " and DATE_FORMAT(schedule_date,'%Y-%m-%d') <= '"+endDate+"'"+where+""; |
| 644 | 676 | |
| 645 | 677 | list = jdbcTemplate.query(sql, |
| ... | ... | @@ -652,11 +684,9 @@ public class BusIntervalServiceImpl implements BusIntervalService { |
| 652 | 684 | schedule.setRealExecDate(rs.getString("real_exec_date")); |
| 653 | 685 | schedule.setXlName(rs.getString("xl_name")); |
| 654 | 686 | schedule.setLpName(rs.getString("lp_name")); |
| 655 | - schedule.setBcType(rs.getString("bc_type")); | |
| 656 | 687 | schedule.setBcs(rs.getInt("bcs")); |
| 657 | 688 | schedule.setBcsj(rs.getInt("bcsj")); |
| 658 | 689 | schedule.setJhlc(rs.getDouble("jhlc")); |
| 659 | - schedule.setDfsj(rs.getString("dfsj")); | |
| 660 | 690 | schedule.setFcsj(rs.getString("fcsj")); |
| 661 | 691 | schedule.setFcsjActual(rs.getString("fcsj_actual")); |
| 662 | 692 | schedule.setZdsj(rs.getString("zdsj")); |
| ... | ... | @@ -668,12 +698,6 @@ public class BusIntervalServiceImpl implements BusIntervalService { |
| 668 | 698 | schedule.setRemarks(rs.getString("remarks")); |
| 669 | 699 | schedule.setGsName(rs.getString("gs_name")); |
| 670 | 700 | schedule.setFgsName(rs.getString("fgs_name")); |
| 671 | - schedule.setDfAuto(rs.getBoolean("df_auto")); | |
| 672 | - schedule.setOnline(rs.getBoolean("online")); | |
| 673 | - schedule.setClZbh(rs.getString("cl_zbh")); | |
| 674 | - schedule.setjGh(rs.getString("j_gh")); | |
| 675 | - schedule.setjName(rs.getString("j_name")); | |
| 676 | - schedule.setStatus(rs.getInt("status")); | |
| 677 | 701 | schedule.setSpId(rs.getLong("sp_id")); |
| 678 | 702 | |
| 679 | 703 | if(schedule.getFcsjActual() != null && schedule.getFcsjActual().trim().length() == 0){ |
| ... | ... | @@ -726,7 +750,7 @@ public class BusIntervalServiceImpl implements BusIntervalService { |
| 726 | 750 | { |
| 727 | 751 | List<Map<String, String>> temp1 = new ArrayList<Map<String, String>>(); |
| 728 | 752 | List<Map<String, String>> temp2 = new ArrayList<Map<String, String>>(); |
| 729 | - sql = "select * from bsth_c_s_sp_info where bc_type != 'in' and bc_type != 'out' and bc_type != 'ldks'"; | |
| 753 | + sql = "select id, lp, fcsj, xl_bm, tt_info from bsth_c_s_sp_info where bc_type != 'in' and bc_type != 'out' and bc_type != 'ldks'"; | |
| 730 | 754 | |
| 731 | 755 | if(startDate.equals(endDate)){ |
| 732 | 756 | sql += " and schedule_date = '"+startDate+"'"; |
| ... | ... | @@ -782,7 +806,7 @@ public class BusIntervalServiceImpl implements BusIntervalService { |
| 782 | 806 | } |
| 783 | 807 | } |
| 784 | 808 | |
| 785 | - sql = "select * from bsth_c_s_child_task order by start_date"; | |
| 809 | + sql = "select destroy, start_date, end_date, mileage, mileage_type, schedule from bsth_c_s_child_task order by start_date"; | |
| 786 | 810 | |
| 787 | 811 | cList = jdbcTemplate.query(sql, |
| 788 | 812 | new RowMapper<ChildTaskPlan>(){ |
| ... | ... | @@ -798,10 +822,12 @@ public class BusIntervalServiceImpl implements BusIntervalService { |
| 798 | 822 | return cTask; |
| 799 | 823 | } |
| 800 | 824 | }); |
| 801 | - | |
| 825 | + | |
| 802 | 826 | if(model.length() != 0){ |
| 803 | - sql = "select sp.id from bsth_c_s_sp_info sp left join bsth_c_s_ttinfo_detail tt on sp.tt_info = tt.ttinfo and sp.xl_bm = tt.xl and sp.lp = tt.lp and sp.fcsj = tt.fcsj " | |
| 804 | - + "where tt_info = '" + model + "' and bc_type != 'in' and bc_type != 'out' and bc_type != 'ldks'"; | |
| 827 | + sql = "select sp.id from " | |
| 828 | + + "(select id, tt_info, xl_bm, lp, fcsj from bsth_c_s_sp_info where schedule_date >= '"+startDate+"' and schedule_date <= '"+endDate+"'" | |
| 829 | + + " and tt_info = '" + model + "' and bc_type != 'in' and bc_type != 'out' and bc_type != 'ldks') sp" | |
| 830 | + + " left join bsth_c_s_ttinfo_detail tt on sp.tt_info = tt.ttinfo and sp.xl_bm = tt.xl and sp.lp = tt.lp and sp.fcsj = tt.fcsj"; | |
| 805 | 831 | |
| 806 | 832 | ttList = jdbcTemplate.query(sql, |
| 807 | 833 | new RowMapper<Map<String, Object>>(){ |
| ... | ... | @@ -809,10 +835,14 @@ public class BusIntervalServiceImpl implements BusIntervalService { |
| 809 | 835 | public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { |
| 810 | 836 | Map<String, Object> m = new HashMap<String, Object>(); |
| 811 | 837 | m.put("id", rs.getString("id")); |
| 812 | - m.put("ists", rs.getString("ists")!=null?rs.getString("ists"):"0"); | |
| 838 | +// m.put("ists", rs.getString("ists")!=null?rs.getString("ists"):"0"); | |
| 813 | 839 | return m; |
| 814 | 840 | } |
| 815 | 841 | }); |
| 842 | + | |
| 843 | + for(Map<String, Object> m : ttList){ | |
| 844 | + ttSet.add(Long.valueOf(m.get("id").toString())); | |
| 845 | + } | |
| 816 | 846 | } |
| 817 | 847 | |
| 818 | 848 | } catch (Exception e) { |
| ... | ... | @@ -852,15 +882,21 @@ public class BusIntervalServiceImpl implements BusIntervalService { |
| 852 | 882 | if(schedule.getXlName()==null || schedule.getXlName().trim().length()==0) |
| 853 | 883 | continue; |
| 854 | 884 | if(model.length() != 0){ |
| 855 | - for(Map<String, Object> tt : ttList){ | |
| 856 | - long id = Long.valueOf(tt.get("id").toString()); | |
| 857 | - if(id == (long)schedule.getSpId()){ | |
| 858 | - String key = schedule.getScheduleDateStr() + "/" + schedule.getXlName() + "/" + schedule.getLpName(); | |
| 859 | - if(!keyMap.containsKey(key)) | |
| 860 | - keyMap.put(key, new ArrayList<ScheduleRealInfo>()); | |
| 861 | - keyMap.get(key).add(schedule); | |
| 862 | - } | |
| 885 | + if(ttSet.contains(schedule.getSpId())){ | |
| 886 | + String key = schedule.getScheduleDateStr() + "/" + schedule.getXlName() + "/" + schedule.getLpName(); | |
| 887 | + if(!keyMap.containsKey(key)) | |
| 888 | + keyMap.put(key, new ArrayList<ScheduleRealInfo>()); | |
| 889 | + keyMap.get(key).add(schedule); | |
| 863 | 890 | } |
| 891 | +// for(Map<String, Object> tt : ttList){ | |
| 892 | +// long id = Long.valueOf(tt.get("id").toString()); | |
| 893 | +// if(id == (long)schedule.getSpId()){ | |
| 894 | +// String key = schedule.getScheduleDateStr() + "/" + schedule.getXlName() + "/" + schedule.getLpName(); | |
| 895 | +// if(!keyMap.containsKey(key)) | |
| 896 | +// keyMap.put(key, new ArrayList<ScheduleRealInfo>()); | |
| 897 | +// keyMap.get(key).add(schedule); | |
| 898 | +// } | |
| 899 | +// } | |
| 864 | 900 | }else{ |
| 865 | 901 | String key = schedule.getScheduleDateStr() + "/" + schedule.getXlName() + "/" + schedule.getLpName(); |
| 866 | 902 | if(!keyMap.containsKey(key)) | ... | ... |