ScheduleComparator.java
1.58 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
package com.bsth.data.schedule;
import com.bsth.entity.realcontrol.ScheduleRealInfo;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Map;
/**
*
* @ClassName: ScheduleComparator
* @Description: TODO(实际班次排序器)
* @author PanZhao
* @date 2016年8月15日 下午1:53:28
*
*/
public class ScheduleComparator {
/* public static class FCNO implements Comparator<ScheduleRealInfo>{
@Override
public int compare(ScheduleRealInfo s1, ScheduleRealInfo s2) {
return s1.getFcno() - s2.getFcno();
}
}*/
static Map<String, Integer> bcTypeOrderMap = new HashMap<>();
static{
bcTypeOrderMap.put("out", 0);
bcTypeOrderMap.put("normal", 1);
bcTypeOrderMap.put("region", 2);
bcTypeOrderMap.put("major", 3);
bcTypeOrderMap.put("venting", 4);
bcTypeOrderMap.put("ldks", 5);
bcTypeOrderMap.put("in", 6);
}
public static class FCSJ implements Comparator<ScheduleRealInfo>{
@Override
public int compare(ScheduleRealInfo s1, ScheduleRealInfo s2) {
int diff = (int) (s1.getFcsjT() - s2.getFcsjT());
return diff!=0?diff:typeOrder(s1.getBcType()) - typeOrder(s2.getBcType());
}
}
private static int typeOrder(String bcType){
return bcTypeOrderMap.get(bcType)!=null?bcTypeOrderMap.get(bcType):0;
}
public static class DFSJ implements Comparator<ScheduleRealInfo>{
@Override
public int compare(ScheduleRealInfo s1, ScheduleRealInfo s2) {
int diff = (int) (s1.getDfsjT() - s2.getDfsjT());
return diff!=0?diff:typeOrder(s1.getBcType()) - typeOrder(s2.getBcType());
}
}
}