Commit 13ba7d4d83b279959d57677b9dd632a175aeb402
1 parent
c117dacc
update...
Showing
13 changed files
with
312 additions
and
14 deletions
src/main/java/com/bsth/data/gpsdata/GpsEntity.java
| @@ -79,6 +79,12 @@ public class GpsEntity implements Cloneable{ | @@ -79,6 +79,12 @@ public class GpsEntity implements Cloneable{ | ||
| 79 | @JsonIgnore | 79 | @JsonIgnore |
| 80 | private StationRoute station; | 80 | private StationRoute station; |
| 81 | 81 | ||
| 82 | + /** | ||
| 83 | + * 前置约束 -站点编码 | ||
| 84 | + */ | ||
| 85 | + @JsonIgnore | ||
| 86 | + private String premiseCode; | ||
| 87 | + | ||
| 82 | /** 状态 */ | 88 | /** 状态 */ |
| 83 | private String signalState = "normal"; | 89 | private String signalState = "normal"; |
| 84 | 90 | ||
| @@ -358,4 +364,12 @@ public class GpsEntity implements Cloneable{ | @@ -358,4 +364,12 @@ public class GpsEntity implements Cloneable{ | ||
| 358 | public void setServerTimestamp(Long serverTimestamp) { | 364 | public void setServerTimestamp(Long serverTimestamp) { |
| 359 | this.serverTimestamp = serverTimestamp; | 365 | this.serverTimestamp = serverTimestamp; |
| 360 | } | 366 | } |
| 367 | + | ||
| 368 | + public String getPremiseCode() { | ||
| 369 | + return premiseCode; | ||
| 370 | + } | ||
| 371 | + | ||
| 372 | + public void setPremiseCode(String premiseCode) { | ||
| 373 | + this.premiseCode = premiseCode; | ||
| 374 | + } | ||
| 361 | } | 375 | } |
src/main/java/com/bsth/data/gpsdata/arrival/GeoCacheData.java
| @@ -3,8 +3,10 @@ package com.bsth.data.gpsdata.arrival; | @@ -3,8 +3,10 @@ package com.bsth.data.gpsdata.arrival; | ||
| 3 | import com.bsth.data.gpsdata.GpsEntity; | 3 | import com.bsth.data.gpsdata.GpsEntity; |
| 4 | import com.bsth.data.gpsdata.arrival.entity.StationRoute; | 4 | import com.bsth.data.gpsdata.arrival.entity.StationRoute; |
| 5 | import com.bsth.data.gpsdata.arrival.entity.TimedEnableStationRoute; | 5 | import com.bsth.data.gpsdata.arrival.entity.TimedEnableStationRoute; |
| 6 | +import com.bsth.data.gpsdata.arrival.precondition.entity.PreconditionGeo; | ||
| 6 | import com.bsth.data.gpsdata.arrival.utils.CircleQueue; | 7 | import com.bsth.data.gpsdata.arrival.utils.CircleQueue; |
| 7 | import com.bsth.data.gpsdata.arrival.utils.StationRouteComp; | 8 | import com.bsth.data.gpsdata.arrival.utils.StationRouteComp; |
| 9 | +import com.google.common.base.Splitter; | ||
| 8 | import com.google.common.collect.ArrayListMultimap; | 10 | import com.google.common.collect.ArrayListMultimap; |
| 9 | import com.vividsolutions.jts.geom.Coordinate; | 11 | import com.vividsolutions.jts.geom.Coordinate; |
| 10 | import com.vividsolutions.jts.geom.GeometryFactory; | 12 | import com.vividsolutions.jts.geom.GeometryFactory; |
| @@ -14,6 +16,7 @@ import org.apache.commons.lang3.StringUtils; | @@ -14,6 +16,7 @@ import org.apache.commons.lang3.StringUtils; | ||
| 14 | import org.slf4j.Logger; | 16 | import org.slf4j.Logger; |
| 15 | import org.slf4j.LoggerFactory; | 17 | import org.slf4j.LoggerFactory; |
| 16 | import org.springframework.beans.factory.annotation.Autowired; | 18 | import org.springframework.beans.factory.annotation.Autowired; |
| 19 | +import org.springframework.jdbc.core.BeanPropertyRowMapper; | ||
| 17 | import org.springframework.jdbc.core.JdbcTemplate; | 20 | import org.springframework.jdbc.core.JdbcTemplate; |
| 18 | import org.springframework.jdbc.core.RowMapper; | 21 | import org.springframework.jdbc.core.RowMapper; |
| 19 | import org.springframework.stereotype.Component; | 22 | import org.springframework.stereotype.Component; |
| @@ -42,6 +45,8 @@ public class GeoCacheData { | @@ -42,6 +45,8 @@ public class GeoCacheData { | ||
| 42 | 45 | ||
| 43 | //线路站点路由 | 46 | //线路站点路由 |
| 44 | private static ArrayListMultimap<String, StationRoute> stationCacheMap; | 47 | private static ArrayListMultimap<String, StationRoute> stationCacheMap; |
| 48 | + //线路前置进站围栏 | ||
| 49 | + public static ArrayListMultimap<String, PreconditionGeo> premiseGeoMap; | ||
| 45 | 50 | ||
| 46 | //线路_上下行_站点编码 ——> 站点 | 51 | //线路_上下行_站点编码 ——> 站点 |
| 47 | private static Map<String, StationRoute> routeCodeMap; | 52 | private static Map<String, StationRoute> routeCodeMap; |
| @@ -56,7 +61,6 @@ public class GeoCacheData { | @@ -56,7 +61,6 @@ public class GeoCacheData { | ||
| 56 | 61 | ||
| 57 | //需要定时刷新的站点路由 | 62 | //需要定时刷新的站点路由 |
| 58 | public static Map<String, TimedEnableStationRoute> tesMap = new HashMap<>(); | 63 | public static Map<String, TimedEnableStationRoute> tesMap = new HashMap<>(); |
| 59 | - //TimedEnableStationRoute | ||
| 60 | 64 | ||
| 61 | @Autowired | 65 | @Autowired |
| 62 | JdbcTemplate jdbcTemplate; | 66 | JdbcTemplate jdbcTemplate; |
| @@ -68,10 +72,6 @@ public class GeoCacheData { | @@ -68,10 +72,6 @@ public class GeoCacheData { | ||
| 68 | public static void putGps(GpsEntity gps) { | 72 | public static void putGps(GpsEntity gps) { |
| 69 | CircleQueue<GpsEntity> queue = gpsCacheMap.get(gps.getNbbm()); | 73 | CircleQueue<GpsEntity> queue = gpsCacheMap.get(gps.getNbbm()); |
| 70 | if (queue == null) { | 74 | if (queue == null) { |
| 71 | - /*//第一个点从站内开始 | ||
| 72 | - if (gps.getInstation() == 0) | ||
| 73 | - return;*/ | ||
| 74 | - | ||
| 75 | queue = new CircleQueue<>(CACHE_SIZE); | 75 | queue = new CircleQueue<>(CACHE_SIZE); |
| 76 | gpsCacheMap.put(gps.getNbbm(), queue); | 76 | gpsCacheMap.put(gps.getNbbm(), queue); |
| 77 | } | 77 | } |
| @@ -146,6 +146,61 @@ public class GeoCacheData { | @@ -146,6 +146,61 @@ public class GeoCacheData { | ||
| 146 | 146 | ||
| 147 | //加载路段信息 | 147 | //加载路段信息 |
| 148 | loadRoadsData(); | 148 | loadRoadsData(); |
| 149 | + | ||
| 150 | + //加载前置进站围栏 | ||
| 151 | + loadPremiseGeoData(); | ||
| 152 | + } | ||
| 153 | + | ||
| 154 | + private void loadPremiseGeoData() { | ||
| 155 | + ArrayListMultimap<String, PreconditionGeo> premiseGeoMapCopy = ArrayListMultimap.create(); | ||
| 156 | + | ||
| 157 | + String sql = "select * from bsth_f_geo_premise"; | ||
| 158 | + List<PreconditionGeo> list = jdbcTemplate.query(sql, BeanPropertyRowMapper.newInstance(PreconditionGeo.class)); | ||
| 159 | + | ||
| 160 | + List<String> coordList; | ||
| 161 | + String[] cs; | ||
| 162 | + com.bsth.util.Geo.Point point; | ||
| 163 | + List<com.bsth.util.Geo.Point> ps; | ||
| 164 | + StationRoute sr; | ||
| 165 | + for(PreconditionGeo p : list){ | ||
| 166 | + try{ | ||
| 167 | + sr = routeCodeMap.get(p.getLineCode()+"_"+p.getUpDown()+"_"+p.getStationCode()); | ||
| 168 | + p.setOrder(sr.getRouteSort()); | ||
| 169 | + //polygon | ||
| 170 | + ps = new ArrayList<>(); | ||
| 171 | + coordList = Splitter.on(",").trimResults().splitToList(p.getCoords()); | ||
| 172 | + for(String c : coordList){ | ||
| 173 | + cs = c.split(" "); | ||
| 174 | + point = new com.bsth.util.Geo.Point(Double.parseDouble(cs[0]), Double.parseDouble(cs[1])); | ||
| 175 | + ps.add(point); | ||
| 176 | + } | ||
| 177 | + | ||
| 178 | + p.setPolygon(new com.bsth.util.Geo.Polygon(ps)); | ||
| 179 | + | ||
| 180 | + sr.setPremise(true); | ||
| 181 | + //按线路,走向分组 | ||
| 182 | + premiseGeoMapCopy.put(p.getLineCode()+"_"+p.getUpDown(), p); | ||
| 183 | + }catch (Exception e){ | ||
| 184 | + logger.error("", e); | ||
| 185 | + } | ||
| 186 | + } | ||
| 187 | + | ||
| 188 | + //排序 | ||
| 189 | + Set<String> ks = premiseGeoMapCopy.keySet(); | ||
| 190 | + PreconditionGeoComp comp = new PreconditionGeoComp(); | ||
| 191 | + for(String k : ks){ | ||
| 192 | + Collections.sort(premiseGeoMapCopy.get(k), comp); | ||
| 193 | + } | ||
| 194 | + | ||
| 195 | + premiseGeoMap = premiseGeoMapCopy; | ||
| 196 | + } | ||
| 197 | + | ||
| 198 | + private static class PreconditionGeoComp implements Comparator<PreconditionGeo>{ | ||
| 199 | + | ||
| 200 | + @Override | ||
| 201 | + public int compare(PreconditionGeo p1, PreconditionGeo p2) { | ||
| 202 | + return p1.getOrder() - p2.getOrder(); | ||
| 203 | + } | ||
| 149 | } | 204 | } |
| 150 | 205 | ||
| 151 | private void loadRoadsData() { | 206 | private void loadRoadsData() { |
src/main/java/com/bsth/data/gpsdata/arrival/SignalHandle.java
| @@ -78,6 +78,7 @@ public abstract class SignalHandle { | @@ -78,6 +78,7 @@ public abstract class SignalHandle { | ||
| 78 | byte updown = Byte.parseByte(sch.getXlDir()); | 78 | byte updown = Byte.parseByte(sch.getXlDir()); |
| 79 | //gps 切换走向 | 79 | //gps 切换走向 |
| 80 | gps.setUpDown(updown); | 80 | gps.setUpDown(updown); |
| 81 | + gps.setPremiseCode(null); | ||
| 81 | 82 | ||
| 82 | List<StationRoute> srs = GeoCacheData.getStationRoute(sch.getXlBm(), updown); | 83 | List<StationRoute> srs = GeoCacheData.getStationRoute(sch.getXlBm(), updown); |
| 83 | StationRoute station = GeoUtils.gpsInStation(gps, srs); | 84 | StationRoute station = GeoUtils.gpsInStation(gps, srs); |
src/main/java/com/bsth/data/gpsdata/arrival/entity/StationRoute.java
| @@ -60,6 +60,11 @@ public class StationRoute { | @@ -60,6 +60,11 @@ public class StationRoute { | ||
| 60 | 60 | ||
| 61 | private String name; | 61 | private String name; |
| 62 | 62 | ||
| 63 | + /** | ||
| 64 | + * 是否有前置进站约束 | ||
| 65 | + */ | ||
| 66 | + private boolean premise; | ||
| 67 | + | ||
| 63 | public String getCode() { | 68 | public String getCode() { |
| 64 | return code; | 69 | return code; |
| 65 | } | 70 | } |
| @@ -147,5 +152,13 @@ public class StationRoute { | @@ -147,5 +152,13 @@ public class StationRoute { | ||
| 147 | public void setName(String name) { | 152 | public void setName(String name) { |
| 148 | this.name = name; | 153 | this.name = name; |
| 149 | } | 154 | } |
| 155 | + | ||
| 156 | + public boolean isPremise() { | ||
| 157 | + return premise; | ||
| 158 | + } | ||
| 159 | + | ||
| 160 | + public void setPremise(boolean premise) { | ||
| 161 | + this.premise = premise; | ||
| 162 | + } | ||
| 150 | } | 163 | } |
| 151 | 164 |
src/main/java/com/bsth/data/gpsdata/arrival/handlers/InOutStationSignalHandle.java
| @@ -4,6 +4,7 @@ import com.bsth.data.LineConfigData; | @@ -4,6 +4,7 @@ import com.bsth.data.LineConfigData; | ||
| 4 | import com.bsth.data.gpsdata.GpsEntity; | 4 | import com.bsth.data.gpsdata.GpsEntity; |
| 5 | import com.bsth.data.gpsdata.arrival.GeoCacheData; | 5 | import com.bsth.data.gpsdata.arrival.GeoCacheData; |
| 6 | import com.bsth.data.gpsdata.arrival.SignalHandle; | 6 | import com.bsth.data.gpsdata.arrival.SignalHandle; |
| 7 | +import com.bsth.data.gpsdata.arrival.entity.StationRoute; | ||
| 7 | import com.bsth.data.gpsdata.arrival.utils.CircleQueue; | 8 | import com.bsth.data.gpsdata.arrival.utils.CircleQueue; |
| 8 | import com.bsth.data.gpsdata.arrival.utils.ScheduleSignalState; | 9 | import com.bsth.data.gpsdata.arrival.utils.ScheduleSignalState; |
| 9 | import com.bsth.data.gpsdata.arrival.utils.SignalSchPlanMatcher; | 10 | import com.bsth.data.gpsdata.arrival.utils.SignalSchPlanMatcher; |
| @@ -148,6 +149,7 @@ public class InOutStationSignalHandle extends SignalHandle{ | @@ -148,6 +149,7 @@ public class InOutStationSignalHandle extends SignalHandle{ | ||
| 148 | && (gps.getInstation()==0 || !gps.getStopNo().equals(prev.getStopNo())) | 149 | && (gps.getInstation()==0 || !gps.getStopNo().equals(prev.getStopNo())) |
| 149 | && !willDepart(gps, prev, sch)){ | 150 | && !willDepart(gps, prev, sch)){ |
| 150 | 151 | ||
| 152 | + gps.setPremiseCode(null); | ||
| 151 | //发车班次匹配 | 153 | //发车班次匹配 |
| 152 | signalSchPlanMatcher.outMatch(gps, sch); | 154 | signalSchPlanMatcher.outMatch(gps, sch); |
| 153 | sch = dayOfSchedule.executeCurr(gps.getNbbm()); | 155 | sch = dayOfSchedule.executeCurr(gps.getNbbm()); |
| @@ -234,6 +236,10 @@ public class InOutStationSignalHandle extends SignalHandle{ | @@ -234,6 +236,10 @@ public class InOutStationSignalHandle extends SignalHandle{ | ||
| 234 | * @return | 236 | * @return |
| 235 | */ | 237 | */ |
| 236 | private boolean outManyFit(GpsEntity gps, ScheduleRealInfo sch) { | 238 | private boolean outManyFit(GpsEntity gps, ScheduleRealInfo sch) { |
| 239 | + LineConfig conf = lineConfigData.get(sch.getXlBm()); | ||
| 240 | + if(null != conf && conf.isLockFirstOutTime()) | ||
| 241 | + return false;//锁定第一个发车信号,不匹配最佳 | ||
| 242 | + | ||
| 237 | if(StringUtils.isNotEmpty(sch.getZdsjActual())) | 243 | if(StringUtils.isNotEmpty(sch.getZdsjActual())) |
| 238 | return false; | 244 | return false; |
| 239 | 245 | ||
| @@ -289,7 +295,7 @@ public class InOutStationSignalHandle extends SignalHandle{ | @@ -289,7 +295,7 @@ public class InOutStationSignalHandle extends SignalHandle{ | ||
| 289 | ScheduleRealInfo sch = dayOfSchedule.executeCurr(gps.getNbbm()); | 295 | ScheduleRealInfo sch = dayOfSchedule.executeCurr(gps.getNbbm()); |
| 290 | 296 | ||
| 291 | if(gps.getStopNo().equals(sch.getZdzCode()) | 297 | if(gps.getStopNo().equals(sch.getZdzCode()) |
| 292 | - && !gps.getStopNo().equals(prev.getStopNo())){ | 298 | + && (!gps.getStopNo().equals(prev.getStopNo()) || gps.getStopNo().equals(prev.getPremiseCode()))){ |
| 293 | 299 | ||
| 294 | int diff = 0; | 300 | int diff = 0; |
| 295 | try{ | 301 | try{ |
| @@ -305,6 +311,11 @@ public class InOutStationSignalHandle extends SignalHandle{ | @@ -305,6 +311,11 @@ public class InOutStationSignalHandle extends SignalHandle{ | ||
| 305 | if(Math.abs(diff) > MAX_NORMAL_DIFF) | 311 | if(Math.abs(diff) > MAX_NORMAL_DIFF) |
| 306 | return; | 312 | return; |
| 307 | 313 | ||
| 314 | + //校验进站前置约束 | ||
| 315 | + if(!validInPremise(gps)){ | ||
| 316 | + return; | ||
| 317 | + } | ||
| 318 | + | ||
| 308 | //环线或内外圈 ,飘出去再回来 | 319 | //环线或内外圈 ,飘出去再回来 |
| 309 | if(sch.getQdzCode().equals(sch.getZdzCode()) | 320 | if(sch.getQdzCode().equals(sch.getZdzCode()) |
| 310 | && StringUtils.isNotEmpty(sch.getFcsjActual()) | 321 | && StringUtils.isNotEmpty(sch.getFcsjActual()) |
| @@ -409,6 +420,28 @@ public class InOutStationSignalHandle extends SignalHandle{ | @@ -409,6 +420,28 @@ public class InOutStationSignalHandle extends SignalHandle{ | ||
| 409 | } | 420 | } |
| 410 | 421 | ||
| 411 | /** | 422 | /** |
| 423 | + * 校验进站前置约束 | ||
| 424 | + * @param gps | ||
| 425 | + * @return | ||
| 426 | + */ | ||
| 427 | + private boolean validInPremise(GpsEntity gps) { | ||
| 428 | + StationRoute sr = gps.getStation(); | ||
| 429 | + if(null == sr || !sr.isPremise()) | ||
| 430 | + return true; | ||
| 431 | + | ||
| 432 | + String premiseCode = gps.getPremiseCode(); | ||
| 433 | + | ||
| 434 | + if(StringUtils.isNotEmpty(premiseCode) && premiseCode.equals(gps.getStopNo())){ | ||
| 435 | + logger.info("满足前置进站约束 " + premiseCode); | ||
| 436 | + return true; | ||
| 437 | + } | ||
| 438 | + else{ | ||
| 439 | + logger.info(gps.getNbbm() + " not premiseCode 不满足前置进站约束 " + premiseCode); | ||
| 440 | + } | ||
| 441 | + return false; | ||
| 442 | + } | ||
| 443 | + | ||
| 444 | + /** | ||
| 412 | * 和当前进站信号最匹配的一个班次 | 445 | * 和当前进站信号最匹配的一个班次 |
| 413 | * @param gps | 446 | * @param gps |
| 414 | * @param halfList | 447 | * @param halfList |
src/main/java/com/bsth/data/gpsdata/arrival/handlers/StationInsideHandle.java
| @@ -6,6 +6,8 @@ import com.bsth.data.gpsdata.arrival.SignalHandle; | @@ -6,6 +6,8 @@ import com.bsth.data.gpsdata.arrival.SignalHandle; | ||
| 6 | import com.bsth.data.gpsdata.arrival.entity.StationRoute; | 6 | import com.bsth.data.gpsdata.arrival.entity.StationRoute; |
| 7 | import com.bsth.data.gpsdata.arrival.utils.CircleQueue; | 7 | import com.bsth.data.gpsdata.arrival.utils.CircleQueue; |
| 8 | import com.bsth.data.gpsdata.arrival.utils.GeoUtils; | 8 | import com.bsth.data.gpsdata.arrival.utils.GeoUtils; |
| 9 | +import org.slf4j.Logger; | ||
| 10 | +import org.slf4j.LoggerFactory; | ||
| 9 | import org.springframework.stereotype.Component; | 11 | import org.springframework.stereotype.Component; |
| 10 | 12 | ||
| 11 | import java.util.List; | 13 | import java.util.List; |
| @@ -17,6 +19,7 @@ import java.util.List; | @@ -17,6 +19,7 @@ import java.util.List; | ||
| 17 | @Component | 19 | @Component |
| 18 | public class StationInsideHandle extends SignalHandle { | 20 | public class StationInsideHandle extends SignalHandle { |
| 19 | 21 | ||
| 22 | + Logger logger = LoggerFactory.getLogger(this.getClass()); | ||
| 20 | 23 | ||
| 21 | @Override | 24 | @Override |
| 22 | public boolean handle(GpsEntity gps, CircleQueue<GpsEntity> prevs) { | 25 | public boolean handle(GpsEntity gps, CircleQueue<GpsEntity> prevs) { |
| @@ -37,13 +40,41 @@ public class StationInsideHandle extends SignalHandle { | @@ -37,13 +40,41 @@ public class StationInsideHandle extends SignalHandle { | ||
| 37 | gps.setStation(station); | 40 | gps.setStation(station); |
| 38 | } | 41 | } |
| 39 | 42 | ||
| 43 | + //是否在进站前置围栏内 | ||
| 44 | + String premiseCode = GeoUtils.gpsInPremiseGeo(gps); | ||
| 45 | + gps.setPremiseCode(premiseCode); | ||
| 46 | + | ||
| 47 | + if(isNotEmpty(prevs)){ | ||
| 48 | + try { | ||
| 49 | + GpsEntity prev = prevs.getTail(); | ||
| 50 | + //继承前置围栏 | ||
| 51 | + if(null == premiseCode && null != prev.getPremiseCode()) | ||
| 52 | + gps.setPremiseCode(prev.getPremiseCode()); | ||
| 53 | + | ||
| 54 | + //在场,站外 | ||
| 55 | + if(gps.getInstation() == 0){ | ||
| 56 | + //继承上一个点的站点编码 | ||
| 57 | + gps.setStopNo(prev.getStopNo()); | ||
| 58 | + | ||
| 59 | + /*if(null == premiseCode && null != prev.getPremiseCode()) | ||
| 60 | + gps.setPremiseCode(prev.getPremiseCode());*/ | ||
| 61 | + } | ||
| 62 | + /*else if(null != gps.getPremiseCode() && !gps.getStopNo().equals(gps.getPremiseCode())){ | ||
| 63 | + gps.setPremiseCode(null); | ||
| 64 | + }*/ | ||
| 65 | + }catch (Exception e){ | ||
| 66 | + logger.error("", e); | ||
| 67 | + } | ||
| 68 | + } | ||
| 69 | + | ||
| 70 | +/* | ||
| 40 | //在场,站外 | 71 | //在场,站外 |
| 41 | if(gps.getInstation() == 0 && isNotEmpty(prevs)){ | 72 | if(gps.getInstation() == 0 && isNotEmpty(prevs)){ |
| 42 | //继承上一个点的站点编码 | 73 | //继承上一个点的站点编码 |
| 43 | GpsEntity prev = prevs.getTail(); | 74 | GpsEntity prev = prevs.getTail(); |
| 44 | gps.setStopNo(prev.getStopNo()); | 75 | gps.setStopNo(prev.getStopNo()); |
| 45 | } | 76 | } |
| 46 | - | 77 | +*/ |
| 47 | return true; | 78 | return true; |
| 48 | } | 79 | } |
| 49 | } | 80 | } |
src/main/java/com/bsth/data/gpsdata/arrival/precondition/InPreconditionHandler.java
0 → 100644
| 1 | +package com.bsth.data.gpsdata.arrival.precondition; | ||
| 2 | + | ||
| 3 | +import com.bsth.data.gpsdata.GpsEntity; | ||
| 4 | +import org.springframework.stereotype.Component; | ||
| 5 | + | ||
| 6 | +/** | ||
| 7 | + * 进站(前置电子围栏) | ||
| 8 | + * Created by panzhao on 2017/9/23. | ||
| 9 | + */ | ||
| 10 | +@Component | ||
| 11 | +public class InPreconditionHandler { | ||
| 12 | + | ||
| 13 | + /** | ||
| 14 | + * 进站动作是否有通过前置围栏 | ||
| 15 | + * @param gps | ||
| 16 | + * @param prev | ||
| 17 | + * @return | ||
| 18 | + */ | ||
| 19 | + public boolean isPass(GpsEntity gps, GpsEntity prev){ | ||
| 20 | + return false; | ||
| 21 | + } | ||
| 22 | +} |
src/main/java/com/bsth/data/gpsdata/arrival/precondition/entity/PreconditionGeo.java
0 → 100644
| 1 | +package com.bsth.data.gpsdata.arrival.precondition.entity; | ||
| 2 | + | ||
| 3 | +import com.bsth.util.Geo.Polygon; | ||
| 4 | + | ||
| 5 | +/** | ||
| 6 | + * 前置围栏 -地理坐标 | ||
| 7 | + * Created by panzhao on 2017/9/23. | ||
| 8 | + */ | ||
| 9 | +public class PreconditionGeo { | ||
| 10 | + | ||
| 11 | + private String name; | ||
| 12 | + | ||
| 13 | + /** | ||
| 14 | + * 前置约束的站点编码 | ||
| 15 | + */ | ||
| 16 | + private String stationCode; | ||
| 17 | + | ||
| 18 | + /** | ||
| 19 | + * 线路编码 | ||
| 20 | + */ | ||
| 21 | + private String lineCode; | ||
| 22 | + | ||
| 23 | + /** | ||
| 24 | + * 上下行 | ||
| 25 | + */ | ||
| 26 | + private int upDown; | ||
| 27 | + | ||
| 28 | + /** | ||
| 29 | + * 多边形坐标 | ||
| 30 | + */ | ||
| 31 | + private String coords; | ||
| 32 | + | ||
| 33 | + private com.bsth.util.Geo.Polygon polygon; | ||
| 34 | + | ||
| 35 | + private Integer order; | ||
| 36 | + | ||
| 37 | + public String getName() { | ||
| 38 | + return name; | ||
| 39 | + } | ||
| 40 | + | ||
| 41 | + public void setName(String name) { | ||
| 42 | + this.name = name; | ||
| 43 | + } | ||
| 44 | + | ||
| 45 | + public String getStationCode() { | ||
| 46 | + return stationCode; | ||
| 47 | + } | ||
| 48 | + | ||
| 49 | + public void setStationCode(String stationCode) { | ||
| 50 | + this.stationCode = stationCode; | ||
| 51 | + } | ||
| 52 | + | ||
| 53 | + public String getLineCode() { | ||
| 54 | + return lineCode; | ||
| 55 | + } | ||
| 56 | + | ||
| 57 | + public void setLineCode(String lineCode) { | ||
| 58 | + this.lineCode = lineCode; | ||
| 59 | + } | ||
| 60 | + | ||
| 61 | + public int getUpDown() { | ||
| 62 | + return upDown; | ||
| 63 | + } | ||
| 64 | + | ||
| 65 | + public void setUpDown(int upDown) { | ||
| 66 | + this.upDown = upDown; | ||
| 67 | + } | ||
| 68 | + | ||
| 69 | + public String getCoords() { | ||
| 70 | + return coords; | ||
| 71 | + } | ||
| 72 | + | ||
| 73 | + public void setCoords(String coords) { | ||
| 74 | + this.coords = coords; | ||
| 75 | + } | ||
| 76 | + | ||
| 77 | + public Integer getOrder() { | ||
| 78 | + return order; | ||
| 79 | + } | ||
| 80 | + | ||
| 81 | + public void setOrder(Integer order) { | ||
| 82 | + this.order = order; | ||
| 83 | + } | ||
| 84 | + | ||
| 85 | + public Polygon getPolygon() { | ||
| 86 | + return polygon; | ||
| 87 | + } | ||
| 88 | + | ||
| 89 | + public void setPolygon(Polygon polygon) { | ||
| 90 | + this.polygon = polygon; | ||
| 91 | + } | ||
| 92 | +} |
src/main/java/com/bsth/data/gpsdata/arrival/utils/GeoUtils.java
| @@ -3,6 +3,7 @@ package com.bsth.data.gpsdata.arrival.utils; | @@ -3,6 +3,7 @@ package com.bsth.data.gpsdata.arrival.utils; | ||
| 3 | import com.bsth.data.gpsdata.GpsEntity; | 3 | import com.bsth.data.gpsdata.GpsEntity; |
| 4 | import com.bsth.data.gpsdata.arrival.GeoCacheData; | 4 | import com.bsth.data.gpsdata.arrival.GeoCacheData; |
| 5 | import com.bsth.data.gpsdata.arrival.entity.StationRoute; | 5 | import com.bsth.data.gpsdata.arrival.entity.StationRoute; |
| 6 | +import com.bsth.data.gpsdata.arrival.precondition.entity.PreconditionGeo; | ||
| 6 | import com.vividsolutions.jts.geom.Coordinate; | 7 | import com.vividsolutions.jts.geom.Coordinate; |
| 7 | import com.vividsolutions.jts.geom.GeometryFactory; | 8 | import com.vividsolutions.jts.geom.GeometryFactory; |
| 8 | import com.vividsolutions.jts.geom.LineString; | 9 | import com.vividsolutions.jts.geom.LineString; |
| @@ -169,6 +170,28 @@ public class GeoUtils { | @@ -169,6 +170,28 @@ public class GeoUtils { | ||
| 169 | } | 170 | } |
| 170 | 171 | ||
| 171 | /** | 172 | /** |
| 173 | + * 是否在进站前置围栏内 | ||
| 174 | + * @param gps | ||
| 175 | + * @return | ||
| 176 | + */ | ||
| 177 | + public static String gpsInPremiseGeo(GpsEntity gps) { | ||
| 178 | + List<PreconditionGeo> list = GeoCacheData.premiseGeoMap.get(gps.getLineId()+"_"+gps.getUpDown()); | ||
| 179 | + | ||
| 180 | + if(null == list || list.size()==0) | ||
| 181 | + return null; | ||
| 182 | + | ||
| 183 | + com.bsth.util.Geo.Point point = new com.bsth.util.Geo.Point(gps.getLon(), gps.getLat()); | ||
| 184 | + com.bsth.util.Geo.Polygon polygon; | ||
| 185 | + for(PreconditionGeo p : list){ | ||
| 186 | + polygon = p.getPolygon(); | ||
| 187 | + if(com.bsth.util.Geo.GeoUtils.isPointInPolygon(point, polygon)){ | ||
| 188 | + return p.getStationCode(); | ||
| 189 | + } | ||
| 190 | + } | ||
| 191 | + return null; | ||
| 192 | + } | ||
| 193 | + | ||
| 194 | + /** | ||
| 172 | * 是否是有效的连续点 | 195 | * 是否是有效的连续点 |
| 173 | * @param prevGps | 196 | * @param prevGps |
| 174 | * @param gps | 197 | * @param gps |
src/main/java/com/bsth/data/gpsdata/recovery/GpsDataRecovery.java
| @@ -60,7 +60,7 @@ public class GpsDataRecovery implements ApplicationContextAware { | @@ -60,7 +60,7 @@ public class GpsDataRecovery implements ApplicationContextAware { | ||
| 60 | for (String nbbm : keys) { | 60 | for (String nbbm : keys) { |
| 61 | Collections.sort(listMap.get(nbbm), comp); | 61 | Collections.sort(listMap.get(nbbm), comp); |
| 62 | threadPool.execute(new RecoveryThread(listMap.get(nbbm), count)); | 62 | threadPool.execute(new RecoveryThread(listMap.get(nbbm), count)); |
| 63 | - /*if(nbbm.equals("S0K-004")) | 63 | + /*if(nbbm.equals("W2H-015")) |
| 64 | new RecoveryThread(listMap.get(nbbm), count).run();*/ | 64 | new RecoveryThread(listMap.get(nbbm), count).run();*/ |
| 65 | /*if(lineId.equals("60028")) | 65 | /*if(lineId.equals("60028")) |
| 66 | new RecoveryThread(listMap.get(lineId), count).run();*/ | 66 | new RecoveryThread(listMap.get(lineId), count).run();*/ |
| @@ -84,7 +84,7 @@ public class GpsDataRecovery implements ApplicationContextAware { | @@ -84,7 +84,7 @@ public class GpsDataRecovery implements ApplicationContextAware { | ||
| 84 | Calendar calendar = Calendar.getInstance(); | 84 | Calendar calendar = Calendar.getInstance(); |
| 85 | int dayOfYear = calendar.get(Calendar.DAY_OF_YEAR); | 85 | int dayOfYear = calendar.get(Calendar.DAY_OF_YEAR); |
| 86 | 86 | ||
| 87 | - String sql = "select DEVICE_ID,LAT,LON,TS,SPEED_GPS,LINE_ID,SERVICE_STATE from bsth_c_gps_info where days_year=246";// + dayOfYear; | 87 | + String sql = "select DEVICE_ID,LAT,LON,TS,SPEED_GPS,LINE_ID,SERVICE_STATE from bsth_c_gps_info where days_year=267";// + dayOfYear; |
| 88 | JdbcTemplate jdbcTemplate = new JdbcTemplate(DBUtils_MS.getDataSource()); | 88 | JdbcTemplate jdbcTemplate = new JdbcTemplate(DBUtils_MS.getDataSource()); |
| 89 | 89 | ||
| 90 | List<GpsEntity> list = | 90 | List<GpsEntity> list = |
| @@ -153,7 +153,7 @@ public class GpsDataRecovery implements ApplicationContextAware { | @@ -153,7 +153,7 @@ public class GpsDataRecovery implements ApplicationContextAware { | ||
| 153 | boolean task; | 153 | boolean task; |
| 154 | for (GpsEntity gps : list) { | 154 | for (GpsEntity gps : list) { |
| 155 | try { | 155 | try { |
| 156 | - /*if(gps.getTimestamp() >= 1504298280000L){ | 156 | + /*if(gps.getTimestamp() >= 1506216540000L){ |
| 157 | System.out.println("debugger..."); | 157 | System.out.println("debugger..."); |
| 158 | }*/ | 158 | }*/ |
| 159 | //是否有任务 | 159 | //是否有任务 |
src/main/java/com/bsth/entity/realcontrol/LineConfig.java
| @@ -89,6 +89,11 @@ public class LineConfig { | @@ -89,6 +89,11 @@ public class LineConfig { | ||
| 89 | private int upStopMinute; | 89 | private int upStopMinute; |
| 90 | private int downStopMinute; | 90 | private int downStopMinute; |
| 91 | 91 | ||
| 92 | + /** | ||
| 93 | + * 使用第一个发车时间,不匹配最佳时间 | ||
| 94 | + */ | ||
| 95 | + private boolean lockFirstOutTime; | ||
| 96 | + | ||
| 92 | 97 | ||
| 93 | @OneToMany(cascade = CascadeType.ALL) | 98 | @OneToMany(cascade = CascadeType.ALL) |
| 94 | private Set<D80ReplyTemp> d80Temps = new HashSet<>(); | 99 | private Set<D80ReplyTemp> d80Temps = new HashSet<>(); |
| @@ -281,4 +286,12 @@ public class LineConfig { | @@ -281,4 +286,12 @@ public class LineConfig { | ||
| 281 | public void setTwinsStation(String twinsStation) { | 286 | public void setTwinsStation(String twinsStation) { |
| 282 | this.twinsStation = twinsStation; | 287 | this.twinsStation = twinsStation; |
| 283 | } | 288 | } |
| 289 | + | ||
| 290 | + public boolean isLockFirstOutTime() { | ||
| 291 | + return lockFirstOutTime; | ||
| 292 | + } | ||
| 293 | + | ||
| 294 | + public void setLockFirstOutTime(boolean lockFirstOutTime) { | ||
| 295 | + this.lockFirstOutTime = lockFirstOutTime; | ||
| 296 | + } | ||
| 284 | } | 297 | } |
src/main/java/com/bsth/entity/realcontrol/ScheduleRealInfo.java
| @@ -642,7 +642,8 @@ public class ScheduleRealInfo { | @@ -642,7 +642,8 @@ public class ScheduleRealInfo { | ||
| 642 | public void calcEndTime(){ | 642 | public void calcEndTime(){ |
| 643 | //计划终点时间 | 643 | //计划终点时间 |
| 644 | if(this.getBcsj() != null){ | 644 | if(this.getBcsj() != null){ |
| 645 | - this.setZdsjT(this.getDfsjT() + (this.getBcsj() * 60 * 1000)); | 645 | + //this.setZdsjT(this.getDfsjT() + (this.getBcsj() * 60 * 1000)); |
| 646 | + this.setZdsjT(this.getFcsjT() + (this.getBcsj() * 60 * 1000));//计划终点时间不变 | ||
| 646 | this.setZdsj(fmtHHmm.print(this.zdsjT)); | 647 | this.setZdsj(fmtHHmm.print(this.zdsjT)); |
| 647 | } | 648 | } |
| 648 | } | 649 | } |
src/main/java/com/bsth/service/realcontrol/impl/ScheduleRealInfoServiceImpl.java
| @@ -251,12 +251,12 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInf | @@ -251,12 +251,12 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInf | ||
| 251 | List<ScheduleRealInfo> ts = new ArrayList<>(); | 251 | List<ScheduleRealInfo> ts = new ArrayList<>(); |
| 252 | ts.add(schedule); | 252 | ts.add(schedule); |
| 253 | //调整终点时间和下一个班次的应到时间 | 253 | //调整终点时间和下一个班次的应到时间 |
| 254 | - schedule.calcEndTime(); | ||
| 255 | - ScheduleRealInfo nextSch = dayOfSchedule.nextByLp2(schedule); | 254 | + //schedule.calcEndTime(); |
| 255 | + /*ScheduleRealInfo nextSch = dayOfSchedule.nextByLp2(schedule); | ||
| 256 | if (null != nextSch) { | 256 | if (null != nextSch) { |
| 257 | nextSch.setQdzArrDatejh(schedule.getZdsj()); | 257 | nextSch.setQdzArrDatejh(schedule.getZdsj()); |
| 258 | ts.add(nextSch); | 258 | ts.add(nextSch); |
| 259 | - } | 259 | + }*/ |
| 260 | 260 | ||
| 261 | //调整班次类型 | 261 | //调整班次类型 |
| 262 | if (StringUtils.isNotEmpty(bcType) && !bcType.equals(schedule.getBcType())) { | 262 | if (StringUtils.isNotEmpty(bcType) && !bcType.equals(schedule.getBcType())) { |