Commit cad38b2c6241b3f2531f800d6929c8ca9ba3ea4a
Merge branch 'minhang' into qingpu
Showing
60 changed files
with
2487 additions
and
1107 deletions
Too many changes to show.
To preserve performance only 60 of 90 files are displayed.
src/main/java/com/bsth/controller/forms/ExportController.java
| ... | ... | @@ -13,8 +13,10 @@ import org.springframework.web.bind.annotation.RequestMethod; |
| 13 | 13 | import org.springframework.web.bind.annotation.RequestParam; |
| 14 | 14 | import org.springframework.web.bind.annotation.RestController; |
| 15 | 15 | |
| 16 | +import com.bsth.data.BasicData; | |
| 16 | 17 | import com.bsth.entity.mcy_forms.Allline; |
| 17 | 18 | import com.bsth.entity.mcy_forms.Changetochange; |
| 19 | +import com.bsth.entity.mcy_forms.Daily; | |
| 18 | 20 | import com.bsth.entity.mcy_forms.Executionrate; |
| 19 | 21 | import com.bsth.entity.mcy_forms.Linepasswengerflow; |
| 20 | 22 | import com.bsth.entity.mcy_forms.Operationservice; |
| ... | ... | @@ -231,7 +233,7 @@ public class ExportController { |
| 231 | 233 | listI.add(resList.iterator()); |
| 232 | 234 | String path = this.getClass().getResource("/").getPath() + "static\\pages\\forms\\"; |
| 233 | 235 | ee.excelReplace(listI, new Object[] { map }, path + "mould\\vehicleloading.xls", |
| 234 | - path + "export\\车辆加注" + sdfSimple.format(sdfMonth.parse(map.get("dat").toString())) + ".xls"); | |
| 236 | + path + "export\\车辆加注" + sdfSimple.format(sdfMonth.parse(map.get("data").toString())) + ".xls"); | |
| 235 | 237 | } catch (Exception e) { |
| 236 | 238 | e.printStackTrace(); |
| 237 | 239 | } |
| ... | ... | @@ -319,8 +321,31 @@ public class ExportController { |
| 319 | 321 | List<Turnoutrate> turnoutrate = formsService.turnoutrate(map); |
| 320 | 322 | Map<String, Object> map1 = new HashMap<String, Object>(); |
| 321 | 323 | List<Map<String, Object>> resList = new ArrayList<Map<String, Object>>(); |
| 324 | + /*Float xlts=0f; | |
| 325 | + Float jh=0f; | |
| 326 | + Float sj=0f; | |
| 327 | + Float qz=0f; | |
| 328 | + Float ccl=0f; | |
| 329 | + Float bcjh=0f; | |
| 330 | + Float bcsj=0f; | |
| 331 | + Float bczxl=0f; | |
| 332 | + Float gs=0f; | |
| 333 | + Float zhgs=0f;*/ | |
| 334 | + | |
| 322 | 335 | for (Turnoutrate l : turnoutrate) { |
| 323 | 336 | Map<String, Object> m = new HashMap<String, Object>(); |
| 337 | + | |
| 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()); | |
| 344 | + 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()); | |
| 347 | + | |
| 348 | + */ | |
| 324 | 349 | m.put("rq", l.getRq()); |
| 325 | 350 | m.put("gs", l.getGs()); |
| 326 | 351 | m.put("zhgs", l.getZhgs()); |
| ... | ... | @@ -334,6 +359,19 @@ public class ExportController { |
| 334 | 359 | m.put("bbzxl", l.getBbzxl()); |
| 335 | 360 | m.put("sm", l.getSm()); |
| 336 | 361 | resList.add(m); |
| 362 | + | |
| 363 | + /*m=new HashMap<String,Object>(); | |
| 364 | + m.put("total_xlts", jh); | |
| 365 | + m.put("total_jh", jh); | |
| 366 | + 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); | |
| 371 | + m.put("total_bczxl", bczxl); | |
| 372 | + m.put("total_gs", gs); | |
| 373 | + m.put("total_zhgs", zhgs); | |
| 374 | + */ | |
| 337 | 375 | } |
| 338 | 376 | |
| 339 | 377 | try { |
| ... | ... | @@ -356,8 +394,29 @@ public class ExportController { |
| 356 | 394 | List<Executionrate> executionrate = formsService.executionrate(map); |
| 357 | 395 | Map<String, Object> map1 = new HashMap<String, Object>(); |
| 358 | 396 | List<Map<String, Object>> resList = new ArrayList<Map<String, Object>>(); |
| 397 | + /* Float xlts=0f; | |
| 398 | + Float jh=0f; | |
| 399 | + Float sj=0f; | |
| 400 | + Float ccl=0f; | |
| 401 | + Float bcjh=0f; | |
| 402 | + Float bcsj=0f; | |
| 403 | + Float bczxl=0f; | |
| 404 | + Float gs=0f; | |
| 405 | + Float zhgs=0f;*/ | |
| 406 | + | |
| 359 | 407 | for (Executionrate l : executionrate) { |
| 360 | 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()); | |
| 415 | + 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()); | |
| 418 | + | |
| 419 | + */ | |
| 361 | 420 | m.put("rq", l.getRq()); |
| 362 | 421 | m.put("gs", l.getGs()); |
| 363 | 422 | m.put("zhgs", l.getZhgs()); |
| ... | ... | @@ -370,6 +429,19 @@ public class ExportController { |
| 370 | 429 | m.put("bbzxl", l.getBbzxl()); |
| 371 | 430 | m.put("sm", l.getSm()); |
| 372 | 431 | resList.add(m); |
| 432 | + | |
| 433 | + | |
| 434 | + /* m=new HashMap<String,Object>(); | |
| 435 | + 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);*/ | |
| 444 | + | |
| 373 | 445 | } |
| 374 | 446 | |
| 375 | 447 | try { |
| ... | ... | @@ -393,12 +465,31 @@ public class ExportController { |
| 393 | 465 | List<Allline> allline = formsService.allline(map); |
| 394 | 466 | Map<String, Object> map1 = new HashMap<String, Object>(); |
| 395 | 467 | List<Map<String, Object>> resList = new ArrayList<Map<String, Object>>(); |
| 468 | + /* Integer jh=0; | |
| 469 | + Integer sj=0; | |
| 470 | + Integer ccl=0; | |
| 471 | + Integer bcjh=0; | |
| 472 | + Float bcsj=0f; | |
| 473 | + Integer bczxl=0; | |
| 474 | + Integer gs=0; | |
| 475 | + Float zhgs=0f; | |
| 476 | + */ | |
| 396 | 477 | for (Allline l : allline) { |
| 397 | 478 | Map<String, Object> m = new HashMap<String, Object>(); |
| 479 | + | |
| 480 | + /*jh +=l.getGsgs()=="" ? 0: Integer.valueOf(l.getGsgs()); | |
| 481 | + sj +=l.getFgsgs()==""?0: Integer.valueOf(l.getFgsgs()); | |
| 482 | + 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()); | |
| 485 | + 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 | + */ | |
| 398 | 489 | m.put("rq", l.getRq()); |
| 399 | - m.put("gs", l.getGs()); | |
| 400 | - m.put("zhgs", l.getZhgs()); | |
| 401 | - m.put("xl", l.getXl()); | |
| 490 | + m.put("gs", l.getGsgs()); | |
| 491 | + m.put("zhgs", l.getFgsgs()); | |
| 492 | + //m.put("xl", l.getXl()); | |
| 402 | 493 | m.put("cchjh", l.getCchjh()); |
| 403 | 494 | m.put("cchsj", l.getCchsj()); |
| 404 | 495 | m.put("chl", l.getChl()); |
| ... | ... | @@ -407,6 +498,17 @@ public class ExportController { |
| 407 | 498 | m.put("bbzxl", l.getBbzxl()); |
| 408 | 499 | m.put("sm", l.getSm()); |
| 409 | 500 | resList.add(m); |
| 501 | + | |
| 502 | + /*m=new HashMap<String,Object>(); | |
| 503 | + m.put("total_jh", jh); | |
| 504 | + m.put("total_sj", sj); | |
| 505 | + m.put("total_ccl", ccl); | |
| 506 | + m.put("total_bcjh", bcjh); | |
| 507 | + m.put("total_bcsj", bcsj); | |
| 508 | + m.put("total_bczxl", bczxl); | |
| 509 | + m.put("total_gs", gs); | |
| 510 | + m.put("total_zhgs", zhgs); | |
| 511 | + */ | |
| 410 | 512 | } |
| 411 | 513 | |
| 412 | 514 | try { |
| ... | ... | @@ -422,6 +524,56 @@ public class ExportController { |
| 422 | 524 | |
| 423 | 525 | |
| 424 | 526 | |
| 527 | + //班次日报表 | |
| 528 | + @RequestMapping(value = "/dailyExport", method = RequestMethod.POST) | |
| 529 | + public List<Map<String, Object>> dailyExport(@RequestParam Map<String, Object> map) { | |
| 530 | + SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"), sdfSimple = new SimpleDateFormat("yyyyMMdd"); | |
| 531 | + List<Iterator<?>> listI = new ArrayList<Iterator<?>>(); | |
| 532 | + ReportUtils ee = new ReportUtils(); | |
| 533 | + List<Daily> allline = formsService.daily(map); | |
| 534 | + | |
| 535 | + List<Map<String, Object>> resList = new ArrayList<Map<String, Object>>(); | |
| 536 | + Float zgl=0f; | |
| 537 | + Float ks=0f; | |
| 538 | + Float yh=0f; | |
| 539 | + Float bc=0f; | |
| 540 | + Map<String, Object> m ; | |
| 541 | + for (Daily d : allline) { | |
| 542 | + m = new HashMap<String, Object>(); | |
| 543 | + zgl +=d.getZlc()==""?0f:Float.valueOf(d.getZlc()); | |
| 544 | + ks +=d.getJzl1()==""?0f:Float.valueOf(d.getJzl1()); | |
| 545 | + yh +=d.getYh()==""?0f:Float.valueOf(d.getYh()); | |
| 546 | + bc +=d.getBc()==""?0f:Float.valueOf(d.getBc()); | |
| 547 | + m.put("zbh", d.getZbh()); | |
| 548 | + m.put("jgh",d.getJgh()); | |
| 549 | + m.put("jName", d.getjName()); | |
| 550 | + m.put("zlc", d.getZlc()); | |
| 551 | + m.put("jzl1", d.getJzl1()); | |
| 552 | + m.put("yh", d.getYh()); | |
| 553 | + m.put("bc", d.getBc()); | |
| 554 | + | |
| 555 | + resList.add(m); | |
| 556 | + } | |
| 557 | + | |
| 558 | + m=new HashMap<String,Object>(); | |
| 559 | + m.put("total_zgl", zgl); | |
| 560 | + m.put("total_ks", ks); | |
| 561 | + m.put("total_yh", yh); | |
| 562 | + m.put("total_bc", bc); | |
| 563 | + | |
| 564 | + m.put("line", BasicData.lineCode2NameMap.get(map.get("line").toString())); | |
| 565 | + m.put("date", map.get("date").toString()); | |
| 566 | + try { | |
| 567 | + listI.add(resList.iterator()); | |
| 568 | + String path = this.getClass().getResource("/").getPath() + "static\\pages\\forms\\"; | |
| 569 | + ee.excelReplace(listI, new Object[] { m }, path + "mould\\daily.xls", path + "export\\班次日报表" | |
| 570 | + + sdfSimple.format(sdfMonth.parse(map.get("date").toString())) + ".xls"); | |
| 571 | + } catch (Exception e) { | |
| 572 | + e.printStackTrace(); | |
| 573 | + } | |
| 574 | + return resList; | |
| 575 | + } | |
| 576 | + | |
| 425 | 577 | |
| 426 | 578 | |
| 427 | 579 | } | ... | ... |
src/main/java/com/bsth/controller/forms/MCY_FormsController.java
| ... | ... | @@ -11,6 +11,7 @@ import org.springframework.web.bind.annotation.RestController; |
| 11 | 11 | |
| 12 | 12 | import com.bsth.entity.mcy_forms.Allline; |
| 13 | 13 | import com.bsth.entity.mcy_forms.Changetochange; |
| 14 | +import com.bsth.entity.mcy_forms.Daily; | |
| 14 | 15 | import com.bsth.entity.mcy_forms.Executionrate; |
| 15 | 16 | import com.bsth.entity.mcy_forms.Linepasswengerflow; |
| 16 | 17 | import com.bsth.entity.mcy_forms.Operationservice; |
| ... | ... | @@ -112,4 +113,12 @@ public class MCY_FormsController { |
| 112 | 113 | |
| 113 | 114 | return formsService.allline(map); |
| 114 | 115 | } |
| 116 | + | |
| 117 | + // 营运线路名称统计表 | |
| 118 | + @RequestMapping(value = "/daily", method = RequestMethod.POST) | |
| 119 | + public List<Daily> daily(@RequestParam Map<String, Object> map) { | |
| 120 | + | |
| 121 | + return formsService.daily(map); | |
| 122 | + } | |
| 123 | + | |
| 115 | 124 | } | ... | ... |
src/main/java/com/bsth/controller/realcontrol/SignalStateController.java
0 → 100644
| 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/controller/report/ReportController.java
| ... | ... | @@ -64,6 +64,11 @@ public class ReportController { |
| 64 | 64 | return service.tbodyTime3(line, ttinfo); |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | + @RequestMapping(value = "/tbodyTime4", method = RequestMethod.GET) | |
| 68 | + public List<Map<String, Object>> tbodyTime4(@RequestParam String line,@RequestParam String ttinfo) { | |
| 69 | + return service.tbodyTime4(line, ttinfo); | |
| 70 | + } | |
| 71 | + | |
| 67 | 72 | @RequestMapping(value = "/tbodyTime5", method = RequestMethod.GET) |
| 68 | 73 | public List<Map<String, Object>> tbodyTime5(@RequestParam String line,@RequestParam String ttinfo) { |
| 69 | 74 | return service.tbodyTime5(line, ttinfo); | ... | ... |
src/main/java/com/bsth/data/BasicData.java
| ... | ... | @@ -13,6 +13,7 @@ import org.slf4j.Logger; |
| 13 | 13 | import org.slf4j.LoggerFactory; |
| 14 | 14 | import org.springframework.beans.factory.annotation.Autowired; |
| 15 | 15 | import org.springframework.boot.CommandLineRunner; |
| 16 | +import org.springframework.core.annotation.Order; | |
| 16 | 17 | import org.springframework.stereotype.Component; |
| 17 | 18 | |
| 18 | 19 | import java.util.*; |
| ... | ... | @@ -25,13 +26,14 @@ import java.util.concurrent.TimeUnit; |
| 25 | 26 | * @date 2016年8月10日 下午3:27:45 |
| 26 | 27 | */ |
| 27 | 28 | @Component |
| 29 | +@Order(value = 1) | |
| 28 | 30 | public class BasicData implements CommandLineRunner { |
| 29 | - | |
| 30 | - //公司代码和公司名对照(K: 公司编码,V:公司名) | |
| 31 | - public static Map<String, String> businessCodeNameMap; | |
| 32 | - | |
| 33 | - //分公司公司代码和分公司公司名对照(K: 公司编码+分公司编码,V:分公司公司名) | |
| 34 | - public static Map<String, String> businessFgsCodeNameMap; | |
| 31 | + | |
| 32 | + //公司代码和公司名对照(K: 公司编码,V:公司名) | |
| 33 | + public static Map<String, String> businessCodeNameMap; | |
| 34 | + | |
| 35 | + //分公司公司代码和分公司公司名对照(K: 公司编码+分公司编码,V:分公司公司名) | |
| 36 | + public static Map<String, String> businessFgsCodeNameMap; | |
| 35 | 37 | |
| 36 | 38 | //设备号和车辆自编号 (K: 设备编码 ,V:车辆自编号) |
| 37 | 39 | public static BiMap<String, String> deviceId2NbbmMap; |
| ... | ... | @@ -39,27 +41,21 @@ public class BasicData implements CommandLineRunner { |
| 39 | 41 | //车辆自编号和公司代码对照 (K: 车辆自编号 ,V:公司代码) |
| 40 | 42 | public static Map<String, String> nbbm2CompanyCodeMap; |
| 41 | 43 | |
| 42 | - //站点编码和名称对照,包括停车场 (K: 站点编码 ,V:站点名称) | |
| 44 | + //站点编码和名称对照,包括停车场 (K: lineCode_updown_stationCode ,V:站点名称) | |
| 43 | 45 | public static Map<String, String> stationCode2NameMap; |
| 44 | 46 | |
| 45 | 47 | //线路起终点对照(线路编码_上下行_起终点) 1024_0_B (1024上行起点) |
| 46 | - public static Map<String, String> lineSEPointMap; | |
| 48 | + //public static Map<String, String> lineSEPointMap; | |
| 47 | 49 | |
| 48 | 50 | //车辆和线路对照 |
| 49 | 51 | public static Map<String, Line> nbbm2LineMap; |
| 50 | 52 | |
| 51 | - //线路和用户对照 用于webSocket定向推送消息(用户进入线调时写入数据) | |
| 52 | - //public static TreeMultimap<String, String> lineCode2SocketUserMap = TreeMultimap.create(); | |
| 53 | - | |
| 54 | 53 | //线路ID和code 对照 |
| 55 | 54 | public static BiMap<Integer, String> lineId2CodeMap; |
| 56 | 55 | |
| 57 | 56 | //线路编码和名称对照 |
| 58 | 57 | public static Map<String, String> lineCode2NameMap; |
| 59 | 58 | |
| 60 | - //线路编码_站点编码 == 0|1 上下行 | |
| 61 | - //public static Map<String, Integer> lineStationUpDownMap; | |
| 62 | - | |
| 63 | 59 | //停车场 |
| 64 | 60 | public static List<String> parkCodeList; |
| 65 | 61 | |
| ... | ... | @@ -77,7 +73,7 @@ public class BasicData implements CommandLineRunner { |
| 77 | 73 | public static Map<String, String> allPerson; |
| 78 | 74 | |
| 79 | 75 | //站点名和运管处编号 对照 |
| 80 | - public static Map<String,Integer> stationName2YgcNumber; | |
| 76 | + public static Map<String, Integer> stationName2YgcNumber; | |
| 81 | 77 | |
| 82 | 78 | |
| 83 | 79 | static Logger logger = LoggerFactory.getLogger(BasicData.class); |
| ... | ... | @@ -87,7 +83,7 @@ public class BasicData implements CommandLineRunner { |
| 87 | 83 | |
| 88 | 84 | @Override |
| 89 | 85 | public void run(String... arg0) throws Exception { |
| 90 | - Application.mainServices.scheduleWithFixedDelay(dataLoader, 2, 2, TimeUnit.HOURS); | |
| 86 | + Application.mainServices.scheduleWithFixedDelay(dataLoader, 0, 2, TimeUnit.HOURS); | |
| 91 | 87 | } |
| 92 | 88 | |
| 93 | 89 | |
| ... | ... | @@ -114,7 +110,7 @@ public class BasicData implements CommandLineRunner { |
| 114 | 110 | |
| 115 | 111 | @Autowired |
| 116 | 112 | PersonnelRepository personnelRepository; |
| 117 | - | |
| 113 | + | |
| 118 | 114 | @Autowired |
| 119 | 115 | BusinessRepository businessRepository; |
| 120 | 116 | |
| ... | ... | @@ -156,47 +152,24 @@ public class BasicData implements CommandLineRunner { |
| 156 | 152 | return 0; |
| 157 | 153 | } |
| 158 | 154 | |
| 159 | - | |
| 160 | -/* private void loadStationRouteInfo() { | |
| 161 | - Iterator<StationRoute> iterator = stationRouteRepository.findAllEffective().iterator(); | |
| 162 | - | |
| 163 | - Map<String, String> sePointMap = new HashMap<>(); | |
| 164 | - //lineSEPointMap | |
| 165 | - Map<String, Integer> map = new HashMap<>(); | |
| 166 | - | |
| 167 | - StationRoute route; | |
| 168 | - while (iterator.hasNext()) { | |
| 169 | - route = iterator.next(); | |
| 170 | - map.put(route.getLineCode() + "_" + route.getStationCode(), route.getDirections()); | |
| 171 | - | |
| 172 | - if (route.getStationMark() != null && | |
| 173 | - (route.getStationMark().equals("B") || route.getStationMark().equals("E"))) { | |
| 174 | - sePointMap.put(route.getLineCode() + "_" | |
| 175 | - + route.getDirections() | |
| 176 | - + "_" + route.getStationMark(), route.getStationCode()); | |
| 177 | - } | |
| 178 | - } | |
| 179 | - lineStationUpDownMap = map; | |
| 180 | - lineSEPointMap = sePointMap; | |
| 181 | - }*/ | |
| 182 | - | |
| 183 | 155 | /** |
| 184 | 156 | * loadBusinessInfo |
| 185 | 157 | * (公司代码公司名对照) |
| 186 | 158 | */ |
| 187 | - public void loadBusinessInfo(){ | |
| 188 | - Map<String, String> businessMap=new HashMap<String,String>(); | |
| 189 | - Map<String, String> businessFgsMap=new HashMap<String,String>(); | |
| 190 | - Iterator<Business> busIter=businessRepository.findAll().iterator(); | |
| 191 | - Business t; | |
| 192 | - while(busIter.hasNext()){ | |
| 193 | - t=busIter.next(); | |
| 194 | - businessMap.put(t.getBusinessCode(), t.getBusinessName()); | |
| 195 | - businessFgsMap.put(t.getBusinessCode()+"_"+t.getUpCode(), t.getBusinessName()); | |
| 196 | - } | |
| 197 | - businessCodeNameMap=businessMap; | |
| 198 | - businessFgsCodeNameMap=businessFgsMap; | |
| 159 | + public void loadBusinessInfo() { | |
| 160 | + Map<String, String> businessMap = new HashMap<String, String>(); | |
| 161 | + Map<String, String> businessFgsMap = new HashMap<String, String>(); | |
| 162 | + Iterator<Business> busIter = businessRepository.findAll().iterator(); | |
| 163 | + Business t; | |
| 164 | + while (busIter.hasNext()) { | |
| 165 | + t = busIter.next(); | |
| 166 | + businessMap.put(t.getBusinessCode(), t.getBusinessName()); | |
| 167 | + businessFgsMap.put(t.getBusinessCode() + "_" + t.getUpCode(), t.getBusinessName()); | |
| 168 | + } | |
| 169 | + businessCodeNameMap = businessMap; | |
| 170 | + businessFgsCodeNameMap = businessFgsMap; | |
| 199 | 171 | } |
| 172 | + | |
| 200 | 173 | /** |
| 201 | 174 | * @Title: loadDeviceInfo |
| 202 | 175 | * @Description: TODO(加载设备相关信息) |
| ... | ... | @@ -223,13 +196,13 @@ public class BasicData implements CommandLineRunner { |
| 223 | 196 | */ |
| 224 | 197 | public void loadStationInfo() { |
| 225 | 198 | Map<String, String> stationCode2Name = new HashMap<>(); |
| 226 | - Iterator<Station> iterator = stationRepository.findAll().iterator(); | |
| 227 | - //站点 | |
| 228 | - Station station; | |
| 199 | + Iterator<StationRoute> iterator = stationRouteRepository.findAll().iterator(); | |
| 200 | + StationRoute sroute; | |
| 229 | 201 | while (iterator.hasNext()) { |
| 230 | - station = iterator.next(); | |
| 231 | - stationCode2Name.put(station.getStationCod(), station.getStationName()); | |
| 202 | + sroute = iterator.next(); | |
| 203 | + stationCode2Name.put(sroute.getLineCode() + "_" + sroute.getDirections() + "_" + sroute.getStationCode(), sroute.getStationName()); | |
| 232 | 204 | } |
| 205 | + | |
| 233 | 206 | //停车场 |
| 234 | 207 | Iterator<CarPark> iterator2 = carParkRepository.findAll().iterator(); |
| 235 | 208 | |
| ... | ... | @@ -266,7 +239,7 @@ public class BasicData implements CommandLineRunner { |
| 266 | 239 | * @Title: loadLineInfo |
| 267 | 240 | * @Description: TODO(加载线路相关信息) |
| 268 | 241 | */ |
| 269 | - public void loadLineInfo(){ | |
| 242 | + public void loadLineInfo() { | |
| 270 | 243 | Iterator<Line> iterator = lineRepository.findAll().iterator(); |
| 271 | 244 | |
| 272 | 245 | Line line; |
| ... | ... | @@ -276,36 +249,36 @@ public class BasicData implements CommandLineRunner { |
| 276 | 249 | Map<String, String> code2SHcode = new HashMap<String, String>(); |
| 277 | 250 | Map<String, Integer> tempStationName2YgcNumber = new HashMap<String, Integer>(); |
| 278 | 251 | |
| 279 | - while(iterator.hasNext()){ | |
| 252 | + while (iterator.hasNext()) { | |
| 280 | 253 | line = iterator.next(); |
| 281 | 254 | biMap.put(line.getId(), line.getLineCode()); |
| 282 | 255 | code2name.put(line.getLineCode(), line.getName()); |
| 283 | - id2SHcode.put(line.getId(),line.getShanghaiLinecode()); | |
| 256 | + id2SHcode.put(line.getId(), line.getShanghaiLinecode()); | |
| 284 | 257 | code2SHcode.put(line.getLineCode(), line.getShanghaiLinecode()); |
| 285 | 258 | |
| 286 | 259 | /** |
| 287 | 260 | * 加载运管处的站点及序号 |
| 288 | 261 | * 上行从1开始,下行顺序续编 |
| 289 | 262 | |
| 290 | - List<Object[]> ygcLines = stationRouteRepository.findAllLineWithYgc(); | |
| 291 | - if(ygcLines != null && ygcLines.size() > 0){ | |
| 292 | - int size = ygcLines.size(); | |
| 293 | - Object[] tempArray ; | |
| 294 | - int num = 1; | |
| 295 | - String key; | |
| 296 | - String lineCode = ""; | |
| 297 | - for (int i = 0; i < size; i ++){ | |
| 298 | - tempArray = ygcLines.get(i); | |
| 299 | - if(lineCode.equals("")){ | |
| 300 | - lineCode = tempArray[0]+""; | |
| 301 | - }else if(!lineCode.equals(tempArray[0]+"")){ | |
| 302 | - num = 1; | |
| 303 | - lineCode = tempArray[0]+""; | |
| 304 | - } | |
| 305 | - key = tempArray[0] + "_"+tempArray[1] + "_"+tempArray[2]; | |
| 306 | - tempStationName2YgcNumber.put(key,num++); | |
| 307 | - } | |
| 308 | - }*/ | |
| 263 | + List<Object[]> ygcLines = stationRouteRepository.findAllLineWithYgc(); | |
| 264 | + if(ygcLines != null && ygcLines.size() > 0){ | |
| 265 | + int size = ygcLines.size(); | |
| 266 | + Object[] tempArray ; | |
| 267 | + int num = 1; | |
| 268 | + String key; | |
| 269 | + String lineCode = ""; | |
| 270 | + for (int i = 0; i < size; i ++){ | |
| 271 | + tempArray = ygcLines.get(i); | |
| 272 | + if(lineCode.equals("")){ | |
| 273 | + lineCode = tempArray[0]+""; | |
| 274 | + }else if(!lineCode.equals(tempArray[0]+"")){ | |
| 275 | + num = 1; | |
| 276 | + lineCode = tempArray[0]+""; | |
| 277 | + } | |
| 278 | + key = tempArray[0] + "_"+tempArray[1] + "_"+tempArray[2]; | |
| 279 | + tempStationName2YgcNumber.put(key,num++); | |
| 280 | + } | |
| 281 | + }*/ | |
| 309 | 282 | } |
| 310 | 283 | |
| 311 | 284 | lineId2CodeMap = biMap; | ... | ... |
src/main/java/com/bsth/data/LineConfigData.java
| ... | ... | @@ -10,6 +10,7 @@ import org.slf4j.Logger; |
| 10 | 10 | import org.slf4j.LoggerFactory; |
| 11 | 11 | import org.springframework.beans.factory.annotation.Autowired; |
| 12 | 12 | import org.springframework.boot.CommandLineRunner; |
| 13 | +import org.springframework.core.annotation.Order; | |
| 13 | 14 | import org.springframework.stereotype.Component; |
| 14 | 15 | |
| 15 | 16 | import java.util.*; |
| ... | ... | @@ -23,6 +24,7 @@ import java.util.*; |
| 23 | 24 | * |
| 24 | 25 | */ |
| 25 | 26 | @Component |
| 27 | +@Order(value = 2) | |
| 26 | 28 | public class LineConfigData implements CommandLineRunner { |
| 27 | 29 | |
| 28 | 30 | Logger logger = LoggerFactory.getLogger(this.getClass()); | ... | ... |
src/main/java/com/bsth/data/gpsdata/GpsEntity.java
src/main/java/com/bsth/data/gpsdata/GpsRealData.java
| ... | ... | @@ -2,7 +2,6 @@ package com.bsth.data.gpsdata; |
| 2 | 2 | |
| 3 | 3 | import com.alibaba.fastjson.JSON; |
| 4 | 4 | import com.alibaba.fastjson.JSONObject; |
| 5 | -import com.bsth.Application; | |
| 6 | 5 | import com.bsth.data.BasicData; |
| 7 | 6 | import com.bsth.data.forecast.ForecastRealServer; |
| 8 | 7 | import com.bsth.data.gpsdata.arrival.GpsRealAnalyse; |
| ... | ... | @@ -26,7 +25,6 @@ import org.springframework.stereotype.Component; |
| 26 | 25 | import java.io.BufferedReader; |
| 27 | 26 | import java.io.InputStreamReader; |
| 28 | 27 | import java.util.*; |
| 29 | -import java.util.concurrent.TimeUnit; | |
| 30 | 28 | |
| 31 | 29 | /** |
| 32 | 30 | * @author PanZhao |
| ... | ... | @@ -67,12 +65,23 @@ public class GpsRealData implements CommandLineRunner { |
| 67 | 65 | |
| 68 | 66 | @Override |
| 69 | 67 | public void run(String... arg0) throws Exception { |
| 70 | - logger.info("gpsDataLoader,40,6"); | |
| 71 | - Application.mainServices.scheduleWithFixedDelay(gpsDataLoader, 40, 6, TimeUnit.SECONDS); | |
| 68 | + logger.info("gpsDataLoader,20,5"); | |
| 69 | + //Application.mainServices.scheduleWithFixedDelay(gpsDataLoader, 20, 6, TimeUnit.SECONDS); | |
| 72 | 70 | } |
| 73 | 71 | |
| 74 | 72 | public void put(GpsEntity gps) { |
| 75 | - gpsMap.put(gps.getDeviceId(), gps); | |
| 73 | + String device = gps.getDeviceId(); | |
| 74 | + gpsMap.put(device, gps); | |
| 75 | + | |
| 76 | + if (StringUtils.isNotBlank(gps.getLineId())){ | |
| 77 | + //站点名称 | |
| 78 | + gps.setStationName(getStationName(gps)); | |
| 79 | + lineCode2Devices.put(gps.getLineId(), device); | |
| 80 | + } | |
| 81 | + } | |
| 82 | + | |
| 83 | + public String getStationName(GpsEntity gps){ | |
| 84 | + return BasicData.stationCode2NameMap.get(gps.getLineId() + "_" + gps.getUpDown() + gps.getStopNo()); | |
| 76 | 85 | } |
| 77 | 86 | |
| 78 | 87 | /** |
| ... | ... | @@ -197,6 +206,8 @@ public class GpsRealData implements CommandLineRunner { |
| 197 | 206 | gps.setNbbm(nbbm); |
| 198 | 207 | //有更新的点位 |
| 199 | 208 | updateList.add(gps); |
| 209 | + //实时GPS数据集 | |
| 210 | + gpsRealData.put(gps); | |
| 200 | 211 | } |
| 201 | 212 | //分析数据 |
| 202 | 213 | gpsRealAnalyse.analyse(updateList); | ... | ... |
src/main/java/com/bsth/data/gpsdata/SignalStateData.java
0 → 100644
| 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
| ... | ... | @@ -29,8 +29,8 @@ public class GeoCacheData { |
| 29 | 29 | |
| 30 | 30 | static Logger logger = LoggerFactory.getLogger(GeoCacheData.class); |
| 31 | 31 | |
| 32 | - //每辆车缓存最后500条gps | |
| 33 | - private static final int CACHE_SIZE = 500; | |
| 32 | + //每辆车缓存最后1000条gps | |
| 33 | + private static final int CACHE_SIZE = 1000; | |
| 34 | 34 | private static Map<String, CircleQueue<GpsEntity>> gpsCacheMap = new HashMap<>(); |
| 35 | 35 | |
| 36 | 36 | //线路路段走向 |
| ... | ... | @@ -75,7 +75,7 @@ public class GeoCacheData { |
| 75 | 75 | } |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | - public static StationRoute getRouteCode(GpsEntity gps){ | |
| 78 | + public static StationRoute getRouteCode(GpsEntity gps) { | |
| 79 | 79 | return routeCodeMap.get(gps.getLineId() + "_" + gps.getUpDown() + "_" + gps.getStopNo()); |
| 80 | 80 | } |
| 81 | 81 | |
| ... | ... | @@ -94,6 +94,21 @@ public class GeoCacheData { |
| 94 | 94 | return null; |
| 95 | 95 | } |
| 96 | 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 | + | |
| 97 | 112 | public static Polygon getTccPolygon(String code) { |
| 98 | 113 | return tccMap.get(code); |
| 99 | 114 | } |
| ... | ... | @@ -191,4 +206,16 @@ public class GeoCacheData { |
| 191 | 206 | } |
| 192 | 207 | return cds; |
| 193 | 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 | + } | |
| 194 | 221 | } |
| 195 | 222 | \ No newline at end of file | ... | ... |
src/main/java/com/bsth/data/gpsdata/arrival/GpsRealAnalyse.java
| 1 | -package com.bsth.data.gpsdata.arrival; | |
| 2 | - | |
| 3 | -import com.bsth.data.gpsdata.GpsEntity; | |
| 4 | -import com.bsth.data.gpsdata.arrival.handlers.*; | |
| 5 | -import com.bsth.data.gpsdata.arrival.utils.CircleQueue; | |
| 6 | -import org.slf4j.Logger; | |
| 7 | -import org.slf4j.LoggerFactory; | |
| 8 | -import org.springframework.beans.factory.annotation.Autowired; | |
| 9 | -import org.springframework.stereotype.Component; | |
| 10 | - | |
| 11 | -import java.util.List; | |
| 12 | -import java.util.concurrent.CountDownLatch; | |
| 13 | -import java.util.concurrent.ExecutorService; | |
| 14 | -import java.util.concurrent.Executors; | |
| 15 | - | |
| 16 | -/** | |
| 17 | - * gps 实时数据分析 | |
| 18 | - * Created by panzhao on 2016/12/27. | |
| 19 | - */ | |
| 20 | -@Component | |
| 21 | -public class GpsRealAnalyse { | |
| 22 | - | |
| 23 | - Logger logger = LoggerFactory.getLogger(this.getClass()); | |
| 24 | - | |
| 25 | - @Autowired | |
| 26 | - OfflineSignalHandle offlineSignalHandle; | |
| 27 | - @Autowired | |
| 28 | - CorrectSignalHandle correctSignalHandle; | |
| 29 | - @Autowired | |
| 30 | - StationInsideHandle stationInsideHandle; | |
| 31 | - @Autowired | |
| 32 | - InOutStationSignalHandle inOutStationSignalHandle; | |
| 33 | - @Autowired | |
| 34 | - ReverseSignalHandle reverseSignalHandle; | |
| 35 | - | |
| 36 | - //50个线程 | |
| 37 | - static ExecutorService threadPool = Executors.newFixedThreadPool(50); | |
| 38 | - | |
| 39 | - public void analyse(List<GpsEntity> list) { | |
| 40 | - CountDownLatch count = new CountDownLatch(list.size()); | |
| 41 | - | |
| 42 | - for(GpsEntity gps : list) | |
| 43 | - threadPool.execute(new SignalHandleThread(gps, count)); | |
| 44 | - | |
| 45 | - try { | |
| 46 | - //等待子线程结束 | |
| 47 | - count.await(); | |
| 48 | - } catch (InterruptedException e) { | |
| 49 | - logger.error("", e); | |
| 50 | - } | |
| 51 | - } | |
| 52 | - | |
| 53 | - public class SignalHandleThread implements Runnable { | |
| 54 | - | |
| 55 | - GpsEntity gps; | |
| 56 | - CountDownLatch count; | |
| 57 | - | |
| 58 | - SignalHandleThread(GpsEntity gps, CountDownLatch count) { | |
| 59 | - this.gps = gps; | |
| 60 | - this.count = count; | |
| 61 | - } | |
| 62 | - | |
| 63 | - @Override | |
| 64 | - public void run() { | |
| 65 | - | |
| 66 | - try { | |
| 67 | - CircleQueue<GpsEntity> prevs = GeoCacheData.getGps(gps.getNbbm()); | |
| 68 | - //掉线处理 | |
| 69 | - offlineSignalHandle.handle(gps, prevs); | |
| 70 | - //状态处理 | |
| 71 | - if(!correctSignalHandle.handle(gps, prevs)) | |
| 72 | - return; | |
| 73 | - //场,站内外判断 | |
| 74 | - stationInsideHandle.handle(gps, prevs); | |
| 75 | - //反向处理 | |
| 76 | - reverseSignalHandle.handle(gps, prevs); | |
| 77 | - //进出站动作处理 | |
| 78 | - inOutStationSignalHandle.handle(gps, prevs); | |
| 79 | - GeoCacheData.putGps(gps); | |
| 80 | - | |
| 81 | - } catch (Exception e) { | |
| 82 | - logger.error("", e); | |
| 83 | - } finally { | |
| 84 | - count.countDown(); | |
| 85 | - } | |
| 86 | - } | |
| 87 | - } | |
| 88 | -} | |
| 1 | +package com.bsth.data.gpsdata.arrival; | |
| 2 | + | |
| 3 | +import com.bsth.data.gpsdata.GpsEntity; | |
| 4 | +import com.bsth.data.gpsdata.arrival.handlers.*; | |
| 5 | +import com.bsth.data.gpsdata.arrival.utils.CircleQueue; | |
| 6 | +import org.slf4j.Logger; | |
| 7 | +import org.slf4j.LoggerFactory; | |
| 8 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 9 | +import org.springframework.stereotype.Component; | |
| 10 | + | |
| 11 | +import java.util.List; | |
| 12 | +import java.util.concurrent.CountDownLatch; | |
| 13 | +import java.util.concurrent.ExecutorService; | |
| 14 | +import java.util.concurrent.Executors; | |
| 15 | + | |
| 16 | +/** | |
| 17 | + * gps 实时数据分析 | |
| 18 | + * Created by panzhao on 2016/12/27. | |
| 19 | + */ | |
| 20 | +@Component | |
| 21 | +public class GpsRealAnalyse { | |
| 22 | + | |
| 23 | + Logger logger = LoggerFactory.getLogger(this.getClass()); | |
| 24 | + | |
| 25 | + @Autowired | |
| 26 | + OfflineSignalHandle offlineSignalHandle; | |
| 27 | + @Autowired | |
| 28 | + CorrectSignalHandle correctSignalHandle; | |
| 29 | + @Autowired | |
| 30 | + StationInsideHandle stationInsideHandle; | |
| 31 | + @Autowired | |
| 32 | + InOutStationSignalHandle inOutStationSignalHandle; | |
| 33 | + @Autowired | |
| 34 | + ReverseSignalHandle reverseSignalHandle; | |
| 35 | + | |
| 36 | + //50个线程 | |
| 37 | + static ExecutorService threadPool = Executors.newFixedThreadPool(50); | |
| 38 | + | |
| 39 | + public void analyse(List<GpsEntity> list) { | |
| 40 | + CountDownLatch count = new CountDownLatch(list.size()); | |
| 41 | + | |
| 42 | + for(GpsEntity gps : list) | |
| 43 | + threadPool.execute(new SignalHandleThread(gps, count)); | |
| 44 | + | |
| 45 | + try { | |
| 46 | + //等待子线程结束 | |
| 47 | + count.await(); | |
| 48 | + } catch (InterruptedException e) { | |
| 49 | + logger.error("", e); | |
| 50 | + } | |
| 51 | + } | |
| 52 | + | |
| 53 | + public class SignalHandleThread implements Runnable { | |
| 54 | + | |
| 55 | + GpsEntity gps; | |
| 56 | + CountDownLatch count; | |
| 57 | + | |
| 58 | + SignalHandleThread(GpsEntity gps, CountDownLatch count) { | |
| 59 | + this.gps = gps; | |
| 60 | + this.count = count; | |
| 61 | + } | |
| 62 | + | |
| 63 | + @Override | |
| 64 | + public void run() { | |
| 65 | + | |
| 66 | + try { | |
| 67 | + CircleQueue<GpsEntity> prevs = GeoCacheData.getGps(gps.getNbbm()); | |
| 68 | + //掉线处理 | |
| 69 | + offlineSignalHandle.handle(gps, prevs); | |
| 70 | + //状态处理 | |
| 71 | + if(!correctSignalHandle.handle(gps, prevs)) | |
| 72 | + return; | |
| 73 | + //场,站内外判断 | |
| 74 | + stationInsideHandle.handle(gps, prevs); | |
| 75 | + //反向处理 | |
| 76 | + reverseSignalHandle.handle(gps, prevs); | |
| 77 | + //进出站动作处理 | |
| 78 | + inOutStationSignalHandle.handle(gps, prevs); | |
| 79 | + GeoCacheData.putGps(gps); | |
| 80 | + | |
| 81 | + } catch (Exception e) { | |
| 82 | + logger.error("", e); | |
| 83 | + } finally { | |
| 84 | + count.countDown(); | |
| 85 | + } | |
| 86 | + } | |
| 87 | + } | |
| 88 | +} | ... | ... |
src/main/java/com/bsth/data/gpsdata/arrival/SignalHandle.java
| 1 | 1 | package com.bsth.data.gpsdata.arrival; |
| 2 | 2 | |
| 3 | 3 | import com.bsth.data.gpsdata.GpsEntity; |
| 4 | +import com.bsth.data.gpsdata.arrival.entity.StationRoute; | |
| 4 | 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; | |
| 5 | 10 | |
| 6 | 11 | /** |
| 7 | 12 | * Created by panzhao on 2016/12/27. |
| ... | ... | @@ -14,64 +19,71 @@ public abstract class SignalHandle { |
| 14 | 19 | return prevs != null && prevs.size() > 0 && prevs.getTail() != null; |
| 15 | 20 | } |
| 16 | 21 | |
| 22 | + protected boolean isDriftSignal(GpsEntity gps) { | |
| 23 | + return gps.getLat() == 0 || gps.getLon() == 0; | |
| 24 | + } | |
| 25 | + | |
| 17 | 26 | /** |
| 18 | 27 | * 是不是异常信号 |
| 19 | 28 | * |
| 20 | 29 | * @param gps |
| 21 | - * @return | |
| 22 | - */ | |
| 23 | - protected boolean isAbnormal(GpsEntity gps) { | |
| 24 | - return gps.getLat() == 0 || gps.getLon() == 0; | |
| 25 | - } | |
| 30 | + * @return protected boolean isAbnormal(GpsEntity gps) { | |
| 31 | + return gps.getLat() == 0 || gps.getLon() == 0; | |
| 32 | + }*/ | |
| 26 | 33 | |
| 27 | 34 | /** |
| 28 | 35 | * 连续异常信号个数统计 |
| 29 | 36 | * |
| 30 | 37 | * @param prevs |
| 31 | - * @return | |
| 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 | + * } | |
| 32 | 57 | */ |
| 33 | - protected int abnormalCount(CircleQueue<GpsEntity> prevs) { | |
| 34 | - int count = 0; | |
| 35 | 58 | |
| 36 | - if (!isNotEmpty(prevs)) | |
| 37 | - return count; | |
| 38 | - | |
| 39 | - GpsEntity[] array = (GpsEntity[]) prevs.getQueue(); | |
| 40 | - GpsEntity gps; | |
| 41 | - for (int i = array.length - 1; i > 0; i--) { | |
| 42 | - gps = array[i]; | |
| 43 | - | |
| 44 | - if (isAbnormal(gps)) | |
| 45 | - count++; | |
| 46 | - else | |
| 47 | - break; | |
| 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()); | |
| 48 | 66 | } |
| 49 | - | |
| 50 | - return count; | |
| 51 | 67 | } |
| 52 | 68 | |
| 53 | 69 | /** |
| 54 | - * 车辆运行轨迹(最近20分钟) | |
| 55 | - * 0:上行 1:下行 -1:未知 | |
| 70 | + * 是否是从异常状态恢复的第一个信号 | |
| 56 | 71 | * |
| 57 | 72 | * @param gps |
| 73 | + * @param prevs | |
| 58 | 74 | * @return |
| 59 | 75 | */ |
| 60 | - protected int runTrack(GpsEntity gps, CircleQueue<GpsEntity> prevs) { | |
| 61 | - int rs = -1, count = 0; | |
| 62 | - | |
| 63 | - long et = gps.getTimestamp() - (1000 * 60 * 20); | |
| 64 | - Object[] array = prevs.getQueue(); | |
| 65 | - GpsEntity prev; | |
| 66 | - for(Object obj : array){ | |
| 67 | - prev = (GpsEntity) obj; | |
| 68 | - if(prev.getTimestamp() < et) | |
| 69 | - break; | |
| 70 | - | |
| 76 | + protected boolean abnormalRecovery(GpsEntity gps, CircleQueue<GpsEntity> prevs) { | |
| 77 | + if (prevs == null || prevs.size() == 0) | |
| 78 | + return false; | |
| 71 | 79 | |
| 80 | + GpsEntity prev = prevs.getTail(); | |
| 81 | + //从漂移状态恢复 | |
| 82 | + if (isDriftSignal(prev) | |
| 83 | + && !isDriftSignal(gps)) { | |
| 84 | + return true; | |
| 72 | 85 | } |
| 73 | - //for() | |
| 74 | - return 0; | |
| 75 | - } | |
| 76 | 86 | |
| 77 | -} | |
| 87 | + return false; | |
| 88 | + } | |
| 89 | +} | |
| 78 | 90 | \ No newline at end of file | ... | ... |
src/main/java/com/bsth/data/gpsdata/arrival/entity/RouteReverse.java
| ... | ... | @@ -5,6 +5,7 @@ package com.bsth.data.gpsdata.arrival.entity; |
| 5 | 5 | */ |
| 6 | 6 | public class RouteReverse { |
| 7 | 7 | |
| 8 | + private String nbbm; | |
| 8 | 9 | //反转个数 |
| 9 | 10 | private int count; |
| 10 | 11 | |
| ... | ... | @@ -14,18 +15,18 @@ public class RouteReverse { |
| 14 | 15 | //掉头站点 |
| 15 | 16 | private String turned; |
| 16 | 17 | |
| 17 | - //开始时间 | |
| 18 | - private long st; | |
| 19 | - | |
| 20 | 18 | //掉头时间 |
| 21 | 19 | private long zt; |
| 22 | 20 | |
| 23 | - //结束时间 | |
| 24 | - private long et; | |
| 21 | + //检测时间 | |
| 22 | + private long ct; | |
| 25 | 23 | |
| 26 | 24 | //是否闭合 |
| 27 | 25 | private boolean close; |
| 28 | 26 | |
| 27 | + //信号不明确 | |
| 28 | + private boolean vague; | |
| 29 | + | |
| 29 | 30 | public int getCount() { |
| 30 | 31 | return count; |
| 31 | 32 | } |
| ... | ... | @@ -50,22 +51,6 @@ public class RouteReverse { |
| 50 | 51 | this.turned = turned; |
| 51 | 52 | } |
| 52 | 53 | |
| 53 | - public long getSt() { | |
| 54 | - return st; | |
| 55 | - } | |
| 56 | - | |
| 57 | - public void setSt(long st) { | |
| 58 | - this.st = st; | |
| 59 | - } | |
| 60 | - | |
| 61 | - public long getEt() { | |
| 62 | - return et; | |
| 63 | - } | |
| 64 | - | |
| 65 | - public void setEt(long et) { | |
| 66 | - this.et = et; | |
| 67 | - } | |
| 68 | - | |
| 69 | 54 | public boolean isClose() { |
| 70 | 55 | return close; |
| 71 | 56 | } |
| ... | ... | @@ -81,4 +66,28 @@ public class RouteReverse { |
| 81 | 66 | public void setZt(long zt) { |
| 82 | 67 | this.zt = zt; |
| 83 | 68 | } |
| 84 | -} | |
| 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 | +} | |
| 85 | 94 | \ No newline at end of file | ... | ... |
src/main/java/com/bsth/data/gpsdata/arrival/entity/SignalAbnormal.java
0 → 100644
| 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
0 → 100644
| 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/entity/StationRoute.java
| 1 | -package com.bsth.data.gpsdata.arrival.entity; | |
| 2 | - | |
| 3 | -import com.vividsolutions.jts.geom.Point; | |
| 4 | -import com.vividsolutions.jts.geom.Polygon; | |
| 5 | - | |
| 6 | -/** | |
| 7 | - * Created by panzhao on 2016/12/23. | |
| 8 | - */ | |
| 9 | -public class StationRoute { | |
| 10 | - | |
| 11 | - /** | |
| 12 | - * 线路编码 | |
| 13 | - */ | |
| 14 | - private String lineCode; | |
| 15 | - | |
| 16 | - /** | |
| 17 | - * 上下行 | |
| 18 | - */ | |
| 19 | - private int directions; | |
| 20 | - | |
| 21 | - /** | |
| 22 | - * 站点编码 | |
| 23 | - */ | |
| 24 | - private String code; | |
| 25 | - | |
| 26 | - /** | |
| 27 | - * 路由顺序 | |
| 28 | - */ | |
| 29 | - private int routeSort; | |
| 30 | - | |
| 31 | - /** | |
| 32 | - * 站点位置 | |
| 33 | - */ | |
| 34 | - private Point point; | |
| 35 | - | |
| 36 | - /** | |
| 37 | - * 圆形半径 | |
| 38 | - */ | |
| 39 | - private Float radius; | |
| 40 | - | |
| 41 | - /** | |
| 42 | - * 多边形电子围栏 | |
| 43 | - */ | |
| 44 | - private Polygon polygon; | |
| 45 | - | |
| 46 | - /** | |
| 47 | - * 站点标记 | |
| 48 | - */ | |
| 49 | - private String mark; | |
| 50 | - | |
| 51 | - /** | |
| 52 | - * 下一站 | |
| 53 | - */ | |
| 54 | - private StationRoute next; | |
| 55 | - | |
| 56 | - /** | |
| 57 | - * 上一站 | |
| 58 | - */ | |
| 59 | - private StationRoute prve; | |
| 60 | - | |
| 61 | - private String name; | |
| 62 | - | |
| 63 | - public String getCode() { | |
| 64 | - return code; | |
| 65 | - } | |
| 66 | - | |
| 67 | - public void setCode(String code) { | |
| 68 | - this.code = code; | |
| 69 | - } | |
| 70 | - | |
| 71 | - public int getRouteSort() { | |
| 72 | - return routeSort; | |
| 73 | - } | |
| 74 | - | |
| 75 | - public void setRouteSort(int routeSort) { | |
| 76 | - this.routeSort = routeSort; | |
| 77 | - } | |
| 78 | - | |
| 79 | - public Point getPoint() { | |
| 80 | - return point; | |
| 81 | - } | |
| 82 | - | |
| 83 | - public void setPoint(Point point) { | |
| 84 | - this.point = point; | |
| 85 | - } | |
| 86 | - | |
| 87 | - public Float getRadius() { | |
| 88 | - return radius; | |
| 89 | - } | |
| 90 | - | |
| 91 | - public void setRadius(Float radius) { | |
| 92 | - this.radius = radius; | |
| 93 | - } | |
| 94 | - | |
| 95 | - public Polygon getPolygon() { | |
| 96 | - return polygon; | |
| 97 | - } | |
| 98 | - | |
| 99 | - public void setPolygon(Polygon polygon) { | |
| 100 | - this.polygon = polygon; | |
| 101 | - } | |
| 102 | - | |
| 103 | - public String getLineCode() { | |
| 104 | - return lineCode; | |
| 105 | - } | |
| 106 | - | |
| 107 | - public void setLineCode(String lineCode) { | |
| 108 | - this.lineCode = lineCode; | |
| 109 | - } | |
| 110 | - | |
| 111 | - public int getDirections() { | |
| 112 | - return directions; | |
| 113 | - } | |
| 114 | - | |
| 115 | - public void setDirections(int directions) { | |
| 116 | - this.directions = directions; | |
| 117 | - } | |
| 118 | - | |
| 119 | - public StationRoute getNext() { | |
| 120 | - return next; | |
| 121 | - } | |
| 122 | - | |
| 123 | - public void setNext(StationRoute next) { | |
| 124 | - this.next = next; | |
| 125 | - } | |
| 126 | - | |
| 127 | - public StationRoute getPrve() { | |
| 128 | - return prve; | |
| 129 | - } | |
| 130 | - | |
| 131 | - public void setPrve(StationRoute prve) { | |
| 132 | - this.prve = prve; | |
| 133 | - } | |
| 134 | - | |
| 135 | - public String getMark() { | |
| 136 | - return mark; | |
| 137 | - } | |
| 138 | - | |
| 139 | - public void setMark(String mark) { | |
| 140 | - this.mark = mark; | |
| 141 | - } | |
| 142 | - | |
| 143 | - public String getName() { | |
| 144 | - return name; | |
| 145 | - } | |
| 146 | - | |
| 147 | - public void setName(String name) { | |
| 148 | - this.name = name; | |
| 149 | - } | |
| 150 | -} | |
| 151 | - | |
| 1 | +package com.bsth.data.gpsdata.arrival.entity; | |
| 2 | + | |
| 3 | +import com.vividsolutions.jts.geom.Point; | |
| 4 | +import com.vividsolutions.jts.geom.Polygon; | |
| 5 | + | |
| 6 | +/** | |
| 7 | + * Created by panzhao on 2016/12/23. | |
| 8 | + */ | |
| 9 | +public class StationRoute { | |
| 10 | + | |
| 11 | + /** | |
| 12 | + * 线路编码 | |
| 13 | + */ | |
| 14 | + private String lineCode; | |
| 15 | + | |
| 16 | + /** | |
| 17 | + * 上下行 | |
| 18 | + */ | |
| 19 | + private int directions; | |
| 20 | + | |
| 21 | + /** | |
| 22 | + * 站点编码 | |
| 23 | + */ | |
| 24 | + private String code; | |
| 25 | + | |
| 26 | + /** | |
| 27 | + * 路由顺序 | |
| 28 | + */ | |
| 29 | + private int routeSort; | |
| 30 | + | |
| 31 | + /** | |
| 32 | + * 站点位置 | |
| 33 | + */ | |
| 34 | + private Point point; | |
| 35 | + | |
| 36 | + /** | |
| 37 | + * 圆形半径 | |
| 38 | + */ | |
| 39 | + private Float radius; | |
| 40 | + | |
| 41 | + /** | |
| 42 | + * 多边形电子围栏 | |
| 43 | + */ | |
| 44 | + private Polygon polygon; | |
| 45 | + | |
| 46 | + /** | |
| 47 | + * 站点标记 | |
| 48 | + */ | |
| 49 | + private String mark; | |
| 50 | + | |
| 51 | + /** | |
| 52 | + * 下一站 | |
| 53 | + */ | |
| 54 | + private StationRoute next; | |
| 55 | + | |
| 56 | + /** | |
| 57 | + * 上一站 | |
| 58 | + */ | |
| 59 | + private StationRoute prve; | |
| 60 | + | |
| 61 | + private String name; | |
| 62 | + | |
| 63 | + public String getCode() { | |
| 64 | + return code; | |
| 65 | + } | |
| 66 | + | |
| 67 | + public void setCode(String code) { | |
| 68 | + this.code = code; | |
| 69 | + } | |
| 70 | + | |
| 71 | + public int getRouteSort() { | |
| 72 | + return routeSort; | |
| 73 | + } | |
| 74 | + | |
| 75 | + public void setRouteSort(int routeSort) { | |
| 76 | + this.routeSort = routeSort; | |
| 77 | + } | |
| 78 | + | |
| 79 | + public Point getPoint() { | |
| 80 | + return point; | |
| 81 | + } | |
| 82 | + | |
| 83 | + public void setPoint(Point point) { | |
| 84 | + this.point = point; | |
| 85 | + } | |
| 86 | + | |
| 87 | + public Float getRadius() { | |
| 88 | + return radius; | |
| 89 | + } | |
| 90 | + | |
| 91 | + public void setRadius(Float radius) { | |
| 92 | + this.radius = radius; | |
| 93 | + } | |
| 94 | + | |
| 95 | + public Polygon getPolygon() { | |
| 96 | + return polygon; | |
| 97 | + } | |
| 98 | + | |
| 99 | + public void setPolygon(Polygon polygon) { | |
| 100 | + this.polygon = polygon; | |
| 101 | + } | |
| 102 | + | |
| 103 | + public String getLineCode() { | |
| 104 | + return lineCode; | |
| 105 | + } | |
| 106 | + | |
| 107 | + public void setLineCode(String lineCode) { | |
| 108 | + this.lineCode = lineCode; | |
| 109 | + } | |
| 110 | + | |
| 111 | + public int getDirections() { | |
| 112 | + return directions; | |
| 113 | + } | |
| 114 | + | |
| 115 | + public void setDirections(int directions) { | |
| 116 | + this.directions = directions; | |
| 117 | + } | |
| 118 | + | |
| 119 | + public StationRoute getNext() { | |
| 120 | + return next; | |
| 121 | + } | |
| 122 | + | |
| 123 | + public void setNext(StationRoute next) { | |
| 124 | + this.next = next; | |
| 125 | + } | |
| 126 | + | |
| 127 | + public StationRoute getPrve() { | |
| 128 | + return prve; | |
| 129 | + } | |
| 130 | + | |
| 131 | + public void setPrve(StationRoute prve) { | |
| 132 | + this.prve = prve; | |
| 133 | + } | |
| 134 | + | |
| 135 | + public String getMark() { | |
| 136 | + return mark; | |
| 137 | + } | |
| 138 | + | |
| 139 | + public void setMark(String mark) { | |
| 140 | + this.mark = mark; | |
| 141 | + } | |
| 142 | + | |
| 143 | + public String getName() { | |
| 144 | + return name; | |
| 145 | + } | |
| 146 | + | |
| 147 | + public void setName(String name) { | |
| 148 | + this.name = name; | |
| 149 | + } | |
| 150 | +} | |
| 151 | + | ... | ... |
src/main/java/com/bsth/data/gpsdata/arrival/handlers/CorrectSignalHandle.java
| 1 | -package com.bsth.data.gpsdata.arrival.handlers; | |
| 2 | - | |
| 3 | -import com.bsth.data.gpsdata.GpsEntity; | |
| 4 | -import com.bsth.data.gpsdata.arrival.SignalHandle; | |
| 5 | -import com.bsth.data.gpsdata.arrival.utils.CircleQueue; | |
| 6 | -import com.bsth.data.schedule.DayOfSchedule; | |
| 7 | -import com.bsth.entity.realcontrol.ChildTaskPlan; | |
| 8 | -import com.bsth.entity.realcontrol.ScheduleRealInfo; | |
| 9 | -import org.springframework.beans.factory.annotation.Autowired; | |
| 10 | -import org.springframework.stereotype.Component; | |
| 11 | - | |
| 12 | -/** | |
| 13 | - * 信号状态纠正 | |
| 14 | - * Created by panzhao on 2016/12/27. | |
| 15 | - */ | |
| 16 | -@Component | |
| 17 | -public class CorrectSignalHandle extends SignalHandle { | |
| 18 | - | |
| 19 | - @Autowired | |
| 20 | - DayOfSchedule dayOfSchedule; | |
| 21 | - | |
| 22 | - @Override | |
| 23 | - public boolean handle(GpsEntity gps, CircleQueue<GpsEntity> prevs) { | |
| 24 | - Object task = dayOfSchedule.executeCurr(gps.getNbbm()); | |
| 25 | - if(task == null) | |
| 26 | - return false; | |
| 27 | - ScheduleRealInfo sch; | |
| 28 | - | |
| 29 | - //子任务 | |
| 30 | - if(task.getClass().isAssignableFrom(ChildTaskPlan.class)){ | |
| 31 | - ChildTaskPlan childTask = (ChildTaskPlan) task; | |
| 32 | - sch = childTask.getSchedule(); | |
| 33 | - } | |
| 34 | - else | |
| 35 | - sch = (ScheduleRealInfo) task; | |
| 36 | - | |
| 37 | - int updown = Integer.parseInt(sch.getXlDir()); | |
| 38 | - //走向 | |
| 39 | - if(gps.getUpDown() != updown){ | |
| 40 | - gps.setUpDown(updown); | |
| 41 | - gps.setState(0); | |
| 42 | - } | |
| 43 | - | |
| 44 | - | |
| 45 | - return true; | |
| 46 | - } | |
| 47 | -} | |
| 1 | +package com.bsth.data.gpsdata.arrival.handlers; | |
| 2 | + | |
| 3 | +import com.bsth.data.gpsdata.GpsEntity; | |
| 4 | +import com.bsth.data.gpsdata.arrival.SignalHandle; | |
| 5 | +import com.bsth.data.gpsdata.arrival.utils.CircleQueue; | |
| 6 | +import com.bsth.data.schedule.DayOfSchedule; | |
| 7 | +import com.bsth.entity.realcontrol.ChildTaskPlan; | |
| 8 | +import com.bsth.entity.realcontrol.ScheduleRealInfo; | |
| 9 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 10 | +import org.springframework.stereotype.Component; | |
| 11 | + | |
| 12 | +/** | |
| 13 | + * 信号状态纠正 | |
| 14 | + * Created by panzhao on 2016/12/27. | |
| 15 | + */ | |
| 16 | +@Component | |
| 17 | +public class CorrectSignalHandle extends SignalHandle { | |
| 18 | + | |
| 19 | + @Autowired | |
| 20 | + DayOfSchedule dayOfSchedule; | |
| 21 | + | |
| 22 | + @Override | |
| 23 | + public boolean handle(GpsEntity gps, CircleQueue<GpsEntity> prevs) { | |
| 24 | + Object task = dayOfSchedule.executeCurr(gps.getNbbm()); | |
| 25 | + if(task == null) | |
| 26 | + return false; | |
| 27 | + ScheduleRealInfo sch; | |
| 28 | + | |
| 29 | + //子任务 | |
| 30 | + if(task.getClass().isAssignableFrom(ChildTaskPlan.class)){ | |
| 31 | + ChildTaskPlan childTask = (ChildTaskPlan) task; | |
| 32 | + sch = childTask.getSchedule(); | |
| 33 | + } | |
| 34 | + else | |
| 35 | + sch = (ScheduleRealInfo) task; | |
| 36 | + | |
| 37 | + int updown = Integer.parseInt(sch.getXlDir()); | |
| 38 | + //走向 | |
| 39 | + if(gps.getUpDown() != updown){ | |
| 40 | + gps.setUpDown(updown); | |
| 41 | + gps.setState(0); | |
| 42 | + } | |
| 43 | + | |
| 44 | + | |
| 45 | + return true; | |
| 46 | + } | |
| 47 | +} | ... | ... |
src/main/java/com/bsth/data/gpsdata/arrival/handlers/InOutStationSignalHandle.java
| ... | ... | @@ -2,23 +2,21 @@ package com.bsth.data.gpsdata.arrival.handlers; |
| 2 | 2 | |
| 3 | 3 | import com.bsth.data.LineConfigData; |
| 4 | 4 | import com.bsth.data.gpsdata.GpsEntity; |
| 5 | -import com.bsth.data.gpsdata.arrival.GeoCacheData; | |
| 6 | 5 | import com.bsth.data.gpsdata.arrival.SignalHandle; |
| 7 | -import com.bsth.data.gpsdata.arrival.entity.StationRoute; | |
| 8 | 6 | import com.bsth.data.gpsdata.arrival.utils.CircleQueue; |
| 9 | -import com.bsth.data.gpsdata.arrival.utils.GeoUtils; | |
| 7 | +import com.bsth.data.gpsdata.arrival.utils.ScheduleSignalState; | |
| 8 | +import com.bsth.data.gpsdata.arrival.utils.SignalSchPlanMatcher; | |
| 10 | 9 | import com.bsth.data.schedule.DayOfSchedule; |
| 11 | 10 | import com.bsth.entity.realcontrol.LineConfig; |
| 12 | 11 | import com.bsth.entity.realcontrol.ScheduleRealInfo; |
| 13 | 12 | import com.bsth.service.directive.DirectiveService; |
| 14 | 13 | import com.bsth.websocket.handler.SendUtils; |
| 14 | +import org.apache.commons.lang3.StringUtils; | |
| 15 | 15 | import org.slf4j.Logger; |
| 16 | 16 | import org.slf4j.LoggerFactory; |
| 17 | 17 | import org.springframework.beans.factory.annotation.Autowired; |
| 18 | 18 | import org.springframework.stereotype.Component; |
| 19 | 19 | |
| 20 | -import java.util.List; | |
| 21 | - | |
| 22 | 20 | /** |
| 23 | 21 | * 进出站动作处理 |
| 24 | 22 | * Created by panzhao on 2016/12/27. |
| ... | ... | @@ -40,8 +38,25 @@ public class InOutStationSignalHandle extends SignalHandle{ |
| 40 | 38 | @Autowired |
| 41 | 39 | DirectiveService directiveService; |
| 42 | 40 | |
| 41 | + @Autowired | |
| 42 | + ScheduleSignalState scheduleSignalState; | |
| 43 | + | |
| 44 | + @Autowired | |
| 45 | + SignalSchPlanMatcher signalSchPlanMatcher; | |
| 46 | + | |
| 47 | + private final static int MAX_BEFORE_TIME = 1000 * 60 * 72; | |
| 48 | + | |
| 43 | 49 | @Override |
| 44 | 50 | public boolean handle(GpsEntity gps, CircleQueue<GpsEntity> prevs) { |
| 51 | + //忽略漂移信号 | |
| 52 | + if(isDriftSignal(gps)) | |
| 53 | + return false; | |
| 54 | + | |
| 55 | + //从异常状态恢复的第一个信号 | |
| 56 | + if(abnormalRecovery(gps, prevs)){ | |
| 57 | + //回溯一下之前的轨迹 | |
| 58 | + scheduleSignalState.signalRetrospect(gps); | |
| 59 | + } | |
| 45 | 60 | |
| 46 | 61 | if(isNotEmpty(prevs)){ |
| 47 | 62 | GpsEntity prev = prevs.getTail(); |
| ... | ... | @@ -91,13 +106,23 @@ public class InOutStationSignalHandle extends SignalHandle{ |
| 91 | 106 | ScheduleRealInfo sch = dayOfSchedule.executeCurr(gps.getNbbm()); |
| 92 | 107 | String qdzCode = sch.getQdzCode(); |
| 93 | 108 | |
| 94 | - | |
| 95 | - //if(sch.getFcsjActual() != ) | |
| 109 | + //首班出场最多提前1.2小时 | |
| 110 | + if(dayOfSchedule.isFirstOut(sch) && sch.getDfsjT() - gps.getTimestamp() > MAX_BEFORE_TIME) | |
| 111 | + return; | |
| 96 | 112 | |
| 97 | 113 | //起点发车 |
| 98 | 114 | if(qdzCode != null && prev.getStopNo().equals(qdzCode) |
| 99 | 115 | && !willDepart(gps, prev, sch)){ |
| 100 | 116 | |
| 117 | + //发车班次匹配 | |
| 118 | + signalSchPlanMatcher.outMatch(gps, sch); | |
| 119 | + sch = dayOfSchedule.executeCurr(gps.getNbbm()); | |
| 120 | + | |
| 121 | + //实发时间不覆盖 | |
| 122 | + if(StringUtils.isNotEmpty(sch.getFcsjActual())) | |
| 123 | + return; | |
| 124 | + | |
| 125 | + //实发时间 | |
| 101 | 126 | sch.setFcsjActualAll(gps.getTimestamp()); |
| 102 | 127 | //通知客户端 |
| 103 | 128 | sendUtils.sendFcsj(sch); |
| ... | ... | @@ -108,16 +133,27 @@ public class InOutStationSignalHandle extends SignalHandle{ |
| 108 | 133 | outStationAndOutPark(sch); |
| 109 | 134 | logger.info("班次:" + sch.getDfsj() + "发车, 时间:" + sch.getFcsjActual()); |
| 110 | 135 | } |
| 136 | + else if(sch.getBcType().equals("out")){ | |
| 137 | + ScheduleRealInfo next = dayOfSchedule.nextSame(sch); | |
| 138 | + if(prev.getStopNo().equals(next.getQdzCode())){ | |
| 139 | + //发下一个班次 | |
| 140 | + dayOfSchedule.addExecPlan(next); | |
| 141 | + outStation(gps, prev); | |
| 142 | + } | |
| 143 | + } | |
| 111 | 144 | } |
| 112 | 145 | |
| 146 | + | |
| 113 | 147 | private void outStationAndOutPark(ScheduleRealInfo sch){ |
| 114 | 148 | LineConfig config = lineConfigData.get(sch.getXlBm()); |
| 115 | 149 | if (config != null && config.getOutConfig() == 2) { |
| 116 | 150 | //出站既出场 |
| 117 | 151 | ScheduleRealInfo schPrev = dayOfSchedule.prev(sch); |
| 118 | 152 | if (schPrev != null && schPrev.getBcType().equals("out")) { |
| 119 | - schPrev.setFcsjActualAll(sch.getFcsjActual()); | |
| 120 | - schPrev.setZdsjActualAll(sch.getFcsjActual()); | |
| 153 | + schPrev.setFcsjActualAll(sch.getFcsjActualTime()); | |
| 154 | + schPrev.setZdsjActualAll(sch.getFcsjActualTime()); | |
| 155 | + | |
| 156 | + sendUtils.refreshSch(schPrev); | |
| 121 | 157 | } |
| 122 | 158 | } |
| 123 | 159 | } |
| ... | ... | @@ -129,9 +165,12 @@ public class InOutStationSignalHandle extends SignalHandle{ |
| 129 | 165 | */ |
| 130 | 166 | private void inStation(GpsEntity gps, GpsEntity prev){ |
| 131 | 167 | ScheduleRealInfo sch = dayOfSchedule.executeCurr(gps.getNbbm()); |
| 132 | - String zdzCode = sch.getZdzCode(); | |
| 133 | 168 | |
| 134 | - if(zdzCode != null && gps.getStopNo().equals(zdzCode)){ | |
| 169 | + if(gps.getStopNo().equals(sch.getZdzCode())){ | |
| 170 | + | |
| 171 | + //实达时间不覆盖 | |
| 172 | + if(StringUtils.isNotEmpty(sch.getZdsjActual())) | |
| 173 | + return; | |
| 135 | 174 | |
| 136 | 175 | sch.setZdsjActualAll(gps.getTimestamp()); |
| 137 | 176 | //已完成班次数 |
| ... | ... | @@ -142,33 +181,22 @@ public class InOutStationSignalHandle extends SignalHandle{ |
| 142 | 181 | //持久化 |
| 143 | 182 | dayOfSchedule.save(sch); |
| 144 | 183 | //下发调度指令 |
| 145 | - //directiveService.send60Dispatch(next, doneSum, "到站@系统"); | |
| 184 | + directiveService.send60Dispatch(next, doneSum, "到站@系统"); | |
| 146 | 185 | |
| 147 | 186 | //准备执行下一个班次 |
| 148 | 187 | if (next != null) { |
| 149 | 188 | next.setQdzArrDatesj(sch.getZdsjActual()); |
| 150 | 189 | dayOfSchedule.addExecPlan(next); |
| 151 | - | |
| 152 | 190 | //进站既进场 |
| 153 | 191 | inStationAndInPark(sch, next); |
| 154 | - | |
| 155 | 192 | //将gps转换为下一个班次走向的站内信号 |
| 156 | - int updown = Integer.parseInt(next.getXlDir()); | |
| 157 | - List<StationRoute> srs = GeoCacheData.getStationRoute(next.getXlBm(), updown); | |
| 158 | - StationRoute station = GeoUtils.gpsInStation(gps, srs); | |
| 159 | - if (station != null) { | |
| 160 | - gps.setUpDown(updown); | |
| 161 | - gps.setStopNo(station.getCode()); | |
| 162 | - } | |
| 193 | + transformUpdown(gps, sch); | |
| 163 | 194 | } |
| 164 | 195 | } |
| 165 | - /* //如果出场班次计划终点时间5分钟后还未完成,检查一下车辆轨迹,是否已经在执行线路上班次 | |
| 166 | - else if(sch.getBcType().equals("out") | |
| 167 | - && sch.getZdsj() != null | |
| 168 | - && gps.getTimestamp() - sch.getZdsjT() >= 1000 * 60 * 5){ | |
| 169 | - logger.info("出场班次计划终点时间5分钟后还未完成"); | |
| 170 | - | |
| 171 | - }*/ | |
| 196 | + else if(sch.getFcsjActual() == null){ | |
| 197 | + //有进站,但班次没有实发,向前追溯一下信号 | |
| 198 | + scheduleSignalState.signalRetrospect(gps, sch); | |
| 199 | + } | |
| 172 | 200 | } |
| 173 | 201 | |
| 174 | 202 | /** |
| ... | ... | @@ -179,8 +207,10 @@ public class InOutStationSignalHandle extends SignalHandle{ |
| 179 | 207 | LineConfig config = lineConfigData.get(sch.getXlBm()); |
| 180 | 208 | if (next.getBcType().equals("in") && |
| 181 | 209 | config != null && config.getOutConfig() == 2) { |
| 182 | - next.setFcsjActualAll(sch.getZdsjActual()); | |
| 183 | - next.setZdsjActualAll(sch.getZdsjActual()); | |
| 210 | + next.setFcsjActualAll(sch.getZdsjActualTime()); | |
| 211 | + next.setZdsjActualAll(sch.getZdsjActualTime()); | |
| 212 | + | |
| 213 | + sendUtils.refreshSch(next); | |
| 184 | 214 | } |
| 185 | 215 | } |
| 186 | 216 | |
| ... | ... | @@ -193,7 +223,7 @@ public class InOutStationSignalHandle extends SignalHandle{ |
| 193 | 223 | */ |
| 194 | 224 | private boolean willDepart(GpsEntity gps, GpsEntity prev, Object task){ |
| 195 | 225 | |
| 196 | -/* ScheduleRealInfo sch = (ScheduleRealInfo) task; | |
| 226 | + /*ScheduleRealInfo sch = (ScheduleRealInfo) task; | |
| 197 | 227 | ScheduleRealInfo prevTask = dayOfSchedule.prev(sch); |
| 198 | 228 | if(prevTask == null || prevTask.getBcType().equals("out")) |
| 199 | 229 | return false; | ... | ... |
src/main/java/com/bsth/data/gpsdata/arrival/handlers/OfflineSignalHandle.java
| ... | ... | @@ -13,16 +13,17 @@ import org.springframework.stereotype.Component; |
| 13 | 13 | @Component |
| 14 | 14 | public class OfflineSignalHandle extends SignalHandle{ |
| 15 | 15 | |
| 16 | - //断开3分钟,标记为重连信号 | |
| 17 | - private final static int OFFLINE_TIME = 1000 * 60 * 3; | |
| 16 | + //断开2分钟,标记为重连信号 | |
| 17 | + private final static int OFFLINE_TIME = 1000 * 60 * 2; | |
| 18 | 18 | |
| 19 | 19 | //断开70分钟,之前的信号不再有参考价值 |
| 20 | 20 | private final static int CLEAR_TIME = 1000 * 60 * 70; |
| 21 | 21 | |
| 22 | 22 | @Override |
| 23 | 23 | public boolean handle(GpsEntity gps, CircleQueue<GpsEntity> prevs) { |
| 24 | - //异常信号不管 | |
| 25 | - if(isAbnormal(gps)){ | |
| 24 | + //漂移信号不管 | |
| 25 | + if(isDriftSignal(gps)){ | |
| 26 | + gps.setSignalState("drift"); | |
| 26 | 27 | return true; |
| 27 | 28 | } |
| 28 | 29 | |
| ... | ... | @@ -39,4 +40,4 @@ public class OfflineSignalHandle extends SignalHandle{ |
| 39 | 40 | } |
| 40 | 41 | return true; |
| 41 | 42 | } |
| 42 | 43 | -} |
| 44 | +} | |
| 43 | 45 | \ No newline at end of file | ... | ... |
src/main/java/com/bsth/data/gpsdata/arrival/handlers/ReverseSignalHandle.java
| 1 | 1 | package com.bsth.data.gpsdata.arrival.handlers; |
| 2 | 2 | |
| 3 | -import com.alibaba.fastjson.JSON; | |
| 4 | 3 | import com.bsth.data.gpsdata.GpsEntity; |
| 5 | 4 | import com.bsth.data.gpsdata.arrival.GeoCacheData; |
| 6 | 5 | import com.bsth.data.gpsdata.arrival.SignalHandle; |
| 7 | 6 | import com.bsth.data.gpsdata.arrival.entity.RouteReverse; |
| 8 | 7 | import com.bsth.data.gpsdata.arrival.entity.StationRoute; |
| 9 | 8 | import com.bsth.data.gpsdata.arrival.utils.CircleQueue; |
| 9 | +import com.bsth.data.gpsdata.arrival.utils.ScheduleSignalState; | |
| 10 | 10 | import com.bsth.data.schedule.DayOfSchedule; |
| 11 | -import com.bsth.entity.realcontrol.ScheduleRealInfo; | |
| 12 | 11 | import org.slf4j.Logger; |
| 13 | 12 | import org.slf4j.LoggerFactory; |
| 14 | 13 | import org.springframework.beans.factory.annotation.Autowired; |
| ... | ... | @@ -26,6 +25,9 @@ public class ReverseSignalHandle extends SignalHandle { |
| 26 | 25 | @Autowired |
| 27 | 26 | DayOfSchedule dayOfSchedule; |
| 28 | 27 | |
| 28 | + @Autowired | |
| 29 | + ScheduleSignalState scheduleSignalState; | |
| 30 | + | |
| 29 | 31 | @Override |
| 30 | 32 | public boolean handle(GpsEntity gps, CircleQueue<GpsEntity> prevs) { |
| 31 | 33 | if (!isNotEmpty(prevs)) |
| ... | ... | @@ -36,17 +38,10 @@ public class ReverseSignalHandle extends SignalHandle { |
| 36 | 38 | if (isReverse(gps, prev)) { |
| 37 | 39 | RouteReverse reverse = reverseSearch(prevs, gps); |
| 38 | 40 | |
| 39 | - if (reverse.getCount() >= 2) { | |
| 40 | - //切换到下一个班次 | |
| 41 | - ScheduleRealInfo sch = dayOfSchedule.executeCurr(gps.getNbbm()); | |
| 42 | - if (sch.getBcType().equals("out") && sch.getZdsjT() != null && sch.getZdsjT() > gps.getTimestamp()) { | |
| 43 | - return false; | |
| 44 | - } | |
| 45 | - dayOfSchedule.addExecPlan(dayOfSchedule.next(sch)); | |
| 46 | - | |
| 47 | - if (reverse.isClose()) { | |
| 48 | - logger.info("区间掉头,车辆:" + gps.getNbbm() + " -" + JSON.toJSONString(reverse)); | |
| 49 | - } | |
| 41 | + if (reverse.getCount() >= 4 | |
| 42 | + && reverse.isClose() | |
| 43 | + && !GeoCacheData.isEndStation(gps.getLineId(), gps.getUpDown(), reverse.getTurned())) { | |
| 44 | + scheduleSignalState.reverseAnalyse(reverse); | |
| 50 | 45 | } |
| 51 | 46 | } |
| 52 | 47 | return false; |
| ... | ... | @@ -63,7 +58,8 @@ public class ReverseSignalHandle extends SignalHandle { |
| 63 | 58 | RouteReverse routeReverse = new RouteReverse(); |
| 64 | 59 | int count = 0; |
| 65 | 60 | String path = ""; |
| 66 | - String turned = null; | |
| 61 | + long zt = 0L; | |
| 62 | + boolean half = false; | |
| 67 | 63 | |
| 68 | 64 | //当前站点 |
| 69 | 65 | StationRoute curr = GeoCacheData.getRouteCode(gps), sr; |
| ... | ... | @@ -72,22 +68,29 @@ public class ReverseSignalHandle extends SignalHandle { |
| 72 | 68 | for (int i = array.length - 1; i > 0; i--) { |
| 73 | 69 | prev = (GpsEntity) array[i]; |
| 74 | 70 | |
| 75 | - if(!prev.getUpDown().equals(gps.getUpDown())) | |
| 71 | + if (!prev.getUpDown().equals(gps.getUpDown()) | |
| 72 | + || prev.getSignalState().equals("reconnection")) | |
| 76 | 73 | break; |
| 77 | 74 | |
| 78 | 75 | if (prev.getInstation() == 1) { |
| 79 | 76 | sr = GeoCacheData.getRouteCode(prev); |
| 80 | 77 | |
| 81 | 78 | if (sr.getRouteSort() > curr.getRouteSort()) { |
| 79 | + if(half){ | |
| 80 | + routeReverse.setVague(true); | |
| 81 | + } | |
| 82 | + | |
| 82 | 83 | path += (curr.getCode() + ","); |
| 83 | 84 | count++; |
| 85 | + zt = prev.getTimestamp(); | |
| 84 | 86 | } else if (sr.getRouteSort() < curr.getRouteSort()) { |
| 85 | - path += (curr.getCode() + ","); | |
| 86 | - //掉头点 | |
| 87 | - if (turned == null) | |
| 88 | - turned = prev.getStopNo(); | |
| 87 | + if (routeReverse.getTurned() == null) { | |
| 88 | + routeReverse.setTurned(curr.getCode()); | |
| 89 | + half = true; | |
| 90 | + } | |
| 89 | 91 | |
| 90 | - //路径闭合 | |
| 92 | + path += (curr.getCode() + ","); | |
| 93 | + //掉头前当前站 | |
| 91 | 94 | if (sr.getCode().equals(gps.getStopNo())) { |
| 92 | 95 | routeReverse.setClose(true); |
| 93 | 96 | path += sr.getCode(); |
| ... | ... | @@ -99,9 +102,11 @@ public class ReverseSignalHandle extends SignalHandle { |
| 99 | 102 | } |
| 100 | 103 | } |
| 101 | 104 | |
| 105 | + routeReverse.setZt(zt); | |
| 102 | 106 | routeReverse.setCount(count); |
| 103 | 107 | routeReverse.setDetail(path); |
| 104 | - routeReverse.setTurned(turned); | |
| 108 | + routeReverse.setCt(gps.getTimestamp()); | |
| 109 | + routeReverse.setNbbm(gps.getNbbm()); | |
| 105 | 110 | return routeReverse; |
| 106 | 111 | } |
| 107 | 112 | |
| ... | ... | @@ -129,4 +134,4 @@ public class ReverseSignalHandle extends SignalHandle { |
| 129 | 134 | } |
| 130 | 135 | return false; |
| 131 | 136 | } |
| 132 | 137 | -} |
| 138 | +} | |
| 133 | 139 | \ No newline at end of file | ... | ... |
src/main/java/com/bsth/data/gpsdata/arrival/handlers/StationInsideHandle.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.StationRoute; | |
| 7 | -import com.bsth.data.gpsdata.arrival.utils.CircleQueue; | |
| 8 | -import com.bsth.data.gpsdata.arrival.utils.GeoUtils; | |
| 9 | -import org.springframework.stereotype.Component; | |
| 10 | - | |
| 11 | -import java.util.List; | |
| 12 | - | |
| 13 | -/** | |
| 14 | - * 站内站外判定 | |
| 15 | - * Created by panzhao on 2016/12/27. | |
| 16 | - */ | |
| 17 | -@Component | |
| 18 | -public class StationInsideHandle extends SignalHandle { | |
| 19 | - | |
| 20 | - | |
| 21 | - @Override | |
| 22 | - public boolean handle(GpsEntity gps, CircleQueue<GpsEntity> prevs) { | |
| 23 | - //是否在场内 | |
| 24 | - String parkCode = GeoUtils.gpsInCarpark(gps); | |
| 25 | - if (parkCode != null) { | |
| 26 | - gps.setInstation(2); | |
| 27 | - gps.setStopNo(parkCode); | |
| 28 | - } | |
| 29 | - | |
| 30 | - //是否在站内 | |
| 31 | - List<StationRoute> srs = GeoCacheData.getStationRoute(gps.getLineId(), gps.getUpDown()); | |
| 32 | - StationRoute station = GeoUtils.gpsInStation(gps, srs); | |
| 33 | - if (station != null) { | |
| 34 | - gps.setInstation(1); | |
| 35 | - gps.setStopNo(station.getCode()); | |
| 36 | - gps.setStation(station); | |
| 37 | - } | |
| 38 | - | |
| 39 | - //在场,站外 | |
| 40 | - if(gps.getInstation() == 0 && isNotEmpty(prevs)){ | |
| 41 | - //继承上一个点的站点编码 | |
| 42 | - GpsEntity prev = prevs.getTail(); | |
| 43 | - gps.setStopNo(prev.getStopNo()); | |
| 44 | - } | |
| 45 | - | |
| 46 | - return true; | |
| 47 | - } | |
| 48 | -} | |
| 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.StationRoute; | |
| 7 | +import com.bsth.data.gpsdata.arrival.utils.CircleQueue; | |
| 8 | +import com.bsth.data.gpsdata.arrival.utils.GeoUtils; | |
| 9 | +import org.springframework.stereotype.Component; | |
| 10 | + | |
| 11 | +import java.util.List; | |
| 12 | + | |
| 13 | +/** | |
| 14 | + * 站内站外判定 | |
| 15 | + * Created by panzhao on 2016/12/27. | |
| 16 | + */ | |
| 17 | +@Component | |
| 18 | +public class StationInsideHandle extends SignalHandle { | |
| 19 | + | |
| 20 | + | |
| 21 | + @Override | |
| 22 | + public boolean handle(GpsEntity gps, CircleQueue<GpsEntity> prevs) { | |
| 23 | + //是否在场内 | |
| 24 | + String parkCode = GeoUtils.gpsInCarpark(gps); | |
| 25 | + if (parkCode != null) { | |
| 26 | + gps.setInstation(2); | |
| 27 | + gps.setStopNo(parkCode); | |
| 28 | + } | |
| 29 | + | |
| 30 | + //是否在站内 | |
| 31 | + List<StationRoute> srs = GeoCacheData.getStationRoute(gps.getLineId(), gps.getUpDown()); | |
| 32 | + StationRoute station = GeoUtils.gpsInStation(gps, srs); | |
| 33 | + if (station != null) { | |
| 34 | + gps.setInstation(1); | |
| 35 | + gps.setStopNo(station.getCode()); | |
| 36 | + gps.setStation(station); | |
| 37 | + } | |
| 38 | + | |
| 39 | + //在场,站外 | |
| 40 | + if(gps.getInstation() == 0 && isNotEmpty(prevs)){ | |
| 41 | + //继承上一个点的站点编码 | |
| 42 | + GpsEntity prev = prevs.getTail(); | |
| 43 | + gps.setStopNo(prev.getStopNo()); | |
| 44 | + } | |
| 45 | + | |
| 46 | + return true; | |
| 47 | + } | |
| 48 | +} | ... | ... |
src/main/java/com/bsth/data/gpsdata/arrival/utils/CircleQueue.java
| 1 | -package com.bsth.data.gpsdata.arrival.utils; | |
| 2 | - | |
| 3 | -import java.util.Arrays; | |
| 4 | - | |
| 5 | -/** | |
| 6 | - * 循环队列 | |
| 7 | - * Created by panzhao on 2016/12/23. | |
| 8 | - */ | |
| 9 | -public class CircleQueue<T> { | |
| 10 | - | |
| 11 | - /** | |
| 12 | - * (循环队列)数组的容量 | |
| 13 | - */ | |
| 14 | - public int capacity; | |
| 15 | - | |
| 16 | - /** | |
| 17 | - * 数组:保存循环队列的元素 | |
| 18 | - */ | |
| 19 | - public Object[] elementData; | |
| 20 | - | |
| 21 | - /** | |
| 22 | - * 头 | |
| 23 | - */ | |
| 24 | - public int head = 0; | |
| 25 | - | |
| 26 | - /** | |
| 27 | - * 尾 | |
| 28 | - */ | |
| 29 | - public int tail = 0; | |
| 30 | - | |
| 31 | - /** | |
| 32 | - * 以指定长度的数组来创建循环队列 | |
| 33 | - * | |
| 34 | - * @param initSize | |
| 35 | - */ | |
| 36 | - public CircleQueue(final int initSize) { | |
| 37 | - capacity = initSize; | |
| 38 | - elementData = new Object[capacity]; | |
| 39 | - } | |
| 40 | - | |
| 41 | - /** | |
| 42 | - * 获取循环队列的大小 | |
| 43 | - */ | |
| 44 | - public int size() { | |
| 45 | - if (isEmpty()) { | |
| 46 | - return 0; | |
| 47 | - } else if (isFull()) { | |
| 48 | - return capacity; | |
| 49 | - } else { | |
| 50 | - return tail + 1; | |
| 51 | - } | |
| 52 | - } | |
| 53 | - | |
| 54 | - /** | |
| 55 | - * 插入队尾一个元素 | |
| 56 | - */ | |
| 57 | - public void add(final T element) { | |
| 58 | - if (isEmpty()) { | |
| 59 | - elementData[0] = element; | |
| 60 | - } else if (isFull()) { | |
| 61 | - elementData[head] = element; | |
| 62 | - head++; | |
| 63 | - tail++; | |
| 64 | - head = head == capacity ? 0 : head; | |
| 65 | - tail = tail == capacity ? 0 : tail; | |
| 66 | - } else { | |
| 67 | - elementData[tail + 1] = element; | |
| 68 | - tail++; | |
| 69 | - } | |
| 70 | - } | |
| 71 | - | |
| 72 | - public boolean isEmpty() { | |
| 73 | - return tail == head && tail == 0 && elementData[tail] == null; | |
| 74 | - } | |
| 75 | - | |
| 76 | - public boolean isFull() { | |
| 77 | - return head != 0 && head - tail == 1 || head == 0 && tail == capacity - 1; | |
| 78 | - } | |
| 79 | - | |
| 80 | - public void clear() { | |
| 81 | - Arrays.fill(elementData, null); | |
| 82 | - head = 0; | |
| 83 | - tail = 0; | |
| 84 | - } | |
| 85 | - | |
| 86 | - /** | |
| 87 | - * @return 取 循环队列里的值(先进的index=0) | |
| 88 | - */ | |
| 89 | - public Object[] getQueue() { | |
| 90 | - final Object[] elementDataSort; | |
| 91 | - final Object[] elementDataCopy = elementData.clone(); | |
| 92 | - if (isEmpty()) { | |
| 93 | - elementDataSort = new Object[0]; | |
| 94 | - } else if (isFull()) { | |
| 95 | - elementDataSort = new Object[capacity]; | |
| 96 | - int indexMax = capacity; | |
| 97 | - int indexSort = 0; | |
| 98 | - for (int i = head; i < indexMax;) { | |
| 99 | - elementDataSort[indexSort] = elementDataCopy[i]; | |
| 100 | - indexSort++; | |
| 101 | - i++; | |
| 102 | - if (i == capacity) { | |
| 103 | - i = 0; | |
| 104 | - indexMax = head; | |
| 105 | - } | |
| 106 | - } | |
| 107 | - } else { | |
| 108 | - elementDataSort = new Object[tail]; | |
| 109 | - for (int i = 0; i < tail; i++) { | |
| 110 | - elementDataSort[i] = elementDataCopy[i]; | |
| 111 | - } | |
| 112 | - } | |
| 113 | - return elementDataSort; | |
| 114 | - } | |
| 115 | - | |
| 116 | - /** | |
| 117 | - * 取最后一个值 | |
| 118 | - * @return | |
| 119 | - */ | |
| 120 | - public T getTail(){ | |
| 121 | - return elementData[tail] == null?null:(T)elementData[tail]; | |
| 122 | - } | |
| 1 | +package com.bsth.data.gpsdata.arrival.utils; | |
| 2 | + | |
| 3 | +import java.util.Arrays; | |
| 4 | + | |
| 5 | +/** | |
| 6 | + * 循环队列 | |
| 7 | + * Created by panzhao on 2016/12/23. | |
| 8 | + */ | |
| 9 | +public class CircleQueue<T> { | |
| 10 | + | |
| 11 | + /** | |
| 12 | + * (循环队列)数组的容量 | |
| 13 | + */ | |
| 14 | + public int capacity; | |
| 15 | + | |
| 16 | + /** | |
| 17 | + * 数组:保存循环队列的元素 | |
| 18 | + */ | |
| 19 | + public Object[] elementData; | |
| 20 | + | |
| 21 | + /** | |
| 22 | + * 头 | |
| 23 | + */ | |
| 24 | + public int head = 0; | |
| 25 | + | |
| 26 | + /** | |
| 27 | + * 尾 | |
| 28 | + */ | |
| 29 | + public int tail = 0; | |
| 30 | + | |
| 31 | + /** | |
| 32 | + * 以指定长度的数组来创建循环队列 | |
| 33 | + * | |
| 34 | + * @param initSize | |
| 35 | + */ | |
| 36 | + public CircleQueue(final int initSize) { | |
| 37 | + capacity = initSize; | |
| 38 | + elementData = new Object[capacity]; | |
| 39 | + } | |
| 40 | + | |
| 41 | + /** | |
| 42 | + * 获取循环队列的大小 | |
| 43 | + */ | |
| 44 | + public int size() { | |
| 45 | + if (isEmpty()) { | |
| 46 | + return 0; | |
| 47 | + } else if (isFull()) { | |
| 48 | + return capacity; | |
| 49 | + } else { | |
| 50 | + return tail + 1; | |
| 51 | + } | |
| 52 | + } | |
| 53 | + | |
| 54 | + /** | |
| 55 | + * 插入队尾一个元素 | |
| 56 | + */ | |
| 57 | + public void add(final T element) { | |
| 58 | + if (isEmpty()) { | |
| 59 | + elementData[0] = element; | |
| 60 | + } else if (isFull()) { | |
| 61 | + elementData[head] = element; | |
| 62 | + head++; | |
| 63 | + tail++; | |
| 64 | + head = head == capacity ? 0 : head; | |
| 65 | + tail = tail == capacity ? 0 : tail; | |
| 66 | + } else { | |
| 67 | + elementData[tail + 1] = element; | |
| 68 | + tail++; | |
| 69 | + } | |
| 70 | + } | |
| 71 | + | |
| 72 | + public boolean isEmpty() { | |
| 73 | + return tail == head && tail == 0 && elementData[tail] == null; | |
| 74 | + } | |
| 75 | + | |
| 76 | + public boolean isFull() { | |
| 77 | + return head != 0 && head - tail == 1 || head == 0 && tail == capacity - 1; | |
| 78 | + } | |
| 79 | + | |
| 80 | + public void clear() { | |
| 81 | + Arrays.fill(elementData, null); | |
| 82 | + head = 0; | |
| 83 | + tail = 0; | |
| 84 | + } | |
| 85 | + | |
| 86 | + /** | |
| 87 | + * @return 取 循环队列里的值(先进的index=0) | |
| 88 | + */ | |
| 89 | + public Object[] getQueue() { | |
| 90 | + final Object[] elementDataSort; | |
| 91 | + final Object[] elementDataCopy = elementData.clone(); | |
| 92 | + if (isEmpty()) { | |
| 93 | + elementDataSort = new Object[0]; | |
| 94 | + } else if (isFull()) { | |
| 95 | + elementDataSort = new Object[capacity]; | |
| 96 | + int indexMax = capacity; | |
| 97 | + int indexSort = 0; | |
| 98 | + for (int i = head; i < indexMax;) { | |
| 99 | + elementDataSort[indexSort] = elementDataCopy[i]; | |
| 100 | + indexSort++; | |
| 101 | + i++; | |
| 102 | + if (i == capacity) { | |
| 103 | + i = 0; | |
| 104 | + indexMax = head; | |
| 105 | + } | |
| 106 | + } | |
| 107 | + } else { | |
| 108 | + elementDataSort = new Object[tail + 1]; | |
| 109 | + for (int i = 0; i <= tail; i++) { | |
| 110 | + elementDataSort[i] = elementDataCopy[i]; | |
| 111 | + } | |
| 112 | + } | |
| 113 | + return elementDataSort; | |
| 114 | + } | |
| 115 | + | |
| 116 | + /** | |
| 117 | + * 取最后一个值 | |
| 118 | + * @return | |
| 119 | + */ | |
| 120 | + public T getTail(){ | |
| 121 | + return elementData[tail] == null?null:(T)elementData[tail]; | |
| 122 | + } | |
| 123 | 123 | } |
| 124 | 124 | \ No newline at end of file | ... | ... |
src/main/java/com/bsth/data/gpsdata/arrival/utils/GeoUtils.java
| 1 | -package com.bsth.data.gpsdata.arrival.utils; | |
| 2 | - | |
| 3 | -import com.bsth.data.gpsdata.GpsEntity; | |
| 4 | -import com.bsth.data.gpsdata.arrival.GeoCacheData; | |
| 5 | -import com.bsth.data.gpsdata.arrival.entity.StationRoute; | |
| 6 | -import com.vividsolutions.jts.geom.Coordinate; | |
| 7 | -import com.vividsolutions.jts.geom.GeometryFactory; | |
| 8 | -import com.vividsolutions.jts.geom.Point; | |
| 9 | -import com.vividsolutions.jts.geom.Polygon; | |
| 10 | - | |
| 11 | -import java.util.List; | |
| 12 | -import java.util.Map; | |
| 13 | -import java.util.Set; | |
| 14 | - | |
| 15 | -/** | |
| 16 | - * Created by panzhao on 2016/12/23. | |
| 17 | - */ | |
| 18 | -public class GeoUtils { | |
| 19 | - | |
| 20 | - private final static double EARTHRADIUS = 6378137; | |
| 21 | - | |
| 22 | - private static GeometryFactory geometryFactory = new GeometryFactory(); | |
| 23 | - /** | |
| 24 | - * gps是否在路由上的某个站内 | |
| 25 | - * | |
| 26 | - * @param gps | |
| 27 | - * @param srs | |
| 28 | - * @return | |
| 29 | - */ | |
| 30 | - public static StationRoute gpsInStation(GpsEntity gps, List<StationRoute> srs) { | |
| 31 | - Point point = geometryFactory.createPoint(new Coordinate(gps.getLat(), gps.getLon())); | |
| 32 | - double min = -1, distance, distance2; | |
| 33 | - StationRoute stationRoute = null; | |
| 34 | - | |
| 35 | - for (StationRoute sr : srs) { | |
| 36 | - if (sr.getPolygon() == null) { | |
| 37 | - //圆形 | |
| 38 | - distance = getDistance(sr.getPoint(), point);//sr.getPoint().distance(point); | |
| 39 | - | |
| 40 | - if (distance > sr.getRadius()) | |
| 41 | - continue; | |
| 42 | - | |
| 43 | - if (min > distance || min == -1) { | |
| 44 | - min = distance; | |
| 45 | - stationRoute = sr; | |
| 46 | - } | |
| 47 | - } else { | |
| 48 | - //多边形 | |
| 49 | - if (sr.getPolygon().contains(point)) { | |
| 50 | - stationRoute = sr; | |
| 51 | - break; | |
| 52 | - } | |
| 53 | - } | |
| 54 | - } | |
| 55 | - return stationRoute; | |
| 56 | - } | |
| 57 | - | |
| 58 | - public static double getDistance(Point p1, Point p2) { | |
| 59 | - double lng1 = getLoop(p1.getY(), -180, 180), lat1 = getRange( | |
| 60 | - p1.getX(), -74, 74); | |
| 61 | - double lng2 = getLoop(p2.getY(), -180, 180), lat2 = getRange( | |
| 62 | - p2.getX(), -74, 74); | |
| 63 | - | |
| 64 | - double x1, x2, y1, y2; | |
| 65 | - x1 = degreeToRad(lng1); | |
| 66 | - y1 = degreeToRad(lat1); | |
| 67 | - x2 = degreeToRad(lng2); | |
| 68 | - y2 = degreeToRad(lat2); | |
| 69 | - return EARTHRADIUS | |
| 70 | - * Math.acos((Math.sin(y1) * Math.sin(y2) + Math.cos(y1) | |
| 71 | - * Math.cos(y2) * Math.cos(x2 - x1))); | |
| 72 | - } | |
| 73 | - | |
| 74 | - private static double getLoop(double v, double a, double b) { | |
| 75 | - while (v > b) { | |
| 76 | - v -= b - a; | |
| 77 | - } | |
| 78 | - while (v < a) { | |
| 79 | - v += b - a; | |
| 80 | - } | |
| 81 | - return v; | |
| 82 | - } | |
| 83 | - | |
| 84 | - private static double getRange(double v, double a, double b) { | |
| 85 | - v = Math.min(Math.max(v, a), b); | |
| 86 | - return v; | |
| 87 | - } | |
| 88 | - | |
| 89 | - private static double degreeToRad(double degree) { | |
| 90 | - return Math.PI * degree / 180; | |
| 91 | - } | |
| 92 | - | |
| 93 | - | |
| 94 | - /** | |
| 95 | - * gps 是否在某个停车场内 | |
| 96 | - * @param gps | |
| 97 | - * @return | |
| 98 | - */ | |
| 99 | - public static String gpsInCarpark(GpsEntity gps){ | |
| 100 | - Point point = geometryFactory.createPoint(new Coordinate(gps.getLat(), gps.getLon())); | |
| 101 | - | |
| 102 | - Map<String, Polygon> carparkMap = GeoCacheData.tccMap; | |
| 103 | - Set<String> codes = carparkMap.keySet(); | |
| 104 | - Polygon polygon; | |
| 105 | - for(String code : codes){ | |
| 106 | - polygon = carparkMap.get(code); | |
| 107 | - if(point.within(polygon)){ | |
| 108 | - return code; | |
| 109 | - } | |
| 110 | - } | |
| 111 | - return null; | |
| 112 | - } | |
| 113 | - | |
| 114 | - /** | |
| 115 | - * 是否是有效的连续点 | |
| 116 | - * @param prevGps | |
| 117 | - * @param gps | |
| 118 | - * @return | |
| 119 | - */ | |
| 120 | - public static boolean overdue(GpsEntity prevGps, GpsEntity gps) { | |
| 121 | - return gps.getTimestamp() - prevGps.getTimestamp() < 120000; | |
| 122 | - } | |
| 123 | -} | |
| 1 | +package com.bsth.data.gpsdata.arrival.utils; | |
| 2 | + | |
| 3 | +import com.bsth.data.gpsdata.GpsEntity; | |
| 4 | +import com.bsth.data.gpsdata.arrival.GeoCacheData; | |
| 5 | +import com.bsth.data.gpsdata.arrival.entity.StationRoute; | |
| 6 | +import com.vividsolutions.jts.geom.Coordinate; | |
| 7 | +import com.vividsolutions.jts.geom.GeometryFactory; | |
| 8 | +import com.vividsolutions.jts.geom.Point; | |
| 9 | +import com.vividsolutions.jts.geom.Polygon; | |
| 10 | + | |
| 11 | +import java.util.List; | |
| 12 | +import java.util.Map; | |
| 13 | +import java.util.Set; | |
| 14 | + | |
| 15 | +/** | |
| 16 | + * Created by panzhao on 2016/12/23. | |
| 17 | + */ | |
| 18 | +public class GeoUtils { | |
| 19 | + | |
| 20 | + private final static double EARTHRADIUS = 6378137; | |
| 21 | + | |
| 22 | + private static GeometryFactory geometryFactory = new GeometryFactory(); | |
| 23 | + /** | |
| 24 | + * gps是否在路由上的某个站内 | |
| 25 | + * | |
| 26 | + * @param gps | |
| 27 | + * @param srs | |
| 28 | + * @return | |
| 29 | + */ | |
| 30 | + public static StationRoute gpsInStation(GpsEntity gps, List<StationRoute> srs) { | |
| 31 | + Point point = geometryFactory.createPoint(new Coordinate(gps.getLat(), gps.getLon())); | |
| 32 | + double min = -1, distance, distance2; | |
| 33 | + StationRoute stationRoute = null; | |
| 34 | + | |
| 35 | + for (StationRoute sr : srs) { | |
| 36 | + if (sr.getPolygon() == null) { | |
| 37 | + //圆形 | |
| 38 | + distance = getDistance(sr.getPoint(), point);//sr.getPoint().distance(point); | |
| 39 | + | |
| 40 | + if (distance > sr.getRadius()) | |
| 41 | + continue; | |
| 42 | + | |
| 43 | + if (min > distance || min == -1) { | |
| 44 | + min = distance; | |
| 45 | + stationRoute = sr; | |
| 46 | + } | |
| 47 | + } else { | |
| 48 | + //多边形 | |
| 49 | + if (sr.getPolygon().contains(point)) { | |
| 50 | + stationRoute = sr; | |
| 51 | + break; | |
| 52 | + } | |
| 53 | + } | |
| 54 | + } | |
| 55 | + return stationRoute; | |
| 56 | + } | |
| 57 | + | |
| 58 | + public static double getDistance(Point p1, Point p2) { | |
| 59 | + double lng1 = getLoop(p1.getY(), -180, 180), lat1 = getRange( | |
| 60 | + p1.getX(), -74, 74); | |
| 61 | + double lng2 = getLoop(p2.getY(), -180, 180), lat2 = getRange( | |
| 62 | + p2.getX(), -74, 74); | |
| 63 | + | |
| 64 | + double x1, x2, y1, y2; | |
| 65 | + x1 = degreeToRad(lng1); | |
| 66 | + y1 = degreeToRad(lat1); | |
| 67 | + x2 = degreeToRad(lng2); | |
| 68 | + y2 = degreeToRad(lat2); | |
| 69 | + return EARTHRADIUS | |
| 70 | + * Math.acos((Math.sin(y1) * Math.sin(y2) + Math.cos(y1) | |
| 71 | + * Math.cos(y2) * Math.cos(x2 - x1))); | |
| 72 | + } | |
| 73 | + | |
| 74 | + private static double getLoop(double v, double a, double b) { | |
| 75 | + while (v > b) { | |
| 76 | + v -= b - a; | |
| 77 | + } | |
| 78 | + while (v < a) { | |
| 79 | + v += b - a; | |
| 80 | + } | |
| 81 | + return v; | |
| 82 | + } | |
| 83 | + | |
| 84 | + private static double getRange(double v, double a, double b) { | |
| 85 | + v = Math.min(Math.max(v, a), b); | |
| 86 | + return v; | |
| 87 | + } | |
| 88 | + | |
| 89 | + private static double degreeToRad(double degree) { | |
| 90 | + return Math.PI * degree / 180; | |
| 91 | + } | |
| 92 | + | |
| 93 | + | |
| 94 | + /** | |
| 95 | + * gps 是否在某个停车场内 | |
| 96 | + * @param gps | |
| 97 | + * @return | |
| 98 | + */ | |
| 99 | + public static String gpsInCarpark(GpsEntity gps){ | |
| 100 | + Point point = geometryFactory.createPoint(new Coordinate(gps.getLat(), gps.getLon())); | |
| 101 | + | |
| 102 | + Map<String, Polygon> carparkMap = GeoCacheData.tccMap; | |
| 103 | + Set<String> codes = carparkMap.keySet(); | |
| 104 | + Polygon polygon; | |
| 105 | + for(String code : codes){ | |
| 106 | + polygon = carparkMap.get(code); | |
| 107 | + if(point.within(polygon)){ | |
| 108 | + return code; | |
| 109 | + } | |
| 110 | + } | |
| 111 | + return null; | |
| 112 | + } | |
| 113 | + | |
| 114 | + /** | |
| 115 | + * 是否是有效的连续点 | |
| 116 | + * @param prevGps | |
| 117 | + * @param gps | |
| 118 | + * @return | |
| 119 | + */ | |
| 120 | + public static boolean overdue(GpsEntity prevGps, GpsEntity gps) { | |
| 121 | + return gps.getTimestamp() - prevGps.getTimestamp() < 120000; | |
| 122 | + } | |
| 123 | +} | ... | ... |
src/main/java/com/bsth/data/gpsdata/arrival/utils/ScheduleSignalState.java
0 → 100644
| 1 | +package com.bsth.data.gpsdata.arrival.utils; | |
| 2 | + | |
| 3 | +import com.bsth.data.LineConfigData; | |
| 4 | +import com.bsth.data.gpsdata.GpsEntity; | |
| 5 | +import com.bsth.data.gpsdata.SignalStateData; | |
| 6 | +import com.bsth.data.gpsdata.arrival.GeoCacheData; | |
| 7 | +import com.bsth.data.gpsdata.arrival.entity.RouteReverse; | |
| 8 | +import com.bsth.data.gpsdata.arrival.entity.SignalAbnormal; | |
| 9 | +import com.bsth.data.gpsdata.arrival.entity.SignalState; | |
| 10 | +import com.bsth.data.schedule.DayOfSchedule; | |
| 11 | +import com.bsth.entity.realcontrol.LineConfig; | |
| 12 | +import com.bsth.entity.realcontrol.ScheduleRealInfo; | |
| 13 | +import org.slf4j.Logger; | |
| 14 | +import org.slf4j.LoggerFactory; | |
| 15 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 16 | +import org.springframework.stereotype.Component; | |
| 17 | + | |
| 18 | +/** | |
| 19 | + * 班次信号状态分析 | |
| 20 | + * Created by panzhao on 2016/12/29. | |
| 21 | + */ | |
| 22 | +@Component | |
| 23 | +public class ScheduleSignalState { | |
| 24 | + | |
| 25 | + @Autowired | |
| 26 | + DayOfSchedule dayOfSchedule; | |
| 27 | + | |
| 28 | + Logger logger = LoggerFactory.getLogger(this.getClass()); | |
| 29 | + | |
| 30 | + @Autowired | |
| 31 | + LineConfigData lineConfigData; | |
| 32 | + | |
| 33 | + @Autowired | |
| 34 | + SignalStateData signalStateData; | |
| 35 | + | |
| 36 | + /** | |
| 37 | + * 路由反向分析 | |
| 38 | + */ | |
| 39 | + public void reverseAnalyse(RouteReverse reverse) { | |
| 40 | + ScheduleRealInfo sch = dayOfSchedule.executeCurr(reverse.getNbbm()); | |
| 41 | + | |
| 42 | + String bcType = sch.getBcType(); | |
| 43 | + | |
| 44 | + switch (bcType) { | |
| 45 | + case "out": | |
| 46 | + outReverseAnalyse(sch, reverse); | |
| 47 | + break; | |
| 48 | + case "normal": | |
| 49 | + normalReverseAnalyse(sch, reverse); | |
| 50 | + break; | |
| 51 | + } | |
| 52 | + } | |
| 53 | + | |
| 54 | + /** | |
| 55 | + * 出场班次路由反向分析 | |
| 56 | + * | |
| 57 | + * @param sch | |
| 58 | + */ | |
| 59 | + private void outReverseAnalyse(ScheduleRealInfo sch, RouteReverse reverse) { | |
| 60 | + long t = reverse.getCt(); | |
| 61 | + //出场班次终点时间前,允许反向轨迹 | |
| 62 | + if (sch.getZdsjT() != null && sch.getZdsjT() > t) { | |
| 63 | + return; | |
| 64 | + } | |
| 65 | + | |
| 66 | + int rt; | |
| 67 | + //从实发 到 当前时间 < 计划运送时间 * 0.9 | |
| 68 | + if (sch.getFcsjActual() != null && sch.getBcsj() != null) { | |
| 69 | + rt = (int) (t - sch.getFcsjActualTime()); | |
| 70 | + if (rt < sch.getBcsj() * 0.9) | |
| 71 | + return; | |
| 72 | + } | |
| 73 | + | |
| 74 | + ScheduleRealInfo next = dayOfSchedule.next(sch); | |
| 75 | + if (next.getXlDir().equals(sch.getXlDir())) | |
| 76 | + return; | |
| 77 | + | |
| 78 | + //时间足够下一个班次待发时间运行到当前站 | |
| 79 | + int runTime = reverse.getCount() * 1500 * 60; | |
| 80 | + if (next.getDfsjT() + runTime < t) { | |
| 81 | + //跳到下一个班次 | |
| 82 | + dayOfSchedule.addExecPlan(next); | |
| 83 | + } | |
| 84 | + } | |
| 85 | + | |
| 86 | + /** | |
| 87 | + * 正常班次路由反向分析 | |
| 88 | + * | |
| 89 | + * @param sch | |
| 90 | + * @param reverse | |
| 91 | + */ | |
| 92 | + private void normalReverseAnalyse(ScheduleRealInfo sch, RouteReverse reverse) { | |
| 93 | + LineConfig conf = lineConfigData.get(sch.getXlBm()); | |
| 94 | + | |
| 95 | + if (conf.isReadReverse()) { | |
| 96 | + //跳下一个班次 | |
| 97 | + ScheduleRealInfo next = dayOfSchedule.next(sch); | |
| 98 | + if (next != null) | |
| 99 | + dayOfSchedule.addExecPlan(next); | |
| 100 | + | |
| 101 | + //记录信号状态 | |
| 102 | + SignalState signalState = SignalState.reverseSignalSTate(sch, reverse); | |
| 103 | + signalStateData.put(signalState); | |
| 104 | + } | |
| 105 | + } | |
| 106 | + | |
| 107 | + public void signalRetrospect(GpsEntity gps) { | |
| 108 | + signalRetrospect(gps, dayOfSchedule.executeCurr(gps.getNbbm())); | |
| 109 | + } | |
| 110 | + | |
| 111 | + /** | |
| 112 | + * 信号追溯 | |
| 113 | + * | |
| 114 | + * @param gps | |
| 115 | + * @param sch | |
| 116 | + */ | |
| 117 | + public void signalRetrospect(GpsEntity gps, ScheduleRealInfo sch) { | |
| 118 | + //回放数据,是否有掉线或者漂移 | |
| 119 | + CircleQueue<GpsEntity> queue = GeoCacheData.getGps(gps.getNbbm()); | |
| 120 | + if (queue == null || queue.size() == 0 /*|| gps.getInstation() == 0*/) | |
| 121 | + return; | |
| 122 | + | |
| 123 | + //起始时间点 | |
| 124 | + long st = 0; | |
| 125 | + ScheduleRealInfo prev = dayOfSchedule.prev(sch); | |
| 126 | + | |
| 127 | + if (prev != null) { | |
| 128 | + if (prev.getZdsjActual() != null) | |
| 129 | + st = prev.getZdsjActualTime(); | |
| 130 | + else | |
| 131 | + st = (GeoCacheData.midwayStation(gps.getLineId(), gps.getUpDown(), sch.getQdzCode(), gps.getStopNo()).size() + 1) * (1000 * 60 * 5); | |
| 132 | + } | |
| 133 | + | |
| 134 | + Object[] tempArray = queue.getQueue(); | |
| 135 | + int len = tempArray.length; | |
| 136 | + | |
| 137 | + Object[] array = new Object[len + 1]; | |
| 138 | + System.arraycopy(tempArray, 0, array, 0, len); | |
| 139 | + array[len] = gps; | |
| 140 | + | |
| 141 | + String gpsState = ""; | |
| 142 | + GpsEntity tempGps, nearGps = null; | |
| 143 | + int i = len - 1; | |
| 144 | + for (; i >= 0; i--) { | |
| 145 | + tempGps = (GpsEntity) array[i]; | |
| 146 | + | |
| 147 | + gpsState = tempGps.getSignalState(); | |
| 148 | + if (gpsState.equals("truncation")) | |
| 149 | + break; | |
| 150 | + else if (gpsState.equals("drift")) { | |
| 151 | + nearGps = (GpsEntity) array[i + 1]; | |
| 152 | + break; | |
| 153 | + } else if (gpsState.equals("reconnection")) { | |
| 154 | + nearGps = tempGps; | |
| 155 | + break; | |
| 156 | + } | |
| 157 | + | |
| 158 | + if (tempGps.getTimestamp() < st) | |
| 159 | + break; | |
| 160 | + } | |
| 161 | + | |
| 162 | + if (nearGps != null && i > 0) { | |
| 163 | + createSignalAbnormal(gpsState, nearGps, i, array, sch); | |
| 164 | + } | |
| 165 | + } | |
| 166 | + | |
| 167 | + private void createSignalAbnormal(String gpsState, GpsEntity nearGps, int i, Object[] array, ScheduleRealInfo sch) { | |
| 168 | + switch (gpsState) { | |
| 169 | + case "drift": | |
| 170 | + driftSignalAbnormal(nearGps, i, array, sch); | |
| 171 | + break; | |
| 172 | + case "reconnection": | |
| 173 | + offlineSignalAbnormal(nearGps, ((GpsEntity) array[i - 1]), sch); | |
| 174 | + break; | |
| 175 | + } | |
| 176 | + } | |
| 177 | + | |
| 178 | + /** | |
| 179 | + * 掉线异常状态记录 | |
| 180 | + * | |
| 181 | + * @param e | |
| 182 | + * @param s | |
| 183 | + */ | |
| 184 | + private void offlineSignalAbnormal(GpsEntity e, GpsEntity s, ScheduleRealInfo sch) { | |
| 185 | + long st = s.getTimestamp(), et = e.getTimestamp(); | |
| 186 | + | |
| 187 | + //掉线超过10分钟才记录 | |
| 188 | + if (et - st < (1000 * 60 * 10)) | |
| 189 | + return; | |
| 190 | + | |
| 191 | + SignalAbnormal signalAbnormal = new SignalAbnormal(); | |
| 192 | + signalAbnormal.setSt(st); | |
| 193 | + signalAbnormal.setEt(et); | |
| 194 | + signalAbnormal.setAbnormalType("reconnection"); | |
| 195 | + signalAbnormal.setDestCode(sch.getQdzCode()); | |
| 196 | + signalAbnormal.setOutOrIn(0); | |
| 197 | + | |
| 198 | + //截断GPS | |
| 199 | + e.setSignalState("truncation"); | |
| 200 | + | |
| 201 | + //记录信号状态 | |
| 202 | + SignalState signalState = SignalState.abnormalSignalSTate(sch, signalAbnormal); | |
| 203 | + signalStateData.put(signalState); | |
| 204 | + } | |
| 205 | + | |
| 206 | + /** | |
| 207 | + * 漂移异常状态记录 | |
| 208 | + * | |
| 209 | + * @param nearGps | |
| 210 | + * @param i | |
| 211 | + * @param array | |
| 212 | + */ | |
| 213 | + private void driftSignalAbnormal(GpsEntity nearGps, int i, Object[] array, ScheduleRealInfo sch) { | |
| 214 | + GpsEntity gps, s = null; | |
| 215 | + //找到漂移开始时间 | |
| 216 | + for (; i >= 0; i--) { | |
| 217 | + gps = (GpsEntity) array[i]; | |
| 218 | + | |
| 219 | + if (!gps.getSignalState().equals("drift") || i == 0 | |
| 220 | + || gps.getSignalState().equals("truncation")) { | |
| 221 | + s = gps; | |
| 222 | + break; | |
| 223 | + } | |
| 224 | + } | |
| 225 | + | |
| 226 | + long st = s.getTimestamp(), et = nearGps.getTimestamp(); | |
| 227 | + if (et - st < (1000 * 60 * 3)) | |
| 228 | + return; | |
| 229 | + /*if (s != null){ | |
| 230 | + st = s.getTimestamp(); | |
| 231 | + //漂移小于3分钟 | |
| 232 | + if(et - st < (1000 * 60 * 3)) | |
| 233 | + return; | |
| 234 | + }*/ | |
| 235 | + | |
| 236 | + | |
| 237 | + SignalAbnormal signalAbnormal = new SignalAbnormal(); | |
| 238 | + signalAbnormal.setSt(st); | |
| 239 | + signalAbnormal.setEt(et); | |
| 240 | + signalAbnormal.setAbnormalType("drift"); | |
| 241 | + signalAbnormal.setDestCode(sch.getQdzCode()); | |
| 242 | + signalAbnormal.setOutOrIn(0); | |
| 243 | + | |
| 244 | + //截断GPS | |
| 245 | + nearGps.setSignalState("truncation"); | |
| 246 | + | |
| 247 | + //记录信号状态 | |
| 248 | + SignalState signalState = SignalState.abnormalSignalSTate(sch, signalAbnormal); | |
| 249 | + signalStateData.put(signalState); | |
| 250 | + } | |
| 251 | +} | ... | ... |
src/main/java/com/bsth/data/gpsdata/arrival/utils/SignalSchPlanMatcher.java
0 → 100644
| 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/arrival/utils/StationRouteComp.java
| 1 | -package com.bsth.data.gpsdata.arrival.utils; | |
| 2 | - | |
| 3 | -import com.bsth.data.gpsdata.arrival.entity.StationRoute; | |
| 4 | - | |
| 5 | -import java.util.Comparator; | |
| 6 | - | |
| 7 | -/** | |
| 8 | - * Created by panzhao on 2016/12/24. | |
| 9 | - */ | |
| 10 | -public class StationRouteComp implements Comparator<StationRoute>{ | |
| 11 | - @Override | |
| 12 | - public int compare(StationRoute s1, StationRoute s2) { | |
| 13 | - return s1.getRouteSort() - s2.getRouteSort(); | |
| 14 | - } | |
| 15 | -} | |
| 1 | +package com.bsth.data.gpsdata.arrival.utils; | |
| 2 | + | |
| 3 | +import com.bsth.data.gpsdata.arrival.entity.StationRoute; | |
| 4 | + | |
| 5 | +import java.util.Comparator; | |
| 6 | + | |
| 7 | +/** | |
| 8 | + * Created by panzhao on 2016/12/24. | |
| 9 | + */ | |
| 10 | +public class StationRouteComp implements Comparator<StationRoute>{ | |
| 11 | + @Override | |
| 12 | + public int compare(StationRoute s1, StationRoute s2) { | |
| 13 | + return s1.getRouteSort() - s2.getRouteSort(); | |
| 14 | + } | |
| 15 | +} | ... | ... |
src/main/java/com/bsth/data/gpsdata/recovery/GpsDataRecovery.java
| ... | ... | @@ -28,7 +28,7 @@ import java.util.concurrent.Executors; |
| 28 | 28 | * Created by panzhao on 2016/12/24. |
| 29 | 29 | */ |
| 30 | 30 | @Component |
| 31 | -public class GpsDataRecovery implements ApplicationContextAware{ | |
| 31 | +public class GpsDataRecovery implements ApplicationContextAware { | |
| 32 | 32 | |
| 33 | 33 | static Logger logger = LoggerFactory.getLogger(GpsDataRecovery.class); |
| 34 | 34 | |
| ... | ... | @@ -48,7 +48,7 @@ public class GpsDataRecovery implements ApplicationContextAware{ |
| 48 | 48 | //按车辆分组数据 |
| 49 | 49 | ArrayListMultimap<String, GpsEntity> listMap = ArrayListMultimap.create(); |
| 50 | 50 | for (GpsEntity gps : list) { |
| 51 | - if(gps.getNbbm() != null) | |
| 51 | + if (gps.getNbbm() != null) | |
| 52 | 52 | listMap.put(gps.getNbbm(), gps); |
| 53 | 53 | } |
| 54 | 54 | |
| ... | ... | @@ -60,6 +60,8 @@ public class GpsDataRecovery implements ApplicationContextAware{ |
| 60 | 60 | for (String nbbm : keys) { |
| 61 | 61 | Collections.sort(listMap.get(nbbm), comp); |
| 62 | 62 | threadPool.execute(new RecoveryThread(listMap.get(nbbm), count)); |
| 63 | + /*if(nbbm.equals("YT-CD008")) | |
| 64 | + new RecoveryThread(listMap.get(nbbm), count).run();*/ | |
| 63 | 65 | } |
| 64 | 66 | |
| 65 | 67 | try { |
| ... | ... | @@ -124,7 +126,7 @@ public class GpsDataRecovery implements ApplicationContextAware{ |
| 124 | 126 | reverseSignalHandle = applicationContext.getBean(ReverseSignalHandle.class); |
| 125 | 127 | } |
| 126 | 128 | |
| 127 | - public static class GpsComp implements Comparator<GpsEntity>{ | |
| 129 | + public static class GpsComp implements Comparator<GpsEntity> { | |
| 128 | 130 | |
| 129 | 131 | @Override |
| 130 | 132 | public int compare(GpsEntity g1, GpsEntity g2) { |
| ... | ... | @@ -132,26 +134,28 @@ public class GpsDataRecovery implements ApplicationContextAware{ |
| 132 | 134 | } |
| 133 | 135 | } |
| 134 | 136 | |
| 135 | - public static class RecoveryThread implements Runnable{ | |
| 137 | + public static class RecoveryThread implements Runnable { | |
| 136 | 138 | List<GpsEntity> list; |
| 137 | 139 | CountDownLatch count; |
| 138 | 140 | |
| 139 | - RecoveryThread(List<GpsEntity> list, CountDownLatch count){ | |
| 141 | + RecoveryThread(List<GpsEntity> list, CountDownLatch count) { | |
| 140 | 142 | this.list = list; |
| 141 | 143 | this.count = count; |
| 142 | 144 | } |
| 145 | + | |
| 143 | 146 | @Override |
| 144 | 147 | public void run() { |
| 145 | 148 | try { |
| 146 | 149 | //循环gps恢复数据 |
| 147 | 150 | CircleQueue<GpsEntity> prevs; |
| 148 | 151 | |
| 149 | - for(GpsEntity gps : list){ | |
| 152 | + for (GpsEntity gps : list) { | |
| 153 | + | |
| 150 | 154 | prevs = GeoCacheData.getGps(gps.getNbbm()); |
| 151 | 155 | //掉线处理 |
| 152 | 156 | offlineSignalHandle.handle(gps, prevs); |
| 153 | 157 | //状态处理 |
| 154 | - if(!correctSignalHandle.handle(gps, prevs)) | |
| 158 | + if (!correctSignalHandle.handle(gps, prevs)) | |
| 155 | 159 | continue; |
| 156 | 160 | //场,站内外判断 |
| 157 | 161 | stationInsideHandle.handle(gps, prevs); |
| ... | ... | @@ -160,11 +164,12 @@ public class GpsDataRecovery implements ApplicationContextAware{ |
| 160 | 164 | //进出站动作处理 |
| 161 | 165 | inOutStationSignalHandle.handle(gps, prevs); |
| 162 | 166 | GeoCacheData.putGps(gps); |
| 167 | + | |
| 168 | + //Thread.sleep(50); | |
| 163 | 169 | } |
| 164 | - }catch (Exception e){ | |
| 170 | + } catch (Exception e) { | |
| 165 | 171 | logger.error("", e); |
| 166 | - } | |
| 167 | - finally { | |
| 172 | + } finally { | |
| 168 | 173 | count.countDown(); |
| 169 | 174 | } |
| 170 | 175 | } | ... | ... |
src/main/java/com/bsth/data/schedule/DayOfSchedule.java
| ... | ... | @@ -2,8 +2,6 @@ package com.bsth.data.schedule; |
| 2 | 2 | |
| 3 | 3 | import com.alibaba.fastjson.JSON; |
| 4 | 4 | import com.alibaba.fastjson.JSONArray; |
| 5 | -import com.bsth.Application; | |
| 6 | -import com.bsth.data.BasicData; | |
| 7 | 5 | import com.bsth.data.LineConfigData; |
| 8 | 6 | import com.bsth.data.directive.FirstScheduleCheckThread; |
| 9 | 7 | import com.bsth.data.gpsdata.GpsRealData; |
| ... | ... | @@ -29,12 +27,12 @@ import org.slf4j.Logger; |
| 29 | 27 | import org.slf4j.LoggerFactory; |
| 30 | 28 | import org.springframework.beans.factory.annotation.Autowired; |
| 31 | 29 | import org.springframework.boot.CommandLineRunner; |
| 30 | +import org.springframework.core.annotation.Order; | |
| 32 | 31 | import org.springframework.stereotype.Component; |
| 33 | 32 | |
| 34 | 33 | import java.text.ParseException; |
| 35 | 34 | import java.text.SimpleDateFormat; |
| 36 | 35 | import java.util.*; |
| 37 | -import java.util.concurrent.TimeUnit; | |
| 38 | 36 | |
| 39 | 37 | /** |
| 40 | 38 | * @author PanZhao |
| ... | ... | @@ -43,6 +41,7 @@ import java.util.concurrent.TimeUnit; |
| 43 | 41 | * @date 2016年8月15日 上午10:16:12 |
| 44 | 42 | */ |
| 45 | 43 | @Component |
| 44 | +@Order(value = 3) | |
| 46 | 45 | public class DayOfSchedule implements CommandLineRunner { |
| 47 | 46 | |
| 48 | 47 | Logger logger = LoggerFactory.getLogger(this.getClass()); |
| ... | ... | @@ -117,19 +116,14 @@ public class DayOfSchedule implements CommandLineRunner { |
| 117 | 116 | LineConfigData lineConfigs; |
| 118 | 117 | |
| 119 | 118 | @Autowired |
| 120 | - BasicData.BasicDataLoader dataLoader; | |
| 121 | - | |
| 122 | - @Autowired | |
| 123 | 119 | GpsDataRecovery gpsDataRecovery; |
| 124 | 120 | |
| 125 | 121 | private static DateTimeFormatter fmtyyyyMMdd = DateTimeFormat.forPattern("yyyy-MM-dd"), fmtHHmm = DateTimeFormat.forPattern("HH:mm"); |
| 126 | 122 | |
| 127 | 123 | @Override |
| 128 | 124 | public void run(String... arg0) throws Exception { |
| 129 | - //加载基础数据 | |
| 130 | - dataLoader.loadAllData(); | |
| 131 | 125 | //从数据库恢复排班 |
| 132 | - dataRecovery(); | |
| 126 | + //dataRecovery(); | |
| 133 | 127 | |
| 134 | 128 | //翻班线程 |
| 135 | 129 | // Application.mainServices.scheduleWithFixedDelay(scheduleRefreshThread, 15, 240, TimeUnit.SECONDS); |
| ... | ... | @@ -138,7 +132,7 @@ public class DayOfSchedule implements CommandLineRunner { |
| 138 | 132 | //首班出场指令补发器 |
| 139 | 133 | // Application.mainServices.scheduleWithFixedDelay(firstScheduleCheckThread, 30, 240, TimeUnit.SECONDS); |
| 140 | 134 | //班次误点扫描 |
| 141 | - Application.mainServices.scheduleWithFixedDelay(scheduleLateThread, 60, 60, TimeUnit.SECONDS); | |
| 135 | +// Application.mainServices.scheduleWithFixedDelay(scheduleLateThread, 60, 60, TimeUnit.SECONDS); | |
| 142 | 136 | |
| 143 | 137 | //每天凌晨2点20提交数据到运管处 |
| 144 | 138 | long diff = (DateUtils.getTimestamp() + 1000 * 60 * 140) - System.currentTimeMillis(); |
| ... | ... | @@ -224,15 +218,8 @@ public class DayOfSchedule implements CommandLineRunner { |
| 224 | 218 | reCalcExecPlan(nbbm); |
| 225 | 219 | } |
| 226 | 220 | |
| 227 | - //是否是出站即出场 | |
| 228 | - LineConfig conf = lineConfigData.get(lineCode); | |
| 229 | - if (conf.getOutConfig() == 2) { | |
| 230 | - for (String nbbm : cars) | |
| 231 | - schAttrCalculator.connectOutSchedule(nbbmScheduleMap.get(nbbm)); | |
| 232 | - } | |
| 233 | - | |
| 234 | 221 | // 页面 翻班通知 |
| 235 | - sendUtils.shiftSchedule(lineCode); | |
| 222 | + //sendUtils.shiftSchedule(lineCode); | |
| 236 | 223 | } catch (Exception e) { |
| 237 | 224 | logger.error("", e); |
| 238 | 225 | return -1; |
| ... | ... | @@ -503,6 +490,41 @@ public class DayOfSchedule implements CommandLineRunner { |
| 503 | 490 | } |
| 504 | 491 | |
| 505 | 492 | /** |
| 493 | + * 下一个相同走向的班次 | |
| 494 | + * @param sch | |
| 495 | + * @return | |
| 496 | + */ | |
| 497 | + public ScheduleRealInfo nextSame(ScheduleRealInfo sch){ | |
| 498 | + List<ScheduleRealInfo> list = nbbmScheduleMap.get(sch.getClZbh()); | |
| 499 | + int outConfig = -1; | |
| 500 | + LineConfig config = lineConfigData.get(sch.getXlBm()); | |
| 501 | + if (config != null) | |
| 502 | + outConfig = config.getOutConfig(); | |
| 503 | + | |
| 504 | + boolean flag = false; | |
| 505 | + ScheduleRealInfo next = null; | |
| 506 | + for (ScheduleRealInfo temp : list) { | |
| 507 | + if (temp.getId() == sch.getId()) { | |
| 508 | + flag = true; | |
| 509 | + continue; | |
| 510 | + } | |
| 511 | + //忽略烂班 | |
| 512 | + if (temp.isDestroy()) | |
| 513 | + continue; | |
| 514 | + | |
| 515 | + //出站既出场,忽略出场班次 | |
| 516 | + if (outConfig == 2 && temp.getBcType().equals("out")) | |
| 517 | + continue; | |
| 518 | + | |
| 519 | + if (flag && temp.getXlDir().equals(sch.getXlDir())) { | |
| 520 | + next = temp; | |
| 521 | + break; | |
| 522 | + } | |
| 523 | + } | |
| 524 | + return next; | |
| 525 | + } | |
| 526 | + | |
| 527 | + /** | |
| 506 | 528 | * 上一个班次 |
| 507 | 529 | * |
| 508 | 530 | * @param sch |
| ... | ... | @@ -527,6 +549,18 @@ public class DayOfSchedule implements CommandLineRunner { |
| 527 | 549 | return prev; |
| 528 | 550 | } |
| 529 | 551 | |
| 552 | + /** | |
| 553 | + * 是否是首班出场 | |
| 554 | + * @param sch | |
| 555 | + * @return | |
| 556 | + */ | |
| 557 | + public boolean isFirstOut(ScheduleRealInfo sch){ | |
| 558 | + List<ScheduleRealInfo> list = nbbmScheduleMap.get(sch.getClZbh()); | |
| 559 | + if(list.get(0).equals(sch) && sch.getBcType().equals("out")) | |
| 560 | + return true; | |
| 561 | + return false; | |
| 562 | + } | |
| 563 | + | |
| 530 | 564 | public void put(ScheduleRealInfo sch) { |
| 531 | 565 | schAttrCalculator |
| 532 | 566 | .calcRealDate(sch) | ... | ... |
src/main/java/com/bsth/data/schedule/SchAttrCalculator.java
| ... | ... | @@ -62,13 +62,13 @@ public class SchAttrCalculator { |
| 62 | 62 | sch.setDfsjAll(fmtyyyyMMddHHmm.parseMillis(sch.getScheduleDateStr()+sch.getDfsj())); |
| 63 | 63 | |
| 64 | 64 | //實發時間 |
| 65 | - if(sch.getFcsjActual() != null && | |
| 65 | + if(StringUtils.isNotEmpty(sch.getFcsjActual()) && | |
| 66 | 66 | sch.getFcsjActual().compareTo(conf.getStartOpt()) < 0){ |
| 67 | 67 | sch.setFcsjActualAll(fmtyyyyMMddHHmm.parseMillis(sch.getScheduleDateStr()+sch.getFcsjActual()) + DAY_TIME); |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | //實際終點時間 |
| 71 | - if(sch.getZdsjActual() != null && | |
| 71 | + if(StringUtils.isNotEmpty(sch.getZdsjActual()) && | |
| 72 | 72 | sch.getZdsjActual().compareTo(conf.getStartOpt()) < 0){ |
| 73 | 73 | sch.setZdsjActualAll(fmtyyyyMMddHHmm.parseMillis(sch.getScheduleDateStr()+sch.getZdsjActual()) + DAY_TIME); |
| 74 | 74 | } |
| ... | ... | @@ -162,34 +162,6 @@ public class SchAttrCalculator { |
| 162 | 162 | |
| 163 | 163 | return updateList; |
| 164 | 164 | } |
| 165 | - | |
| 166 | - /** | |
| 167 | - * | |
| 168 | - * @Title: connectOutSchedule | |
| 169 | - * @Description: TODO(关联出场班次) | |
| 170 | - */ | |
| 171 | - public void connectOutSchedule(List<ScheduleRealInfo> list){ | |
| 172 | - Collections.sort(list, new ScheduleComparator.FCSJ()); | |
| 173 | - | |
| 174 | - int len = list.size(); | |
| 175 | - if(len == 0) | |
| 176 | - return; | |
| 177 | - | |
| 178 | - ScheduleRealInfo prve = list.get(0), curr; | |
| 179 | - for(int i = 1; i < len; i ++){ | |
| 180 | - curr = list.get(i); | |
| 181 | - | |
| 182 | - //出站即出场关联 | |
| 183 | - if(prve.getBcType().equals("out") && prve.getJhlc() == null) | |
| 184 | - curr.setTwinsSch(prve); | |
| 185 | - | |
| 186 | - //进站即进场关联 | |
| 187 | - if(curr.getBcType().equals("in") && curr.getJhlc() == null) | |
| 188 | - prve.setTwinsSch(curr); | |
| 189 | - | |
| 190 | - prve = curr; | |
| 191 | - } | |
| 192 | - } | |
| 193 | 165 | |
| 194 | 166 | public SchAttrCalculator calcFcsjTime(ScheduleRealInfo sch) throws ParseException { |
| 195 | 167 | sch.setFcsjT(fmtyyyyMMddHHmm.parseMillis(sch.getRealExecDate() + sch.getFcsj())); | ... | ... |
src/main/java/com/bsth/entity/mcy_forms/Daily.java
0 → 100644
| 1 | +package com.bsth.entity.mcy_forms; | |
| 2 | + | |
| 3 | +public class Daily { | |
| 4 | + | |
| 5 | + private String rq;//日期 | |
| 6 | + | |
| 7 | + public String getRq() { | |
| 8 | + return rq; | |
| 9 | + } | |
| 10 | + | |
| 11 | + public void setRq(String rq) { | |
| 12 | + this.rq = rq; | |
| 13 | + } | |
| 14 | + | |
| 15 | + private String zbh;//车牌号 | |
| 16 | + | |
| 17 | + private String jgh;//员工号 | |
| 18 | + | |
| 19 | + private String jName;//驾驶员 | |
| 20 | + | |
| 21 | + private String zlc;//里程 | |
| 22 | + | |
| 23 | + private String jzl1;//空驶公里 | |
| 24 | + | |
| 25 | + private String yh;//油耗 | |
| 26 | + | |
| 27 | + private String bc;//班次 | |
| 28 | + | |
| 29 | + public String getZbh() { | |
| 30 | + return zbh; | |
| 31 | + } | |
| 32 | + | |
| 33 | + public void setZbh(String zbh) { | |
| 34 | + this.zbh = zbh; | |
| 35 | + } | |
| 36 | + | |
| 37 | + public String getJgh() { | |
| 38 | + return jgh; | |
| 39 | + } | |
| 40 | + | |
| 41 | + public void setJgh(String jgh) { | |
| 42 | + this.jgh = jgh; | |
| 43 | + } | |
| 44 | + | |
| 45 | + public String getjName() { | |
| 46 | + return jName; | |
| 47 | + } | |
| 48 | + | |
| 49 | + public void setjName(String jName) { | |
| 50 | + this.jName = jName; | |
| 51 | + } | |
| 52 | + | |
| 53 | + public String getZlc() { | |
| 54 | + return zlc; | |
| 55 | + } | |
| 56 | + | |
| 57 | + public void setZlc(String zlc) { | |
| 58 | + this.zlc = zlc; | |
| 59 | + } | |
| 60 | + | |
| 61 | + public String getJzl1() { | |
| 62 | + return jzl1; | |
| 63 | + } | |
| 64 | + | |
| 65 | + public void setJzl1(String jzl1) { | |
| 66 | + this.jzl1 = jzl1; | |
| 67 | + } | |
| 68 | + | |
| 69 | + public String getYh() { | |
| 70 | + return yh; | |
| 71 | + } | |
| 72 | + | |
| 73 | + public void setYh(String yh) { | |
| 74 | + this.yh = yh; | |
| 75 | + } | |
| 76 | + | |
| 77 | + public String getBc() { | |
| 78 | + return bc; | |
| 79 | + } | |
| 80 | + | |
| 81 | + public void setBc(String bc) { | |
| 82 | + this.bc = bc; | |
| 83 | + } | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | +} | ... | ... |
src/main/java/com/bsth/entity/realcontrol/LineConfig.java
| ... | ... | @@ -53,6 +53,9 @@ public class LineConfig { |
| 53 | 53 | /** 调度指令模板 */ |
| 54 | 54 | private String schDirectiveTemp; |
| 55 | 55 | |
| 56 | + /** 识别区间调头 */ | |
| 57 | + private boolean readReverse; | |
| 58 | + | |
| 56 | 59 | @OneToMany(cascade = CascadeType.ALL) |
| 57 | 60 | private Set<D80ReplyTemp> d80Temps = new HashSet<>(); |
| 58 | 61 | |
| ... | ... | @@ -140,4 +143,12 @@ public class LineConfig { |
| 140 | 143 | public void setD80Temps(Set<D80ReplyTemp> d80Temps) { |
| 141 | 144 | this.d80Temps = d80Temps; |
| 142 | 145 | } |
| 146 | + | |
| 147 | + public boolean isReadReverse() { | |
| 148 | + return readReverse; | |
| 149 | + } | |
| 150 | + | |
| 151 | + public void setReadReverse(boolean readReverse) { | |
| 152 | + this.readReverse = readReverse; | |
| 153 | + } | |
| 143 | 154 | } | ... | ... |
src/main/java/com/bsth/entity/realcontrol/ScheduleRealInfo.java
| ... | ... | @@ -94,11 +94,6 @@ public class ScheduleRealInfo { |
| 94 | 94 | * 班次类型 TODO:正常班次、出场、进场、加油、区间班次、放空班次、放大站班次、两点间空驶 |
| 95 | 95 | */ |
| 96 | 96 | private String bcType; |
| 97 | - | |
| 98 | - /** 出站即出场 , 关联的进出场班次 */ | |
| 99 | - @JsonIgnore | |
| 100 | - @Transient | |
| 101 | - private ScheduleRealInfo twinsSch; | |
| 102 | 97 | |
| 103 | 98 | /** 创建人 */ |
| 104 | 99 | @JsonIgnore |
| ... | ... | @@ -258,21 +253,6 @@ public class ScheduleRealInfo { |
| 258 | 253 | this.ccno = ccno; |
| 259 | 254 | } |
| 260 | 255 | |
| 261 | - public static DateTimeFormatter getFmtHHmm() { | |
| 262 | - return fmtHHmm; | |
| 263 | - } | |
| 264 | - | |
| 265 | - public static void setFmtHHmm(DateTimeFormatter fmtHHmm) { | |
| 266 | - ScheduleRealInfo.fmtHHmm = fmtHHmm; | |
| 267 | - } | |
| 268 | - | |
| 269 | - public static DateTimeFormatter getFmtyyyyMMddHHmm() { | |
| 270 | - return fmtyyyyMMddHHmm; | |
| 271 | - } | |
| 272 | - | |
| 273 | - public static void setFmtyyyyMMddHHmm(DateTimeFormatter fmtyyyyMMddHHmm) { | |
| 274 | - ScheduleRealInfo.fmtyyyyMMddHHmm = fmtyyyyMMddHHmm; | |
| 275 | - } | |
| 276 | 256 | |
| 277 | 257 | /** ---------------- |
| 278 | 258 | @OneToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL) |
| ... | ... | @@ -804,13 +784,13 @@ public class ScheduleRealInfo { |
| 804 | 784 | this.opDirectiveState = opDirectiveState; |
| 805 | 785 | } |
| 806 | 786 | |
| 807 | - public ScheduleRealInfo getTwinsSch() { | |
| 787 | +/* public ScheduleRealInfo getTwinsSch() { | |
| 808 | 788 | return twinsSch; |
| 809 | 789 | } |
| 810 | 790 | |
| 811 | 791 | public void setTwinsSch(ScheduleRealInfo twinsSch) { |
| 812 | 792 | this.twinsSch = twinsSch; |
| 813 | - } | |
| 793 | + }*/ | |
| 814 | 794 | |
| 815 | 795 | public boolean isLate() { |
| 816 | 796 | return late; | ... | ... |
src/main/java/com/bsth/repository/realcontrol/ScheduleRealInfoRepository.java
| ... | ... | @@ -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') 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) | |
| 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) | |
| 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 | -} | |
| 128 | +} | |
| 129 | 129 | \ No newline at end of file | ... | ... |
src/main/java/com/bsth/service/excep/impl/OfflineServiceImpl.java
| ... | ... | @@ -46,23 +46,33 @@ public class OfflineServiceImpl implements OfflineService { |
| 46 | 46 | Object line=map.get("line"); |
| 47 | 47 | Object nbbm=map.get("nbbm"); |
| 48 | 48 | Object updown=map.get("updown"); |
| 49 | - | |
| 49 | + Object date=map.get("date"); | |
| 50 | 50 | |
| 51 | 51 | if(line!=null){ |
| 52 | - if(line.toString()!="") | |
| 53 | - sql +=" and line="+line; | |
| 52 | + sql +=" and line like'%"+line.toString()+"%'"; | |
| 54 | 53 | } |
| 55 | 54 | |
| 56 | 55 | if(nbbm!=null){ |
| 57 | - if(nbbm.toString()!="") | |
| 58 | - sql +=" and vehicle like '%"+nbbm+"%'"; | |
| 56 | + sql +=" and vehicle like '%"+nbbm.toString()+"%'"; | |
| 59 | 57 | } |
| 60 | 58 | |
| 61 | 59 | if(updown!=null){ |
| 62 | - if(updown.toString() !="") | |
| 63 | - sql +="and up_down ="+updown; | |
| 60 | + sql +="and up_down like '%"+updown.toString()+"%'"; | |
| 61 | + } | |
| 62 | + if(date!=null){ | |
| 63 | + if (date.toString().length()>0) { | |
| 64 | + SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:MM:SS"); | |
| 65 | + try { | |
| 66 | + Long t1=sdf.parse(date.toString()+" 00:00:00").getTime(); | |
| 67 | + Long t2=sdf.parse(date.toString()+" 23:59:59").getTime(); | |
| 68 | + sql += " and timestamp >="+t1 +" and timestamp <="+t2; | |
| 69 | + } catch (ParseException e) { | |
| 70 | + // TODO Auto-generated catch block | |
| 71 | + e.printStackTrace(); | |
| 72 | + } | |
| 73 | + } | |
| 74 | + | |
| 64 | 75 | } |
| 65 | - | |
| 66 | 76 | sql +=" order by id limit ?,?"; |
| 67 | 77 | |
| 68 | 78 | try { |
| ... | ... | @@ -118,19 +128,32 @@ public class OfflineServiceImpl implements OfflineService { |
| 118 | 128 | Object nbbm=map.get("nbbm"); |
| 119 | 129 | Object updown=map.get("updown"); |
| 120 | 130 | |
| 131 | + Object date=map.get("date"); | |
| 132 | + | |
| 121 | 133 | if(line!=null){ |
| 122 | - if(line.toString()!="") | |
| 123 | - sql +=" and line="+line; | |
| 134 | + sql +=" and line like'%"+line.toString()+"%'"; | |
| 124 | 135 | } |
| 125 | 136 | |
| 126 | 137 | if(nbbm!=null){ |
| 127 | - if(nbbm.toString()!="") | |
| 128 | - sql +=" and vehicle like '%"+nbbm+"%'"; | |
| 138 | + sql +=" and vehicle like '%"+nbbm.toString()+"%'"; | |
| 129 | 139 | } |
| 130 | 140 | |
| 131 | 141 | if(updown!=null){ |
| 132 | - if(updown.toString() !="") | |
| 133 | - sql +="and up_down ="+updown; | |
| 142 | + sql +="and up_down like '%"+updown.toString()+"%'"; | |
| 143 | + } | |
| 144 | + if(date!=null){ | |
| 145 | + if (date.toString().length()>0) { | |
| 146 | + SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:MM:SS"); | |
| 147 | + try { | |
| 148 | + Long t1=sdf.parse(date.toString()+" 00:00:00").getTime(); | |
| 149 | + Long t2=sdf.parse(date.toString()+" 23:59:59").getTime(); | |
| 150 | + sql += " and timestamp >="+t1 +" and timestamp <="+t2; | |
| 151 | + } catch (ParseException e) { | |
| 152 | + // TODO Auto-generated catch block | |
| 153 | + e.printStackTrace(); | |
| 154 | + } | |
| 155 | + } | |
| 156 | + | |
| 134 | 157 | } |
| 135 | 158 | |
| 136 | 159 | Connection conn = null; | ... | ... |
src/main/java/com/bsth/service/excep/impl/OutboundServiceImpl.java
| ... | ... | @@ -36,23 +36,33 @@ public class OutboundServiceImpl implements OutboundService{ |
| 36 | 36 | Object line=map.get("line"); |
| 37 | 37 | Object nbbm=map.get("nbbm"); |
| 38 | 38 | Object updown=map.get("updown"); |
| 39 | + Object date=map.get("date"); | |
| 39 | 40 | |
| 40 | - | |
| 41 | 41 | if(line!=null){ |
| 42 | - if(line.toString()!="") | |
| 43 | - sql +=" and line="+line; | |
| 42 | + sql +=" and line like'%"+line.toString()+"%'"; | |
| 44 | 43 | } |
| 45 | 44 | |
| 46 | 45 | if(nbbm!=null){ |
| 47 | - if(nbbm.toString()!="") | |
| 48 | - sql +=" and vehicle like '%"+nbbm+"%'"; | |
| 46 | + sql +=" and vehicle like '%"+nbbm.toString()+"%'"; | |
| 49 | 47 | } |
| 50 | 48 | |
| 51 | 49 | if(updown!=null){ |
| 52 | - if(updown.toString() !="") | |
| 53 | - sql +="and up_down ="+updown; | |
| 50 | + sql +="and up_down like '%"+updown.toString()+"%'"; | |
| 51 | + } | |
| 52 | + if(date!=null){ | |
| 53 | + if (date.toString().length()>0) { | |
| 54 | + SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:MM:SS"); | |
| 55 | + try { | |
| 56 | + Long t1=sdf.parse(date.toString()+" 00:00:00").getTime(); | |
| 57 | + Long t2=sdf.parse(date.toString()+" 23:59:59").getTime(); | |
| 58 | + sql += " and timestamp >="+t1 +" and timestamp <="+t2; | |
| 59 | + } catch (ParseException e) { | |
| 60 | + // TODO Auto-generated catch block | |
| 61 | + e.printStackTrace(); | |
| 62 | + } | |
| 63 | + } | |
| 64 | + | |
| 54 | 65 | } |
| 55 | - | |
| 56 | 66 | sql +=" order by id limit ?,?"; |
| 57 | 67 | |
| 58 | 68 | |
| ... | ... | @@ -102,20 +112,32 @@ public class OutboundServiceImpl implements OutboundService{ |
| 102 | 112 | Object line=map.get("line"); |
| 103 | 113 | Object nbbm=map.get("nbbm"); |
| 104 | 114 | Object updown=map.get("updown"); |
| 105 | - | |
| 115 | + Object date=map.get("date"); | |
| 106 | 116 | if(line!=null){ |
| 107 | - if(line.toString()!="") | |
| 108 | - sql +=" and line="+line; | |
| 117 | + sql +=" and line like '%"+line.toString()+"%'"; | |
| 118 | + | |
| 109 | 119 | } |
| 110 | 120 | |
| 111 | 121 | if(nbbm!=null){ |
| 112 | - if(nbbm.toString()!="") | |
| 113 | - sql +=" and vehicle like '%"+nbbm+"%'"; | |
| 122 | + sql +=" and vehicle like '%"+nbbm.toString()+"%'"; | |
| 114 | 123 | } |
| 115 | 124 | |
| 116 | 125 | if(updown!=null){ |
| 117 | - if(updown.toString() !="") | |
| 118 | - sql +="and up_down ="+updown; | |
| 126 | + sql +=" and up_down like '%"+updown.toString()+"%'"; | |
| 127 | + } | |
| 128 | + if(date!=null){ | |
| 129 | + if (date.toString().length()>0) { | |
| 130 | + SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | |
| 131 | + try { | |
| 132 | + Long t1=sdf.parse(date.toString()+" 00:00:00").getTime(); | |
| 133 | + Long t2=sdf.parse(date.toString()+" 23:59:59").getTime(); | |
| 134 | + sql += " and timestamp >="+t1 +" and timestamp <="+t2; | |
| 135 | + } catch (ParseException e) { | |
| 136 | + // TODO Auto-generated catch block | |
| 137 | + e.printStackTrace(); | |
| 138 | + } | |
| 139 | + } | |
| 140 | + | |
| 119 | 141 | } |
| 120 | 142 | Connection conn = null; |
| 121 | 143 | PreparedStatement ps = null; |
| ... | ... | @@ -214,7 +236,7 @@ public class OutboundServiceImpl implements OutboundService{ |
| 214 | 236 | times=sdf.format(new Date()); |
| 215 | 237 | } |
| 216 | 238 | SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| 217 | - String times1=times+" 00:00:01"; | |
| 239 | + String times1=times+" 00:00:00"; | |
| 218 | 240 | String times2=times+" 23:59:59"; |
| 219 | 241 | |
| 220 | 242 | Connection conn = null; | ... | ... |
src/main/java/com/bsth/service/excep/impl/SpeedingServiceImpl.java
| ... | ... | @@ -38,22 +38,34 @@ public class SpeedingServiceImpl implements SpeedingService { |
| 38 | 38 | Object line=map.get("line"); |
| 39 | 39 | Object nbbm=map.get("nbbm"); |
| 40 | 40 | Object updown=map.get("updown"); |
| 41 | - | |
| 41 | + Object date=map.get("date"); | |
| 42 | 42 | |
| 43 | 43 | if(line!=null){ |
| 44 | - if(line.toString()!="") | |
| 45 | - sql +=" and line="+line; | |
| 44 | + sql +=" and line like'%"+line.toString()+"%'"; | |
| 46 | 45 | } |
| 47 | 46 | |
| 48 | 47 | if(nbbm!=null){ |
| 49 | - if(nbbm.toString()!="") | |
| 50 | - sql +=" and vehicle like '%"+nbbm+"%'"; | |
| 48 | + sql +=" and vehicle like '%"+nbbm.toString()+"%'"; | |
| 51 | 49 | } |
| 52 | 50 | |
| 53 | 51 | if(updown!=null){ |
| 54 | - if(updown.toString() !="") | |
| 55 | - sql +="and up_down ="+updown; | |
| 52 | + sql +="and up_down like '%"+updown.toString()+"%'"; | |
| 53 | + } | |
| 54 | + if(date!=null){ | |
| 55 | + if (date.toString().length()>0) { | |
| 56 | + SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:MM:SS"); | |
| 57 | + try { | |
| 58 | + Long t1=sdf.parse(date.toString()+" 00:00:00").getTime(); | |
| 59 | + Long t2=sdf.parse(date.toString()+" 23:59:59").getTime(); | |
| 60 | + sql += " and timestamp >="+t1 +" and timestamp <="+t2; | |
| 61 | + } catch (ParseException e) { | |
| 62 | + // TODO Auto-generated catch block | |
| 63 | + e.printStackTrace(); | |
| 64 | + } | |
| 65 | + } | |
| 66 | + | |
| 56 | 67 | } |
| 68 | + | |
| 57 | 69 | |
| 58 | 70 | sql +=" order by id limit ?,?"; |
| 59 | 71 | |
| ... | ... | @@ -103,19 +115,32 @@ public class SpeedingServiceImpl implements SpeedingService { |
| 103 | 115 | Object nbbm=map.get("nbbm"); |
| 104 | 116 | Object updown=map.get("updown"); |
| 105 | 117 | |
| 118 | + Object date=map.get("date"); | |
| 119 | + | |
| 106 | 120 | if(line!=null){ |
| 107 | - if(line.toString()!="") | |
| 108 | - sql +=" and line="+line; | |
| 121 | + sql +=" and line like'%"+line.toString()+"%'"; | |
| 109 | 122 | } |
| 110 | 123 | |
| 111 | 124 | if(nbbm!=null){ |
| 112 | - if(nbbm.toString()!="") | |
| 113 | - sql +=" and vehicle like '%"+nbbm+"%'"; | |
| 125 | + sql +=" and vehicle like '%"+nbbm.toString()+"%'"; | |
| 114 | 126 | } |
| 115 | 127 | |
| 116 | 128 | if(updown!=null){ |
| 117 | - if(updown.toString() !="") | |
| 118 | - sql +="and up_down ="+updown; | |
| 129 | + sql +="and up_down like '%"+updown.toString()+"%'"; | |
| 130 | + } | |
| 131 | + if(date!=null){ | |
| 132 | + if (date.toString().length()>0) { | |
| 133 | + SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:MM:SS"); | |
| 134 | + try { | |
| 135 | + Long t1=sdf.parse(date.toString()+" 00:00:00").getTime(); | |
| 136 | + Long t2=sdf.parse(date.toString()+" 23:59:59").getTime(); | |
| 137 | + sql += " and timestamp >="+t1 +" and timestamp <="+t2; | |
| 138 | + } catch (ParseException e) { | |
| 139 | + // TODO Auto-generated catch block | |
| 140 | + e.printStackTrace(); | |
| 141 | + } | |
| 142 | + } | |
| 143 | + | |
| 119 | 144 | } |
| 120 | 145 | Connection conn = null; |
| 121 | 146 | PreparedStatement ps = null; | ... | ... |
src/main/java/com/bsth/service/forms/ExportService.java
| ... | ... | @@ -2,6 +2,7 @@ package com.bsth.service.forms; |
| 2 | 2 | |
| 3 | 3 | import java.util.List; |
| 4 | 4 | |
| 5 | +import com.bsth.entity.mcy_forms.Daily; | |
| 5 | 6 | import com.bsth.entity.mcy_forms.Linepasswengerflow; |
| 6 | 7 | import com.bsth.entity.mcy_forms.Operationservice; |
| 7 | 8 | import com.bsth.entity.mcy_forms.Shifday; |
| ... | ... | @@ -28,6 +29,6 @@ public interface ExportService { |
| 28 | 29 | public void operationservice(String startDate, String endDate, String lpName, |
| 29 | 30 | List<Operationservice> resList); |
| 30 | 31 | |
| 31 | - | |
| 32 | + | |
| 32 | 33 | |
| 33 | 34 | } | ... | ... |
src/main/java/com/bsth/service/forms/FormsService.java
| ... | ... | @@ -5,6 +5,7 @@ import java.util.Map; |
| 5 | 5 | |
| 6 | 6 | import com.bsth.entity.mcy_forms.Allline; |
| 7 | 7 | import com.bsth.entity.mcy_forms.Changetochange; |
| 8 | +import com.bsth.entity.mcy_forms.Daily; | |
| 8 | 9 | import com.bsth.entity.mcy_forms.Executionrate; |
| 9 | 10 | import com.bsth.entity.mcy_forms.Linepasswengerflow; |
| 10 | 11 | import com.bsth.entity.mcy_forms.Operationservice; |
| ... | ... | @@ -39,4 +40,6 @@ public interface FormsService { |
| 39 | 40 | public List<Executionrate> executionrate(Map<String, Object> map); |
| 40 | 41 | |
| 41 | 42 | public List<Allline> allline(Map<String, Object> map); |
| 43 | + | |
| 44 | + public List<Daily> daily(Map<String, Object> map); | |
| 42 | 45 | } | ... | ... |
src/main/java/com/bsth/service/forms/impl/FormsServiceImpl.java
| ... | ... | @@ -25,6 +25,7 @@ import com.bsth.entity.mcy_forms.Vehicleloading; |
| 25 | 25 | import com.bsth.entity.mcy_forms.Waybillday; |
| 26 | 26 | import com.bsth.entity.mcy_forms.Allline; |
| 27 | 27 | import com.bsth.entity.mcy_forms.Changetochange; |
| 28 | +import com.bsth.entity.mcy_forms.Daily; | |
| 28 | 29 | import com.bsth.entity.mcy_forms.Executionrate; |
| 29 | 30 | import com.bsth.service.forms.CommonService; |
| 30 | 31 | import com.bsth.service.forms.FormsService; |
| ... | ... | @@ -290,6 +291,7 @@ public class FormsServiceImpl implements FormsService { |
| 290 | 291 | |
| 291 | 292 | List<Changetochange> list = jdbcTemplate.query(sql, new RowMapper<Changetochange>() { |
| 292 | 293 | |
| 294 | + | |
| 293 | 295 | @Override |
| 294 | 296 | public Changetochange mapRow(ResultSet arg0, int arg1) throws SQLException { |
| 295 | 297 | Changetochange chan = new Changetochange(); |
| ... | ... | @@ -314,6 +316,7 @@ public class FormsServiceImpl implements FormsService { |
| 314 | 316 | return list; |
| 315 | 317 | } |
| 316 | 318 | |
| 319 | + | |
| 317 | 320 | // 路单数据 |
| 318 | 321 | @Override |
| 319 | 322 | public List<Singledata> singledata(Map<String, Object> map) { |
| ... | ... | @@ -706,4 +709,46 @@ public class FormsServiceImpl implements FormsService { |
| 706 | 709 | |
| 707 | 710 | return list; |
| 708 | 711 | } |
| 712 | + | |
| 713 | + @Override | |
| 714 | + public List<Daily> daily(Map<String, Object> map) { | |
| 715 | + | |
| 716 | + String sql ="select r.schedule_date_str,r.xl_bm,r.xl_name,r.cl_zbh,r.j_gh,r.j_name,y.YH,r.gs_bm,r.gs_name,r.fgs_bm,r.fgs_name " | |
| 717 | + + " from bsth_c_s_sp_info_real r LEFT JOIN bsth_c_ylb y ON r.cl_zbh = y.nbbm " | |
| 718 | + + " WHERE 1 = 1" | |
| 719 | + + " and r.xl_bm='" + map.get("line").toString() + "'" | |
| 720 | + + " and to_days(r.schedule_date)=to_days('"+map.get("date").toString()+"')" | |
| 721 | + + " AND r.gs_bm is not null"; | |
| 722 | + | |
| 723 | + if(map.get("gsdmDaily").toString()!=""){ | |
| 724 | + sql+=" and r.gs_bm='"+map.get("gsdmDaily").toString()+"'"; | |
| 725 | + } | |
| 726 | + if(map.get("fgsdmDaily").toString()!=""){ | |
| 727 | + sql+=" and r.fgs_bm='"+map.get("fgsdmDaily").toString()+"'"; | |
| 728 | + } | |
| 729 | + sql += " GROUP BY r.schedule_date_str,r.xl_bm,r.xl_name,r.cl_zbh,r.j_gh,r.j_name,y.YH,r.gs_bm,r.gs_name,r.fgs_bm,r.fgs_name "; | |
| 730 | + | |
| 731 | + List<Daily> list = jdbcTemplate.query(sql, new RowMapper<Daily>() { | |
| 732 | + @Override | |
| 733 | + public Daily mapRow(ResultSet arg0, int arg1) throws SQLException { | |
| 734 | + Daily daily = new Daily(); | |
| 735 | + daily.setRq(arg0.getString("schedule_date_str")); | |
| 736 | + daily.setZbh(arg0.getString("cl_zbh")); | |
| 737 | + daily.setJgh(arg0.getString("j_gh")); | |
| 738 | + daily.setjName(arg0.getString("j_name")); | |
| 739 | + daily.setYh(arg0.getString("YH")); | |
| 740 | + return daily; | |
| 741 | + } | |
| 742 | + }); | |
| 743 | + | |
| 744 | + for(int i=0;i<list.size();i++){ | |
| 745 | + Daily d=list.get(i); | |
| 746 | + Map<String, Object> maps = new HashMap<>(); | |
| 747 | + maps = commonService.findKMBC2(d.getJgh(),d.getZbh(),d.getRq()); | |
| 748 | + d.setJzl1(maps.get("ksgl").toString()); | |
| 749 | + d.setZlc(maps.get("realMileage").toString()); | |
| 750 | + d.setBc(maps.get("sjbc").toString()); | |
| 751 | + } | |
| 752 | + return list; | |
| 753 | + } | |
| 709 | 754 | } | ... | ... |
src/main/java/com/bsth/service/realcontrol/impl/ScheduleRealInfoServiceImpl.java
| ... | ... | @@ -1212,7 +1212,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInf |
| 1212 | 1212 | map.put("ljbc", ljbc); |
| 1213 | 1213 | map.put("sjbc", jhbc-cjbc+ljbc); |
| 1214 | 1214 | map.put("jcclc", jcclc); |
| 1215 | - map.put("zkslc", ksgl+jcclc); | |
| 1215 | + map.put("zkslc", format.format(ksgl+jcclc)); | |
| 1216 | 1216 | return map; |
| 1217 | 1217 | } |
| 1218 | 1218 | |
| ... | ... | @@ -1226,7 +1226,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInf |
| 1226 | 1226 | if(obj != null){ |
| 1227 | 1227 | map = new HashMap<String,Object>(); |
| 1228 | 1228 | map.put("xlName", xlName); |
| 1229 | - map.put("clZbh", code); | |
| 1229 | + map.put("clZbh", obj[3]); | |
| 1230 | 1230 | map.put("company", obj[0]); |
| 1231 | 1231 | map.put("requestType", "0x" + Integer.toHexString(Integer.parseInt(obj[1]+"")).toUpperCase()); |
| 1232 | 1232 | map.put("requestTime", obj[2]); | ... | ... |
src/main/java/com/bsth/service/report/ReportService.java
| ... | ... | @@ -24,6 +24,8 @@ public interface ReportService { |
| 24 | 24 | Map<String, Object> tbodyTime2(String line ,String ttinfo); |
| 25 | 25 | |
| 26 | 26 | List<Map<String, Object>> tbodyTime3(String line ,String ttinfo); |
| 27 | + | |
| 28 | + List<Map<String, Object>> tbodyTime4(String line ,String ttinfo); | |
| 27 | 29 | List<Map<String, Object>> tbodyTime5(String line ,String ttinfo); |
| 28 | 30 | |
| 29 | 31 | List<Map<String, Object>> getTtinfo(Map<String, Object> map); | ... | ... |
src/main/java/com/bsth/service/report/impl/ReportServiceImpl.java
| ... | ... | @@ -451,21 +451,36 @@ public class ReportServiceImpl implements ReportService{ |
| 451 | 451 | System.out.println(609360%60); |
| 452 | 452 | } |
| 453 | 453 | @Override |
| 454 | - public List<Map<String, Object>> tbodyTime3(String line, String date) { | |
| 454 | + public List<Map<String, Object>> tbodyTime3(String line, String ttinfo) { | |
| 455 | 455 | // TODO Auto-generated method stub |
| 456 | 456 | List<Map<String, Object>> list=new ArrayList<Map<String,Object>>(); |
| 457 | - String sqlZd=" select qdz_name, count(cl_zbh) as cls , 'zqc' as lx from bsth_c_s_sp_info where " | |
| 458 | - + " DATE_FORMAT(schedule_date,'%Y-%m-%d') ='"+date+"' and xl_bm='"+line+"' and bc_type='normal' " | |
| 459 | - + " and fcsj>'06:31' and fcsj<'08:00' group by qdz_name union " | |
| 460 | - + " select qdz_name, count(cl_zbh) as cls , 'wqc' as lx from bsth_c_s_sp_info " | |
| 461 | - + " where DATE_FORMAT(schedule_date,'%Y-%m-%d') ='"+date+"' and xl_bm='"+line+"' " | |
| 462 | - + " and bc_type='normal' and fcsj>'16:01' and fcsj<'18:00' group by qdz_name union " | |
| 463 | - + " select qdz_name, count(cl_zbh) as cls , 'zqj' as lx from bsth_c_s_sp_info " | |
| 464 | - + " where DATE_FORMAT(schedule_date,'%Y-%m-%d') ='"+date+"' and xl_bm='"+line+"' " | |
| 465 | - + " and bc_type='region' and fcsj>'06:31' and fcsj<'08:00' group by qdz_name union " | |
| 466 | - + " select qdz_name, count(cl_zbh) as cls , 'wqj' as lx from bsth_c_s_sp_info " | |
| 467 | - + " where DATE_FORMAT(schedule_date,'%Y-%m-%d') ='"+date+"' and xl_bm='"+line+"' " | |
| 468 | - + " and bc_type='region' and fcsj>'16:01' and fcsj<'18:00'group by qdz_name"; | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + String sqlZd=" select t.*,x.station_name as qdz_name from (" | |
| 461 | + + " select qdz,count(lp) as cls,lx from ( select qdz,lp, 'zqc' as lx " | |
| 462 | + + " from bsth_c_s_ttinfo_detail where " | |
| 463 | + + " bc_type='normal' and ttinfo ='"+ttinfo+"' " | |
| 464 | + + " and fcsj>'06:31' and fcsj<'08:00' group by qdz,lp) t1" | |
| 465 | + + " group by qdz " | |
| 466 | + + " union " | |
| 467 | + + " select qdz,count(lp) as cls,lx from ( select qdz,lp, 'wqc' as lx " | |
| 468 | + + " from bsth_c_s_ttinfo_detail where " | |
| 469 | + + " bc_type='normal' and ttinfo ='"+ttinfo+"' " | |
| 470 | + + " and fcsj>'16:01' and fcsj<'18:00' group by qdz,lp) t2" | |
| 471 | + + " group by qdz " | |
| 472 | + + " union " | |
| 473 | + + " select qdz,count(lp) as cls,lx from ( select qdz,lp, 'zqj' as lx " | |
| 474 | + + " from bsth_c_s_ttinfo_detail where " | |
| 475 | + + " bc_type='region' and ttinfo ='"+ttinfo+"' " | |
| 476 | + + " and fcsj>'06:31' and fcsj<'08:00' group by qdz,lp) t3" | |
| 477 | + + " group by qdz " | |
| 478 | + + " union " | |
| 479 | + + " select qdz,count(lp) as cls,lx from ( select qdz,lp, 'wqj' as lx " | |
| 480 | + + " from bsth_c_s_ttinfo_detail where " | |
| 481 | + + " bc_type='region' and ttinfo ='"+ttinfo+"' " | |
| 482 | + + " and fcsj>'16:01' and fcsj<'18:00' group by qdz,lp) t4" | |
| 483 | + + " group by qdz ) t left join bsth_c_station x on t.qdz=x.id"; | |
| 469 | 484 | |
| 470 | 485 | List<Map<String, Object>> lists= jdbcTemplate.query(sqlZd, |
| 471 | 486 | new RowMapper<Map<String, Object>>(){ |
| ... | ... | @@ -526,55 +541,238 @@ public class ReportServiceImpl implements ReportService{ |
| 526 | 541 | } |
| 527 | 542 | return list; |
| 528 | 543 | } |
| 544 | + | |
| 529 | 545 | @Override |
| 530 | - public List<Map<String, Object>> tbodyTime5(String line, String date) { | |
| 546 | + public List<Map<String, Object>> tbodyTime4(String line, String ttinfo) { | |
| 547 | + List<Map<String, Object>> list =new ArrayList<>(); | |
| 531 | 548 | // TODO Auto-generated method stub |
| 532 | - String sql="select min(fcsj) as fcsj,'lx0' as lx from bsth_c_s_sp_info where " | |
| 533 | - + " DATE_FORMAT(schedule_date,'%Y-%m-%d') ='"+date+"' and xl_bm='"+line+"'" | |
| 534 | - + " and bc_type='out' and xl_dir=0 union " | |
| 535 | - + " select min(fcsj) as fcsj,'lx1' as lx from bsth_c_s_sp_info where " | |
| 536 | - + " DATE_FORMAT(schedule_date,'%Y-%m-%d') ='"+date+"' and xl_bm='"+line+"'" | |
| 537 | - + " and bc_type='out' and xl_dir=1"; | |
| 538 | - List<Map<String, Object>> lists= jdbcTemplate.query(sql, | |
| 539 | - new RowMapper<Map<String, Object>>(){ | |
| 549 | + //最早营运时间 区分夜宵线 | |
| 550 | + String sqlMinYysj="select start_opt from bsth_c_line_config where line = '"+BasicData.lineId2CodeMap.inverse().get(line) +"'"; | |
| 551 | + String minfcsj=jdbcTemplate.queryForObject(sqlMinYysj, String.class); | |
| 552 | + | |
| 553 | + //查询全程 | |
| 554 | + String sqlqc="select t.*,x.station_name as qdz_name from ( " | |
| 555 | + + "(SELECT fcsj,qdz,2 as xh,xl_dir FROM bsth_c_s_ttinfo_detail " | |
| 556 | + + " where ttinfo ='"+ttinfo+"' and bc_type='normal' and fcsj <='"+minfcsj+"' ) " | |
| 557 | + + " union " | |
| 558 | + + " (SELECT fcsj,qdz,1 as xh,xl_dir FROM bsth_c_s_ttinfo_detail " | |
| 559 | + + " where ttinfo ='"+ttinfo+"' and bc_type='normal' and fcsj > '"+minfcsj+"') " | |
| 560 | + + "order by xl_dir,xh,fcsj ) t left join bsth_c_station x on t.qdz=x.id"; | |
| 561 | + List<Map<String, String>> qclist= jdbcTemplate.query(sqlqc, | |
| 562 | + new RowMapper<Map<String, String>>(){ | |
| 540 | 563 | @Override |
| 541 | - public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { | |
| 542 | - Map<String, Object> m=new HashMap<String,Object>(); | |
| 543 | - m.put("lx", rs.getString("lx")); | |
| 564 | + public Map<String, String> mapRow(ResultSet rs, int rowNum) throws SQLException { | |
| 565 | + Map<String, String> m=new HashMap<String,String>(); | |
| 566 | + m.put("qdz_name", rs.getString("qdz_name")); | |
| 544 | 567 | m.put("fcsj", rs.getString("fcsj")); |
| 568 | + m.put("xl", rs.getString("xl_dir")); | |
| 545 | 569 | return m; |
| 546 | 570 | } |
| 571 | + | |
| 547 | 572 | }); |
| 573 | + | |
| 574 | + Map<String, Object> qcMap=new HashMap<String,Object>(); | |
| 575 | + int num=0; | |
| 576 | + String sxfcsj=""; | |
| 577 | + String xxfcsj=""; | |
| 578 | + String sxzd=""; | |
| 579 | + String xxzd=""; | |
| 580 | + for (int i = 0; i < qclist.size(); i++) { | |
| 581 | + Map<String, String> map=qclist.get(i); | |
| 582 | + if(map.get("xl").equals("0")){ | |
| 583 | + if(sxzd.equals("")){ | |
| 584 | + sxzd=map.get("qdz_name").toString(); | |
| 585 | + qcMap.put("sxzm", sxzd); | |
| 586 | + sxfcsj +=map.get("fcsj").toString()+"-"; | |
| 587 | + } | |
| 588 | + if(!(qclist.get(i+1).get("xl").equals("0"))){ | |
| 589 | + sxfcsj +=map.get("fcsj").toString(); | |
| 590 | + qcMap.put("sxsj",sxfcsj); | |
| 591 | + qcMap.put("sxbc", i+1); | |
| 592 | + num=i+1; | |
| 593 | + } | |
| 594 | + } | |
| 595 | + if(map.get("xl").equals("1")){ | |
| 596 | + if(xxzd.equals("")){ | |
| 597 | + xxzd=map.get("qdz_name").toString(); | |
| 598 | + xxfcsj+=map.get("fcsj").toString()+"-"; | |
| 599 | + qcMap.put("xxzm", xxzd); | |
| 600 | + } | |
| 601 | + } | |
| 602 | + } | |
| 603 | + xxfcsj +=qclist.get(qclist.size()-1).get("fcsj").toString(); | |
| 604 | + qcMap.put("xxsj", xxfcsj); | |
| 605 | + qcMap.put("xxbc", qclist.size()-num); | |
| 606 | + list.add(qcMap); | |
| 548 | 607 | |
| 549 | - String sqlList="select * from bsth_c_s_sp_info where " | |
| 550 | - + "DATE_FORMAT(schedule_date,'%Y-%m-%d') ='"+date+"' and xl_bm='"+line+"'" | |
| 551 | - + " and bc_type='normal' order by fcsj"; | |
| 552 | - List<SchedulePlanInfo> list= jdbcTemplate.query(sqlList, | |
| 553 | - new RowMapper<SchedulePlanInfo>(){ | |
| 608 | + | |
| 609 | + //查询区间 | |
| 610 | + String sqlqj="select t.*,x.station_name as qdz_name from ( " | |
| 611 | + + "(SELECT fcsj,qdz,'1' as gf,xl_dir FROM bsth_c_s_ttinfo_detail " | |
| 612 | + + "where ttinfo ='"+ttinfo+"' and bc_type='region' and fcsj >='06:31'" | |
| 613 | + + "and fcsj <'08:30')" | |
| 614 | + + " union ( SELECT fcsj,qdz,'2' as gf,xl_dir FROM bsth_c_s_ttinfo_detail " | |
| 615 | + + "where ttinfo ='"+ttinfo+"' and bc_type='region' " | |
| 616 | + + "and fcsj > '16:01' and fcsj < '18:00') order by xl_dir,gf,fcsj ) t " | |
| 617 | + + "left join bsth_c_station x on t.qdz=x.id"; | |
| 618 | + | |
| 619 | + List<Map<String, String>> qjlist= jdbcTemplate.query(sqlqj, | |
| 620 | + new RowMapper<Map<String, String>>(){ | |
| 554 | 621 | @Override |
| 555 | - public SchedulePlanInfo mapRow(ResultSet rs, int rowNum) throws SQLException { | |
| 556 | - SchedulePlanInfo m=new SchedulePlanInfo(); | |
| 557 | - m.setBcsj(rs.getInt("bcsj")); | |
| 558 | - m.setXlDir(rs.getString("xl_dir")); | |
| 559 | - m.setFcsj(rs.getString("fcsj")); | |
| 622 | + public Map<String, String> mapRow(ResultSet rs, int rowNum) throws SQLException { | |
| 623 | + Map<String, String> m=new HashMap<String,String>(); | |
| 624 | + m.put("qdz_name", rs.getString("qdz_name")); | |
| 625 | + m.put("fcsj", rs.getString("fcsj")); | |
| 626 | + m.put("xl", rs.getString("xl_dir")); | |
| 627 | + m.put("gf", rs.getString("gf")); | |
| 560 | 628 | return m; |
| 561 | 629 | } |
| 562 | 630 | }); |
| 563 | - //上下行最早发车时间 (用于与夜班线 跨零点的班次进行比较) | |
| 564 | - String lx0=""; | |
| 565 | - String lx1=""; | |
| 566 | - for (int x = 0; x < lists.size(); x++) { | |
| 567 | - if(lists.get(x).get("lx").equals("lx0")){ | |
| 568 | - lx0=lists.get(x).get("fcsj")==null?"0:0":lists.get(x).get("fcsj").toString(); | |
| 631 | + | |
| 632 | + Map<String, Object> qjzMap=new HashMap<String,Object>(); | |
| 633 | + Map<String, Object> qjwMap=new HashMap<String,Object>(); | |
| 634 | + int numqj=0; | |
| 635 | + String sxfcsjqj=""; | |
| 636 | + String xxfcsjqj=""; | |
| 637 | + String sxzdqj=""; | |
| 638 | + String xxzdqj=""; | |
| 639 | + for(int i=0;i<qjlist.size();i++){ | |
| 640 | + Map<String, String> map=qjlist.get(i); | |
| 641 | + if(map.get("xl").toString().equals("0")){ | |
| 642 | + if(map.get("gf").toString().equals("1")){ | |
| 643 | + if(sxzdqj.equals("")){ | |
| 644 | + sxzdqj =map.get("qdz_name").toString(); | |
| 645 | + qjzMap.put("sxzm", sxzdqj); | |
| 646 | + sxfcsjqj +=map.get("fcsj").toString()+"-"; | |
| 647 | + } | |
| 648 | + if(i<qjlist.size()-1){ | |
| 649 | + if(!(qjlist.get(i+1).get("gf").equals("1"))){ | |
| 650 | + sxfcsjqj +=map.get("fcsj").toString(); | |
| 651 | + qjzMap.put("sxsj",sxfcsjqj); | |
| 652 | + qjzMap.put("sxbc", i+1); | |
| 653 | + numqj=i+1; | |
| 654 | + sxzdqj =""; | |
| 655 | + sxfcsjqj=""; | |
| 656 | + } | |
| 657 | + }else{ | |
| 658 | + qjzMap.put("sxsj",sxfcsjqj+"-"+map.get("fcsj").toString()); | |
| 659 | + qjzMap.put("sxbc", i+1); | |
| 660 | + numqj=i+1; | |
| 661 | + sxzdqj =""; | |
| 662 | + sxfcsjqj=""; | |
| 663 | + } | |
| 664 | + } | |
| 665 | + if(map.get("gf").toString().equals("2")){ | |
| 666 | + if(sxzdqj.equals("")){ | |
| 667 | + sxzdqj =map.get("qdz_name").toString(); | |
| 668 | + qjwMap.put("sxzm", sxzdqj); | |
| 669 | + sxfcsjqj +=map.get("fcsj").toString()+"-"; | |
| 670 | + } | |
| 671 | + if(i<qjlist.size()-1){ | |
| 672 | + if(!(qjlist.get(i+1).get("xl").equals("0"))){ | |
| 673 | + sxfcsjqj +=map.get("fcsj").toString(); | |
| 674 | + qjwMap.put("sxsj",sxfcsjqj); | |
| 675 | + qjwMap.put("sxbc", i+1-numqj); | |
| 676 | + numqj=i+1; | |
| 677 | + } | |
| 678 | + }else{ | |
| 679 | + qjwMap.put("sxsj",sxfcsjqj+"-"+map.get("fcsj").toString()); | |
| 680 | + qjwMap.put("sxbc", i+1-numqj); | |
| 681 | + numqj=i+1; | |
| 682 | + } | |
| 683 | + } | |
| 684 | + | |
| 569 | 685 | }else{ |
| 570 | - lx1=lists.get(x).get("fcsj")==null?"0:0":lists.get(x).get("fcsj").toString(); | |
| 686 | + if(map.get("gf").toString().equals("1")){ | |
| 687 | + if(xxzdqj.equals("")){ | |
| 688 | + xxzdqj =map.get("qdz_name").toString(); | |
| 689 | + qjzMap.put("xxzm", xxzdqj); | |
| 690 | + xxfcsjqj +=map.get("fcsj").toString()+"-"; | |
| 691 | + } | |
| 692 | + if(i<qjlist.size()-1){ | |
| 693 | + if(!(qjlist.get(i+1).get("gf").equals("1"))){ | |
| 694 | + xxfcsjqj +=map.get("fcsj").toString(); | |
| 695 | + qjzMap.put("xxsj",xxfcsjqj); | |
| 696 | + qjzMap.put("xxbc", i+1-numqj); | |
| 697 | + numqj=i+1; | |
| 698 | + xxzdqj =""; | |
| 699 | + xxfcsjqj=""; | |
| 700 | + } | |
| 701 | + }else{ | |
| 702 | + qjzMap.put("xxsj",xxfcsjqj+"-"+map.get("fcsj").toString()); | |
| 703 | + qjzMap.put("xxbc", i+1-numqj); | |
| 704 | + numqj=i+1; | |
| 705 | + xxzdqj =""; | |
| 706 | + xxfcsjqj=""; | |
| 707 | + } | |
| 708 | + } | |
| 709 | + if(map.get("gf").toString().equals("2")){ | |
| 710 | + if(xxzdqj.equals("")){ | |
| 711 | + xxzdqj =map.get("qdz_name").toString(); | |
| 712 | + qjwMap.put("xxzm", xxzdqj); | |
| 713 | + xxfcsjqj +=map.get("fcsj").toString()+"-"; | |
| 714 | + } | |
| 715 | + if(i<qjlist.size()){ | |
| 716 | + if(i==qjlist.size()-1){ | |
| 717 | + xxfcsjqj +=map.get("fcsj").toString(); | |
| 718 | + qjwMap.put("xxsj",xxfcsjqj); | |
| 719 | + qjwMap.put("xxbc", i+1-numqj); | |
| 720 | + numqj=i+1; | |
| 721 | + } | |
| 722 | + }else{ | |
| 723 | + qjwMap.put("xxsj",xxfcsjqj+"-"+xxfcsjqj); | |
| 724 | + qjwMap.put("xxbc", i+1-numqj); | |
| 725 | + numqj=i+1; | |
| 726 | + } | |
| 727 | + } | |
| 728 | + | |
| 729 | + | |
| 571 | 730 | } |
| 572 | 731 | } |
| 573 | 732 | |
| 574 | - String[] lx0sj = lx0.split(":"); | |
| 575 | - int sxFc=Integer.parseInt(lx0sj[0])*60+Integer.parseInt(lx0sj[1]); | |
| 576 | - String[] lx1sj = lx1.split(":"); | |
| 577 | - int xxFc=Integer.parseInt(lx1sj[0])*60+Integer.parseInt(lx1sj[1]); | |
| 733 | + if(!qjzMap.isEmpty()){ | |
| 734 | + list.add(qjzMap); | |
| 735 | + } | |
| 736 | + if(!qjwMap.isEmpty()){ | |
| 737 | + list.add(qjwMap); | |
| 738 | + | |
| 739 | + } | |
| 740 | + return list; | |
| 741 | + } | |
| 742 | + @Override | |
| 743 | + public List<Map<String, Object>> tbodyTime5(String line, String ttinfo) { | |
| 744 | + // TODO Auto-generated method stub | |
| 745 | + //最早营运时间 区分夜宵线 | |
| 746 | + String sqlMinYysj="select start_opt from bsth_c_line_config where line = '"+BasicData.lineId2CodeMap.inverse().get(line) +"'"; | |
| 747 | + String minfcsj=jdbcTemplate.queryForObject(sqlMinYysj, String.class); | |
| 748 | + String[] minSjs = minfcsj.split(":"); | |
| 749 | + int minSj=Integer.parseInt(minSjs[0])*60+Integer.parseInt(minSjs[1]); | |
| 750 | + //查询时间里程 | |
| 751 | + String sqlPc=" (SELECT jhlc,fcsj,bcsj,bc_type,lp,xl_dir,2 as xh FROM " | |
| 752 | + + " bsth_c_s_ttinfo_detail where ttinfo ='"+ttinfo+"' and " | |
| 753 | + + " fcsj <='"+minfcsj+"' and bc_type = 'normal') " | |
| 754 | + + " union " | |
| 755 | + + " (SELECT jhlc,fcsj,bcsj,bc_type,lp,xl_dir,1 as xh FROM " | |
| 756 | + + " bsth_c_s_ttinfo_detail where ttinfo ='"+ttinfo+"' and " | |
| 757 | + + " fcsj >'"+minfcsj+"' and bc_type ='normal') " | |
| 758 | + + " order by xl_dir, xh,fcsj"; | |
| 759 | + | |
| 760 | + Map<String, Object> map=new HashMap<String,Object>(); | |
| 761 | + List<Map<String, Object>> list= jdbcTemplate.query(sqlPc, | |
| 762 | + new RowMapper<Map<String, Object>>(){ | |
| 763 | + @Override | |
| 764 | + public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { | |
| 765 | + Map<String, Object> m=new HashMap<String,Object>(); | |
| 766 | + m.put("fcsj", rs.getString("fcsj")); | |
| 767 | + m.put("yygl", rs.getString("jhlc")==null?"0":rs.getString("jhlc")); | |
| 768 | + m.put("bcsj", rs.getString("bcsj")); | |
| 769 | + m.put("bcType", rs.getString("bc_type")); | |
| 770 | + m.put("lp", rs.getString("lp")); | |
| 771 | + m.put("dir", rs.getString("xl_dir")); | |
| 772 | + return m; | |
| 773 | + } | |
| 774 | + }); | |
| 775 | + | |
| 578 | 776 | //班次 |
| 579 | 777 | int sj_0 = 6*60+31,sj_1 = 8*60+30,sj_2 = 16*60+1,sj_3 = 18*60; |
| 580 | 778 | |
| ... | ... | @@ -587,17 +785,17 @@ public class ReportServiceImpl implements ReportService{ |
| 587 | 785 | //车距 (发车时间的间距) i--MIN a--MAX |
| 588 | 786 | int iC=999,aC=-1,iZg=999,aZg=-1,iZw=999,aZw=-1,iWg=999,aWg=-1,iJcZ=999,aJcZ=-1,iJcW=999,aJcW=-1; |
| 589 | 787 | int iC1=999,aC1=-1,iZg1=999,aZg1=-1,iZw1=999,aZw1=-1,iWg1=999,aWg1=-1,iJc1Z=999,aJc1Z=-1,iJc1W=999,aJc1W=-1; |
| 590 | -// List<ScheduleRealInfo> list = scheduleRealInfoRepository.scheduleByDateAndLine(line, date); | |
| 788 | + | |
| 591 | 789 | for(int i=0;i<list.size();i++){ |
| 592 | - SchedulePlanInfo t=list.get(i); | |
| 593 | - String xlDir=t.getXlDir(); | |
| 594 | - int bcsj=t.getBcsj(); | |
| 595 | - String fcsj=t.getFcsj(); | |
| 790 | + Map<String, Object> ttMap=list.get(i); | |
| 791 | + String xlDir=ttMap.get("dir").toString(); | |
| 792 | + int bcsj=Integer.parseInt(ttMap.get("bcsj").toString()); | |
| 793 | + String fcsj=ttMap.get("fcsj").toString(); | |
| 596 | 794 | String[] fcsjs=fcsj.split(":"); |
| 597 | 795 | int fcsjNum=Integer.parseInt(fcsjs[0])*60+Integer.parseInt(fcsjs[1]); |
| 598 | 796 | |
| 599 | 797 | if(xlDir.equals("0")){ |
| 600 | - if(fcsjNum>=sxFc && fcsjNum<sj_0){ | |
| 798 | + if(fcsjNum>=minSj && fcsjNum<sj_0){ | |
| 601 | 799 | ccsj0 +=bcsj; |
| 602 | 800 | if(aC<0){ |
| 603 | 801 | cfc0 =fcsjNum; |
| ... | ... | @@ -672,7 +870,7 @@ public class ReportServiceImpl implements ReportService{ |
| 672 | 870 | } |
| 673 | 871 | jcfc0W=fcsjNum; |
| 674 | 872 | } |
| 675 | - }else if(fcsjNum<sxFc){ | |
| 873 | + }else if(fcsjNum<minSj){ | |
| 676 | 874 | jcsj0 +=bcsj; |
| 677 | 875 | if(aJcZ<0){ |
| 678 | 876 | jcfc0Z=fcsjNum; |
| ... | ... | @@ -690,7 +888,7 @@ public class ReportServiceImpl implements ReportService{ |
| 690 | 888 | |
| 691 | 889 | |
| 692 | 890 | }else{ |
| 693 | - if(fcsjNum>=xxFc && fcsjNum<sj_0){ | |
| 891 | + if(fcsjNum>=minSj && fcsjNum<sj_0){ | |
| 694 | 892 | ccsj1 +=bcsj; |
| 695 | 893 | if(aC1<0){ |
| 696 | 894 | cfc1=fcsjNum; |
| ... | ... | @@ -762,7 +960,7 @@ public class ReportServiceImpl implements ReportService{ |
| 762 | 960 | |
| 763 | 961 | jcfc1W=fcsjNum; |
| 764 | 962 | } |
| 765 | - }else if(fcsjNum<xxFc){ | |
| 963 | + }else if(fcsjNum<minSj){ | |
| 766 | 964 | jcsj1 +=bcsj; |
| 767 | 965 | if(aJc1Z<0){ |
| 768 | 966 | jcfc1Z=fcsjNum; |
| ... | ... | @@ -860,4 +1058,5 @@ public class ReportServiceImpl implements ReportService{ |
| 860 | 1058 | } |
| 861 | 1059 | return list; |
| 862 | 1060 | } |
| 1061 | + | |
| 863 | 1062 | } | ... | ... |
src/main/java/com/bsth/service/schedule/PeopleCarPlanServiceImpl.java
| ... | ... | @@ -180,6 +180,7 @@ public class PeopleCarPlanServiceImpl implements PeopleCarPlanService { |
| 180 | 180 | |
| 181 | 181 | |
| 182 | 182 | } catch (Exception e) { |
| 183 | + | |
| 183 | 184 | // TODO Auto-generated catch block |
| 184 | 185 | e.printStackTrace(); |
| 185 | 186 | } |
| ... | ... | @@ -313,6 +314,8 @@ public class PeopleCarPlanServiceImpl implements PeopleCarPlanService { |
| 313 | 314 | // TODO Auto-generated catch block |
| 314 | 315 | e.printStackTrace(); |
| 315 | 316 | } |
| 317 | + String companyName = "", subCompanyName = ""; | |
| 318 | + | |
| 316 | 319 | for(String key : keyMap.keySet()){ |
| 317 | 320 | Map<String, Object> tempMap = new HashMap<String, Object>(); |
| 318 | 321 | Map<String, List <ScheduleRealInfo>> listMap = new HashMap<String, List <ScheduleRealInfo>>(); |
| ... | ... | @@ -323,6 +326,10 @@ public class PeopleCarPlanServiceImpl implements PeopleCarPlanService { |
| 323 | 326 | int jhzgf = 0, sjzgf = 0, jhwgf = 0, sjwgf = 0; |
| 324 | 327 | for(ScheduleRealInfo schedule : keyMap.get(key)){ |
| 325 | 328 | // schedule.setFcsjAll(schedule.getFcsj()); |
| 329 | + if(companyName.length() == 0 && schedule.getGsName() != null) | |
| 330 | + companyName = schedule.getGsName(); | |
| 331 | + if(subCompanyName.length() == 0 && schedule.getFgsName() != null) | |
| 332 | + subCompanyName = schedule.getFgsName(); | |
| 326 | 333 | |
| 327 | 334 | //早晚高峰时段执行率 |
| 328 | 335 | if(schedule.getFcsjT() >= zgfBegin && schedule.getFcsjT() <= zgfEnd){ |
| ... | ... | @@ -424,6 +431,8 @@ public class PeopleCarPlanServiceImpl implements PeopleCarPlanService { |
| 424 | 431 | |
| 425 | 432 | } |
| 426 | 433 | |
| 434 | + tempMap.put("company", companyName); | |
| 435 | + tempMap.put("subCompany", subCompanyName); | |
| 427 | 436 | tempMap.put("date", date); |
| 428 | 437 | tempMap.put("line", key); |
| 429 | 438 | tempMap.put("jhbc", jhbc); |
| ... | ... | @@ -509,6 +518,8 @@ public class PeopleCarPlanServiceImpl implements PeopleCarPlanService { |
| 509 | 518 | schedule.setScheduleDateStr(rs.getString("schedule_date_Str")); |
| 510 | 519 | schedule.setXlName(rs.getString("xl_name")); |
| 511 | 520 | schedule.setBcType(rs.getString("bc_type")); |
| 521 | + schedule.setGsName(rs.getString("gs_name")); | |
| 522 | + schedule.setFgsName(rs.getString("fgs_name")); | |
| 512 | 523 | schedule.setBcs(rs.getInt("bcs")); |
| 513 | 524 | schedule.setFcno(rs.getInt("fcno")); |
| 514 | 525 | schedule.setFcsj(rs.getString("fcsj")); |
| ... | ... | @@ -588,6 +599,7 @@ public class PeopleCarPlanServiceImpl implements PeopleCarPlanService { |
| 588 | 599 | } |
| 589 | 600 | } |
| 590 | 601 | } |
| 602 | + String companyName = "", subCompanyName = ""; | |
| 591 | 603 | for(String key : keyMap.keySet()){ |
| 592 | 604 | Map<String, Object> tempMap = new HashMap<String, Object>(); |
| 593 | 605 | List<Integer> fcsj = new ArrayList<Integer>(); |
| ... | ... | @@ -595,6 +607,11 @@ public class PeopleCarPlanServiceImpl implements PeopleCarPlanService { |
| 595 | 607 | int jhbc = 0; |
| 596 | 608 | int sjbc = 0; |
| 597 | 609 | for(ScheduleRealInfo schedule : keyMap.get(key)){ |
| 610 | + if(companyName.length() == 0 && schedule.getGsName() != null) | |
| 611 | + companyName = schedule.getGsName(); | |
| 612 | + if(subCompanyName.length() == 0 && schedule.getFgsName() != null) | |
| 613 | + subCompanyName = schedule.getFgsName(); | |
| 614 | + | |
| 598 | 615 | tempMap.put("date", schedule.getScheduleDateStr()); |
| 599 | 616 | tempMap.put("bcsj", schedule.getBcsj()); |
| 600 | 617 | if(schedule.getFcsjActual() != null){ |
| ... | ... | @@ -654,6 +671,8 @@ public class PeopleCarPlanServiceImpl implements PeopleCarPlanService { |
| 654 | 671 | tempMap.put("zmys", "/"); |
| 655 | 672 | tempMap.put("pjys", "/"); |
| 656 | 673 | } |
| 674 | + tempMap.put("company", companyName); | |
| 675 | + tempMap.put("subCompany", subCompanyName); | |
| 657 | 676 | String[] split = key.split("/"); |
| 658 | 677 | tempMap.put("line", split[0]); |
| 659 | 678 | tempMap.put("qdz", split[1]); | ... | ... |
src/main/java/com/bsth/websocket/handler/SendUtils.java
| 1 | 1 | package com.bsth.websocket.handler; |
| 2 | 2 | |
| 3 | -import java.text.SimpleDateFormat; | |
| 4 | -import java.util.ArrayList; | |
| 5 | -import java.util.Date; | |
| 6 | -import java.util.HashMap; | |
| 7 | -import java.util.List; | |
| 8 | -import java.util.Map; | |
| 9 | - | |
| 10 | -import org.slf4j.Logger; | |
| 11 | -import org.slf4j.LoggerFactory; | |
| 12 | -import org.springframework.beans.factory.annotation.Autowired; | |
| 13 | -import org.springframework.stereotype.Component; | |
| 14 | - | |
| 15 | 3 | import com.alibaba.fastjson.JSONObject; |
| 16 | 4 | import com.bsth.data.BasicData; |
| 17 | 5 | import com.bsth.data.LineConfigData; |
| 18 | -import com.bsth.data.schedule.DayOfSchedule; | |
| 6 | +import com.bsth.data.gpsdata.arrival.entity.SignalState; | |
| 19 | 7 | import com.bsth.entity.directive.D80; |
| 20 | 8 | import com.bsth.entity.realcontrol.ScheduleRealInfo; |
| 21 | 9 | import com.fasterxml.jackson.core.JsonProcessingException; |
| 22 | 10 | import com.fasterxml.jackson.databind.ObjectMapper; |
| 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 | +import java.text.SimpleDateFormat; | |
| 17 | +import java.util.*; | |
| 23 | 18 | |
| 24 | 19 | @Component |
| 25 | 20 | public class SendUtils{ |
| ... | ... | @@ -40,7 +35,7 @@ public class SendUtils{ |
| 40 | 35 | */ |
| 41 | 36 | public void sendFcsj(ScheduleRealInfo sch) { |
| 42 | 37 | //处理出站即出场的班次 |
| 43 | - connectOutSchTime(sch); | |
| 38 | + //connectOutSchTime(sch); | |
| 44 | 39 | |
| 45 | 40 | Map<String, Object> map = new HashMap<>(); |
| 46 | 41 | map.put("fn", "faChe"); |
| ... | ... | @@ -86,7 +81,7 @@ public class SendUtils{ |
| 86 | 81 | */ |
| 87 | 82 | public void sendZdsj(ScheduleRealInfo sch, ScheduleRealInfo nextSch, int finish) { |
| 88 | 83 | //处理进站即进场的班次 |
| 89 | - connectInSchTime(sch); | |
| 84 | + //connectInSchTime(sch); | |
| 90 | 85 | |
| 91 | 86 | Map<String, Object> map = new HashMap<>(); |
| 92 | 87 | map.put("fn", "zhongDian"); |
| ... | ... | @@ -103,12 +98,30 @@ public class SendUtils{ |
| 103 | 98 | logger.error("", e); |
| 104 | 99 | } |
| 105 | 100 | } |
| 101 | + | |
| 102 | + /** | |
| 103 | + * 推送班次信号状态 | |
| 104 | + * @param state | |
| 105 | + */ | |
| 106 | + public void sendSignalState(SignalState state){ | |
| 107 | + Map<String, Object> map = new HashMap<>(); | |
| 108 | + map.put("fn", "signal_state"); | |
| 109 | + map.put("data", state); | |
| 110 | + | |
| 111 | + ObjectMapper mapper = new ObjectMapper(); | |
| 112 | + | |
| 113 | + try { | |
| 114 | + socketHandler.sendMessageToLine(state.getLineCode(), mapper.writeValueAsString(map)); | |
| 115 | + } catch (Exception e) { | |
| 116 | + logger.error("", e); | |
| 117 | + } | |
| 118 | + } | |
| 106 | 119 | |
| 107 | 120 | /** |
| 108 | 121 | * |
| 109 | 122 | * @Title: shiftSchedule |
| 110 | 123 | * @Description: TODO(线路翻班通知) |
| 111 | - */ | |
| 124 | + | |
| 112 | 125 | public void shiftSchedule(String lineCode){ |
| 113 | 126 | Map<String, Object> map = new HashMap<>(); |
| 114 | 127 | map.put("fn", "systemNotice"); |
| ... | ... | @@ -124,7 +137,7 @@ public class SendUtils{ |
| 124 | 137 | logger.error("", e); |
| 125 | 138 | } |
| 126 | 139 | } |
| 127 | - | |
| 140 | + */ | |
| 128 | 141 | /** |
| 129 | 142 | * |
| 130 | 143 | * @Title: sendDirectiveToPage |
| ... | ... | @@ -157,39 +170,4 @@ public class SendUtils{ |
| 157 | 170 | list.add(sch); |
| 158 | 171 | refreshSch(list); |
| 159 | 172 | } |
| 160 | - | |
| 161 | - | |
| 162 | - //出站即出场 | |
| 163 | - public void connectOutSchTime(ScheduleRealInfo sch){ | |
| 164 | - try{ | |
| 165 | - ScheduleRealInfo twins = sch.getTwinsSch(); | |
| 166 | - if(twins != null | |
| 167 | - && lineConfigData.get(sch.getXlBm()).getOutConfig() == 2 | |
| 168 | - && twins.getBcType().equals("out")){ | |
| 169 | - | |
| 170 | - twins.setFcsjActualAll(sch.getFcsjActualTime()); | |
| 171 | - //刷新关联的出场班次 | |
| 172 | - //refreshSch(twins); | |
| 173 | - } | |
| 174 | - }catch(Exception e){ | |
| 175 | - logger.error("", e); | |
| 176 | - } | |
| 177 | - } | |
| 178 | - | |
| 179 | - //进站即出场 | |
| 180 | - public void connectInSchTime(ScheduleRealInfo sch){ | |
| 181 | - try{ | |
| 182 | - ScheduleRealInfo twins = sch.getTwinsSch(); | |
| 183 | - if(twins != null | |
| 184 | - && lineConfigData.get(sch.getXlBm()).getOutConfig() == 2 | |
| 185 | - && twins.getBcType().equals("in")){ | |
| 186 | - | |
| 187 | - twins.setZdsjActualAll(sch.getZdsjActualTime()); | |
| 188 | - //刷新关联的出场班次 | |
| 189 | - //refreshSch(twins); | |
| 190 | - } | |
| 191 | - }catch(Exception e){ | |
| 192 | - logger.error("", e); | |
| 193 | - } | |
| 194 | - } | |
| 195 | 173 | } | ... | ... |
src/main/resources/static/pages/excep/boundList.html
| ... | ... | @@ -82,7 +82,9 @@ |
| 82 | 82 | <option value="-1">无效</option> |
| 83 | 83 | </select> |
| 84 | 84 | </td> |
| 85 | - <td></td> | |
| 85 | + <td> | |
| 86 | + <input class="form-control" type="date" name="date" /> | |
| 87 | + </td> | |
| 86 | 88 | <td> |
| 87 | 89 | <button class="btn btn-sm green btn-outline filter-submit margin-bottom" > |
| 88 | 90 | <i class="fa fa-search"></i> 搜索</button> |
| ... | ... | @@ -237,8 +239,20 @@ $(function(){ |
| 237 | 239 | initPagination = false; |
| 238 | 240 | return; |
| 239 | 241 | } |
| 242 | + var cells = $('tr.filter')[0].cells | |
| 243 | + ,params = {} | |
| 244 | + ,name; | |
| 245 | + $.each(cells, function(i, cell){ | |
| 246 | + var items = $('input,select', cell); | |
| 247 | + for(var j = 0, item; item = items[j++];){ | |
| 248 | + name = $(item).attr('name'); | |
| 249 | + if(name){ | |
| 250 | + params[name] = $(item).val(); | |
| 251 | + } | |
| 252 | + } | |
| 253 | + }); | |
| 240 | 254 | page = num - 1; |
| 241 | - jsDoQuery(null, false); | |
| 255 | + jsDoQuery(params, false); | |
| 242 | 256 | } |
| 243 | 257 | }); |
| 244 | 258 | } | ... | ... |
src/main/resources/static/pages/excep/offlineList.html
| ... | ... | @@ -82,7 +82,9 @@ |
| 82 | 82 | <option value="-1">无效</option> |
| 83 | 83 | </select> |
| 84 | 84 | </td> |
| 85 | - <td></td> | |
| 85 | + <td> | |
| 86 | + <input class="form-control" type="date" name="date" /> | |
| 87 | + </td> | |
| 86 | 88 | <td> |
| 87 | 89 | <button class="btn btn-sm green btn-outline filter-submit margin-bottom" > |
| 88 | 90 | <i class="fa fa-search"></i> 搜索</button> |
| ... | ... | @@ -242,7 +244,20 @@ $(function(){ |
| 242 | 244 | |
| 243 | 245 | |
| 244 | 246 | page = num - 1; |
| 245 | - jsDoQuery(null, false); | |
| 247 | + | |
| 248 | + var cells = $('tr.filter')[0].cells | |
| 249 | + ,params = {} | |
| 250 | + ,name; | |
| 251 | + $.each(cells, function(i, cell){ | |
| 252 | + var items = $('input,select', cell); | |
| 253 | + for(var j = 0, item; item = items[j++];){ | |
| 254 | + name = $(item).attr('name'); | |
| 255 | + if(name){ | |
| 256 | + params[name] = $(item).val(); | |
| 257 | + } | |
| 258 | + } | |
| 259 | + }); | |
| 260 | + jsDoQuery(params, false); | |
| 246 | 261 | } |
| 247 | 262 | }); |
| 248 | 263 | } | ... | ... |
src/main/resources/static/pages/excep/speedingList.html
| ... | ... | @@ -72,6 +72,7 @@ |
| 72 | 72 | <input type="text" class="form-control form-filter input-sm" name="nbbm"> |
| 73 | 73 | </td> |
| 74 | 74 | <td> |
| 75 | + <input class="form-control" type="date" name="date" /> | |
| 75 | 76 | </td> |
| 76 | 77 | <td></td> |
| 77 | 78 | <td> |
| ... | ... | @@ -238,7 +239,19 @@ $(function(){ |
| 238 | 239 | return; |
| 239 | 240 | } |
| 240 | 241 | page = num - 1; |
| 241 | - jsDoQuery(null, false); | |
| 242 | + var cells = $('tr.filter')[0].cells | |
| 243 | + ,params = {} | |
| 244 | + ,name; | |
| 245 | + $.each(cells, function(i, cell){ | |
| 246 | + var items = $('input,select', cell); | |
| 247 | + for(var j = 0, item; item = items[j++];){ | |
| 248 | + name = $(item).attr('name'); | |
| 249 | + if(name){ | |
| 250 | + params[name] = $(item).val(); | |
| 251 | + } | |
| 252 | + } | |
| 253 | + }); | |
| 254 | + jsDoQuery(params, false); | |
| 242 | 255 | } |
| 243 | 256 | }); |
| 244 | 257 | } | ... | ... |
src/main/resources/static/pages/forms/mould/allline.xls
No preview for this file type
src/main/resources/static/pages/forms/mould/daily.xls
No preview for this file type
src/main/resources/static/pages/forms/mould/peoCarPlan.xls
No preview for this file type
src/main/resources/static/pages/forms/mould/scheduleAnaly.xls
No preview for this file type
src/main/resources/static/pages/forms/mould/workDaily.xls
No preview for this file type
src/main/resources/static/pages/forms/statement/account.html
| ... | ... | @@ -133,7 +133,7 @@ |
| 133 | 133 | |
| 134 | 134 | $("#query").on("click",function(){ |
| 135 | 135 | var line = $("#line").val(); |
| 136 | - var xlName = $("#line").text(); | |
| 136 | + var xlName = $("#select2-line-container").html(); | |
| 137 | 137 | var date = $("#date").val(); |
| 138 | 138 | var code = $("#code").val(); |
| 139 | 139 | $(".hidden").removeClass("hidden"); | ... | ... |
src/main/resources/static/pages/forms/statement/correctForm.html
| ... | ... | @@ -49,7 +49,7 @@ |
| 49 | 49 | </div> |
| 50 | 50 | <div class="form-group"> |
| 51 | 51 | <input class="btn btn-default" type="button" id="query" value="筛选"/> |
| 52 | - <input class="btn btn-default" type="button" id="export" value="导出"/> | |
| 52 | +<!-- <input class="btn btn-default" type="button" id="export" value="导出"/> --> | |
| 53 | 53 | </div> |
| 54 | 54 | </form> |
| 55 | 55 | </div> | ... | ... |
src/main/resources/static/pages/forms/statement/daily.html
| ... | ... | @@ -26,7 +26,15 @@ |
| 26 | 26 | <div class="col-md-12"> |
| 27 | 27 | <div class="portlet light porttlet-fit bordered"> |
| 28 | 28 | <div class="portlet-title"> |
| 29 | - <form class="form-inline" action=""> | |
| 29 | + <form class="form-inline" action=""> | |
| 30 | + <div style="display: inline-block; margin-left: 33px;" id="gsdmDiv_daily"> | |
| 31 | + <span class="item-label" style="width: 80px;">公司: </span> | |
| 32 | + <select class="form-control" name="company" id="gsdmDaily" style="width: 140px;"></select> | |
| 33 | + </div> | |
| 34 | + <div style="display: inline-block; margin-left: 24px;" id="fgsdmDiv_daily"> | |
| 35 | + <span class="item-label" style="width: 80px;">分公司: </span> | |
| 36 | + <select class="form-control" name="subCompany" id="fgsdmDaily" style="width: 140px;"></select> | |
| 37 | + </div> | |
| 30 | 38 | <div style="display: inline-block;"> |
| 31 | 39 | <span class="item-label" style="width: 80px;">线路: </span> |
| 32 | 40 | <select class="form-control" name="line" id="line" style="width: 180px;"></select> |
| ... | ... | @@ -64,15 +72,15 @@ |
| 64 | 72 | <td>班次</td> |
| 65 | 73 | </tr> |
| 66 | 74 | </thead> |
| 67 | - <tbody class="dailyInfo"> | |
| 75 | + <tbody id="tbody"> | |
| 68 | 76 | |
| 69 | 77 | </tbody> |
| 70 | 78 | <tr> |
| 71 | 79 | <td colspan="3">小计</td> |
| 72 | 80 | <td><span id="total_zgl"> </span></td> |
| 73 | - <td><span id="total_ksgl"> </span></td> | |
| 81 | + <td><span id="total_ks"> </span></td> | |
| 74 | 82 | <td><span id="total_yh"> </span></td> |
| 75 | - <td><span id="total_bcs"> </span></td> | |
| 83 | + <td><span id="total_bc"> </span></td> | |
| 76 | 84 | </tr> |
| 77 | 85 | </table> |
| 78 | 86 | </div> |
| ... | ... | @@ -82,7 +90,9 @@ |
| 82 | 90 | </div> |
| 83 | 91 | |
| 84 | 92 | <script> |
| 85 | - $(function(){ | |
| 93 | + $(function(){ | |
| 94 | + var reqCodeMap = {"0xA1": '请求恢复运营', "0xA2": '申请调档', "0xA3": '出场请求', "0xA5": '进场请求', "0xA7": '加油请求', "0x50": '车辆故障', "0x70": '路阻报告', "0x60": '事故报告', "0x11": '扣证纠纷', "0x12" : '报警'}; | |
| 95 | + | |
| 86 | 96 | // 关闭左侧栏 |
| 87 | 97 | if (!$('body').hasClass('page-sidebar-closed')) |
| 88 | 98 | $('.menu-toggler.sidebar-toggler').click(); |
| ... | ... | @@ -92,6 +102,42 @@ |
| 92 | 102 | locale : 'zh-cn' |
| 93 | 103 | }); |
| 94 | 104 | |
| 105 | + var obj = []; | |
| 106 | + $.get('/user/companyData', function(result){ | |
| 107 | + obj = result; | |
| 108 | + var options = ''; | |
| 109 | + for(var i = 0; i < obj.length; i++){ | |
| 110 | + options += '<option value="'+obj[i].companyCode+'">'+obj[i].companyName+'</option>'; | |
| 111 | + } | |
| 112 | + | |
| 113 | + if(obj.length ==0){ | |
| 114 | + $("#gsdmDiv_daily").css('display','none'); | |
| 115 | + $('#gsdmDiv_daily').css('display','none'); | |
| 116 | + }else if(obj.length ==1){ | |
| 117 | + $("#fgsdmDiv_daily").css('display','none'); | |
| 118 | + if(obj[0].children.length == 1 || obj[0].children.length ==0) | |
| 119 | + $('#fgsdmDiv_daily').css('display','none'); | |
| 120 | + } | |
| 121 | + $('#gsdmDaily').html(options); | |
| 122 | + updateCompany(); | |
| 123 | + }); | |
| 124 | + | |
| 125 | + $("#gsdmDaily").on("change",updateCompany); | |
| 126 | + function updateCompany(){ | |
| 127 | + var company = $('#gsdmDaily').val(); | |
| 128 | + var options = ''; | |
| 129 | + for(var i = 0; i < obj.length; i++){ | |
| 130 | + if(obj[i].companyCode == company){ | |
| 131 | + var children = obj[i].children; | |
| 132 | + for(var j = 0; j < children.length; j++){ | |
| 133 | + options += '<option value="'+children[j].code+'">'+children[j].name+'</option>'; | |
| 134 | + } | |
| 135 | + } | |
| 136 | + } | |
| 137 | + $('#fgsdmDaily').html(options); | |
| 138 | + } | |
| 139 | + | |
| 140 | + | |
| 95 | 141 | $.get('/basic/lineCode2Name',function(result){ |
| 96 | 142 | var data=[]; |
| 97 | 143 | |
| ... | ... | @@ -101,50 +147,82 @@ |
| 101 | 147 | initPinYinSelect2('#line',data,''); |
| 102 | 148 | |
| 103 | 149 | }) |
| 104 | - var line; | |
| 105 | - var date; | |
| 106 | - $("#query").on("click",function(){ | |
| 107 | - line = $("#line").val(); | |
| 108 | - var lineName=$("#select2-line-container").html(); | |
| 109 | - date = $("#date").val(); | |
| 110 | - $get('/realSchedule/dailyInfo',{line:line,date:date,type:'query'},function(result){ | |
| 111 | - $("#form_line").text(lineName); | |
| 112 | - $("#form_date").text(date); | |
| 113 | - var total_zgl = 0,total_ksgl = 0,total_yh = 0,total_bcs = 0; | |
| 114 | - $.each(result, function(i, obj) { | |
| 115 | - total_zgl = Number(obj.zgl)+Number(total_zgl); | |
| 116 | - total_ksgl = Number(obj.ksgl)+Number(total_ksgl); | |
| 117 | - total_yh = Number(0)+Number(total_yh); | |
| 118 | - total_bcs = Number(obj.bcs)+Number(total_bcs); | |
| 119 | - }); | |
| 120 | - $("#total_zgl").text(total_zgl.toFixed(2)); | |
| 121 | - $("#total_ksgl").text(total_ksgl.toFixed(2)); | |
| 122 | - $("#total_yh").text(total_yh.toFixed(2)); | |
| 123 | - $("#total_bcs").text(total_bcs); | |
| 124 | - | |
| 125 | - // 把数据填充到模版中 | |
| 126 | - var tbodyHtml = template('dailyInfo',{list:result}); | |
| 127 | - // 把渲染好的模版html文本追加到表格中 | |
| 128 | - $('#forms .dailyInfo').html(tbodyHtml); | |
| 129 | - }); | |
| 150 | + | |
| 151 | + var line; | |
| 152 | + var date; | |
| 153 | + var gsdmDaily; | |
| 154 | + var fgsdmDaily; | |
| 155 | + $("#query").on("click",function(){ | |
| 156 | + | |
| 157 | + line = $("#line").val(); | |
| 158 | + var lineName=$("#select2-line-container").html(); | |
| 159 | + date = $("#date").val(); | |
| 160 | + gsdmDaily=$("#gsdmDaily").val(); | |
| 161 | + fgsdmDaily = $("#fgsdmDaily").val(); | |
| 162 | + | |
| 163 | + $post('/mcy_forms/daily',{gsdmDaily:gsdmDaily,fgsdmDaily:fgsdmDaily, line:line,date:date,type:'query'},function(result){ | |
| 164 | + $("#form_line").text(lineName); | |
| 165 | + $("#form_date").text(date); | |
| 166 | + // 把数据填充到模版中 | |
| 167 | + var tbodyHtml = template('dailyInfo',{list:result}); | |
| 168 | + // 把渲染好的模版html文本追加到表格中 | |
| 169 | + $('#tbody').html(tbodyHtml); | |
| 170 | + line = $("#line").val(); | |
| 171 | + | |
| 172 | + startDate = $("#startDate").val(); | |
| 173 | + endDate = $("#endDate").val(); | |
| 174 | + $("#sDate").text(startDate); | |
| 175 | + $("#eDate").text(endDate); | |
| 176 | + | |
| 177 | + var total_zgl = 0,total_ks = 0; | |
| 178 | + var total_yh = 0,total_bc = 0; | |
| 179 | + | |
| 180 | + $.each(result, function(i, obj) { | |
| 181 | + total_zgl +=Number(obj.zlc); | |
| 182 | + total_ks +=Number(obj.jzl1); | |
| 183 | + total_yh += Number(obj.yh); | |
| 184 | + total_bc += Number(obj.bc); | |
| 185 | + | |
| 186 | + }); | |
| 187 | + $("#total_zgl").text(total_zgl.toFixed(2)); | |
| 188 | + $("#total_ks").text(total_ks.toFixed(2)); | |
| 189 | + $("#total_yh").text(total_yh.toFixed(2)); | |
| 190 | + $("#total_bc").text(total_bc.toFixed(2)); | |
| 191 | + | |
| 192 | + var temp = {}; | |
| 193 | + var today_account = 0; | |
| 194 | + | |
| 195 | + temp["line"] = $("#line").text(); | |
| 196 | + $.each(result, function(i, obj) { | |
| 197 | + if(moment(obj.schedule_date_str).format("YYYY-MM-DD") == moment(obj.startDate).format("YYYY-MM-DD")){ | |
| 198 | + today_account++; | |
| 199 | + } | |
| 200 | + obj.updateDate = moment(obj.startDate).format("YYYY-MM-DD HH:mm:ss"); | |
| 201 | + }); | |
| 202 | + }) | |
| 203 | + }); | |
| 204 | + | |
| 205 | + $("#export").on("click",function(){ | |
| 206 | + line = $("#line").val(); | |
| 207 | + date = $("#date").val(); | |
| 208 | + gsdmDaily=$("#gsdmDaily").val(); | |
| 209 | + fgsdmDaily = $("#fgsdmDaily").val(); | |
| 210 | + $post('/mcy_export/dailyExport',{gsdmDaily:gsdmDaily,fgsdmDaily:fgsdmDaily,line:line,date:date,type:'export'},function(result){ | |
| 211 | + window.open("/downloadFile/download?fileName=班次日报表"+moment(date).format("YYYYMMDD")); | |
| 130 | 212 | }); |
| 131 | - $("#export").on("click",function(){ | |
| 132 | - $get('/realSchedule/dailyInfo',{line:line,date:date,type:'export'},function(result){ | |
| 133 | - window.open("/downloadFile/download?fileName=班次日报"+moment(date).format("YYYYMMDD")); | |
| 134 | - }); | |
| 135 | - }); | |
| 136 | - }); | |
| 213 | + }); | |
| 214 | +}); | |
| 137 | 215 | </script> |
| 138 | 216 | <script type="text/html" id="dailyInfo"> |
| 139 | 217 | {{each list as obj i}} |
| 140 | 218 | <tr> |
| 141 | - <td>{{obj.clZbh}}</td> | |
| 142 | - <td>{{obj.jGh}}</td> | |
| 219 | + <td>{{obj.zbh}}</td> | |
| 220 | + <td>{{obj.jgh}}</td> | |
| 143 | 221 | <td>{{obj.jName}}</td> |
| 144 | - <td>{{obj.zgl}}</td> | |
| 145 | - <td>{{obj.ksgl}}</td> | |
| 146 | - <td>0</td> | |
| 147 | - <td>{{obj.bcs}}</td> | |
| 222 | + <td>{{obj.zlc}}</td> | |
| 223 | + <td>{{obj.jzl1}}</td> | |
| 224 | + <td>{{obj.yh}}</td> | |
| 225 | + <td>{{obj.bc}}</td> | |
| 148 | 226 | </tr> |
| 149 | 227 | {{/each}} |
| 150 | 228 | {{if list.length == 0}} | ... | ... |
src/main/resources/static/pages/forms/statement/firstAndLastBus.html
| ... | ... | @@ -97,6 +97,7 @@ |
| 97 | 97 | |
| 98 | 98 | <script> |
| 99 | 99 | $(function(){ |
| 100 | + $('#export').attr('disabled', "true"); | |
| 100 | 101 | |
| 101 | 102 | // 关闭左侧栏 |
| 102 | 103 | if (!$('body').hasClass('page-sidebar-closed')) |
| ... | ... | @@ -186,11 +187,22 @@ |
| 186 | 187 | // 把渲染好的模版html文本追加到表格中 |
| 187 | 188 | $('#forms tbody').html(tbodyHtml); |
| 188 | 189 | |
| 190 | + if(result.length == 0) | |
| 191 | + $("#export").attr('disabled',"true"); | |
| 192 | + else | |
| 193 | + $("#export").removeAttr("disabled"); | |
| 189 | 194 | }); |
| 190 | 195 | } |
| 191 | 196 | |
| 192 | 197 | $("#export").on("click",function(){ |
| 193 | - $get('/pcpc/firstAndLastBus',{line:line,date:date,type:'export'},function(result){ | |
| 198 | + var params = {}; | |
| 199 | + params['company'] = company; | |
| 200 | + params['subCompany'] = subCompany; | |
| 201 | + params['line'] = line; | |
| 202 | + params['line'] = line; | |
| 203 | + params['date'] = date; | |
| 204 | + params['type'] = "export"; | |
| 205 | + $get('/pcpc/firstAndLastBus', params, function(result){ | |
| 194 | 206 | window.open("/downloadFile/download?fileName=线路首末班"+moment(date).format("YYYYMMDD")); |
| 195 | 207 | }); |
| 196 | 208 | }); | ... | ... |
src/main/resources/static/pages/forms/statement/historyMessage.html
| ... | ... | @@ -41,7 +41,7 @@ |
| 41 | 41 | </div> |
| 42 | 42 | <div class="form-group"> |
| 43 | 43 | <input class="btn btn-default" type="button" id="query" value="筛选"/> |
| 44 | - <input class="btn btn-default" type="button" id="export" value="导出"/> | |
| 44 | +<!-- <input class="btn btn-default" type="button" id="export" value="导出"/> --> | |
| 45 | 45 | </div> |
| 46 | 46 | </form> |
| 47 | 47 | </div> | ... | ... |
src/main/resources/static/pages/forms/statement/peopleCarPlan.html
| ... | ... | @@ -80,6 +80,7 @@ |
| 80 | 80 | |
| 81 | 81 | <script> |
| 82 | 82 | $(function(){ |
| 83 | + $('#export').attr('disabled', "true"); | |
| 83 | 84 | |
| 84 | 85 | // 关闭左侧栏 |
| 85 | 86 | if (!$('body').hasClass('page-sidebar-closed')) |
| ... | ... | @@ -168,11 +169,21 @@ |
| 168 | 169 | // 把渲染好的模版html文本追加到表格中 |
| 169 | 170 | $('#forms tbody').html(tbodyHtml); |
| 170 | 171 | |
| 172 | + if(result.length == 0) | |
| 173 | + $("#export").attr('disabled',"true"); | |
| 174 | + else | |
| 175 | + $("#export").removeAttr("disabled"); | |
| 171 | 176 | }); |
| 172 | 177 | } |
| 173 | 178 | |
| 174 | 179 | $("#export").on("click",function(){ |
| 175 | - $get('/pcpc/queryPeopleCar',{line:line,date:date,type:'export'},function(result){ | |
| 180 | + var params = {}; | |
| 181 | + params['company'] = company; | |
| 182 | + params['subCompany'] = subCompany; | |
| 183 | + params['line'] = line; | |
| 184 | + params['date'] = date; | |
| 185 | + params['type'] = "export"; | |
| 186 | + $get('/pcpc/queryPeopleCar', params, function(result){ | |
| 176 | 187 | window.open("/downloadFile/download?fileName=计划车辆班次人员"+moment(date).format("YYYYMMDD")); |
| 177 | 188 | }); |
| 178 | 189 | }); | ... | ... |
src/main/resources/static/pages/forms/statement/scheduleAnaly.html
| ... | ... | @@ -65,18 +65,21 @@ |
| 65 | 65 | <table class="table table-bordered table-hover table-checkable" id="forms"> |
| 66 | 66 | <thead> |
| 67 | 67 | <tr class="hidden"> |
| 68 | - <th width="10%">线路</th> | |
| 69 | - <th width="10%">起点站名</th> | |
| 70 | - <th width="8%">计发时间</th> | |
| 71 | - <th width="8%">计划运送时间(分)</th> | |
| 72 | - <th width="8%">计划完成次数</th> | |
| 73 | - <th width="8%">完成次数</th> | |
| 74 | - <th width="8%">最早发车时间</th> | |
| 75 | - <th width="8%">最晚发车时间</th> | |
| 76 | - <th width="8%">平均发车时间</th> | |
| 77 | - <th width="8%">最慢运送时间(分)</th> | |
| 78 | - <th width="8%">最快运送时间(分)</th> | |
| 79 | - <th width="8%">平均运送时间(分)</th> | |
| 68 | + <th style="display: none;"></th> | |
| 69 | + <th width="8%">公司</th> | |
| 70 | + <th width="8%">分公司</th> | |
| 71 | + <th width="8%">线路</th> | |
| 72 | + <th width="8%">起点站名</th> | |
| 73 | + <th width="6%">计发时间</th> | |
| 74 | + <th width="6%">计划运送时间(分)</th> | |
| 75 | + <th width="6%">计划完成次数</th> | |
| 76 | + <th width="6%">完成次数</th> | |
| 77 | + <th width="6%">最早发车时间</th> | |
| 78 | + <th width="6%">最晚发车时间</th> | |
| 79 | + <th width="6%">平均发车时间</th> | |
| 80 | + <th width="6%">最慢运送时间(分)</th> | |
| 81 | + <th width="6%">最快运送时间(分)</th> | |
| 82 | + <th width="6%">平均运送时间(分)</th> | |
| 80 | 83 | </tr> |
| 81 | 84 | </thead> |
| 82 | 85 | <tbody> |
| ... | ... | @@ -95,6 +98,7 @@ |
| 95 | 98 | <script> |
| 96 | 99 | $(function(){ |
| 97 | 100 | var page = 0, initPagination; |
| 101 | + $('#export').attr('disabled', "true"); | |
| 98 | 102 | |
| 99 | 103 | // 关闭左侧栏 |
| 100 | 104 | if (!$('body').hasClass('page-sidebar-closed')) |
| ... | ... | @@ -200,6 +204,11 @@ |
| 200 | 204 | // 把渲染好的模版html文本追加到表格中 |
| 201 | 205 | $('#forms tbody').html(tbodyHtml); |
| 202 | 206 | |
| 207 | + if(result.dataList.length == 0) | |
| 208 | + $("#export").attr('disabled',"true"); | |
| 209 | + else | |
| 210 | + $("#export").removeAttr("disabled"); | |
| 211 | + | |
| 203 | 212 | if(pagination && result.dataList.length > 0){ |
| 204 | 213 | //重新分页 |
| 205 | 214 | initPagination = true; |
| ... | ... | @@ -213,7 +222,16 @@ |
| 213 | 222 | } |
| 214 | 223 | |
| 215 | 224 | $("#export").on("click",function(){ |
| 216 | - $get('/pcpc/scheduleAnaly',{page:'',line:line,startDate:startDate,endDate:endDate,model:model,type:'export'},function(result){ | |
| 225 | + var params = {}; | |
| 226 | + params['page'] = page; | |
| 227 | + params['line'] = line; | |
| 228 | + params['startDate'] = startDate; | |
| 229 | + params['endDate'] = endDate; | |
| 230 | + params['model'] = model; | |
| 231 | + params['company'] = company; | |
| 232 | + params['subCompany'] = subCompany; | |
| 233 | + params['type'] = "export"; | |
| 234 | + $get('/pcpc/scheduleAnaly', params, function(result){ | |
| 217 | 235 | window.open("/downloadFile/download?fileName=时刻表分析"+moment(startDate).format("YYYYMMDD")+"-"+moment(endDate).format("YYYYMMDD")); |
| 218 | 236 | }); |
| 219 | 237 | }); |
| ... | ... | @@ -289,6 +307,9 @@ |
| 289 | 307 | <script type="text/html" id="list_scheduleAnaly"> |
| 290 | 308 | {{each list as obj i}} |
| 291 | 309 | <tr> |
| 310 | + <th style="display: none;"></th> | |
| 311 | + <td>{{obj.company}}</td> | |
| 312 | + <td>{{obj.subCompany}}</td> | |
| 292 | 313 | <td>{{obj.line}}</td> |
| 293 | 314 | <td>{{obj.qdz}}</td> |
| 294 | 315 | <td>{{obj.jhfc}}</td> |
| ... | ... | @@ -305,7 +326,7 @@ |
| 305 | 326 | {{/each}} |
| 306 | 327 | {{if list.length == 0}} |
| 307 | 328 | <tr> |
| 308 | - <td colspan="12"><h6 class="muted">没有找到相关数据</h6></td> | |
| 329 | + <td colspan="14"><h6 class="muted">没有找到相关数据</h6></td> | |
| 309 | 330 | </tr> |
| 310 | 331 | {{/if}} |
| 311 | 332 | </script> |
| 312 | 333 | \ No newline at end of file | ... | ... |
src/main/resources/static/pages/forms/statement/scheduleDaily.html
| ... | ... | @@ -37,7 +37,7 @@ |
| 37 | 37 | </div> |
| 38 | 38 | <div class="form-group"> |
| 39 | 39 | <input class="btn btn-default" type="button" id="query" value="查询"/> |
| 40 | - <input class="btn btn-default" type="button" id="export" value="导出"/> | |
| 40 | +<!-- <input class="btn btn-default" type="button" id="export" value="导出"/> --> | |
| 41 | 41 | </div> |
| 42 | 42 | </form> |
| 43 | 43 | </div> | ... | ... |