Commit 3ba92f76e2c431400f000253c3fb471732449881

Authored by 潘钊
1 parent 7bfd3a16

update...

src/main/java/com/bsth/data/gpsdata_v2/handlers/AbnormalStateProcess.java
1 1 package com.bsth.data.gpsdata_v2.handlers;
2 2  
  3 +import com.alibaba.fastjson.JSON;
3 4 import com.bsth.data.gpsdata_v2.cache.GeoCacheData;
4 5 import com.bsth.data.gpsdata_v2.entity.CtLineString;
5 6 import com.bsth.data.gpsdata_v2.entity.GpsEntity;
6 7 import com.bsth.data.gpsdata_v2.utils.GeoUtils;
7 8 import com.bsth.util.Geo.Point;
  9 +import org.slf4j.Logger;
  10 +import org.slf4j.LoggerFactory;
8 11 import org.springframework.stereotype.Component;
9 12  
10 13 import java.util.List;
... ... @@ -25,16 +28,22 @@ public class AbnormalStateProcess {
25 28 */
26 29 private static final double OUT_BOUNDS_THRESHOLD = 100;
27 30  
  31 + Logger logger = LoggerFactory.getLogger(this.getClass());
28 32  
29 33 public void process(GpsEntity gps) {
30   - if(isOffline(gps))
31   - return;
32   -
33   - if(overspeed(gps))
34   - return;
35   -
36   - if(outOfBounds((gps)))
37   - return;
  34 + try{
  35 + if(isOffline(gps))
  36 + return;
  37 +
  38 + if(overspeed(gps))
  39 + return;
  40 +
  41 + if(outOfBounds((gps)))
  42 + return;
  43 + }catch (Exception e){
  44 + logger.error("AbnormalStateProcess error", e);
  45 + logger.error("AbnormalStateProcess error data", JSON.toJSONString(gps));
  46 + }
38 47 }
39 48  
40 49 private boolean isOffline(GpsEntity gps){
... ...
src/main/java/com/bsth/data/gpsdata_v2/handlers/GpsStateProcess.java
1 1 package com.bsth.data.gpsdata_v2.handlers;
2 2  
  3 +import com.alibaba.fastjson.JSON;
3 4 import com.bsth.data.gpsdata_v2.entity.GpsEntity;
4 5 import com.bsth.data.gpsdata_v2.status_manager.GpsStatusManager;
5 6 import com.bsth.data.schedule.DayOfSchedule;
6 7 import com.bsth.entity.realcontrol.ScheduleRealInfo;
  8 +import org.slf4j.Logger;
  9 +import org.slf4j.LoggerFactory;
7 10 import org.springframework.beans.factory.annotation.Autowired;
8 11 import org.springframework.stereotype.Component;
9 12  
... ... @@ -20,28 +23,35 @@ public class GpsStateProcess {
20 23 @Autowired
21 24 GpsStatusManager gpsStatusManager;
22 25  
23   - public void process(GpsEntity gps){
24   - //在执行的任务
25   - ScheduleRealInfo sch = dayOfSchedule.executeCurr(gps.getNbbm());
26   -
27   - if(null == sch)
28   - return;
29   -
30   - byte upDown = Byte.parseByte(sch.getXlDir());
31   -
32   - if(gps.getUpDown() != upDown){
33   - gps.setUpDown(upDown);//修正走向
34   - }
35   -
36   - if((!gps.isService() || gps.getUpDown() != upDown) &&
37   - !dayOfSchedule.emptyService(sch)){
38   - //下发指令纠正车载的 营运状态 和 走向
39   - gpsStatusManager.changeServiceState(gps.getNbbm(), upDown, 0, "同步@系统");
40   - }
  26 + Logger logger = LoggerFactory.getLogger(this.getClass());
41 27  
42   - if(!sch.getXlBm().equals(gps.getLineId())){
43   - //切换车载的 线路编码
44   - gpsStatusManager.changeLine(gps.getNbbm(), sch.getXlBm(), "同步@系统");
  28 + public void process(GpsEntity gps){
  29 + try{
  30 + //在执行的任务
  31 + ScheduleRealInfo sch = dayOfSchedule.executeCurr(gps.getNbbm());
  32 +
  33 + if(null == sch)
  34 + return;
  35 +
  36 + byte upDown = Byte.parseByte(sch.getXlDir());
  37 +
  38 + if(gps.getUpDown() != upDown){
  39 + gps.setUpDown(upDown);//修正走向
  40 + }
  41 +
  42 + if((!gps.isService() || gps.getUpDown() != upDown) &&
  43 + !dayOfSchedule.emptyService(sch)){
  44 + //下发指令纠正车载的 营运状态 和 走向
  45 + gpsStatusManager.changeServiceState(gps.getNbbm(), upDown, 0, "同步@系统");
  46 + }
  47 +
  48 + if(!sch.getXlBm().equals(gps.getLineId())){
  49 + //切换车载的 线路编码
  50 + gpsStatusManager.changeLine(gps.getNbbm(), sch.getXlBm(), "同步@系统");
  51 + }
  52 + }catch (Exception e){
  53 + logger.error("GpsStateProcess error" , e);
  54 + logger.error("GpsStateProcess error data" , JSON.toJSONString(gps));
45 55 }
46 56 }
47 57 }
... ...
src/main/java/com/bsth/data/gpsdata_v2/handlers/InStationProcess.java
1 1 package com.bsth.data.gpsdata_v2.handlers;
2 2  
  3 +import com.alibaba.fastjson.JSON;
3 4 import com.bsth.data.LineConfigData;
4 5 import com.bsth.data.gpsdata_v2.cache.GeoCacheData;
5 6 import com.bsth.data.gpsdata_v2.cache.GpsCacheData;
... ... @@ -43,35 +44,40 @@ public class InStationProcess {
43 44 Logger logger = LoggerFactory.getLogger(this.getClass());
44 45  
45 46 public void process(GpsEntity gps) {
46   - //自动执行的班次信号,滚蛋
47   - LineConfig config = lineConfigData.get(gps.getLineId());
48   - if(null != config && config.isAutoExec())
49   - return;
50   -
51   - GpsEntity prev = GpsCacheData.getPrev(gps);
52   -
53   - if(null == prev)
54   - return;
55   -
56   - //从站外到站内
57   - if(prev.getInstation() == 0 && gps.getInstation() > 0){
58   - inStation(gps, prev);
  47 + try{
  48 + //自动执行的班次信号,滚蛋
  49 + LineConfig config = lineConfigData.get(gps.getLineId());
  50 + if(null != config && config.isAutoExec())
  51 + return;
  52 +
  53 + GpsEntity prev = GpsCacheData.getPrev(gps);
  54 +
  55 + if(null == prev)
  56 + return;
  57 +
  58 + //从站外到站内
  59 + if(prev.getInstation() == 0 && gps.getInstation() > 0){
  60 + inStation(gps, prev);
  61 + }
  62 +
  63 + //从站内到另一个站内
  64 + if(prev.getInstation() == 1 && gps.getInstation() == 1
  65 + && !prev.getStopNo().equals(gps.getStopNo())
  66 + && !prev.getStation().getName().equals(gps.getStation().getName()))
  67 + inStation(gps, prev);
  68 +
  69 + //从场内到站内
  70 + if(prev.getInstation() == 2 && gps.getInstation() == 1){
  71 + inStation(gps, prev);
  72 + }
  73 +
  74 + //被起点站覆盖的情况下进场
  75 + if(isInPark(gps, prev))
  76 + inStation(gps, prev);
  77 + }catch (Exception e){
  78 + logger.error("InStationProcess error", e);
  79 + logger.error("InStationProcess error data", JSON.toJSONString(gps));
59 80 }
60   -
61   - //从站内到另一个站内
62   - if(prev.getInstation() == 1 && gps.getInstation() == 1
63   - && !prev.getStopNo().equals(gps.getStopNo())
64   - && !prev.getStation().getName().equals(gps.getStation().getName()))
65   - inStation(gps, prev);
66   -
67   - //从场内到站内
68   - if(prev.getInstation() == 2 && gps.getInstation() == 1){
69   - inStation(gps, prev);
70   - }
71   -
72   - //被起点站覆盖的情况下进场
73   - if(isInPark(gps, prev))
74   - inStation(gps, prev);
75 81 }
76 82  
77 83 /**
... ...
src/main/java/com/bsth/data/gpsdata_v2/handlers/OutStationProcess.java
1 1 package com.bsth.data.gpsdata_v2.handlers;
2 2  
  3 +import com.alibaba.fastjson.JSON;
3 4 import com.bsth.data.LineConfigData;
4 5 import com.bsth.data.gpsdata_v2.cache.GpsCacheData;
5 6 import com.bsth.data.gpsdata_v2.entity.GpsEntity;
... ... @@ -42,28 +43,33 @@ public class OutStationProcess {
42 43 private final static int MAX_BEFORE_TIME = 1000 * 60 * 120;
43 44  
44 45 public void process(GpsEntity gps) {
45   - //自动执行的班次信号,滚蛋
46   - LineConfig config = lineConfigData.get(gps.getLineId());
47   - if (null != config && config.isAutoExec())
48   - return;
  46 + try{
  47 + //自动执行的线路,滚蛋
  48 + LineConfig config = lineConfigData.get(gps.getLineId());
  49 + if (null != config && config.isAutoExec())
  50 + return;
49 51  
50   - GpsEntity prev = GpsCacheData.getPrev(gps);
  52 + GpsEntity prev = GpsCacheData.getPrev(gps);
51 53  
52   - if (null == prev)
53   - return;
  54 + if (null == prev)
  55 + return;
54 56  
55   - //从站内到站外
56   - if (prev.getInstation() > 0 && gps.getInstation() == 0)
57   - outStation(gps, prev);
  57 + //从站内到站外
  58 + if (prev.getInstation() > 0 && gps.getInstation() == 0)
  59 + outStation(gps, prev);
58 60  
59   - //从站内到另一个站内
60   - if (prev.getInstation() > 0 && gps.getInstation() > 0
61   - && !prev.getStopNo().equals(gps.getStopNo()))
62   - outStation(gps, prev);
  61 + //从站内到另一个站内
  62 + if (prev.getInstation() > 0 && gps.getInstation() > 0
  63 + && !prev.getStopNo().equals(gps.getStopNo()))
  64 + outStation(gps, prev);
63 65  
64   - //在被起点站覆盖的情况下出场
65   - if (isOutPark(gps, prev))
66   - outStation(gps, prev);
  66 + //在被起点站覆盖的情况下出场
  67 + if (isOutPark(gps, prev))
  68 + outStation(gps, prev);
  69 + }catch (Exception e){
  70 + logger.error("OutStationProcess error", e);
  71 + logger.error("OutStationProcess error", JSON.toJSONString(gps));
  72 + }
67 73 }
68 74  
69 75 /**
... ...
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.alibaba.fastjson.JSON;
3 4 import com.bsth.data.LineConfigData;
4 5 import com.bsth.data.gpsdata_v2.cache.GeoCacheData;
5 6 import com.bsth.data.gpsdata_v2.cache.GpsCacheData;
... ... @@ -8,6 +9,8 @@ import com.bsth.data.gpsdata_v2.entity.StationRoute;
8 9 import com.bsth.data.schedule.DayOfSchedule;
9 10 import com.bsth.entity.realcontrol.LineConfig;
10 11 import com.bsth.entity.realcontrol.ScheduleRealInfo;
  12 +import org.slf4j.Logger;
  13 +import org.slf4j.LoggerFactory;
11 14 import org.springframework.beans.factory.annotation.Autowired;
12 15 import org.springframework.stereotype.Component;
13 16  
... ... @@ -30,27 +33,33 @@ public class ReverseRouteProcess {
30 33 @Autowired
31 34 LineConfigData lineConfigData;
32 35  
33   - public void process(GpsEntity gps){
34   -
35   - LineConfig config = lineConfigData.get(gps.getLineId());
36   - if(null != config && config.isReadReverse() &&
37   - reversRoute(gps) && !GeoCacheData.isLoopLine(gps.getLineId())){
38   -
39   - ScheduleRealInfo sch = dayOfSchedule.executeCurr(gps.getNbbm());
40   -
41   - if(null == sch)
42   - return;
43   - if(isInOut(sch) || !sch.getXlBm().equals(gps.getLineId()))
44   - return;
  36 + Logger logger = LoggerFactory.getLogger(this.getClass());
45 37  
46   - //next
47   - ScheduleRealInfo next = dayOfSchedule.next(sch);
48   - if(isInOut(next))
49   - return;
50   -
51   - //跳下一个班次
52   - if(Math.abs(next.getDfsjT() - gps.getTimestamp()) < TIME_THRESHOLD)
53   - dayOfSchedule.addExecPlan(next);
  38 + public void process(GpsEntity gps){
  39 + try{
  40 + LineConfig config = lineConfigData.get(gps.getLineId());
  41 + if(null != config && config.isReadReverse() &&
  42 + reversRoute(gps) && !GeoCacheData.isLoopLine(gps.getLineId())){
  43 +
  44 + ScheduleRealInfo sch = dayOfSchedule.executeCurr(gps.getNbbm());
  45 +
  46 + if(null == sch)
  47 + return;
  48 + if(isInOut(sch) || !sch.getXlBm().equals(gps.getLineId()))
  49 + return;
  50 +
  51 + //next
  52 + ScheduleRealInfo next = dayOfSchedule.next(sch);
  53 + if(isInOut(next))
  54 + return;
  55 +
  56 + //跳下一个班次
  57 + if(Math.abs(next.getDfsjT() - gps.getTimestamp()) < TIME_THRESHOLD)
  58 + dayOfSchedule.addExecPlan(next);
  59 + }
  60 + }catch (Exception e){
  61 + logger.error("ReverseRouteProcess error", e);
  62 + logger.error("ReverseRouteProcess error data", JSON.toJSONString(gps));
54 63 }
55 64 }
56 65  
... ...
src/main/java/com/bsth/data/gpsdata_v2/handlers/StationInsideProcess.java
1 1 package com.bsth.data.gpsdata_v2.handlers;
2 2  
  3 +import com.alibaba.fastjson.JSON;
3 4 import com.bsth.data.gpsdata_v2.cache.GeoCacheData;
4 5 import com.bsth.data.gpsdata_v2.cache.GpsCacheData;
5 6 import com.bsth.data.gpsdata_v2.entity.GpsEntity;
6 7 import com.bsth.data.gpsdata_v2.entity.StationRoute;
7 8 import com.bsth.data.gpsdata_v2.utils.GeoUtils;
  9 +import org.slf4j.Logger;
  10 +import org.slf4j.LoggerFactory;
8 11 import org.springframework.stereotype.Component;
9 12  
10 13 import java.util.List;
... ... @@ -16,41 +19,48 @@ import java.util.List;
16 19 @Component
17 20 public class StationInsideProcess {
18 21  
19   - public void process(GpsEntity gps){
20   - //是否在场内
21   - String parkCode = GeoUtils.gpsInCarpark(gps);
  22 + Logger logger = LoggerFactory.getLogger(this.getClass());
22 23  
23   - if (parkCode != null) {
24   - gps.setInstation(2);
25   - gps.setStopNo(parkCode);
26   - gps.setCarparkNo(parkCode);
27   - }
  24 + public void process(GpsEntity gps) {
  25 + try {
  26 + //是否在场内
  27 + String parkCode = GeoUtils.gpsInCarpark(gps);
28 28  
29   - //是否在站内
30   - List<StationRoute> srs = GeoCacheData.getStationRoute(gps.getLineId(), gps.getUpDown());
31   - StationRoute station = GeoUtils.gpsInStation(gps, srs);
32   - if (station != null) {
33   - gps.setInstation(1);
34   - gps.setStopNo(station.getCode());
35   - gps.setStation(station);
36   - }
  29 + if (parkCode != null) {
  30 + gps.setInstation(2);
  31 + gps.setStopNo(parkCode);
  32 + gps.setCarparkNo(parkCode);
  33 + }
  34 +
  35 + //是否在站内
  36 + List<StationRoute> srs = GeoCacheData.getStationRoute(gps.getLineId(), gps.getUpDown());
  37 + StationRoute station = GeoUtils.gpsInStation(gps, srs);
  38 + if (station != null) {
  39 + gps.setInstation(1);
  40 + gps.setStopNo(station.getCode());
  41 + gps.setStation(station);
  42 + }
37 43  
38   - //是否在进站前置围栏内
39   - String premiseCode = GeoUtils.gpsInPremiseGeo(gps);
40   - gps.setPremiseCode(premiseCode);
  44 + //是否在进站前置围栏内
  45 + String premiseCode = GeoUtils.gpsInPremiseGeo(gps);
  46 + gps.setPremiseCode(premiseCode);
41 47  
42   - //上一个点位
43   - GpsEntity prev = GpsCacheData.getPrev(gps);
  48 + //上一个点位
  49 + GpsEntity prev = GpsCacheData.getPrev(gps);
44 50  
45   - if(null != prev){
46   - //继承前置围栏状态
47   - if(null == premiseCode && null != prev.getPremiseCode())
48   - gps.setPremiseCode(prev.getPremiseCode());
  51 + if (null != prev) {
  52 + //继承前置围栏状态
  53 + if (null == premiseCode && null != prev.getPremiseCode())
  54 + gps.setPremiseCode(prev.getPremiseCode());
49 55  
50   - //在场,站外
51   - if(gps.getInstation() == 0){
52   - gps.setStopNo(prev.getStopNo());//继承上一个点的站点编码
  56 + //在场,站外
  57 + if (gps.getInstation() == 0) {
  58 + gps.setStopNo(prev.getStopNo());//继承上一个点的站点编码
  59 + }
53 60 }
  61 + } catch (Exception e) {
  62 + logger.error("StationInsideProcess error", e);
  63 + logger.error("StationInsideProcess error data", JSON.toJSONString(gps));
54 64 }
55 65 }
56 66 }
... ...