GpsController.java
8.01 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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
package com.bsth.controller.gps;
import com.bsth.data.BasicData;
import com.bsth.data.gpsdata_v2.GpsRealData;
import com.bsth.data.gpsdata_v2.entity.GpsEntity;
import com.bsth.data.gpsdata_v2.handlers.overspeed.GpsOverspeed;
import com.bsth.data.gpsdata_v2.handlers.overspeed.OverspeedProcess;
import com.bsth.service.gps.GpsService;
import com.bsth.service.gps.entity.GpsSpeed;
import com.google.common.base.Splitter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@RestController
@RequestMapping("gps")
public class GpsController {
@Autowired
GpsRealData gpsRealData;
@Autowired
GpsService gpsService;
@Autowired
OverspeedProcess overspeedProcess;
@RequestMapping(value = "/real/all")
public Map<String, Object> search(@RequestParam Map<String, Object> map,
@RequestParam(defaultValue = "0") int page,
@RequestParam(defaultValue = "15") int size,
@RequestParam(defaultValue = "timestamp") String order,
@RequestParam(defaultValue = "DESC") String direction) {
return gpsService.search(map, page, size, order, direction);
}
@RequestMapping(value = "/real/line/{lineCode}")
public List<GpsEntity> findByLineCode(@PathVariable("lineCode") String lineCode) {
return gpsRealData.getByLine(lineCode);
}
@RequestMapping(value = "/real/line")
public Map<String, Object> findByLineCodes(@RequestParam String lineCodes) {
Map<String, Object> rs = new HashMap();
List<String> lineArray = Splitter.on(",").splitToList(lineCodes);
//实时gps
List<GpsEntity> gpsList = gpsRealData.get(lineArray);
//超速信息
List<GpsOverspeed> overspeedList = overspeedProcess.findByLines(lineArray);
rs.put("gpsList", gpsList);
rs.put("overspeedList", overspeedList);
return rs;
}
@RequestMapping(value = "/allDevices")
public Iterable<String> allDevices() {
return gpsRealData.allDevices();
}
@RequestMapping(value = "/removeRealGps", method = RequestMethod.POST)
public Map<String, Object> removeRealGps(@RequestParam String device) {
return gpsService.removeRealGps(device);
}
/**
* @Title: history @Description: TODO(这个方法给测试页面用) @throws
*/
@RequestMapping(value = "/history/{device}")
public List<Map<String, Object>> history(@PathVariable("device") String device, @RequestParam Long startTime,
@RequestParam Long endTime, @RequestParam int directions) {
return gpsService.history(device, startTime, endTime, directions);
}
@RequestMapping(value = "/gpsHistory/multiple")
public List<Map<String, Object>> gpsHistory(@RequestParam String[] nbbmArray, @RequestParam Long st,
@RequestParam Long et) {
return gpsService.history(nbbmArray, st, et);
}
/*@RequestMapping(value = "/analyse/ram")
public List<ArrivalInfo> ramData(@RequestParam String nbbm) {
return ArrivalDataBuffer.allMap.get(nbbm);
}*/
@RequestMapping(value = "/Car2DeviceId")
public Map<String, String> findCarDeviceIdMap() {
return BasicData.deviceId2NbbmMap.inverse();
}
@RequestMapping(value = "/buffAera")
public Map<String, Object> findBuffAeraByCode(@RequestParam String code, @RequestParam String type) {
return gpsService.findBuffAeraByCode(code, type);
}
@RequestMapping(value = "/findRoadSpeed")
public Map<String, Object> findRoadSpeed(@RequestParam String lineCode) {
return gpsService.findRoadSpeed(lineCode);
}
/**
* gps补全
* type 0 : 实时GPS 1:走补传
* @return
*/
@RequestMapping(value = "/gpsCompletion", method = RequestMethod.POST)
public Map<String, Object> gpsCompletion(@RequestParam long schId, @RequestParam int type) {
return gpsService.gpsCompletion(schId, type);
}
/**
* 历史GPS查询 ,第二版轨迹回放用
* @param nbbm
* @param st
* @param et
* @return
*/
@RequestMapping(value = "/history_v2/{nbbm}")
public Map<String, Object> history_v2(@PathVariable("nbbm") String nbbm, @RequestParam long st, @RequestParam long et){
return gpsService.history_v2(nbbm, st, et);
}
/**
* 历史GPS查询 ,第三版轨迹回放用
* @param nbbm
* @param st
* @param et
* @return
*/
@RequestMapping(value = "/history_v3/{nbbm}")
public Map<String, Object> history_v3(@PathVariable("nbbm") String nbbm, @RequestParam long st, @RequestParam long et){
return gpsService.history_v3(nbbm, st, et);
}
/**
* 轨迹导出
* @param nbbm
* @param st
* @param et
* @return
*/
@RequestMapping(value = "/history_v3/excel/{nbbm}")
public void trailExcel(@PathVariable("nbbm") String nbbm, @RequestParam long st, @RequestParam long et, HttpServletResponse resp){
gpsService.trailExcel(nbbm, st, et, resp);
}
/**
* 轨迹异常数据导出
* @param nbbm
* @param st
* @param et
* @return
*/
@RequestMapping(value = "/history_v3/excel_abnormal/{nbbm}")
public void abnormalExcel(@PathVariable("nbbm") String nbbm, @RequestParam long st, @RequestParam long et, HttpServletResponse resp){
gpsService.abnormalExcel(nbbm, st, et, resp);
}
/**
* 到离站数据导出
* @param nbbm
* @param st
* @param et
* @return
*/
@RequestMapping(value = "/history_v3/excel_arrival/{nbbm}")
public void arrivalExcel(@PathVariable("nbbm") String nbbm, @RequestParam long st, @RequestParam long et, HttpServletResponse resp){
gpsService.arrivalExcel(nbbm, st, et, resp);
}
/**
* 安全驾驶数据 分页查询
* @param map
* @param page
* @param size
* @param order
* @param direction
* @return
*/
@RequestMapping(value = "/safeDriv")
public Map<String, Object> safeDrivList(@RequestParam Map<String, Object> map,
@RequestParam(defaultValue = "0") int page,
@RequestParam(defaultValue = "15") int size,
@RequestParam(defaultValue = "timestamp") String order,
@RequestParam(defaultValue = "DESC") String direction){
return gpsService.safeDrivList(map , page, size, order, direction);
}
@RequestMapping(value = "/findPosition", method = RequestMethod.GET)
public List<GpsSpeed> findPosition(@RequestParam String vehicle,@RequestParam String startdate,@RequestParam String enddate) throws ParseException {
String deviceid = BasicData.deviceId2NbbmMap.inverse().get(vehicle);
List<GpsSpeed> listGpsSpeed = new ArrayList<GpsSpeed>();
listGpsSpeed = gpsService.findPosition(deviceid,startdate,enddate);
return listGpsSpeed;
}
@RequestMapping(value = "/pagequery",method = RequestMethod.GET)
public Map<String, Object> pagequery(@RequestParam Map<String, Object> map){
map.put("curPage", map.get("page").toString());
map.put("pageData","10");
return gpsService.Pagequery(map);
}
/**
* 获取线路下所有车辆,包括实时设备 和 计划排班
* @param lineCode
* @return
*/
@RequestMapping(value = "/allCarsByLine",method = RequestMethod.GET)
public Map<String, Object> allCarsByLine(String lineCode){
return gpsService.allCarsByLine(lineCode);
}
}