Commit e270f96c4ccbe8d0a19b44e5b0a41787fc7f5036

Authored by 娄高锋
1 parent d124d9c9

行驶时间及车速统计表

src/main/java/com/bsth/service/impl/BusIntervalServiceImpl.java
... ... @@ -666,9 +666,10 @@ public class BusIntervalServiceImpl implements BusIntervalService {
666 666 if(sfqr == 1){
667 667 where += " and zdsj >= '"+times1+"' and fcsj <= '"+times2+"'";
668 668 }
669   - where += " and bc_type != 'in' and bc_type != 'out' and bc_type != 'ldks'";
  669 +// where += " and bc_type != 'in' and bc_type != 'out' and bc_type != 'ldks'";
  670 + where += " and bc_type != 'ldks'";
670 671  
671   - String sql = "select id, schedule_date_Str, real_exec_date, xl_name, lp_name, bcs, bcsj, jhlc,"
  672 + String sql = "select id, schedule_date_Str, real_exec_date, xl_name, lp_name, bcs, bcsj, jhlc, bc_type,"
672 673 + " fcsj, fcsj_actual, zdsj, zdsj_actual, qdz_name, zdz_name, xl_dir, status, remarks, gs_name, fgs_name, sp_id"
673 674 + " from bsth_c_s_sp_info_real where DATE_FORMAT(schedule_date,'%Y-%m-%d') >= '"+startDate+"'"
674 675 + " and DATE_FORMAT(schedule_date,'%Y-%m-%d') <= '"+endDate+"'"+where+"";
... ... @@ -692,6 +693,7 @@ public class BusIntervalServiceImpl implements BusIntervalService {
692 693 schedule.setZdsjActual(rs.getString("zdsj_actual"));
693 694 schedule.setQdzName(rs.getString("qdz_name"));
694 695 schedule.setZdzName(rs.getString("zdz_name"));
  696 + schedule.setBcType(rs.getString("bc_type"));
695 697 schedule.setXlDir(rs.getString("xl_dir"));
696 698 schedule.setStatus(rs.getInt("status"));
697 699 schedule.setRemarks(rs.getString("remarks"));
... ... @@ -825,7 +827,7 @@ public class BusIntervalServiceImpl implements BusIntervalService {
825 827 if(model.length() != 0){
826 828 sql = "select sp.id from "
827 829 + "(select id, tt_info, xl_bm, lp, fcsj from bsth_c_s_sp_info where schedule_date >= '"+startDate+"' and schedule_date <= '"+endDate+"'"
828   - + " and tt_info = '" + model + "' and bc_type != 'in' and bc_type != 'out' and bc_type != 'ldks') sp"
  830 + + " and tt_info = '" + model + "' and bc_type != 'ldks') sp"
829 831 + " 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";
830 832  
831 833 ttList = jdbcTemplate.query(sql,
... ... @@ -908,6 +910,7 @@ public class BusIntervalServiceImpl implements BusIntervalService {
908 910 for(String key : keyMap.keySet()){
909 911 Map<String, Object> tempMap = new HashMap<String, Object>();
910 912 Map<Long, ScheduleRealInfo> sortMap = new HashMap<Long, ScheduleRealInfo>();
  913 + Map<Long, Map<String, Object>> sortMap1 = new HashMap<Long, Map<String, Object>>();
911 914 List<Map<String, Object>> mapList = new ArrayList<Map<String, Object>>();
912 915 List<Long> keyList = new ArrayList<Long>();
913 916 List<Long> keyList2 = new ArrayList<Long>();
... ... @@ -939,30 +942,25 @@ public class BusIntervalServiceImpl implements BusIntervalService {
939 942 for(int i = 1; i < keyList.size(); i++){
940 943 ScheduleRealInfo schedule1 = sortMap.get(keyList.get(i - 1));
941 944 ScheduleRealInfo schedule2 = sortMap.get(keyList.get(i));
942   - if(!tsSet.contains(schedule1.getId())){
943   - if(sfqr == 1 && time1 > schedule1.getFcsjT()){
944   - jhyysj += schedule2.getFcsjT() - time1;
945   - }else if(sfqr == 1 && time2 < schedule2.getFcsjT()){
946   - jhyysj += time2 - schedule1.getFcsjT();
  945 + if(!tsSet.contains(schedule1.getId()) && !schedule1.getBcType().toString().equals("in") && !schedule1.getBcType().toString().equals("out")){
  946 + long fcsj1 = schedule1.getFcsjT();
  947 + long fcsj2 = schedule2.getFcsjT();
  948 + if(tsSet.contains(schedule2.getId()) || schedule2.getBcType().toString().equals("in") || schedule2.getBcType().toString().equals("out")){
  949 + fcsj2 = schedule1.getZdsjT();
  950 + }
  951 + if(sfqr == 1 && time1 > fcsj1){
  952 + jhyysj += fcsj2 - time1;
  953 + }else if(sfqr == 1 && time2 < fcsj2){
  954 + jhyysj += time2 - fcsj1;
947 955 }else{
948   - jhyysj += schedule2.getFcsjT() - schedule1.getFcsjT();
  956 + jhyysj += fcsj2 - fcsj1;
949 957 }
950   - jhyysj1 += schedule2.getFcsjT() - schedule1.getFcsjT();
951   - }
952   - long zdsj2 = schedule2.getZdsjT();
953   - long fcsj2 = schedule2.getFcsjT();
954   - if(fcsj2 > zdsj2)
955   - zdsj2 += 1440l;
956   - if(sfqr == 1 && time1 > fcsj2){
957   - jhyssj += zdsj2 - time1;
958   - }else if(sfqr == 1 && time2 < zdsj2){
959   - jhyssj += time2 - fcsj2;
960   - }else{
961   - jhyssj += zdsj2 - fcsj2;
  958 + if(jhyysj < 0){
  959 + System.out.println(fcsj2 + " - " + fcsj1);
  960 + }
  961 + jhyysj1 += fcsj2 - fcsj1;
962 962 }
963   - jhyssj1 += zdsj2 - fcsj2;
964   - jhlc += schedule2.getJhlc()==null?0:schedule2.getJhlc();
965   - if(i == 1){
  963 + if(i == 1 && schedule1.getBcType().toString().equals("normal")){
966 964 long zdsj1 = schedule1.getZdsjT();
967 965 long fcsj1 = schedule1.getFcsjT();
968 966 if(fcsj1 > zdsj1)
... ... @@ -977,12 +975,27 @@ public class BusIntervalServiceImpl implements BusIntervalService {
977 975 jhyssj1 += zdsj1 - fcsj1;
978 976 jhlc += schedule1.getJhlc()==null?0:schedule1.getJhlc();
979 977 }
  978 + if(schedule2.getBcType().toString().equals("normal")){
  979 + long zdsj2 = schedule2.getZdsjT();
  980 + long fcsj2 = schedule2.getFcsjT();
  981 + if(fcsj2 > zdsj2)
  982 + zdsj2 += 1440l;
  983 + if(sfqr == 1 && time1 > fcsj2){
  984 + jhyssj += zdsj2 - time1;
  985 + }else if(sfqr == 1 && time2 < zdsj2){
  986 + jhyssj += time2 - fcsj2;
  987 + }else{
  988 + jhyssj += zdsj2 - fcsj2;
  989 + }
  990 + jhyssj1 += zdsj2 - fcsj2;
  991 + jhlc += schedule2.getJhlc()==null?0:schedule2.getJhlc();
  992 + }
980 993 }
981 994  
982 995 for(int i = 0; i < keyList.size(); i++){
983 996 Map<String, Object> m = new HashMap<String, Object>();
984 997 ScheduleRealInfo schedule = sortMap.get(keyList.get(i));
985   -
  998 +
986 999 if(cMap.containsKey(schedule.getId())){
987 1000 List<ChildTaskPlan> cTasks = cMap.get(schedule.getId());
988 1001 for(ChildTaskPlan childTaskPlan : cTasks){
... ... @@ -1005,6 +1018,7 @@ public class BusIntervalServiceImpl implements BusIntervalService {
1005 1018 temp.put("fcsj", null);
1006 1019 }
1007 1020 }
  1021 + temp.put("bcType", schedule.getBcType());
1008 1022 mapList.add(temp);
1009 1023 }
1010 1024 }else{
... ... @@ -1022,6 +1036,7 @@ public class BusIntervalServiceImpl implements BusIntervalService {
1022 1036 m.put("zdsj", null);
1023 1037 m.put("fcsj", null);
1024 1038 }
  1039 + m.put("bcType", schedule.getBcType());
1025 1040 mapList.add(m);
1026 1041 }
1027 1042 }
... ... @@ -1029,6 +1044,7 @@ public class BusIntervalServiceImpl implements BusIntervalService {
1029 1044 for(Map<String, Object> m : mapList){
1030 1045 if(m.get("fcsj") != null && m.get("fcsj").toString().trim().length()!=0){
1031 1046 keyList2.add(Long.valueOf(m.get("fcsj").toString()));
  1047 + sortMap1.put(Long.valueOf(m.get("fcsj").toString()), m);
1032 1048 }
1033 1049 }
1034 1050 Collections.sort(keyList2);
... ... @@ -1036,36 +1052,31 @@ public class BusIntervalServiceImpl implements BusIntervalService {
1036 1052 for(int i = 1; i < keyList2.size(); i++){
1037 1053 long fcsj1 = keyList2.get(i - 1);
1038 1054 long fcsj2 = keyList2.get(i);
1039   - if(fcsj2 - fcsj1 < 90){
1040   - if(sfqr == 1 && time1 > fcsj1){
1041   - sjyysj += fcsj2 - time1;
1042   - }else if(sfqr == 1 && time2 < fcsj2){
1043   - sjyysj += time2 - fcsj1;
1044   - }else{
1045   - sjyysj += fcsj2 - fcsj1;
1046   - }
1047   - sjyysj1 += fcsj2 - fcsj1;
  1055 + Map<String, Object> m1 = sortMap1.get(fcsj1);
  1056 + Map<String, Object> m2 = sortMap1.get(fcsj2);
  1057 + if(m1.get("bcType").toString().equals("in") || m1.get("bcType").toString().equals("out"))
  1058 + continue;
  1059 + if(m2.get("bcType").toString().equals("in") || m2.get("bcType").toString().equals("out")){
  1060 + fcsj2 = Long.valueOf(m1.get("zdsj").toString());
  1061 + } else if(i == keyList.size() - 1){
  1062 + fcsj2 = Long.valueOf(m2.get("zdsj").toString());
  1063 + }
  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;
1048 1070 }
  1071 + sjyysj1 += fcsj2 - fcsj1;
1049 1072 }
1050 1073  
1051   - for(int i = 1; i < mapList.size(); i++){
1052   - Map<String, Object> m1 = mapList.get(i - 1);
1053   - Map<String, Object> m2 = mapList.get(i);
1054   -// if(m1.get("fcsj") != null && m2.get("fcsj") != null){
1055   -// long fcsj2 = Long.valueOf(m2.get("fcsj").toString());
1056   -// long fcsj1 = Long.valueOf(m1.get("fcsj").toString());
1057   -// if(sfqr == 1 && time1 > fcsj1){
1058   -// sjyysj += fcsj2 - time1;
1059   -// }else if(sfqr == 1 && time2 < fcsj2){
1060   -// sjyysj += time2 - fcsj1;
1061   -// }else{
1062   -// sjyysj += fcsj2 - fcsj1;
1063   -// }
1064   -// sjyysj1 += fcsj2 - fcsj1;
1065   -// }
1066   - if(m2.get("fcsj") != null && m2.get("zdsj") != null){
1067   - long zdsj = Long.valueOf(m2.get("zdsj").toString());
1068   - long fcsj = Long.valueOf(m2.get("fcsj").toString());
  1074 + for(int i = 0; i < mapList.size(); i++){
  1075 + Map<String, Object> m = mapList.get(i);
  1076 + if(m.get("fcsj") != null && m.get("zdsj") != null &&
  1077 + !m.get("bcType").toString().equals("in") && !m.get("bcType").toString().equals("out")){
  1078 + long zdsj = Long.valueOf(m.get("zdsj").toString());
  1079 + long fcsj = Long.valueOf(m.get("fcsj").toString());
1069 1080 if(fcsj > zdsj)
1070 1081 zdsj += 1440l;
1071 1082 if(sfqr == 1 && time1 > fcsj){
... ... @@ -1076,22 +1087,7 @@ public class BusIntervalServiceImpl implements BusIntervalService {
1076 1087 sjyssj += zdsj - fcsj;
1077 1088 }
1078 1089 sjyssj1 += zdsj - fcsj;
1079   - sjlc += Double.valueOf(m2.get("lc").toString());
1080   - }
1081   - if(i == 1 && m1.get("fcsj") != null && m1.get("zdsj") != null){
1082   - long zdsj = Long.valueOf(m1.get("zdsj").toString());
1083   - long fcsj = Long.valueOf(m1.get("fcsj").toString());
1084   - if(fcsj > zdsj)
1085   - zdsj += 1440l;
1086   - if(sfqr == 1 && time1 > fcsj){
1087   - sjyssj += zdsj - time1;
1088   - }else if(sfqr == 1 && time2 < zdsj){
1089   - sjyssj += time2 - fcsj;
1090   - }else{
1091   - sjyssj += zdsj - fcsj;
1092   - }
1093   - sjyssj1 += zdsj - fcsj;
1094   - sjlc += Double.valueOf(m1.get("lc").toString());
  1090 + sjlc += Double.valueOf(m.get("lc").toString());
1095 1091 }
1096 1092 }
1097 1093 tempMap.put("company", companyName);
... ...