Commit a5e079d43c32ce484c0983bee5fbc4872c56a1f1

Authored by 潘钊
2 parents cad38b2c c8d5078d

Merge branch 'minhang' into qingpu

# Conflicts:
#	src/main/resources/ms-jdbc.properties
Showing 42 changed files with 1643 additions and 1503 deletions
src/main/java/com/bsth/controller/forms/ExportController.java
... ... @@ -321,31 +321,34 @@ public class ExportController {
321 321 List<Turnoutrate> turnoutrate = formsService.turnoutrate(map);
322 322 Map<String, Object> map1 = new HashMap<String, Object>();
323 323 List<Map<String, Object>> resList = new ArrayList<Map<String, Object>>();
324   - /*Float xlts=0f;
325   - Float jh=0f;
  324 + String xlts="";
  325 + String zsgs="";
  326 + String jh="";
  327 + Float j=0f;
326 328 Float sj=0f;
327 329 Float qz=0f;
328 330 Float ccl=0f;
329 331 Float bcjh=0f;
330   - Float bcsj=0f;
  332 + String bcsj="";
331 333 Float bczxl=0f;
332   - Float gs=0f;
333   - Float zhgs=0f;*/
  334 + String gs="";
  335 + String zhgs="";
334 336  
335 337 for (Turnoutrate l : turnoutrate) {
336 338 Map<String, Object> m = new HashMap<String, Object>();
337 339  
338   - /* xlts +=l.getGs()==""?0f:Float.valueOf(l.getGs());
339   - jh +=l.getZhgs()==""?0f:Float.valueOf(l.getZhgs());
340   - sj +=l.getXl()==""?0f:Float.valueOf(l.getXl());
341   - ccl +=l.getCchjh()==""?0f:Float.valueOf(l.getCchjh());
342   - bcjh +=l.getCchsj()==""?0f:Float.valueOf(l.getCchsj());
343   - bcsj +=l.getChl()==""?0f:Float.valueOf(l.getChl());
  340 + xlts +=l.getGsgs()==""?0:String.valueOf(l.getGsgs());
  341 + zsgs +=l.getFgsgs()==""?0:String.valueOf(l.getFgsgs());
  342 + jh +=l.getXl()==""?0:String.valueOf(l.getXl());
  343 + sj +=l.getCchjh()==""?0f:Float.valueOf(l.getCchjh());
  344 + ccl +=l.getCchsj()==""?0f:Float.valueOf(l.getCchsj());
  345 + bcjh +=l.getCchqz()==""?0f:Float.valueOf(l.getCchqz());
  346 + bcsj +=l.getChl()==""?0:String.valueOf(l.getChl());
344 347 bczxl +=l.getBcjh()==""?0f:Float.valueOf(l.getBcjh());
345   - gs +=l.getBbzxl()==""?0f:Float.valueOf(l.getBbzxl());
346   - zhgs +=l.getBbzxl()==""?0f:Float.valueOf(l.getBbzxl());
  348 + gs +=l.getBcsj()==""?0:String.valueOf(l.getBcsj());
  349 + zhgs +=l.getBbzxl()==""?0:String.valueOf(l.getBbzxl());
  350 +
347 351  
348   - */
349 352 m.put("rq", l.getRq());
350 353 m.put("gs", l.getGs());
351 354 m.put("zhgs", l.getZhgs());
... ... @@ -355,23 +358,27 @@ public class ExportController {
355 358 m.put("cchqz", l.getCchqz());
356 359 m.put("chl", l.getChl());
357 360 m.put("bcjh", l.getBcjh());
358   - m.put("bcsj", l.getBbzxl());
  361 + m.put("bcsj", l.getBcsj());
359 362 m.put("bbzxl", l.getBbzxl());
360 363 m.put("sm", l.getSm());
361 364 resList.add(m);
362 365  
363   - /*m=new HashMap<String,Object>();
364   - m.put("total_xlts", jh);
  366 +
  367 +
  368 + m=new HashMap<String,Object>();
  369 + m.put("total_xlts", xlts);
  370 + m.put("total_zhgs", zsgs);
365 371 m.put("total_jh", jh);
366 372 m.put("total_sj", sj);
367   - m.put("total_qz", qz);
368   - m.put("total_ccl", ccl);
369   - m.put("total_bcjh", bcjh);
370   - m.put("total_bcsj", bcsj);
  373 + m.put("total_qz", ccl);
  374 + m.put("total_ccl", bcjh);
  375 + m.put("total_bcjh",bcsj);
  376 + m.put("total_bcsj", bczxl);
371 377 m.put("total_bczxl", bczxl);
372   - m.put("total_gs", gs);
373   - m.put("total_zhgs", zhgs);
374   - */
  378 + m.put("total_gs", zhgs);
  379 +
  380 +
  381 + map1 = m;
375 382 }
376 383  
377 384 try {
... ... @@ -385,7 +392,7 @@ public class ExportController {
385 392 return resList;
386 393 }
387 394  
388   - //营运线路出车率统计表
  395 + //班次执行率统计表
389 396 @RequestMapping(value = "/executionrateExport", method = RequestMethod.POST)
390 397 public List<Map<String, Object>> executionrateExport(@RequestParam Map<String, Object> map) {
391 398 SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"), sdfSimple = new SimpleDateFormat("yyyyMMdd");
... ... @@ -394,29 +401,33 @@ public class ExportController {
394 401 List<Executionrate> executionrate = formsService.executionrate(map);
395 402 Map<String, Object> map1 = new HashMap<String, Object>();
396 403 List<Map<String, Object>> resList = new ArrayList<Map<String, Object>>();
397   - /* Float xlts=0f;
398   - Float jh=0f;
  404 + String xlts="";
  405 + String zsgs="";
  406 + String jh="";
399 407 Float sj=0f;
400 408 Float ccl=0f;
401 409 Float bcjh=0f;
402   - Float bcsj=0f;
  410 + String bcsj="";
403 411 Float bczxl=0f;
404   - Float gs=0f;
405   - Float zhgs=0f;*/
  412 + String gs="";
  413 + String zhgs="";
406 414  
  415 + Map<String, Object> m = new HashMap<String, Object>();
  416 +
407 417 for (Executionrate l : executionrate) {
408   - Map<String, Object> m = new HashMap<String, Object>();
409   - /* xlts +=l.getGs()==""?0f:Float.valueOf(l.getGs());
410   - jh +=l.getZhgs()==""?0f:Float.valueOf(l.getZhgs());
411   - sj +=l.getXl()==""?0f:Float.valueOf(l.getXl());
412   - ccl +=l.getCchjh()==""?0f:Float.valueOf(l.getCchjh());
413   - bcjh +=l.getCchsj()==""?0f:Float.valueOf(l.getCchsj());
414   - bcsj +=l.getChl()==""?0f:Float.valueOf(l.getChl());
  418 +
  419 + xlts +=l.getGsgs()==""?0:String.valueOf(l.getGsgs());
  420 + zsgs +=l.getFgsgs()==""?0:String.valueOf(l.getFgsgs());
  421 + jh +=l.getXl()==""?0:String.valueOf(l.getXl());
  422 + sj +=l.getCchjh()==""?0f:Float.valueOf(l.getCchjh());
  423 + ccl +=l.getCchsj()==""?0f:Float.valueOf(l.getCchsj());
  424 + bcsj +=l.getChl()==""?0:String.valueOf(l.getChl());
415 425 bczxl +=l.getBcjh()==""?0f:Float.valueOf(l.getBcjh());
416   - gs +=l.getBbzxl()==""?0f:Float.valueOf(l.getBbzxl());
417   - zhgs +=l.getBbzxl()==""?0f:Float.valueOf(l.getBbzxl());
  426 + gs +=l.getBcsj()==""?0:String.valueOf(l.getBcsj());
  427 + zhgs +=l.getBbzxl()==""?0:String.valueOf(l.getBbzxl());
  428 +
  429 +
418 430  
419   - */
420 431 m.put("rq", l.getRq());
421 432 m.put("gs", l.getGs());
422 433 m.put("zhgs", l.getZhgs());
... ... @@ -425,23 +436,24 @@ public class ExportController {
425 436 m.put("cchsj", l.getCchsj());
426 437 m.put("chl", l.getChl());
427 438 m.put("bcjh", l.getBcjh());
428   - m.put("bcsj", l.getBbzxl());
  439 + m.put("bcsj", l.getBcsj());
429 440 m.put("bbzxl", l.getBbzxl());
430 441 m.put("sm", l.getSm());
431 442 resList.add(m);
432 443  
433 444  
434   - /* m=new HashMap<String,Object>();
  445 + m=new HashMap<String,Object>();
  446 + m.put("total_gs", xlts);
  447 + m.put("total_zhgs", zsgs);
435 448 m.put("total_xlts", jh);
436   - m.put("total_jh", jh);
437   - m.put("total_sj", sj);
438   - m.put("total_ccl", ccl);
439   - m.put("total_bcjh", bcjh);
440   - m.put("total_bcsj", bcsj);
441   - m.put("total_bczxl", bczxl);
442   - m.put("total_gs", gs);
443   - m.put("total_zhgs", zhgs);*/
  449 + m.put("total_jh", sj);
  450 + m.put("total_sj", ccl);
  451 + m.put("total_ccl",bcsj);
  452 + m.put("total_bcjh", bczxl);
  453 + m.put("total_bcsj", gs);
  454 + m.put("total_bczxl", zhgs);
444 455  
  456 + map1 = m;
445 457 }
446 458  
447 459 try {
... ... @@ -465,41 +477,42 @@ public class ExportController {
465 477 List<Allline> allline = formsService.allline(map);
466 478 Map<String, Object> map1 = new HashMap<String, Object>();
467 479 List<Map<String, Object>> resList = new ArrayList<Map<String, Object>>();
468   - /* Integer jh=0;
  480 + Integer jh=0;
469 481 Integer sj=0;
470 482 Integer ccl=0;
471   - Integer bcjh=0;
472   - Float bcsj=0f;
  483 + Double bcjh=0.0;
  484 + String bcsj="";
473 485 Integer bczxl=0;
474   - Integer gs=0;
475   - Float zhgs=0f;
476   - */
  486 + String gs="";
  487 + String zhgs="";
  488 + Map<String, Object> m ;
477 489 for (Allline l : allline) {
478   - Map<String, Object> m = new HashMap<String, Object>();
  490 + m = new HashMap<String, Object>();
479 491  
480   - /*jh +=l.getGsgs()=="" ? 0: Integer.valueOf(l.getGsgs());
  492 + jh +=l.getGsgs()=="" ? 0: Integer.valueOf(l.getGsgs());
481 493 sj +=l.getFgsgs()==""?0: Integer.valueOf(l.getFgsgs());
482 494 ccl +=l.getCchjh()==""?0: Integer.valueOf(l.getCchjh());
483   - bcjh +=l.getCchsj()==""?0: Integer.valueOf(l.getCchsj());
484   - bcsj +=l.getChl()==""?0f:Float.valueOf(l.getChl());
  495 + bcjh +=l.getCchsj()==""?0: Double.valueOf(l.getCchsj());
  496 +
  497 + bcsj +=l.getChl()==""? 0:String.valueOf(l.getChl());
485 498 bczxl +=l.getBcjh()==""?0: Integer.valueOf(l.getBcjh());
486   - gs +=l.getBbzxl()==""?0: Integer.valueOf(l.getBbzxl());
487   - zhgs +=l.getBbzxl()==""?0f:Float.valueOf(l.getBbzxl());
488   - */
  499 + gs +=l.getBcsj()==""?0: String.valueOf(l.getBcsj());
  500 + zhgs +=l.getBbzxl()==""?0:String.valueOf(l.getBbzxl());
  501 +
489 502 m.put("rq", l.getRq());
490   - m.put("gs", l.getGsgs());
491   - m.put("zhgs", l.getFgsgs());
492   - //m.put("xl", l.getXl());
  503 + m.put("gs", l.getGs());
  504 + m.put("zhgs", l.getZhgs());
  505 + m.put("xl", l.getXl());
493 506 m.put("cchjh", l.getCchjh());
494 507 m.put("cchsj", l.getCchsj());
495 508 m.put("chl", l.getChl());
496 509 m.put("bcjh", l.getBcjh());
497   - m.put("bcsj", l.getBbzxl());
  510 + m.put("bcsj", l.getBcsj());
498 511 m.put("bbzxl", l.getBbzxl());
499 512 m.put("sm", l.getSm());
500 513 resList.add(m);
501 514  
502   - /*m=new HashMap<String,Object>();
  515 + m=new HashMap<String,Object>();
503 516 m.put("total_jh", jh);
504 517 m.put("total_sj", sj);
505 518 m.put("total_ccl", ccl);
... ... @@ -508,7 +521,8 @@ public class ExportController {
508 521 m.put("total_bczxl", bczxl);
509 522 m.put("total_gs", gs);
510 523 m.put("total_zhgs", zhgs);
511   - */
  524 + map1 = m;
  525 +
512 526 }
513 527  
514 528 try {
... ...
src/main/java/com/bsth/controller/realcontrol/SignalStateController.java
1   -package com.bsth.controller.realcontrol;
2   -
3   -import com.bsth.data.gpsdata.SignalStateData;
4   -import com.bsth.data.gpsdata.arrival.entity.SignalState;
5   -import org.springframework.beans.factory.annotation.Autowired;
6   -import org.springframework.web.bind.annotation.RequestMapping;
7   -import org.springframework.web.bind.annotation.RequestParam;
8   -import org.springframework.web.bind.annotation.RestController;
9   -
10   -import java.util.List;
11   -
12   -/**
13   - * Created by panzhao on 2016/12/30.
14   - */
15   -@RestController
16   -@RequestMapping("signalState")
17   -public class SignalStateController {
18   -
19   - @Autowired
20   - SignalStateData signalStateData;
21   -
22   - @RequestMapping("/multi")
23   - public List<SignalState> findByMultiLine(@RequestParam String idx){
24   - return signalStateData.get(idx);
25   - }
26   -}
  1 +package com.bsth.controller.realcontrol;
  2 +
  3 +import com.bsth.data.gpsdata.SignalStateData;
  4 +import com.bsth.data.gpsdata.arrival.entity.SignalState;
  5 +import org.springframework.beans.factory.annotation.Autowired;
  6 +import org.springframework.web.bind.annotation.RequestMapping;
  7 +import org.springframework.web.bind.annotation.RequestParam;
  8 +import org.springframework.web.bind.annotation.RestController;
  9 +
  10 +import java.util.List;
  11 +
  12 +/**
  13 + * Created by panzhao on 2016/12/30.
  14 + */
  15 +@RestController
  16 +@RequestMapping("signalState")
  17 +public class SignalStateController {
  18 +
  19 + @Autowired
  20 + SignalStateData signalStateData;
  21 +
  22 + @RequestMapping("/multi")
  23 + public List<SignalState> findByMultiLine(@RequestParam String idx){
  24 + return signalStateData.get(idx);
  25 + }
  26 +}
... ...
src/main/java/com/bsth/data/BasicData.java
... ... @@ -13,7 +13,6 @@ 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;
17 16 import org.springframework.stereotype.Component;
18 17  
19 18 import java.util.*;
... ... @@ -26,7 +25,6 @@ import java.util.concurrent.TimeUnit;
26 25 * @date 2016年8月10日 下午3:27:45
27 26 */
28 27 @Component
29   -@Order(value = 1)
30 28 public class BasicData implements CommandLineRunner {
31 29  
32 30 //公司代码和公司名对照(K: 公司编码,V:公司名)
... ... @@ -83,9 +81,13 @@ public class BasicData implements CommandLineRunner {
83 81  
84 82 @Override
85 83 public void run(String... arg0) throws Exception {
86   - Application.mainServices.scheduleWithFixedDelay(dataLoader, 0, 2, TimeUnit.HOURS);
  84 + Application.mainServices.scheduleWithFixedDelay(dataLoader, 2, 2, TimeUnit.HOURS);
87 85 }
88 86  
  87 + public static String getStationNameByCode(String code, String prefix){
  88 + String name = stationCode2NameMap.get(code);
  89 + return name != null? name: stationCode2NameMap.get(prefix + code);
  90 + }
89 91  
90 92 @Component
91 93 public static class BasicDataLoader extends Thread {
... ...
src/main/java/com/bsth/data/forecast/ForecastRealServer.java
... ... @@ -86,7 +86,7 @@ public class ForecastRealServer implements CommandLineRunner {
86 86 //终点站
87 87 String eStation = null;
88 88 //当前执行班次
89   - ScheduleRealInfo sch = dayOfSchedule.execPlanMap().get(nbbm);
  89 + ScheduleRealInfo sch = dayOfSchedule.executeCurr(nbbm);
90 90 if(null != sch)
91 91 eStation = sch.getZdzCode();
92 92  
... ...
src/main/java/com/bsth/data/gpsdata/GpsRealData.java
... ... @@ -66,22 +66,41 @@ public class GpsRealData implements CommandLineRunner {
66 66 @Override
67 67 public void run(String... arg0) throws Exception {
68 68 logger.info("gpsDataLoader,20,5");
69   - //Application.mainServices.scheduleWithFixedDelay(gpsDataLoader, 20, 6, TimeUnit.SECONDS);
  69 + //Application.mainServices.scheduleWithFixedDelay(gpsDataLoader, 20, 30, TimeUnit.SECONDS);
70 70 }
71 71  
72 72 public void put(GpsEntity gps) {
73 73 String device = gps.getDeviceId();
74   - gpsMap.put(device, gps);
  74 + GpsEntity old = gpsMap.get(device);
  75 +
  76 + try {
  77 + if (!StringUtils.isEmpty(gps.getStopNo())) {
  78 + //站点编码改变
  79 + if (null == old || !gps.getStopNo().equals(old.getStopNo())) {
  80 + gps.setArrTime(gps.getTimestamp());
  81 + //预测到达终点时间
  82 + forecastRealServer.forecast(gps.getNbbm(), gps);
  83 + } else {
  84 + gps.setArrTime(old.getArrTime());
  85 + //不预测, 重新计算终点时间
  86 + gps.setExpectStopTime(forecastRealServer.expectStopTime(gps.getNbbm()));
  87 + }
  88 + }
  89 + } catch (Exception e) {
  90 + logger.error("", e);
  91 + }
75 92  
76   - if (StringUtils.isNotBlank(gps.getLineId())){
  93 + //刷新对照
  94 + gpsMap.put(device, gps);
  95 + if (StringUtils.isNotBlank(gps.getLineId())) {
77 96 //站点名称
78 97 gps.setStationName(getStationName(gps));
79 98 lineCode2Devices.put(gps.getLineId(), device);
80 99 }
81 100 }
82 101  
83   - public String getStationName(GpsEntity gps){
84   - return BasicData.stationCode2NameMap.get(gps.getLineId() + "_" + gps.getUpDown() + gps.getStopNo());
  102 + public String getStationName(GpsEntity gps) {
  103 + return BasicData.getStationNameByCode(gps.getStopNo(), gps.getLineId() + "_" + gps.getUpDown() + "_");
85 104 }
86 105  
87 106 /**
... ... @@ -103,7 +122,7 @@ public class GpsRealData implements CommandLineRunner {
103 122 for (String device : set) {
104 123 gps = gpsMap.get(device);
105 124 //过滤异常GPS数据
106   - if (gps.isAbnormal())
  125 + if (gps == null || gps.isAbnormal())
107 126 continue;
108 127  
109 128 sch = dayOfSchedule.execPlanMap().get(gps.getNbbm());
... ... @@ -206,8 +225,6 @@ public class GpsRealData implements CommandLineRunner {
206 225 gps.setNbbm(nbbm);
207 226 //有更新的点位
208 227 updateList.add(gps);
209   - //实时GPS数据集
210   - gpsRealData.put(gps);
211 228 }
212 229 //分析数据
213 230 gpsRealAnalyse.analyse(updateList);
... ...
src/main/java/com/bsth/data/gpsdata/SignalStateData.java
1   -package com.bsth.data.gpsdata;
2   -
3   -import com.bsth.data.gpsdata.arrival.entity.SignalState;
4   -import com.bsth.websocket.handler.SendUtils;
5   -import com.google.common.base.Splitter;
6   -import com.google.common.collect.ArrayListMultimap;
7   -import org.springframework.beans.factory.annotation.Autowired;
8   -import org.springframework.stereotype.Component;
9   -
10   -import java.util.ArrayList;
11   -import java.util.List;
12   -
13   -/**
14   - * 信号状态数据
15   - * Created by panzhao on 2016/12/30.
16   - */
17   -@Component
18   -public class SignalStateData {
19   -
20   - @Autowired
21   - SendUtils sendUtils;
22   -
23   - private static ArrayListMultimap<String, SignalState> listMultimap = ArrayListMultimap.create();
24   -
25   - public void put(SignalState state){
26   - listMultimap.put(state.getLineCode(), state);
27   - //推送到客户端
28   - sendUtils.sendSignalState(state);
29   - }
30   -
31   - public List<SignalState> get(String idx){
32   - List<SignalState> rs = new ArrayList<>();
33   - List<String> ids = Splitter.on(",").splitToList(idx);
34   -
35   - for(String lineCode : ids){
36   - rs.addAll(listMultimap.get(lineCode));
37   - }
38   - return rs;
39   - }
40   -}
  1 +package com.bsth.data.gpsdata;
  2 +
  3 +import com.bsth.data.gpsdata.arrival.entity.SignalState;
  4 +import com.bsth.websocket.handler.SendUtils;
  5 +import com.google.common.base.Splitter;
  6 +import com.google.common.collect.ArrayListMultimap;
  7 +import org.springframework.beans.factory.annotation.Autowired;
  8 +import org.springframework.stereotype.Component;
  9 +
  10 +import java.util.ArrayList;
  11 +import java.util.List;
  12 +
  13 +/**
  14 + * 信号状态数据
  15 + * Created by panzhao on 2016/12/30.
  16 + */
  17 +@Component
  18 +public class SignalStateData {
  19 +
  20 + @Autowired
  21 + SendUtils sendUtils;
  22 +
  23 + private static ArrayListMultimap<String, SignalState> listMultimap = ArrayListMultimap.create();
  24 +
  25 + public void put(SignalState state){
  26 + listMultimap.put(state.getLineCode(), state);
  27 + //推送到客户端
  28 + sendUtils.sendSignalState(state);
  29 + }
  30 +
  31 + public List<SignalState> get(String idx){
  32 + List<SignalState> rs = new ArrayList<>();
  33 + List<String> ids = Splitter.on(",").splitToList(idx);
  34 +
  35 + for(String lineCode : ids){
  36 + rs.addAll(listMultimap.get(lineCode));
  37 + }
  38 + return rs;
  39 + }
  40 +}
... ...
src/main/java/com/bsth/data/gpsdata/arrival/GeoCacheData.java
1   -package com.bsth.data.gpsdata.arrival;
2   -
3   -import com.bsth.data.gpsdata.GpsEntity;
4   -import com.bsth.data.gpsdata.arrival.entity.StationRoute;
5   -import com.bsth.data.gpsdata.arrival.utils.CircleQueue;
6   -import com.bsth.data.gpsdata.arrival.utils.StationRouteComp;
7   -import com.google.common.collect.ArrayListMultimap;
8   -import com.vividsolutions.jts.geom.Coordinate;
9   -import com.vividsolutions.jts.geom.GeometryFactory;
10   -import com.vividsolutions.jts.geom.LineString;
11   -import com.vividsolutions.jts.geom.Polygon;
12   -import org.apache.commons.lang3.StringUtils;
13   -import org.slf4j.Logger;
14   -import org.slf4j.LoggerFactory;
15   -import org.springframework.beans.factory.annotation.Autowired;
16   -import org.springframework.jdbc.core.JdbcTemplate;
17   -import org.springframework.jdbc.core.RowMapper;
18   -import org.springframework.stereotype.Component;
19   -
20   -import java.sql.ResultSet;
21   -import java.sql.SQLException;
22   -import java.util.*;
23   -
24   -/**
25   - * Created by panzhao on 2016/12/23.
26   - */
27   -@Component
28   -public class GeoCacheData {
29   -
30   - static Logger logger = LoggerFactory.getLogger(GeoCacheData.class);
31   -
32   - //每辆车缓存最后1000条gps
33   - private static final int CACHE_SIZE = 1000;
34   - private static Map<String, CircleQueue<GpsEntity>> gpsCacheMap = new HashMap<>();
35   -
36   - //线路路段走向
37   - private static ArrayListMultimap<String, LineString> sectionCacheMap;
38   -
39   - //线路站点路由
40   - private static ArrayListMultimap<String, StationRoute> stationCacheMap;
41   -
42   - //线路_上下行_站点编码 ——> 站点
43   - private static Map<String, StationRoute> routeCodeMap;
44   -
45   - //停车场
46   - public static Map<String, Polygon> tccMap;
47   -
48   - @Autowired
49   - JdbcTemplate jdbcTemplate;
50   -
51   - public static CircleQueue<GpsEntity> getGps(String nbbm) {
52   - return gpsCacheMap.get(nbbm);
53   - }
54   -
55   - public static void putGps(GpsEntity gps) {
56   - CircleQueue<GpsEntity> queue = gpsCacheMap.get(gps.getNbbm());
57   - if (queue == null) {
58   - /*//第一个点从站内开始
59   - if (gps.getInstation() == 0)
60   - return;*/
61   -
62   - queue = new CircleQueue<>(CACHE_SIZE);
63   - gpsCacheMap.put(gps.getNbbm(), queue);
64   - }
65   - queue.add(gps);
66   - }
67   -
68   - public static void clear(String nbbm) {
69   - try {
70   - CircleQueue<GpsEntity> queue = gpsCacheMap.get(nbbm);
71   - if (queue != null)
72   - queue.clear();
73   - } catch (Exception e) {
74   - logger.error("", e);
75   - }
76   - }
77   -
78   - public static StationRoute getRouteCode(GpsEntity gps) {
79   - return routeCodeMap.get(gps.getLineId() + "_" + gps.getUpDown() + "_" + gps.getStopNo());
80   - }
81   -
82   - public static List<StationRoute> getStationRoute(String lineCode, int directions) {
83   - return stationCacheMap.get(lineCode + "_" + directions);
84   - }
85   -
86   - public static StationRoute getStation(String lineCode, int directions, String code) {
87   - List<StationRoute> list = getStationRoute(lineCode, directions);
88   -
89   - for (StationRoute sr : list) {
90   - if (sr.getCode().equals(code)) {
91   - return sr;
92   - }
93   - }
94   - return null;
95   - }
96   -
97   - public static List<StationRoute> midwayStation(String lineCode, int directions, String sCode, String eCode) {
98   - List<StationRoute> list = getStationRoute(lineCode, directions), rs = new ArrayList<>();
99   -
100   - boolean flag = false;
101   - for (StationRoute sr : list) {
102   - if (flag)
103   - rs.add(sr);
104   - if (sr.getCode().equals(sCode))
105   - flag = true;
106   - else if (sr.getCode().equals(eCode))
107   - break;
108   - }
109   - return rs;
110   - }
111   -
112   - public static Polygon getTccPolygon(String code) {
113   - return tccMap.get(code);
114   - }
115   -
116   - public void loadData() {
117   - final GeometryFactory geometryFactory = new GeometryFactory();
118   - //加载站点路由
119   - String sql = "select r.LINE_CODE,r.DIRECTIONS,r.STATION_CODE,r.STATION_MARK,s.SHAPES_TYPE,s.G_LONX,s.G_LATY,ST_AsText(s.G_POLYGON_GRID) as G_POLYGON_GRID,s.RADIUS, r.STATION_ROUTE_CODE,s.STATION_NAME from bsth_c_stationroute r left join bsth_c_station s on r.station=s.id where r.destroy=0 order by r.station_route_code";
120   - List<StationRoute> routeList = jdbcTemplate.query(sql, new RowMapper<StationRoute>() {
121   - @Override
122   - public StationRoute mapRow(ResultSet rs, int rowNum) throws SQLException {
123   - StationRoute sRoute = new StationRoute();
124   - sRoute.setCode(rs.getString("STATION_CODE"));
125   - sRoute.setLineCode(rs.getString("LINE_CODE"));
126   - sRoute.setDirections(rs.getInt("DIRECTIONS"));
127   - sRoute.setPoint(geometryFactory.createPoint(new Coordinate(rs.getFloat("G_LATY"), rs.getFloat("G_LONX"))));
128   - sRoute.setRadius(rs.getFloat("RADIUS"));
129   - sRoute.setRouteSort(rs.getInt("STATION_ROUTE_CODE"));
130   - sRoute.setMark(rs.getString("STATION_MARK"));
131   - sRoute.setName(rs.getString("STATION_NAME"));
132   -
133   - String shapesType = rs.getString("SHAPES_TYPE");
134   - //多边形电子围栏
135   - if (StringUtils.isNotEmpty(shapesType) && shapesType.equals("d")) {
136   - sRoute.setPolygon(geometryFactory.createPolygon(parsePolygon(rs.getString("G_POLYGON_GRID"))));
137   - }
138   - return sRoute;
139   - }
140   - });
141   - //按线路和走向分组
142   - if (routeList.size() > 0) {
143   - ArrayListMultimap<String, StationRoute> tempMap = ArrayListMultimap.create();
144   - Map<String, StationRoute> codeMap = new HashMap<>(routeList.size());
145   - for (StationRoute sr : routeList) {
146   - tempMap.put(sr.getLineCode() + "_" + sr.getDirections(), sr);
147   - //站点编码 ——> 和路由顺序对照
148   - codeMap.put(sr.getLineCode() + "_" + sr.getDirections() + "_" + sr.getCode(), sr);
149   - }
150   -
151   - StationRouteComp srCom = new StationRouteComp();
152   - //连接路由
153   - Set<String> set = tempMap.keySet();
154   - for (String key : set) {
155   - Collections.sort(tempMap.get(key), srCom);
156   - connectStationRoute(tempMap.get(key));
157   - }
158   -
159   - stationCacheMap = tempMap;
160   - routeCodeMap = codeMap;
161   - }
162   -
163   - //加载停车场数据
164   - sql = "select PARK_CODE, ST_AsText(G_PARK_POINT) as G_PARK_POINT from bsth_c_car_park where park_code is not null and b_park_point is not null";
165   - List<Map<String, Object>> tccList = jdbcTemplate.queryForList(sql);
166   - Map<String, Polygon> tccTempMap = new HashMap<>();
167   -
168   - Polygon polygon;
169   - for (Map<String, Object> tMap : tccList) {
170   -
171   - try {
172   - polygon = geometryFactory.createPolygon(parsePolygon(tMap.get("G_PARK_POINT").toString()));
173   - tccTempMap.put(tMap.get("PARK_CODE").toString()
174   - , polygon);
175   - } catch (Exception e) {
176   - logger.error("停车场:" + tMap.get("PARK_CODE"), e);
177   - }
178   - }
179   -
180   - if (tccTempMap.size() > 0)
181   - tccMap = tccTempMap;
182   - }
183   -
184   - private void connectStationRoute(List<StationRoute> list) {
185   - int size = list.size();
186   - StationRoute sr = null;
187   - for (int i = 0; i < size; i++) {
188   - sr = list.get(i);
189   - //上一个
190   - if (i > 0)
191   - sr.setPrve(list.get(i - 1));
192   - //下一个
193   - if (i < size - 1)
194   - sr.setNext(list.get(i + 1));
195   - }
196   - }
197   -
198   - public Coordinate[] parsePolygon(String polygonStr) {
199   - String[] coords = polygonStr.substring(9, polygonStr.length() - 2).split(","), temps;
200   -
201   - Coordinate[] cds = new Coordinate[coords.length];
202   - int len = coords.length;
203   - for (int i = 0; i < len; i++) {
204   - temps = coords[i].split(" ");
205   - cds[i] = new Coordinate(Float.parseFloat(temps[1]), Float.parseFloat(temps[0]));
206   - }
207   - return cds;
208   - }
209   -
210   - /**
211   - * 是不是终点站
212   - * @param lineId
213   - * @param upDown
214   - * @param stationCode
215   - * @return
216   - */
217   - public static boolean isEndStation(String lineId, Integer upDown, String stationCode) {
218   - StationRoute station = routeCodeMap.get(lineId + "_" + upDown + "_" + stationCode);
219   - return station != null && station.getMark().equals("E");
220   - }
  1 +package com.bsth.data.gpsdata.arrival;
  2 +
  3 +import com.bsth.data.gpsdata.GpsEntity;
  4 +import com.bsth.data.gpsdata.arrival.entity.StationRoute;
  5 +import com.bsth.data.gpsdata.arrival.utils.CircleQueue;
  6 +import com.bsth.data.gpsdata.arrival.utils.StationRouteComp;
  7 +import com.google.common.collect.ArrayListMultimap;
  8 +import com.vividsolutions.jts.geom.Coordinate;
  9 +import com.vividsolutions.jts.geom.GeometryFactory;
  10 +import com.vividsolutions.jts.geom.LineString;
  11 +import com.vividsolutions.jts.geom.Polygon;
  12 +import org.apache.commons.lang3.StringUtils;
  13 +import org.slf4j.Logger;
  14 +import org.slf4j.LoggerFactory;
  15 +import org.springframework.beans.factory.annotation.Autowired;
  16 +import org.springframework.jdbc.core.JdbcTemplate;
  17 +import org.springframework.jdbc.core.RowMapper;
  18 +import org.springframework.stereotype.Component;
  19 +
  20 +import java.sql.ResultSet;
  21 +import java.sql.SQLException;
  22 +import java.util.*;
  23 +
  24 +/**
  25 + * Created by panzhao on 2016/12/23.
  26 + */
  27 +@Component
  28 +public class GeoCacheData {
  29 +
  30 + static Logger logger = LoggerFactory.getLogger(GeoCacheData.class);
  31 +
  32 + //每辆车缓存最后1000条gps
  33 + private static final int CACHE_SIZE = 1000;
  34 + private static Map<String, CircleQueue<GpsEntity>> gpsCacheMap = new HashMap<>();
  35 +
  36 + //线路路段走向
  37 + private static ArrayListMultimap<String, LineString> sectionCacheMap;
  38 +
  39 + //线路站点路由
  40 + private static ArrayListMultimap<String, StationRoute> stationCacheMap;
  41 +
  42 + //线路_上下行_站点编码 ——> 站点
  43 + private static Map<String, StationRoute> routeCodeMap;
  44 +
  45 + //停车场
  46 + public static Map<String, Polygon> tccMap;
  47 +
  48 + @Autowired
  49 + JdbcTemplate jdbcTemplate;
  50 +
  51 + public static CircleQueue<GpsEntity> getGps(String nbbm) {
  52 + return gpsCacheMap.get(nbbm);
  53 + }
  54 +
  55 + public static void putGps(GpsEntity gps) {
  56 + CircleQueue<GpsEntity> queue = gpsCacheMap.get(gps.getNbbm());
  57 + if (queue == null) {
  58 + /*//第一个点从站内开始
  59 + if (gps.getInstation() == 0)
  60 + return;*/
  61 +
  62 + queue = new CircleQueue<>(CACHE_SIZE);
  63 + gpsCacheMap.put(gps.getNbbm(), queue);
  64 + }
  65 + queue.add(gps);
  66 + }
  67 +
  68 + public static void clear(String nbbm) {
  69 + try {
  70 + CircleQueue<GpsEntity> queue = gpsCacheMap.get(nbbm);
  71 + if (queue != null)
  72 + queue.clear();
  73 + } catch (Exception e) {
  74 + logger.error("", e);
  75 + }
  76 + }
  77 +
  78 + public static StationRoute getRouteCode(GpsEntity gps) {
  79 + return routeCodeMap.get(gps.getLineId() + "_" + gps.getUpDown() + "_" + gps.getStopNo());
  80 + }
  81 +
  82 + public static List<StationRoute> getStationRoute(String lineCode, int directions) {
  83 + return stationCacheMap.get(lineCode + "_" + directions);
  84 + }
  85 +
  86 + public static StationRoute getStation(String lineCode, int directions, String code) {
  87 + List<StationRoute> list = getStationRoute(lineCode, directions);
  88 +
  89 + for (StationRoute sr : list) {
  90 + if (sr.getCode().equals(code)) {
  91 + return sr;
  92 + }
  93 + }
  94 + return null;
  95 + }
  96 +
  97 + public static List<StationRoute> midwayStation(String lineCode, int directions, String sCode, String eCode) {
  98 + List<StationRoute> list = getStationRoute(lineCode, directions), rs = new ArrayList<>();
  99 +
  100 + boolean flag = false;
  101 + for (StationRoute sr : list) {
  102 + if (flag)
  103 + rs.add(sr);
  104 + if (sr.getCode().equals(sCode))
  105 + flag = true;
  106 + else if (sr.getCode().equals(eCode))
  107 + break;
  108 + }
  109 + return rs;
  110 + }
  111 +
  112 + public static Polygon getTccPolygon(String code) {
  113 + return tccMap.get(code);
  114 + }
  115 +
  116 + public void loadData() {
  117 + final GeometryFactory geometryFactory = new GeometryFactory();
  118 + //加载站点路由
  119 + String sql = "select r.LINE_CODE,r.DIRECTIONS,r.STATION_CODE,r.STATION_MARK,s.SHAPES_TYPE,s.G_LONX,s.G_LATY,ST_AsText(s.G_POLYGON_GRID) as G_POLYGON_GRID,s.RADIUS, r.STATION_ROUTE_CODE,s.STATION_NAME from bsth_c_stationroute r left join bsth_c_station s on r.station=s.id where r.destroy=0 order by r.station_route_code";
  120 + List<StationRoute> routeList = jdbcTemplate.query(sql, new RowMapper<StationRoute>() {
  121 + @Override
  122 + public StationRoute mapRow(ResultSet rs, int rowNum) throws SQLException {
  123 + StationRoute sRoute = new StationRoute();
  124 + sRoute.setCode(rs.getString("STATION_CODE"));
  125 + sRoute.setLineCode(rs.getString("LINE_CODE"));
  126 + sRoute.setDirections(rs.getInt("DIRECTIONS"));
  127 + sRoute.setPoint(geometryFactory.createPoint(new Coordinate(rs.getFloat("G_LATY"), rs.getFloat("G_LONX"))));
  128 + sRoute.setRadius(rs.getFloat("RADIUS"));
  129 + sRoute.setRouteSort(rs.getInt("STATION_ROUTE_CODE"));
  130 + sRoute.setMark(rs.getString("STATION_MARK"));
  131 + sRoute.setName(rs.getString("STATION_NAME"));
  132 +
  133 + String shapesType = rs.getString("SHAPES_TYPE");
  134 + //多边形电子围栏
  135 + if (StringUtils.isNotEmpty(shapesType) && shapesType.equals("d")) {
  136 + sRoute.setPolygon(geometryFactory.createPolygon(parsePolygon(rs.getString("G_POLYGON_GRID"))));
  137 + }
  138 + return sRoute;
  139 + }
  140 + });
  141 + //按线路和走向分组
  142 + if (routeList.size() > 0) {
  143 + ArrayListMultimap<String, StationRoute> tempMap = ArrayListMultimap.create();
  144 + Map<String, StationRoute> codeMap = new HashMap<>(routeList.size());
  145 + for (StationRoute sr : routeList) {
  146 + tempMap.put(sr.getLineCode() + "_" + sr.getDirections(), sr);
  147 + //站点编码 ——> 和路由顺序对照
  148 + codeMap.put(sr.getLineCode() + "_" + sr.getDirections() + "_" + sr.getCode(), sr);
  149 + }
  150 +
  151 + StationRouteComp srCom = new StationRouteComp();
  152 + //连接路由
  153 + Set<String> set = tempMap.keySet();
  154 + for (String key : set) {
  155 + Collections.sort(tempMap.get(key), srCom);
  156 + connectStationRoute(tempMap.get(key));
  157 + }
  158 +
  159 + stationCacheMap = tempMap;
  160 + routeCodeMap = codeMap;
  161 + }
  162 +
  163 + //加载停车场数据
  164 + sql = "select PARK_CODE, ST_AsText(G_PARK_POINT) as G_PARK_POINT from bsth_c_car_park where park_code is not null and b_park_point is not null";
  165 + List<Map<String, Object>> tccList = jdbcTemplate.queryForList(sql);
  166 + Map<String, Polygon> tccTempMap = new HashMap<>();
  167 +
  168 + Polygon polygon;
  169 + for (Map<String, Object> tMap : tccList) {
  170 +
  171 + try {
  172 + polygon = geometryFactory.createPolygon(parsePolygon(tMap.get("G_PARK_POINT").toString()));
  173 + tccTempMap.put(tMap.get("PARK_CODE").toString()
  174 + , polygon);
  175 + } catch (Exception e) {
  176 + logger.error("停车场:" + tMap.get("PARK_CODE"), e);
  177 + }
  178 + }
  179 +
  180 + if (tccTempMap.size() > 0)
  181 + tccMap = tccTempMap;
  182 + }
  183 +
  184 + private void connectStationRoute(List<StationRoute> list) {
  185 + int size = list.size();
  186 + StationRoute sr = null;
  187 + for (int i = 0; i < size; i++) {
  188 + sr = list.get(i);
  189 + //上一个
  190 + if (i > 0)
  191 + sr.setPrve(list.get(i - 1));
  192 + //下一个
  193 + if (i < size - 1)
  194 + sr.setNext(list.get(i + 1));
  195 + }
  196 + }
  197 +
  198 + public Coordinate[] parsePolygon(String polygonStr) {
  199 + String[] coords = polygonStr.substring(9, polygonStr.length() - 2).split(","), temps;
  200 +
  201 + Coordinate[] cds = new Coordinate[coords.length];
  202 + int len = coords.length;
  203 + for (int i = 0; i < len; i++) {
  204 + temps = coords[i].split(" ");
  205 + cds[i] = new Coordinate(Float.parseFloat(temps[1]), Float.parseFloat(temps[0]));
  206 + }
  207 + return cds;
  208 + }
  209 +
  210 + /**
  211 + * 是不是终点站
  212 + * @param lineId
  213 + * @param upDown
  214 + * @param stationCode
  215 + * @return
  216 + */
  217 + public static boolean isEndStation(String lineId, Integer upDown, String stationCode) {
  218 + StationRoute station = routeCodeMap.get(lineId + "_" + upDown + "_" + stationCode);
  219 + return station != null && station.getMark().equals("E");
  220 + }
221 221 }
222 222 \ No newline at end of file
... ...
src/main/java/com/bsth/data/gpsdata/arrival/GpsRealAnalyse.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.GpsRealData;
4 5 import com.bsth.data.gpsdata.arrival.handlers.*;
5 6 import com.bsth.data.gpsdata.arrival.utils.CircleQueue;
6 7 import org.slf4j.Logger;
... ... @@ -33,6 +34,9 @@ public class GpsRealAnalyse {
33 34 @Autowired
34 35 ReverseSignalHandle reverseSignalHandle;
35 36  
  37 + @Autowired
  38 + GpsRealData gpsRealData;
  39 +
36 40 //50个线程
37 41 static ExecutorService threadPool = Executors.newFixedThreadPool(50);
38 42  
... ... @@ -45,6 +49,10 @@ public class GpsRealAnalyse {
45 49 try {
46 50 //等待子线程结束
47 51 count.await();
  52 +
  53 + //加入实时gps对照
  54 + for(GpsEntity gps: list)
  55 + gpsRealData.put(gps);
48 56 } catch (InterruptedException e) {
49 57 logger.error("", e);
50 58 }
... ...
src/main/java/com/bsth/data/gpsdata/arrival/SignalHandle.java
1   -package com.bsth.data.gpsdata.arrival;
2   -
3   -import com.bsth.data.gpsdata.GpsEntity;
4   -import com.bsth.data.gpsdata.arrival.entity.StationRoute;
5   -import com.bsth.data.gpsdata.arrival.utils.CircleQueue;
6   -import com.bsth.data.gpsdata.arrival.utils.GeoUtils;
7   -import com.bsth.entity.realcontrol.ScheduleRealInfo;
8   -
9   -import java.util.List;
10   -
11   -/**
12   - * Created by panzhao on 2016/12/27.
13   - */
14   -public abstract class SignalHandle {
15   -
16   - public abstract boolean handle(GpsEntity gps, CircleQueue<GpsEntity> prevs);
17   -
18   - protected boolean isNotEmpty(CircleQueue<GpsEntity> prevs) {
19   - return prevs != null && prevs.size() > 0 && prevs.getTail() != null;
20   - }
21   -
22   - protected boolean isDriftSignal(GpsEntity gps) {
23   - return gps.getLat() == 0 || gps.getLon() == 0;
24   - }
25   -
26   - /**
27   - * 是不是异常信号
28   - *
29   - * @param gps
30   - * @return protected boolean isAbnormal(GpsEntity gps) {
31   - return gps.getLat() == 0 || gps.getLon() == 0;
32   - }*/
33   -
34   - /**
35   - * 连续异常信号个数统计
36   - *
37   - * @param prevs
38   - * @return protected int abnormalCount(CircleQueue<GpsEntity> prevs) {
39   - * int count = 0;
40   - * <p>
41   - * if (!isNotEmpty(prevs))
42   - * return count;
43   - * <p>
44   - * GpsEntity[] array = (GpsEntity[]) prevs.getQueue();
45   - * GpsEntity gps;
46   - * for (int i = array.length - 1; i > 0; i--) {
47   - * gps = array[i];
48   - * <p>
49   - * if (isAbnormal(gps))
50   - * count++;
51   - * else
52   - * break;
53   - * }
54   - * <p>
55   - * return count;
56   - * }
57   - */
58   -
59   - protected void transformUpdown(GpsEntity gps, ScheduleRealInfo sch) {
60   - int updown = Integer.parseInt(sch.getXlDir());
61   - List<StationRoute> srs = GeoCacheData.getStationRoute(sch.getXlBm(), updown);
62   - StationRoute station = GeoUtils.gpsInStation(gps, srs);
63   - if (station != null) {
64   - gps.setUpDown(updown);
65   - gps.setStopNo(station.getCode());
66   - }
67   - }
68   -
69   - /**
70   - * 是否是从异常状态恢复的第一个信号
71   - *
72   - * @param gps
73   - * @param prevs
74   - * @return
75   - */
76   - protected boolean abnormalRecovery(GpsEntity gps, CircleQueue<GpsEntity> prevs) {
77   - if (prevs == null || prevs.size() == 0)
78   - return false;
79   -
80   - GpsEntity prev = prevs.getTail();
81   - //从漂移状态恢复
82   - if (isDriftSignal(prev)
83   - && !isDriftSignal(gps)) {
84   - return true;
85   - }
86   -
87   - return false;
88   - }
  1 +package com.bsth.data.gpsdata.arrival;
  2 +
  3 +import com.bsth.data.gpsdata.GpsEntity;
  4 +import com.bsth.data.gpsdata.arrival.entity.StationRoute;
  5 +import com.bsth.data.gpsdata.arrival.utils.CircleQueue;
  6 +import com.bsth.data.gpsdata.arrival.utils.GeoUtils;
  7 +import com.bsth.entity.realcontrol.ScheduleRealInfo;
  8 +
  9 +import java.util.List;
  10 +
  11 +/**
  12 + * Created by panzhao on 2016/12/27.
  13 + */
  14 +public abstract class SignalHandle {
  15 +
  16 + public abstract boolean handle(GpsEntity gps, CircleQueue<GpsEntity> prevs);
  17 +
  18 + protected boolean isNotEmpty(CircleQueue<GpsEntity> prevs) {
  19 + return prevs != null && prevs.size() > 0 && prevs.getTail() != null;
  20 + }
  21 +
  22 + protected boolean isDriftSignal(GpsEntity gps) {
  23 + return gps.getLat() == 0 || gps.getLon() == 0;
  24 + }
  25 +
  26 + /**
  27 + * 是不是异常信号
  28 + *
  29 + * @param gps
  30 + * @return protected boolean isAbnormal(GpsEntity gps) {
  31 + return gps.getLat() == 0 || gps.getLon() == 0;
  32 + }*/
  33 +
  34 + /**
  35 + * 连续异常信号个数统计
  36 + *
  37 + * @param prevs
  38 + * @return protected int abnormalCount(CircleQueue<GpsEntity> prevs) {
  39 + * int count = 0;
  40 + * <p>
  41 + * if (!isNotEmpty(prevs))
  42 + * return count;
  43 + * <p>
  44 + * GpsEntity[] array = (GpsEntity[]) prevs.getQueue();
  45 + * GpsEntity gps;
  46 + * for (int i = array.length - 1; i > 0; i--) {
  47 + * gps = array[i];
  48 + * <p>
  49 + * if (isAbnormal(gps))
  50 + * count++;
  51 + * else
  52 + * break;
  53 + * }
  54 + * <p>
  55 + * return count;
  56 + * }
  57 + */
  58 +
  59 + protected void transformUpdown(GpsEntity gps, ScheduleRealInfo sch) {
  60 + int updown = Integer.parseInt(sch.getXlDir());
  61 + List<StationRoute> srs = GeoCacheData.getStationRoute(sch.getXlBm(), updown);
  62 + StationRoute station = GeoUtils.gpsInStation(gps, srs);
  63 + if (station != null) {
  64 + gps.setUpDown(updown);
  65 + gps.setStopNo(station.getCode());
  66 + }
  67 + }
  68 +
  69 + /**
  70 + * 是否是从异常状态恢复的第一个信号
  71 + *
  72 + * @param gps
  73 + * @param prevs
  74 + * @return
  75 + */
  76 + protected boolean abnormalRecovery(GpsEntity gps, CircleQueue<GpsEntity> prevs) {
  77 + if (prevs == null || prevs.size() == 0)
  78 + return false;
  79 +
  80 + GpsEntity prev = prevs.getTail();
  81 + //从漂移状态恢复
  82 + if (isDriftSignal(prev)
  83 + && !isDriftSignal(gps)) {
  84 + return true;
  85 + }
  86 +
  87 + return false;
  88 + }
89 89 }
90 90 \ No newline at end of file
... ...
src/main/java/com/bsth/data/gpsdata/arrival/entity/RouteReverse.java
1   -package com.bsth.data.gpsdata.arrival.entity;
2   -
3   -/** 路由反转
4   - * Created by panzhao on 2016/12/28.
5   - */
6   -public class RouteReverse {
7   -
8   - private String nbbm;
9   - //反转个数
10   - private int count;
11   -
12   - //详细 1,2,3,2,1
13   - private String detail;
14   -
15   - //掉头站点
16   - private String turned;
17   -
18   - //掉头时间
19   - private long zt;
20   -
21   - //检测时间
22   - private long ct;
23   -
24   - //是否闭合
25   - private boolean close;
26   -
27   - //信号不明确
28   - private boolean vague;
29   -
30   - public int getCount() {
31   - return count;
32   - }
33   -
34   - public void setCount(int count) {
35   - this.count = count;
36   - }
37   -
38   - public String getDetail() {
39   - return detail;
40   - }
41   -
42   - public void setDetail(String detail) {
43   - this.detail = detail;
44   - }
45   -
46   - public String getTurned() {
47   - return turned;
48   - }
49   -
50   - public void setTurned(String turned) {
51   - this.turned = turned;
52   - }
53   -
54   - public boolean isClose() {
55   - return close;
56   - }
57   -
58   - public void setClose(boolean close) {
59   - this.close = close;
60   - }
61   -
62   - public long getZt() {
63   - return zt;
64   - }
65   -
66   - public void setZt(long zt) {
67   - this.zt = zt;
68   - }
69   -
70   - public long getCt() {
71   - return ct;
72   - }
73   -
74   - public void setCt(long ct) {
75   - this.ct = ct;
76   - }
77   -
78   - public String getNbbm() {
79   - return nbbm;
80   - }
81   -
82   - public void setNbbm(String nbbm) {
83   - this.nbbm = nbbm;
84   - }
85   -
86   - public boolean isVague() {
87   - return vague;
88   - }
89   -
90   - public void setVague(boolean vague) {
91   - this.vague = vague;
92   - }
  1 +package com.bsth.data.gpsdata.arrival.entity;
  2 +
  3 +/** 路由反转
  4 + * Created by panzhao on 2016/12/28.
  5 + */
  6 +public class RouteReverse {
  7 +
  8 + private String nbbm;
  9 + //反转个数
  10 + private int count;
  11 +
  12 + //详细 1,2,3,2,1
  13 + private String detail;
  14 +
  15 + //掉头站点
  16 + private String turned;
  17 +
  18 + //掉头时间
  19 + private long zt;
  20 +
  21 + //检测时间
  22 + private long ct;
  23 +
  24 + //是否闭合
  25 + private boolean close;
  26 +
  27 + //信号不明确
  28 + private boolean vague;
  29 +
  30 + public int getCount() {
  31 + return count;
  32 + }
  33 +
  34 + public void setCount(int count) {
  35 + this.count = count;
  36 + }
  37 +
  38 + public String getDetail() {
  39 + return detail;
  40 + }
  41 +
  42 + public void setDetail(String detail) {
  43 + this.detail = detail;
  44 + }
  45 +
  46 + public String getTurned() {
  47 + return turned;
  48 + }
  49 +
  50 + public void setTurned(String turned) {
  51 + this.turned = turned;
  52 + }
  53 +
  54 + public boolean isClose() {
  55 + return close;
  56 + }
  57 +
  58 + public void setClose(boolean close) {
  59 + this.close = close;
  60 + }
  61 +
  62 + public long getZt() {
  63 + return zt;
  64 + }
  65 +
  66 + public void setZt(long zt) {
  67 + this.zt = zt;
  68 + }
  69 +
  70 + public long getCt() {
  71 + return ct;
  72 + }
  73 +
  74 + public void setCt(long ct) {
  75 + this.ct = ct;
  76 + }
  77 +
  78 + public String getNbbm() {
  79 + return nbbm;
  80 + }
  81 +
  82 + public void setNbbm(String nbbm) {
  83 + this.nbbm = nbbm;
  84 + }
  85 +
  86 + public boolean isVague() {
  87 + return vague;
  88 + }
  89 +
  90 + public void setVague(boolean vague) {
  91 + this.vague = vague;
  92 + }
93 93 }
94 94 \ No newline at end of file
... ...
src/main/java/com/bsth/data/gpsdata/arrival/entity/SignalAbnormal.java
1   -package com.bsth.data.gpsdata.arrival.entity;
2   -
3   -/**
4   - * 班次信号异常(漂移 或 断线)
5   - * Created by panzhao on 2016/12/31.
6   - */
7   -public class SignalAbnormal {
8   -
9   - private Long et;
10   -
11   - /** drift or reconnection */
12   - private String abnormalType;
13   -
14   - private Long st;
15   -
16   - private String nearPoint;
17   -
18   - private String destCode;
19   -
20   - private Long ct;
21   -
22   - //0: 发车 1:到站
23   - private int outOrIn;
24   -
25   - public Long getEt() {
26   - return et;
27   - }
28   -
29   - public void setEt(Long et) {
30   - this.et = et;
31   - }
32   -
33   - public String getAbnormalType() {
34   - return abnormalType;
35   - }
36   -
37   - public void setAbnormalType(String abnormalType) {
38   - this.abnormalType = abnormalType;
39   - }
40   -
41   - public Long getSt() {
42   - return st;
43   - }
44   -
45   - public void setSt(Long st) {
46   - this.st = st;
47   - }
48   -
49   - public String getNearPoint() {
50   - return nearPoint;
51   - }
52   -
53   - public void setNearPoint(String nearPoint) {
54   - this.nearPoint = nearPoint;
55   - }
56   -
57   - public Long getCt() {
58   - return ct;
59   - }
60   -
61   - public void setCt(Long ct) {
62   - this.ct = ct;
63   - }
64   -
65   - public int getOutOrIn() {
66   - return outOrIn;
67   - }
68   -
69   - public void setOutOrIn(int outOrIn) {
70   - this.outOrIn = outOrIn;
71   - }
72   -
73   - public String getDestCode() {
74   - return destCode;
75   - }
76   -
77   - public void setDestCode(String destCode) {
78   - this.destCode = destCode;
79   - }
80   -}
  1 +package com.bsth.data.gpsdata.arrival.entity;
  2 +
  3 +/**
  4 + * 班次信号异常(漂移 或 断线)
  5 + * Created by panzhao on 2016/12/31.
  6 + */
  7 +public class SignalAbnormal {
  8 +
  9 + private Long et;
  10 +
  11 + /** drift or reconnection */
  12 + private String abnormalType;
  13 +
  14 + private Long st;
  15 +
  16 + private String nearPoint;
  17 +
  18 + private String destCode;
  19 +
  20 + private Long ct;
  21 +
  22 + //0: 发车 1:到站
  23 + private int outOrIn;
  24 +
  25 + public Long getEt() {
  26 + return et;
  27 + }
  28 +
  29 + public void setEt(Long et) {
  30 + this.et = et;
  31 + }
  32 +
  33 + public String getAbnormalType() {
  34 + return abnormalType;
  35 + }
  36 +
  37 + public void setAbnormalType(String abnormalType) {
  38 + this.abnormalType = abnormalType;
  39 + }
  40 +
  41 + public Long getSt() {
  42 + return st;
  43 + }
  44 +
  45 + public void setSt(Long st) {
  46 + this.st = st;
  47 + }
  48 +
  49 + public String getNearPoint() {
  50 + return nearPoint;
  51 + }
  52 +
  53 + public void setNearPoint(String nearPoint) {
  54 + this.nearPoint = nearPoint;
  55 + }
  56 +
  57 + public Long getCt() {
  58 + return ct;
  59 + }
  60 +
  61 + public void setCt(Long ct) {
  62 + this.ct = ct;
  63 + }
  64 +
  65 + public int getOutOrIn() {
  66 + return outOrIn;
  67 + }
  68 +
  69 + public void setOutOrIn(int outOrIn) {
  70 + this.outOrIn = outOrIn;
  71 + }
  72 +
  73 + public String getDestCode() {
  74 + return destCode;
  75 + }
  76 +
  77 + public void setDestCode(String destCode) {
  78 + this.destCode = destCode;
  79 + }
  80 +}
... ...
src/main/java/com/bsth/data/gpsdata/arrival/entity/SignalState.java
1   -package com.bsth.data.gpsdata.arrival.entity;
2   -
3   -import com.bsth.data.BasicData;
4   -import com.bsth.entity.realcontrol.ScheduleRealInfo;
5   -import org.joda.time.format.DateTimeFormat;
6   -import org.joda.time.format.DateTimeFormatter;
7   -
8   -/**
9   - * 信号状态
10   - * Created by panzhao on 2016/12/30.
11   - */
12   -public class SignalState {
13   -
14   - private String type;
15   -
16   - private Long st;
17   -
18   - //private Long checkTime;
19   -
20   - private Long schId;
21   -
22   - private String lineCode;
23   -
24   - private String text;
25   -
26   - private RouteReverse reverse;
27   -
28   - private SignalAbnormal signalAbnormal;
29   -
30   - private static DateTimeFormatter fmtHHmm = DateTimeFormat.forPattern("HH:mm");
31   -
32   - /**
33   - * 记录区间调头
34   - *
35   - * @param sch
36   - * @param reverse
37   - * @return
38   - */
39   - public static SignalState reverseSignalSTate(ScheduleRealInfo sch, RouteReverse reverse) {
40   - if(reverse.isVague())
41   - return null;
42   -
43   - SignalState state = new SignalState();
44   - state.setSchId(sch.getId());
45   - state.setType("route_reverse");
46   - //state.setCheckTime(System.currentTimeMillis());
47   -
48   - String stationName = BasicData.stationCode2NameMap.get(sch.getXlBm() + "_" + sch.getXlDir() + "_" + reverse.getTurned());
49   - state.setText(fmtHHmm.print(reverse.getZt()) + " 从 " + stationName + " 站掉头");
50   - state.setSt(sch.getFcsjActualTime());
51   - state.setLineCode(sch.getXlBm());
52   - state.setReverse(reverse);
53   - return state;
54   - }
55   -
56   - public static SignalState abnormalSignalSTate(ScheduleRealInfo sch, SignalAbnormal signalAbnormal) {
57   - SignalState state = new SignalState();
58   - state.setSchId(sch.getId());
59   - state.setType("abnormal_signal");
60   - //state.setCheckTime(signalAbnormal.getCt());
61   - state.setLineCode(sch.getXlBm());
62   -
63   - String text = (fmtHHmm.print(signalAbnormal.getSt()) + " ~ " + fmtHHmm.print(signalAbnormal.getEt()));
64   - String abnormType = signalAbnormal.getAbnormalType();
65   - if (abnormType.equals("drift"))
66   - text += "(GPS无效)";
67   - else if (abnormType.equals("reconnection"))
68   - text += "(信号丢失)";
69   -
70   - state.setText(text);
71   - state.setSignalAbnormal(signalAbnormal);
72   - return state;
73   - }
74   -
75   - public String getType() {
76   - return type;
77   - }
78   -
79   - public void setType(String type) {
80   - this.type = type;
81   - }
82   -
83   - public long getSchId() {
84   - return schId;
85   - }
86   -
87   - public void setSchId(long schId) {
88   - this.schId = schId;
89   - }
90   -
91   - public String getLineCode() {
92   - return lineCode;
93   - }
94   -
95   - public void setLineCode(String lineCode) {
96   - this.lineCode = lineCode;
97   - }
98   -
99   - public Long getSt() {
100   - return st;
101   - }
102   -
103   - public void setSt(Long st) {
104   - this.st = st;
105   - }
106   -
107   - public String getText() {
108   - return text;
109   - }
110   -
111   - public void setText(String text) {
112   - this.text = text;
113   - }
114   -
115   - public RouteReverse getReverse() {
116   - return reverse;
117   - }
118   -
119   - public void setReverse(RouteReverse reverse) {
120   - this.reverse = reverse;
121   - }
122   -
123   - public SignalAbnormal getSignalAbnormal() {
124   - return signalAbnormal;
125   - }
126   -
127   - public void setSignalAbnormal(SignalAbnormal signalAbnormal) {
128   - this.signalAbnormal = signalAbnormal;
129   - }
130   -}
  1 +package com.bsth.data.gpsdata.arrival.entity;
  2 +
  3 +import com.bsth.data.BasicData;
  4 +import com.bsth.entity.realcontrol.ScheduleRealInfo;
  5 +import org.joda.time.format.DateTimeFormat;
  6 +import org.joda.time.format.DateTimeFormatter;
  7 +
  8 +/**
  9 + * 信号状态
  10 + * Created by panzhao on 2016/12/30.
  11 + */
  12 +public class SignalState {
  13 +
  14 + private String type;
  15 +
  16 + private Long st;
  17 +
  18 + //private Long checkTime;
  19 +
  20 + private Long schId;
  21 +
  22 + private String lineCode;
  23 +
  24 + private String text;
  25 +
  26 + private RouteReverse reverse;
  27 +
  28 + private SignalAbnormal signalAbnormal;
  29 +
  30 + private static DateTimeFormatter fmtHHmm = DateTimeFormat.forPattern("HH:mm");
  31 +
  32 + /**
  33 + * 记录区间调头
  34 + *
  35 + * @param sch
  36 + * @param reverse
  37 + * @return
  38 + */
  39 + public static SignalState reverseSignalSTate(ScheduleRealInfo sch, RouteReverse reverse) {
  40 + if(reverse.isVague())
  41 + return null;
  42 +
  43 + SignalState state = new SignalState();
  44 + state.setSchId(sch.getId());
  45 + state.setType("route_reverse");
  46 + //state.setCheckTime(System.currentTimeMillis());
  47 +
  48 + String stationName = BasicData.stationCode2NameMap.get(sch.getXlBm() + "_" + sch.getXlDir() + "_" + reverse.getTurned());
  49 + state.setText(fmtHHmm.print(reverse.getZt()) + " 从 " + stationName + " 站掉头");
  50 + state.setSt(sch.getFcsjActualTime());
  51 + state.setLineCode(sch.getXlBm());
  52 + state.setReverse(reverse);
  53 + return state;
  54 + }
  55 +
  56 + public static SignalState abnormalSignalSTate(ScheduleRealInfo sch, SignalAbnormal signalAbnormal) {
  57 + SignalState state = new SignalState();
  58 + state.setSchId(sch.getId());
  59 + state.setType("abnormal_signal");
  60 + //state.setCheckTime(signalAbnormal.getCt());
  61 + state.setLineCode(sch.getXlBm());
  62 +
  63 + String text = (fmtHHmm.print(signalAbnormal.getSt()) + " ~ " + fmtHHmm.print(signalAbnormal.getEt()));
  64 + String abnormType = signalAbnormal.getAbnormalType();
  65 + if (abnormType.equals("drift"))
  66 + text += "(GPS无效)";
  67 + else if (abnormType.equals("reconnection"))
  68 + text += "(信号丢失)";
  69 +
  70 + state.setText(text);
  71 + state.setSignalAbnormal(signalAbnormal);
  72 + return state;
  73 + }
  74 +
  75 + public String getType() {
  76 + return type;
  77 + }
  78 +
  79 + public void setType(String type) {
  80 + this.type = type;
  81 + }
  82 +
  83 + public long getSchId() {
  84 + return schId;
  85 + }
  86 +
  87 + public void setSchId(long schId) {
  88 + this.schId = schId;
  89 + }
  90 +
  91 + public String getLineCode() {
  92 + return lineCode;
  93 + }
  94 +
  95 + public void setLineCode(String lineCode) {
  96 + this.lineCode = lineCode;
  97 + }
  98 +
  99 + public Long getSt() {
  100 + return st;
  101 + }
  102 +
  103 + public void setSt(Long st) {
  104 + this.st = st;
  105 + }
  106 +
  107 + public String getText() {
  108 + return text;
  109 + }
  110 +
  111 + public void setText(String text) {
  112 + this.text = text;
  113 + }
  114 +
  115 + public RouteReverse getReverse() {
  116 + return reverse;
  117 + }
  118 +
  119 + public void setReverse(RouteReverse reverse) {
  120 + this.reverse = reverse;
  121 + }
  122 +
  123 + public SignalAbnormal getSignalAbnormal() {
  124 + return signalAbnormal;
  125 + }
  126 +
  127 + public void setSignalAbnormal(SignalAbnormal signalAbnormal) {
  128 + this.signalAbnormal = signalAbnormal;
  129 + }
  130 +}
... ...
src/main/java/com/bsth/data/gpsdata/arrival/handlers/InOutStationSignalHandle.java
... ... @@ -181,7 +181,7 @@ public class InOutStationSignalHandle extends SignalHandle{
181 181 //持久化
182 182 dayOfSchedule.save(sch);
183 183 //下发调度指令
184   - directiveService.send60Dispatch(next, doneSum, "到站@系统");
  184 + //directiveService.send60Dispatch(next, doneSum, "到站@系统");
185 185  
186 186 //准备执行下一个班次
187 187 if (next != null) {
... ... @@ -246,4 +246,4 @@ public class InOutStationSignalHandle extends SignalHandle{
246 246 }*/
247 247 return false;
248 248 }
249 249 -}
  250 +}
250 251 \ No newline at end of file
... ...
src/main/java/com/bsth/data/gpsdata/arrival/handlers/OfflineSignalHandle.java
1   -package com.bsth.data.gpsdata.arrival.handlers;
2   -
3   -import com.bsth.data.gpsdata.GpsEntity;
4   -import com.bsth.data.gpsdata.arrival.GeoCacheData;
5   -import com.bsth.data.gpsdata.arrival.SignalHandle;
6   -import com.bsth.data.gpsdata.arrival.utils.CircleQueue;
7   -import org.springframework.stereotype.Component;
8   -
9   -/**
10   - * 信号断线重连处理
11   - * Created by panzhao on 2016/12/27.
12   - */
13   -@Component
14   -public class OfflineSignalHandle extends SignalHandle{
15   -
16   - //断开2分钟,标记为重连信号
17   - private final static int OFFLINE_TIME = 1000 * 60 * 2;
18   -
19   - //断开70分钟,之前的信号不再有参考价值
20   - private final static int CLEAR_TIME = 1000 * 60 * 70;
21   -
22   - @Override
23   - public boolean handle(GpsEntity gps, CircleQueue<GpsEntity> prevs) {
24   - //漂移信号不管
25   - if(isDriftSignal(gps)){
26   - gps.setSignalState("drift");
27   - return true;
28   - }
29   -
30   - if(isNotEmpty(prevs)){
31   - GpsEntity prev = prevs.getTail();
32   - int space = (int) (gps.getTimestamp() - prev.getTimestamp());
33   - if(space > OFFLINE_TIME)
34   - gps.setSignalState("reconnection");
35   -
36   - if(space > CLEAR_TIME){
37   - //清理缓存的信号
38   - GeoCacheData.clear(gps.getNbbm());
39   - }
40   - }
41   - return true;
42   - }
  1 +package com.bsth.data.gpsdata.arrival.handlers;
  2 +
  3 +import com.bsth.data.gpsdata.GpsEntity;
  4 +import com.bsth.data.gpsdata.arrival.GeoCacheData;
  5 +import com.bsth.data.gpsdata.arrival.SignalHandle;
  6 +import com.bsth.data.gpsdata.arrival.utils.CircleQueue;
  7 +import org.springframework.stereotype.Component;
  8 +
  9 +/**
  10 + * 信号断线重连处理
  11 + * Created by panzhao on 2016/12/27.
  12 + */
  13 +@Component
  14 +public class OfflineSignalHandle extends SignalHandle{
  15 +
  16 + //断开2分钟,标记为重连信号
  17 + private final static int OFFLINE_TIME = 1000 * 60 * 2;
  18 +
  19 + //断开70分钟,之前的信号不再有参考价值
  20 + private final static int CLEAR_TIME = 1000 * 60 * 70;
  21 +
  22 + @Override
  23 + public boolean handle(GpsEntity gps, CircleQueue<GpsEntity> prevs) {
  24 + //漂移信号不管
  25 + if(isDriftSignal(gps)){
  26 + gps.setSignalState("drift");
  27 + return true;
  28 + }
  29 +
  30 + if(isNotEmpty(prevs)){
  31 + GpsEntity prev = prevs.getTail();
  32 + int space = (int) (gps.getTimestamp() - prev.getTimestamp());
  33 + if(space > OFFLINE_TIME)
  34 + gps.setSignalState("reconnection");
  35 +
  36 + if(space > CLEAR_TIME){
  37 + //清理缓存的信号
  38 + GeoCacheData.clear(gps.getNbbm());
  39 + }
  40 + }
  41 + return true;
  42 + }
43 43 }
44 44 \ No newline at end of file
... ...
src/main/java/com/bsth/data/gpsdata/arrival/handlers/ReverseSignalHandle.java
1   -package com.bsth.data.gpsdata.arrival.handlers;
2   -
3   -import com.bsth.data.gpsdata.GpsEntity;
4   -import com.bsth.data.gpsdata.arrival.GeoCacheData;
5   -import com.bsth.data.gpsdata.arrival.SignalHandle;
6   -import com.bsth.data.gpsdata.arrival.entity.RouteReverse;
7   -import com.bsth.data.gpsdata.arrival.entity.StationRoute;
8   -import com.bsth.data.gpsdata.arrival.utils.CircleQueue;
9   -import com.bsth.data.gpsdata.arrival.utils.ScheduleSignalState;
10   -import com.bsth.data.schedule.DayOfSchedule;
11   -import org.slf4j.Logger;
12   -import org.slf4j.LoggerFactory;
13   -import org.springframework.beans.factory.annotation.Autowired;
14   -import org.springframework.stereotype.Component;
15   -
16   -/**
17   - * 路由反向信号处理
18   - * Created by panzhao on 2016/12/28.
19   - */
20   -@Component
21   -public class ReverseSignalHandle extends SignalHandle {
22   -
23   - Logger logger = LoggerFactory.getLogger(this.getClass());
24   -
25   - @Autowired
26   - DayOfSchedule dayOfSchedule;
27   -
28   - @Autowired
29   - ScheduleSignalState scheduleSignalState;
30   -
31   - @Override
32   - public boolean handle(GpsEntity gps, CircleQueue<GpsEntity> prevs) {
33   - if (!isNotEmpty(prevs))
34   - return false;
35   -
36   - GpsEntity prev = prevs.getTail();
37   -
38   - if (isReverse(gps, prev)) {
39   - RouteReverse reverse = reverseSearch(prevs, gps);
40   -
41   - if (reverse.getCount() >= 4
42   - && reverse.isClose()
43   - && !GeoCacheData.isEndStation(gps.getLineId(), gps.getUpDown(), reverse.getTurned())) {
44   - scheduleSignalState.reverseAnalyse(reverse);
45   - }
46   - }
47   - return false;
48   - }
49   -
50   - /**
51   - * 搜索路由反向详细
52   - *
53   - * @param prevs
54   - * @param gps
55   - * @return
56   - */
57   - public RouteReverse reverseSearch(CircleQueue<GpsEntity> prevs, GpsEntity gps) {
58   - RouteReverse routeReverse = new RouteReverse();
59   - int count = 0;
60   - String path = "";
61   - long zt = 0L;
62   - boolean half = false;
63   -
64   - //当前站点
65   - StationRoute curr = GeoCacheData.getRouteCode(gps), sr;
66   - GpsEntity prev;
67   - Object[] array = prevs.getQueue();
68   - for (int i = array.length - 1; i > 0; i--) {
69   - prev = (GpsEntity) array[i];
70   -
71   - if (!prev.getUpDown().equals(gps.getUpDown())
72   - || prev.getSignalState().equals("reconnection"))
73   - break;
74   -
75   - if (prev.getInstation() == 1) {
76   - sr = GeoCacheData.getRouteCode(prev);
77   -
78   - if (sr.getRouteSort() > curr.getRouteSort()) {
79   - if(half){
80   - routeReverse.setVague(true);
81   - }
82   -
83   - path += (curr.getCode() + ",");
84   - count++;
85   - zt = prev.getTimestamp();
86   - } else if (sr.getRouteSort() < curr.getRouteSort()) {
87   - if (routeReverse.getTurned() == null) {
88   - routeReverse.setTurned(curr.getCode());
89   - half = true;
90   - }
91   -
92   - path += (curr.getCode() + ",");
93   - //掉头前当前站
94   - if (sr.getCode().equals(gps.getStopNo())) {
95   - routeReverse.setClose(true);
96   - path += sr.getCode();
97   - break;
98   - }
99   - }
100   -
101   - curr = sr;
102   - }
103   - }
104   -
105   - routeReverse.setZt(zt);
106   - routeReverse.setCount(count);
107   - routeReverse.setDetail(path);
108   - routeReverse.setCt(gps.getTimestamp());
109   - routeReverse.setNbbm(gps.getNbbm());
110   - return routeReverse;
111   - }
112   -
113   - /**
114   - * 是否反向
115   - *
116   - * @param gps
117   - * @param prev
118   - * @return
119   - */
120   - public boolean isReverse(GpsEntity gps, GpsEntity prev) {
121   - if (gps.getInstation() == 1
122   - &&
123   - gps.getUpDown().equals(prev.getUpDown())
124   - && !gps.getStopNo().equals(prev.getStopNo())) {
125   -
126   - StationRoute currStation = GeoCacheData.getRouteCode(gps);
127   - StationRoute prevStation = GeoCacheData.getRouteCode(prev);
128   -
129   - if (currStation == null || prevStation == null)
130   - return false;
131   -
132   - if (currStation.getRouteSort() < prevStation.getRouteSort())
133   - return true;
134   - }
135   - return false;
136   - }
  1 +package com.bsth.data.gpsdata.arrival.handlers;
  2 +
  3 +import com.bsth.data.gpsdata.GpsEntity;
  4 +import com.bsth.data.gpsdata.arrival.GeoCacheData;
  5 +import com.bsth.data.gpsdata.arrival.SignalHandle;
  6 +import com.bsth.data.gpsdata.arrival.entity.RouteReverse;
  7 +import com.bsth.data.gpsdata.arrival.entity.StationRoute;
  8 +import com.bsth.data.gpsdata.arrival.utils.CircleQueue;
  9 +import com.bsth.data.gpsdata.arrival.utils.ScheduleSignalState;
  10 +import com.bsth.data.schedule.DayOfSchedule;
  11 +import org.slf4j.Logger;
  12 +import org.slf4j.LoggerFactory;
  13 +import org.springframework.beans.factory.annotation.Autowired;
  14 +import org.springframework.stereotype.Component;
  15 +
  16 +/**
  17 + * 路由反向信号处理
  18 + * Created by panzhao on 2016/12/28.
  19 + */
  20 +@Component
  21 +public class ReverseSignalHandle extends SignalHandle {
  22 +
  23 + Logger logger = LoggerFactory.getLogger(this.getClass());
  24 +
  25 + @Autowired
  26 + DayOfSchedule dayOfSchedule;
  27 +
  28 + @Autowired
  29 + ScheduleSignalState scheduleSignalState;
  30 +
  31 + @Override
  32 + public boolean handle(GpsEntity gps, CircleQueue<GpsEntity> prevs) {
  33 + if (!isNotEmpty(prevs))
  34 + return false;
  35 +
  36 + GpsEntity prev = prevs.getTail();
  37 +
  38 + if (isReverse(gps, prev)) {
  39 + RouteReverse reverse = reverseSearch(prevs, gps);
  40 +
  41 + if (reverse.getCount() >= 4
  42 + && reverse.isClose()
  43 + && !GeoCacheData.isEndStation(gps.getLineId(), gps.getUpDown(), reverse.getTurned())) {
  44 + scheduleSignalState.reverseAnalyse(reverse);
  45 + }
  46 + }
  47 + return false;
  48 + }
  49 +
  50 + /**
  51 + * 搜索路由反向详细
  52 + *
  53 + * @param prevs
  54 + * @param gps
  55 + * @return
  56 + */
  57 + public RouteReverse reverseSearch(CircleQueue<GpsEntity> prevs, GpsEntity gps) {
  58 + RouteReverse routeReverse = new RouteReverse();
  59 + int count = 0;
  60 + String path = "";
  61 + long zt = 0L;
  62 + boolean half = false;
  63 +
  64 + //当前站点
  65 + StationRoute curr = GeoCacheData.getRouteCode(gps), sr;
  66 + GpsEntity prev;
  67 + Object[] array = prevs.getQueue();
  68 + for (int i = array.length - 1; i > 0; i--) {
  69 + prev = (GpsEntity) array[i];
  70 +
  71 + if (!prev.getUpDown().equals(gps.getUpDown())
  72 + || prev.getSignalState().equals("reconnection"))
  73 + break;
  74 +
  75 + if (prev.getInstation() == 1) {
  76 + sr = GeoCacheData.getRouteCode(prev);
  77 +
  78 + if (sr.getRouteSort() > curr.getRouteSort()) {
  79 + if(half){
  80 + routeReverse.setVague(true);
  81 + }
  82 +
  83 + path += (curr.getCode() + ",");
  84 + count++;
  85 + zt = prev.getTimestamp();
  86 + } else if (sr.getRouteSort() < curr.getRouteSort()) {
  87 + if (routeReverse.getTurned() == null) {
  88 + routeReverse.setTurned(curr.getCode());
  89 + half = true;
  90 + }
  91 +
  92 + path += (curr.getCode() + ",");
  93 + //掉头前当前站
  94 + if (sr.getCode().equals(gps.getStopNo())) {
  95 + routeReverse.setClose(true);
  96 + path += sr.getCode();
  97 + break;
  98 + }
  99 + }
  100 +
  101 + curr = sr;
  102 + }
  103 + }
  104 +
  105 + routeReverse.setZt(zt);
  106 + routeReverse.setCount(count);
  107 + routeReverse.setDetail(path);
  108 + routeReverse.setCt(gps.getTimestamp());
  109 + routeReverse.setNbbm(gps.getNbbm());
  110 + return routeReverse;
  111 + }
  112 +
  113 + /**
  114 + * 是否反向
  115 + *
  116 + * @param gps
  117 + * @param prev
  118 + * @return
  119 + */
  120 + public boolean isReverse(GpsEntity gps, GpsEntity prev) {
  121 + if (gps.getInstation() == 1
  122 + &&
  123 + gps.getUpDown().equals(prev.getUpDown())
  124 + && !gps.getStopNo().equals(prev.getStopNo())) {
  125 +
  126 + StationRoute currStation = GeoCacheData.getRouteCode(gps);
  127 + StationRoute prevStation = GeoCacheData.getRouteCode(prev);
  128 +
  129 + if (currStation == null || prevStation == null)
  130 + return false;
  131 +
  132 + if (currStation.getRouteSort() < prevStation.getRouteSort())
  133 + return true;
  134 + }
  135 + return false;
  136 + }
137 137 }
138 138 \ No newline at end of file
... ...
src/main/java/com/bsth/data/gpsdata/arrival/utils/ScheduleSignalState.java
... ... @@ -100,7 +100,8 @@ public class ScheduleSignalState {
100 100  
101 101 //记录信号状态
102 102 SignalState signalState = SignalState.reverseSignalSTate(sch, reverse);
103   - signalStateData.put(signalState);
  103 + if(signalState != null)
  104 + signalStateData.put(signalState);
104 105 }
105 106 }
106 107  
... ... @@ -248,4 +249,4 @@ public class ScheduleSignalState {
248 249 SignalState signalState = SignalState.abnormalSignalSTate(sch, signalAbnormal);
249 250 signalStateData.put(signalState);
250 251 }
251 252 -}
  253 +}
252 254 \ No newline at end of file
... ...
src/main/java/com/bsth/data/gpsdata/arrival/utils/SignalSchPlanMatcher.java
1   -package com.bsth.data.gpsdata.arrival.utils;
2   -
3   -import com.bsth.data.gpsdata.GpsEntity;
4   -import com.bsth.data.schedule.DayOfSchedule;
5   -import com.bsth.entity.realcontrol.ScheduleRealInfo;
6   -import org.springframework.beans.factory.annotation.Autowired;
7   -import org.springframework.stereotype.Component;
8   -
9   -/**
10   - * 班次匹配器
11   - * Created by panzhao on 2016/12/31.
12   - */
13   -@Component
14   -public class SignalSchPlanMatcher {
15   -
16   - @Autowired
17   - DayOfSchedule dayOfSchedule;
18   -
19   - /**
20   - * 发车信号匹配
21   - * @param outSigal
22   - * @param sch
23   - * @return
24   - */
25   - public void outMatch(GpsEntity outSigal, ScheduleRealInfo sch){
26   - long t = outSigal.getTimestamp();
27   - if(t < sch.getDfsjT())
28   - return;
29   -
30   - //下一个相同走向的班次
31   - ScheduleRealInfo next = dayOfSchedule.nextSame(sch);
32   - if(next == null || !next.getQdzCode().equals(sch.getQdzCode()))
33   - return;
34   -
35   - //晚于班次间隔百分之70,跳下一个班次
36   - double s = (int) (next.getDfsjT() - sch.getDfsjT());
37   - double r = (int) (t - sch.getDfsjT());
38   - if(r / s > 0.7){
39   - dayOfSchedule.addExecPlan(next);
40   - outMatch(outSigal, next);
41   - }
42   - }
43   -}
  1 +package com.bsth.data.gpsdata.arrival.utils;
  2 +
  3 +import com.bsth.data.gpsdata.GpsEntity;
  4 +import com.bsth.data.schedule.DayOfSchedule;
  5 +import com.bsth.entity.realcontrol.ScheduleRealInfo;
  6 +import org.springframework.beans.factory.annotation.Autowired;
  7 +import org.springframework.stereotype.Component;
  8 +
  9 +/**
  10 + * 班次匹配器
  11 + * Created by panzhao on 2016/12/31.
  12 + */
  13 +@Component
  14 +public class SignalSchPlanMatcher {
  15 +
  16 + @Autowired
  17 + DayOfSchedule dayOfSchedule;
  18 +
  19 + /**
  20 + * 发车信号匹配
  21 + * @param outSigal
  22 + * @param sch
  23 + * @return
  24 + */
  25 + public void outMatch(GpsEntity outSigal, ScheduleRealInfo sch){
  26 + long t = outSigal.getTimestamp();
  27 + if(t < sch.getDfsjT())
  28 + return;
  29 +
  30 + //下一个相同走向的班次
  31 + ScheduleRealInfo next = dayOfSchedule.nextSame(sch);
  32 + if(next == null || !next.getQdzCode().equals(sch.getQdzCode()))
  33 + return;
  34 +
  35 + //晚于班次间隔百分之70,跳下一个班次
  36 + double s = (int) (next.getDfsjT() - sch.getDfsjT());
  37 + double r = (int) (t - sch.getDfsjT());
  38 + if(r / s > 0.7){
  39 + dayOfSchedule.addExecPlan(next);
  40 + outMatch(outSigal, next);
  41 + }
  42 + }
  43 +}
... ...
src/main/java/com/bsth/data/gpsdata/recovery/GpsDataRecovery.java
1   -package com.bsth.data.gpsdata.recovery;
2   -
3   -import com.bsth.data.BasicData;
4   -import com.bsth.data.gpsdata.GpsEntity;
5   -import com.bsth.data.gpsdata.arrival.GeoCacheData;
6   -import com.bsth.data.gpsdata.arrival.handlers.*;
7   -import com.bsth.data.gpsdata.arrival.utils.CircleQueue;
8   -import com.bsth.util.db.DBUtils_MS;
9   -import com.google.common.collect.ArrayListMultimap;
10   -import org.slf4j.Logger;
11   -import org.slf4j.LoggerFactory;
12   -import org.springframework.beans.BeansException;
13   -import org.springframework.context.ApplicationContext;
14   -import org.springframework.context.ApplicationContextAware;
15   -import org.springframework.jdbc.core.JdbcTemplate;
16   -import org.springframework.jdbc.core.RowMapper;
17   -import org.springframework.stereotype.Component;
18   -
19   -import java.sql.ResultSet;
20   -import java.sql.SQLException;
21   -import java.util.*;
22   -import java.util.concurrent.CountDownLatch;
23   -import java.util.concurrent.ExecutorService;
24   -import java.util.concurrent.Executors;
25   -
26   -/**
27   - * gps数据恢复
28   - * Created by panzhao on 2016/12/24.
29   - */
30   -@Component
31   -public class GpsDataRecovery implements ApplicationContextAware {
32   -
33   - static Logger logger = LoggerFactory.getLogger(GpsDataRecovery.class);
34   -
35   - public static boolean run;
36   -
37   - static ExecutorService threadPool = Executors.newFixedThreadPool(10);
38   -
39   - static OfflineSignalHandle offlineSignalHandle;
40   - static CorrectSignalHandle correctSignalHandle;
41   - static StationInsideHandle stationInsideHandle;
42   - static InOutStationSignalHandle inOutStationSignalHandle;
43   - static ReverseSignalHandle reverseSignalHandle;
44   -
45   - public void recovery() {
46   - List<GpsEntity> list = loadData();
47   -
48   - //按车辆分组数据
49   - ArrayListMultimap<String, GpsEntity> listMap = ArrayListMultimap.create();
50   - for (GpsEntity gps : list) {
51   - if (gps.getNbbm() != null)
52   - listMap.put(gps.getNbbm(), gps);
53   - }
54   -
55   -
56   - Set<String> keys = listMap.keySet();
57   -
58   - CountDownLatch count = new CountDownLatch(keys.size());
59   - GpsComp comp = new GpsComp();
60   - for (String nbbm : keys) {
61   - Collections.sort(listMap.get(nbbm), comp);
62   - threadPool.execute(new RecoveryThread(listMap.get(nbbm), count));
63   - /*if(nbbm.equals("YT-CD008"))
64   - new RecoveryThread(listMap.get(nbbm), count).run();*/
65   - }
66   -
67   - try {
68   - count.await();
69   - run = false;
70   - logger.info("数据恢复完成....");
71   - } catch (InterruptedException e) {
72   - logger.error("", e);
73   - }
74   - }
75   -
76   - /**
77   - * 加载当天的gps数据
78   - *
79   - * @return
80   - */
81   - public List<GpsEntity> loadData() {
82   - Calendar calendar = Calendar.getInstance();
83   - int dayOfYear = calendar.get(Calendar.DAY_OF_YEAR);
84   -
85   - String sql = "select DEVICE_ID,LAT,LON,TS,SPEED_GPS,LINE_ID,SERVICE_STATE from bsth_c_gps_info where days_year=" + dayOfYear;
86   - JdbcTemplate jdbcTemplate = new JdbcTemplate(DBUtils_MS.getDataSource());
87   -
88   - List<GpsEntity> list =
89   - jdbcTemplate.query(sql, new RowMapper<GpsEntity>() {
90   - @Override
91   - public GpsEntity mapRow(ResultSet rs, int rowNum) throws SQLException {
92   - GpsEntity gps = new GpsEntity();
93   -
94   - gps.setDeviceId(rs.getString("DEVICE_ID"));
95   - gps.setNbbm(BasicData.deviceId2NbbmMap.get(gps.getDeviceId()));
96   - gps.setSpeed(rs.getFloat("SPEED_GPS"));
97   - gps.setLat(rs.getFloat("LAT"));
98   - gps.setLon(rs.getFloat("LON"));
99   - gps.setLineId(rs.getString("LINE_ID"));
100   - gps.setTimestamp(rs.getLong("TS"));
101   - gps.setUpDown(getUpOrDown(rs.getLong("SERVICE_STATE")));
102   - return gps;
103   - }
104   - });
105   - return list;
106   - }
107   -
108   - /**
109   - * 王通 2016/6/29 9:23:24 获取车辆线路上下行
110   - *
111   - * @return -1无效 0上行 1下行
112   - */
113   - public static int getUpOrDown(long serviceState) {
114   - if ((serviceState & 0x00020000) == 0x00020000 || (serviceState & 0x80000000) == 0x80000000
115   - || (serviceState & 0x01000000) == 0x01000000 || (serviceState & 0x08000000) == 0x08000000)
116   - return -1;
117   - return (((serviceState & 0x10000000) == 0x10000000) ? 1 : 0);
118   - }
119   -
120   - @Override
121   - public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
122   - offlineSignalHandle = applicationContext.getBean(OfflineSignalHandle.class);
123   - correctSignalHandle = applicationContext.getBean(CorrectSignalHandle.class);
124   - stationInsideHandle = applicationContext.getBean(StationInsideHandle.class);
125   - inOutStationSignalHandle = applicationContext.getBean(InOutStationSignalHandle.class);
126   - reverseSignalHandle = applicationContext.getBean(ReverseSignalHandle.class);
127   - }
128   -
129   - public static class GpsComp implements Comparator<GpsEntity> {
130   -
131   - @Override
132   - public int compare(GpsEntity g1, GpsEntity g2) {
133   - return g1.getTimestamp().compareTo(g2.getTimestamp());
134   - }
135   - }
136   -
137   - public static class RecoveryThread implements Runnable {
138   - List<GpsEntity> list;
139   - CountDownLatch count;
140   -
141   - RecoveryThread(List<GpsEntity> list, CountDownLatch count) {
142   - this.list = list;
143   - this.count = count;
144   - }
145   -
146   - @Override
147   - public void run() {
148   - try {
149   - //循环gps恢复数据
150   - CircleQueue<GpsEntity> prevs;
151   -
152   - for (GpsEntity gps : list) {
153   -
154   - prevs = GeoCacheData.getGps(gps.getNbbm());
155   - //掉线处理
156   - offlineSignalHandle.handle(gps, prevs);
157   - //状态处理
158   - if (!correctSignalHandle.handle(gps, prevs))
159   - continue;
160   - //场,站内外判断
161   - stationInsideHandle.handle(gps, prevs);
162   - //反向处理
163   - reverseSignalHandle.handle(gps, prevs);
164   - //进出站动作处理
165   - inOutStationSignalHandle.handle(gps, prevs);
166   - GeoCacheData.putGps(gps);
167   -
168   - //Thread.sleep(50);
169   - }
170   - } catch (Exception e) {
171   - logger.error("", e);
172   - } finally {
173   - count.countDown();
174   - }
175   - }
176   - }
  1 +package com.bsth.data.gpsdata.recovery;
  2 +
  3 +import com.bsth.data.BasicData;
  4 +import com.bsth.data.gpsdata.GpsEntity;
  5 +import com.bsth.data.gpsdata.arrival.GeoCacheData;
  6 +import com.bsth.data.gpsdata.arrival.handlers.*;
  7 +import com.bsth.data.gpsdata.arrival.utils.CircleQueue;
  8 +import com.bsth.util.db.DBUtils_MS;
  9 +import com.google.common.collect.ArrayListMultimap;
  10 +import org.slf4j.Logger;
  11 +import org.slf4j.LoggerFactory;
  12 +import org.springframework.beans.BeansException;
  13 +import org.springframework.context.ApplicationContext;
  14 +import org.springframework.context.ApplicationContextAware;
  15 +import org.springframework.jdbc.core.JdbcTemplate;
  16 +import org.springframework.jdbc.core.RowMapper;
  17 +import org.springframework.stereotype.Component;
  18 +
  19 +import java.sql.ResultSet;
  20 +import java.sql.SQLException;
  21 +import java.util.*;
  22 +import java.util.concurrent.CountDownLatch;
  23 +import java.util.concurrent.ExecutorService;
  24 +import java.util.concurrent.Executors;
  25 +
  26 +/**
  27 + * gps数据恢复
  28 + * Created by panzhao on 2016/12/24.
  29 + */
  30 +@Component
  31 +public class GpsDataRecovery implements ApplicationContextAware {
  32 +
  33 + static Logger logger = LoggerFactory.getLogger(GpsDataRecovery.class);
  34 +
  35 + public static boolean run;
  36 +
  37 + static ExecutorService threadPool = Executors.newFixedThreadPool(10);
  38 +
  39 + static OfflineSignalHandle offlineSignalHandle;
  40 + static CorrectSignalHandle correctSignalHandle;
  41 + static StationInsideHandle stationInsideHandle;
  42 + static InOutStationSignalHandle inOutStationSignalHandle;
  43 + static ReverseSignalHandle reverseSignalHandle;
  44 +
  45 + public void recovery() {
  46 + List<GpsEntity> list = loadData();
  47 +
  48 + //按车辆分组数据
  49 + ArrayListMultimap<String, GpsEntity> listMap = ArrayListMultimap.create();
  50 + for (GpsEntity gps : list) {
  51 + if (gps.getNbbm() != null)
  52 + listMap.put(gps.getNbbm(), gps);
  53 + }
  54 +
  55 +
  56 + Set<String> keys = listMap.keySet();
  57 +
  58 + CountDownLatch count = new CountDownLatch(keys.size());
  59 + GpsComp comp = new GpsComp();
  60 + for (String nbbm : keys) {
  61 + Collections.sort(listMap.get(nbbm), comp);
  62 + threadPool.execute(new RecoveryThread(listMap.get(nbbm), count));
  63 + /*if(nbbm.equals("YT-CD008"))
  64 + new RecoveryThread(listMap.get(nbbm), count).run();*/
  65 + }
  66 +
  67 + try {
  68 + count.await();
  69 + run = false;
  70 + logger.info("数据恢复完成....");
  71 + } catch (InterruptedException e) {
  72 + logger.error("", e);
  73 + }
  74 + }
  75 +
  76 + /**
  77 + * 加载当天的gps数据
  78 + *
  79 + * @return
  80 + */
  81 + public List<GpsEntity> loadData() {
  82 + Calendar calendar = Calendar.getInstance();
  83 + int dayOfYear = calendar.get(Calendar.DAY_OF_YEAR);
  84 +
  85 + String sql = "select DEVICE_ID,LAT,LON,TS,SPEED_GPS,LINE_ID,SERVICE_STATE from bsth_c_gps_info where days_year=" + dayOfYear;
  86 + JdbcTemplate jdbcTemplate = new JdbcTemplate(DBUtils_MS.getDataSource());
  87 +
  88 + List<GpsEntity> list =
  89 + jdbcTemplate.query(sql, new RowMapper<GpsEntity>() {
  90 + @Override
  91 + public GpsEntity mapRow(ResultSet rs, int rowNum) throws SQLException {
  92 + GpsEntity gps = new GpsEntity();
  93 +
  94 + gps.setDeviceId(rs.getString("DEVICE_ID"));
  95 + gps.setNbbm(BasicData.deviceId2NbbmMap.get(gps.getDeviceId()));
  96 + gps.setSpeed(rs.getFloat("SPEED_GPS"));
  97 + gps.setLat(rs.getFloat("LAT"));
  98 + gps.setLon(rs.getFloat("LON"));
  99 + gps.setLineId(rs.getString("LINE_ID"));
  100 + gps.setTimestamp(rs.getLong("TS"));
  101 + gps.setUpDown(getUpOrDown(rs.getLong("SERVICE_STATE")));
  102 + return gps;
  103 + }
  104 + });
  105 + return list;
  106 + }
  107 +
  108 + /**
  109 + * 王通 2016/6/29 9:23:24 获取车辆线路上下行
  110 + *
  111 + * @return -1无效 0上行 1下行
  112 + */
  113 + public static int getUpOrDown(long serviceState) {
  114 + if ((serviceState & 0x00020000) == 0x00020000 || (serviceState & 0x80000000) == 0x80000000
  115 + || (serviceState & 0x01000000) == 0x01000000 || (serviceState & 0x08000000) == 0x08000000)
  116 + return -1;
  117 + return (((serviceState & 0x10000000) == 0x10000000) ? 1 : 0);
  118 + }
  119 +
  120 + @Override
  121 + public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
  122 + offlineSignalHandle = applicationContext.getBean(OfflineSignalHandle.class);
  123 + correctSignalHandle = applicationContext.getBean(CorrectSignalHandle.class);
  124 + stationInsideHandle = applicationContext.getBean(StationInsideHandle.class);
  125 + inOutStationSignalHandle = applicationContext.getBean(InOutStationSignalHandle.class);
  126 + reverseSignalHandle = applicationContext.getBean(ReverseSignalHandle.class);
  127 + }
  128 +
  129 + public static class GpsComp implements Comparator<GpsEntity> {
  130 +
  131 + @Override
  132 + public int compare(GpsEntity g1, GpsEntity g2) {
  133 + return g1.getTimestamp().compareTo(g2.getTimestamp());
  134 + }
  135 + }
  136 +
  137 + public static class RecoveryThread implements Runnable {
  138 + List<GpsEntity> list;
  139 + CountDownLatch count;
  140 +
  141 + RecoveryThread(List<GpsEntity> list, CountDownLatch count) {
  142 + this.list = list;
  143 + this.count = count;
  144 + }
  145 +
  146 + @Override
  147 + public void run() {
  148 + try {
  149 + //循环gps恢复数据
  150 + CircleQueue<GpsEntity> prevs;
  151 +
  152 + for (GpsEntity gps : list) {
  153 +
  154 + prevs = GeoCacheData.getGps(gps.getNbbm());
  155 + //掉线处理
  156 + offlineSignalHandle.handle(gps, prevs);
  157 + //状态处理
  158 + if (!correctSignalHandle.handle(gps, prevs))
  159 + continue;
  160 + //场,站内外判断
  161 + stationInsideHandle.handle(gps, prevs);
  162 + //反向处理
  163 + reverseSignalHandle.handle(gps, prevs);
  164 + //进出站动作处理
  165 + inOutStationSignalHandle.handle(gps, prevs);
  166 + GeoCacheData.putGps(gps);
  167 +
  168 + //Thread.sleep(50);
  169 + }
  170 + } catch (Exception e) {
  171 + logger.error("", e);
  172 + } finally {
  173 + count.countDown();
  174 + }
  175 + }
  176 + }
177 177 }
178 178 \ No newline at end of file
... ...
src/main/java/com/bsth/data/schedule/DayOfSchedule.java
... ... @@ -2,6 +2,8 @@ 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;
5 7 import com.bsth.data.LineConfigData;
6 8 import com.bsth.data.directive.FirstScheduleCheckThread;
7 9 import com.bsth.data.gpsdata.GpsRealData;
... ... @@ -33,6 +35,7 @@ import org.springframework.stereotype.Component;
33 35 import java.text.ParseException;
34 36 import java.text.SimpleDateFormat;
35 37 import java.util.*;
  38 +import java.util.concurrent.TimeUnit;
36 39  
37 40 /**
38 41 * @author PanZhao
... ... @@ -82,6 +85,9 @@ public class DayOfSchedule implements CommandLineRunner {
82 85 @Autowired
83 86 GpsRealData gpsRealData;
84 87  
  88 + @Autowired
  89 + BasicData.BasicDataLoader basicDataLoader;
  90 +
85 91 /**
86 92 * 线路当前使用的排班的日期
87 93 */
... ... @@ -122,13 +128,14 @@ public class DayOfSchedule implements CommandLineRunner {
122 128  
123 129 @Override
124 130 public void run(String... arg0) throws Exception {
  131 + basicDataLoader.loadAllData();
125 132 //从数据库恢复排班
126   - //dataRecovery();
  133 + dataRecovery();
127 134  
128 135 //翻班线程
129   -// Application.mainServices.scheduleWithFixedDelay(scheduleRefreshThread, 15, 240, TimeUnit.SECONDS);
  136 + Application.mainServices.scheduleWithFixedDelay(scheduleRefreshThread, 15, 240, TimeUnit.SECONDS);
130 137 //入库
131   -// Application.mainServices.scheduleWithFixedDelay(schedulePstThread, 60, 60, TimeUnit.SECONDS);
  138 + Application.mainServices.scheduleWithFixedDelay(schedulePstThread, 60, 60, TimeUnit.SECONDS);
132 139 //首班出场指令补发器
133 140 // Application.mainServices.scheduleWithFixedDelay(firstScheduleCheckThread, 30, 240, TimeUnit.SECONDS);
134 141 //班次误点扫描
... ...
src/main/java/com/bsth/repository/realcontrol/ScheduleRealInfoRepository.java
... ... @@ -32,7 +32,7 @@ public interface ScheduleRealInfoRepository extends BaseRepository&lt;ScheduleRealI
32 32  
33 33 //把sum(addMileage) 替换为0 数据表去掉了 add_mileage 字段
34 34 @Query(value="select new map(clZbh as clZbh,jGh as jGh,jName as jName,sum(jhlc) as zgl,"
35   - + " 0 as ksgl,count(jName) as bcs) from ScheduleRealInfo s where"
  35 + + "0 as ksgl,count(jName) as bcs) from ScheduleRealInfo s where"
36 36 + " s.xlBm = ?1 and DATE_FORMAT(s.scheduleDate,'%Y-%m-%d') = ?2 group by clZbh,jGh,jName")
37 37 List<Map<String, Object>> dailyInfo(String line,String date);
38 38  
... ... @@ -71,7 +71,7 @@ public interface ScheduleRealInfoRepository extends BaseRepository&lt;ScheduleRealI
71 71 @Query(value="select count(jName) from ScheduleRealInfo s where s.jName = ?1 and s.clZbh = ?2 and s.lpName = ?3 and sflj != 0")
72 72 int findLjbc(String jName,String clZbh,String lpName);
73 73  
74   - @Query(value="SELECT c.company,r.request_code,FROM_UNIXTIME(r.timestamp/1000,'%Y-%m-%d %T'),c.inside_code FROM bsth_v_report_80 r LEFT JOIN bsth_c_cars c ON c.equipment_code = r.device_id where FROM_UNIXTIME(r.timestamp/1000,'%Y-%m-%d') = ?2 and r.line_id like %?1% and c.inside_code like %?3%",nativeQuery=true)
  74 + @Query(value="SELECT c.company,r.request_code,FROM_UNIXTIME(r.timestamp/1000,'%Y-%m-%d %T') FROM bsth_v_report_80 r LEFT JOIN bsth_c_cars c ON c.equipment_code = r.device_id where FROM_UNIXTIME(r.timestamp/1000,'%Y-%m-%d') = ?2 and r.line_id = ?1 and c.inside_code = ?3",nativeQuery=true)
75 75 List<Object[]> account(String line,String date,String code);
76 76  
77 77 @Query(value="select s from ScheduleRealInfo s where s.xlBm = ?1 and s.scheduleDate >= str_to_date(?2,'%Y-%m-%d') "
... ... @@ -125,4 +125,4 @@ public interface ScheduleRealInfoRepository extends BaseRepository&lt;ScheduleRealI
125 125 @Query(value="select new map(xlBm as xlBm) from ScheduleRealInfo s where DATE_FORMAT(s.scheduleDate,'%Y-%m-%d') = ?1 GROUP BY xlBm ORDER BY xlBm")
126 126 List<Map<String,Object>> setDDRBGroup(String date);
127 127  
128   -}
129 128 \ No newline at end of file
  129 +}
... ...
src/main/java/com/bsth/service/forms/impl/FormsServiceImpl.java
... ... @@ -616,8 +616,8 @@ public class FormsServiceImpl implements FormsService {
616 616 tu.setRq(rq);
617 617 tu.setGs(arg0.getString("gs_name").toString());
618 618 tu.setZhgs(arg0.getString("fgs_name").toString());
619   - //tu.setXl(arg0.getString("xlgs"));这个是根据公司判断线路有几条
620   - tu.setXl(arg0.getString("sxl"));
  619 + tu.setXl(arg0.getString("xlgs"));//这个是根据公司判断线路有几条
  620 + //tu.setXl(arg0.getString("sxl"));
621 621 tu.setXlmc(arg0.getString("sxl"));
622 622 tu.setCchjh(arg0.getString("jcl").toString());
623 623 tu.setCchsj(arg0.getString("scl").toString());
... ...
src/main/java/com/bsth/service/impl/TrafficManageServiceImpl.java
... ... @@ -14,7 +14,6 @@ import com.bsth.repository.schedule.*;
14 14 import com.bsth.service.TrafficManageService;
15 15 import com.bsth.util.TimeUtils;
16 16 import com.bsth.util.db.DBUtils_MS;
17   -import com.bsth.webService.trafficManage.geotool.services.Internal;
18 17 import com.bsth.webService.trafficManage.geotool.services.InternalPortType;
19 18 import com.bsth.webService.trafficManage.org.tempuri.WebServiceLocator;
20 19 import com.bsth.webService.trafficManage.org.tempuri.WebServiceSoap;
... ... @@ -105,7 +104,7 @@ public class TrafficManageServiceImpl implements TrafficManageService{
105 104  
106 105  
107 106 // 运管处接口
108   - private InternalPortType portType = new Internal().getInternalHttpSoap11Endpoint();
  107 + private InternalPortType portType = null;//new Internal().getInternalHttpSoap11Endpoint();
109 108 private WebServiceSoap ssop ;
110 109 {
111 110 try {
... ...
src/main/java/com/bsth/service/realcontrol/impl/ChildTaskPlanServiceImpl.java
... ... @@ -17,65 +17,66 @@ import javax.transaction.Transactional;
17 17 import java.util.Map;
18 18  
19 19 @Service
20   -public class ChildTaskPlanServiceImpl extends BaseServiceImpl<ChildTaskPlan, Long> implements ChildTaskPlanService{
  20 +public class ChildTaskPlanServiceImpl extends BaseServiceImpl<ChildTaskPlan, Long> implements ChildTaskPlanService {
21 21  
22 22 /*@Autowired
23   - ScheduleRealInfoServiceImpl scheduleRealInfoService;*/
24   -
25   - @Autowired
26   - ScheduleRealInfoRepository scheduleRealInfoRepository;
27   -
28   - @Autowired
29   - ChildTaskPlanRepository childTaskPlanRepository;
30   -
31   - @Autowired
32   - DayOfSchedule dayOfSchedule;
33   -
34   - @Autowired
35   - Arrival2Schedule arrival2Schedule;
36   -
37   - @Autowired
38   - JdbcTemplate jdbcTemplate;
39   -
40   - @Transactional
41   - @Override
42   - public Map<String, Object> save(ChildTaskPlan t) {
43   - Map<String, Object> rs;
44   - //保存起终点名称
45   - Map<String, String> map = BasicData.stationCode2NameMap;
46   -
47   - t.setStartStationName(map.get(t.getStartStation()));
48   - t.setEndStationName(map.get(t.getEndStation()));
49   - //先持久化子任务
50   - rs = super.save(t);
51   - //再关联主任务
52   - ScheduleRealInfo sch = dayOfSchedule.get(t.getSchedule().getId());
53   - sch.getcTasks().add(t);
54   - dayOfSchedule.save(sch);
55   -
56   - rs.put("t", sch);
57   -
58   - if(sch.getZdsjActual() == null)
59   - arrival2Schedule.removeExpect(sch.getClZbh());
60   - return rs;
61   - }
62   -
63   - @Override
64   - public Map<String, Object> delete(Long id) {
65   - Map<String, Object> rs;
66   -
67   - ChildTaskPlan cPlan = childTaskPlanRepository.findOne(id);
68   - //解除和主任务关联
69   - ScheduleRealInfo sch = dayOfSchedule.get(cPlan.getSchedule().getId());
70   - sch.getcTasks().remove(cPlan);
71   - //删除关联表数据
72   - jdbcTemplate.execute("delete from bsth_c_s_sp_info_real_c_tasks where bsth_c_s_sp_info_real="+sch.getId()+" and c_tasks="+cPlan.getId());
73   -
74   - //删除子任务
75   - rs = super.delete(id);
76   - dayOfSchedule.save(sch);
77   -
78   - rs.put("t", sch);
79   - return rs;
80   - }
  23 + ScheduleRealInfoServiceImpl scheduleRealInfoService;*/
  24 +
  25 + @Autowired
  26 + ScheduleRealInfoRepository scheduleRealInfoRepository;
  27 +
  28 + @Autowired
  29 + ChildTaskPlanRepository childTaskPlanRepository;
  30 +
  31 + @Autowired
  32 + DayOfSchedule dayOfSchedule;
  33 +
  34 + @Autowired
  35 + Arrival2Schedule arrival2Schedule;
  36 +
  37 + @Autowired
  38 + JdbcTemplate jdbcTemplate;
  39 +
  40 + @Transactional
  41 + @Override
  42 + public Map<String, Object> save(ChildTaskPlan t) {
  43 + ScheduleRealInfo sch = dayOfSchedule.get(t.getSchedule().getId());
  44 + Map<String, Object> rs;
  45 + //保存起终点名称
  46 + Map<String, String> map = BasicData.stationCode2NameMap;
  47 + String prefix = sch.getXlBm() + "_" + sch.getXlDir() + "_";
  48 +
  49 + t.setStartStationName(BasicData.getStationNameByCode(t.getStartStation(), prefix));
  50 + t.setEndStationName(BasicData.getStationNameByCode(t.getEndStation(), prefix));
  51 + //先持久化子任务
  52 + rs = super.save(t);
  53 + //再关联主任务
  54 + sch.getcTasks().add(t);
  55 + dayOfSchedule.save(sch);
  56 +
  57 + rs.put("t", sch);
  58 +
  59 + if (sch.getZdsjActual() == null)
  60 + arrival2Schedule.removeExpect(sch.getClZbh());
  61 + return rs;
  62 + }
  63 +
  64 + @Override
  65 + public Map<String, Object> delete(Long id) {
  66 + Map<String, Object> rs;
  67 +
  68 + ChildTaskPlan cPlan = childTaskPlanRepository.findOne(id);
  69 + //解除和主任务关联
  70 + ScheduleRealInfo sch = dayOfSchedule.get(cPlan.getSchedule().getId());
  71 + sch.getcTasks().remove(cPlan);
  72 + //删除关联表数据
  73 + jdbcTemplate.execute("delete from bsth_c_s_sp_info_real_c_tasks where bsth_c_s_sp_info_real=" + sch.getId() + " and c_tasks=" + cPlan.getId());
  74 +
  75 + //删除子任务
  76 + rs = super.delete(id);
  77 + dayOfSchedule.save(sch);
  78 +
  79 + rs.put("t", sch);
  80 + return rs;
  81 + }
81 82 }
... ...
src/main/resources/application-dev.properties
... ... @@ -7,13 +7,13 @@ spring.jpa.hibernate.naming_strategy= org.hibernate.cfg.ImprovedNamingStrategy
7 7 #DATABASE
8 8 spring.jpa.database= MYSQL
9 9 spring.jpa.show-sql= true
10   -spring.datasource.driver-class-name= com.mysql.jdbc.Driver
11   -spring.datasource.url= jdbc:mysql://127.0.0.1/qp_control?useUnicode=true&characterEncoding=utf-8&useSSL=false
12   -spring.datasource.username= root
13   -spring.datasource.password=
14   -#spring.datasource.url= jdbc:mysql://192.168.168.117/pd_control?useUnicode=true&characterEncoding=utf-8&useSSL=false
  10 +#spring.datasource.driver-class-name= com.mysql.jdbc.Driver
  11 +#spring.datasource.url= jdbc:mysql://192.168.168.201/mh_control?useUnicode=true&characterEncoding=utf-8&useSSL=false
15 12 #spring.datasource.username= root
16   -#spring.datasource.password= root
  13 +#spring.datasource.password= 123456
  14 +spring.datasource.url= jdbc:mysql://localhost/mh_control?useUnicode=true&characterEncoding=utf-8&useSSL=false
  15 +spring.datasource.username= root
  16 +spring.datasource.password= root
17 17 #DATASOURCE
18 18 spring.datasource.max-active=100
19 19 spring.datasource.max-idle=8
... ...
src/main/resources/static/pages/forms/mould/allline.xls
No preview for this file type
src/main/resources/static/pages/forms/mould/executionrate.xls
No preview for this file type
src/main/resources/static/pages/forms/mould/turnoutrate.xls
No preview for this file type
src/main/resources/static/real_control_v2/css/main.css
... ... @@ -165,8 +165,8 @@ svg.line-chart g.item:nth-last-child(3)&gt;text {
165 165 }
166 166  
167 167 svg.line-chart g.gps-wrap>rect {
168   - width: 28px;
169   - height: 24px;
  168 + width: 34px;
  169 + height: 18px;
170 170 /*fill: #fff;*/
171 171 rx: 4px;
172 172 cursor: pointer;
... ... @@ -188,7 +188,7 @@ svg.line-chart g.gps-wrap&gt;rect.hover {
188 188  
189 189 svg.line-chart g.gps-wrap>text {
190 190 font-size: 13px;
191   - transform: translate(3px, 17px);
  191 + transform: translate(2px, 14px);
192 192 pointer-events: none;
193 193 }
194 194  
... ...
src/main/resources/static/real_control_v2/fragments/home/tooltip.html
... ... @@ -19,11 +19,12 @@
19 19 </div>
20 20 <div>
21 21 <span class="field">速度:</span>{{speed}}</div>
22   - <hr>
  22 + <div>
  23 + <span class="field">时间:</span>{{dateStr}}</div>
  24 + {{if expectStopTime!=null}}
23 25 <div>
24 26 预计 {{expectStopTime}} 分钟到达终点</div>
25   - <!-- <hr> -->
26   - <!-- <div class="subtitle">更新时间: 10:34.26</div> -->
  27 + {{/if}}
27 28 <div class="tip_map_wrap"></div>
28 29 </div>
29 30 </div>
... ... @@ -43,12 +44,15 @@
43 44 <div>
44 45 <span class="field">设备:</span>{{gps.deviceId}}
45 46 </div>
46   - <div>
  47 + <div style="color: #747272;">
  48 + {{gps.dateStr}}
  49 + </div>
  50 + <!--<div>
47 51 <span class="field">进站时间:</span>?
48 52 </div>
49 53 <div>
50 54 <span class="field">计划发出:</span>?
51   - </div>
  55 + </div>-->
52 56  
53 57 </div>
54 58 </div>
... ...
src/main/resources/static/real_control_v2/fragments/line_schedule/context_menu/bc_type_major.html
... ... @@ -15,7 +15,7 @@
15 15 </div>
16 16 <div class="uk-width-1-2">
17 17 <div class="uk-form-row">
18   - <label class="uk-form-label" style="width: 75px;">放站至</label>
  18 + <label class="uk-form-label" style="width: 75px;">放站至</label>
19 19 <div class="uk-form-controls" style="margin-left: 75px;">
20 20 <select name="endStation">
21 21 </select>
... ... @@ -53,11 +53,31 @@
53 53  
54 54 var remarks;
55 55 function refreshDirectiveStr() {
  56 +
  57 + var $qdz = $('[name=startStation]')
  58 + , $zdz = $('[name=endStation]');
56 59 //指令内容
57   - var qdzName = $('[name=startStation]').find("option:selected").text()
58   - , zdzName = $('[name=endStation]').find("option:selected").text();
59   - remarks=' 由 ' + qdzName + ' 放站至 ' + zdzName;
60   - $('[name=directiveStr]', modal).text('班次:'+sch.dfsj+remarks).trigger('input');
  60 + var qdzName = $qdz.find("option:selected").text()
  61 + , zdzName = $zdz.find("option:selected").text();
  62 +
  63 + //只修改起点
  64 + if(sch.qdzCode != $qdz.val() && sch.zdzCode == $zdz.val()){
  65 + remarks = ' 从 '+ sch.qdzName +' 待客至 ' + qdzName + ' ,放站至 ' + zdzName;
  66 + }
  67 + //只修改终点
  68 + else if(sch.qdzCode == $qdz.val() && sch.zdzCode != $zdz.val()){
  69 + remarks = ' 从 '+ sch.qdzName +' 放站至 ' + zdzName + ' 开始待客';
  70 + }
  71 + //起终点都改变
  72 + else if(sch.qdzCode != $qdz.val() && sch.zdzCode != $zdz.val()){
  73 + remarks = ' 从 '+ qdzName +' 放站至 ' + zdzName + ' 开始待客';
  74 + }
  75 + //起终点都不改变
  76 + else if(sch.qdzCode == $qdz.val() && sch.zdzCode == $zdz.val()){
  77 + remarks = ' 从 '+ qdzName +' 放站至 ' + zdzName;
  78 + }
  79 +
  80 + $('[name=directiveStr]', modal).text('班次:' + sch.dfsj + remarks).trigger('input');
61 81 }
62 82  
63 83 $('[name=startStation]', modal).on('change', function () {
... ...
src/main/resources/static/real_control_v2/fragments/line_schedule/context_menu/bc_type_venting.html
... ... @@ -6,7 +6,7 @@
6 6 <div class="uk-grid">
7 7 <div class="uk-width-1-2">
8 8 <div class="uk-form-row">
9   - <label class="uk-form-label" style="width: 75px;"></label>
  9 + <label class="uk-form-label" style="width: 75px;">起点</label>
10 10 <div class="uk-form-controls" style="margin-left: 75px;">
11 11 <select name="startStation">
12 12 </select>
... ... @@ -15,7 +15,7 @@
15 15 </div>
16 16 <div class="uk-width-1-2">
17 17 <div class="uk-form-row">
18   - <label class="uk-form-label" style="width: 75px;">直放至</label>
  18 + <label class="uk-form-label" style="width: 75px;">终点</label>
19 19 <div class="uk-form-controls" style="margin-left: 75px;">
20 20 <select name="endStation">
21 21 </select>
... ... @@ -53,12 +53,30 @@
53 53  
54 54 var remarks;
55 55 function refreshDirectiveStr() {
  56 + var $qdz = $('[name=startStation]')
  57 + , $zdz = $('[name=endStation]');
56 58 //指令内容
57   - var qdzName = $('[name=startStation]').find("option:selected").text()
58   - , zdzName = $('[name=endStation]').find("option:selected").text();
  59 + var qdzName = $qdz.find("option:selected").text()
  60 + , zdzName = $zdz.find("option:selected").text();
59 61  
60   - remarks=' 由 ' + qdzName + ' 直放至 ' + zdzName;
61   - $('[name=directiveStr]', modal).text('班次:'+sch.dfsj+ remarks).trigger('input');
  62 + //只修改起点
  63 + if(sch.qdzCode != $qdz.val() && sch.zdzCode == $zdz.val()){
  64 + remarks = ' 从 '+ sch.qdzName +' 待客至 ' + qdzName + ' ,直放至 ' + zdzName;
  65 + }
  66 + //只修改终点
  67 + else if(sch.qdzCode == $qdz.val() && sch.zdzCode != $zdz.val()){
  68 + remarks = ' 从 '+ sch.qdzName +' 直放至 ' + zdzName + ' 开始待客';
  69 + }
  70 + //起终点都改变
  71 + else if(sch.qdzCode != $qdz.val() && sch.zdzCode != $zdz.val()){
  72 + remarks = ' 从 '+ qdzName +' 直放至 ' + zdzName + ' 开始待客';
  73 + }
  74 + //起终点都不改变
  75 + else if(sch.qdzCode == $qdz.val() && sch.zdzCode == $zdz.val()){
  76 + remarks = ' 从 '+ qdzName +' 直放至 ' + zdzName;
  77 + }
  78 +
  79 + $('[name=directiveStr]', modal).text('班次:' + sch.dfsj + remarks).trigger('input');
62 80 }
63 81  
64 82 $('[name=startStation]', modal).on('change', function () {
... ... @@ -98,7 +116,7 @@
98 116 f.on('success.form.fv', function (e) {
99 117 e.preventDefault();
100 118 var data = $(this).serializeJSON();
101   - // notify_wait('准备下发指令')
  119 + // notify_wait('准备下发指令')
102 120 //下发指令
103 121 $.post('/directive/phrase', {nbbm: sch.clZbh, text: data.directiveStr}, function (rs) {
104 122 if (rs == 0) {
... ... @@ -128,7 +146,10 @@
128 146  
129 147 function changeBcType() {
130 148 //将班次类型调整为直放
131   - gb_common.$post('/realSchedule/changeBcType/'+sch.id, {bcType: 'venting', remarks: remarks}, function(rs){
  149 + gb_common.$post('/realSchedule/changeBcType/' + sch.id, {
  150 + bcType: 'venting',
  151 + remarks: remarks
  152 + }, function (rs) {
132 153 UIkit.modal(modal).hide();
133 154 gb_schedule_table.updateSchedule(rs.t);
134 155 //触发父容器刷新事件
... ...
src/main/resources/static/real_control_v2/fragments/north/nav/signal_state_config.html
1   -<div class="uk-modal ct-form-modal" id="signal_state_config-modal">
2   - <div class="uk-modal-dialog" style="width: 530px;">
3   - <a href="" class="uk-modal-close uk-close"></a>
4   - <div class="uk-modal-header">
5   - <h2>信号标记设置</h2></div>
6   -
7   - <p style="border-bottom: 1px solid #efefef;color: grey;padding-bottom: 9px;">
8   - <small>
9   - <i class="uk-icon-question-circle"> </i>
10   - 设置项将会保存在本地客户端,清理缓存和更换电脑会重置.</small>
11   - </p>
12   - <form class="uk-form uk-form-horizontal">
13   - <div class="uk-grid">
14   - <div class="uk-width-2-3 uk-container-center">
15   - <div class="uk-form-row">
16   - <label class="uk-form-label">是否启用</label>
17   - <div class="uk-form-controls">
18   - <select name="enable">
19   - <option value="1">启用</option>
20   - <option value="0">禁用</option>
21   - </select>
22   - </div>
23   - </div>
24   - </div>
25   - </div>
26   -
27   - <div class="uk-modal-footer uk-text-right" style="margin-bottom: -20px;">
28   - <button type="button" class="uk-button uk-modal-close">取消</button>
29   - <button type="submit" class="uk-button uk-button-primary"><i class="uk-icon-check"></i> &nbsp;保存</button>
30   - </div>
31   - </form>
32   - </div>
33   -
34   - <script>
35   - (function() {
36   - var modal = '#signal_state_config-modal';
37   - var f = $('form', modal);
38   -
39   - $(modal).on('init', function(e, data) {
40   - var val = gb_signal_state.isEnable()?1:0;
41   - $('[name=enable]', f).val(val);
42   - });
43   -
44   - f.formValidation(gb_form_validation_opts);
45   - f.on('success.form.fv', function(e) {
46   - e.preventDefault();
47   - var data = $(this).serializeJSON();
48   -
49   - if(data.enable=='1')
50   - gb_signal_state.enable();
51   - else
52   - gb_signal_state.disable();
53   -
54   - UIkit.modal(modal).hide();
55   - });
56   -
57   - })();
58   - </script>
  1 +<div class="uk-modal ct-form-modal" id="signal_state_config-modal">
  2 + <div class="uk-modal-dialog" style="width: 530px;">
  3 + <a href="" class="uk-modal-close uk-close"></a>
  4 + <div class="uk-modal-header">
  5 + <h2>信号标记设置</h2></div>
  6 +
  7 + <p style="border-bottom: 1px solid #efefef;color: grey;padding-bottom: 9px;">
  8 + <small>
  9 + <i class="uk-icon-question-circle"> </i>
  10 + 设置项将会保存在本地客户端,清理缓存和更换电脑会重置.</small>
  11 + </p>
  12 + <form class="uk-form uk-form-horizontal">
  13 + <div class="uk-grid">
  14 + <div class="uk-width-2-3 uk-container-center">
  15 + <div class="uk-form-row">
  16 + <label class="uk-form-label">是否启用</label>
  17 + <div class="uk-form-controls">
  18 + <select name="enable">
  19 + <option value="1">启用</option>
  20 + <option value="0">禁用</option>
  21 + </select>
  22 + </div>
  23 + </div>
  24 + </div>
  25 + </div>
  26 +
  27 + <div class="uk-modal-footer uk-text-right" style="margin-bottom: -20px;">
  28 + <button type="button" class="uk-button uk-modal-close">取消</button>
  29 + <button type="submit" class="uk-button uk-button-primary"><i class="uk-icon-check"></i> &nbsp;保存</button>
  30 + </div>
  31 + </form>
  32 + </div>
  33 +
  34 + <script>
  35 + (function() {
  36 + var modal = '#signal_state_config-modal';
  37 + var f = $('form', modal);
  38 +
  39 + $(modal).on('init', function(e, data) {
  40 + var val = gb_signal_state.isEnable()?1:0;
  41 + $('[name=enable]', f).val(val);
  42 + });
  43 +
  44 + f.formValidation(gb_form_validation_opts);
  45 + f.on('success.form.fv', function(e) {
  46 + e.preventDefault();
  47 + var data = $(this).serializeJSON();
  48 +
  49 + if(data.enable=='1')
  50 + gb_signal_state.enable();
  51 + else
  52 + gb_signal_state.disable();
  53 +
  54 + UIkit.modal(modal).hide();
  55 + });
  56 +
  57 + })();
  58 + </script>
59 59 </div>
60 60 \ No newline at end of file
... ...
src/main/resources/static/real_control_v2/js/data/data_gps.js
... ... @@ -3,7 +3,7 @@
3 3 var gb_data_gps = (function() {
4 4  
5 5 //fixed time refresh delay
6   - var delay = 1000 * 6;
  6 + var delay = 1000 * 60;
7 7 //deviceId ——> gps
8 8 var realData = {};
9 9 //refresh after callback
... ... @@ -51,8 +51,10 @@ var gb_data_gps = (function() {
51 51 } else
52 52 addArr.push(this);
53 53 //起终点 拼接方向标识
54   - if(this.sEPoint)
55   - this.stopNo=this.stopNo+'_'+this.upDown;
  54 + /*if(this.sEPoint)
  55 + this.stopNo=this.stopNo+'_'+this.upDown;*/
  56 + //时间格式化
  57 + this.dateStr = moment(this.timestamp).format('YYYY-MM-DD HH:mm:ss');
56 58 realData[this.deviceId] = this;
57 59 });
58 60  
... ...
src/main/resources/static/real_control_v2/js/line_schedule/context_menu.js
... ... @@ -190,4 +190,6 @@ var gb_schedule_context_menu = (function() {
190 190 }
191 191 }
192 192 });
  193 +
  194 + return callbackHandler;
193 195 })();
... ...
src/main/resources/static/real_control_v2/js/line_schedule/dbclick.js
... ... @@ -67,15 +67,23 @@ var gb_schedule_table_dbclick = (function() {
67 67 'cancel': {
68 68 name: '取消',
69 69 icon: "delete"
70   - },
71   - 'save': {
72   - name: '保存',
73   - icon: "edit"
74 70 }
75 71 }
76 72 });
  73 +
  74 + var sfsjCellClick = function (elem) {
  75 + elem.dblclick(function () {
  76 +
  77 + var id = $(this).parent().data('id'),
  78 + lineCode = $(this).parents('li.line_schedule').data('id');
  79 +
  80 + var sch = gb_schedule_table.findScheduleByLine(lineCode)[id];
  81 + gb_schedule_context_menu.fcxxwt(sch);
  82 + });
  83 + };
77 84  
78 85 return {
79   - init: init
  86 + init: init,
  87 + sfsjCellClick:sfsjCellClick
80 88 };
81 89 })();
... ...
src/main/resources/static/real_control_v2/js/line_schedule/sch_table.js
... ... @@ -108,6 +108,9 @@ var gb_schedule_table = (function () {
108 108 }
109 109 });
110 110 });
  111 +
  112 + //双击
  113 + gb_schedule_table_dbclick.sfsjCellClick($('dd.fcsjActualCell'));
111 114 }
112 115  
113 116 //重置序号
... ... @@ -192,20 +195,20 @@ var gb_schedule_table = (function () {
192 195 if (!isArray(schArr))
193 196 schArr = [schArr];
194 197  
195   - var tMaps={};
  198 + var tMaps = {};
196 199 $.each(schArr, function () {
197 200 line2Schedule[this.xlBm][this.id] = this;
198 201 updateDom(this);
199 202 //线路_车辆 过滤重复数据
200   - tMaps[this.xlBm+'_'+this.clZbh]=1;
  203 + tMaps[this.xlBm + '_' + this.clZbh] = 1;
201 204 });
202 205  
203   - /* //重新标记末班
204   - var ts=[];
205   - for(var k in tMaps){
206   - ts = k.split('_');
207   - markerLastByNbbm(ts[0], ts[1]);
208   - }*/
  206 + /* //重新标记末班
  207 + var ts=[];
  208 + for(var k in tMaps){
  209 + ts = k.split('_');
  210 + markerLastByNbbm(ts[0], ts[1]);
  211 + }*/
209 212 };
210 213  
211 214 //update dom
... ... @@ -218,10 +221,10 @@ var gb_schedule_table = (function () {
218 221 //车辆自编号
219 222 $(dds[2]).replaceWith(temps['line-schedule-nbbm-temp'](sch));
220 223 //if (sch.qdzArrDateJH)
221   - $(dds[3]).text(sch.qdzArrDateJH?sch.qdzArrDateJH:'');
  224 + $(dds[3]).text(sch.qdzArrDateJH ? sch.qdzArrDateJH : '');
222 225  
223 226 //if (sch.qdzArrDateSJ)
224   - $(dds[4]).text(sch.qdzArrDateSJ?sch.qdzArrDateSJ:'');
  227 + $(dds[4]).text(sch.qdzArrDateSJ ? sch.qdzArrDateSJ : '');
225 228  
226 229 //计发时间
227 230 $(dds[5]).replaceWith(temps['line-schedule-fcsj-temp'](sch));
... ... @@ -229,7 +232,9 @@ var gb_schedule_table = (function () {
229 232  
230 233 //实发时间
231 234 calc_sch_real_shift(sch);
232   - var sfsjDd = temps['line-schedule-sfsj-temp'](sch);
  235 + var sfsjDd = $(temps['line-schedule-sfsj-temp'](sch));
  236 + //双击
  237 + gb_schedule_table_dbclick.sfsjCellClick(sfsjDd);
233 238 $(dds[7]).replaceWith(sfsjDd);
234 239 if (sch.remarks)
235 240 $(dds[8]).html('<span title="' + sch.remarks + '" data-uk-tooltip="{pos:\'top-left\'}">' + sch.remarks + '</span>');
... ... @@ -239,7 +244,7 @@ var gb_schedule_table = (function () {
239 244 //信号状态标记
240 245 gb_signal_state.marker_sch(sch);
241 246 //班次是车辆的最后一班
242   - if(dl.hasClass('dl-last-sch'))
  247 + if (dl.hasClass('dl-last-sch'))
243 248 markerLastSch([sch]);
244 249 };
245 250  
... ... @@ -420,13 +425,13 @@ var gb_schedule_table = (function () {
420 425  
421 426 //清除线路下指定班次的 末班标记
422 427 var removeMarkers = function (lineCode, array) {
423   - var idx=[];
  428 + var idx = [];
424 429 $.each(array, function () {
425 430 idx.push(this.id);
426 431 });
427 432  
428   - $('dl.dl-last-sch','li.line_schedule[data-id=' + lineCode + ']').each(function () {
429   - if($(this).hasClass('dl-last-sch') && idx.indexOf($(this).data('id'))){
  433 + $('dl.dl-last-sch', 'li.line_schedule[data-id=' + lineCode + ']').each(function () {
  434 + if ($(this).hasClass('dl-last-sch') && idx.indexOf($(this).data('id'))) {
430 435 $(this).removeClass('dl-last-sch').find('.last-sch-sunken').remove();
431 436 }
432 437 });
... ...
src/main/resources/static/real_control_v2/js/signal_state/signal_state.js
1   -/**
2   - * GPS信号状态
3   - * @type {{}}
4   - */
5   -var gb_signal_state = (function () {
6   - var storage = window.localStorage;
7   -
8   - $(document).on('click', 'i.signal_state_icon', function (e) {
9   - e.stopPropagation();
10   - });
11   -
12   - var signal_state_data = {};
13   - var enable = true;
14   - //读取本地状态
15   - var locStatus = storage.getItem("signal_state_enable");
16   - if (locStatus && locStatus=='0')
17   - enable = false;
18   -
19   - var init = function () {
20   - $.get('/signalState/multi', {idx: gb_data_basic.line_idx}, function (rs) {
21   - //按班次ID分组
22   - signal_state_data = gb_common.groupBy(rs, 'schId');
23   -
24   - for (var schId in signal_state_data) {
25   - multi_render(signal_state_data[schId]);
26   - }
27   - });
28   - };
29   -
30   - var multi_render = function (list) {
31   - if (!enable)
32   - return;
33   -
34   - if (!list || list.length == 0)
35   - return;
36   - var line = list[0].lineCode
37   - , schId = list[0].schId;
38   -
39   - var sch = gb_schedule_table.findScheduleByLine(line)[schId];
40   - var dl = gb_schedule_table.getDl(sch);
41   - var icon = 'question-circle';
42   - var t = '';
43   - $.each(list, function () {
44   - t += (this.text + '<br>');
45   - });
46   -
47   - if (list.length == 1 && list[0].type == 'route_reverse')
48   - icon = 'reply';
49   -
50   - var dd = $('dd.fcsjActualCell', dl);
51   - var se = $('i.signal_state_icon', dd);
52   - if (se && se.length > 0)
53   - se.remove();
54   -
55   - dd.append('<i data-uk-tooltip title="' + t + '" class="uk-icon-' + icon + ' signal_state_icon"></i>');
56   - };
57   -
58   - var put = function (obj) {
59   - if (!signal_state_data[obj.schId]) {
60   - signal_state_data[obj.schId] = [];
61   - }
62   -
63   - signal_state_data[obj.schId].push(obj);
64   - multi_render(signal_state_data[obj.schId]);
65   - };
66   -
67   - var marker_sch = function (sch) {
68   - var list = signal_state_data[sch.id];
69   - if (list) {
70   - multi_render(list);
71   - }
72   - };
73   -
74   - var clearAll = function () {
75   - $('.signal_state_icon').remove();
76   - };
77   -
78   - return {
79   - init: init,
80   - put: put,
81   - marker_sch: marker_sch,
82   - isEnable: function () {
83   - return enable;
84   - },
85   - disable: function () {
86   - enable = false;
87   - storage.setItem("signal_state_enable", 0);
88   -
89   - clearAll();
90   - },
91   - enable: function () {
92   - enable = true;
93   - storage.setItem("signal_state_enable", 1);
94   - for (var schId in signal_state_data) {
95   - multi_render(signal_state_data[schId]);
96   - }
97   - }
98   - };
  1 +/**
  2 + * GPS信号状态
  3 + * @type {{}}
  4 + */
  5 +var gb_signal_state = (function () {
  6 + var storage = window.localStorage;
  7 +
  8 + $(document).on('click', 'i.signal_state_icon', function (e) {
  9 + e.stopPropagation();
  10 + });
  11 +
  12 + var signal_state_data = {};
  13 + var enable = true;
  14 + //读取本地状态
  15 + var locStatus = storage.getItem("signal_state_enable");
  16 + if (locStatus && locStatus=='0')
  17 + enable = false;
  18 +
  19 + var init = function () {
  20 + $.get('/signalState/multi', {idx: gb_data_basic.line_idx}, function (rs) {
  21 + //按班次ID分组
  22 + signal_state_data = gb_common.groupBy(rs, 'schId');
  23 +
  24 + for (var schId in signal_state_data) {
  25 + multi_render(signal_state_data[schId]);
  26 + }
  27 + });
  28 + };
  29 +
  30 + var multi_render = function (list) {
  31 + if (!enable)
  32 + return;
  33 +
  34 + if (!list || list.length == 0)
  35 + return;
  36 + var line = list[0].lineCode
  37 + , schId = list[0].schId;
  38 +
  39 + var sch = gb_schedule_table.findScheduleByLine(line)[schId];
  40 + var dl = gb_schedule_table.getDl(sch);
  41 + var icon = 'question-circle';
  42 + var t = '';
  43 + $.each(list, function () {
  44 + t += (this.text + '<br>');
  45 + });
  46 +
  47 + if (list.length == 1 && list[0].type == 'route_reverse')
  48 + icon = 'reply';
  49 +
  50 + var dd = $('dd.fcsjActualCell', dl);
  51 + var se = $('i.signal_state_icon', dd);
  52 + if (se && se.length > 0)
  53 + se.remove();
  54 +
  55 + dd.append('<i data-uk-tooltip title="' + t + '" class="uk-icon-' + icon + ' signal_state_icon"></i>');
  56 + };
  57 +
  58 + var put = function (obj) {
  59 + if (!signal_state_data[obj.schId]) {
  60 + signal_state_data[obj.schId] = [];
  61 + }
  62 +
  63 + signal_state_data[obj.schId].push(obj);
  64 + multi_render(signal_state_data[obj.schId]);
  65 + };
  66 +
  67 + var marker_sch = function (sch) {
  68 + var list = signal_state_data[sch.id];
  69 + if (list) {
  70 + multi_render(list);
  71 + }
  72 + };
  73 +
  74 + var clearAll = function () {
  75 + $('.signal_state_icon').remove();
  76 + };
  77 +
  78 + return {
  79 + init: init,
  80 + put: put,
  81 + marker_sch: marker_sch,
  82 + isEnable: function () {
  83 + return enable;
  84 + },
  85 + disable: function () {
  86 + enable = false;
  87 + storage.setItem("signal_state_enable", 0);
  88 +
  89 + clearAll();
  90 + },
  91 + enable: function () {
  92 + enable = true;
  93 + storage.setItem("signal_state_enable", 1);
  94 + for (var schId in signal_state_data) {
  95 + multi_render(signal_state_data[schId]);
  96 + }
  97 + }
  98 + };
99 99 })();
100 100 \ No newline at end of file
... ...
src/main/resources/static/real_control_v2/js/utils/svg_chart.js
1 1 /* 线路模拟图 */
2 2  
3   -var gb_svg_chart = (function() {
  3 +var gb_svg_chart = (function () {
4 4  
5 5 //chart height
6 6 var chart_height = 123;
... ... @@ -11,22 +11,22 @@ var gb_svg_chart = (function() {
11 11 //svg namespace
12 12 var svgns = 'http://www.w3.org/2000/svg';
13 13  
14   - var calc_text_y = function(t) {
  14 + var calc_text_y = function (t) {
15 15 return (chart_height - (chart_height / t_max_size * t.length)) / 2 + 5;
16 16 },
17   - cat_text = function(t) {
  17 + cat_text = function (t) {
18 18 return t.length > t_max_size ? t.substr(0, t_max_size) : t;
19 19 },
20   - get_width = function(wrap) {
  20 + get_width = function (wrap) {
21 21 return wrap.actual('outerWidth');
22 22 },
23   - get_height = function(wrap) {
  23 + get_height = function (wrap) {
24 24 var h = wrap.actual('outerHeight');
25 25 //隐藏元素取最外层的高度
26 26 return h < 20 ? wrap.parent().actual('outerHeight') - 2 : h;
27 27 }
28 28  
29   - var draw_line = function(lineCode, wrap) {
  29 + var draw_line = function (lineCode, wrap) {
30 30  
31 31 var data = gb_svg_data_convert.mergeRoute(gb_data_basic.stationRoutes(lineCode)),
32 32 len = data.length;
... ... @@ -36,22 +36,22 @@ var gb_svg_chart = (function() {
36 36 //x scale
37 37 ,
38 38 xScale = d3.scale.linear().range([x_padd, w - x_padd]).domain([0, len - 1]),
39   - cx = function(d, i) {
  39 + cx = function (d, i) {
40 40 return xScale(i);
41 41 },
42   - cy = function() {
  42 + cy = function () {
43 43 return (h - chart_height) / 2;
44 44 },
45   - ty = function(d) {
  45 + ty = function (d) {
46 46 return cy() + calc_text_y(cat_text(d.name[0]));
47 47 }
48 48 //line generator
49 49 ,
50 50 upLine = d3.svg.line().x(xScale).y(cy),
51   - downLine = d3.svg.line().x(xScale).y(function() {
  51 + downLine = d3.svg.line().x(xScale).y(function () {
52 52 return cy() + chart_height
53 53 }),
54   - multi_text = function(d, i, that) {
  54 + multi_text = function (d, i, that) {
55 55  
56 56 var dText = document.createElementNS(svgns, 'text'),
57 57 t = cat_text(d.name[1]);
... ... @@ -82,14 +82,14 @@ var gb_svg_chart = (function() {
82 82 'station_link': true
83 83 };
84 84 items.append('path').classed(p_clzz)
85   - .attr('d', function(d, i) {
  85 + .attr('d', function (d, i) {
86 86 return i < len - 1 ? upLine([i, i + 1]) : '';
87 87 });
88 88  
89 89 //down station link path
90 90 p_clzz.down = true;
91 91 items.append('path').classed(p_clzz)
92   - .attr('d', function(d, i) {
  92 + .attr('d', function (d, i) {
93 93 return i < len - 1 ? downLine([i, i + 1]) : '';
94 94 });
95 95  
... ... @@ -97,40 +97,44 @@ var gb_svg_chart = (function() {
97 97 var c_clzz = {
98 98 'station_circle': true
99 99 };
100   - items.select(function (d) {return d.type!=1?this:null;})
  100 + items.select(function (d) {
  101 + return d.type != 1 ? this : null;
  102 + })
101 103 .append('circle').classed(c_clzz)
102 104 .attr('cx', cx)
103 105 .attr('cy', cy)
104   - .attr('data-id', function(d) {
  106 + .attr('data-id', function (d) {
105 107 return d.id[0];
106 108 });
107 109  
108 110 //down circle
109 111 c_clzz.down = true;
110   - items.select(function (d) {return d.type!=0?this:null;})
  112 + items.select(function (d) {
  113 + return d.type != 0 ? this : null;
  114 + })
111 115 .append('circle').classed(c_clzz)
112 116 .attr('cx', cx)
113   - .attr('cy', function(d, i) {
  117 + .attr('cy', function (d, i) {
114 118 return cy(d, i) + chart_height;
115 119 })
116   - .attr('data-id', function(d) {
117   - return d.type==1?d.id[0]:d.id[1];
  120 + .attr('data-id', function (d) {
  121 + return d.type == 1 ? d.id[0] : d.id[1];
118 122 });
119 123  
120 124 //station name text
121 125 items.append('text').classed({
122   - 'station_text': true,
123   - 'up': function(d) {
124   - return d.type == 3 ? true : false;
125   - }
126   - })
127   - .text(function(d) {
  126 + 'station_text': true,
  127 + 'up': function (d) {
  128 + return d.type == 3 ? true : false;
  129 + }
  130 + })
  131 + .text(function (d) {
128 132 return cat_text(d.name[0]);
129 133 })
130   - .attr('title', function(d) {
  134 + .attr('title', function (d) {
131 135 return d.name[0];
132 136 })
133   - .attr('x', function(d, i) {
  137 + .attr('x', function (d, i) {
134 138 return d.type == 3 ? multi_text(d, i, this) : cx(d, i)
135 139 })
136 140 .attr('y', ty);
... ... @@ -149,90 +153,95 @@ var gb_svg_chart = (function() {
149 153 // ----- draw gps ------
150 154 //gps 按线路站点分组后的下标映射
151 155 var line_gps_index = {};
152   - var get_circle = function(dataId, svg) {
  156 + var get_circle = function (dataId, svg) {
153 157 try {
154 158 var circle = $('.station_circle[data-id=' + dataId + ']', svg);
155 159 if (circle.length == 0)
156 160 circle = null;
157   - }catch (e){
  161 + } catch (e) {
158 162 console.log('get_circle error! station_circle data-id:' + dataId);
159 163 return null;
160 164 }
161 165 return circle;
162 166 },
163   - gx = function(gps, svg) {
164   - var circle = get_circle(gps.stopNo, svg);
  167 + gx = function (gps, svg) {
  168 + var circle = get_circle(gps.stopNo + '_' + gps.upDown, svg);
165 169 if (!circle) return -100;
166 170  
167 171 return circle.attr('cx') - 14;
168 172 },
169   - gy = function(gps, svg) {
170   - var circle = get_circle(gps.stopNo, svg);
  173 + gy = function (gps, svg) {
  174 + var circle = get_circle(gps.stopNo + '_' + gps.upDown, svg);
171 175 if (!circle) return -100;
172 176  
173 177 var cy = parseInt(circle.attr('cy')),
174   - index = line_gps_index[gps.lineId][gps.stopNo][gps.deviceId];
  178 + index = line_gps_index[gps.lineId][gps.stopNo + '_' + gps.upDown][gps.deviceId];
175 179  
176   - return gps.upDown == 0 ? cy - 31 - (index * 28) : cy + 7 + (index * 28);
  180 + return gps.upDown == 0 ? cy - 25 - (index * 21) : cy + 7 + (index * 21);
177 181 },
178   - ups_gps = function(d) {
  182 + ups_gps = function (d) {
179 183 return d.gpsUps;
180 184 },
181   - downs_gps = function(d) {
  185 + downs_gps = function (d) {
182 186 return d.gpsDowns;
183 187 },
184   - gps_index_mapp = function(data) {
  188 + gps_index_mapp = function (data) {
185 189 var rs = {};
186   - var dataGroupStop = gb_common.groupBy(data, 'stopNo');
  190 + var dataGroupStop = gb_svg_data_convert.groupByStationAndUpdown(data);
187 191 for (var stopNo in dataGroupStop) {
188 192 rs[stopNo] = {};
189   - $.each(dataGroupStop[stopNo], function(i, gps) {
  193 + $.each(dataGroupStop[stopNo], function (i, gps) {
190 194 rs[stopNo][gps.deviceId] = i;
191 195 });
192 196 }
193 197 return rs;
194 198 },
195   - g_text = function(d) {
196   - var len = (d.nbbm == false ? 0 : d.nbbm.length);
197   - return len > 3 ? d.nbbm.substr(len - 3) : d.nbbm;
  199 + g_text = function (d) {
  200 + var len = (d.nbbm == false ? 0 : d.nbbm.length)
  201 + , t = len > 3 ? d.nbbm.substr(len - 3) : d.nbbm;
  202 +
  203 + if (d.nbbm.indexOf('-') > 1) {
  204 + t = d.nbbm.substr(d.nbbm.indexOf('-') - 1, 1) + t;
  205 + }
  206 + return t;
198 207 },
199   - gps_key = function(d) {
  208 + gps_key = function (d) {
200 209 return d.deviceId;
201 210 },
202   - gps_update_point = function(e, svg) {
203   - e.transition().attr('x', function(d) {
204   - return gx(d, svg);
205   - })
206   - .attr('y', function(d) {
  211 + gps_update_point = function (e, svg) {
  212 + e.transition().attr('x', function (d) {
  213 + return gx(d, svg);
  214 + })
  215 + .attr('y', function (d) {
207 216 return gy(d, svg);
208 217 })
209   - .attr('updown', function(d) {
  218 + .attr('updown', function (d) {
210 219 return d.upDown;
211 220 });
212 221 //update tip position
213 222 gb_svg_tooltip.update(e);
214 223 },
215   - rct_id = function(d) {
  224 + rct_id = function (d) {
216 225 return 'rct_' + d.deviceId;
217 226 },
218   - tx_id = function(d) {
  227 + tx_id = function (d) {
219 228 return 'tx_' + d.deviceId;
220 229 }
221 230  
222   - var setGps = function(lineCode) {
  231 + var setGps = function (lineCode) {
223 232 var svgs = $('.line-chart[data-code=' + lineCode + ']'),
224 233 data = gb_data_gps.gpsByLineCode(lineCode);
225 234  
226   - var list=[];
  235 + var list = [];
227 236 //过滤无站点字段的数据
228   - $.each(data, function(){
229   - if(!this.stopNo || this.stopNo=='')
  237 + $.each(data, function () {
  238 + if (!this.stopNo || this.stopNo == '')
230 239 return true;
231 240 list.push(this);
232 241 });
233 242  
234 243 line_gps_index[lineCode] = gps_index_mapp(list);
235   - $.each(svgs, function() {
  244 + $.each(svgs, function () {
236 245 //绘制gps
237 246 draw_gps(this, list);
238 247 //聚合gps
... ... @@ -241,7 +250,7 @@ var gb_svg_chart = (function() {
241 250  
242 251 };
243 252  
244   - var draw_gps = function(svg, data) {
  253 + var draw_gps = function (svg, data) {
245 254 //remove merge_hide class
246 255 $('.merge_hide', svg).removeAttr('class');
247 256  
... ... @@ -256,22 +265,22 @@ var gb_svg_chart = (function() {
256 265 gps_update_point(ts, svg);
257 266 };
258 267  
259   - var marker_clusterer = function(svg, lineCode) {
260   - //debugger
  268 + var marker_clusterer = function (svg, lineCode) {
  269 + //debugger
261 270 var gpsArr, idxMapp = line_gps_index[lineCode];
262   - //svgs = $('.line-chart[data-code=' + lineCode + ']');
  271 + //svgs = $('.line-chart[data-code=' + lineCode + ']');
263 272 for (var stopNo in idxMapp) {
264 273 gpsArr = gb_common.get_keys(idxMapp[stopNo]);
265 274 //remove old merger point
266 275 $('g[_id=' + 'merger_' + stopNo + ']', svg).remove();
267 276 if (gpsArr.length <= 2)
268   - continue;
  277 + continue;
269 278  
270 279 marker_clusterer_merge(svg, stopNo, gpsArr);
271 280 }
272 281 }
273 282  
274   - var marker_clusterer_merge = function(svg, stopNo, gpsArr) {
  283 + var marker_clusterer_merge = function (svg, stopNo, gpsArr) {
275 284 //stop circle
276 285 var circle = get_circle(stopNo, svg);
277 286 if (!circle) return;
... ... @@ -282,7 +291,7 @@ var gb_svg_chart = (function() {
282 291  
283 292 var svg = d3.select(svg);
284 293 //hide old element
285   - $.each(gpsArr, function(i, d) {
  294 + $.each(gpsArr, function (i, d) {
286 295 $('rect[_id=rct_' + d + '],text[_id=tx_' + d + ']').attr('class', 'merge_hide');
287 296 });
288 297  
... ... @@ -292,7 +301,7 @@ var gb_svg_chart = (function() {
292 301 });
293 302 //merge rect
294 303 mergerG.append('rect').attr('x', x - 12)
295   - .attr('y', function() {
  304 + .attr('y', function () {
296 305 return isDown ? y + 7 : y - 32;
297 306 });
298 307 //merge text
... ...
src/main/resources/static/real_control_v2/js/utils/svg_chart_map.js
... ... @@ -37,14 +37,15 @@ var gb_svg_map_util = (function () {
37 37  
38 38 var drawStationMarker = function (routeItem) {
39 39 var station = routeItem.station,
  40 + name = routeItem.stationName,
40 41 coord = TransGPS.wgsToBD(station.gLaty, station.gLonx);
41 42  
42 43 var marker = new BMap.Marker(new BMap.Point(coord.lng, coord.lat));
43 44  
44 45 //label
45   - var offsetX = Math.abs(station.stationName.length / 2 * 12),
  46 + var offsetX = Math.abs(name.length / 2 * 12),
46 47 offsetY = -20,
47   - label = new BMap.Label(station.stationName, {
  48 + label = new BMap.Label(name, {
48 49 offset: new BMap.Size(-offsetX, offsetY)
49 50 });
50 51  
... ...
src/main/resources/static/real_control_v2/js/utils/svg_chart_tooltip.js
... ... @@ -13,6 +13,7 @@ var gb_svg_tooltip = (function () {
13 13 if (rect.attr('aria-describedby'))
14 14 return;
15 15 var gps = gb_data_gps.findOne($(this).attr('_id').split('_')[1]);
  16 + console.log('gps', gps);
16 17 $(this).qtip({
17 18 show: {
18 19 ready: true,
... ... @@ -151,7 +152,7 @@ var gb_svg_tooltip = (function () {
151 152 function searchByStop(list, stop) {
152 153 var rs = [];
153 154 $.each(list, function () {
154   - if (this.stopNo == stop)
  155 + if ((this.stopNo + '_' + this.upDown) == stop)
155 156 rs.push(this);
156 157 });
157 158 return rs;
... ...
src/main/resources/static/real_control_v2/js/utils/svg_data_convert.js
... ... @@ -103,14 +103,30 @@ var gb_svg_data_convert = (function() {
103 103 };
104 104  
105 105 var get_station_code=function (station) {
106   - if(station.stationMark=='B' || station.stationMark=='E')
  106 + /*if(station.stationMark=='B' || station.stationMark=='E')
107 107 return station.stationCode+'_'+station.directions;
108 108 else
109   - return station.stationCode;
  109 + return station.stationCode;*/
  110 + return station.stationCode+'_'+station.directions;
110 111 };
111 112  
112 113 var nvl_get = function(list, index) {
113 114 return list[index] == null ? {} : list[index];
114 115 };
115   - return {mergeRoute: mergeRoute};
  116 +
  117 + var groupByStationAndUpdown = function (data) {
  118 + //gb_common.groupBy(data, 'stopNo')
  119 + var rs = {},
  120 + key;
  121 + $.each(data, function () {
  122 + key = this['stopNo'] + '_' + this['upDown'];
  123 + if (!rs[key])
  124 + rs[key] = [];
  125 +
  126 + rs[key].push(this);
  127 + });
  128 +
  129 + return rs;
  130 + };
  131 + return {mergeRoute: mergeRoute, groupByStationAndUpdown: groupByStationAndUpdown};
116 132 })();
... ...
src/main/resources/static/real_control_v2/mapmonitor/js/map/platform/baidu.js
... ... @@ -394,7 +394,7 @@ var gb_map_baidu = (function(){
394 394 //线路名
395 395 gps.lineName = gb_data_basic.lineCode2NameAll()[gps.lineId];
396 396 //时间
397   - gps.dateStr = moment(gps.timestamp).format('YYYY-MM-DD HH:mm:ss');
  397 + //gps.dateStr = moment(gps.timestamp).format('YYYY-MM-DD HH:mm:ss');
398 398  
399 399 marker.infoWindow.setContent(gb_map_overlay_mge.map_gps_win_temp(gps));
400 400 map.openInfoWindow(marker.infoWindow, marker.point);
... ...