FreeLoginController.java
12.1 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
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
package com.bsth.controller.realcontrol;
import com.bsth.data.BasicData;
import com.bsth.data.Station2ParkBuffer;
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.data.pinyin.PersionPinYin;
import com.bsth.data.pinyin.PersionPinYinBuffer;
import com.bsth.entity.Line;
import com.bsth.entity.LineInformation;
import com.bsth.entity.realcontrol.ScheduleRealInfo;
import com.bsth.entity.realcontrol.StationToPark;
import com.bsth.entity.sys.*;
import com.bsth.repository.LineRepository;
import com.bsth.repository.sys.SysUserRepository;
import com.bsth.service.BusinessService;
import com.bsth.service.LineInformationService;
import com.bsth.service.LineService;
import com.bsth.service.StationRouteService;
import com.bsth.service.gps.GpsService;
import com.bsth.service.realcontrol.LineConfigService;
import com.bsth.service.realcontrol.RealMapService;
import com.bsth.service.realcontrol.ScheduleRealInfoService;
import com.bsth.service.sys.CompanyAuthorityService;
import com.bsth.service.sys.DutyEmployeeService;
import com.google.common.base.Splitter;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.BiMap;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletResponse;
import java.util.*;
/**
* Created by zhangxianzhou on 2019/5/14.
* describe 用户免登录的线调页面
*/
@RestController
@RequestMapping("/freeLogin")
public class FreeLoginController {
//Logger logger = LoggerFactory.getLogger(this.getClass());
@Autowired
LineService lineService;
@Autowired
GpsRealData gpsRealData;
@Autowired
GpsService gpsService;
@Autowired
LineInformationService lineInformationService;
@Autowired
BusinessService businessService;
@Autowired
LineRepository lineRepository;
@Autowired
RealMapService realMapService;
@Autowired
LineConfigService lineConfigService;
@Autowired
StationRouteService stationRouteService;
@Autowired
PersionPinYinBuffer persionPinYinBuffer;
@Autowired
OverspeedProcess overspeedProcess;
@Autowired
ScheduleRealInfoService scheduleRealInfoService;
/**
* @return 免登录主页
*/
@RequestMapping("/real_control/v2")
public ModelAndView v2() {
ModelAndView mv = new ModelAndView();
//免登录线调主页
mv.setViewName("/real_control_v3/main.html");
return mv;
}
/**
* @param map 筛选条件
* @return 所有线路信息
*/
@RequestMapping("/line/all")
public Iterable list(@RequestParam Map<String, Object> map) {
return lineService.list(map);
}
/**
* @param codeArray 线路数组
* @return 检查线路
*/
@RequestMapping("/lineConfig/check")
public Map<String, Object> check(@RequestParam String[] codeArray) {
return lineConfigService.check(codeArray);
}
/**
* 初始化线路配置
*
* @param lineCode 线路code
* @return 1
*/
@RequestMapping("/lineConfig/init/{lineCode}")
public Integer init(@PathVariable("lineCode") String lineCode) throws Exception {
return lineConfigService.init(lineCode);
}
/**
* @return 线路权限
*/
@RequestMapping("/realControAuthority/findByCurrentUser")
public RealControAuthority findByCurrentUser() {
List<Line> lines = lineRepository.findAllService();
StringBuffer sb = new StringBuffer();
if (!lines.isEmpty()) {
for (int i = 0; i < lines.size(); i++) {
if (i < lines.size() - 1) {
sb.append(lines.get(i).getId());
sb.append(",");
} else {
sb.append(lines.get(i).getId());
}
}
}
RealControAuthority realControAuthority = new RealControAuthority();
realControAuthority.setExcludeMenus("");
realControAuthority.setLineCodeStr(sb.toString());
realControAuthority.setUserId(1);
realControAuthority.setPattern(1);
return realControAuthority;
}
/**
* @param map 筛选条件
* @return 企业信息
*/
@RequestMapping("/business/all")
public Iterable bussinessList(@RequestParam Map<String, Object> map) {
return businessService.list(map);
}
/**
* @param idx 线路id
* @return 线路路由
*/
@RequestMapping("/realMap/findRouteByLine")
public Map<String, Object> findRouteByLine(@RequestParam String idx) {
return realMapService.findRouteByLine(idx);
}
/**
* 停车场
*
* @return 停车场
*/
@RequestMapping(value = "/realMap/carParkSpatialData")
public Map<String, Object> carParkSpatialData() {
return realMapService.carParkSpatialData();
}
/**
* 获取多个线路的路段信息(为前端越界计算提供数据)
*
* @param codeIdx 线路id
* @return 线路的路段信息
*/
@RequestMapping(value = "/realMap/multiSectionRoute")
public Map<String, Object> multiSectionRoute(@RequestParam String codeIdx) {
return realMapService.multiSectionRoute(codeIdx);
}
/**
* 根据线路获取站点路由及空间数据
*/
@RequestMapping(value = "/realMap/stationSpatialData")
public Map<String, Object> stationSpatialData(@RequestParam String idx) {
return realMapService.stationSpatialData(idx);
}
/**
* @param lineIds 线路id
* @return 多线路路由查询
*/
@RequestMapping(value = "/stationroute/multiLine", method = RequestMethod.GET)
public Map<String, Object> findByMultiLine(@RequestParam String lineIds) {
return stationRouteService.findByMultiLine(lineIds);
}
/**
* @return 线路编码和名称对照
*/
@RequestMapping("/basic/lineCode2Name")
public Map<String, String> findLineCodeMap() {
return BasicData.lineCode2NameMap;
}
/**
* @param idx 线路id
* @return 场到站
*/
@RequestMapping("/basic/station2ParkData")
public Map<String, Collection<StationToPark>> findStation2ParkData(@RequestParam String idx) {
List<String> lines = Splitter.on(",").splitToList(idx);
ArrayListMultimap<String, StationToPark> rs = ArrayListMultimap.create();
for (String lineCode : lines) {
rs.putAll(lineCode, Station2ParkBuffer.get(lineCode));
}
return rs.asMap();
}
/**
* @return 设备号和车辆自编号 (K: 设备编码 ,V:车辆自编号)
*/
@RequestMapping("/basic/nbbm2deviceId")
public Map<String, String> nbbm2deviceId() {
return BasicData.deviceId2NbbmMap.inverse();
}
/**
* @return 人员拼音数据映射缓存
*/
@RequestMapping(value = "/basic/all_personnel_py", method = RequestMethod.GET)
public List<PersionPinYin> findAll_PY() {
return persionPinYinBuffer.getAll();
}
/**
* @return 车辆
*/
@RequestMapping("/basic/cars")
public Iterable<String> findAllNbbm() {
return BasicData.deviceId2NbbmMap.values();
}
/**
* 车辆自编号和车牌号对照
*
* @return 车辆自编号和车牌号对照
*/
@RequestMapping("/basic/nbbm2PlateNo")
public Map<String, String> nbbm2PlateNo() {
return BasicData.nbbmCompanyPlateMap;
}
/**
* 获取车辆信息
*
* @param idx 线路id
* @return 获取车辆信息
*/
@RequestMapping("/basic/ccInfo/lineArray")
public List<Map<String, String>> ccInfoByLine(@RequestParam String idx) {
List<String> liness = Splitter.on(",").splitToList(idx);
List<Map<String, String>> rs = new ArrayList<>();
Set<String> ks = BasicData.nbbm2LineMap.keySet();
Map<String, String> map;
BiMap<String, String> nbbm2deviceMap = BasicData.deviceId2NbbmMap.inverse();
Line line;
for (String nbbm : ks) {
line = BasicData.nbbm2LineMap.get(nbbm);
if (liness.contains(line.getLineCode())) {
map = new HashMap<>();
map.put("nbbm", nbbm);
map.put("lineName", line.getName());
map.put("deviceId", nbbm2deviceMap.get(nbbm));
map.put("lineCode", line.getLineCode());
rs.add(map);
}
}
return rs;
}
/**
* @param lineCodes 线路编码
* @return 多条线路信息
*/
@RequestMapping("/lineInformation/line/multi")
public List<LineInformation> findByLine(@RequestParam String lineCodes) {
return lineInformationService.findByLine(lineCodes);
}
/**
* 主页SVG模拟图
*
* @param idx 线路id
* @return 主页SVG模拟图
*/
@RequestMapping(value = "/realSchedule/svgAttr", method = RequestMethod.GET)
public Map<String, Object> findSvgAttr(@RequestParam String idx) {
return scheduleRealInfoService.findSvgAttr(idx);
}
/**
* 获取班次
*
* @param lines 线路id
* @return 获取班次
*/
@RequestMapping(value = "/realSchedule/lines")
public Map<String, Collection<ScheduleRealInfo>> findByLines(@RequestParam String lines) {
return scheduleRealInfoService.findByLines(lines);
}
/**
* 线路编码获取GPS集合
*
* @param lineCode 线路编码
* @return 线路编码获取GPS集合
*/
@RequestMapping(value = "/gps/real/line/{lineCode}")
public List<GpsEntity> findByLineCode(@PathVariable("lineCode") String lineCode) {
return gpsRealData.getByLine(lineCode);
}
/**
* @param lineCodes 线路编码
* @return 实时gps 超速信息
*/
@RequestMapping(value = "/gps/real/line")
public Map<String, Object> findByLineCodes(@RequestParam String lineCodes) {
Map<String, Object> rs = new HashMap();
List<String> lineArray = Splitter.on(",").splitToList(lineCodes);
//超速信息
List<GpsOverspeed> overspeedList = overspeedProcess.findByLines(lineArray);
//实时gps
List<GpsEntity> gpsList = gpsRealData.get(lineArray);
rs.put("gpsList", gpsList);
rs.put("overspeedList", overspeedList);
return rs;
}
/**
* 历史GPS查询 ,第三版轨迹回放用
*
* @param nbbm 车辆编号
* @param st 开始时间
* @param et 结束时间
* @return 历史GPS查询
*/
@RequestMapping(value = "/gps/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 结束时间
*/
@RequestMapping(value = "/gps/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 结束时间
*/
@RequestMapping(value = "/gps/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 lineCode 线路编码
* @return 获取线路下所有车辆,包括实时设备 和 计划排班
*/
@RequestMapping(value = "/gps/allCarsByLine", method = RequestMethod.GET)
public Map<String, Object> allCarsByLine(String lineCode) {
return gpsService.allCarsByLine(lineCode);
}
}