Commit 25636958228afaa5e8001a1850cc0b1e22dfa880

Authored by 娄高锋
1 parent c857201c

行驶时间及车速统计表

src/main/java/com/bsth/service/impl/BusIntervalServiceImpl.java
... ... @@ -673,9 +673,10 @@ public class BusIntervalServiceImpl implements BusIntervalService {
673 673 if(sfqr == 1){
674 674 where += " and zdsj >= '"+times1+"' and fcsj <= '"+times2+"'";
675 675 }
676   - where += " and bc_type != 'in' and bc_type != 'out' and bc_type != 'ldks'";
  676 +// where += " and bc_type != 'in' and bc_type != 'out' and bc_type != 'ldks'";
  677 + where += " and bc_type != 'ldks'";
677 678  
678   - String sql = "select id, schedule_date_Str, real_exec_date, xl_name, lp_name, bcs, bcsj, jhlc,"
  679 + String sql = "select id, schedule_date_Str, real_exec_date, xl_name, lp_name, bcs, bcsj, jhlc, bc_type,"
679 680 + " fcsj, fcsj_actual, zdsj, zdsj_actual, qdz_name, zdz_name, xl_dir, status, remarks, gs_name, fgs_name, sp_id"
680 681 + " from bsth_c_s_sp_info_real where DATE_FORMAT(schedule_date,'%Y-%m-%d') >= '"+startDate+"'"
681 682 + " and DATE_FORMAT(schedule_date,'%Y-%m-%d') <= '"+endDate+"'"+where+"";
... ... @@ -699,6 +700,7 @@ public class BusIntervalServiceImpl implements BusIntervalService {
699 700 schedule.setZdsjActual(rs.getString("zdsj_actual"));
700 701 schedule.setQdzName(rs.getString("qdz_name"));
701 702 schedule.setZdzName(rs.getString("zdz_name"));
  703 + schedule.setBcType(rs.getString("bc_type"));
702 704 schedule.setXlDir(rs.getString("xl_dir"));
703 705 schedule.setStatus(rs.getInt("status"));
704 706 schedule.setRemarks(rs.getString("remarks"));
... ... @@ -832,7 +834,7 @@ public class BusIntervalServiceImpl implements BusIntervalService {
832 834 if(model.length() != 0){
833 835 sql = "select sp.id from "
834 836 + "(select id, tt_info, xl_bm, lp, fcsj from bsth_c_s_sp_info where schedule_date >= '"+startDate+"' and schedule_date <= '"+endDate+"'"
835   - + " and tt_info = '" + model + "' and bc_type != 'in' and bc_type != 'out' and bc_type != 'ldks') sp"
  837 + + " and tt_info = '" + model + "' and bc_type != 'ldks') sp"
836 838 + " 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";
837 839  
838 840 ttList = jdbcTemplate.query(sql,
... ... @@ -915,6 +917,7 @@ public class BusIntervalServiceImpl implements BusIntervalService {
915 917 for(String key : keyMap.keySet()){
916 918 Map<String, Object> tempMap = new HashMap<String, Object>();
917 919 Map<Long, ScheduleRealInfo> sortMap = new HashMap<Long, ScheduleRealInfo>();
  920 + Map<Long, Map<String, Object>> sortMap1 = new HashMap<Long, Map<String, Object>>();
918 921 List<Map<String, Object>> mapList = new ArrayList<Map<String, Object>>();
919 922 List<Long> keyList = new ArrayList<Long>();
920 923 List<Long> keyList2 = new ArrayList<Long>();
... ... @@ -946,30 +949,25 @@ public class BusIntervalServiceImpl implements BusIntervalService {
946 949 for(int i = 1; i < keyList.size(); i++){
947 950 ScheduleRealInfo schedule1 = sortMap.get(keyList.get(i - 1));
948 951 ScheduleRealInfo schedule2 = sortMap.get(keyList.get(i));
949   - if(!tsSet.contains(schedule1.getId())){
950   - if(sfqr == 1 && time1 > schedule1.getFcsjT()){
951   - jhyysj += schedule2.getFcsjT() - time1;
952   - }else if(sfqr == 1 && time2 < schedule2.getFcsjT()){
953   - jhyysj += time2 - schedule1.getFcsjT();
  952 + if(!tsSet.contains(schedule1.getId()) && !schedule1.getBcType().toString().equals("in") && !schedule1.getBcType().toString().equals("out")){
  953 + long fcsj1 = schedule1.getFcsjT();
  954 + long fcsj2 = schedule2.getFcsjT();
  955 + if(tsSet.contains(schedule2.getId()) || schedule2.getBcType().toString().equals("in") || schedule2.getBcType().toString().equals("out")){
  956 + fcsj2 = schedule1.getZdsjT();
  957 + }
  958 + if(sfqr == 1 && time1 > fcsj1){
  959 + jhyysj += fcsj2 - time1;
  960 + }else if(sfqr == 1 && time2 < fcsj2){
  961 + jhyysj += time2 - fcsj1;
954 962 }else{
955   - jhyysj += schedule2.getFcsjT() - schedule1.getFcsjT();
  963 + jhyysj += fcsj2 - fcsj1;
956 964 }
957   - jhyysj1 += schedule2.getFcsjT() - schedule1.getFcsjT();
958   - }
959   - long zdsj2 = schedule2.getZdsjT();
960   - long fcsj2 = schedule2.getFcsjT();
961   - if(fcsj2 > zdsj2)
962   - zdsj2 += 1440l;
963   - if(sfqr == 1 && time1 > fcsj2){
964   - jhyssj += zdsj2 - time1;
965   - }else if(sfqr == 1 && time2 < zdsj2){
966   - jhyssj += time2 - fcsj2;
967   - }else{
968   - jhyssj += zdsj2 - fcsj2;
  965 + if(jhyysj < 0){
  966 + System.out.println(fcsj2 + " - " + fcsj1);
  967 + }
  968 + jhyysj1 += fcsj2 - fcsj1;
969 969 }
970   - jhyssj1 += zdsj2 - fcsj2;
971   - jhlc += schedule2.getJhlc()==null?0:schedule2.getJhlc();
972   - if(i == 1){
  970 + if(i == 1 && schedule1.getBcType().toString().equals("normal")){
973 971 long zdsj1 = schedule1.getZdsjT();
974 972 long fcsj1 = schedule1.getFcsjT();
975 973 if(fcsj1 > zdsj1)
... ... @@ -984,12 +982,27 @@ public class BusIntervalServiceImpl implements BusIntervalService {
984 982 jhyssj1 += zdsj1 - fcsj1;
985 983 jhlc += schedule1.getJhlc()==null?0:schedule1.getJhlc();
986 984 }
  985 + if(schedule2.getBcType().toString().equals("normal")){
  986 + long zdsj2 = schedule2.getZdsjT();
  987 + long fcsj2 = schedule2.getFcsjT();
  988 + if(fcsj2 > zdsj2)
  989 + zdsj2 += 1440l;
  990 + if(sfqr == 1 && time1 > fcsj2){
  991 + jhyssj += zdsj2 - time1;
  992 + }else if(sfqr == 1 && time2 < zdsj2){
  993 + jhyssj += time2 - fcsj2;
  994 + }else{
  995 + jhyssj += zdsj2 - fcsj2;
  996 + }
  997 + jhyssj1 += zdsj2 - fcsj2;
  998 + jhlc += schedule2.getJhlc()==null?0:schedule2.getJhlc();
  999 + }
987 1000 }
988 1001  
989 1002 for(int i = 0; i < keyList.size(); i++){
990 1003 Map<String, Object> m = new HashMap<String, Object>();
991 1004 ScheduleRealInfo schedule = sortMap.get(keyList.get(i));
992   -
  1005 +
993 1006 if(cMap.containsKey(schedule.getId())){
994 1007 List<ChildTaskPlan> cTasks = cMap.get(schedule.getId());
995 1008 for(ChildTaskPlan childTaskPlan : cTasks){
... ... @@ -1012,6 +1025,7 @@ public class BusIntervalServiceImpl implements BusIntervalService {
1012 1025 temp.put("fcsj", null);
1013 1026 }
1014 1027 }
  1028 + temp.put("bcType", schedule.getBcType());
1015 1029 mapList.add(temp);
1016 1030 }
1017 1031 }else{
... ... @@ -1029,6 +1043,7 @@ public class BusIntervalServiceImpl implements BusIntervalService {
1029 1043 m.put("zdsj", null);
1030 1044 m.put("fcsj", null);
1031 1045 }
  1046 + m.put("bcType", schedule.getBcType());
1032 1047 mapList.add(m);
1033 1048 }
1034 1049 }
... ... @@ -1036,6 +1051,7 @@ public class BusIntervalServiceImpl implements BusIntervalService {
1036 1051 for(Map<String, Object> m : mapList){
1037 1052 if(m.get("fcsj") != null && m.get("fcsj").toString().trim().length()!=0){
1038 1053 keyList2.add(Long.valueOf(m.get("fcsj").toString()));
  1054 + sortMap1.put(Long.valueOf(m.get("fcsj").toString()), m);
1039 1055 }
1040 1056 }
1041 1057 Collections.sort(keyList2);
... ... @@ -1043,36 +1059,31 @@ public class BusIntervalServiceImpl implements BusIntervalService {
1043 1059 for(int i = 1; i < keyList2.size(); i++){
1044 1060 long fcsj1 = keyList2.get(i - 1);
1045 1061 long fcsj2 = keyList2.get(i);
1046   - if(fcsj2 - fcsj1 < 90){
1047   - if(sfqr == 1 && time1 > fcsj1){
1048   - sjyysj += fcsj2 - time1;
1049   - }else if(sfqr == 1 && time2 < fcsj2){
1050   - sjyysj += time2 - fcsj1;
1051   - }else{
1052   - sjyysj += fcsj2 - fcsj1;
1053   - }
1054   - sjyysj1 += fcsj2 - fcsj1;
  1062 + Map<String, Object> m1 = sortMap1.get(fcsj1);
  1063 + Map<String, Object> m2 = sortMap1.get(fcsj2);
  1064 + if(m1.get("bcType").toString().equals("in") || m1.get("bcType").toString().equals("out"))
  1065 + continue;
  1066 + if(m2.get("bcType").toString().equals("in") || m2.get("bcType").toString().equals("out")){
  1067 + fcsj2 = Long.valueOf(m1.get("zdsj").toString());
  1068 + } else if(i == keyList.size() - 1){
  1069 + fcsj2 = Long.valueOf(m2.get("zdsj").toString());
  1070 + }
  1071 + if(sfqr == 1 && time1 > fcsj1){
  1072 + sjyysj += fcsj2 - time1;
  1073 + }else if(sfqr == 1 && time2 < fcsj2){
  1074 + sjyysj += time2 - fcsj1;
  1075 + }else{
  1076 + sjyysj += fcsj2 - fcsj1;
1055 1077 }
  1078 + sjyysj1 += fcsj2 - fcsj1;
1056 1079 }
1057 1080  
1058   - for(int i = 1; i < mapList.size(); i++){
1059   - Map<String, Object> m1 = mapList.get(i - 1);
1060   - Map<String, Object> m2 = mapList.get(i);
1061   -// if(m1.get("fcsj") != null && m2.get("fcsj") != null){
1062   -// long fcsj2 = Long.valueOf(m2.get("fcsj").toString());
1063   -// long fcsj1 = Long.valueOf(m1.get("fcsj").toString());
1064   -// if(sfqr == 1 && time1 > fcsj1){
1065   -// sjyysj += fcsj2 - time1;
1066   -// }else if(sfqr == 1 && time2 < fcsj2){
1067   -// sjyysj += time2 - fcsj1;
1068   -// }else{
1069   -// sjyysj += fcsj2 - fcsj1;
1070   -// }
1071   -// sjyysj1 += fcsj2 - fcsj1;
1072   -// }
1073   - if(m2.get("fcsj") != null && m2.get("zdsj") != null){
1074   - long zdsj = Long.valueOf(m2.get("zdsj").toString());
1075   - long fcsj = Long.valueOf(m2.get("fcsj").toString());
  1081 + for(int i = 0; i < mapList.size(); i++){
  1082 + Map<String, Object> m = mapList.get(i);
  1083 + if(m.get("fcsj") != null && m.get("zdsj") != null &&
  1084 + !m.get("bcType").toString().equals("in") && !m.get("bcType").toString().equals("out")){
  1085 + long zdsj = Long.valueOf(m.get("zdsj").toString());
  1086 + long fcsj = Long.valueOf(m.get("fcsj").toString());
1076 1087 if(fcsj > zdsj)
1077 1088 zdsj += 1440l;
1078 1089 if(sfqr == 1 && time1 > fcsj){
... ... @@ -1083,22 +1094,7 @@ public class BusIntervalServiceImpl implements BusIntervalService {
1083 1094 sjyssj += zdsj - fcsj;
1084 1095 }
1085 1096 sjyssj1 += zdsj - fcsj;
1086   - sjlc += Double.valueOf(m2.get("lc").toString());
1087   - }
1088   - if(i == 1 && m1.get("fcsj") != null && m1.get("zdsj") != null){
1089   - long zdsj = Long.valueOf(m1.get("zdsj").toString());
1090   - long fcsj = Long.valueOf(m1.get("fcsj").toString());
1091   - if(fcsj > zdsj)
1092   - zdsj += 1440l;
1093   - if(sfqr == 1 && time1 > fcsj){
1094   - sjyssj += zdsj - time1;
1095   - }else if(sfqr == 1 && time2 < zdsj){
1096   - sjyssj += time2 - fcsj;
1097   - }else{
1098   - sjyssj += zdsj - fcsj;
1099   - }
1100   - sjyssj1 += zdsj - fcsj;
1101   - sjlc += Double.valueOf(m1.get("lc").toString());
  1097 + sjlc += Double.valueOf(m.get("lc").toString());
1102 1098 }
1103 1099 }
1104 1100 tempMap.put("company", companyName);
... ...