Commit cb9e67ff05cd414ded1cdaa4c6fd226336892efc

Authored by 潘钊
1 parent 85e1836c

update...

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