Commit c8d5078df1f4d65ac13e6e02deb6d645cd31d90b
Merge branch 'minhang' of http://222.66.0.204:8090/panzhaov5/bsth_control into minhang
# Conflicts: # src/main/java/com/bsth/data/gpsdata/arrival/handlers/InOutStationSignalHandle.java # src/main/java/com/bsth/data/gpsdata/arrival/utils/ScheduleSignalState.java
Showing
23 changed files
with
1327 additions
and
1311 deletions
src/main/java/com/bsth/controller/forms/ExportController.java
| ... | ... | @@ -321,31 +321,34 @@ public class ExportController { |
| 321 | 321 | List<Turnoutrate> turnoutrate = formsService.turnoutrate(map); |
| 322 | 322 | Map<String, Object> map1 = new HashMap<String, Object>(); |
| 323 | 323 | List<Map<String, Object>> resList = new ArrayList<Map<String, Object>>(); |
| 324 | - /*Float xlts=0f; | |
| 325 | - Float jh=0f; | |
| 324 | + String xlts=""; | |
| 325 | + String zsgs=""; | |
| 326 | + String jh=""; | |
| 327 | + Float j=0f; | |
| 326 | 328 | Float sj=0f; |
| 327 | 329 | Float qz=0f; |
| 328 | 330 | Float ccl=0f; |
| 329 | 331 | Float bcjh=0f; |
| 330 | - Float bcsj=0f; | |
| 332 | + String bcsj=""; | |
| 331 | 333 | Float bczxl=0f; |
| 332 | - Float gs=0f; | |
| 333 | - Float zhgs=0f;*/ | |
| 334 | + String gs=""; | |
| 335 | + String zhgs=""; | |
| 334 | 336 | |
| 335 | 337 | for (Turnoutrate l : turnoutrate) { |
| 336 | 338 | Map<String, Object> m = new HashMap<String, Object>(); |
| 337 | 339 | |
| 338 | - /* xlts +=l.getGs()==""?0f:Float.valueOf(l.getGs()); | |
| 339 | - jh +=l.getZhgs()==""?0f:Float.valueOf(l.getZhgs()); | |
| 340 | - sj +=l.getXl()==""?0f:Float.valueOf(l.getXl()); | |
| 341 | - ccl +=l.getCchjh()==""?0f:Float.valueOf(l.getCchjh()); | |
| 342 | - bcjh +=l.getCchsj()==""?0f:Float.valueOf(l.getCchsj()); | |
| 343 | - bcsj +=l.getChl()==""?0f:Float.valueOf(l.getChl()); | |
| 340 | + xlts +=l.getGsgs()==""?0:String.valueOf(l.getGsgs()); | |
| 341 | + zsgs +=l.getFgsgs()==""?0:String.valueOf(l.getFgsgs()); | |
| 342 | + jh +=l.getXl()==""?0:String.valueOf(l.getXl()); | |
| 343 | + sj +=l.getCchjh()==""?0f:Float.valueOf(l.getCchjh()); | |
| 344 | + ccl +=l.getCchsj()==""?0f:Float.valueOf(l.getCchsj()); | |
| 345 | + bcjh +=l.getCchqz()==""?0f:Float.valueOf(l.getCchqz()); | |
| 346 | + bcsj +=l.getChl()==""?0:String.valueOf(l.getChl()); | |
| 344 | 347 | bczxl +=l.getBcjh()==""?0f:Float.valueOf(l.getBcjh()); |
| 345 | - gs +=l.getBbzxl()==""?0f:Float.valueOf(l.getBbzxl()); | |
| 346 | - zhgs +=l.getBbzxl()==""?0f:Float.valueOf(l.getBbzxl()); | |
| 348 | + gs +=l.getBcsj()==""?0:String.valueOf(l.getBcsj()); | |
| 349 | + zhgs +=l.getBbzxl()==""?0:String.valueOf(l.getBbzxl()); | |
| 350 | + | |
| 347 | 351 | |
| 348 | - */ | |
| 349 | 352 | m.put("rq", l.getRq()); |
| 350 | 353 | m.put("gs", l.getGs()); |
| 351 | 354 | m.put("zhgs", l.getZhgs()); |
| ... | ... | @@ -355,23 +358,27 @@ public class ExportController { |
| 355 | 358 | m.put("cchqz", l.getCchqz()); |
| 356 | 359 | m.put("chl", l.getChl()); |
| 357 | 360 | m.put("bcjh", l.getBcjh()); |
| 358 | - m.put("bcsj", l.getBbzxl()); | |
| 361 | + m.put("bcsj", l.getBcsj()); | |
| 359 | 362 | m.put("bbzxl", l.getBbzxl()); |
| 360 | 363 | m.put("sm", l.getSm()); |
| 361 | 364 | resList.add(m); |
| 362 | 365 | |
| 363 | - /*m=new HashMap<String,Object>(); | |
| 364 | - m.put("total_xlts", jh); | |
| 366 | + | |
| 367 | + | |
| 368 | + m=new HashMap<String,Object>(); | |
| 369 | + m.put("total_xlts", xlts); | |
| 370 | + m.put("total_zhgs", zsgs); | |
| 365 | 371 | m.put("total_jh", jh); |
| 366 | 372 | m.put("total_sj", sj); |
| 367 | - m.put("total_qz", qz); | |
| 368 | - m.put("total_ccl", ccl); | |
| 369 | - m.put("total_bcjh", bcjh); | |
| 370 | - m.put("total_bcsj", bcsj); | |
| 373 | + m.put("total_qz", ccl); | |
| 374 | + m.put("total_ccl", bcjh); | |
| 375 | + m.put("total_bcjh",bcsj); | |
| 376 | + m.put("total_bcsj", bczxl); | |
| 371 | 377 | m.put("total_bczxl", bczxl); |
| 372 | - m.put("total_gs", gs); | |
| 373 | - m.put("total_zhgs", zhgs); | |
| 374 | - */ | |
| 378 | + m.put("total_gs", zhgs); | |
| 379 | + | |
| 380 | + | |
| 381 | + map1 = m; | |
| 375 | 382 | } |
| 376 | 383 | |
| 377 | 384 | try { |
| ... | ... | @@ -385,7 +392,7 @@ public class ExportController { |
| 385 | 392 | return resList; |
| 386 | 393 | } |
| 387 | 394 | |
| 388 | - //营运线路出车率统计表 | |
| 395 | + //班次执行率统计表 | |
| 389 | 396 | @RequestMapping(value = "/executionrateExport", method = RequestMethod.POST) |
| 390 | 397 | public List<Map<String, Object>> executionrateExport(@RequestParam Map<String, Object> map) { |
| 391 | 398 | SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"), sdfSimple = new SimpleDateFormat("yyyyMMdd"); |
| ... | ... | @@ -394,29 +401,33 @@ public class ExportController { |
| 394 | 401 | List<Executionrate> executionrate = formsService.executionrate(map); |
| 395 | 402 | Map<String, Object> map1 = new HashMap<String, Object>(); |
| 396 | 403 | List<Map<String, Object>> resList = new ArrayList<Map<String, Object>>(); |
| 397 | - /* Float xlts=0f; | |
| 398 | - Float jh=0f; | |
| 404 | + String xlts=""; | |
| 405 | + String zsgs=""; | |
| 406 | + String jh=""; | |
| 399 | 407 | Float sj=0f; |
| 400 | 408 | Float ccl=0f; |
| 401 | 409 | Float bcjh=0f; |
| 402 | - Float bcsj=0f; | |
| 410 | + String bcsj=""; | |
| 403 | 411 | Float bczxl=0f; |
| 404 | - Float gs=0f; | |
| 405 | - Float zhgs=0f;*/ | |
| 412 | + String gs=""; | |
| 413 | + String zhgs=""; | |
| 406 | 414 | |
| 415 | + Map<String, Object> m = new HashMap<String, Object>(); | |
| 416 | + | |
| 407 | 417 | for (Executionrate l : executionrate) { |
| 408 | - Map<String, Object> m = new HashMap<String, Object>(); | |
| 409 | - /* xlts +=l.getGs()==""?0f:Float.valueOf(l.getGs()); | |
| 410 | - jh +=l.getZhgs()==""?0f:Float.valueOf(l.getZhgs()); | |
| 411 | - sj +=l.getXl()==""?0f:Float.valueOf(l.getXl()); | |
| 412 | - ccl +=l.getCchjh()==""?0f:Float.valueOf(l.getCchjh()); | |
| 413 | - bcjh +=l.getCchsj()==""?0f:Float.valueOf(l.getCchsj()); | |
| 414 | - bcsj +=l.getChl()==""?0f:Float.valueOf(l.getChl()); | |
| 418 | + | |
| 419 | + xlts +=l.getGsgs()==""?0:String.valueOf(l.getGsgs()); | |
| 420 | + zsgs +=l.getFgsgs()==""?0:String.valueOf(l.getFgsgs()); | |
| 421 | + jh +=l.getXl()==""?0:String.valueOf(l.getXl()); | |
| 422 | + sj +=l.getCchjh()==""?0f:Float.valueOf(l.getCchjh()); | |
| 423 | + ccl +=l.getCchsj()==""?0f:Float.valueOf(l.getCchsj()); | |
| 424 | + bcsj +=l.getChl()==""?0:String.valueOf(l.getChl()); | |
| 415 | 425 | bczxl +=l.getBcjh()==""?0f:Float.valueOf(l.getBcjh()); |
| 416 | - gs +=l.getBbzxl()==""?0f:Float.valueOf(l.getBbzxl()); | |
| 417 | - zhgs +=l.getBbzxl()==""?0f:Float.valueOf(l.getBbzxl()); | |
| 426 | + gs +=l.getBcsj()==""?0:String.valueOf(l.getBcsj()); | |
| 427 | + zhgs +=l.getBbzxl()==""?0:String.valueOf(l.getBbzxl()); | |
| 428 | + | |
| 429 | + | |
| 418 | 430 | |
| 419 | - */ | |
| 420 | 431 | m.put("rq", l.getRq()); |
| 421 | 432 | m.put("gs", l.getGs()); |
| 422 | 433 | m.put("zhgs", l.getZhgs()); |
| ... | ... | @@ -425,23 +436,24 @@ public class ExportController { |
| 425 | 436 | m.put("cchsj", l.getCchsj()); |
| 426 | 437 | m.put("chl", l.getChl()); |
| 427 | 438 | m.put("bcjh", l.getBcjh()); |
| 428 | - m.put("bcsj", l.getBbzxl()); | |
| 439 | + m.put("bcsj", l.getBcsj()); | |
| 429 | 440 | m.put("bbzxl", l.getBbzxl()); |
| 430 | 441 | m.put("sm", l.getSm()); |
| 431 | 442 | resList.add(m); |
| 432 | 443 | |
| 433 | 444 | |
| 434 | - /* m=new HashMap<String,Object>(); | |
| 445 | + m=new HashMap<String,Object>(); | |
| 446 | + m.put("total_gs", xlts); | |
| 447 | + m.put("total_zhgs", zsgs); | |
| 435 | 448 | m.put("total_xlts", jh); |
| 436 | - m.put("total_jh", jh); | |
| 437 | - m.put("total_sj", sj); | |
| 438 | - m.put("total_ccl", ccl); | |
| 439 | - m.put("total_bcjh", bcjh); | |
| 440 | - m.put("total_bcsj", bcsj); | |
| 441 | - m.put("total_bczxl", bczxl); | |
| 442 | - m.put("total_gs", gs); | |
| 443 | - m.put("total_zhgs", zhgs);*/ | |
| 449 | + m.put("total_jh", sj); | |
| 450 | + m.put("total_sj", ccl); | |
| 451 | + m.put("total_ccl",bcsj); | |
| 452 | + m.put("total_bcjh", bczxl); | |
| 453 | + m.put("total_bcsj", gs); | |
| 454 | + m.put("total_bczxl", zhgs); | |
| 444 | 455 | |
| 456 | + map1 = m; | |
| 445 | 457 | } |
| 446 | 458 | |
| 447 | 459 | try { |
| ... | ... | @@ -465,41 +477,42 @@ public class ExportController { |
| 465 | 477 | List<Allline> allline = formsService.allline(map); |
| 466 | 478 | Map<String, Object> map1 = new HashMap<String, Object>(); |
| 467 | 479 | List<Map<String, Object>> resList = new ArrayList<Map<String, Object>>(); |
| 468 | - /* Integer jh=0; | |
| 480 | + Integer jh=0; | |
| 469 | 481 | Integer sj=0; |
| 470 | 482 | Integer ccl=0; |
| 471 | - Integer bcjh=0; | |
| 472 | - Float bcsj=0f; | |
| 483 | + Double bcjh=0.0; | |
| 484 | + String bcsj=""; | |
| 473 | 485 | Integer bczxl=0; |
| 474 | - Integer gs=0; | |
| 475 | - Float zhgs=0f; | |
| 476 | - */ | |
| 486 | + String gs=""; | |
| 487 | + String zhgs=""; | |
| 488 | + Map<String, Object> m ; | |
| 477 | 489 | for (Allline l : allline) { |
| 478 | - Map<String, Object> m = new HashMap<String, Object>(); | |
| 490 | + m = new HashMap<String, Object>(); | |
| 479 | 491 | |
| 480 | - /*jh +=l.getGsgs()=="" ? 0: Integer.valueOf(l.getGsgs()); | |
| 492 | + jh +=l.getGsgs()=="" ? 0: Integer.valueOf(l.getGsgs()); | |
| 481 | 493 | sj +=l.getFgsgs()==""?0: Integer.valueOf(l.getFgsgs()); |
| 482 | 494 | ccl +=l.getCchjh()==""?0: Integer.valueOf(l.getCchjh()); |
| 483 | - bcjh +=l.getCchsj()==""?0: Integer.valueOf(l.getCchsj()); | |
| 484 | - bcsj +=l.getChl()==""?0f:Float.valueOf(l.getChl()); | |
| 495 | + bcjh +=l.getCchsj()==""?0: Double.valueOf(l.getCchsj()); | |
| 496 | + | |
| 497 | + bcsj +=l.getChl()==""? 0:String.valueOf(l.getChl()); | |
| 485 | 498 | bczxl +=l.getBcjh()==""?0: Integer.valueOf(l.getBcjh()); |
| 486 | - gs +=l.getBbzxl()==""?0: Integer.valueOf(l.getBbzxl()); | |
| 487 | - zhgs +=l.getBbzxl()==""?0f:Float.valueOf(l.getBbzxl()); | |
| 488 | - */ | |
| 499 | + gs +=l.getBcsj()==""?0: String.valueOf(l.getBcsj()); | |
| 500 | + zhgs +=l.getBbzxl()==""?0:String.valueOf(l.getBbzxl()); | |
| 501 | + | |
| 489 | 502 | m.put("rq", l.getRq()); |
| 490 | - m.put("gs", l.getGsgs()); | |
| 491 | - m.put("zhgs", l.getFgsgs()); | |
| 492 | - //m.put("xl", l.getXl()); | |
| 503 | + m.put("gs", l.getGs()); | |
| 504 | + m.put("zhgs", l.getZhgs()); | |
| 505 | + m.put("xl", l.getXl()); | |
| 493 | 506 | m.put("cchjh", l.getCchjh()); |
| 494 | 507 | m.put("cchsj", l.getCchsj()); |
| 495 | 508 | m.put("chl", l.getChl()); |
| 496 | 509 | m.put("bcjh", l.getBcjh()); |
| 497 | - m.put("bcsj", l.getBbzxl()); | |
| 510 | + m.put("bcsj", l.getBcsj()); | |
| 498 | 511 | m.put("bbzxl", l.getBbzxl()); |
| 499 | 512 | m.put("sm", l.getSm()); |
| 500 | 513 | resList.add(m); |
| 501 | 514 | |
| 502 | - /*m=new HashMap<String,Object>(); | |
| 515 | + m=new HashMap<String,Object>(); | |
| 503 | 516 | m.put("total_jh", jh); |
| 504 | 517 | m.put("total_sj", sj); |
| 505 | 518 | m.put("total_ccl", ccl); |
| ... | ... | @@ -508,7 +521,8 @@ public class ExportController { |
| 508 | 521 | m.put("total_bczxl", bczxl); |
| 509 | 522 | m.put("total_gs", gs); |
| 510 | 523 | m.put("total_zhgs", zhgs); |
| 511 | - */ | |
| 524 | + map1 = m; | |
| 525 | + | |
| 512 | 526 | } |
| 513 | 527 | |
| 514 | 528 | try { | ... | ... |
src/main/java/com/bsth/controller/realcontrol/SignalStateController.java
| 1 | -package com.bsth.controller.realcontrol; | |
| 2 | - | |
| 3 | -import com.bsth.data.gpsdata.SignalStateData; | |
| 4 | -import com.bsth.data.gpsdata.arrival.entity.SignalState; | |
| 5 | -import org.springframework.beans.factory.annotation.Autowired; | |
| 6 | -import org.springframework.web.bind.annotation.RequestMapping; | |
| 7 | -import org.springframework.web.bind.annotation.RequestParam; | |
| 8 | -import org.springframework.web.bind.annotation.RestController; | |
| 9 | - | |
| 10 | -import java.util.List; | |
| 11 | - | |
| 12 | -/** | |
| 13 | - * Created by panzhao on 2016/12/30. | |
| 14 | - */ | |
| 15 | -@RestController | |
| 16 | -@RequestMapping("signalState") | |
| 17 | -public class SignalStateController { | |
| 18 | - | |
| 19 | - @Autowired | |
| 20 | - SignalStateData signalStateData; | |
| 21 | - | |
| 22 | - @RequestMapping("/multi") | |
| 23 | - public List<SignalState> findByMultiLine(@RequestParam String idx){ | |
| 24 | - return signalStateData.get(idx); | |
| 25 | - } | |
| 26 | -} | |
| 1 | +package com.bsth.controller.realcontrol; | |
| 2 | + | |
| 3 | +import com.bsth.data.gpsdata.SignalStateData; | |
| 4 | +import com.bsth.data.gpsdata.arrival.entity.SignalState; | |
| 5 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 6 | +import org.springframework.web.bind.annotation.RequestMapping; | |
| 7 | +import org.springframework.web.bind.annotation.RequestParam; | |
| 8 | +import org.springframework.web.bind.annotation.RestController; | |
| 9 | + | |
| 10 | +import java.util.List; | |
| 11 | + | |
| 12 | +/** | |
| 13 | + * Created by panzhao on 2016/12/30. | |
| 14 | + */ | |
| 15 | +@RestController | |
| 16 | +@RequestMapping("signalState") | |
| 17 | +public class SignalStateController { | |
| 18 | + | |
| 19 | + @Autowired | |
| 20 | + SignalStateData signalStateData; | |
| 21 | + | |
| 22 | + @RequestMapping("/multi") | |
| 23 | + public List<SignalState> findByMultiLine(@RequestParam String idx){ | |
| 24 | + return signalStateData.get(idx); | |
| 25 | + } | |
| 26 | +} | ... | ... |
src/main/java/com/bsth/data/gpsdata/SignalStateData.java
| 1 | -package com.bsth.data.gpsdata; | |
| 2 | - | |
| 3 | -import com.bsth.data.gpsdata.arrival.entity.SignalState; | |
| 4 | -import com.bsth.websocket.handler.SendUtils; | |
| 5 | -import com.google.common.base.Splitter; | |
| 6 | -import com.google.common.collect.ArrayListMultimap; | |
| 7 | -import org.springframework.beans.factory.annotation.Autowired; | |
| 8 | -import org.springframework.stereotype.Component; | |
| 9 | - | |
| 10 | -import java.util.ArrayList; | |
| 11 | -import java.util.List; | |
| 12 | - | |
| 13 | -/** | |
| 14 | - * 信号状态数据 | |
| 15 | - * Created by panzhao on 2016/12/30. | |
| 16 | - */ | |
| 17 | -@Component | |
| 18 | -public class SignalStateData { | |
| 19 | - | |
| 20 | - @Autowired | |
| 21 | - SendUtils sendUtils; | |
| 22 | - | |
| 23 | - private static ArrayListMultimap<String, SignalState> listMultimap = ArrayListMultimap.create(); | |
| 24 | - | |
| 25 | - public void put(SignalState state){ | |
| 26 | - listMultimap.put(state.getLineCode(), state); | |
| 27 | - //推送到客户端 | |
| 28 | - sendUtils.sendSignalState(state); | |
| 29 | - } | |
| 30 | - | |
| 31 | - public List<SignalState> get(String idx){ | |
| 32 | - List<SignalState> rs = new ArrayList<>(); | |
| 33 | - List<String> ids = Splitter.on(",").splitToList(idx); | |
| 34 | - | |
| 35 | - for(String lineCode : ids){ | |
| 36 | - rs.addAll(listMultimap.get(lineCode)); | |
| 37 | - } | |
| 38 | - return rs; | |
| 39 | - } | |
| 40 | -} | |
| 1 | +package com.bsth.data.gpsdata; | |
| 2 | + | |
| 3 | +import com.bsth.data.gpsdata.arrival.entity.SignalState; | |
| 4 | +import com.bsth.websocket.handler.SendUtils; | |
| 5 | +import com.google.common.base.Splitter; | |
| 6 | +import com.google.common.collect.ArrayListMultimap; | |
| 7 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 8 | +import org.springframework.stereotype.Component; | |
| 9 | + | |
| 10 | +import java.util.ArrayList; | |
| 11 | +import java.util.List; | |
| 12 | + | |
| 13 | +/** | |
| 14 | + * 信号状态数据 | |
| 15 | + * Created by panzhao on 2016/12/30. | |
| 16 | + */ | |
| 17 | +@Component | |
| 18 | +public class SignalStateData { | |
| 19 | + | |
| 20 | + @Autowired | |
| 21 | + SendUtils sendUtils; | |
| 22 | + | |
| 23 | + private static ArrayListMultimap<String, SignalState> listMultimap = ArrayListMultimap.create(); | |
| 24 | + | |
| 25 | + public void put(SignalState state){ | |
| 26 | + listMultimap.put(state.getLineCode(), state); | |
| 27 | + //推送到客户端 | |
| 28 | + sendUtils.sendSignalState(state); | |
| 29 | + } | |
| 30 | + | |
| 31 | + public List<SignalState> get(String idx){ | |
| 32 | + List<SignalState> rs = new ArrayList<>(); | |
| 33 | + List<String> ids = Splitter.on(",").splitToList(idx); | |
| 34 | + | |
| 35 | + for(String lineCode : ids){ | |
| 36 | + rs.addAll(listMultimap.get(lineCode)); | |
| 37 | + } | |
| 38 | + return rs; | |
| 39 | + } | |
| 40 | +} | ... | ... |
src/main/java/com/bsth/data/gpsdata/arrival/GeoCacheData.java
| 1 | -package com.bsth.data.gpsdata.arrival; | |
| 2 | - | |
| 3 | -import com.bsth.data.gpsdata.GpsEntity; | |
| 4 | -import com.bsth.data.gpsdata.arrival.entity.StationRoute; | |
| 5 | -import com.bsth.data.gpsdata.arrival.utils.CircleQueue; | |
| 6 | -import com.bsth.data.gpsdata.arrival.utils.StationRouteComp; | |
| 7 | -import com.google.common.collect.ArrayListMultimap; | |
| 8 | -import com.vividsolutions.jts.geom.Coordinate; | |
| 9 | -import com.vividsolutions.jts.geom.GeometryFactory; | |
| 10 | -import com.vividsolutions.jts.geom.LineString; | |
| 11 | -import com.vividsolutions.jts.geom.Polygon; | |
| 12 | -import org.apache.commons.lang3.StringUtils; | |
| 13 | -import org.slf4j.Logger; | |
| 14 | -import org.slf4j.LoggerFactory; | |
| 15 | -import org.springframework.beans.factory.annotation.Autowired; | |
| 16 | -import org.springframework.jdbc.core.JdbcTemplate; | |
| 17 | -import org.springframework.jdbc.core.RowMapper; | |
| 18 | -import org.springframework.stereotype.Component; | |
| 19 | - | |
| 20 | -import java.sql.ResultSet; | |
| 21 | -import java.sql.SQLException; | |
| 22 | -import java.util.*; | |
| 23 | - | |
| 24 | -/** | |
| 25 | - * Created by panzhao on 2016/12/23. | |
| 26 | - */ | |
| 27 | -@Component | |
| 28 | -public class GeoCacheData { | |
| 29 | - | |
| 30 | - static Logger logger = LoggerFactory.getLogger(GeoCacheData.class); | |
| 31 | - | |
| 32 | - //每辆车缓存最后1000条gps | |
| 33 | - private static final int CACHE_SIZE = 1000; | |
| 34 | - private static Map<String, CircleQueue<GpsEntity>> gpsCacheMap = new HashMap<>(); | |
| 35 | - | |
| 36 | - //线路路段走向 | |
| 37 | - private static ArrayListMultimap<String, LineString> sectionCacheMap; | |
| 38 | - | |
| 39 | - //线路站点路由 | |
| 40 | - private static ArrayListMultimap<String, StationRoute> stationCacheMap; | |
| 41 | - | |
| 42 | - //线路_上下行_站点编码 ——> 站点 | |
| 43 | - private static Map<String, StationRoute> routeCodeMap; | |
| 44 | - | |
| 45 | - //停车场 | |
| 46 | - public static Map<String, Polygon> tccMap; | |
| 47 | - | |
| 48 | - @Autowired | |
| 49 | - JdbcTemplate jdbcTemplate; | |
| 50 | - | |
| 51 | - public static CircleQueue<GpsEntity> getGps(String nbbm) { | |
| 52 | - return gpsCacheMap.get(nbbm); | |
| 53 | - } | |
| 54 | - | |
| 55 | - public static void putGps(GpsEntity gps) { | |
| 56 | - CircleQueue<GpsEntity> queue = gpsCacheMap.get(gps.getNbbm()); | |
| 57 | - if (queue == null) { | |
| 58 | - /*//第一个点从站内开始 | |
| 59 | - if (gps.getInstation() == 0) | |
| 60 | - return;*/ | |
| 61 | - | |
| 62 | - queue = new CircleQueue<>(CACHE_SIZE); | |
| 63 | - gpsCacheMap.put(gps.getNbbm(), queue); | |
| 64 | - } | |
| 65 | - queue.add(gps); | |
| 66 | - } | |
| 67 | - | |
| 68 | - public static void clear(String nbbm) { | |
| 69 | - try { | |
| 70 | - CircleQueue<GpsEntity> queue = gpsCacheMap.get(nbbm); | |
| 71 | - if (queue != null) | |
| 72 | - queue.clear(); | |
| 73 | - } catch (Exception e) { | |
| 74 | - logger.error("", e); | |
| 75 | - } | |
| 76 | - } | |
| 77 | - | |
| 78 | - public static StationRoute getRouteCode(GpsEntity gps) { | |
| 79 | - return routeCodeMap.get(gps.getLineId() + "_" + gps.getUpDown() + "_" + gps.getStopNo()); | |
| 80 | - } | |
| 81 | - | |
| 82 | - public static List<StationRoute> getStationRoute(String lineCode, int directions) { | |
| 83 | - return stationCacheMap.get(lineCode + "_" + directions); | |
| 84 | - } | |
| 85 | - | |
| 86 | - public static StationRoute getStation(String lineCode, int directions, String code) { | |
| 87 | - List<StationRoute> list = getStationRoute(lineCode, directions); | |
| 88 | - | |
| 89 | - for (StationRoute sr : list) { | |
| 90 | - if (sr.getCode().equals(code)) { | |
| 91 | - return sr; | |
| 92 | - } | |
| 93 | - } | |
| 94 | - return null; | |
| 95 | - } | |
| 96 | - | |
| 97 | - public static List<StationRoute> midwayStation(String lineCode, int directions, String sCode, String eCode) { | |
| 98 | - List<StationRoute> list = getStationRoute(lineCode, directions), rs = new ArrayList<>(); | |
| 99 | - | |
| 100 | - boolean flag = false; | |
| 101 | - for (StationRoute sr : list) { | |
| 102 | - if (flag) | |
| 103 | - rs.add(sr); | |
| 104 | - if (sr.getCode().equals(sCode)) | |
| 105 | - flag = true; | |
| 106 | - else if (sr.getCode().equals(eCode)) | |
| 107 | - break; | |
| 108 | - } | |
| 109 | - return rs; | |
| 110 | - } | |
| 111 | - | |
| 112 | - public static Polygon getTccPolygon(String code) { | |
| 113 | - return tccMap.get(code); | |
| 114 | - } | |
| 115 | - | |
| 116 | - public void loadData() { | |
| 117 | - final GeometryFactory geometryFactory = new GeometryFactory(); | |
| 118 | - //加载站点路由 | |
| 119 | - String sql = "select r.LINE_CODE,r.DIRECTIONS,r.STATION_CODE,r.STATION_MARK,s.SHAPES_TYPE,s.G_LONX,s.G_LATY,ST_AsText(s.G_POLYGON_GRID) as G_POLYGON_GRID,s.RADIUS, r.STATION_ROUTE_CODE,s.STATION_NAME from bsth_c_stationroute r left join bsth_c_station s on r.station=s.id where r.destroy=0 order by r.station_route_code"; | |
| 120 | - List<StationRoute> routeList = jdbcTemplate.query(sql, new RowMapper<StationRoute>() { | |
| 121 | - @Override | |
| 122 | - public StationRoute mapRow(ResultSet rs, int rowNum) throws SQLException { | |
| 123 | - StationRoute sRoute = new StationRoute(); | |
| 124 | - sRoute.setCode(rs.getString("STATION_CODE")); | |
| 125 | - sRoute.setLineCode(rs.getString("LINE_CODE")); | |
| 126 | - sRoute.setDirections(rs.getInt("DIRECTIONS")); | |
| 127 | - sRoute.setPoint(geometryFactory.createPoint(new Coordinate(rs.getFloat("G_LATY"), rs.getFloat("G_LONX")))); | |
| 128 | - sRoute.setRadius(rs.getFloat("RADIUS")); | |
| 129 | - sRoute.setRouteSort(rs.getInt("STATION_ROUTE_CODE")); | |
| 130 | - sRoute.setMark(rs.getString("STATION_MARK")); | |
| 131 | - sRoute.setName(rs.getString("STATION_NAME")); | |
| 132 | - | |
| 133 | - String shapesType = rs.getString("SHAPES_TYPE"); | |
| 134 | - //多边形电子围栏 | |
| 135 | - if (StringUtils.isNotEmpty(shapesType) && shapesType.equals("d")) { | |
| 136 | - sRoute.setPolygon(geometryFactory.createPolygon(parsePolygon(rs.getString("G_POLYGON_GRID")))); | |
| 137 | - } | |
| 138 | - return sRoute; | |
| 139 | - } | |
| 140 | - }); | |
| 141 | - //按线路和走向分组 | |
| 142 | - if (routeList.size() > 0) { | |
| 143 | - ArrayListMultimap<String, StationRoute> tempMap = ArrayListMultimap.create(); | |
| 144 | - Map<String, StationRoute> codeMap = new HashMap<>(routeList.size()); | |
| 145 | - for (StationRoute sr : routeList) { | |
| 146 | - tempMap.put(sr.getLineCode() + "_" + sr.getDirections(), sr); | |
| 147 | - //站点编码 ——> 和路由顺序对照 | |
| 148 | - codeMap.put(sr.getLineCode() + "_" + sr.getDirections() + "_" + sr.getCode(), sr); | |
| 149 | - } | |
| 150 | - | |
| 151 | - StationRouteComp srCom = new StationRouteComp(); | |
| 152 | - //连接路由 | |
| 153 | - Set<String> set = tempMap.keySet(); | |
| 154 | - for (String key : set) { | |
| 155 | - Collections.sort(tempMap.get(key), srCom); | |
| 156 | - connectStationRoute(tempMap.get(key)); | |
| 157 | - } | |
| 158 | - | |
| 159 | - stationCacheMap = tempMap; | |
| 160 | - routeCodeMap = codeMap; | |
| 161 | - } | |
| 162 | - | |
| 163 | - //加载停车场数据 | |
| 164 | - sql = "select PARK_CODE, ST_AsText(G_PARK_POINT) as G_PARK_POINT from bsth_c_car_park where park_code is not null and b_park_point is not null"; | |
| 165 | - List<Map<String, Object>> tccList = jdbcTemplate.queryForList(sql); | |
| 166 | - Map<String, Polygon> tccTempMap = new HashMap<>(); | |
| 167 | - | |
| 168 | - Polygon polygon; | |
| 169 | - for (Map<String, Object> tMap : tccList) { | |
| 170 | - | |
| 171 | - try { | |
| 172 | - polygon = geometryFactory.createPolygon(parsePolygon(tMap.get("G_PARK_POINT").toString())); | |
| 173 | - tccTempMap.put(tMap.get("PARK_CODE").toString() | |
| 174 | - , polygon); | |
| 175 | - } catch (Exception e) { | |
| 176 | - logger.error("停车场:" + tMap.get("PARK_CODE"), e); | |
| 177 | - } | |
| 178 | - } | |
| 179 | - | |
| 180 | - if (tccTempMap.size() > 0) | |
| 181 | - tccMap = tccTempMap; | |
| 182 | - } | |
| 183 | - | |
| 184 | - private void connectStationRoute(List<StationRoute> list) { | |
| 185 | - int size = list.size(); | |
| 186 | - StationRoute sr = null; | |
| 187 | - for (int i = 0; i < size; i++) { | |
| 188 | - sr = list.get(i); | |
| 189 | - //上一个 | |
| 190 | - if (i > 0) | |
| 191 | - sr.setPrve(list.get(i - 1)); | |
| 192 | - //下一个 | |
| 193 | - if (i < size - 1) | |
| 194 | - sr.setNext(list.get(i + 1)); | |
| 195 | - } | |
| 196 | - } | |
| 197 | - | |
| 198 | - public Coordinate[] parsePolygon(String polygonStr) { | |
| 199 | - String[] coords = polygonStr.substring(9, polygonStr.length() - 2).split(","), temps; | |
| 200 | - | |
| 201 | - Coordinate[] cds = new Coordinate[coords.length]; | |
| 202 | - int len = coords.length; | |
| 203 | - for (int i = 0; i < len; i++) { | |
| 204 | - temps = coords[i].split(" "); | |
| 205 | - cds[i] = new Coordinate(Float.parseFloat(temps[1]), Float.parseFloat(temps[0])); | |
| 206 | - } | |
| 207 | - return cds; | |
| 208 | - } | |
| 209 | - | |
| 210 | - /** | |
| 211 | - * 是不是终点站 | |
| 212 | - * @param lineId | |
| 213 | - * @param upDown | |
| 214 | - * @param stationCode | |
| 215 | - * @return | |
| 216 | - */ | |
| 217 | - public static boolean isEndStation(String lineId, Integer upDown, String stationCode) { | |
| 218 | - StationRoute station = routeCodeMap.get(lineId + "_" + upDown + "_" + stationCode); | |
| 219 | - return station != null && station.getMark().equals("E"); | |
| 220 | - } | |
| 1 | +package com.bsth.data.gpsdata.arrival; | |
| 2 | + | |
| 3 | +import com.bsth.data.gpsdata.GpsEntity; | |
| 4 | +import com.bsth.data.gpsdata.arrival.entity.StationRoute; | |
| 5 | +import com.bsth.data.gpsdata.arrival.utils.CircleQueue; | |
| 6 | +import com.bsth.data.gpsdata.arrival.utils.StationRouteComp; | |
| 7 | +import com.google.common.collect.ArrayListMultimap; | |
| 8 | +import com.vividsolutions.jts.geom.Coordinate; | |
| 9 | +import com.vividsolutions.jts.geom.GeometryFactory; | |
| 10 | +import com.vividsolutions.jts.geom.LineString; | |
| 11 | +import com.vividsolutions.jts.geom.Polygon; | |
| 12 | +import org.apache.commons.lang3.StringUtils; | |
| 13 | +import org.slf4j.Logger; | |
| 14 | +import org.slf4j.LoggerFactory; | |
| 15 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 16 | +import org.springframework.jdbc.core.JdbcTemplate; | |
| 17 | +import org.springframework.jdbc.core.RowMapper; | |
| 18 | +import org.springframework.stereotype.Component; | |
| 19 | + | |
| 20 | +import java.sql.ResultSet; | |
| 21 | +import java.sql.SQLException; | |
| 22 | +import java.util.*; | |
| 23 | + | |
| 24 | +/** | |
| 25 | + * Created by panzhao on 2016/12/23. | |
| 26 | + */ | |
| 27 | +@Component | |
| 28 | +public class GeoCacheData { | |
| 29 | + | |
| 30 | + static Logger logger = LoggerFactory.getLogger(GeoCacheData.class); | |
| 31 | + | |
| 32 | + //每辆车缓存最后1000条gps | |
| 33 | + private static final int CACHE_SIZE = 1000; | |
| 34 | + private static Map<String, CircleQueue<GpsEntity>> gpsCacheMap = new HashMap<>(); | |
| 35 | + | |
| 36 | + //线路路段走向 | |
| 37 | + private static ArrayListMultimap<String, LineString> sectionCacheMap; | |
| 38 | + | |
| 39 | + //线路站点路由 | |
| 40 | + private static ArrayListMultimap<String, StationRoute> stationCacheMap; | |
| 41 | + | |
| 42 | + //线路_上下行_站点编码 ——> 站点 | |
| 43 | + private static Map<String, StationRoute> routeCodeMap; | |
| 44 | + | |
| 45 | + //停车场 | |
| 46 | + public static Map<String, Polygon> tccMap; | |
| 47 | + | |
| 48 | + @Autowired | |
| 49 | + JdbcTemplate jdbcTemplate; | |
| 50 | + | |
| 51 | + public static CircleQueue<GpsEntity> getGps(String nbbm) { | |
| 52 | + return gpsCacheMap.get(nbbm); | |
| 53 | + } | |
| 54 | + | |
| 55 | + public static void putGps(GpsEntity gps) { | |
| 56 | + CircleQueue<GpsEntity> queue = gpsCacheMap.get(gps.getNbbm()); | |
| 57 | + if (queue == null) { | |
| 58 | + /*//第一个点从站内开始 | |
| 59 | + if (gps.getInstation() == 0) | |
| 60 | + return;*/ | |
| 61 | + | |
| 62 | + queue = new CircleQueue<>(CACHE_SIZE); | |
| 63 | + gpsCacheMap.put(gps.getNbbm(), queue); | |
| 64 | + } | |
| 65 | + queue.add(gps); | |
| 66 | + } | |
| 67 | + | |
| 68 | + public static void clear(String nbbm) { | |
| 69 | + try { | |
| 70 | + CircleQueue<GpsEntity> queue = gpsCacheMap.get(nbbm); | |
| 71 | + if (queue != null) | |
| 72 | + queue.clear(); | |
| 73 | + } catch (Exception e) { | |
| 74 | + logger.error("", e); | |
| 75 | + } | |
| 76 | + } | |
| 77 | + | |
| 78 | + public static StationRoute getRouteCode(GpsEntity gps) { | |
| 79 | + return routeCodeMap.get(gps.getLineId() + "_" + gps.getUpDown() + "_" + gps.getStopNo()); | |
| 80 | + } | |
| 81 | + | |
| 82 | + public static List<StationRoute> getStationRoute(String lineCode, int directions) { | |
| 83 | + return stationCacheMap.get(lineCode + "_" + directions); | |
| 84 | + } | |
| 85 | + | |
| 86 | + public static StationRoute getStation(String lineCode, int directions, String code) { | |
| 87 | + List<StationRoute> list = getStationRoute(lineCode, directions); | |
| 88 | + | |
| 89 | + for (StationRoute sr : list) { | |
| 90 | + if (sr.getCode().equals(code)) { | |
| 91 | + return sr; | |
| 92 | + } | |
| 93 | + } | |
| 94 | + return null; | |
| 95 | + } | |
| 96 | + | |
| 97 | + public static List<StationRoute> midwayStation(String lineCode, int directions, String sCode, String eCode) { | |
| 98 | + List<StationRoute> list = getStationRoute(lineCode, directions), rs = new ArrayList<>(); | |
| 99 | + | |
| 100 | + boolean flag = false; | |
| 101 | + for (StationRoute sr : list) { | |
| 102 | + if (flag) | |
| 103 | + rs.add(sr); | |
| 104 | + if (sr.getCode().equals(sCode)) | |
| 105 | + flag = true; | |
| 106 | + else if (sr.getCode().equals(eCode)) | |
| 107 | + break; | |
| 108 | + } | |
| 109 | + return rs; | |
| 110 | + } | |
| 111 | + | |
| 112 | + public static Polygon getTccPolygon(String code) { | |
| 113 | + return tccMap.get(code); | |
| 114 | + } | |
| 115 | + | |
| 116 | + public void loadData() { | |
| 117 | + final GeometryFactory geometryFactory = new GeometryFactory(); | |
| 118 | + //加载站点路由 | |
| 119 | + String sql = "select r.LINE_CODE,r.DIRECTIONS,r.STATION_CODE,r.STATION_MARK,s.SHAPES_TYPE,s.G_LONX,s.G_LATY,ST_AsText(s.G_POLYGON_GRID) as G_POLYGON_GRID,s.RADIUS, r.STATION_ROUTE_CODE,s.STATION_NAME from bsth_c_stationroute r left join bsth_c_station s on r.station=s.id where r.destroy=0 order by r.station_route_code"; | |
| 120 | + List<StationRoute> routeList = jdbcTemplate.query(sql, new RowMapper<StationRoute>() { | |
| 121 | + @Override | |
| 122 | + public StationRoute mapRow(ResultSet rs, int rowNum) throws SQLException { | |
| 123 | + StationRoute sRoute = new StationRoute(); | |
| 124 | + sRoute.setCode(rs.getString("STATION_CODE")); | |
| 125 | + sRoute.setLineCode(rs.getString("LINE_CODE")); | |
| 126 | + sRoute.setDirections(rs.getInt("DIRECTIONS")); | |
| 127 | + sRoute.setPoint(geometryFactory.createPoint(new Coordinate(rs.getFloat("G_LATY"), rs.getFloat("G_LONX")))); | |
| 128 | + sRoute.setRadius(rs.getFloat("RADIUS")); | |
| 129 | + sRoute.setRouteSort(rs.getInt("STATION_ROUTE_CODE")); | |
| 130 | + sRoute.setMark(rs.getString("STATION_MARK")); | |
| 131 | + sRoute.setName(rs.getString("STATION_NAME")); | |
| 132 | + | |
| 133 | + String shapesType = rs.getString("SHAPES_TYPE"); | |
| 134 | + //多边形电子围栏 | |
| 135 | + if (StringUtils.isNotEmpty(shapesType) && shapesType.equals("d")) { | |
| 136 | + sRoute.setPolygon(geometryFactory.createPolygon(parsePolygon(rs.getString("G_POLYGON_GRID")))); | |
| 137 | + } | |
| 138 | + return sRoute; | |
| 139 | + } | |
| 140 | + }); | |
| 141 | + //按线路和走向分组 | |
| 142 | + if (routeList.size() > 0) { | |
| 143 | + ArrayListMultimap<String, StationRoute> tempMap = ArrayListMultimap.create(); | |
| 144 | + Map<String, StationRoute> codeMap = new HashMap<>(routeList.size()); | |
| 145 | + for (StationRoute sr : routeList) { | |
| 146 | + tempMap.put(sr.getLineCode() + "_" + sr.getDirections(), sr); | |
| 147 | + //站点编码 ——> 和路由顺序对照 | |
| 148 | + codeMap.put(sr.getLineCode() + "_" + sr.getDirections() + "_" + sr.getCode(), sr); | |
| 149 | + } | |
| 150 | + | |
| 151 | + StationRouteComp srCom = new StationRouteComp(); | |
| 152 | + //连接路由 | |
| 153 | + Set<String> set = tempMap.keySet(); | |
| 154 | + for (String key : set) { | |
| 155 | + Collections.sort(tempMap.get(key), srCom); | |
| 156 | + connectStationRoute(tempMap.get(key)); | |
| 157 | + } | |
| 158 | + | |
| 159 | + stationCacheMap = tempMap; | |
| 160 | + routeCodeMap = codeMap; | |
| 161 | + } | |
| 162 | + | |
| 163 | + //加载停车场数据 | |
| 164 | + sql = "select PARK_CODE, ST_AsText(G_PARK_POINT) as G_PARK_POINT from bsth_c_car_park where park_code is not null and b_park_point is not null"; | |
| 165 | + List<Map<String, Object>> tccList = jdbcTemplate.queryForList(sql); | |
| 166 | + Map<String, Polygon> tccTempMap = new HashMap<>(); | |
| 167 | + | |
| 168 | + Polygon polygon; | |
| 169 | + for (Map<String, Object> tMap : tccList) { | |
| 170 | + | |
| 171 | + try { | |
| 172 | + polygon = geometryFactory.createPolygon(parsePolygon(tMap.get("G_PARK_POINT").toString())); | |
| 173 | + tccTempMap.put(tMap.get("PARK_CODE").toString() | |
| 174 | + , polygon); | |
| 175 | + } catch (Exception e) { | |
| 176 | + logger.error("停车场:" + tMap.get("PARK_CODE"), e); | |
| 177 | + } | |
| 178 | + } | |
| 179 | + | |
| 180 | + if (tccTempMap.size() > 0) | |
| 181 | + tccMap = tccTempMap; | |
| 182 | + } | |
| 183 | + | |
| 184 | + private void connectStationRoute(List<StationRoute> list) { | |
| 185 | + int size = list.size(); | |
| 186 | + StationRoute sr = null; | |
| 187 | + for (int i = 0; i < size; i++) { | |
| 188 | + sr = list.get(i); | |
| 189 | + //上一个 | |
| 190 | + if (i > 0) | |
| 191 | + sr.setPrve(list.get(i - 1)); | |
| 192 | + //下一个 | |
| 193 | + if (i < size - 1) | |
| 194 | + sr.setNext(list.get(i + 1)); | |
| 195 | + } | |
| 196 | + } | |
| 197 | + | |
| 198 | + public Coordinate[] parsePolygon(String polygonStr) { | |
| 199 | + String[] coords = polygonStr.substring(9, polygonStr.length() - 2).split(","), temps; | |
| 200 | + | |
| 201 | + Coordinate[] cds = new Coordinate[coords.length]; | |
| 202 | + int len = coords.length; | |
| 203 | + for (int i = 0; i < len; i++) { | |
| 204 | + temps = coords[i].split(" "); | |
| 205 | + cds[i] = new Coordinate(Float.parseFloat(temps[1]), Float.parseFloat(temps[0])); | |
| 206 | + } | |
| 207 | + return cds; | |
| 208 | + } | |
| 209 | + | |
| 210 | + /** | |
| 211 | + * 是不是终点站 | |
| 212 | + * @param lineId | |
| 213 | + * @param upDown | |
| 214 | + * @param stationCode | |
| 215 | + * @return | |
| 216 | + */ | |
| 217 | + public static boolean isEndStation(String lineId, Integer upDown, String stationCode) { | |
| 218 | + StationRoute station = routeCodeMap.get(lineId + "_" + upDown + "_" + stationCode); | |
| 219 | + return station != null && station.getMark().equals("E"); | |
| 220 | + } | |
| 221 | 221 | } |
| 222 | 222 | \ No newline at end of file | ... | ... |
src/main/java/com/bsth/data/gpsdata/arrival/SignalHandle.java
| 1 | -package com.bsth.data.gpsdata.arrival; | |
| 2 | - | |
| 3 | -import com.bsth.data.gpsdata.GpsEntity; | |
| 4 | -import com.bsth.data.gpsdata.arrival.entity.StationRoute; | |
| 5 | -import com.bsth.data.gpsdata.arrival.utils.CircleQueue; | |
| 6 | -import com.bsth.data.gpsdata.arrival.utils.GeoUtils; | |
| 7 | -import com.bsth.entity.realcontrol.ScheduleRealInfo; | |
| 8 | - | |
| 9 | -import java.util.List; | |
| 10 | - | |
| 11 | -/** | |
| 12 | - * Created by panzhao on 2016/12/27. | |
| 13 | - */ | |
| 14 | -public abstract class SignalHandle { | |
| 15 | - | |
| 16 | - public abstract boolean handle(GpsEntity gps, CircleQueue<GpsEntity> prevs); | |
| 17 | - | |
| 18 | - protected boolean isNotEmpty(CircleQueue<GpsEntity> prevs) { | |
| 19 | - return prevs != null && prevs.size() > 0 && prevs.getTail() != null; | |
| 20 | - } | |
| 21 | - | |
| 22 | - protected boolean isDriftSignal(GpsEntity gps) { | |
| 23 | - return gps.getLat() == 0 || gps.getLon() == 0; | |
| 24 | - } | |
| 25 | - | |
| 26 | - /** | |
| 27 | - * 是不是异常信号 | |
| 28 | - * | |
| 29 | - * @param gps | |
| 30 | - * @return protected boolean isAbnormal(GpsEntity gps) { | |
| 31 | - return gps.getLat() == 0 || gps.getLon() == 0; | |
| 32 | - }*/ | |
| 33 | - | |
| 34 | - /** | |
| 35 | - * 连续异常信号个数统计 | |
| 36 | - * | |
| 37 | - * @param prevs | |
| 38 | - * @return protected int abnormalCount(CircleQueue<GpsEntity> prevs) { | |
| 39 | - * int count = 0; | |
| 40 | - * <p> | |
| 41 | - * if (!isNotEmpty(prevs)) | |
| 42 | - * return count; | |
| 43 | - * <p> | |
| 44 | - * GpsEntity[] array = (GpsEntity[]) prevs.getQueue(); | |
| 45 | - * GpsEntity gps; | |
| 46 | - * for (int i = array.length - 1; i > 0; i--) { | |
| 47 | - * gps = array[i]; | |
| 48 | - * <p> | |
| 49 | - * if (isAbnormal(gps)) | |
| 50 | - * count++; | |
| 51 | - * else | |
| 52 | - * break; | |
| 53 | - * } | |
| 54 | - * <p> | |
| 55 | - * return count; | |
| 56 | - * } | |
| 57 | - */ | |
| 58 | - | |
| 59 | - protected void transformUpdown(GpsEntity gps, ScheduleRealInfo sch) { | |
| 60 | - int updown = Integer.parseInt(sch.getXlDir()); | |
| 61 | - List<StationRoute> srs = GeoCacheData.getStationRoute(sch.getXlBm(), updown); | |
| 62 | - StationRoute station = GeoUtils.gpsInStation(gps, srs); | |
| 63 | - if (station != null) { | |
| 64 | - gps.setUpDown(updown); | |
| 65 | - gps.setStopNo(station.getCode()); | |
| 66 | - } | |
| 67 | - } | |
| 68 | - | |
| 69 | - /** | |
| 70 | - * 是否是从异常状态恢复的第一个信号 | |
| 71 | - * | |
| 72 | - * @param gps | |
| 73 | - * @param prevs | |
| 74 | - * @return | |
| 75 | - */ | |
| 76 | - protected boolean abnormalRecovery(GpsEntity gps, CircleQueue<GpsEntity> prevs) { | |
| 77 | - if (prevs == null || prevs.size() == 0) | |
| 78 | - return false; | |
| 79 | - | |
| 80 | - GpsEntity prev = prevs.getTail(); | |
| 81 | - //从漂移状态恢复 | |
| 82 | - if (isDriftSignal(prev) | |
| 83 | - && !isDriftSignal(gps)) { | |
| 84 | - return true; | |
| 85 | - } | |
| 86 | - | |
| 87 | - return false; | |
| 88 | - } | |
| 1 | +package com.bsth.data.gpsdata.arrival; | |
| 2 | + | |
| 3 | +import com.bsth.data.gpsdata.GpsEntity; | |
| 4 | +import com.bsth.data.gpsdata.arrival.entity.StationRoute; | |
| 5 | +import com.bsth.data.gpsdata.arrival.utils.CircleQueue; | |
| 6 | +import com.bsth.data.gpsdata.arrival.utils.GeoUtils; | |
| 7 | +import com.bsth.entity.realcontrol.ScheduleRealInfo; | |
| 8 | + | |
| 9 | +import java.util.List; | |
| 10 | + | |
| 11 | +/** | |
| 12 | + * Created by panzhao on 2016/12/27. | |
| 13 | + */ | |
| 14 | +public abstract class SignalHandle { | |
| 15 | + | |
| 16 | + public abstract boolean handle(GpsEntity gps, CircleQueue<GpsEntity> prevs); | |
| 17 | + | |
| 18 | + protected boolean isNotEmpty(CircleQueue<GpsEntity> prevs) { | |
| 19 | + return prevs != null && prevs.size() > 0 && prevs.getTail() != null; | |
| 20 | + } | |
| 21 | + | |
| 22 | + protected boolean isDriftSignal(GpsEntity gps) { | |
| 23 | + return gps.getLat() == 0 || gps.getLon() == 0; | |
| 24 | + } | |
| 25 | + | |
| 26 | + /** | |
| 27 | + * 是不是异常信号 | |
| 28 | + * | |
| 29 | + * @param gps | |
| 30 | + * @return protected boolean isAbnormal(GpsEntity gps) { | |
| 31 | + return gps.getLat() == 0 || gps.getLon() == 0; | |
| 32 | + }*/ | |
| 33 | + | |
| 34 | + /** | |
| 35 | + * 连续异常信号个数统计 | |
| 36 | + * | |
| 37 | + * @param prevs | |
| 38 | + * @return protected int abnormalCount(CircleQueue<GpsEntity> prevs) { | |
| 39 | + * int count = 0; | |
| 40 | + * <p> | |
| 41 | + * if (!isNotEmpty(prevs)) | |
| 42 | + * return count; | |
| 43 | + * <p> | |
| 44 | + * GpsEntity[] array = (GpsEntity[]) prevs.getQueue(); | |
| 45 | + * GpsEntity gps; | |
| 46 | + * for (int i = array.length - 1; i > 0; i--) { | |
| 47 | + * gps = array[i]; | |
| 48 | + * <p> | |
| 49 | + * if (isAbnormal(gps)) | |
| 50 | + * count++; | |
| 51 | + * else | |
| 52 | + * break; | |
| 53 | + * } | |
| 54 | + * <p> | |
| 55 | + * return count; | |
| 56 | + * } | |
| 57 | + */ | |
| 58 | + | |
| 59 | + protected void transformUpdown(GpsEntity gps, ScheduleRealInfo sch) { | |
| 60 | + int updown = Integer.parseInt(sch.getXlDir()); | |
| 61 | + List<StationRoute> srs = GeoCacheData.getStationRoute(sch.getXlBm(), updown); | |
| 62 | + StationRoute station = GeoUtils.gpsInStation(gps, srs); | |
| 63 | + if (station != null) { | |
| 64 | + gps.setUpDown(updown); | |
| 65 | + gps.setStopNo(station.getCode()); | |
| 66 | + } | |
| 67 | + } | |
| 68 | + | |
| 69 | + /** | |
| 70 | + * 是否是从异常状态恢复的第一个信号 | |
| 71 | + * | |
| 72 | + * @param gps | |
| 73 | + * @param prevs | |
| 74 | + * @return | |
| 75 | + */ | |
| 76 | + protected boolean abnormalRecovery(GpsEntity gps, CircleQueue<GpsEntity> prevs) { | |
| 77 | + if (prevs == null || prevs.size() == 0) | |
| 78 | + return false; | |
| 79 | + | |
| 80 | + GpsEntity prev = prevs.getTail(); | |
| 81 | + //从漂移状态恢复 | |
| 82 | + if (isDriftSignal(prev) | |
| 83 | + && !isDriftSignal(gps)) { | |
| 84 | + return true; | |
| 85 | + } | |
| 86 | + | |
| 87 | + return false; | |
| 88 | + } | |
| 89 | 89 | } |
| 90 | 90 | \ No newline at end of file | ... | ... |
src/main/java/com/bsth/data/gpsdata/arrival/entity/RouteReverse.java
| 1 | -package com.bsth.data.gpsdata.arrival.entity; | |
| 2 | - | |
| 3 | -/** 路由反转 | |
| 4 | - * Created by panzhao on 2016/12/28. | |
| 5 | - */ | |
| 6 | -public class RouteReverse { | |
| 7 | - | |
| 8 | - private String nbbm; | |
| 9 | - //反转个数 | |
| 10 | - private int count; | |
| 11 | - | |
| 12 | - //详细 1,2,3,2,1 | |
| 13 | - private String detail; | |
| 14 | - | |
| 15 | - //掉头站点 | |
| 16 | - private String turned; | |
| 17 | - | |
| 18 | - //掉头时间 | |
| 19 | - private long zt; | |
| 20 | - | |
| 21 | - //检测时间 | |
| 22 | - private long ct; | |
| 23 | - | |
| 24 | - //是否闭合 | |
| 25 | - private boolean close; | |
| 26 | - | |
| 27 | - //信号不明确 | |
| 28 | - private boolean vague; | |
| 29 | - | |
| 30 | - public int getCount() { | |
| 31 | - return count; | |
| 32 | - } | |
| 33 | - | |
| 34 | - public void setCount(int count) { | |
| 35 | - this.count = count; | |
| 36 | - } | |
| 37 | - | |
| 38 | - public String getDetail() { | |
| 39 | - return detail; | |
| 40 | - } | |
| 41 | - | |
| 42 | - public void setDetail(String detail) { | |
| 43 | - this.detail = detail; | |
| 44 | - } | |
| 45 | - | |
| 46 | - public String getTurned() { | |
| 47 | - return turned; | |
| 48 | - } | |
| 49 | - | |
| 50 | - public void setTurned(String turned) { | |
| 51 | - this.turned = turned; | |
| 52 | - } | |
| 53 | - | |
| 54 | - public boolean isClose() { | |
| 55 | - return close; | |
| 56 | - } | |
| 57 | - | |
| 58 | - public void setClose(boolean close) { | |
| 59 | - this.close = close; | |
| 60 | - } | |
| 61 | - | |
| 62 | - public long getZt() { | |
| 63 | - return zt; | |
| 64 | - } | |
| 65 | - | |
| 66 | - public void setZt(long zt) { | |
| 67 | - this.zt = zt; | |
| 68 | - } | |
| 69 | - | |
| 70 | - public long getCt() { | |
| 71 | - return ct; | |
| 72 | - } | |
| 73 | - | |
| 74 | - public void setCt(long ct) { | |
| 75 | - this.ct = ct; | |
| 76 | - } | |
| 77 | - | |
| 78 | - public String getNbbm() { | |
| 79 | - return nbbm; | |
| 80 | - } | |
| 81 | - | |
| 82 | - public void setNbbm(String nbbm) { | |
| 83 | - this.nbbm = nbbm; | |
| 84 | - } | |
| 85 | - | |
| 86 | - public boolean isVague() { | |
| 87 | - return vague; | |
| 88 | - } | |
| 89 | - | |
| 90 | - public void setVague(boolean vague) { | |
| 91 | - this.vague = vague; | |
| 92 | - } | |
| 1 | +package com.bsth.data.gpsdata.arrival.entity; | |
| 2 | + | |
| 3 | +/** 路由反转 | |
| 4 | + * Created by panzhao on 2016/12/28. | |
| 5 | + */ | |
| 6 | +public class RouteReverse { | |
| 7 | + | |
| 8 | + private String nbbm; | |
| 9 | + //反转个数 | |
| 10 | + private int count; | |
| 11 | + | |
| 12 | + //详细 1,2,3,2,1 | |
| 13 | + private String detail; | |
| 14 | + | |
| 15 | + //掉头站点 | |
| 16 | + private String turned; | |
| 17 | + | |
| 18 | + //掉头时间 | |
| 19 | + private long zt; | |
| 20 | + | |
| 21 | + //检测时间 | |
| 22 | + private long ct; | |
| 23 | + | |
| 24 | + //是否闭合 | |
| 25 | + private boolean close; | |
| 26 | + | |
| 27 | + //信号不明确 | |
| 28 | + private boolean vague; | |
| 29 | + | |
| 30 | + public int getCount() { | |
| 31 | + return count; | |
| 32 | + } | |
| 33 | + | |
| 34 | + public void setCount(int count) { | |
| 35 | + this.count = count; | |
| 36 | + } | |
| 37 | + | |
| 38 | + public String getDetail() { | |
| 39 | + return detail; | |
| 40 | + } | |
| 41 | + | |
| 42 | + public void setDetail(String detail) { | |
| 43 | + this.detail = detail; | |
| 44 | + } | |
| 45 | + | |
| 46 | + public String getTurned() { | |
| 47 | + return turned; | |
| 48 | + } | |
| 49 | + | |
| 50 | + public void setTurned(String turned) { | |
| 51 | + this.turned = turned; | |
| 52 | + } | |
| 53 | + | |
| 54 | + public boolean isClose() { | |
| 55 | + return close; | |
| 56 | + } | |
| 57 | + | |
| 58 | + public void setClose(boolean close) { | |
| 59 | + this.close = close; | |
| 60 | + } | |
| 61 | + | |
| 62 | + public long getZt() { | |
| 63 | + return zt; | |
| 64 | + } | |
| 65 | + | |
| 66 | + public void setZt(long zt) { | |
| 67 | + this.zt = zt; | |
| 68 | + } | |
| 69 | + | |
| 70 | + public long getCt() { | |
| 71 | + return ct; | |
| 72 | + } | |
| 73 | + | |
| 74 | + public void setCt(long ct) { | |
| 75 | + this.ct = ct; | |
| 76 | + } | |
| 77 | + | |
| 78 | + public String getNbbm() { | |
| 79 | + return nbbm; | |
| 80 | + } | |
| 81 | + | |
| 82 | + public void setNbbm(String nbbm) { | |
| 83 | + this.nbbm = nbbm; | |
| 84 | + } | |
| 85 | + | |
| 86 | + public boolean isVague() { | |
| 87 | + return vague; | |
| 88 | + } | |
| 89 | + | |
| 90 | + public void setVague(boolean vague) { | |
| 91 | + this.vague = vague; | |
| 92 | + } | |
| 93 | 93 | } |
| 94 | 94 | \ No newline at end of file | ... | ... |
src/main/java/com/bsth/data/gpsdata/arrival/entity/SignalAbnormal.java
| 1 | -package com.bsth.data.gpsdata.arrival.entity; | |
| 2 | - | |
| 3 | -/** | |
| 4 | - * 班次信号异常(漂移 或 断线) | |
| 5 | - * Created by panzhao on 2016/12/31. | |
| 6 | - */ | |
| 7 | -public class SignalAbnormal { | |
| 8 | - | |
| 9 | - private Long et; | |
| 10 | - | |
| 11 | - /** drift or reconnection */ | |
| 12 | - private String abnormalType; | |
| 13 | - | |
| 14 | - private Long st; | |
| 15 | - | |
| 16 | - private String nearPoint; | |
| 17 | - | |
| 18 | - private String destCode; | |
| 19 | - | |
| 20 | - private Long ct; | |
| 21 | - | |
| 22 | - //0: 发车 1:到站 | |
| 23 | - private int outOrIn; | |
| 24 | - | |
| 25 | - public Long getEt() { | |
| 26 | - return et; | |
| 27 | - } | |
| 28 | - | |
| 29 | - public void setEt(Long et) { | |
| 30 | - this.et = et; | |
| 31 | - } | |
| 32 | - | |
| 33 | - public String getAbnormalType() { | |
| 34 | - return abnormalType; | |
| 35 | - } | |
| 36 | - | |
| 37 | - public void setAbnormalType(String abnormalType) { | |
| 38 | - this.abnormalType = abnormalType; | |
| 39 | - } | |
| 40 | - | |
| 41 | - public Long getSt() { | |
| 42 | - return st; | |
| 43 | - } | |
| 44 | - | |
| 45 | - public void setSt(Long st) { | |
| 46 | - this.st = st; | |
| 47 | - } | |
| 48 | - | |
| 49 | - public String getNearPoint() { | |
| 50 | - return nearPoint; | |
| 51 | - } | |
| 52 | - | |
| 53 | - public void setNearPoint(String nearPoint) { | |
| 54 | - this.nearPoint = nearPoint; | |
| 55 | - } | |
| 56 | - | |
| 57 | - public Long getCt() { | |
| 58 | - return ct; | |
| 59 | - } | |
| 60 | - | |
| 61 | - public void setCt(Long ct) { | |
| 62 | - this.ct = ct; | |
| 63 | - } | |
| 64 | - | |
| 65 | - public int getOutOrIn() { | |
| 66 | - return outOrIn; | |
| 67 | - } | |
| 68 | - | |
| 69 | - public void setOutOrIn(int outOrIn) { | |
| 70 | - this.outOrIn = outOrIn; | |
| 71 | - } | |
| 72 | - | |
| 73 | - public String getDestCode() { | |
| 74 | - return destCode; | |
| 75 | - } | |
| 76 | - | |
| 77 | - public void setDestCode(String destCode) { | |
| 78 | - this.destCode = destCode; | |
| 79 | - } | |
| 80 | -} | |
| 1 | +package com.bsth.data.gpsdata.arrival.entity; | |
| 2 | + | |
| 3 | +/** | |
| 4 | + * 班次信号异常(漂移 或 断线) | |
| 5 | + * Created by panzhao on 2016/12/31. | |
| 6 | + */ | |
| 7 | +public class SignalAbnormal { | |
| 8 | + | |
| 9 | + private Long et; | |
| 10 | + | |
| 11 | + /** drift or reconnection */ | |
| 12 | + private String abnormalType; | |
| 13 | + | |
| 14 | + private Long st; | |
| 15 | + | |
| 16 | + private String nearPoint; | |
| 17 | + | |
| 18 | + private String destCode; | |
| 19 | + | |
| 20 | + private Long ct; | |
| 21 | + | |
| 22 | + //0: 发车 1:到站 | |
| 23 | + private int outOrIn; | |
| 24 | + | |
| 25 | + public Long getEt() { | |
| 26 | + return et; | |
| 27 | + } | |
| 28 | + | |
| 29 | + public void setEt(Long et) { | |
| 30 | + this.et = et; | |
| 31 | + } | |
| 32 | + | |
| 33 | + public String getAbnormalType() { | |
| 34 | + return abnormalType; | |
| 35 | + } | |
| 36 | + | |
| 37 | + public void setAbnormalType(String abnormalType) { | |
| 38 | + this.abnormalType = abnormalType; | |
| 39 | + } | |
| 40 | + | |
| 41 | + public Long getSt() { | |
| 42 | + return st; | |
| 43 | + } | |
| 44 | + | |
| 45 | + public void setSt(Long st) { | |
| 46 | + this.st = st; | |
| 47 | + } | |
| 48 | + | |
| 49 | + public String getNearPoint() { | |
| 50 | + return nearPoint; | |
| 51 | + } | |
| 52 | + | |
| 53 | + public void setNearPoint(String nearPoint) { | |
| 54 | + this.nearPoint = nearPoint; | |
| 55 | + } | |
| 56 | + | |
| 57 | + public Long getCt() { | |
| 58 | + return ct; | |
| 59 | + } | |
| 60 | + | |
| 61 | + public void setCt(Long ct) { | |
| 62 | + this.ct = ct; | |
| 63 | + } | |
| 64 | + | |
| 65 | + public int getOutOrIn() { | |
| 66 | + return outOrIn; | |
| 67 | + } | |
| 68 | + | |
| 69 | + public void setOutOrIn(int outOrIn) { | |
| 70 | + this.outOrIn = outOrIn; | |
| 71 | + } | |
| 72 | + | |
| 73 | + public String getDestCode() { | |
| 74 | + return destCode; | |
| 75 | + } | |
| 76 | + | |
| 77 | + public void setDestCode(String destCode) { | |
| 78 | + this.destCode = destCode; | |
| 79 | + } | |
| 80 | +} | ... | ... |
src/main/java/com/bsth/data/gpsdata/arrival/entity/SignalState.java
| 1 | -package com.bsth.data.gpsdata.arrival.entity; | |
| 2 | - | |
| 3 | -import com.bsth.data.BasicData; | |
| 4 | -import com.bsth.entity.realcontrol.ScheduleRealInfo; | |
| 5 | -import org.joda.time.format.DateTimeFormat; | |
| 6 | -import org.joda.time.format.DateTimeFormatter; | |
| 7 | - | |
| 8 | -/** | |
| 9 | - * 信号状态 | |
| 10 | - * Created by panzhao on 2016/12/30. | |
| 11 | - */ | |
| 12 | -public class SignalState { | |
| 13 | - | |
| 14 | - private String type; | |
| 15 | - | |
| 16 | - private Long st; | |
| 17 | - | |
| 18 | - //private Long checkTime; | |
| 19 | - | |
| 20 | - private Long schId; | |
| 21 | - | |
| 22 | - private String lineCode; | |
| 23 | - | |
| 24 | - private String text; | |
| 25 | - | |
| 26 | - private RouteReverse reverse; | |
| 27 | - | |
| 28 | - private SignalAbnormal signalAbnormal; | |
| 29 | - | |
| 30 | - private static DateTimeFormatter fmtHHmm = DateTimeFormat.forPattern("HH:mm"); | |
| 31 | - | |
| 32 | - /** | |
| 33 | - * 记录区间调头 | |
| 34 | - * | |
| 35 | - * @param sch | |
| 36 | - * @param reverse | |
| 37 | - * @return | |
| 38 | - */ | |
| 39 | - public static SignalState reverseSignalSTate(ScheduleRealInfo sch, RouteReverse reverse) { | |
| 40 | - if(reverse.isVague()) | |
| 41 | - return null; | |
| 42 | - | |
| 43 | - SignalState state = new SignalState(); | |
| 44 | - state.setSchId(sch.getId()); | |
| 45 | - state.setType("route_reverse"); | |
| 46 | - //state.setCheckTime(System.currentTimeMillis()); | |
| 47 | - | |
| 48 | - String stationName = BasicData.stationCode2NameMap.get(sch.getXlBm() + "_" + sch.getXlDir() + "_" + reverse.getTurned()); | |
| 49 | - state.setText(fmtHHmm.print(reverse.getZt()) + " 从 " + stationName + " 站掉头"); | |
| 50 | - state.setSt(sch.getFcsjActualTime()); | |
| 51 | - state.setLineCode(sch.getXlBm()); | |
| 52 | - state.setReverse(reverse); | |
| 53 | - return state; | |
| 54 | - } | |
| 55 | - | |
| 56 | - public static SignalState abnormalSignalSTate(ScheduleRealInfo sch, SignalAbnormal signalAbnormal) { | |
| 57 | - SignalState state = new SignalState(); | |
| 58 | - state.setSchId(sch.getId()); | |
| 59 | - state.setType("abnormal_signal"); | |
| 60 | - //state.setCheckTime(signalAbnormal.getCt()); | |
| 61 | - state.setLineCode(sch.getXlBm()); | |
| 62 | - | |
| 63 | - String text = (fmtHHmm.print(signalAbnormal.getSt()) + " ~ " + fmtHHmm.print(signalAbnormal.getEt())); | |
| 64 | - String abnormType = signalAbnormal.getAbnormalType(); | |
| 65 | - if (abnormType.equals("drift")) | |
| 66 | - text += "(GPS无效)"; | |
| 67 | - else if (abnormType.equals("reconnection")) | |
| 68 | - text += "(信号丢失)"; | |
| 69 | - | |
| 70 | - state.setText(text); | |
| 71 | - state.setSignalAbnormal(signalAbnormal); | |
| 72 | - return state; | |
| 73 | - } | |
| 74 | - | |
| 75 | - public String getType() { | |
| 76 | - return type; | |
| 77 | - } | |
| 78 | - | |
| 79 | - public void setType(String type) { | |
| 80 | - this.type = type; | |
| 81 | - } | |
| 82 | - | |
| 83 | - public long getSchId() { | |
| 84 | - return schId; | |
| 85 | - } | |
| 86 | - | |
| 87 | - public void setSchId(long schId) { | |
| 88 | - this.schId = schId; | |
| 89 | - } | |
| 90 | - | |
| 91 | - public String getLineCode() { | |
| 92 | - return lineCode; | |
| 93 | - } | |
| 94 | - | |
| 95 | - public void setLineCode(String lineCode) { | |
| 96 | - this.lineCode = lineCode; | |
| 97 | - } | |
| 98 | - | |
| 99 | - public Long getSt() { | |
| 100 | - return st; | |
| 101 | - } | |
| 102 | - | |
| 103 | - public void setSt(Long st) { | |
| 104 | - this.st = st; | |
| 105 | - } | |
| 106 | - | |
| 107 | - public String getText() { | |
| 108 | - return text; | |
| 109 | - } | |
| 110 | - | |
| 111 | - public void setText(String text) { | |
| 112 | - this.text = text; | |
| 113 | - } | |
| 114 | - | |
| 115 | - public RouteReverse getReverse() { | |
| 116 | - return reverse; | |
| 117 | - } | |
| 118 | - | |
| 119 | - public void setReverse(RouteReverse reverse) { | |
| 120 | - this.reverse = reverse; | |
| 121 | - } | |
| 122 | - | |
| 123 | - public SignalAbnormal getSignalAbnormal() { | |
| 124 | - return signalAbnormal; | |
| 125 | - } | |
| 126 | - | |
| 127 | - public void setSignalAbnormal(SignalAbnormal signalAbnormal) { | |
| 128 | - this.signalAbnormal = signalAbnormal; | |
| 129 | - } | |
| 130 | -} | |
| 1 | +package com.bsth.data.gpsdata.arrival.entity; | |
| 2 | + | |
| 3 | +import com.bsth.data.BasicData; | |
| 4 | +import com.bsth.entity.realcontrol.ScheduleRealInfo; | |
| 5 | +import org.joda.time.format.DateTimeFormat; | |
| 6 | +import org.joda.time.format.DateTimeFormatter; | |
| 7 | + | |
| 8 | +/** | |
| 9 | + * 信号状态 | |
| 10 | + * Created by panzhao on 2016/12/30. | |
| 11 | + */ | |
| 12 | +public class SignalState { | |
| 13 | + | |
| 14 | + private String type; | |
| 15 | + | |
| 16 | + private Long st; | |
| 17 | + | |
| 18 | + //private Long checkTime; | |
| 19 | + | |
| 20 | + private Long schId; | |
| 21 | + | |
| 22 | + private String lineCode; | |
| 23 | + | |
| 24 | + private String text; | |
| 25 | + | |
| 26 | + private RouteReverse reverse; | |
| 27 | + | |
| 28 | + private SignalAbnormal signalAbnormal; | |
| 29 | + | |
| 30 | + private static DateTimeFormatter fmtHHmm = DateTimeFormat.forPattern("HH:mm"); | |
| 31 | + | |
| 32 | + /** | |
| 33 | + * 记录区间调头 | |
| 34 | + * | |
| 35 | + * @param sch | |
| 36 | + * @param reverse | |
| 37 | + * @return | |
| 38 | + */ | |
| 39 | + public static SignalState reverseSignalSTate(ScheduleRealInfo sch, RouteReverse reverse) { | |
| 40 | + if(reverse.isVague()) | |
| 41 | + return null; | |
| 42 | + | |
| 43 | + SignalState state = new SignalState(); | |
| 44 | + state.setSchId(sch.getId()); | |
| 45 | + state.setType("route_reverse"); | |
| 46 | + //state.setCheckTime(System.currentTimeMillis()); | |
| 47 | + | |
| 48 | + String stationName = BasicData.stationCode2NameMap.get(sch.getXlBm() + "_" + sch.getXlDir() + "_" + reverse.getTurned()); | |
| 49 | + state.setText(fmtHHmm.print(reverse.getZt()) + " 从 " + stationName + " 站掉头"); | |
| 50 | + state.setSt(sch.getFcsjActualTime()); | |
| 51 | + state.setLineCode(sch.getXlBm()); | |
| 52 | + state.setReverse(reverse); | |
| 53 | + return state; | |
| 54 | + } | |
| 55 | + | |
| 56 | + public static SignalState abnormalSignalSTate(ScheduleRealInfo sch, SignalAbnormal signalAbnormal) { | |
| 57 | + SignalState state = new SignalState(); | |
| 58 | + state.setSchId(sch.getId()); | |
| 59 | + state.setType("abnormal_signal"); | |
| 60 | + //state.setCheckTime(signalAbnormal.getCt()); | |
| 61 | + state.setLineCode(sch.getXlBm()); | |
| 62 | + | |
| 63 | + String text = (fmtHHmm.print(signalAbnormal.getSt()) + " ~ " + fmtHHmm.print(signalAbnormal.getEt())); | |
| 64 | + String abnormType = signalAbnormal.getAbnormalType(); | |
| 65 | + if (abnormType.equals("drift")) | |
| 66 | + text += "(GPS无效)"; | |
| 67 | + else if (abnormType.equals("reconnection")) | |
| 68 | + text += "(信号丢失)"; | |
| 69 | + | |
| 70 | + state.setText(text); | |
| 71 | + state.setSignalAbnormal(signalAbnormal); | |
| 72 | + return state; | |
| 73 | + } | |
| 74 | + | |
| 75 | + public String getType() { | |
| 76 | + return type; | |
| 77 | + } | |
| 78 | + | |
| 79 | + public void setType(String type) { | |
| 80 | + this.type = type; | |
| 81 | + } | |
| 82 | + | |
| 83 | + public long getSchId() { | |
| 84 | + return schId; | |
| 85 | + } | |
| 86 | + | |
| 87 | + public void setSchId(long schId) { | |
| 88 | + this.schId = schId; | |
| 89 | + } | |
| 90 | + | |
| 91 | + public String getLineCode() { | |
| 92 | + return lineCode; | |
| 93 | + } | |
| 94 | + | |
| 95 | + public void setLineCode(String lineCode) { | |
| 96 | + this.lineCode = lineCode; | |
| 97 | + } | |
| 98 | + | |
| 99 | + public Long getSt() { | |
| 100 | + return st; | |
| 101 | + } | |
| 102 | + | |
| 103 | + public void setSt(Long st) { | |
| 104 | + this.st = st; | |
| 105 | + } | |
| 106 | + | |
| 107 | + public String getText() { | |
| 108 | + return text; | |
| 109 | + } | |
| 110 | + | |
| 111 | + public void setText(String text) { | |
| 112 | + this.text = text; | |
| 113 | + } | |
| 114 | + | |
| 115 | + public RouteReverse getReverse() { | |
| 116 | + return reverse; | |
| 117 | + } | |
| 118 | + | |
| 119 | + public void setReverse(RouteReverse reverse) { | |
| 120 | + this.reverse = reverse; | |
| 121 | + } | |
| 122 | + | |
| 123 | + public SignalAbnormal getSignalAbnormal() { | |
| 124 | + return signalAbnormal; | |
| 125 | + } | |
| 126 | + | |
| 127 | + public void setSignalAbnormal(SignalAbnormal signalAbnormal) { | |
| 128 | + this.signalAbnormal = signalAbnormal; | |
| 129 | + } | |
| 130 | +} | ... | ... |
src/main/java/com/bsth/data/gpsdata/arrival/handlers/InOutStationSignalHandle.java
src/main/java/com/bsth/data/gpsdata/arrival/handlers/OfflineSignalHandle.java
| 1 | -package com.bsth.data.gpsdata.arrival.handlers; | |
| 2 | - | |
| 3 | -import com.bsth.data.gpsdata.GpsEntity; | |
| 4 | -import com.bsth.data.gpsdata.arrival.GeoCacheData; | |
| 5 | -import com.bsth.data.gpsdata.arrival.SignalHandle; | |
| 6 | -import com.bsth.data.gpsdata.arrival.utils.CircleQueue; | |
| 7 | -import org.springframework.stereotype.Component; | |
| 8 | - | |
| 9 | -/** | |
| 10 | - * 信号断线重连处理 | |
| 11 | - * Created by panzhao on 2016/12/27. | |
| 12 | - */ | |
| 13 | -@Component | |
| 14 | -public class OfflineSignalHandle extends SignalHandle{ | |
| 15 | - | |
| 16 | - //断开2分钟,标记为重连信号 | |
| 17 | - private final static int OFFLINE_TIME = 1000 * 60 * 2; | |
| 18 | - | |
| 19 | - //断开70分钟,之前的信号不再有参考价值 | |
| 20 | - private final static int CLEAR_TIME = 1000 * 60 * 70; | |
| 21 | - | |
| 22 | - @Override | |
| 23 | - public boolean handle(GpsEntity gps, CircleQueue<GpsEntity> prevs) { | |
| 24 | - //漂移信号不管 | |
| 25 | - if(isDriftSignal(gps)){ | |
| 26 | - gps.setSignalState("drift"); | |
| 27 | - return true; | |
| 28 | - } | |
| 29 | - | |
| 30 | - if(isNotEmpty(prevs)){ | |
| 31 | - GpsEntity prev = prevs.getTail(); | |
| 32 | - int space = (int) (gps.getTimestamp() - prev.getTimestamp()); | |
| 33 | - if(space > OFFLINE_TIME) | |
| 34 | - gps.setSignalState("reconnection"); | |
| 35 | - | |
| 36 | - if(space > CLEAR_TIME){ | |
| 37 | - //清理缓存的信号 | |
| 38 | - GeoCacheData.clear(gps.getNbbm()); | |
| 39 | - } | |
| 40 | - } | |
| 41 | - return true; | |
| 42 | - } | |
| 1 | +package com.bsth.data.gpsdata.arrival.handlers; | |
| 2 | + | |
| 3 | +import com.bsth.data.gpsdata.GpsEntity; | |
| 4 | +import com.bsth.data.gpsdata.arrival.GeoCacheData; | |
| 5 | +import com.bsth.data.gpsdata.arrival.SignalHandle; | |
| 6 | +import com.bsth.data.gpsdata.arrival.utils.CircleQueue; | |
| 7 | +import org.springframework.stereotype.Component; | |
| 8 | + | |
| 9 | +/** | |
| 10 | + * 信号断线重连处理 | |
| 11 | + * Created by panzhao on 2016/12/27. | |
| 12 | + */ | |
| 13 | +@Component | |
| 14 | +public class OfflineSignalHandle extends SignalHandle{ | |
| 15 | + | |
| 16 | + //断开2分钟,标记为重连信号 | |
| 17 | + private final static int OFFLINE_TIME = 1000 * 60 * 2; | |
| 18 | + | |
| 19 | + //断开70分钟,之前的信号不再有参考价值 | |
| 20 | + private final static int CLEAR_TIME = 1000 * 60 * 70; | |
| 21 | + | |
| 22 | + @Override | |
| 23 | + public boolean handle(GpsEntity gps, CircleQueue<GpsEntity> prevs) { | |
| 24 | + //漂移信号不管 | |
| 25 | + if(isDriftSignal(gps)){ | |
| 26 | + gps.setSignalState("drift"); | |
| 27 | + return true; | |
| 28 | + } | |
| 29 | + | |
| 30 | + if(isNotEmpty(prevs)){ | |
| 31 | + GpsEntity prev = prevs.getTail(); | |
| 32 | + int space = (int) (gps.getTimestamp() - prev.getTimestamp()); | |
| 33 | + if(space > OFFLINE_TIME) | |
| 34 | + gps.setSignalState("reconnection"); | |
| 35 | + | |
| 36 | + if(space > CLEAR_TIME){ | |
| 37 | + //清理缓存的信号 | |
| 38 | + GeoCacheData.clear(gps.getNbbm()); | |
| 39 | + } | |
| 40 | + } | |
| 41 | + return true; | |
| 42 | + } | |
| 43 | 43 | } |
| 44 | 44 | \ No newline at end of file | ... | ... |
src/main/java/com/bsth/data/gpsdata/arrival/handlers/ReverseSignalHandle.java
| 1 | -package com.bsth.data.gpsdata.arrival.handlers; | |
| 2 | - | |
| 3 | -import com.bsth.data.gpsdata.GpsEntity; | |
| 4 | -import com.bsth.data.gpsdata.arrival.GeoCacheData; | |
| 5 | -import com.bsth.data.gpsdata.arrival.SignalHandle; | |
| 6 | -import com.bsth.data.gpsdata.arrival.entity.RouteReverse; | |
| 7 | -import com.bsth.data.gpsdata.arrival.entity.StationRoute; | |
| 8 | -import com.bsth.data.gpsdata.arrival.utils.CircleQueue; | |
| 9 | -import com.bsth.data.gpsdata.arrival.utils.ScheduleSignalState; | |
| 10 | -import com.bsth.data.schedule.DayOfSchedule; | |
| 11 | -import org.slf4j.Logger; | |
| 12 | -import org.slf4j.LoggerFactory; | |
| 13 | -import org.springframework.beans.factory.annotation.Autowired; | |
| 14 | -import org.springframework.stereotype.Component; | |
| 15 | - | |
| 16 | -/** | |
| 17 | - * 路由反向信号处理 | |
| 18 | - * Created by panzhao on 2016/12/28. | |
| 19 | - */ | |
| 20 | -@Component | |
| 21 | -public class ReverseSignalHandle extends SignalHandle { | |
| 22 | - | |
| 23 | - Logger logger = LoggerFactory.getLogger(this.getClass()); | |
| 24 | - | |
| 25 | - @Autowired | |
| 26 | - DayOfSchedule dayOfSchedule; | |
| 27 | - | |
| 28 | - @Autowired | |
| 29 | - ScheduleSignalState scheduleSignalState; | |
| 30 | - | |
| 31 | - @Override | |
| 32 | - public boolean handle(GpsEntity gps, CircleQueue<GpsEntity> prevs) { | |
| 33 | - if (!isNotEmpty(prevs)) | |
| 34 | - return false; | |
| 35 | - | |
| 36 | - GpsEntity prev = prevs.getTail(); | |
| 37 | - | |
| 38 | - if (isReverse(gps, prev)) { | |
| 39 | - RouteReverse reverse = reverseSearch(prevs, gps); | |
| 40 | - | |
| 41 | - if (reverse.getCount() >= 4 | |
| 42 | - && reverse.isClose() | |
| 43 | - && !GeoCacheData.isEndStation(gps.getLineId(), gps.getUpDown(), reverse.getTurned())) { | |
| 44 | - scheduleSignalState.reverseAnalyse(reverse); | |
| 45 | - } | |
| 46 | - } | |
| 47 | - return false; | |
| 48 | - } | |
| 49 | - | |
| 50 | - /** | |
| 51 | - * 搜索路由反向详细 | |
| 52 | - * | |
| 53 | - * @param prevs | |
| 54 | - * @param gps | |
| 55 | - * @return | |
| 56 | - */ | |
| 57 | - public RouteReverse reverseSearch(CircleQueue<GpsEntity> prevs, GpsEntity gps) { | |
| 58 | - RouteReverse routeReverse = new RouteReverse(); | |
| 59 | - int count = 0; | |
| 60 | - String path = ""; | |
| 61 | - long zt = 0L; | |
| 62 | - boolean half = false; | |
| 63 | - | |
| 64 | - //当前站点 | |
| 65 | - StationRoute curr = GeoCacheData.getRouteCode(gps), sr; | |
| 66 | - GpsEntity prev; | |
| 67 | - Object[] array = prevs.getQueue(); | |
| 68 | - for (int i = array.length - 1; i > 0; i--) { | |
| 69 | - prev = (GpsEntity) array[i]; | |
| 70 | - | |
| 71 | - if (!prev.getUpDown().equals(gps.getUpDown()) | |
| 72 | - || prev.getSignalState().equals("reconnection")) | |
| 73 | - break; | |
| 74 | - | |
| 75 | - if (prev.getInstation() == 1) { | |
| 76 | - sr = GeoCacheData.getRouteCode(prev); | |
| 77 | - | |
| 78 | - if (sr.getRouteSort() > curr.getRouteSort()) { | |
| 79 | - if(half){ | |
| 80 | - routeReverse.setVague(true); | |
| 81 | - } | |
| 82 | - | |
| 83 | - path += (curr.getCode() + ","); | |
| 84 | - count++; | |
| 85 | - zt = prev.getTimestamp(); | |
| 86 | - } else if (sr.getRouteSort() < curr.getRouteSort()) { | |
| 87 | - if (routeReverse.getTurned() == null) { | |
| 88 | - routeReverse.setTurned(curr.getCode()); | |
| 89 | - half = true; | |
| 90 | - } | |
| 91 | - | |
| 92 | - path += (curr.getCode() + ","); | |
| 93 | - //掉头前当前站 | |
| 94 | - if (sr.getCode().equals(gps.getStopNo())) { | |
| 95 | - routeReverse.setClose(true); | |
| 96 | - path += sr.getCode(); | |
| 97 | - break; | |
| 98 | - } | |
| 99 | - } | |
| 100 | - | |
| 101 | - curr = sr; | |
| 102 | - } | |
| 103 | - } | |
| 104 | - | |
| 105 | - routeReverse.setZt(zt); | |
| 106 | - routeReverse.setCount(count); | |
| 107 | - routeReverse.setDetail(path); | |
| 108 | - routeReverse.setCt(gps.getTimestamp()); | |
| 109 | - routeReverse.setNbbm(gps.getNbbm()); | |
| 110 | - return routeReverse; | |
| 111 | - } | |
| 112 | - | |
| 113 | - /** | |
| 114 | - * 是否反向 | |
| 115 | - * | |
| 116 | - * @param gps | |
| 117 | - * @param prev | |
| 118 | - * @return | |
| 119 | - */ | |
| 120 | - public boolean isReverse(GpsEntity gps, GpsEntity prev) { | |
| 121 | - if (gps.getInstation() == 1 | |
| 122 | - && | |
| 123 | - gps.getUpDown().equals(prev.getUpDown()) | |
| 124 | - && !gps.getStopNo().equals(prev.getStopNo())) { | |
| 125 | - | |
| 126 | - StationRoute currStation = GeoCacheData.getRouteCode(gps); | |
| 127 | - StationRoute prevStation = GeoCacheData.getRouteCode(prev); | |
| 128 | - | |
| 129 | - if (currStation == null || prevStation == null) | |
| 130 | - return false; | |
| 131 | - | |
| 132 | - if (currStation.getRouteSort() < prevStation.getRouteSort()) | |
| 133 | - return true; | |
| 134 | - } | |
| 135 | - return false; | |
| 136 | - } | |
| 1 | +package com.bsth.data.gpsdata.arrival.handlers; | |
| 2 | + | |
| 3 | +import com.bsth.data.gpsdata.GpsEntity; | |
| 4 | +import com.bsth.data.gpsdata.arrival.GeoCacheData; | |
| 5 | +import com.bsth.data.gpsdata.arrival.SignalHandle; | |
| 6 | +import com.bsth.data.gpsdata.arrival.entity.RouteReverse; | |
| 7 | +import com.bsth.data.gpsdata.arrival.entity.StationRoute; | |
| 8 | +import com.bsth.data.gpsdata.arrival.utils.CircleQueue; | |
| 9 | +import com.bsth.data.gpsdata.arrival.utils.ScheduleSignalState; | |
| 10 | +import com.bsth.data.schedule.DayOfSchedule; | |
| 11 | +import org.slf4j.Logger; | |
| 12 | +import org.slf4j.LoggerFactory; | |
| 13 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 14 | +import org.springframework.stereotype.Component; | |
| 15 | + | |
| 16 | +/** | |
| 17 | + * 路由反向信号处理 | |
| 18 | + * Created by panzhao on 2016/12/28. | |
| 19 | + */ | |
| 20 | +@Component | |
| 21 | +public class ReverseSignalHandle extends SignalHandle { | |
| 22 | + | |
| 23 | + Logger logger = LoggerFactory.getLogger(this.getClass()); | |
| 24 | + | |
| 25 | + @Autowired | |
| 26 | + DayOfSchedule dayOfSchedule; | |
| 27 | + | |
| 28 | + @Autowired | |
| 29 | + ScheduleSignalState scheduleSignalState; | |
| 30 | + | |
| 31 | + @Override | |
| 32 | + public boolean handle(GpsEntity gps, CircleQueue<GpsEntity> prevs) { | |
| 33 | + if (!isNotEmpty(prevs)) | |
| 34 | + return false; | |
| 35 | + | |
| 36 | + GpsEntity prev = prevs.getTail(); | |
| 37 | + | |
| 38 | + if (isReverse(gps, prev)) { | |
| 39 | + RouteReverse reverse = reverseSearch(prevs, gps); | |
| 40 | + | |
| 41 | + if (reverse.getCount() >= 4 | |
| 42 | + && reverse.isClose() | |
| 43 | + && !GeoCacheData.isEndStation(gps.getLineId(), gps.getUpDown(), reverse.getTurned())) { | |
| 44 | + scheduleSignalState.reverseAnalyse(reverse); | |
| 45 | + } | |
| 46 | + } | |
| 47 | + return false; | |
| 48 | + } | |
| 49 | + | |
| 50 | + /** | |
| 51 | + * 搜索路由反向详细 | |
| 52 | + * | |
| 53 | + * @param prevs | |
| 54 | + * @param gps | |
| 55 | + * @return | |
| 56 | + */ | |
| 57 | + public RouteReverse reverseSearch(CircleQueue<GpsEntity> prevs, GpsEntity gps) { | |
| 58 | + RouteReverse routeReverse = new RouteReverse(); | |
| 59 | + int count = 0; | |
| 60 | + String path = ""; | |
| 61 | + long zt = 0L; | |
| 62 | + boolean half = false; | |
| 63 | + | |
| 64 | + //当前站点 | |
| 65 | + StationRoute curr = GeoCacheData.getRouteCode(gps), sr; | |
| 66 | + GpsEntity prev; | |
| 67 | + Object[] array = prevs.getQueue(); | |
| 68 | + for (int i = array.length - 1; i > 0; i--) { | |
| 69 | + prev = (GpsEntity) array[i]; | |
| 70 | + | |
| 71 | + if (!prev.getUpDown().equals(gps.getUpDown()) | |
| 72 | + || prev.getSignalState().equals("reconnection")) | |
| 73 | + break; | |
| 74 | + | |
| 75 | + if (prev.getInstation() == 1) { | |
| 76 | + sr = GeoCacheData.getRouteCode(prev); | |
| 77 | + | |
| 78 | + if (sr.getRouteSort() > curr.getRouteSort()) { | |
| 79 | + if(half){ | |
| 80 | + routeReverse.setVague(true); | |
| 81 | + } | |
| 82 | + | |
| 83 | + path += (curr.getCode() + ","); | |
| 84 | + count++; | |
| 85 | + zt = prev.getTimestamp(); | |
| 86 | + } else if (sr.getRouteSort() < curr.getRouteSort()) { | |
| 87 | + if (routeReverse.getTurned() == null) { | |
| 88 | + routeReverse.setTurned(curr.getCode()); | |
| 89 | + half = true; | |
| 90 | + } | |
| 91 | + | |
| 92 | + path += (curr.getCode() + ","); | |
| 93 | + //掉头前当前站 | |
| 94 | + if (sr.getCode().equals(gps.getStopNo())) { | |
| 95 | + routeReverse.setClose(true); | |
| 96 | + path += sr.getCode(); | |
| 97 | + break; | |
| 98 | + } | |
| 99 | + } | |
| 100 | + | |
| 101 | + curr = sr; | |
| 102 | + } | |
| 103 | + } | |
| 104 | + | |
| 105 | + routeReverse.setZt(zt); | |
| 106 | + routeReverse.setCount(count); | |
| 107 | + routeReverse.setDetail(path); | |
| 108 | + routeReverse.setCt(gps.getTimestamp()); | |
| 109 | + routeReverse.setNbbm(gps.getNbbm()); | |
| 110 | + return routeReverse; | |
| 111 | + } | |
| 112 | + | |
| 113 | + /** | |
| 114 | + * 是否反向 | |
| 115 | + * | |
| 116 | + * @param gps | |
| 117 | + * @param prev | |
| 118 | + * @return | |
| 119 | + */ | |
| 120 | + public boolean isReverse(GpsEntity gps, GpsEntity prev) { | |
| 121 | + if (gps.getInstation() == 1 | |
| 122 | + && | |
| 123 | + gps.getUpDown().equals(prev.getUpDown()) | |
| 124 | + && !gps.getStopNo().equals(prev.getStopNo())) { | |
| 125 | + | |
| 126 | + StationRoute currStation = GeoCacheData.getRouteCode(gps); | |
| 127 | + StationRoute prevStation = GeoCacheData.getRouteCode(prev); | |
| 128 | + | |
| 129 | + if (currStation == null || prevStation == null) | |
| 130 | + return false; | |
| 131 | + | |
| 132 | + if (currStation.getRouteSort() < prevStation.getRouteSort()) | |
| 133 | + return true; | |
| 134 | + } | |
| 135 | + return false; | |
| 136 | + } | |
| 137 | 137 | } |
| 138 | 138 | \ No newline at end of file | ... | ... |
src/main/java/com/bsth/data/gpsdata/arrival/utils/ScheduleSignalState.java
src/main/java/com/bsth/data/gpsdata/arrival/utils/SignalSchPlanMatcher.java
| 1 | -package com.bsth.data.gpsdata.arrival.utils; | |
| 2 | - | |
| 3 | -import com.bsth.data.gpsdata.GpsEntity; | |
| 4 | -import com.bsth.data.schedule.DayOfSchedule; | |
| 5 | -import com.bsth.entity.realcontrol.ScheduleRealInfo; | |
| 6 | -import org.springframework.beans.factory.annotation.Autowired; | |
| 7 | -import org.springframework.stereotype.Component; | |
| 8 | - | |
| 9 | -/** | |
| 10 | - * 班次匹配器 | |
| 11 | - * Created by panzhao on 2016/12/31. | |
| 12 | - */ | |
| 13 | -@Component | |
| 14 | -public class SignalSchPlanMatcher { | |
| 15 | - | |
| 16 | - @Autowired | |
| 17 | - DayOfSchedule dayOfSchedule; | |
| 18 | - | |
| 19 | - /** | |
| 20 | - * 发车信号匹配 | |
| 21 | - * @param outSigal | |
| 22 | - * @param sch | |
| 23 | - * @return | |
| 24 | - */ | |
| 25 | - public void outMatch(GpsEntity outSigal, ScheduleRealInfo sch){ | |
| 26 | - long t = outSigal.getTimestamp(); | |
| 27 | - if(t < sch.getDfsjT()) | |
| 28 | - return; | |
| 29 | - | |
| 30 | - //下一个相同走向的班次 | |
| 31 | - ScheduleRealInfo next = dayOfSchedule.nextSame(sch); | |
| 32 | - if(next == null || !next.getQdzCode().equals(sch.getQdzCode())) | |
| 33 | - return; | |
| 34 | - | |
| 35 | - //晚于班次间隔百分之70,跳下一个班次 | |
| 36 | - double s = (int) (next.getDfsjT() - sch.getDfsjT()); | |
| 37 | - double r = (int) (t - sch.getDfsjT()); | |
| 38 | - if(r / s > 0.7){ | |
| 39 | - dayOfSchedule.addExecPlan(next); | |
| 40 | - outMatch(outSigal, next); | |
| 41 | - } | |
| 42 | - } | |
| 43 | -} | |
| 1 | +package com.bsth.data.gpsdata.arrival.utils; | |
| 2 | + | |
| 3 | +import com.bsth.data.gpsdata.GpsEntity; | |
| 4 | +import com.bsth.data.schedule.DayOfSchedule; | |
| 5 | +import com.bsth.entity.realcontrol.ScheduleRealInfo; | |
| 6 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 7 | +import org.springframework.stereotype.Component; | |
| 8 | + | |
| 9 | +/** | |
| 10 | + * 班次匹配器 | |
| 11 | + * Created by panzhao on 2016/12/31. | |
| 12 | + */ | |
| 13 | +@Component | |
| 14 | +public class SignalSchPlanMatcher { | |
| 15 | + | |
| 16 | + @Autowired | |
| 17 | + DayOfSchedule dayOfSchedule; | |
| 18 | + | |
| 19 | + /** | |
| 20 | + * 发车信号匹配 | |
| 21 | + * @param outSigal | |
| 22 | + * @param sch | |
| 23 | + * @return | |
| 24 | + */ | |
| 25 | + public void outMatch(GpsEntity outSigal, ScheduleRealInfo sch){ | |
| 26 | + long t = outSigal.getTimestamp(); | |
| 27 | + if(t < sch.getDfsjT()) | |
| 28 | + return; | |
| 29 | + | |
| 30 | + //下一个相同走向的班次 | |
| 31 | + ScheduleRealInfo next = dayOfSchedule.nextSame(sch); | |
| 32 | + if(next == null || !next.getQdzCode().equals(sch.getQdzCode())) | |
| 33 | + return; | |
| 34 | + | |
| 35 | + //晚于班次间隔百分之70,跳下一个班次 | |
| 36 | + double s = (int) (next.getDfsjT() - sch.getDfsjT()); | |
| 37 | + double r = (int) (t - sch.getDfsjT()); | |
| 38 | + if(r / s > 0.7){ | |
| 39 | + dayOfSchedule.addExecPlan(next); | |
| 40 | + outMatch(outSigal, next); | |
| 41 | + } | |
| 42 | + } | |
| 43 | +} | ... | ... |
src/main/java/com/bsth/data/gpsdata/recovery/GpsDataRecovery.java
| 1 | -package com.bsth.data.gpsdata.recovery; | |
| 2 | - | |
| 3 | -import com.bsth.data.BasicData; | |
| 4 | -import com.bsth.data.gpsdata.GpsEntity; | |
| 5 | -import com.bsth.data.gpsdata.arrival.GeoCacheData; | |
| 6 | -import com.bsth.data.gpsdata.arrival.handlers.*; | |
| 7 | -import com.bsth.data.gpsdata.arrival.utils.CircleQueue; | |
| 8 | -import com.bsth.util.db.DBUtils_MS; | |
| 9 | -import com.google.common.collect.ArrayListMultimap; | |
| 10 | -import org.slf4j.Logger; | |
| 11 | -import org.slf4j.LoggerFactory; | |
| 12 | -import org.springframework.beans.BeansException; | |
| 13 | -import org.springframework.context.ApplicationContext; | |
| 14 | -import org.springframework.context.ApplicationContextAware; | |
| 15 | -import org.springframework.jdbc.core.JdbcTemplate; | |
| 16 | -import org.springframework.jdbc.core.RowMapper; | |
| 17 | -import org.springframework.stereotype.Component; | |
| 18 | - | |
| 19 | -import java.sql.ResultSet; | |
| 20 | -import java.sql.SQLException; | |
| 21 | -import java.util.*; | |
| 22 | -import java.util.concurrent.CountDownLatch; | |
| 23 | -import java.util.concurrent.ExecutorService; | |
| 24 | -import java.util.concurrent.Executors; | |
| 25 | - | |
| 26 | -/** | |
| 27 | - * gps数据恢复 | |
| 28 | - * Created by panzhao on 2016/12/24. | |
| 29 | - */ | |
| 30 | -@Component | |
| 31 | -public class GpsDataRecovery implements ApplicationContextAware { | |
| 32 | - | |
| 33 | - static Logger logger = LoggerFactory.getLogger(GpsDataRecovery.class); | |
| 34 | - | |
| 35 | - public static boolean run; | |
| 36 | - | |
| 37 | - static ExecutorService threadPool = Executors.newFixedThreadPool(10); | |
| 38 | - | |
| 39 | - static OfflineSignalHandle offlineSignalHandle; | |
| 40 | - static CorrectSignalHandle correctSignalHandle; | |
| 41 | - static StationInsideHandle stationInsideHandle; | |
| 42 | - static InOutStationSignalHandle inOutStationSignalHandle; | |
| 43 | - static ReverseSignalHandle reverseSignalHandle; | |
| 44 | - | |
| 45 | - public void recovery() { | |
| 46 | - List<GpsEntity> list = loadData(); | |
| 47 | - | |
| 48 | - //按车辆分组数据 | |
| 49 | - ArrayListMultimap<String, GpsEntity> listMap = ArrayListMultimap.create(); | |
| 50 | - for (GpsEntity gps : list) { | |
| 51 | - if (gps.getNbbm() != null) | |
| 52 | - listMap.put(gps.getNbbm(), gps); | |
| 53 | - } | |
| 54 | - | |
| 55 | - | |
| 56 | - Set<String> keys = listMap.keySet(); | |
| 57 | - | |
| 58 | - CountDownLatch count = new CountDownLatch(keys.size()); | |
| 59 | - GpsComp comp = new GpsComp(); | |
| 60 | - for (String nbbm : keys) { | |
| 61 | - Collections.sort(listMap.get(nbbm), comp); | |
| 62 | - threadPool.execute(new RecoveryThread(listMap.get(nbbm), count)); | |
| 63 | - /*if(nbbm.equals("YT-CD008")) | |
| 64 | - new RecoveryThread(listMap.get(nbbm), count).run();*/ | |
| 65 | - } | |
| 66 | - | |
| 67 | - try { | |
| 68 | - count.await(); | |
| 69 | - run = false; | |
| 70 | - logger.info("数据恢复完成...."); | |
| 71 | - } catch (InterruptedException e) { | |
| 72 | - logger.error("", e); | |
| 73 | - } | |
| 74 | - } | |
| 75 | - | |
| 76 | - /** | |
| 77 | - * 加载当天的gps数据 | |
| 78 | - * | |
| 79 | - * @return | |
| 80 | - */ | |
| 81 | - public List<GpsEntity> loadData() { | |
| 82 | - Calendar calendar = Calendar.getInstance(); | |
| 83 | - int dayOfYear = calendar.get(Calendar.DAY_OF_YEAR); | |
| 84 | - | |
| 85 | - String sql = "select DEVICE_ID,LAT,LON,TS,SPEED_GPS,LINE_ID,SERVICE_STATE from bsth_c_gps_info where days_year=" + dayOfYear; | |
| 86 | - JdbcTemplate jdbcTemplate = new JdbcTemplate(DBUtils_MS.getDataSource()); | |
| 87 | - | |
| 88 | - List<GpsEntity> list = | |
| 89 | - jdbcTemplate.query(sql, new RowMapper<GpsEntity>() { | |
| 90 | - @Override | |
| 91 | - public GpsEntity mapRow(ResultSet rs, int rowNum) throws SQLException { | |
| 92 | - GpsEntity gps = new GpsEntity(); | |
| 93 | - | |
| 94 | - gps.setDeviceId(rs.getString("DEVICE_ID")); | |
| 95 | - gps.setNbbm(BasicData.deviceId2NbbmMap.get(gps.getDeviceId())); | |
| 96 | - gps.setSpeed(rs.getFloat("SPEED_GPS")); | |
| 97 | - gps.setLat(rs.getFloat("LAT")); | |
| 98 | - gps.setLon(rs.getFloat("LON")); | |
| 99 | - gps.setLineId(rs.getString("LINE_ID")); | |
| 100 | - gps.setTimestamp(rs.getLong("TS")); | |
| 101 | - gps.setUpDown(getUpOrDown(rs.getLong("SERVICE_STATE"))); | |
| 102 | - return gps; | |
| 103 | - } | |
| 104 | - }); | |
| 105 | - return list; | |
| 106 | - } | |
| 107 | - | |
| 108 | - /** | |
| 109 | - * 王通 2016/6/29 9:23:24 获取车辆线路上下行 | |
| 110 | - * | |
| 111 | - * @return -1无效 0上行 1下行 | |
| 112 | - */ | |
| 113 | - public static int getUpOrDown(long serviceState) { | |
| 114 | - if ((serviceState & 0x00020000) == 0x00020000 || (serviceState & 0x80000000) == 0x80000000 | |
| 115 | - || (serviceState & 0x01000000) == 0x01000000 || (serviceState & 0x08000000) == 0x08000000) | |
| 116 | - return -1; | |
| 117 | - return (((serviceState & 0x10000000) == 0x10000000) ? 1 : 0); | |
| 118 | - } | |
| 119 | - | |
| 120 | - @Override | |
| 121 | - public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { | |
| 122 | - offlineSignalHandle = applicationContext.getBean(OfflineSignalHandle.class); | |
| 123 | - correctSignalHandle = applicationContext.getBean(CorrectSignalHandle.class); | |
| 124 | - stationInsideHandle = applicationContext.getBean(StationInsideHandle.class); | |
| 125 | - inOutStationSignalHandle = applicationContext.getBean(InOutStationSignalHandle.class); | |
| 126 | - reverseSignalHandle = applicationContext.getBean(ReverseSignalHandle.class); | |
| 127 | - } | |
| 128 | - | |
| 129 | - public static class GpsComp implements Comparator<GpsEntity> { | |
| 130 | - | |
| 131 | - @Override | |
| 132 | - public int compare(GpsEntity g1, GpsEntity g2) { | |
| 133 | - return g1.getTimestamp().compareTo(g2.getTimestamp()); | |
| 134 | - } | |
| 135 | - } | |
| 136 | - | |
| 137 | - public static class RecoveryThread implements Runnable { | |
| 138 | - List<GpsEntity> list; | |
| 139 | - CountDownLatch count; | |
| 140 | - | |
| 141 | - RecoveryThread(List<GpsEntity> list, CountDownLatch count) { | |
| 142 | - this.list = list; | |
| 143 | - this.count = count; | |
| 144 | - } | |
| 145 | - | |
| 146 | - @Override | |
| 147 | - public void run() { | |
| 148 | - try { | |
| 149 | - //循环gps恢复数据 | |
| 150 | - CircleQueue<GpsEntity> prevs; | |
| 151 | - | |
| 152 | - for (GpsEntity gps : list) { | |
| 153 | - | |
| 154 | - prevs = GeoCacheData.getGps(gps.getNbbm()); | |
| 155 | - //掉线处理 | |
| 156 | - offlineSignalHandle.handle(gps, prevs); | |
| 157 | - //状态处理 | |
| 158 | - if (!correctSignalHandle.handle(gps, prevs)) | |
| 159 | - continue; | |
| 160 | - //场,站内外判断 | |
| 161 | - stationInsideHandle.handle(gps, prevs); | |
| 162 | - //反向处理 | |
| 163 | - reverseSignalHandle.handle(gps, prevs); | |
| 164 | - //进出站动作处理 | |
| 165 | - inOutStationSignalHandle.handle(gps, prevs); | |
| 166 | - GeoCacheData.putGps(gps); | |
| 167 | - | |
| 168 | - //Thread.sleep(50); | |
| 169 | - } | |
| 170 | - } catch (Exception e) { | |
| 171 | - logger.error("", e); | |
| 172 | - } finally { | |
| 173 | - count.countDown(); | |
| 174 | - } | |
| 175 | - } | |
| 176 | - } | |
| 1 | +package com.bsth.data.gpsdata.recovery; | |
| 2 | + | |
| 3 | +import com.bsth.data.BasicData; | |
| 4 | +import com.bsth.data.gpsdata.GpsEntity; | |
| 5 | +import com.bsth.data.gpsdata.arrival.GeoCacheData; | |
| 6 | +import com.bsth.data.gpsdata.arrival.handlers.*; | |
| 7 | +import com.bsth.data.gpsdata.arrival.utils.CircleQueue; | |
| 8 | +import com.bsth.util.db.DBUtils_MS; | |
| 9 | +import com.google.common.collect.ArrayListMultimap; | |
| 10 | +import org.slf4j.Logger; | |
| 11 | +import org.slf4j.LoggerFactory; | |
| 12 | +import org.springframework.beans.BeansException; | |
| 13 | +import org.springframework.context.ApplicationContext; | |
| 14 | +import org.springframework.context.ApplicationContextAware; | |
| 15 | +import org.springframework.jdbc.core.JdbcTemplate; | |
| 16 | +import org.springframework.jdbc.core.RowMapper; | |
| 17 | +import org.springframework.stereotype.Component; | |
| 18 | + | |
| 19 | +import java.sql.ResultSet; | |
| 20 | +import java.sql.SQLException; | |
| 21 | +import java.util.*; | |
| 22 | +import java.util.concurrent.CountDownLatch; | |
| 23 | +import java.util.concurrent.ExecutorService; | |
| 24 | +import java.util.concurrent.Executors; | |
| 25 | + | |
| 26 | +/** | |
| 27 | + * gps数据恢复 | |
| 28 | + * Created by panzhao on 2016/12/24. | |
| 29 | + */ | |
| 30 | +@Component | |
| 31 | +public class GpsDataRecovery implements ApplicationContextAware { | |
| 32 | + | |
| 33 | + static Logger logger = LoggerFactory.getLogger(GpsDataRecovery.class); | |
| 34 | + | |
| 35 | + public static boolean run; | |
| 36 | + | |
| 37 | + static ExecutorService threadPool = Executors.newFixedThreadPool(10); | |
| 38 | + | |
| 39 | + static OfflineSignalHandle offlineSignalHandle; | |
| 40 | + static CorrectSignalHandle correctSignalHandle; | |
| 41 | + static StationInsideHandle stationInsideHandle; | |
| 42 | + static InOutStationSignalHandle inOutStationSignalHandle; | |
| 43 | + static ReverseSignalHandle reverseSignalHandle; | |
| 44 | + | |
| 45 | + public void recovery() { | |
| 46 | + List<GpsEntity> list = loadData(); | |
| 47 | + | |
| 48 | + //按车辆分组数据 | |
| 49 | + ArrayListMultimap<String, GpsEntity> listMap = ArrayListMultimap.create(); | |
| 50 | + for (GpsEntity gps : list) { | |
| 51 | + if (gps.getNbbm() != null) | |
| 52 | + listMap.put(gps.getNbbm(), gps); | |
| 53 | + } | |
| 54 | + | |
| 55 | + | |
| 56 | + Set<String> keys = listMap.keySet(); | |
| 57 | + | |
| 58 | + CountDownLatch count = new CountDownLatch(keys.size()); | |
| 59 | + GpsComp comp = new GpsComp(); | |
| 60 | + for (String nbbm : keys) { | |
| 61 | + Collections.sort(listMap.get(nbbm), comp); | |
| 62 | + threadPool.execute(new RecoveryThread(listMap.get(nbbm), count)); | |
| 63 | + /*if(nbbm.equals("YT-CD008")) | |
| 64 | + new RecoveryThread(listMap.get(nbbm), count).run();*/ | |
| 65 | + } | |
| 66 | + | |
| 67 | + try { | |
| 68 | + count.await(); | |
| 69 | + run = false; | |
| 70 | + logger.info("数据恢复完成...."); | |
| 71 | + } catch (InterruptedException e) { | |
| 72 | + logger.error("", e); | |
| 73 | + } | |
| 74 | + } | |
| 75 | + | |
| 76 | + /** | |
| 77 | + * 加载当天的gps数据 | |
| 78 | + * | |
| 79 | + * @return | |
| 80 | + */ | |
| 81 | + public List<GpsEntity> loadData() { | |
| 82 | + Calendar calendar = Calendar.getInstance(); | |
| 83 | + int dayOfYear = calendar.get(Calendar.DAY_OF_YEAR); | |
| 84 | + | |
| 85 | + String sql = "select DEVICE_ID,LAT,LON,TS,SPEED_GPS,LINE_ID,SERVICE_STATE from bsth_c_gps_info where days_year=" + dayOfYear; | |
| 86 | + JdbcTemplate jdbcTemplate = new JdbcTemplate(DBUtils_MS.getDataSource()); | |
| 87 | + | |
| 88 | + List<GpsEntity> list = | |
| 89 | + jdbcTemplate.query(sql, new RowMapper<GpsEntity>() { | |
| 90 | + @Override | |
| 91 | + public GpsEntity mapRow(ResultSet rs, int rowNum) throws SQLException { | |
| 92 | + GpsEntity gps = new GpsEntity(); | |
| 93 | + | |
| 94 | + gps.setDeviceId(rs.getString("DEVICE_ID")); | |
| 95 | + gps.setNbbm(BasicData.deviceId2NbbmMap.get(gps.getDeviceId())); | |
| 96 | + gps.setSpeed(rs.getFloat("SPEED_GPS")); | |
| 97 | + gps.setLat(rs.getFloat("LAT")); | |
| 98 | + gps.setLon(rs.getFloat("LON")); | |
| 99 | + gps.setLineId(rs.getString("LINE_ID")); | |
| 100 | + gps.setTimestamp(rs.getLong("TS")); | |
| 101 | + gps.setUpDown(getUpOrDown(rs.getLong("SERVICE_STATE"))); | |
| 102 | + return gps; | |
| 103 | + } | |
| 104 | + }); | |
| 105 | + return list; | |
| 106 | + } | |
| 107 | + | |
| 108 | + /** | |
| 109 | + * 王通 2016/6/29 9:23:24 获取车辆线路上下行 | |
| 110 | + * | |
| 111 | + * @return -1无效 0上行 1下行 | |
| 112 | + */ | |
| 113 | + public static int getUpOrDown(long serviceState) { | |
| 114 | + if ((serviceState & 0x00020000) == 0x00020000 || (serviceState & 0x80000000) == 0x80000000 | |
| 115 | + || (serviceState & 0x01000000) == 0x01000000 || (serviceState & 0x08000000) == 0x08000000) | |
| 116 | + return -1; | |
| 117 | + return (((serviceState & 0x10000000) == 0x10000000) ? 1 : 0); | |
| 118 | + } | |
| 119 | + | |
| 120 | + @Override | |
| 121 | + public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { | |
| 122 | + offlineSignalHandle = applicationContext.getBean(OfflineSignalHandle.class); | |
| 123 | + correctSignalHandle = applicationContext.getBean(CorrectSignalHandle.class); | |
| 124 | + stationInsideHandle = applicationContext.getBean(StationInsideHandle.class); | |
| 125 | + inOutStationSignalHandle = applicationContext.getBean(InOutStationSignalHandle.class); | |
| 126 | + reverseSignalHandle = applicationContext.getBean(ReverseSignalHandle.class); | |
| 127 | + } | |
| 128 | + | |
| 129 | + public static class GpsComp implements Comparator<GpsEntity> { | |
| 130 | + | |
| 131 | + @Override | |
| 132 | + public int compare(GpsEntity g1, GpsEntity g2) { | |
| 133 | + return g1.getTimestamp().compareTo(g2.getTimestamp()); | |
| 134 | + } | |
| 135 | + } | |
| 136 | + | |
| 137 | + public static class RecoveryThread implements Runnable { | |
| 138 | + List<GpsEntity> list; | |
| 139 | + CountDownLatch count; | |
| 140 | + | |
| 141 | + RecoveryThread(List<GpsEntity> list, CountDownLatch count) { | |
| 142 | + this.list = list; | |
| 143 | + this.count = count; | |
| 144 | + } | |
| 145 | + | |
| 146 | + @Override | |
| 147 | + public void run() { | |
| 148 | + try { | |
| 149 | + //循环gps恢复数据 | |
| 150 | + CircleQueue<GpsEntity> prevs; | |
| 151 | + | |
| 152 | + for (GpsEntity gps : list) { | |
| 153 | + | |
| 154 | + prevs = GeoCacheData.getGps(gps.getNbbm()); | |
| 155 | + //掉线处理 | |
| 156 | + offlineSignalHandle.handle(gps, prevs); | |
| 157 | + //状态处理 | |
| 158 | + if (!correctSignalHandle.handle(gps, prevs)) | |
| 159 | + continue; | |
| 160 | + //场,站内外判断 | |
| 161 | + stationInsideHandle.handle(gps, prevs); | |
| 162 | + //反向处理 | |
| 163 | + reverseSignalHandle.handle(gps, prevs); | |
| 164 | + //进出站动作处理 | |
| 165 | + inOutStationSignalHandle.handle(gps, prevs); | |
| 166 | + GeoCacheData.putGps(gps); | |
| 167 | + | |
| 168 | + //Thread.sleep(50); | |
| 169 | + } | |
| 170 | + } catch (Exception e) { | |
| 171 | + logger.error("", e); | |
| 172 | + } finally { | |
| 173 | + count.countDown(); | |
| 174 | + } | |
| 175 | + } | |
| 176 | + } | |
| 177 | 177 | } |
| 178 | 178 | \ No newline at end of file | ... | ... |
src/main/java/com/bsth/repository/realcontrol/ScheduleRealInfoRepository.java
| ... | ... | @@ -32,7 +32,7 @@ public interface ScheduleRealInfoRepository extends BaseRepository<ScheduleRealI |
| 32 | 32 | |
| 33 | 33 | //把sum(addMileage) 替换为0 数据表去掉了 add_mileage 字段 |
| 34 | 34 | @Query(value="select new map(clZbh as clZbh,jGh as jGh,jName as jName,sum(jhlc) as zgl," |
| 35 | - + " 0 as ksgl,count(jName) as bcs) from ScheduleRealInfo s where" | |
| 35 | + + "0 as ksgl,count(jName) as bcs) from ScheduleRealInfo s where" | |
| 36 | 36 | + " s.xlBm = ?1 and DATE_FORMAT(s.scheduleDate,'%Y-%m-%d') = ?2 group by clZbh,jGh,jName") |
| 37 | 37 | List<Map<String, Object>> dailyInfo(String line,String date); |
| 38 | 38 | |
| ... | ... | @@ -71,7 +71,7 @@ public interface ScheduleRealInfoRepository extends BaseRepository<ScheduleRealI |
| 71 | 71 | @Query(value="select count(jName) from ScheduleRealInfo s where s.jName = ?1 and s.clZbh = ?2 and s.lpName = ?3 and sflj != 0") |
| 72 | 72 | int findLjbc(String jName,String clZbh,String lpName); |
| 73 | 73 | |
| 74 | - @Query(value="SELECT c.company,r.request_code,FROM_UNIXTIME(r.timestamp/1000,'%Y-%m-%d %T'),c.inside_code FROM bsth_v_report_80 r LEFT JOIN bsth_c_cars c ON c.equipment_code = r.device_id where FROM_UNIXTIME(r.timestamp/1000,'%Y-%m-%d') = ?2 and r.line_id like %?1% and c.inside_code like %?3%",nativeQuery=true) | |
| 74 | + @Query(value="SELECT c.company,r.request_code,FROM_UNIXTIME(r.timestamp/1000,'%Y-%m-%d %T') FROM bsth_v_report_80 r LEFT JOIN bsth_c_cars c ON c.equipment_code = r.device_id where FROM_UNIXTIME(r.timestamp/1000,'%Y-%m-%d') = ?2 and r.line_id = ?1 and c.inside_code = ?3",nativeQuery=true) | |
| 75 | 75 | List<Object[]> account(String line,String date,String code); |
| 76 | 76 | |
| 77 | 77 | @Query(value="select s from ScheduleRealInfo s where s.xlBm = ?1 and s.scheduleDate >= str_to_date(?2,'%Y-%m-%d') " |
| ... | ... | @@ -125,4 +125,4 @@ public interface ScheduleRealInfoRepository extends BaseRepository<ScheduleRealI |
| 125 | 125 | @Query(value="select new map(xlBm as xlBm) from ScheduleRealInfo s where DATE_FORMAT(s.scheduleDate,'%Y-%m-%d') = ?1 GROUP BY xlBm ORDER BY xlBm") |
| 126 | 126 | List<Map<String,Object>> setDDRBGroup(String date); |
| 127 | 127 | |
| 128 | -} | |
| 129 | 128 | \ No newline at end of file |
| 129 | +} | ... | ... |
src/main/java/com/bsth/service/forms/impl/FormsServiceImpl.java
| ... | ... | @@ -616,8 +616,8 @@ public class FormsServiceImpl implements FormsService { |
| 616 | 616 | tu.setRq(rq); |
| 617 | 617 | tu.setGs(arg0.getString("gs_name").toString()); |
| 618 | 618 | tu.setZhgs(arg0.getString("fgs_name").toString()); |
| 619 | - //tu.setXl(arg0.getString("xlgs"));这个是根据公司判断线路有几条 | |
| 620 | - tu.setXl(arg0.getString("sxl")); | |
| 619 | + tu.setXl(arg0.getString("xlgs"));//这个是根据公司判断线路有几条 | |
| 620 | + //tu.setXl(arg0.getString("sxl")); | |
| 621 | 621 | tu.setXlmc(arg0.getString("sxl")); |
| 622 | 622 | tu.setCchjh(arg0.getString("jcl").toString()); |
| 623 | 623 | tu.setCchsj(arg0.getString("scl").toString()); | ... | ... |
src/main/resources/application-dev.properties
| ... | ... | @@ -7,13 +7,13 @@ spring.jpa.hibernate.naming_strategy= org.hibernate.cfg.ImprovedNamingStrategy |
| 7 | 7 | #DATABASE |
| 8 | 8 | spring.jpa.database= MYSQL |
| 9 | 9 | spring.jpa.show-sql= true |
| 10 | -spring.datasource.driver-class-name= com.mysql.jdbc.Driver | |
| 11 | -spring.datasource.url= jdbc:mysql://127.0.0.1/qp_control?useUnicode=true&characterEncoding=utf-8&useSSL=false | |
| 12 | -spring.datasource.username= root | |
| 13 | -spring.datasource.password= | |
| 14 | -#spring.datasource.url= jdbc:mysql://192.168.168.117/pd_control?useUnicode=true&characterEncoding=utf-8&useSSL=false | |
| 10 | +#spring.datasource.driver-class-name= com.mysql.jdbc.Driver | |
| 11 | +#spring.datasource.url= jdbc:mysql://192.168.168.201/mh_control?useUnicode=true&characterEncoding=utf-8&useSSL=false | |
| 15 | 12 | #spring.datasource.username= root |
| 16 | -#spring.datasource.password= root | |
| 13 | +#spring.datasource.password= 123456 | |
| 14 | +spring.datasource.url= jdbc:mysql://localhost/mh_control?useUnicode=true&characterEncoding=utf-8&useSSL=false | |
| 15 | +spring.datasource.username= root | |
| 16 | +spring.datasource.password= root | |
| 17 | 17 | #DATASOURCE |
| 18 | 18 | spring.datasource.max-active=100 |
| 19 | 19 | spring.datasource.max-idle=8 | ... | ... |
src/main/resources/ms-jdbc.properties
| ... | ... | @@ -4,6 +4,6 @@ |
| 4 | 4 | #ms.mysql.password= 123456 |
| 5 | 5 | |
| 6 | 6 | ms.mysql.driver= com.mysql.jdbc.Driver |
| 7 | -ms.mysql.url= jdbc:mysql://192.168.168.171:3306/ms?useUnicode=true&characterEncoding=utf-8 | |
| 7 | +ms.mysql.url= jdbc:mysql://192.168.168.117:3306/ms?useUnicode=true&characterEncoding=utf-8 | |
| 8 | 8 | ms.mysql.username= root |
| 9 | -ms.mysql.password= root2jsp | |
| 10 | 9 | \ No newline at end of file |
| 10 | +ms.mysql.password= root | |
| 11 | 11 | \ No newline at end of file | ... | ... |
src/main/resources/static/pages/forms/mould/allline.xls
No preview for this file type
src/main/resources/static/pages/forms/mould/executionrate.xls
No preview for this file type
src/main/resources/static/pages/forms/mould/turnoutrate.xls
No preview for this file type
src/main/resources/static/real_control_v2/fragments/north/nav/signal_state_config.html
| 1 | -<div class="uk-modal ct-form-modal" id="signal_state_config-modal"> | |
| 2 | - <div class="uk-modal-dialog" style="width: 530px;"> | |
| 3 | - <a href="" class="uk-modal-close uk-close"></a> | |
| 4 | - <div class="uk-modal-header"> | |
| 5 | - <h2>信号标记设置</h2></div> | |
| 6 | - | |
| 7 | - <p style="border-bottom: 1px solid #efefef;color: grey;padding-bottom: 9px;"> | |
| 8 | - <small> | |
| 9 | - <i class="uk-icon-question-circle"> </i> | |
| 10 | - 设置项将会保存在本地客户端,清理缓存和更换电脑会重置.</small> | |
| 11 | - </p> | |
| 12 | - <form class="uk-form uk-form-horizontal"> | |
| 13 | - <div class="uk-grid"> | |
| 14 | - <div class="uk-width-2-3 uk-container-center"> | |
| 15 | - <div class="uk-form-row"> | |
| 16 | - <label class="uk-form-label">是否启用</label> | |
| 17 | - <div class="uk-form-controls"> | |
| 18 | - <select name="enable"> | |
| 19 | - <option value="1">启用</option> | |
| 20 | - <option value="0">禁用</option> | |
| 21 | - </select> | |
| 22 | - </div> | |
| 23 | - </div> | |
| 24 | - </div> | |
| 25 | - </div> | |
| 26 | - | |
| 27 | - <div class="uk-modal-footer uk-text-right" style="margin-bottom: -20px;"> | |
| 28 | - <button type="button" class="uk-button uk-modal-close">取消</button> | |
| 29 | - <button type="submit" class="uk-button uk-button-primary"><i class="uk-icon-check"></i> 保存</button> | |
| 30 | - </div> | |
| 31 | - </form> | |
| 32 | - </div> | |
| 33 | - | |
| 34 | - <script> | |
| 35 | - (function() { | |
| 36 | - var modal = '#signal_state_config-modal'; | |
| 37 | - var f = $('form', modal); | |
| 38 | - | |
| 39 | - $(modal).on('init', function(e, data) { | |
| 40 | - var val = gb_signal_state.isEnable()?1:0; | |
| 41 | - $('[name=enable]', f).val(val); | |
| 42 | - }); | |
| 43 | - | |
| 44 | - f.formValidation(gb_form_validation_opts); | |
| 45 | - f.on('success.form.fv', function(e) { | |
| 46 | - e.preventDefault(); | |
| 47 | - var data = $(this).serializeJSON(); | |
| 48 | - | |
| 49 | - if(data.enable=='1') | |
| 50 | - gb_signal_state.enable(); | |
| 51 | - else | |
| 52 | - gb_signal_state.disable(); | |
| 53 | - | |
| 54 | - UIkit.modal(modal).hide(); | |
| 55 | - }); | |
| 56 | - | |
| 57 | - })(); | |
| 58 | - </script> | |
| 1 | +<div class="uk-modal ct-form-modal" id="signal_state_config-modal"> | |
| 2 | + <div class="uk-modal-dialog" style="width: 530px;"> | |
| 3 | + <a href="" class="uk-modal-close uk-close"></a> | |
| 4 | + <div class="uk-modal-header"> | |
| 5 | + <h2>信号标记设置</h2></div> | |
| 6 | + | |
| 7 | + <p style="border-bottom: 1px solid #efefef;color: grey;padding-bottom: 9px;"> | |
| 8 | + <small> | |
| 9 | + <i class="uk-icon-question-circle"> </i> | |
| 10 | + 设置项将会保存在本地客户端,清理缓存和更换电脑会重置.</small> | |
| 11 | + </p> | |
| 12 | + <form class="uk-form uk-form-horizontal"> | |
| 13 | + <div class="uk-grid"> | |
| 14 | + <div class="uk-width-2-3 uk-container-center"> | |
| 15 | + <div class="uk-form-row"> | |
| 16 | + <label class="uk-form-label">是否启用</label> | |
| 17 | + <div class="uk-form-controls"> | |
| 18 | + <select name="enable"> | |
| 19 | + <option value="1">启用</option> | |
| 20 | + <option value="0">禁用</option> | |
| 21 | + </select> | |
| 22 | + </div> | |
| 23 | + </div> | |
| 24 | + </div> | |
| 25 | + </div> | |
| 26 | + | |
| 27 | + <div class="uk-modal-footer uk-text-right" style="margin-bottom: -20px;"> | |
| 28 | + <button type="button" class="uk-button uk-modal-close">取消</button> | |
| 29 | + <button type="submit" class="uk-button uk-button-primary"><i class="uk-icon-check"></i> 保存</button> | |
| 30 | + </div> | |
| 31 | + </form> | |
| 32 | + </div> | |
| 33 | + | |
| 34 | + <script> | |
| 35 | + (function() { | |
| 36 | + var modal = '#signal_state_config-modal'; | |
| 37 | + var f = $('form', modal); | |
| 38 | + | |
| 39 | + $(modal).on('init', function(e, data) { | |
| 40 | + var val = gb_signal_state.isEnable()?1:0; | |
| 41 | + $('[name=enable]', f).val(val); | |
| 42 | + }); | |
| 43 | + | |
| 44 | + f.formValidation(gb_form_validation_opts); | |
| 45 | + f.on('success.form.fv', function(e) { | |
| 46 | + e.preventDefault(); | |
| 47 | + var data = $(this).serializeJSON(); | |
| 48 | + | |
| 49 | + if(data.enable=='1') | |
| 50 | + gb_signal_state.enable(); | |
| 51 | + else | |
| 52 | + gb_signal_state.disable(); | |
| 53 | + | |
| 54 | + UIkit.modal(modal).hide(); | |
| 55 | + }); | |
| 56 | + | |
| 57 | + })(); | |
| 58 | + </script> | |
| 59 | 59 | </div> |
| 60 | 60 | \ No newline at end of file | ... | ... |
src/main/resources/static/real_control_v2/js/signal_state/signal_state.js
| 1 | -/** | |
| 2 | - * GPS信号状态 | |
| 3 | - * @type {{}} | |
| 4 | - */ | |
| 5 | -var gb_signal_state = (function () { | |
| 6 | - var storage = window.localStorage; | |
| 7 | - | |
| 8 | - $(document).on('click', 'i.signal_state_icon', function (e) { | |
| 9 | - e.stopPropagation(); | |
| 10 | - }); | |
| 11 | - | |
| 12 | - var signal_state_data = {}; | |
| 13 | - var enable = true; | |
| 14 | - //读取本地状态 | |
| 15 | - var locStatus = storage.getItem("signal_state_enable"); | |
| 16 | - if (locStatus && locStatus=='0') | |
| 17 | - enable = false; | |
| 18 | - | |
| 19 | - var init = function () { | |
| 20 | - $.get('/signalState/multi', {idx: gb_data_basic.line_idx}, function (rs) { | |
| 21 | - //按班次ID分组 | |
| 22 | - signal_state_data = gb_common.groupBy(rs, 'schId'); | |
| 23 | - | |
| 24 | - for (var schId in signal_state_data) { | |
| 25 | - multi_render(signal_state_data[schId]); | |
| 26 | - } | |
| 27 | - }); | |
| 28 | - }; | |
| 29 | - | |
| 30 | - var multi_render = function (list) { | |
| 31 | - if (!enable) | |
| 32 | - return; | |
| 33 | - | |
| 34 | - if (!list || list.length == 0) | |
| 35 | - return; | |
| 36 | - var line = list[0].lineCode | |
| 37 | - , schId = list[0].schId; | |
| 38 | - | |
| 39 | - var sch = gb_schedule_table.findScheduleByLine(line)[schId]; | |
| 40 | - var dl = gb_schedule_table.getDl(sch); | |
| 41 | - var icon = 'question-circle'; | |
| 42 | - var t = ''; | |
| 43 | - $.each(list, function () { | |
| 44 | - t += (this.text + '<br>'); | |
| 45 | - }); | |
| 46 | - | |
| 47 | - if (list.length == 1 && list[0].type == 'route_reverse') | |
| 48 | - icon = 'reply'; | |
| 49 | - | |
| 50 | - var dd = $('dd.fcsjActualCell', dl); | |
| 51 | - var se = $('i.signal_state_icon', dd); | |
| 52 | - if (se && se.length > 0) | |
| 53 | - se.remove(); | |
| 54 | - | |
| 55 | - dd.append('<i data-uk-tooltip title="' + t + '" class="uk-icon-' + icon + ' signal_state_icon"></i>'); | |
| 56 | - }; | |
| 57 | - | |
| 58 | - var put = function (obj) { | |
| 59 | - if (!signal_state_data[obj.schId]) { | |
| 60 | - signal_state_data[obj.schId] = []; | |
| 61 | - } | |
| 62 | - | |
| 63 | - signal_state_data[obj.schId].push(obj); | |
| 64 | - multi_render(signal_state_data[obj.schId]); | |
| 65 | - }; | |
| 66 | - | |
| 67 | - var marker_sch = function (sch) { | |
| 68 | - var list = signal_state_data[sch.id]; | |
| 69 | - if (list) { | |
| 70 | - multi_render(list); | |
| 71 | - } | |
| 72 | - }; | |
| 73 | - | |
| 74 | - var clearAll = function () { | |
| 75 | - $('.signal_state_icon').remove(); | |
| 76 | - }; | |
| 77 | - | |
| 78 | - return { | |
| 79 | - init: init, | |
| 80 | - put: put, | |
| 81 | - marker_sch: marker_sch, | |
| 82 | - isEnable: function () { | |
| 83 | - return enable; | |
| 84 | - }, | |
| 85 | - disable: function () { | |
| 86 | - enable = false; | |
| 87 | - storage.setItem("signal_state_enable", 0); | |
| 88 | - | |
| 89 | - clearAll(); | |
| 90 | - }, | |
| 91 | - enable: function () { | |
| 92 | - enable = true; | |
| 93 | - storage.setItem("signal_state_enable", 1); | |
| 94 | - for (var schId in signal_state_data) { | |
| 95 | - multi_render(signal_state_data[schId]); | |
| 96 | - } | |
| 97 | - } | |
| 98 | - }; | |
| 1 | +/** | |
| 2 | + * GPS信号状态 | |
| 3 | + * @type {{}} | |
| 4 | + */ | |
| 5 | +var gb_signal_state = (function () { | |
| 6 | + var storage = window.localStorage; | |
| 7 | + | |
| 8 | + $(document).on('click', 'i.signal_state_icon', function (e) { | |
| 9 | + e.stopPropagation(); | |
| 10 | + }); | |
| 11 | + | |
| 12 | + var signal_state_data = {}; | |
| 13 | + var enable = true; | |
| 14 | + //读取本地状态 | |
| 15 | + var locStatus = storage.getItem("signal_state_enable"); | |
| 16 | + if (locStatus && locStatus=='0') | |
| 17 | + enable = false; | |
| 18 | + | |
| 19 | + var init = function () { | |
| 20 | + $.get('/signalState/multi', {idx: gb_data_basic.line_idx}, function (rs) { | |
| 21 | + //按班次ID分组 | |
| 22 | + signal_state_data = gb_common.groupBy(rs, 'schId'); | |
| 23 | + | |
| 24 | + for (var schId in signal_state_data) { | |
| 25 | + multi_render(signal_state_data[schId]); | |
| 26 | + } | |
| 27 | + }); | |
| 28 | + }; | |
| 29 | + | |
| 30 | + var multi_render = function (list) { | |
| 31 | + if (!enable) | |
| 32 | + return; | |
| 33 | + | |
| 34 | + if (!list || list.length == 0) | |
| 35 | + return; | |
| 36 | + var line = list[0].lineCode | |
| 37 | + , schId = list[0].schId; | |
| 38 | + | |
| 39 | + var sch = gb_schedule_table.findScheduleByLine(line)[schId]; | |
| 40 | + var dl = gb_schedule_table.getDl(sch); | |
| 41 | + var icon = 'question-circle'; | |
| 42 | + var t = ''; | |
| 43 | + $.each(list, function () { | |
| 44 | + t += (this.text + '<br>'); | |
| 45 | + }); | |
| 46 | + | |
| 47 | + if (list.length == 1 && list[0].type == 'route_reverse') | |
| 48 | + icon = 'reply'; | |
| 49 | + | |
| 50 | + var dd = $('dd.fcsjActualCell', dl); | |
| 51 | + var se = $('i.signal_state_icon', dd); | |
| 52 | + if (se && se.length > 0) | |
| 53 | + se.remove(); | |
| 54 | + | |
| 55 | + dd.append('<i data-uk-tooltip title="' + t + '" class="uk-icon-' + icon + ' signal_state_icon"></i>'); | |
| 56 | + }; | |
| 57 | + | |
| 58 | + var put = function (obj) { | |
| 59 | + if (!signal_state_data[obj.schId]) { | |
| 60 | + signal_state_data[obj.schId] = []; | |
| 61 | + } | |
| 62 | + | |
| 63 | + signal_state_data[obj.schId].push(obj); | |
| 64 | + multi_render(signal_state_data[obj.schId]); | |
| 65 | + }; | |
| 66 | + | |
| 67 | + var marker_sch = function (sch) { | |
| 68 | + var list = signal_state_data[sch.id]; | |
| 69 | + if (list) { | |
| 70 | + multi_render(list); | |
| 71 | + } | |
| 72 | + }; | |
| 73 | + | |
| 74 | + var clearAll = function () { | |
| 75 | + $('.signal_state_icon').remove(); | |
| 76 | + }; | |
| 77 | + | |
| 78 | + return { | |
| 79 | + init: init, | |
| 80 | + put: put, | |
| 81 | + marker_sch: marker_sch, | |
| 82 | + isEnable: function () { | |
| 83 | + return enable; | |
| 84 | + }, | |
| 85 | + disable: function () { | |
| 86 | + enable = false; | |
| 87 | + storage.setItem("signal_state_enable", 0); | |
| 88 | + | |
| 89 | + clearAll(); | |
| 90 | + }, | |
| 91 | + enable: function () { | |
| 92 | + enable = true; | |
| 93 | + storage.setItem("signal_state_enable", 1); | |
| 94 | + for (var schId in signal_state_data) { | |
| 95 | + multi_render(signal_state_data[schId]); | |
| 96 | + } | |
| 97 | + } | |
| 98 | + }; | |
| 99 | 99 | })(); |
| 100 | 100 | \ No newline at end of file | ... | ... |