ScheduleLateThread.java
1.36 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
package com.bsth.data.schedule.thread;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.bsth.data.schedule.DayOfSchedule;
import com.bsth.data.schedule.ScheduleComparator;
import com.bsth.entity.realcontrol.ScheduleRealInfo;
import com.bsth.websocket.handler.SendUtils;
/**
*
* @ClassName: ScheduleLateThread
* @Description: TODO(班次误点扫描线程)
* @author PanZhao
* @date 2016年8月31日 下午3:09:02
*
*/
@Component
public class ScheduleLateThread extends Thread{
@Autowired
DayOfSchedule dayOfSchedule;
@Autowired
SendUtils sendUtils;
private static Comparator<ScheduleRealInfo> cpm = new ScheduleComparator.FCSJ();
@Override
public void run() {
List<ScheduleRealInfo> all = new ArrayList<>(dayOfSchedule.findAll());
Collections.sort(all, cpm);
long t = System.currentTimeMillis();
int size = all.size();
ScheduleRealInfo sch;
for(int i = 0; i < size; i ++){
sch = all.get(i);
if(sch.getDfsjT() > t)
break;
if(sch.getStatus() == 0 && sch.getFcsjActual() == null){
//应发未发
sch.setLate(true);
//通知客户端
sendUtils.refreshSch(sch);
}
}
}
}