Commit 6da8d508cfa0212f169d2bb350726d5852eded70
1 parent
7e22204c
1.加入灾备平台信创链路
Showing
1 changed file
with
423 additions
and
403 deletions
src/main/java/com/bsth/controller/realcontrol/AdminUtilsController.java
| 1 | -package com.bsth.controller.realcontrol; | ||
| 2 | - | ||
| 3 | -import java.lang.reflect.Field; | ||
| 4 | -import java.lang.reflect.Modifier; | ||
| 5 | -import java.util.*; | ||
| 6 | - | ||
| 7 | -import com.bsth.data.BasicData; | ||
| 8 | -import com.bsth.security.SsoConfig; | ||
| 9 | -import com.bsth.service.SectionService; | ||
| 10 | -import com.bsth.service.StationService; | ||
| 11 | -import com.bsth.data.directive.DayOfDirectives; | ||
| 12 | -import com.bsth.data.directive.DirectivesPstThread; | ||
| 13 | -import com.bsth.data.directive.GatewayHttpUtils; | ||
| 14 | -import com.bsth.data.gpsdata_v2.cache.GeoCacheData; | ||
| 15 | -import com.bsth.data.gpsdata_v2.handlers.overspeed.OverspeedProcess; | ||
| 16 | -import com.bsth.data.gpsdata_v2.load.GatewayHttpLoader; | ||
| 17 | -import com.bsth.data.gpsdata_v2.load.SocketClientLoader; | ||
| 18 | -import com.bsth.data.gpsdata_v2.rfid.RfidHttpLoader; | ||
| 19 | -import com.bsth.data.gpsdata_v2.thread.GpsDataLoaderThread; | ||
| 20 | -import com.bsth.data.msg_queue.DirectivePushQueue; | ||
| 21 | -import com.bsth.data.msg_queue.WebSocketPushQueue; | ||
| 22 | -import com.bsth.data.pilot80.PilotReport; | ||
| 23 | -import com.bsth.data.schedule.DayOfSchedule; | ||
| 24 | -import com.bsth.entity.realcontrol.ScheduleRealInfo; | ||
| 25 | -import com.bsth.filter.SQLInjectFilter; | ||
| 26 | -import com.bsth.service.SystemParamService; | ||
| 27 | -import com.bsth.service.schedule.utils.SpringUtils; | ||
| 28 | -import com.bsth.util.MailUtils; | ||
| 29 | -import com.fasterxml.jackson.core.JsonProcessingException; | ||
| 30 | -import com.fasterxml.jackson.databind.ObjectMapper; | ||
| 31 | -import com.fasterxml.jackson.databind.SerializationFeature; | ||
| 32 | -import org.slf4j.Logger; | ||
| 33 | -import org.slf4j.LoggerFactory; | ||
| 34 | -import org.springframework.beans.factory.annotation.Autowired; | ||
| 35 | -import org.springframework.web.bind.annotation.RequestMapping; | ||
| 36 | -import org.springframework.web.bind.annotation.RequestParam; | ||
| 37 | -import org.springframework.web.bind.annotation.RestController; | ||
| 38 | - | ||
| 39 | -import com.bsth.common.ResponseCode; | ||
| 40 | -import com.bsth.websocket.handler.SendUtils; | ||
| 41 | - | ||
| 42 | -import ch.qos.logback.classic.Level; | ||
| 43 | -import ch.qos.logback.classic.LoggerContext; | ||
| 44 | - | ||
| 45 | -/** | ||
| 46 | - * Created by panzhao on 2017/4/14. | ||
| 47 | - */ | ||
| 48 | -@RestController | ||
| 49 | -@RequestMapping("adminUtils") | ||
| 50 | -public class AdminUtilsController { | ||
| 51 | - | ||
| 52 | - | ||
| 53 | - Logger logger = LoggerFactory.getLogger(this.getClass()); | ||
| 54 | - | ||
| 55 | - @Autowired | ||
| 56 | - private ObjectMapper objectMapper; | ||
| 57 | - | ||
| 58 | - @Autowired | ||
| 59 | - DayOfSchedule dayOfSchedule; | ||
| 60 | - | ||
| 61 | - @Autowired | ||
| 62 | - GeoCacheData geoCacheData; | ||
| 63 | - | ||
| 64 | - @Autowired | ||
| 65 | - DayOfDirectives dayOfDirectives; | ||
| 66 | - | ||
| 67 | - @Autowired | ||
| 68 | - SendUtils sendUtils; | ||
| 69 | - | ||
| 70 | - @Autowired | ||
| 71 | - PilotReport pilotReport; | ||
| 72 | - | ||
| 73 | - @Autowired | ||
| 74 | - private MailUtils mailUtils; | ||
| 75 | - | ||
| 76 | - @Autowired | ||
| 77 | - private BasicData.BasicDataLoader basicDataLoader; | ||
| 78 | - | ||
| 79 | - @Autowired | ||
| 80 | - private SectionService sectionService; | ||
| 81 | - | ||
| 82 | - @Autowired | ||
| 83 | - private StationService stationService; | ||
| 84 | - | ||
| 85 | - @Autowired | ||
| 86 | - private SystemParamService systemParamService; | ||
| 87 | - | ||
| 88 | - @Autowired | ||
| 89 | - private SocketClientLoader socketClientLoader; | ||
| 90 | - | ||
| 91 | - @Autowired | ||
| 92 | - private GatewayHttpLoader gatewayHttpLoader; | ||
| 93 | - | ||
| 94 | - @Autowired | ||
| 95 | - private GatewayHttpUtils gatewayHttpUtils; | ||
| 96 | - | ||
| 97 | - @Autowired | ||
| 98 | - private RfidHttpLoader rfidHttpLoader; | ||
| 99 | - | ||
| 100 | - @Autowired | ||
| 101 | - private SsoConfig ssoConfig; | ||
| 102 | - | ||
| 103 | - /** | ||
| 104 | - * 出现重复班次的车辆 | ||
| 105 | - * | ||
| 106 | - * @param | ||
| 107 | - * @RequestMapping(value = "/schRepeat", method = RequestMethod.POST) | ||
| 108 | - * public void schRepeat(@RequestParam String nbbm){ | ||
| 109 | - * logger.info("前端通知,车辆 " + nbbm + "出现重复班次,开始检测..."); | ||
| 110 | - * List<ScheduleRealInfo> list = dayOfSchedule.findByNbbm(nbbm); | ||
| 111 | - * logger.info("检测前,车辆班次数量:" + list.size()); | ||
| 112 | - * <p> | ||
| 113 | - * Map<Long, ScheduleRealInfo> map = new HashMap<>(); | ||
| 114 | - * for(ScheduleRealInfo sch : list){ | ||
| 115 | - * if(map.containsKey(sch.getId())){ | ||
| 116 | - * logger.info("检测到重复ID: " + sch.getId()); | ||
| 117 | - * } | ||
| 118 | - * map.put(sch.getId(), sch); | ||
| 119 | - * } | ||
| 120 | - * <p> | ||
| 121 | - * logger.info("检测后,车辆班次数量:" + list.size()); | ||
| 122 | - * if(map.values().size() > 0){ | ||
| 123 | - * dayOfSchedule.replaceByNbbm(nbbm, map.values()); | ||
| 124 | - * } | ||
| 125 | - * } | ||
| 126 | - */ | ||
| 127 | - | ||
| 128 | -/* @RequestMapping(value = "/directivePushQueue") | ||
| 129 | - public void directivePushQueue(){ | ||
| 130 | - DirectivePushQueue.start(); | ||
| 131 | - }*/ | ||
| 132 | - @RequestMapping(value = "/directiveQueueSize") | ||
| 133 | - public void directiveQueueSize() { | ||
| 134 | - DirectivePushQueue.size(); | ||
| 135 | - } | ||
| 136 | - | ||
| 137 | - /*@RequestMapping(value = "/webSocketPushQueue") | ||
| 138 | - public void webSocketPushQueue(){ | ||
| 139 | - WebSocketPushQueue.start(); | ||
| 140 | - }*/ | ||
| 141 | - | ||
| 142 | - @RequestMapping(value = "/webSocketQueueSize") | ||
| 143 | - public void webSocketQueueSize() { | ||
| 144 | - WebSocketPushQueue.size(); | ||
| 145 | - } | ||
| 146 | - | ||
| 147 | - @RequestMapping(value = "/setHttpFlag") | ||
| 148 | - public void setHttpFlag(@RequestParam int flag) { | ||
| 149 | - if (flag != 0 && flag != -1) | ||
| 150 | - return; | ||
| 151 | - GpsDataLoaderThread.setFlag(flag); | ||
| 152 | - } | ||
| 153 | - | ||
| 154 | - @RequestMapping(value = "/updateCacheBuff") | ||
| 155 | - public void updateCacheBuff() { | ||
| 156 | - geoCacheData.loadData(); | ||
| 157 | - } | ||
| 158 | - | ||
| 159 | - @RequestMapping(value = "/reCalcLpSch") | ||
| 160 | - public void reCalcLpSch() { | ||
| 161 | - dayOfSchedule._test_reCalcLpSch(); | ||
| 162 | - } | ||
| 163 | - | ||
| 164 | - @RequestMapping(value = "/findSchByLpName") | ||
| 165 | - public List<ScheduleRealInfo> findSchByLpName(@RequestParam String lpName) { | ||
| 166 | - return dayOfSchedule.getLpScheduleMap().get(lpName); | ||
| 167 | - } | ||
| 168 | - | ||
| 169 | - @RequestMapping(value = "/findSchByNbbm") | ||
| 170 | - public List<ScheduleRealInfo> findSchByNbbm(@RequestParam String nbbm) { | ||
| 171 | - return dayOfSchedule.findByNbbm(nbbm); | ||
| 172 | - } | ||
| 173 | - | ||
| 174 | - @RequestMapping(value = "/executeCurr") | ||
| 175 | - public ScheduleRealInfo executeCurr(@RequestParam String nbbm) { | ||
| 176 | - return dayOfSchedule.executeCurr(nbbm); | ||
| 177 | - }; | ||
| 178 | - | ||
| 179 | - @RequestMapping(value = "/reCalcExecPlan4Nbbm") | ||
| 180 | - public void reCalcExecPlan4Nbbm(@RequestParam String nbbm) { | ||
| 181 | - dayOfSchedule.reCalcExecPlan(nbbm); | ||
| 182 | - }; | ||
| 183 | - | ||
| 184 | - @RequestMapping(value = "/reCalcExecPlan4Line") | ||
| 185 | - public void reCalcExecPlan4Line(@RequestParam String lineCode) { | ||
| 186 | - Set<String> nbbms = dayOfSchedule.findCarByLineCode(lineCode); | ||
| 187 | - for (String nbbm : nbbms) { | ||
| 188 | - dayOfSchedule.reCalcExecPlan(nbbm); | ||
| 189 | - } | ||
| 190 | - }; | ||
| 191 | - | ||
| 192 | - @RequestMapping(value = "/removeExecPlan") | ||
| 193 | - public int removeExecPlan(@RequestParam String nbbm) { | ||
| 194 | - dayOfSchedule.removeExecPlan(nbbm); | ||
| 195 | - return 1; | ||
| 196 | - } | ||
| 197 | - | ||
| 198 | - @RequestMapping(value = "/sch_re_calc_id_maps") | ||
| 199 | - public int reCalcIdMaps() { | ||
| 200 | - return dayOfSchedule.reCalcIdMaps(); | ||
| 201 | - } | ||
| 202 | - | ||
| 203 | - @RequestMapping(value = "/sch_size_string") | ||
| 204 | - public String schSizeString() { | ||
| 205 | - return dayOfSchedule.sizeString(); | ||
| 206 | - } | ||
| 207 | - | ||
| 208 | - @RequestMapping(value = "/containerSize") | ||
| 209 | - public Map<String, Integer> containerSize() { | ||
| 210 | - Map<String, Integer> rs = new HashMap<>(); | ||
| 211 | - rs.put("60_size", dayOfDirectives.all60().size()); | ||
| 212 | - rs.put("80_size", pilotReport.findAll().size()); | ||
| 213 | - rs.put("nbbm_sch_size", dayOfSchedule.findAll().size()); | ||
| 214 | - rs.put("lp_sch_size", dayOfSchedule.findAllByLpContainer().size()); | ||
| 215 | - rs.put("id_sch_size", dayOfSchedule.findAllByIdContainer().size()); | ||
| 216 | - rs.put("pst_sch_size", dayOfSchedule.getPstSize()); | ||
| 217 | - rs.put("speeds_size", OverspeedProcess.size()); | ||
| 218 | - return rs; | ||
| 219 | - } | ||
| 220 | - | ||
| 221 | - @RequestMapping(value = "/websocketRadioText") | ||
| 222 | - public int radioText(String t, String lineCode) { | ||
| 223 | - sendUtils.sendRadioText(t, lineCode); | ||
| 224 | - return 0; | ||
| 225 | - } | ||
| 226 | - | ||
| 227 | - @Autowired | ||
| 228 | - DirectivesPstThread directivesPstThread; | ||
| 229 | - | ||
| 230 | - @RequestMapping(value = "/_sd_60_pst") | ||
| 231 | - public void sd_60_pst() { | ||
| 232 | - logger.info("手动入库指令...."); | ||
| 233 | - directivesPstThread.run(); | ||
| 234 | - } | ||
| 235 | - | ||
| 236 | - /** | ||
| 237 | - * 删除班次,删除内存中未清理掉的非当天的班次 | ||
| 238 | - * @createDate 2019.05.13 | ||
| 239 | - * @author zhangxianzhou | ||
| 240 | - * @param id 线路id | ||
| 241 | - * @return 被删除的班次信息 | ||
| 242 | - */ | ||
| 243 | - @RequestMapping("/deleteSchduleBC") | ||
| 244 | - public Map<String, Object> deleteSchduleBC(Long id) { | ||
| 245 | - Map<String, Object> rs = new HashMap<>(); | ||
| 246 | - rs.put("status", ResponseCode.ERROR); | ||
| 247 | - ScheduleRealInfo sch = null; | ||
| 248 | - try { | ||
| 249 | - sch = dayOfSchedule.get(id); | ||
| 250 | - if (sch == null) { | ||
| 251 | - rs.put("msg", "无效的id号"); | ||
| 252 | - return rs; | ||
| 253 | - } | ||
| 254 | - | ||
| 255 | - //内存中删除 | ||
| 256 | - dayOfSchedule.deleteBC(sch); | ||
| 257 | - rs.put("delete", sch); | ||
| 258 | - rs.put("status", ResponseCode.SUCCESS); | ||
| 259 | - | ||
| 260 | - } catch (Exception e) { | ||
| 261 | - logger.error("", e); | ||
| 262 | - rs.put("msg", e.getMessage()); | ||
| 263 | - sch.setDeleted(false); | ||
| 264 | - } | ||
| 265 | - | ||
| 266 | - return rs; | ||
| 267 | - } | ||
| 268 | - | ||
| 269 | - @RequestMapping("/changeLogLevel") | ||
| 270 | - public Map<String, Object> changeLogLevel(@RequestParam String level) { | ||
| 271 | - Map<String, Object> rs = new HashMap<>(); | ||
| 272 | - rs.put("errCode", 1); | ||
| 273 | - LoggerContext context = (LoggerContext)LoggerFactory.getILoggerFactory(); | ||
| 274 | - context.getLogger("root").setLevel(Level.toLevel(level)); | ||
| 275 | - rs.put("errCode", 0); | ||
| 276 | - rs.put("errMsg", "成功"); | ||
| 277 | - | ||
| 278 | - return rs; | ||
| 279 | - } | ||
| 280 | - | ||
| 281 | - @RequestMapping("/exportInstance") | ||
| 282 | - public String exportInstance(@RequestParam String classType) { | ||
| 283 | - Map<String, Object> result = new HashMap<>(); | ||
| 284 | - try { | ||
| 285 | - ObjectMapper mapper = new ObjectMapper(); | ||
| 286 | - mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false); | ||
| 287 | - Class cls = Class.forName(classType); | ||
| 288 | - Field[] fields = cls.getDeclaredFields(); | ||
| 289 | - for (Field field : fields) { | ||
| 290 | - if (Modifier.isStatic(field.getModifiers()) && field.getName().indexOf("log") == -1) { | ||
| 291 | - field.setAccessible(true); | ||
| 292 | - result.put(field.getName(), field.get(cls)); | ||
| 293 | - } | ||
| 294 | - } | ||
| 295 | - result.put("_bean", SpringUtils.getBean(Class.forName(classType))); | ||
| 296 | - return mapper.writeValueAsString(result); | ||
| 297 | - } catch (ClassNotFoundException | JsonProcessingException | IllegalAccessException e) { | ||
| 298 | - e.printStackTrace(); | ||
| 299 | - } | ||
| 300 | - | ||
| 301 | - return "error"; | ||
| 302 | - } | ||
| 303 | - | ||
| 304 | - @RequestMapping("/refreshBasicAll") | ||
| 305 | - public String refreshBasicAll() { | ||
| 306 | - Map<String, Object> result = new HashMap<>(); | ||
| 307 | - try { | ||
| 308 | - basicDataLoader.loadAllData(); | ||
| 309 | - return "success"; | ||
| 310 | - } catch (Exception e) { | ||
| 311 | - e.printStackTrace(); | ||
| 312 | - } | ||
| 313 | - | ||
| 314 | - return "error"; | ||
| 315 | - } | ||
| 316 | - | ||
| 317 | - @RequestMapping("/setInjectStr") | ||
| 318 | - public String setInjectStr(@RequestParam String injectStr) { | ||
| 319 | - Map<String, Object> result = new HashMap<>(); | ||
| 320 | - try { | ||
| 321 | - SQLInjectFilter.setInjStr(injectStr); | ||
| 322 | - return "success"; | ||
| 323 | - } catch (Exception e) { | ||
| 324 | - e.printStackTrace(); | ||
| 325 | - } | ||
| 326 | - | ||
| 327 | - return "error"; | ||
| 328 | - } | ||
| 329 | - | ||
| 330 | - @RequestMapping("/reloadSystemParam") | ||
| 331 | - public String reloadSystemParam() { | ||
| 332 | - try { | ||
| 333 | - systemParamService.refresh(); | ||
| 334 | - | ||
| 335 | - return "success"; | ||
| 336 | - } catch (Exception e) { | ||
| 337 | - e.printStackTrace(); | ||
| 338 | - } | ||
| 339 | - | ||
| 340 | - return "error"; | ||
| 341 | - } | ||
| 342 | - | ||
| 343 | - @RequestMapping("/applySystemParam") | ||
| 344 | - public String applySystemParam() { | ||
| 345 | - try { | ||
| 346 | - socketClientLoader.afterPropertiesSet(); | ||
| 347 | - gatewayHttpLoader.afterPropertiesSet(); | ||
| 348 | - gatewayHttpUtils.afterPropertiesSet(); | ||
| 349 | - rfidHttpLoader.afterPropertiesSet(); | ||
| 350 | - ssoConfig.afterPropertiesSet(); | ||
| 351 | - | ||
| 352 | - return "success"; | ||
| 353 | - } catch (Exception e) { | ||
| 354 | - e.printStackTrace(); | ||
| 355 | - } | ||
| 356 | - | ||
| 357 | - return "error"; | ||
| 358 | - } | ||
| 359 | - | ||
| 360 | - @RequestMapping("/reloadAndApplySystemParam") | ||
| 361 | - public String reloadAndApplySystemParam() { | ||
| 362 | - try { | ||
| 363 | - systemParamService.refresh(); | ||
| 364 | - | ||
| 365 | - socketClientLoader.afterPropertiesSet(); | ||
| 366 | - gatewayHttpLoader.afterPropertiesSet(); | ||
| 367 | - gatewayHttpUtils.afterPropertiesSet(); | ||
| 368 | - rfidHttpLoader.afterPropertiesSet(); | ||
| 369 | - ssoConfig.afterPropertiesSet(); | ||
| 370 | - | ||
| 371 | - return "success"; | ||
| 372 | - } catch (Exception e) { | ||
| 373 | - e.printStackTrace(); | ||
| 374 | - } | ||
| 375 | - | ||
| 376 | - return "error"; | ||
| 377 | - } | ||
| 378 | - | ||
| 379 | - @RequestMapping("/section/translateWgs2Bd") | ||
| 380 | - public String translateWgs2Bd1() { | ||
| 381 | - Map<String, Object> result = new HashMap<>(); | ||
| 382 | - try { | ||
| 383 | - sectionService.translateWgs2Bd(); | ||
| 384 | - return "success"; | ||
| 385 | - } catch (Exception e) { | ||
| 386 | - e.printStackTrace(); | ||
| 387 | - } | ||
| 388 | - | ||
| 389 | - return "error"; | ||
| 390 | - } | ||
| 391 | - | ||
| 392 | - @RequestMapping("/station/translateWgs2Bd") | ||
| 393 | - public String translateWgs2Bd2() { | ||
| 394 | - Map<String, Object> result = new HashMap<>(); | ||
| 395 | - try { | ||
| 396 | - stationService.translateWgs2Bd(); | ||
| 397 | - return "success"; | ||
| 398 | - } catch (Exception e) { | ||
| 399 | - e.printStackTrace(); | ||
| 400 | - } | ||
| 401 | - | ||
| 402 | - return "error"; | ||
| 403 | - } | 1 | +package com.bsth.controller.realcontrol; |
| 2 | + | ||
| 3 | +import java.lang.reflect.Field; | ||
| 4 | +import java.lang.reflect.Modifier; | ||
| 5 | +import java.util.*; | ||
| 6 | +import java.util.concurrent.ScheduledExecutorService; | ||
| 7 | +import java.util.concurrent.TimeUnit; | ||
| 8 | + | ||
| 9 | +import com.bsth.Application; | ||
| 10 | +import com.bsth.data.BasicData; | ||
| 11 | +import com.bsth.security.SsoConfig; | ||
| 12 | +import com.bsth.service.SectionService; | ||
| 13 | +import com.bsth.service.StationService; | ||
| 14 | +import com.bsth.data.directive.DayOfDirectives; | ||
| 15 | +import com.bsth.data.directive.DirectivesPstThread; | ||
| 16 | +import com.bsth.data.directive.GatewayHttpUtils; | ||
| 17 | +import com.bsth.data.gpsdata_v2.cache.GeoCacheData; | ||
| 18 | +import com.bsth.data.gpsdata_v2.handlers.overspeed.OverspeedProcess; | ||
| 19 | +import com.bsth.data.gpsdata_v2.load.GatewayHttpLoader; | ||
| 20 | +import com.bsth.data.gpsdata_v2.load.SocketClientLoader; | ||
| 21 | +import com.bsth.data.gpsdata_v2.rfid.RfidHttpLoader; | ||
| 22 | +import com.bsth.data.gpsdata_v2.thread.GpsDataLoaderThread; | ||
| 23 | +import com.bsth.data.msg_queue.DirectivePushQueue; | ||
| 24 | +import com.bsth.data.msg_queue.WebSocketPushQueue; | ||
| 25 | +import com.bsth.data.pilot80.PilotReport; | ||
| 26 | +import com.bsth.data.schedule.DayOfSchedule; | ||
| 27 | +import com.bsth.entity.realcontrol.ScheduleRealInfo; | ||
| 28 | +import com.bsth.filter.SQLInjectFilter; | ||
| 29 | +import com.bsth.service.SystemParamService; | ||
| 30 | +import com.bsth.service.schedule.utils.SpringUtils; | ||
| 31 | +import com.bsth.util.MailUtils; | ||
| 32 | +import com.fasterxml.jackson.core.JsonProcessingException; | ||
| 33 | +import com.fasterxml.jackson.databind.ObjectMapper; | ||
| 34 | +import com.fasterxml.jackson.databind.SerializationFeature; | ||
| 35 | +import org.slf4j.Logger; | ||
| 36 | +import org.slf4j.LoggerFactory; | ||
| 37 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 38 | +import org.springframework.web.bind.annotation.RequestMapping; | ||
| 39 | +import org.springframework.web.bind.annotation.RequestParam; | ||
| 40 | +import org.springframework.web.bind.annotation.RestController; | ||
| 41 | + | ||
| 42 | +import com.bsth.common.ResponseCode; | ||
| 43 | +import com.bsth.websocket.handler.SendUtils; | ||
| 44 | + | ||
| 45 | +import ch.qos.logback.classic.Level; | ||
| 46 | +import ch.qos.logback.classic.LoggerContext; | ||
| 47 | + | ||
| 48 | +/** | ||
| 49 | + * Created by panzhao on 2017/4/14. | ||
| 50 | + */ | ||
| 51 | +@RestController | ||
| 52 | +@RequestMapping("adminUtils") | ||
| 53 | +public class AdminUtilsController { | ||
| 54 | + | ||
| 55 | + | ||
| 56 | + Logger logger = LoggerFactory.getLogger(this.getClass()); | ||
| 57 | + | ||
| 58 | + @Autowired | ||
| 59 | + private ObjectMapper objectMapper; | ||
| 60 | + | ||
| 61 | + @Autowired | ||
| 62 | + DayOfSchedule dayOfSchedule; | ||
| 63 | + | ||
| 64 | + @Autowired | ||
| 65 | + GeoCacheData geoCacheData; | ||
| 66 | + | ||
| 67 | + @Autowired | ||
| 68 | + DayOfDirectives dayOfDirectives; | ||
| 69 | + | ||
| 70 | + @Autowired | ||
| 71 | + SendUtils sendUtils; | ||
| 72 | + | ||
| 73 | + @Autowired | ||
| 74 | + PilotReport pilotReport; | ||
| 75 | + | ||
| 76 | + @Autowired | ||
| 77 | + private MailUtils mailUtils; | ||
| 78 | + | ||
| 79 | + @Autowired | ||
| 80 | + private BasicData.BasicDataLoader basicDataLoader; | ||
| 81 | + | ||
| 82 | + @Autowired | ||
| 83 | + private SectionService sectionService; | ||
| 84 | + | ||
| 85 | + @Autowired | ||
| 86 | + private StationService stationService; | ||
| 87 | + | ||
| 88 | + @Autowired | ||
| 89 | + private SystemParamService systemParamService; | ||
| 90 | + | ||
| 91 | + @Autowired | ||
| 92 | + private SocketClientLoader socketClientLoader; | ||
| 93 | + | ||
| 94 | + @Autowired | ||
| 95 | + private GatewayHttpLoader gatewayHttpLoader; | ||
| 96 | + | ||
| 97 | + @Autowired | ||
| 98 | + private GatewayHttpUtils gatewayHttpUtils; | ||
| 99 | + | ||
| 100 | + @Autowired | ||
| 101 | + private RfidHttpLoader rfidHttpLoader; | ||
| 102 | + | ||
| 103 | + @Autowired | ||
| 104 | + private SsoConfig ssoConfig; | ||
| 105 | + | ||
| 106 | + /** | ||
| 107 | + * 出现重复班次的车辆 | ||
| 108 | + * | ||
| 109 | + * @param | ||
| 110 | + * @RequestMapping(value = "/schRepeat", method = RequestMethod.POST) | ||
| 111 | + * public void schRepeat(@RequestParam String nbbm){ | ||
| 112 | + * logger.info("前端通知,车辆 " + nbbm + "出现重复班次,开始检测..."); | ||
| 113 | + * List<ScheduleRealInfo> list = dayOfSchedule.findByNbbm(nbbm); | ||
| 114 | + * logger.info("检测前,车辆班次数量:" + list.size()); | ||
| 115 | + * <p> | ||
| 116 | + * Map<Long, ScheduleRealInfo> map = new HashMap<>(); | ||
| 117 | + * for(ScheduleRealInfo sch : list){ | ||
| 118 | + * if(map.containsKey(sch.getId())){ | ||
| 119 | + * logger.info("检测到重复ID: " + sch.getId()); | ||
| 120 | + * } | ||
| 121 | + * map.put(sch.getId(), sch); | ||
| 122 | + * } | ||
| 123 | + * <p> | ||
| 124 | + * logger.info("检测后,车辆班次数量:" + list.size()); | ||
| 125 | + * if(map.values().size() > 0){ | ||
| 126 | + * dayOfSchedule.replaceByNbbm(nbbm, map.values()); | ||
| 127 | + * } | ||
| 128 | + * } | ||
| 129 | + */ | ||
| 130 | + | ||
| 131 | +/* @RequestMapping(value = "/directivePushQueue") | ||
| 132 | + public void directivePushQueue(){ | ||
| 133 | + DirectivePushQueue.start(); | ||
| 134 | + }*/ | ||
| 135 | + @RequestMapping(value = "/directiveQueueSize") | ||
| 136 | + public void directiveQueueSize() { | ||
| 137 | + DirectivePushQueue.size(); | ||
| 138 | + } | ||
| 139 | + | ||
| 140 | + /*@RequestMapping(value = "/webSocketPushQueue") | ||
| 141 | + public void webSocketPushQueue(){ | ||
| 142 | + WebSocketPushQueue.start(); | ||
| 143 | + }*/ | ||
| 144 | + | ||
| 145 | + @RequestMapping(value = "/webSocketQueueSize") | ||
| 146 | + public void webSocketQueueSize() { | ||
| 147 | + WebSocketPushQueue.size(); | ||
| 148 | + } | ||
| 149 | + | ||
| 150 | + @RequestMapping(value = "/setHttpFlag") | ||
| 151 | + public void setHttpFlag(@RequestParam int flag) { | ||
| 152 | + if (flag != 0 && flag != -1) | ||
| 153 | + return; | ||
| 154 | + GpsDataLoaderThread.setFlag(flag); | ||
| 155 | + } | ||
| 156 | + | ||
| 157 | + @RequestMapping(value = "/updateCacheBuff") | ||
| 158 | + public void updateCacheBuff() { | ||
| 159 | + geoCacheData.loadData(); | ||
| 160 | + } | ||
| 161 | + | ||
| 162 | + @RequestMapping(value = "/reCalcLpSch") | ||
| 163 | + public void reCalcLpSch() { | ||
| 164 | + dayOfSchedule._test_reCalcLpSch(); | ||
| 165 | + } | ||
| 166 | + | ||
| 167 | + @RequestMapping(value = "/findSchByLpName") | ||
| 168 | + public List<ScheduleRealInfo> findSchByLpName(@RequestParam String lpName) { | ||
| 169 | + return dayOfSchedule.getLpScheduleMap().get(lpName); | ||
| 170 | + } | ||
| 171 | + | ||
| 172 | + @RequestMapping(value = "/findSchByNbbm") | ||
| 173 | + public List<ScheduleRealInfo> findSchByNbbm(@RequestParam String nbbm) { | ||
| 174 | + return dayOfSchedule.findByNbbm(nbbm); | ||
| 175 | + } | ||
| 176 | + | ||
| 177 | + @RequestMapping(value = "/executeCurr") | ||
| 178 | + public ScheduleRealInfo executeCurr(@RequestParam String nbbm) { | ||
| 179 | + return dayOfSchedule.executeCurr(nbbm); | ||
| 180 | + }; | ||
| 181 | + | ||
| 182 | + @RequestMapping(value = "/reCalcExecPlan4Nbbm") | ||
| 183 | + public void reCalcExecPlan4Nbbm(@RequestParam String nbbm) { | ||
| 184 | + dayOfSchedule.reCalcExecPlan(nbbm); | ||
| 185 | + }; | ||
| 186 | + | ||
| 187 | + @RequestMapping(value = "/reCalcExecPlan4Line") | ||
| 188 | + public void reCalcExecPlan4Line(@RequestParam String lineCode) { | ||
| 189 | + Set<String> nbbms = dayOfSchedule.findCarByLineCode(lineCode); | ||
| 190 | + for (String nbbm : nbbms) { | ||
| 191 | + dayOfSchedule.reCalcExecPlan(nbbm); | ||
| 192 | + } | ||
| 193 | + }; | ||
| 194 | + | ||
| 195 | + @RequestMapping(value = "/removeExecPlan") | ||
| 196 | + public int removeExecPlan(@RequestParam String nbbm) { | ||
| 197 | + dayOfSchedule.removeExecPlan(nbbm); | ||
| 198 | + return 1; | ||
| 199 | + } | ||
| 200 | + | ||
| 201 | + @RequestMapping(value = "/sch_re_calc_id_maps") | ||
| 202 | + public int reCalcIdMaps() { | ||
| 203 | + return dayOfSchedule.reCalcIdMaps(); | ||
| 204 | + } | ||
| 205 | + | ||
| 206 | + @RequestMapping(value = "/sch_size_string") | ||
| 207 | + public String schSizeString() { | ||
| 208 | + return dayOfSchedule.sizeString(); | ||
| 209 | + } | ||
| 210 | + | ||
| 211 | + @RequestMapping(value = "/containerSize") | ||
| 212 | + public Map<String, Integer> containerSize() { | ||
| 213 | + Map<String, Integer> rs = new HashMap<>(); | ||
| 214 | + rs.put("60_size", dayOfDirectives.all60().size()); | ||
| 215 | + rs.put("80_size", pilotReport.findAll().size()); | ||
| 216 | + rs.put("nbbm_sch_size", dayOfSchedule.findAll().size()); | ||
| 217 | + rs.put("lp_sch_size", dayOfSchedule.findAllByLpContainer().size()); | ||
| 218 | + rs.put("id_sch_size", dayOfSchedule.findAllByIdContainer().size()); | ||
| 219 | + rs.put("pst_sch_size", dayOfSchedule.getPstSize()); | ||
| 220 | + rs.put("speeds_size", OverspeedProcess.size()); | ||
| 221 | + return rs; | ||
| 222 | + } | ||
| 223 | + | ||
| 224 | + @RequestMapping(value = "/websocketRadioText") | ||
| 225 | + public int radioText(String t, String lineCode) { | ||
| 226 | + sendUtils.sendRadioText(t, lineCode); | ||
| 227 | + return 0; | ||
| 228 | + } | ||
| 229 | + | ||
| 230 | + @Autowired | ||
| 231 | + DirectivesPstThread directivesPstThread; | ||
| 232 | + | ||
| 233 | + @RequestMapping(value = "/_sd_60_pst") | ||
| 234 | + public void sd_60_pst() { | ||
| 235 | + logger.info("手动入库指令...."); | ||
| 236 | + directivesPstThread.run(); | ||
| 237 | + } | ||
| 238 | + | ||
| 239 | + /** | ||
| 240 | + * 删除班次,删除内存中未清理掉的非当天的班次 | ||
| 241 | + * @createDate 2019.05.13 | ||
| 242 | + * @author zhangxianzhou | ||
| 243 | + * @param id 线路id | ||
| 244 | + * @return 被删除的班次信息 | ||
| 245 | + */ | ||
| 246 | + @RequestMapping("/deleteSchduleBC") | ||
| 247 | + public Map<String, Object> deleteSchduleBC(Long id) { | ||
| 248 | + Map<String, Object> rs = new HashMap<>(); | ||
| 249 | + rs.put("status", ResponseCode.ERROR); | ||
| 250 | + ScheduleRealInfo sch = null; | ||
| 251 | + try { | ||
| 252 | + sch = dayOfSchedule.get(id); | ||
| 253 | + if (sch == null) { | ||
| 254 | + rs.put("msg", "无效的id号"); | ||
| 255 | + return rs; | ||
| 256 | + } | ||
| 257 | + | ||
| 258 | + //内存中删除 | ||
| 259 | + dayOfSchedule.deleteBC(sch); | ||
| 260 | + rs.put("delete", sch); | ||
| 261 | + rs.put("status", ResponseCode.SUCCESS); | ||
| 262 | + | ||
| 263 | + } catch (Exception e) { | ||
| 264 | + logger.error("", e); | ||
| 265 | + rs.put("msg", e.getMessage()); | ||
| 266 | + sch.setDeleted(false); | ||
| 267 | + } | ||
| 268 | + | ||
| 269 | + return rs; | ||
| 270 | + } | ||
| 271 | + | ||
| 272 | + @RequestMapping("/changeLogLevel") | ||
| 273 | + public Map<String, Object> changeLogLevel(@RequestParam String level) { | ||
| 274 | + Map<String, Object> rs = new HashMap<>(); | ||
| 275 | + rs.put("errCode", 1); | ||
| 276 | + LoggerContext context = (LoggerContext)LoggerFactory.getILoggerFactory(); | ||
| 277 | + context.getLogger("root").setLevel(Level.toLevel(level)); | ||
| 278 | + rs.put("errCode", 0); | ||
| 279 | + rs.put("errMsg", "成功"); | ||
| 280 | + | ||
| 281 | + return rs; | ||
| 282 | + } | ||
| 283 | + | ||
| 284 | + @RequestMapping("/exportInstance") | ||
| 285 | + public String exportInstance(@RequestParam String classType) { | ||
| 286 | + Map<String, Object> result = new HashMap<>(); | ||
| 287 | + try { | ||
| 288 | + ObjectMapper mapper = new ObjectMapper(); | ||
| 289 | + mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false); | ||
| 290 | + Class cls = Class.forName(classType); | ||
| 291 | + Field[] fields = cls.getDeclaredFields(); | ||
| 292 | + for (Field field : fields) { | ||
| 293 | + if (Modifier.isStatic(field.getModifiers()) && field.getName().indexOf("log") == -1) { | ||
| 294 | + field.setAccessible(true); | ||
| 295 | + result.put(field.getName(), field.get(cls)); | ||
| 296 | + } | ||
| 297 | + } | ||
| 298 | + result.put("_bean", SpringUtils.getBean(Class.forName(classType))); | ||
| 299 | + return mapper.writeValueAsString(result); | ||
| 300 | + } catch (ClassNotFoundException | JsonProcessingException | IllegalAccessException e) { | ||
| 301 | + e.printStackTrace(); | ||
| 302 | + } | ||
| 303 | + | ||
| 304 | + return "error"; | ||
| 305 | + } | ||
| 306 | + | ||
| 307 | + @RequestMapping("/refreshBasicAll") | ||
| 308 | + public String refreshBasicAll() { | ||
| 309 | + Map<String, Object> result = new HashMap<>(); | ||
| 310 | + try { | ||
| 311 | + basicDataLoader.loadAllData(); | ||
| 312 | + return "success"; | ||
| 313 | + } catch (Exception e) { | ||
| 314 | + e.printStackTrace(); | ||
| 315 | + } | ||
| 316 | + | ||
| 317 | + return "error"; | ||
| 318 | + } | ||
| 319 | + | ||
| 320 | + @RequestMapping("/startSchedule") | ||
| 321 | + public String startSchedule(@RequestParam int bits) { | ||
| 322 | + Map<String, Object> result = new HashMap<>(); | ||
| 323 | + try { | ||
| 324 | + ScheduledExecutorService sexec = Application.mainServices; | ||
| 325 | + if ((bits & 1) == 1) { | ||
| 326 | + sexec.scheduleWithFixedDelay(directivesPstThread, 120, 60, TimeUnit.SECONDS); | ||
| 327 | + } | ||
| 328 | + | ||
| 329 | + return "success"; | ||
| 330 | + } catch (Exception e) { | ||
| 331 | + e.printStackTrace(); | ||
| 332 | + } | ||
| 333 | + | ||
| 334 | + return "error"; | ||
| 335 | + } | ||
| 336 | + | ||
| 337 | + @RequestMapping("/setInjectStr") | ||
| 338 | + public String setInjectStr(@RequestParam String injectStr) { | ||
| 339 | + Map<String, Object> result = new HashMap<>(); | ||
| 340 | + try { | ||
| 341 | + SQLInjectFilter.setInjStr(injectStr); | ||
| 342 | + return "success"; | ||
| 343 | + } catch (Exception e) { | ||
| 344 | + e.printStackTrace(); | ||
| 345 | + } | ||
| 346 | + | ||
| 347 | + return "error"; | ||
| 348 | + } | ||
| 349 | + | ||
| 350 | + @RequestMapping("/reloadSystemParam") | ||
| 351 | + public String reloadSystemParam() { | ||
| 352 | + try { | ||
| 353 | + systemParamService.refresh(); | ||
| 354 | + | ||
| 355 | + return "success"; | ||
| 356 | + } catch (Exception e) { | ||
| 357 | + e.printStackTrace(); | ||
| 358 | + } | ||
| 359 | + | ||
| 360 | + return "error"; | ||
| 361 | + } | ||
| 362 | + | ||
| 363 | + @RequestMapping("/applySystemParam") | ||
| 364 | + public String applySystemParam() { | ||
| 365 | + try { | ||
| 366 | + socketClientLoader.afterPropertiesSet(); | ||
| 367 | + gatewayHttpLoader.afterPropertiesSet(); | ||
| 368 | + gatewayHttpUtils.afterPropertiesSet(); | ||
| 369 | + rfidHttpLoader.afterPropertiesSet(); | ||
| 370 | + ssoConfig.afterPropertiesSet(); | ||
| 371 | + | ||
| 372 | + return "success"; | ||
| 373 | + } catch (Exception e) { | ||
| 374 | + e.printStackTrace(); | ||
| 375 | + } | ||
| 376 | + | ||
| 377 | + return "error"; | ||
| 378 | + } | ||
| 379 | + | ||
| 380 | + @RequestMapping("/reloadAndApplySystemParam") | ||
| 381 | + public String reloadAndApplySystemParam() { | ||
| 382 | + try { | ||
| 383 | + systemParamService.refresh(); | ||
| 384 | + | ||
| 385 | + socketClientLoader.afterPropertiesSet(); | ||
| 386 | + gatewayHttpLoader.afterPropertiesSet(); | ||
| 387 | + gatewayHttpUtils.afterPropertiesSet(); | ||
| 388 | + rfidHttpLoader.afterPropertiesSet(); | ||
| 389 | + ssoConfig.afterPropertiesSet(); | ||
| 390 | + | ||
| 391 | + return "success"; | ||
| 392 | + } catch (Exception e) { | ||
| 393 | + e.printStackTrace(); | ||
| 394 | + } | ||
| 395 | + | ||
| 396 | + return "error"; | ||
| 397 | + } | ||
| 398 | + | ||
| 399 | + @RequestMapping("/section/translateWgs2Bd") | ||
| 400 | + public String translateWgs2Bd1() { | ||
| 401 | + Map<String, Object> result = new HashMap<>(); | ||
| 402 | + try { | ||
| 403 | + sectionService.translateWgs2Bd(); | ||
| 404 | + return "success"; | ||
| 405 | + } catch (Exception e) { | ||
| 406 | + e.printStackTrace(); | ||
| 407 | + } | ||
| 408 | + | ||
| 409 | + return "error"; | ||
| 410 | + } | ||
| 411 | + | ||
| 412 | + @RequestMapping("/station/translateWgs2Bd") | ||
| 413 | + public String translateWgs2Bd2() { | ||
| 414 | + Map<String, Object> result = new HashMap<>(); | ||
| 415 | + try { | ||
| 416 | + stationService.translateWgs2Bd(); | ||
| 417 | + return "success"; | ||
| 418 | + } catch (Exception e) { | ||
| 419 | + e.printStackTrace(); | ||
| 420 | + } | ||
| 421 | + | ||
| 422 | + return "error"; | ||
| 423 | + } | ||
| 404 | } | 424 | } |
| 405 | \ No newline at end of file | 425 | \ No newline at end of file |