Commit cb9e67ff05cd414ded1cdaa4c6fd226336892efc
1 parent
85e1836c
update...
Showing
9 changed files
with
64 additions
and
15 deletions
src/main/java/com/bsth/data/gpsdata_v2/DataHandleProcess.java
| ... | ... | @@ -97,6 +97,9 @@ public class DataHandleProcess { |
| 97 | 97 | try { |
| 98 | 98 | for (GpsEntity gps : list) { |
| 99 | 99 | try{ |
| 100 | + if(Math.abs(gps.getTimestamp() - gps.getServerTimestamp()) > 1000 * 60 * 20) | |
| 101 | + continue; | |
| 102 | + | |
| 100 | 103 | gpsStateProcess.process(gps);//状态处理 |
| 101 | 104 | stationInsideProcess.process(gps);//场站内外判定 |
| 102 | 105 | reverseRouteProcess.process(gps);//反向路由处理 | ... | ... |
src/main/java/com/bsth/data/gpsdata_v2/cache/GeoCacheData.java
| ... | ... | @@ -297,6 +297,19 @@ public class GeoCacheData { |
| 297 | 297 | } |
| 298 | 298 | } |
| 299 | 299 | |
| 300 | + /** | |
| 301 | + * 是否是环线 | |
| 302 | + * @param lineId | |
| 303 | + * @return | |
| 304 | + */ | |
| 305 | + public static boolean isLoopLine(String lineId) { | |
| 306 | + List<StationRoute> srs = getStationRoute(lineId , 0); | |
| 307 | + if(srs.get(0).getName().equals(srs.get(srs.size()- 1).getName()) | |
| 308 | + && getStationRoute(lineId , 1).size()==2) | |
| 309 | + return true; | |
| 310 | + return false; | |
| 311 | + } | |
| 312 | + | |
| 300 | 313 | private static class PreconditionGeoComp implements Comparator<PreconditionGeo>{ |
| 301 | 314 | |
| 302 | 315 | @Override | ... | ... |
src/main/java/com/bsth/data/gpsdata_v2/cache/GpsCacheData.java
| ... | ... | @@ -104,6 +104,29 @@ public class GpsCacheData { |
| 104 | 104 | return null; |
| 105 | 105 | } |
| 106 | 106 | |
| 107 | + /** | |
| 108 | + * 最后一段轨迹 | |
| 109 | + * @param gps | |
| 110 | + * @return | |
| 111 | + */ | |
| 112 | + public static int lastInTrailsSize(GpsEntity gps) { | |
| 113 | + //int size = 0; | |
| 114 | + List<GpsExecTrail> trails = trailListMultimap.get(gps.getNbbm()); | |
| 115 | + if(null == trails || trails.size() == 0) | |
| 116 | + return 0; | |
| 117 | + | |
| 118 | + GpsExecTrail gs = trails.get(trails.size() - 1); | |
| 119 | + if(gs.isEnd()) | |
| 120 | + return 0; | |
| 121 | + | |
| 122 | + Set<String> set = new HashSet<>(); | |
| 123 | + for(GpsEntity g : gs.getSrs()){ | |
| 124 | + if(g.getInstation() == 1) | |
| 125 | + set.add(g.getStation().getName()); | |
| 126 | + } | |
| 127 | + return set.size(); | |
| 128 | + } | |
| 129 | + | |
| 107 | 130 | public static List<StationRoute> prevMultiStation(GpsEntity gps) { |
| 108 | 131 | List<StationRoute> rs = new ArrayList<>(); |
| 109 | 132 | List<GpsExecTrail> trails = trailListMultimap.get(gps.getNbbm()); | ... | ... |
src/main/java/com/bsth/data/gpsdata_v2/handlers/InStationProcess.java
| ... | ... | @@ -76,18 +76,17 @@ public class InStationProcess { |
| 76 | 76 | * @param prev |
| 77 | 77 | */ |
| 78 | 78 | private void inStation(GpsEntity gps, GpsEntity prev) { |
| 79 | + ScheduleRealInfo sch = dayOfSchedule.executeCurr(gps.getNbbm()); | |
| 79 | 80 | boolean flow = true; |
| 80 | - //要经过一个中途站才能进 | |
| 81 | - StationRoute s = GpsCacheData.prevStation(gps); | |
| 81 | + //要经过2个中途站才能进 | |
| 82 | + int count = GpsCacheData.lastInTrailsSize(gps); | |
| 82 | 83 | List<StationRoute> routes = GeoCacheData.getStationRoute(gps.getLineId(), gps.getUpDown()); |
| 83 | - if (gps.getInstation() == 1 && routes.size() > 3 | |
| 84 | - && null != s && s.getName().equals(gps.getStation().getName())) { | |
| 84 | + if (isNotInOut(sch) && gps.getInstation() == 1 && routes.size() > 4 | |
| 85 | + && count < 2) { | |
| 85 | 86 | logger.info("没有进中途站,拒绝进站... -" + gps.getNbbm() + " -time:" + gps.getTimestamp()); |
| 86 | 87 | flow = false; |
| 87 | 88 | } |
| 88 | 89 | |
| 89 | - | |
| 90 | - ScheduleRealInfo sch = dayOfSchedule.executeCurr(gps.getNbbm()); | |
| 91 | 90 | boolean isEnd = false; |
| 92 | 91 | |
| 93 | 92 | //进终点 |
| ... | ... | @@ -99,6 +98,10 @@ public class InStationProcess { |
| 99 | 98 | GpsCacheData.in(gps, isEnd); |
| 100 | 99 | } |
| 101 | 100 | |
| 101 | + private boolean isNotInOut(ScheduleRealInfo sch) { | |
| 102 | + return !sch.getBcType().equals("in") && !sch.getBcType().equals("out"); | |
| 103 | + } | |
| 104 | + | |
| 102 | 105 | /** |
| 103 | 106 | * 进班次终点 |
| 104 | 107 | * | ... | ... |
src/main/java/com/bsth/data/gpsdata_v2/handlers/OutStationProcess.java
| ... | ... | @@ -73,7 +73,7 @@ public class OutStationProcess { |
| 73 | 73 | (sch.getQdzCode().equals(prev.getStopNo()) || sch.getQdzCode().equals(prev.getCarparkNo()))){ |
| 74 | 74 | //发车班次匹配 |
| 75 | 75 | if(!signalSchPlanMatcher.outMatch(gps, sch)){ |
| 76 | - //outStation(gps); | |
| 76 | + outStation(gps, prev); | |
| 77 | 77 | return; |
| 78 | 78 | } |
| 79 | 79 | ... | ... |
src/main/java/com/bsth/data/gpsdata_v2/handlers/ReverseRouteProcess.java
| 1 | 1 | package com.bsth.data.gpsdata_v2.handlers; |
| 2 | 2 | |
| 3 | +import com.bsth.data.gpsdata_v2.cache.GeoCacheData; | |
| 3 | 4 | import com.bsth.data.gpsdata_v2.cache.GpsCacheData; |
| 4 | 5 | import com.bsth.data.gpsdata_v2.entity.GpsEntity; |
| 5 | 6 | import com.bsth.data.gpsdata_v2.entity.StationRoute; |
| ... | ... | @@ -25,7 +26,7 @@ public class ReverseRouteProcess { |
| 25 | 26 | DayOfSchedule dayOfSchedule; |
| 26 | 27 | |
| 27 | 28 | public void process(GpsEntity gps){ |
| 28 | - if(reversRoute(gps)){ | |
| 29 | + if(reversRoute(gps) && !GeoCacheData.isLoopLine(gps.getLineId())){ | |
| 29 | 30 | ScheduleRealInfo sch = dayOfSchedule.executeCurr(gps.getNbbm()); |
| 30 | 31 | if(isInOut(sch) || !sch.getXlBm().equals(gps.getLineId())) |
| 31 | 32 | return; | ... | ... |
src/main/java/com/bsth/data/gpsdata_v2/utils/GpsDataRecovery.java
| ... | ... | @@ -40,6 +40,7 @@ public class GpsDataRecovery implements ApplicationContextAware { |
| 40 | 40 | static InStationProcess inStationProcess; |
| 41 | 41 | static OutStationProcess outStationProcess; |
| 42 | 42 | static AbnormalStateProcess abnormalStateProcess; |
| 43 | + static ReverseRouteProcess reverseRouteProcess; | |
| 43 | 44 | |
| 44 | 45 | public void recovery() { |
| 45 | 46 | List<GpsEntity> list = loadData(); |
| ... | ... | @@ -59,7 +60,7 @@ public class GpsDataRecovery implements ApplicationContextAware { |
| 59 | 60 | for (String nbbm : keys) { |
| 60 | 61 | Collections.sort(listMap.get(nbbm), comp); |
| 61 | 62 | threadPool.submit(new RecoveryThread(listMap.get(nbbm), count)); |
| 62 | - /*if(nbbm.equals("S0L-065")) | |
| 63 | + /*if(nbbm.equals("W7C-035")) | |
| 63 | 64 | new RecoveryThread(listMap.get(nbbm), count).run();*/ |
| 64 | 65 | /*if(lineId.equals("60028")) |
| 65 | 66 | new RecoveryThread(listMap.get(lineId), count).run();*/ |
| ... | ... | @@ -83,7 +84,7 @@ public class GpsDataRecovery implements ApplicationContextAware { |
| 83 | 84 | Calendar calendar = Calendar.getInstance(); |
| 84 | 85 | int dayOfYear = calendar.get(Calendar.DAY_OF_YEAR); |
| 85 | 86 | |
| 86 | - String sql = "select DEVICE_ID,LAT,LON,TS,SPEED_GPS,LINE_ID,SERVICE_STATE from bsth_c_gps_info where days_year=" + dayOfYear; | |
| 87 | + String sql = "select DEVICE_ID,LAT,LON,TS,SPEED_GPS,LINE_ID,SERVICE_STATE,SERVER_TS from bsth_c_gps_info where days_year=327"; //+ dayOfYear; | |
| 87 | 88 | JdbcTemplate jdbcTemplate = new JdbcTemplate(DBUtils_MS.getDataSource()); |
| 88 | 89 | |
| 89 | 90 | List<GpsEntity> list = |
| ... | ... | @@ -100,6 +101,7 @@ public class GpsDataRecovery implements ApplicationContextAware { |
| 100 | 101 | gps.setLineId(rs.getString("LINE_ID")); |
| 101 | 102 | gps.setTimestamp(rs.getLong("TS")); |
| 102 | 103 | gps.setUpDown((byte) getUpOrDown(rs.getLong("SERVICE_STATE"))); |
| 104 | + gps.setServerTimestamp(rs.getLong("SERVER_TS")); | |
| 103 | 105 | return gps; |
| 104 | 106 | } |
| 105 | 107 | }); |
| ... | ... | @@ -125,6 +127,7 @@ public class GpsDataRecovery implements ApplicationContextAware { |
| 125 | 127 | inStationProcess = applicationContext.getBean(InStationProcess.class); |
| 126 | 128 | outStationProcess = applicationContext.getBean(OutStationProcess.class); |
| 127 | 129 | abnormalStateProcess = applicationContext.getBean(AbnormalStateProcess.class); |
| 130 | + reverseRouteProcess = applicationContext.getBean(ReverseRouteProcess.class); | |
| 128 | 131 | } |
| 129 | 132 | |
| 130 | 133 | public static class GpsComp implements Comparator<GpsEntity> { |
| ... | ... | @@ -151,12 +154,15 @@ public class GpsDataRecovery implements ApplicationContextAware { |
| 151 | 154 | for (GpsEntity gps : list) { |
| 152 | 155 | try { |
| 153 | 156 | |
| 154 | - /*if(gps.getTimestamp() >= 1511386080000L) | |
| 157 | + /*if(gps.getTimestamp() >= 1511396220000L) | |
| 155 | 158 | System.out.println("aaa");*/ |
| 156 | 159 | |
| 160 | + if(Math.abs(gps.getTimestamp() - gps.getServerTimestamp()) > 1000 * 60 * 20) | |
| 161 | + continue; | |
| 162 | + | |
| 157 | 163 | gpsStateProcess.process(gps);//状态处理 |
| 158 | 164 | stationInsideProcess.process(gps);//场站内外判定 |
| 159 | - | |
| 165 | + reverseRouteProcess.process(gps);//反向路由处理 | |
| 160 | 166 | |
| 161 | 167 | abnormalStateProcess.process(gps);//超速越界 |
| 162 | 168 | ... | ... |
src/main/java/com/bsth/data/gpsdata_v2/utils/GpsDataUtils.java
src/main/java/com/bsth/data/gpsdata_v2/utils/SignalSchPlanMatcher.java
| ... | ... | @@ -39,8 +39,8 @@ public class SignalSchPlanMatcher { |
| 39 | 39 | return true; |
| 40 | 40 | |
| 41 | 41 | try{ |
| 42 | - //晚于待发时间 半小时 ,匹配一下最佳的班次 | |
| 43 | - if(t - sch.getDfsjT() > 1000 * 60 * 30){ | |
| 42 | + //晚于待发时间 10 分钟 ,匹配一下最佳的班次 | |
| 43 | + if(t - sch.getDfsjT() > 1000 * 60 * 10){ | |
| 44 | 44 | ScheduleRealInfo near = searchNearOut(gps); |
| 45 | 45 | |
| 46 | 46 | if(null != near && !near.getId().equals(sch.getId())){ | ... | ... |