Commit 950de0c0e04e364b9b8bd618556d77a07c34204d
1 parent
b2765c8a
新增免登录线调页面
Showing
1 changed file
with
392 additions
and
0 deletions
src/main/java/com/bsth/controller/realcontrol/FreeLoginController.java
0 → 100644
| 1 | +package com.bsth.controller.realcontrol; | |
| 2 | + | |
| 3 | +import com.bsth.data.BasicData; | |
| 4 | +import com.bsth.data.Station2ParkBuffer; | |
| 5 | +import com.bsth.data.gpsdata_v2.GpsRealData; | |
| 6 | +import com.bsth.data.gpsdata_v2.entity.GpsEntity; | |
| 7 | +import com.bsth.data.gpsdata_v2.handlers.overspeed.GpsOverspeed; | |
| 8 | +import com.bsth.data.gpsdata_v2.handlers.overspeed.OverspeedProcess; | |
| 9 | +import com.bsth.data.pinyin.PersionPinYin; | |
| 10 | +import com.bsth.data.pinyin.PersionPinYinBuffer; | |
| 11 | +import com.bsth.entity.Line; | |
| 12 | +import com.bsth.entity.LineInformation; | |
| 13 | +import com.bsth.entity.realcontrol.ScheduleRealInfo; | |
| 14 | +import com.bsth.entity.realcontrol.StationToPark; | |
| 15 | +import com.bsth.entity.sys.*; | |
| 16 | +import com.bsth.repository.LineRepository; | |
| 17 | +import com.bsth.repository.sys.SysUserRepository; | |
| 18 | +import com.bsth.service.BusinessService; | |
| 19 | +import com.bsth.service.LineInformationService; | |
| 20 | +import com.bsth.service.LineService; | |
| 21 | +import com.bsth.service.StationRouteService; | |
| 22 | +import com.bsth.service.gps.GpsService; | |
| 23 | +import com.bsth.service.realcontrol.LineConfigService; | |
| 24 | +import com.bsth.service.realcontrol.RealMapService; | |
| 25 | +import com.bsth.service.realcontrol.ScheduleRealInfoService; | |
| 26 | +import com.bsth.service.sys.CompanyAuthorityService; | |
| 27 | +import com.bsth.service.sys.DutyEmployeeService; | |
| 28 | +import com.google.common.base.Splitter; | |
| 29 | +import com.google.common.collect.ArrayListMultimap; | |
| 30 | +import com.google.common.collect.BiMap; | |
| 31 | +//import org.slf4j.Logger; | |
| 32 | +//import org.slf4j.LoggerFactory; | |
| 33 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 34 | +import org.springframework.web.bind.annotation.*; | |
| 35 | +import org.springframework.web.servlet.ModelAndView; | |
| 36 | + | |
| 37 | +import javax.servlet.http.HttpServletResponse; | |
| 38 | +import java.util.*; | |
| 39 | + | |
| 40 | +/** | |
| 41 | + * Created by zhangxianzhou on 2019/5/14. | |
| 42 | + * describe 用户免登录的线调页面 | |
| 43 | + */ | |
| 44 | +@RestController | |
| 45 | +@RequestMapping("/freeLogin") | |
| 46 | +public class FreeLoginController { | |
| 47 | + //Logger logger = LoggerFactory.getLogger(this.getClass()); | |
| 48 | + @Autowired | |
| 49 | + LineService lineService; | |
| 50 | + @Autowired | |
| 51 | + GpsRealData gpsRealData; | |
| 52 | + | |
| 53 | + @Autowired | |
| 54 | + GpsService gpsService; | |
| 55 | + | |
| 56 | + @Autowired | |
| 57 | + LineInformationService lineInformationService; | |
| 58 | + | |
| 59 | + @Autowired | |
| 60 | + BusinessService businessService; | |
| 61 | + @Autowired | |
| 62 | + LineRepository lineRepository; | |
| 63 | + @Autowired | |
| 64 | + RealMapService realMapService; | |
| 65 | + @Autowired | |
| 66 | + LineConfigService lineConfigService; | |
| 67 | + @Autowired | |
| 68 | + StationRouteService stationRouteService; | |
| 69 | + | |
| 70 | + @Autowired | |
| 71 | + PersionPinYinBuffer persionPinYinBuffer; | |
| 72 | + | |
| 73 | + @Autowired | |
| 74 | + OverspeedProcess overspeedProcess; | |
| 75 | + | |
| 76 | + @Autowired | |
| 77 | + ScheduleRealInfoService scheduleRealInfoService; | |
| 78 | + | |
| 79 | + /** | |
| 80 | + * @return 免登录主页 | |
| 81 | + */ | |
| 82 | + @RequestMapping("/real_control/v2") | |
| 83 | + public ModelAndView v2() { | |
| 84 | + ModelAndView mv = new ModelAndView(); | |
| 85 | + //免登录线调主页 | |
| 86 | + mv.setViewName("/real_control_v3/main.html"); | |
| 87 | + return mv; | |
| 88 | + } | |
| 89 | + | |
| 90 | + /** | |
| 91 | + * @param map 筛选条件 | |
| 92 | + * @return 所有线路信息 | |
| 93 | + */ | |
| 94 | + @RequestMapping("/line/all") | |
| 95 | + public Iterable list(@RequestParam Map<String, Object> map) { | |
| 96 | + return lineService.list(map); | |
| 97 | + } | |
| 98 | + | |
| 99 | + /** | |
| 100 | + * @param codeArray 线路数组 | |
| 101 | + * @return 检查线路 | |
| 102 | + */ | |
| 103 | + @RequestMapping("/lineConfig/check") | |
| 104 | + public Map<String, Object> check(@RequestParam String[] codeArray) { | |
| 105 | + return lineConfigService.check(codeArray); | |
| 106 | + } | |
| 107 | + | |
| 108 | + /** | |
| 109 | + * 初始化线路配置 | |
| 110 | + * | |
| 111 | + * @param lineCode 线路code | |
| 112 | + * @return 1 | |
| 113 | + */ | |
| 114 | + @RequestMapping("/lineConfig/init/{lineCode}") | |
| 115 | + public Integer init(@PathVariable("lineCode") String lineCode) throws Exception { | |
| 116 | + return lineConfigService.init(lineCode); | |
| 117 | + } | |
| 118 | + | |
| 119 | + /** | |
| 120 | + * @return 线路权限 | |
| 121 | + */ | |
| 122 | + @RequestMapping("/realControAuthority/findByCurrentUser") | |
| 123 | + public RealControAuthority findByCurrentUser() { | |
| 124 | + List<Line> lines = lineRepository.findAllService(); | |
| 125 | + StringBuffer sb = new StringBuffer(); | |
| 126 | + if (!lines.isEmpty()) { | |
| 127 | + for (int i = 0; i < lines.size(); i++) { | |
| 128 | + if (i < lines.size() - 1) { | |
| 129 | + sb.append(lines.get(i).getId()); | |
| 130 | + sb.append(","); | |
| 131 | + } else { | |
| 132 | + sb.append(lines.get(i).getId()); | |
| 133 | + } | |
| 134 | + } | |
| 135 | + } | |
| 136 | + RealControAuthority realControAuthority = new RealControAuthority(); | |
| 137 | + realControAuthority.setExcludeMenus(""); | |
| 138 | + realControAuthority.setLineCodeStr(sb.toString()); | |
| 139 | + realControAuthority.setUserId(1); | |
| 140 | + realControAuthority.setPattern(1); | |
| 141 | + return realControAuthority; | |
| 142 | + } | |
| 143 | + | |
| 144 | + /** | |
| 145 | + * @param map 筛选条件 | |
| 146 | + * @return 企业信息 | |
| 147 | + */ | |
| 148 | + @RequestMapping("/business/all") | |
| 149 | + public Iterable bussinessList(@RequestParam Map<String, Object> map) { | |
| 150 | + return businessService.list(map); | |
| 151 | + } | |
| 152 | + | |
| 153 | + /** | |
| 154 | + * @param idx 线路id | |
| 155 | + * @return 线路路由 | |
| 156 | + */ | |
| 157 | + @RequestMapping("/realMap/findRouteByLine") | |
| 158 | + public Map<String, Object> findRouteByLine(@RequestParam String idx) { | |
| 159 | + return realMapService.findRouteByLine(idx); | |
| 160 | + } | |
| 161 | + | |
| 162 | + /** | |
| 163 | + * 停车场 | |
| 164 | + * | |
| 165 | + * @return 停车场 | |
| 166 | + */ | |
| 167 | + @RequestMapping(value = "/realMap/carParkSpatialData") | |
| 168 | + public Map<String, Object> carParkSpatialData() { | |
| 169 | + return realMapService.carParkSpatialData(); | |
| 170 | + } | |
| 171 | + | |
| 172 | + /** | |
| 173 | + * 获取多个线路的路段信息(为前端越界计算提供数据) | |
| 174 | + * | |
| 175 | + * @param codeIdx 线路id | |
| 176 | + * @return 线路的路段信息 | |
| 177 | + */ | |
| 178 | + @RequestMapping(value = "/realMap/multiSectionRoute") | |
| 179 | + public Map<String, Object> multiSectionRoute(@RequestParam String codeIdx) { | |
| 180 | + return realMapService.multiSectionRoute(codeIdx); | |
| 181 | + } | |
| 182 | + | |
| 183 | + /** | |
| 184 | + * 根据线路获取站点路由及空间数据 | |
| 185 | + */ | |
| 186 | + @RequestMapping(value = "/realMap/stationSpatialData") | |
| 187 | + public Map<String, Object> stationSpatialData(@RequestParam String idx) { | |
| 188 | + return realMapService.stationSpatialData(idx); | |
| 189 | + } | |
| 190 | + | |
| 191 | + | |
| 192 | + /** | |
| 193 | + * @param lineIds 线路id | |
| 194 | + * @return 多线路路由查询 | |
| 195 | + */ | |
| 196 | + @RequestMapping(value = "/stationroute/multiLine", method = RequestMethod.GET) | |
| 197 | + public Map<String, Object> findByMultiLine(@RequestParam String lineIds) { | |
| 198 | + return stationRouteService.findByMultiLine(lineIds); | |
| 199 | + } | |
| 200 | + | |
| 201 | + /** | |
| 202 | + * @return 线路编码和名称对照 | |
| 203 | + */ | |
| 204 | + @RequestMapping("/basic/lineCode2Name") | |
| 205 | + public Map<String, String> findLineCodeMap() { | |
| 206 | + return BasicData.lineCode2NameMap; | |
| 207 | + } | |
| 208 | + | |
| 209 | + /** | |
| 210 | + * @param idx 线路id | |
| 211 | + * @return 场到站 | |
| 212 | + */ | |
| 213 | + @RequestMapping("/basic/station2ParkData") | |
| 214 | + public Map<String, Collection<StationToPark>> findStation2ParkData(@RequestParam String idx) { | |
| 215 | + List<String> lines = Splitter.on(",").splitToList(idx); | |
| 216 | + ArrayListMultimap<String, StationToPark> rs = ArrayListMultimap.create(); | |
| 217 | + | |
| 218 | + for (String lineCode : lines) { | |
| 219 | + rs.putAll(lineCode, Station2ParkBuffer.get(lineCode)); | |
| 220 | + } | |
| 221 | + return rs.asMap(); | |
| 222 | + } | |
| 223 | + | |
| 224 | + /** | |
| 225 | + * @return 设备号和车辆自编号 (K: 设备编码 ,V:车辆自编号) | |
| 226 | + */ | |
| 227 | + @RequestMapping("/basic/nbbm2deviceId") | |
| 228 | + public Map<String, String> nbbm2deviceId() { | |
| 229 | + return BasicData.deviceId2NbbmMap.inverse(); | |
| 230 | + } | |
| 231 | + | |
| 232 | + /** | |
| 233 | + * @return 人员拼音数据映射缓存 | |
| 234 | + */ | |
| 235 | + @RequestMapping(value = "/basic/all_personnel_py", method = RequestMethod.GET) | |
| 236 | + public List<PersionPinYin> findAll_PY() { | |
| 237 | + return persionPinYinBuffer.getAll(); | |
| 238 | + } | |
| 239 | + | |
| 240 | + /** | |
| 241 | + * @return 车辆 | |
| 242 | + */ | |
| 243 | + @RequestMapping("/basic/cars") | |
| 244 | + public Iterable<String> findAllNbbm() { | |
| 245 | + return BasicData.deviceId2NbbmMap.values(); | |
| 246 | + } | |
| 247 | + | |
| 248 | + /** | |
| 249 | + * 车辆自编号和车牌号对照 | |
| 250 | + * | |
| 251 | + * @return 车辆自编号和车牌号对照 | |
| 252 | + */ | |
| 253 | + @RequestMapping("/basic/nbbm2PlateNo") | |
| 254 | + public Map<String, String> nbbm2PlateNo() { | |
| 255 | + return BasicData.nbbmCompanyPlateMap; | |
| 256 | + } | |
| 257 | + | |
| 258 | + /** | |
| 259 | + * 获取车辆信息 | |
| 260 | + * | |
| 261 | + * @param idx 线路id | |
| 262 | + * @return 获取车辆信息 | |
| 263 | + */ | |
| 264 | + @RequestMapping("/basic/ccInfo/lineArray") | |
| 265 | + public List<Map<String, String>> ccInfoByLine(@RequestParam String idx) { | |
| 266 | + List<String> liness = Splitter.on(",").splitToList(idx); | |
| 267 | + List<Map<String, String>> rs = new ArrayList<>(); | |
| 268 | + Set<String> ks = BasicData.nbbm2LineMap.keySet(); | |
| 269 | + Map<String, String> map; | |
| 270 | + BiMap<String, String> nbbm2deviceMap = BasicData.deviceId2NbbmMap.inverse(); | |
| 271 | + Line line; | |
| 272 | + for (String nbbm : ks) { | |
| 273 | + line = BasicData.nbbm2LineMap.get(nbbm); | |
| 274 | + if (liness.contains(line.getLineCode())) { | |
| 275 | + map = new HashMap<>(); | |
| 276 | + map.put("nbbm", nbbm); | |
| 277 | + map.put("lineName", line.getName()); | |
| 278 | + map.put("deviceId", nbbm2deviceMap.get(nbbm)); | |
| 279 | + map.put("lineCode", line.getLineCode()); | |
| 280 | + rs.add(map); | |
| 281 | + } | |
| 282 | + } | |
| 283 | + return rs; | |
| 284 | + } | |
| 285 | + | |
| 286 | + /** | |
| 287 | + * @param lineCodes 线路编码 | |
| 288 | + * @return 多条线路信息 | |
| 289 | + */ | |
| 290 | + @RequestMapping("/lineInformation/line/multi") | |
| 291 | + public List<LineInformation> findByLine(@RequestParam String lineCodes) { | |
| 292 | + return lineInformationService.findByLine(lineCodes); | |
| 293 | + } | |
| 294 | + | |
| 295 | + /** | |
| 296 | + * 主页SVG模拟图 | |
| 297 | + * | |
| 298 | + * @param idx 线路id | |
| 299 | + * @return 主页SVG模拟图 | |
| 300 | + */ | |
| 301 | + @RequestMapping(value = "/realSchedule/svgAttr", method = RequestMethod.GET) | |
| 302 | + public Map<String, Object> findSvgAttr(@RequestParam String idx) { | |
| 303 | + return scheduleRealInfoService.findSvgAttr(idx); | |
| 304 | + } | |
| 305 | + | |
| 306 | + /** | |
| 307 | + * 获取班次 | |
| 308 | + * | |
| 309 | + * @param lines 线路id | |
| 310 | + * @return 获取班次 | |
| 311 | + */ | |
| 312 | + @RequestMapping(value = "/realSchedule/lines") | |
| 313 | + public Map<String, Collection<ScheduleRealInfo>> findByLines(@RequestParam String lines) { | |
| 314 | + return scheduleRealInfoService.findByLines(lines); | |
| 315 | + } | |
| 316 | + | |
| 317 | + /** | |
| 318 | + * 线路编码获取GPS集合 | |
| 319 | + * | |
| 320 | + * @param lineCode 线路编码 | |
| 321 | + * @return 线路编码获取GPS集合 | |
| 322 | + */ | |
| 323 | + @RequestMapping(value = "/gps/real/line/{lineCode}") | |
| 324 | + public List<GpsEntity> findByLineCode(@PathVariable("lineCode") String lineCode) { | |
| 325 | + return gpsRealData.getByLine(lineCode); | |
| 326 | + } | |
| 327 | + | |
| 328 | + /** | |
| 329 | + * @param lineCodes 线路编码 | |
| 330 | + * @return 实时gps 超速信息 | |
| 331 | + */ | |
| 332 | + @RequestMapping(value = "/gps/real/line") | |
| 333 | + public Map<String, Object> findByLineCodes(@RequestParam String lineCodes) { | |
| 334 | + Map<String, Object> rs = new HashMap(); | |
| 335 | + List<String> lineArray = Splitter.on(",").splitToList(lineCodes); | |
| 336 | + //超速信息 | |
| 337 | + List<GpsOverspeed> overspeedList = overspeedProcess.findByLines(lineArray); | |
| 338 | + //实时gps | |
| 339 | + List<GpsEntity> gpsList = gpsRealData.get(lineArray); | |
| 340 | + rs.put("gpsList", gpsList); | |
| 341 | + rs.put("overspeedList", overspeedList); | |
| 342 | + return rs; | |
| 343 | + } | |
| 344 | + | |
| 345 | + /** | |
| 346 | + * 历史GPS查询 ,第三版轨迹回放用 | |
| 347 | + * | |
| 348 | + * @param nbbm 车辆编号 | |
| 349 | + * @param st 开始时间 | |
| 350 | + * @param et 结束时间 | |
| 351 | + * @return 历史GPS查询 | |
| 352 | + */ | |
| 353 | + @RequestMapping(value = "/gps/history_v3/{nbbm}") | |
| 354 | + public Map<String, Object> history_v3(@PathVariable("nbbm") String nbbm, @RequestParam long st, @RequestParam long et) { | |
| 355 | + return gpsService.history_v3(nbbm, st, et); | |
| 356 | + } | |
| 357 | + | |
| 358 | + /** | |
| 359 | + * 轨迹导出 | |
| 360 | + * | |
| 361 | + * @param nbbm 车辆编号 | |
| 362 | + * @param st 开始时间 | |
| 363 | + * @param et 结束时间 | |
| 364 | + */ | |
| 365 | + @RequestMapping(value = "/gps/history_v3/excel/{nbbm}") | |
| 366 | + public void trailExcel(@PathVariable("nbbm") String nbbm, @RequestParam long st, @RequestParam long et, HttpServletResponse resp) { | |
| 367 | + gpsService.trailExcel(nbbm, st, et, resp); | |
| 368 | + } | |
| 369 | + | |
| 370 | + /** | |
| 371 | + * 轨迹异常数据导出 | |
| 372 | + * | |
| 373 | + * @param nbbm 车辆编号 | |
| 374 | + * @param st 开始时间 | |
| 375 | + * @param et 结束时间 | |
| 376 | + */ | |
| 377 | + @RequestMapping(value = "/gps/history_v3/excel_abnormal/{nbbm}") | |
| 378 | + public void abnormalExcel(@PathVariable("nbbm") String nbbm, @RequestParam long st, @RequestParam long et, HttpServletResponse resp) { | |
| 379 | + gpsService.abnormalExcel(nbbm, st, et, resp); | |
| 380 | + } | |
| 381 | + | |
| 382 | + /** | |
| 383 | + * 获取线路下所有车辆,包括实时设备 和 计划排班 | |
| 384 | + * | |
| 385 | + * @param lineCode 线路编码 | |
| 386 | + * @return 获取线路下所有车辆,包括实时设备 和 计划排班 | |
| 387 | + */ | |
| 388 | + @RequestMapping(value = "/gps/allCarsByLine", method = RequestMethod.GET) | |
| 389 | + public Map<String, Object> allCarsByLine(String lineCode) { | |
| 390 | + return gpsService.allCarsByLine(lineCode); | |
| 391 | + } | |
| 392 | +} | ... | ... |