anomalyCheckController.java
3.81 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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
package com.bsth.controller.realcontrol;
import com.bsth.data.gpsdata_v2.cache.GeoCacheData;
import com.bsth.data.gpsdata_v2.thread.GpsDataLoaderThread;
import com.bsth.data.msg_queue.DirectivePushQueue;
import com.bsth.data.msg_queue.WebSocketPushQueue;
import com.bsth.data.schedule.DayOfSchedule;
import com.bsth.entity.realcontrol.ScheduleRealInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* Created by panzhao on 2017/4/14.
*/
@RestController
@RequestMapping("anomalyCheck")
public class anomalyCheckController {
Logger logger = LoggerFactory.getLogger(this.getClass());
@Autowired
DayOfSchedule dayOfSchedule;
@Autowired
GeoCacheData geoCacheData;
/**
* 出现重复班次的车辆
* @param nbbm
*/
@RequestMapping(value = "/schRepeat", method = RequestMethod.POST)
public void schRepeat(@RequestParam String nbbm){
logger.info("前端通知,车辆 " + nbbm + "出现重复班次,开始检测...");
List<ScheduleRealInfo> list = dayOfSchedule.findByNbbm(nbbm);
logger.info("检测前,车辆班次数量:" + list.size());
Map<Long, ScheduleRealInfo> map = new HashMap<>();
for(ScheduleRealInfo sch : list){
if(map.containsKey(sch.getId())){
logger.info("检测到重复ID: " + sch.getId());
}
map.put(sch.getId(), sch);
}
logger.info("检测后,车辆班次数量:" + list.size());
if(map.values().size() > 0){
dayOfSchedule.replaceByNbbm(nbbm, map.values());
}
}
@RequestMapping(value = "/directivePushQueue")
public void directivePushQueue(){
DirectivePushQueue.start();
}
@RequestMapping(value = "/directiveQueueSize")
public void directiveQueueSize(){
DirectivePushQueue.size();
}
@RequestMapping(value = "/webSocketPushQueue")
public void webSocketPushQueue(){
WebSocketPushQueue.start();
}
@RequestMapping(value = "/webSocketQueueSize")
public void webSocketQueueSize(){
WebSocketPushQueue.size();
}
@RequestMapping(value = "/setHttpFlag")
public void setHttpFlag(@RequestParam int flag){
if(flag != 0 && flag != -1)
return;
GpsDataLoaderThread.setFlag(flag);
}
@RequestMapping(value = "/updateCacheBuff")
public void updateCacheBuff(){
geoCacheData.loadData();
}
@RequestMapping(value = "/reCalcLpSch")
public void reCalcLpSch(){
dayOfSchedule._test_reCalcLpSch();
}
@RequestMapping(value = "/findSchByLpName")
public List<ScheduleRealInfo> findSchByLpName(@RequestParam String lpName){
return dayOfSchedule.getLpScheduleMap().get(lpName);
}
@RequestMapping(value = "/findSchByNbbm")
public List<ScheduleRealInfo> findSchByNbbm(@RequestParam String nbbm){
return dayOfSchedule.findByNbbm(nbbm);
}
@RequestMapping(value = "/removeExecPlan")
public int removeExecPlan(@RequestParam String nbbm){
dayOfSchedule.removeExecPlan(nbbm);
return 1;
}
@RequestMapping(value = "/sch_re_calc_id_maps")
public int reCalcIdMaps(){
return dayOfSchedule.reCalcIdMaps();
}
@RequestMapping(value = "/sch_size_string")
public String schSizeString(){
return dayOfSchedule.sizeString();
}
}