AnalyseData.java
2.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
package com.bsth.data.arrival;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import com.bsth.data.BasicData;
/**
*
* @ClassName: AnalyseArrivalData
* @Description: TODO(分析一下进出站场数据)
* @author PanZhao
* @date 2016年8月24日 上午11:09:37
*
*/
@Component
public class AnalyseData {
Logger logger = LoggerFactory.getLogger(AnalyseData.class);
public void analyse(Set<String> cars){
try{
List<ArrivalEntity> list, clearList;
for(String car : cars){
list = ArrivalData_GPS.findByNbbm(car);
analyse(list);
//清理掉无效的点
clearList = new ArrayList<>();
for(ArrivalEntity arr : list){
if(!arr.isEnable())
clearList.add(arr);
}
list.removeAll(clearList);
}
}catch(Exception e){
logger.error("", e);
}
}
private final static int SHIFT_TIME = 1000 * 60 * 5,
SCH_TIME = 1000 * 60 * 10;
static ArrivalComparator comp = new ArrivalComparator();
public void analyse(List<ArrivalEntity> list){
if(list.size() <= 1)
return;
//排序
Collections.sort(list, comp);
ArrivalEntity prve = list.get(0)
,curr;
for(int i = 1; i < list.size(); i ++){
curr = list.get(i);
//如果第一个点无效
if(!effective(prve)){
prve.setEnable(false);
prve = curr;
continue;
}
//如果第二个点无效
else if(!effective(curr)){
curr.setEnable(false);
continue;
}
else if(curr.getTs() - prve.getTs() < SCH_TIME){
if(prve.getUpDown() == curr.getUpDown()){
//信号漂移,出站无效
if(curr.getStopNo().equals(prve.getStopNo())
&& prve.getInOut() == 1 && curr.getInOut() == 0
&& curr.getTs() - prve.getTs() < SHIFT_TIME){
prve.setEnable(false);
}
}
else{
//上下行的同名站,新走向的第一个出站信号开始有效
if(prve.getStopName().equals(curr.getStopName())){
if(curr.getInOut() == 0)
curr.setEnable(false);
else
prve = curr;
}
}
}
else
prve = curr;
}
}
private boolean effective(ArrivalEntity arr){
//停车场
if(BasicData.parkCodeList.contains(arr.getStopNo())){
arr.setTcc(true);
return true;
}
Integer upDown = BasicData.lineStationUpDownMap.get(arr.getLineCode() + "_" + arr.getStopNo());
return arr.getUpDown() == upDown || BasicData.parkCodeList.contains(arr.getStopNo());
}
}