Commit cd10c3cdee69881bb9d431e0476eb6faeff7942e

Authored by 娄高锋
2 parents 2ec8a447 c8d5078d

Merge branch 'minhang' of 192.168.168.201:panzhaov5/bsth_control into minhang

Showing 66 changed files with 2187 additions and 845 deletions
src/main/java/com/bsth/controller/forms/ExportController.java
... ... @@ -13,8 +13,10 @@ import org.springframework.web.bind.annotation.RequestMethod;
13 13 import org.springframework.web.bind.annotation.RequestParam;
14 14 import org.springframework.web.bind.annotation.RestController;
15 15  
  16 +import com.bsth.data.BasicData;
16 17 import com.bsth.entity.mcy_forms.Allline;
17 18 import com.bsth.entity.mcy_forms.Changetochange;
  19 +import com.bsth.entity.mcy_forms.Daily;
18 20 import com.bsth.entity.mcy_forms.Executionrate;
19 21 import com.bsth.entity.mcy_forms.Linepasswengerflow;
20 22 import com.bsth.entity.mcy_forms.Operationservice;
... ... @@ -319,8 +321,34 @@ public class ExportController {
319 321 List<Turnoutrate> turnoutrate = formsService.turnoutrate(map);
320 322 Map<String, Object> map1 = new HashMap<String, Object>();
321 323 List<Map<String, Object>> resList = new ArrayList<Map<String, Object>>();
  324 + String xlts="";
  325 + String zsgs="";
  326 + String jh="";
  327 + Float j=0f;
  328 + Float sj=0f;
  329 + Float qz=0f;
  330 + Float ccl=0f;
  331 + Float bcjh=0f;
  332 + String bcsj="";
  333 + Float bczxl=0f;
  334 + String gs="";
  335 + String zhgs="";
  336 +
322 337 for (Turnoutrate l : turnoutrate) {
323 338 Map<String, Object> m = new HashMap<String, Object>();
  339 +
  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());
  347 + bczxl +=l.getBcjh()==""?0f:Float.valueOf(l.getBcjh());
  348 + gs +=l.getBcsj()==""?0:String.valueOf(l.getBcsj());
  349 + zhgs +=l.getBbzxl()==""?0:String.valueOf(l.getBbzxl());
  350 +
  351 +
324 352 m.put("rq", l.getRq());
325 353 m.put("gs", l.getGs());
326 354 m.put("zhgs", l.getZhgs());
... ... @@ -330,10 +358,27 @@ public class ExportController {
330 358 m.put("cchqz", l.getCchqz());
331 359 m.put("chl", l.getChl());
332 360 m.put("bcjh", l.getBcjh());
333   - m.put("bcsj", l.getBbzxl());
  361 + m.put("bcsj", l.getBcsj());
334 362 m.put("bbzxl", l.getBbzxl());
335 363 m.put("sm", l.getSm());
336 364 resList.add(m);
  365 +
  366 +
  367 +
  368 + m=new HashMap<String,Object>();
  369 + m.put("total_xlts", xlts);
  370 + m.put("total_zhgs", zsgs);
  371 + m.put("total_jh", jh);
  372 + m.put("total_sj", sj);
  373 + m.put("total_qz", ccl);
  374 + m.put("total_ccl", bcjh);
  375 + m.put("total_bcjh",bcsj);
  376 + m.put("total_bcsj", bczxl);
  377 + m.put("total_bczxl", bczxl);
  378 + m.put("total_gs", zhgs);
  379 +
  380 +
  381 + map1 = m;
337 382 }
338 383  
339 384 try {
... ... @@ -347,7 +392,7 @@ public class ExportController {
347 392 return resList;
348 393 }
349 394  
350   - //营运线路出车率统计表
  395 + //班次执行率统计表
351 396 @RequestMapping(value = "/executionrateExport", method = RequestMethod.POST)
352 397 public List<Map<String, Object>> executionrateExport(@RequestParam Map<String, Object> map) {
353 398 SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"), sdfSimple = new SimpleDateFormat("yyyyMMdd");
... ... @@ -356,8 +401,33 @@ public class ExportController {
356 401 List<Executionrate> executionrate = formsService.executionrate(map);
357 402 Map<String, Object> map1 = new HashMap<String, Object>();
358 403 List<Map<String, Object>> resList = new ArrayList<Map<String, Object>>();
  404 + String xlts="";
  405 + String zsgs="";
  406 + String jh="";
  407 + Float sj=0f;
  408 + Float ccl=0f;
  409 + Float bcjh=0f;
  410 + String bcsj="";
  411 + Float bczxl=0f;
  412 + String gs="";
  413 + String zhgs="";
  414 +
  415 + Map<String, Object> m = new HashMap<String, Object>();
  416 +
359 417 for (Executionrate l : executionrate) {
360   - Map<String, Object> m = new HashMap<String, Object>();
  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());
  425 + bczxl +=l.getBcjh()==""?0f:Float.valueOf(l.getBcjh());
  426 + gs +=l.getBcsj()==""?0:String.valueOf(l.getBcsj());
  427 + zhgs +=l.getBbzxl()==""?0:String.valueOf(l.getBbzxl());
  428 +
  429 +
  430 +
361 431 m.put("rq", l.getRq());
362 432 m.put("gs", l.getGs());
363 433 m.put("zhgs", l.getZhgs());
... ... @@ -366,10 +436,24 @@ public class ExportController {
366 436 m.put("cchsj", l.getCchsj());
367 437 m.put("chl", l.getChl());
368 438 m.put("bcjh", l.getBcjh());
369   - m.put("bcsj", l.getBbzxl());
  439 + m.put("bcsj", l.getBcsj());
370 440 m.put("bbzxl", l.getBbzxl());
371 441 m.put("sm", l.getSm());
372 442 resList.add(m);
  443 +
  444 +
  445 + m=new HashMap<String,Object>();
  446 + m.put("total_gs", xlts);
  447 + m.put("total_zhgs", zsgs);
  448 + m.put("total_xlts", jh);
  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);
  455 +
  456 + map1 = m;
373 457 }
374 458  
375 459 try {
... ... @@ -393,8 +477,28 @@ public class ExportController {
393 477 List<Allline> allline = formsService.allline(map);
394 478 Map<String, Object> map1 = new HashMap<String, Object>();
395 479 List<Map<String, Object>> resList = new ArrayList<Map<String, Object>>();
  480 + Integer jh=0;
  481 + Integer sj=0;
  482 + Integer ccl=0;
  483 + Double bcjh=0.0;
  484 + String bcsj="";
  485 + Integer bczxl=0;
  486 + String gs="";
  487 + String zhgs="";
  488 + Map<String, Object> m ;
396 489 for (Allline l : allline) {
397   - Map<String, Object> m = new HashMap<String, Object>();
  490 + m = new HashMap<String, Object>();
  491 +
  492 + jh +=l.getGsgs()=="" ? 0: Integer.valueOf(l.getGsgs());
  493 + sj +=l.getFgsgs()==""?0: Integer.valueOf(l.getFgsgs());
  494 + ccl +=l.getCchjh()==""?0: Integer.valueOf(l.getCchjh());
  495 + bcjh +=l.getCchsj()==""?0: Double.valueOf(l.getCchsj());
  496 +
  497 + bcsj +=l.getChl()==""? 0:String.valueOf(l.getChl());
  498 + bczxl +=l.getBcjh()==""?0: Integer.valueOf(l.getBcjh());
  499 + gs +=l.getBcsj()==""?0: String.valueOf(l.getBcsj());
  500 + zhgs +=l.getBbzxl()==""?0:String.valueOf(l.getBbzxl());
  501 +
398 502 m.put("rq", l.getRq());
399 503 m.put("gs", l.getGs());
400 504 m.put("zhgs", l.getZhgs());
... ... @@ -403,10 +507,22 @@ public class ExportController {
403 507 m.put("cchsj", l.getCchsj());
404 508 m.put("chl", l.getChl());
405 509 m.put("bcjh", l.getBcjh());
406   - m.put("bcsj", l.getBbzxl());
  510 + m.put("bcsj", l.getBcsj());
407 511 m.put("bbzxl", l.getBbzxl());
408 512 m.put("sm", l.getSm());
409 513 resList.add(m);
  514 +
  515 + m=new HashMap<String,Object>();
  516 + m.put("total_jh", jh);
  517 + m.put("total_sj", sj);
  518 + m.put("total_ccl", ccl);
  519 + m.put("total_bcjh", bcjh);
  520 + m.put("total_bcsj", bcsj);
  521 + m.put("total_bczxl", bczxl);
  522 + m.put("total_gs", gs);
  523 + m.put("total_zhgs", zhgs);
  524 + map1 = m;
  525 +
410 526 }
411 527  
412 528 try {
... ... @@ -422,6 +538,56 @@ public class ExportController {
422 538  
423 539  
424 540  
  541 + //班次日报表
  542 + @RequestMapping(value = "/dailyExport", method = RequestMethod.POST)
  543 + public List<Map<String, Object>> dailyExport(@RequestParam Map<String, Object> map) {
  544 + SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"), sdfSimple = new SimpleDateFormat("yyyyMMdd");
  545 + List<Iterator<?>> listI = new ArrayList<Iterator<?>>();
  546 + ReportUtils ee = new ReportUtils();
  547 + List<Daily> allline = formsService.daily(map);
  548 +
  549 + List<Map<String, Object>> resList = new ArrayList<Map<String, Object>>();
  550 + Float zgl=0f;
  551 + Float ks=0f;
  552 + Float yh=0f;
  553 + Float bc=0f;
  554 + Map<String, Object> m ;
  555 + for (Daily d : allline) {
  556 + m = new HashMap<String, Object>();
  557 + zgl +=d.getZlc()==""?0f:Float.valueOf(d.getZlc());
  558 + ks +=d.getJzl1()==""?0f:Float.valueOf(d.getJzl1());
  559 + yh +=d.getYh()==""?0f:Float.valueOf(d.getYh());
  560 + bc +=d.getBc()==""?0f:Float.valueOf(d.getBc());
  561 + m.put("zbh", d.getZbh());
  562 + m.put("jgh",d.getJgh());
  563 + m.put("jName", d.getjName());
  564 + m.put("zlc", d.getZlc());
  565 + m.put("jzl1", d.getJzl1());
  566 + m.put("yh", d.getYh());
  567 + m.put("bc", d.getBc());
  568 +
  569 + resList.add(m);
  570 + }
  571 +
  572 + m=new HashMap<String,Object>();
  573 + m.put("total_zgl", zgl);
  574 + m.put("total_ks", ks);
  575 + m.put("total_yh", yh);
  576 + m.put("total_bc", bc);
  577 +
  578 + m.put("line", BasicData.lineCode2NameMap.get(map.get("line").toString()));
  579 + m.put("date", map.get("date").toString());
  580 + try {
  581 + listI.add(resList.iterator());
  582 + String path = this.getClass().getResource("/").getPath() + "static\\pages\\forms\\";
  583 + ee.excelReplace(listI, new Object[] { m }, path + "mould\\daily.xls", path + "export\\班次日报表"
  584 + + sdfSimple.format(sdfMonth.parse(map.get("date").toString())) + ".xls");
  585 + } catch (Exception e) {
  586 + e.printStackTrace();
  587 + }
  588 + return resList;
  589 + }
  590 +
425 591  
426 592  
427 593 }
... ...
src/main/java/com/bsth/controller/forms/MCY_FormsController.java
... ... @@ -11,6 +11,7 @@ import org.springframework.web.bind.annotation.RestController;
11 11  
12 12 import com.bsth.entity.mcy_forms.Allline;
13 13 import com.bsth.entity.mcy_forms.Changetochange;
  14 +import com.bsth.entity.mcy_forms.Daily;
14 15 import com.bsth.entity.mcy_forms.Executionrate;
15 16 import com.bsth.entity.mcy_forms.Linepasswengerflow;
16 17 import com.bsth.entity.mcy_forms.Operationservice;
... ... @@ -112,4 +113,12 @@ public class MCY_FormsController {
112 113  
113 114 return formsService.allline(map);
114 115 }
  116 +
  117 + // 营运线路名称统计表
  118 + @RequestMapping(value = "/daily", method = RequestMethod.POST)
  119 + public List<Daily> daily(@RequestParam Map<String, Object> map) {
  120 +
  121 + return formsService.daily(map);
  122 + }
  123 +
115 124 }
... ...
src/main/java/com/bsth/controller/realcontrol/SignalStateController.java 0 → 100644
  1 +package com.bsth.controller.realcontrol;
  2 +
  3 +import com.bsth.data.gpsdata.SignalStateData;
  4 +import com.bsth.data.gpsdata.arrival.entity.SignalState;
  5 +import org.springframework.beans.factory.annotation.Autowired;
  6 +import org.springframework.web.bind.annotation.RequestMapping;
  7 +import org.springframework.web.bind.annotation.RequestParam;
  8 +import org.springframework.web.bind.annotation.RestController;
  9 +
  10 +import java.util.List;
  11 +
  12 +/**
  13 + * Created by panzhao on 2016/12/30.
  14 + */
  15 +@RestController
  16 +@RequestMapping("signalState")
  17 +public class SignalStateController {
  18 +
  19 + @Autowired
  20 + SignalStateData signalStateData;
  21 +
  22 + @RequestMapping("/multi")
  23 + public List<SignalState> findByMultiLine(@RequestParam String idx){
  24 + return signalStateData.get(idx);
  25 + }
  26 +}
... ...
src/main/java/com/bsth/data/BasicData.java
... ... @@ -26,12 +26,12 @@ import java.util.concurrent.TimeUnit;
26 26 */
27 27 @Component
28 28 public class BasicData implements CommandLineRunner {
29   -
30   - //公司代码和公司名对照(K: 公司编码,V:公司名)
31   - public static Map<String, String> businessCodeNameMap;
32   -
33   - //分公司公司代码和分公司公司名对照(K: 公司编码+分公司编码,V:分公司公司名)
34   - public static Map<String, String> businessFgsCodeNameMap;
  29 +
  30 + //公司代码和公司名对照(K: 公司编码,V:公司名)
  31 + public static Map<String, String> businessCodeNameMap;
  32 +
  33 + //分公司公司代码和分公司公司名对照(K: 公司编码+分公司编码,V:分公司公司名)
  34 + public static Map<String, String> businessFgsCodeNameMap;
35 35  
36 36 //设备号和车辆自编号 (K: 设备编码 ,V:车辆自编号)
37 37 public static BiMap<String, String> deviceId2NbbmMap;
... ... @@ -39,27 +39,21 @@ public class BasicData implements CommandLineRunner {
39 39 //车辆自编号和公司代码对照 (K: 车辆自编号 ,V:公司代码)
40 40 public static Map<String, String> nbbm2CompanyCodeMap;
41 41  
42   - //站点编码和名称对照,包括停车场 (K: 站点编码 ,V:站点名称)
  42 + //站点编码和名称对照,包括停车场 (K: lineCode_updown_stationCode ,V:站点名称)
43 43 public static Map<String, String> stationCode2NameMap;
44 44  
45 45 //线路起终点对照(线路编码_上下行_起终点) 1024_0_B (1024上行起点)
46   - public static Map<String, String> lineSEPointMap;
  46 + //public static Map<String, String> lineSEPointMap;
47 47  
48 48 //车辆和线路对照
49 49 public static Map<String, Line> nbbm2LineMap;
50 50  
51   - //线路和用户对照 用于webSocket定向推送消息(用户进入线调时写入数据)
52   - //public static TreeMultimap<String, String> lineCode2SocketUserMap = TreeMultimap.create();
53   -
54 51 //线路ID和code 对照
55 52 public static BiMap<Integer, String> lineId2CodeMap;
56 53  
57 54 //线路编码和名称对照
58 55 public static Map<String, String> lineCode2NameMap;
59 56  
60   - //线路编码_站点编码 == 0|1 上下行
61   - //public static Map<String, Integer> lineStationUpDownMap;
62   -
63 57 //停车场
64 58 public static List<String> parkCodeList;
65 59  
... ... @@ -77,7 +71,7 @@ public class BasicData implements CommandLineRunner {
77 71 public static Map<String, String> allPerson;
78 72  
79 73 //站点名和运管处编号 对照
80   - public static Map<String,Integer> stationName2YgcNumber;
  74 + public static Map<String, Integer> stationName2YgcNumber;
81 75  
82 76  
83 77 static Logger logger = LoggerFactory.getLogger(BasicData.class);
... ... @@ -90,6 +84,10 @@ public class BasicData implements CommandLineRunner {
90 84 Application.mainServices.scheduleWithFixedDelay(dataLoader, 2, 2, TimeUnit.HOURS);
91 85 }
92 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 + }
93 91  
94 92 @Component
95 93 public static class BasicDataLoader extends Thread {
... ... @@ -114,7 +112,7 @@ public class BasicData implements CommandLineRunner {
114 112  
115 113 @Autowired
116 114 PersonnelRepository personnelRepository;
117   -
  115 +
118 116 @Autowired
119 117 BusinessRepository businessRepository;
120 118  
... ... @@ -156,47 +154,24 @@ public class BasicData implements CommandLineRunner {
156 154 return 0;
157 155 }
158 156  
159   -
160   -/* private void loadStationRouteInfo() {
161   - Iterator<StationRoute> iterator = stationRouteRepository.findAllEffective().iterator();
162   -
163   - Map<String, String> sePointMap = new HashMap<>();
164   - //lineSEPointMap
165   - Map<String, Integer> map = new HashMap<>();
166   -
167   - StationRoute route;
168   - while (iterator.hasNext()) {
169   - route = iterator.next();
170   - map.put(route.getLineCode() + "_" + route.getStationCode(), route.getDirections());
171   -
172   - if (route.getStationMark() != null &&
173   - (route.getStationMark().equals("B") || route.getStationMark().equals("E"))) {
174   - sePointMap.put(route.getLineCode() + "_"
175   - + route.getDirections()
176   - + "_" + route.getStationMark(), route.getStationCode());
177   - }
178   - }
179   - lineStationUpDownMap = map;
180   - lineSEPointMap = sePointMap;
181   - }*/
182   -
183 157 /**
184 158 * loadBusinessInfo
185 159 * (公司代码公司名对照)
186 160 */
187   - public void loadBusinessInfo(){
188   - Map<String, String> businessMap=new HashMap<String,String>();
189   - Map<String, String> businessFgsMap=new HashMap<String,String>();
190   - Iterator<Business> busIter=businessRepository.findAll().iterator();
191   - Business t;
192   - while(busIter.hasNext()){
193   - t=busIter.next();
194   - businessMap.put(t.getBusinessCode(), t.getBusinessName());
195   - businessFgsMap.put(t.getBusinessCode()+"_"+t.getUpCode(), t.getBusinessName());
196   - }
197   - businessCodeNameMap=businessMap;
198   - businessFgsCodeNameMap=businessFgsMap;
  161 + public void loadBusinessInfo() {
  162 + Map<String, String> businessMap = new HashMap<String, String>();
  163 + Map<String, String> businessFgsMap = new HashMap<String, String>();
  164 + Iterator<Business> busIter = businessRepository.findAll().iterator();
  165 + Business t;
  166 + while (busIter.hasNext()) {
  167 + t = busIter.next();
  168 + businessMap.put(t.getBusinessCode(), t.getBusinessName());
  169 + businessFgsMap.put(t.getBusinessCode() + "_" + t.getUpCode(), t.getBusinessName());
  170 + }
  171 + businessCodeNameMap = businessMap;
  172 + businessFgsCodeNameMap = businessFgsMap;
199 173 }
  174 +
200 175 /**
201 176 * @Title: loadDeviceInfo
202 177 * @Description: TODO(加载设备相关信息)
... ... @@ -223,13 +198,13 @@ public class BasicData implements CommandLineRunner {
223 198 */
224 199 public void loadStationInfo() {
225 200 Map<String, String> stationCode2Name = new HashMap<>();
226   - Iterator<Station> iterator = stationRepository.findAll().iterator();
227   - //站点
228   - Station station;
  201 + Iterator<StationRoute> iterator = stationRouteRepository.findAll().iterator();
  202 + StationRoute sroute;
229 203 while (iterator.hasNext()) {
230   - station = iterator.next();
231   - stationCode2Name.put(station.getStationCod(), station.getStationName());
  204 + sroute = iterator.next();
  205 + stationCode2Name.put(sroute.getLineCode() + "_" + sroute.getDirections() + "_" + sroute.getStationCode(), sroute.getStationName());
232 206 }
  207 +
233 208 //停车场
234 209 Iterator<CarPark> iterator2 = carParkRepository.findAll().iterator();
235 210  
... ... @@ -266,7 +241,7 @@ public class BasicData implements CommandLineRunner {
266 241 * @Title: loadLineInfo
267 242 * @Description: TODO(加载线路相关信息)
268 243 */
269   - public void loadLineInfo(){
  244 + public void loadLineInfo() {
270 245 Iterator<Line> iterator = lineRepository.findAll().iterator();
271 246  
272 247 Line line;
... ... @@ -276,36 +251,36 @@ public class BasicData implements CommandLineRunner {
276 251 Map<String, String> code2SHcode = new HashMap<String, String>();
277 252 Map<String, Integer> tempStationName2YgcNumber = new HashMap<String, Integer>();
278 253  
279   - while(iterator.hasNext()){
  254 + while (iterator.hasNext()) {
280 255 line = iterator.next();
281 256 biMap.put(line.getId(), line.getLineCode());
282 257 code2name.put(line.getLineCode(), line.getName());
283   - id2SHcode.put(line.getId(),line.getShanghaiLinecode());
  258 + id2SHcode.put(line.getId(), line.getShanghaiLinecode());
284 259 code2SHcode.put(line.getLineCode(), line.getShanghaiLinecode());
285 260  
286 261 /**
287 262 * 加载运管处的站点及序号
288 263 * 上行从1开始,下行顺序续编
289 264  
290   - List<Object[]> ygcLines = stationRouteRepository.findAllLineWithYgc();
291   - if(ygcLines != null && ygcLines.size() > 0){
292   - int size = ygcLines.size();
293   - Object[] tempArray ;
294   - int num = 1;
295   - String key;
296   - String lineCode = "";
297   - for (int i = 0; i < size; i ++){
298   - tempArray = ygcLines.get(i);
299   - if(lineCode.equals("")){
300   - lineCode = tempArray[0]+"";
301   - }else if(!lineCode.equals(tempArray[0]+"")){
302   - num = 1;
303   - lineCode = tempArray[0]+"";
304   - }
305   - key = tempArray[0] + "_"+tempArray[1] + "_"+tempArray[2];
306   - tempStationName2YgcNumber.put(key,num++);
307   - }
308   - }*/
  265 + List<Object[]> ygcLines = stationRouteRepository.findAllLineWithYgc();
  266 + if(ygcLines != null && ygcLines.size() > 0){
  267 + int size = ygcLines.size();
  268 + Object[] tempArray ;
  269 + int num = 1;
  270 + String key;
  271 + String lineCode = "";
  272 + for (int i = 0; i < size; i ++){
  273 + tempArray = ygcLines.get(i);
  274 + if(lineCode.equals("")){
  275 + lineCode = tempArray[0]+"";
  276 + }else if(!lineCode.equals(tempArray[0]+"")){
  277 + num = 1;
  278 + lineCode = tempArray[0]+"";
  279 + }
  280 + key = tempArray[0] + "_"+tempArray[1] + "_"+tempArray[2];
  281 + tempStationName2YgcNumber.put(key,num++);
  282 + }
  283 + }*/
309 284 }
310 285  
311 286 lineId2CodeMap = biMap;
... ...
src/main/java/com/bsth/data/LineConfigData.java
... ... @@ -10,6 +10,7 @@ import org.slf4j.Logger;
10 10 import org.slf4j.LoggerFactory;
11 11 import org.springframework.beans.factory.annotation.Autowired;
12 12 import org.springframework.boot.CommandLineRunner;
  13 +import org.springframework.core.annotation.Order;
13 14 import org.springframework.stereotype.Component;
14 15  
15 16 import java.util.*;
... ... @@ -23,6 +24,7 @@ import java.util.*;
23 24 *
24 25 */
25 26 @Component
  27 +@Order(value = 2)
26 28 public class LineConfigData implements CommandLineRunner {
27 29  
28 30 Logger logger = LoggerFactory.getLogger(this.getClass());
... ...
src/main/java/com/bsth/data/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/GpsEntity.java
... ... @@ -86,7 +86,7 @@ public class GpsEntity {
86 86 private StationRoute station;
87 87  
88 88 /** 状态 */
89   - private String signalState;
  89 + private String signalState = "normal";
90 90  
91 91 public Integer getCompanyCode() {
92 92 return companyCode;
... ...
src/main/java/com/bsth/data/gpsdata/GpsRealData.java
... ... @@ -2,7 +2,6 @@ package com.bsth.data.gpsdata;
2 2  
3 3 import com.alibaba.fastjson.JSON;
4 4 import com.alibaba.fastjson.JSONObject;
5   -import com.bsth.Application;
6 5 import com.bsth.data.BasicData;
7 6 import com.bsth.data.forecast.ForecastRealServer;
8 7 import com.bsth.data.gpsdata.arrival.GpsRealAnalyse;
... ... @@ -26,7 +25,6 @@ import org.springframework.stereotype.Component;
26 25 import java.io.BufferedReader;
27 26 import java.io.InputStreamReader;
28 27 import java.util.*;
29   -import java.util.concurrent.TimeUnit;
30 28  
31 29 /**
32 30 * @author PanZhao
... ... @@ -67,12 +65,42 @@ public class GpsRealData implements CommandLineRunner {
67 65  
68 66 @Override
69 67 public void run(String... arg0) throws Exception {
70   - logger.info("gpsDataLoader,40,6");
71   - Application.mainServices.scheduleWithFixedDelay(gpsDataLoader, 40, 6, TimeUnit.SECONDS);
  68 + logger.info("gpsDataLoader,20,5");
  69 + //Application.mainServices.scheduleWithFixedDelay(gpsDataLoader, 20, 30, TimeUnit.SECONDS);
72 70 }
73 71  
74 72 public void put(GpsEntity gps) {
75   - gpsMap.put(gps.getDeviceId(), gps);
  73 + String device = gps.getDeviceId();
  74 + 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 + }
  92 +
  93 + //刷新对照
  94 + gpsMap.put(device, gps);
  95 + if (StringUtils.isNotBlank(gps.getLineId())) {
  96 + //站点名称
  97 + gps.setStationName(getStationName(gps));
  98 + lineCode2Devices.put(gps.getLineId(), device);
  99 + }
  100 + }
  101 +
  102 + public String getStationName(GpsEntity gps) {
  103 + return BasicData.getStationNameByCode(gps.getStopNo(), gps.getLineId() + "_" + gps.getUpDown() + "_");
76 104 }
77 105  
78 106 /**
... ... @@ -94,7 +122,7 @@ public class GpsRealData implements CommandLineRunner {
94 122 for (String device : set) {
95 123 gps = gpsMap.get(device);
96 124 //过滤异常GPS数据
97   - if (gps.isAbnormal())
  125 + if (gps == null || gps.isAbnormal())
98 126 continue;
99 127  
100 128 sch = dayOfSchedule.execPlanMap().get(gps.getNbbm());
... ...
src/main/java/com/bsth/data/gpsdata/SignalStateData.java 0 → 100644
  1 +package com.bsth.data.gpsdata;
  2 +
  3 +import com.bsth.data.gpsdata.arrival.entity.SignalState;
  4 +import com.bsth.websocket.handler.SendUtils;
  5 +import com.google.common.base.Splitter;
  6 +import com.google.common.collect.ArrayListMultimap;
  7 +import org.springframework.beans.factory.annotation.Autowired;
  8 +import org.springframework.stereotype.Component;
  9 +
  10 +import java.util.ArrayList;
  11 +import java.util.List;
  12 +
  13 +/**
  14 + * 信号状态数据
  15 + * Created by panzhao on 2016/12/30.
  16 + */
  17 +@Component
  18 +public class SignalStateData {
  19 +
  20 + @Autowired
  21 + SendUtils sendUtils;
  22 +
  23 + private static ArrayListMultimap<String, SignalState> listMultimap = ArrayListMultimap.create();
  24 +
  25 + public void put(SignalState state){
  26 + listMultimap.put(state.getLineCode(), state);
  27 + //推送到客户端
  28 + sendUtils.sendSignalState(state);
  29 + }
  30 +
  31 + public List<SignalState> get(String idx){
  32 + List<SignalState> rs = new ArrayList<>();
  33 + List<String> ids = Splitter.on(",").splitToList(idx);
  34 +
  35 + for(String lineCode : ids){
  36 + rs.addAll(listMultimap.get(lineCode));
  37 + }
  38 + return rs;
  39 + }
  40 +}
... ...
src/main/java/com/bsth/data/gpsdata/arrival/GeoCacheData.java
... ... @@ -29,8 +29,8 @@ public class GeoCacheData {
29 29  
30 30 static Logger logger = LoggerFactory.getLogger(GeoCacheData.class);
31 31  
32   - //每辆车缓存最后500条gps
33   - private static final int CACHE_SIZE = 500;
  32 + //每辆车缓存最后1000条gps
  33 + private static final int CACHE_SIZE = 1000;
34 34 private static Map<String, CircleQueue<GpsEntity>> gpsCacheMap = new HashMap<>();
35 35  
36 36 //线路路段走向
... ... @@ -75,7 +75,7 @@ public class GeoCacheData {
75 75 }
76 76 }
77 77  
78   - public static StationRoute getRouteCode(GpsEntity gps){
  78 + public static StationRoute getRouteCode(GpsEntity gps) {
79 79 return routeCodeMap.get(gps.getLineId() + "_" + gps.getUpDown() + "_" + gps.getStopNo());
80 80 }
81 81  
... ... @@ -94,6 +94,21 @@ public class GeoCacheData {
94 94 return null;
95 95 }
96 96  
  97 + public static List<StationRoute> midwayStation(String lineCode, int directions, String sCode, String eCode) {
  98 + List<StationRoute> list = getStationRoute(lineCode, directions), rs = new ArrayList<>();
  99 +
  100 + boolean flag = false;
  101 + for (StationRoute sr : list) {
  102 + if (flag)
  103 + rs.add(sr);
  104 + if (sr.getCode().equals(sCode))
  105 + flag = true;
  106 + else if (sr.getCode().equals(eCode))
  107 + break;
  108 + }
  109 + return rs;
  110 + }
  111 +
97 112 public static Polygon getTccPolygon(String code) {
98 113 return tccMap.get(code);
99 114 }
... ... @@ -191,4 +206,16 @@ public class GeoCacheData {
191 206 }
192 207 return cds;
193 208 }
  209 +
  210 + /**
  211 + * 是不是终点站
  212 + * @param lineId
  213 + * @param upDown
  214 + * @param stationCode
  215 + * @return
  216 + */
  217 + public static boolean isEndStation(String lineId, Integer upDown, String stationCode) {
  218 + StationRoute station = routeCodeMap.get(lineId + "_" + upDown + "_" + stationCode);
  219 + return station != null && station.getMark().equals("E");
  220 + }
194 221 }
195 222 \ No newline at end of file
... ...
src/main/java/com/bsth/data/gpsdata/arrival/GpsRealAnalyse.java
1 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 1 package com.bsth.data.gpsdata.arrival;
2 2  
3 3 import com.bsth.data.gpsdata.GpsEntity;
  4 +import com.bsth.data.gpsdata.arrival.entity.StationRoute;
4 5 import com.bsth.data.gpsdata.arrival.utils.CircleQueue;
  6 +import com.bsth.data.gpsdata.arrival.utils.GeoUtils;
  7 +import com.bsth.entity.realcontrol.ScheduleRealInfo;
  8 +
  9 +import java.util.List;
5 10  
6 11 /**
7 12 * Created by panzhao on 2016/12/27.
... ... @@ -14,64 +19,71 @@ public abstract class SignalHandle {
14 19 return prevs != null && prevs.size() > 0 && prevs.getTail() != null;
15 20 }
16 21  
  22 + protected boolean isDriftSignal(GpsEntity gps) {
  23 + return gps.getLat() == 0 || gps.getLon() == 0;
  24 + }
  25 +
17 26 /**
18 27 * 是不是异常信号
19 28 *
20 29 * @param gps
21   - * @return
22   - */
23   - protected boolean isAbnormal(GpsEntity gps) {
24   - return gps.getLat() == 0 || gps.getLon() == 0;
25   - }
  30 + * @return protected boolean isAbnormal(GpsEntity gps) {
  31 + return gps.getLat() == 0 || gps.getLon() == 0;
  32 + }*/
26 33  
27 34 /**
28 35 * 连续异常信号个数统计
29 36 *
30 37 * @param prevs
31   - * @return
  38 + * @return protected int abnormalCount(CircleQueue<GpsEntity> prevs) {
  39 + * int count = 0;
  40 + * <p>
  41 + * if (!isNotEmpty(prevs))
  42 + * return count;
  43 + * <p>
  44 + * GpsEntity[] array = (GpsEntity[]) prevs.getQueue();
  45 + * GpsEntity gps;
  46 + * for (int i = array.length - 1; i > 0; i--) {
  47 + * gps = array[i];
  48 + * <p>
  49 + * if (isAbnormal(gps))
  50 + * count++;
  51 + * else
  52 + * break;
  53 + * }
  54 + * <p>
  55 + * return count;
  56 + * }
32 57 */
33   - protected int abnormalCount(CircleQueue<GpsEntity> prevs) {
34   - int count = 0;
35 58  
36   - if (!isNotEmpty(prevs))
37   - return count;
38   -
39   - GpsEntity[] array = (GpsEntity[]) prevs.getQueue();
40   - GpsEntity gps;
41   - for (int i = array.length - 1; i > 0; i--) {
42   - gps = array[i];
43   -
44   - if (isAbnormal(gps))
45   - count++;
46   - else
47   - break;
  59 + protected void transformUpdown(GpsEntity gps, ScheduleRealInfo sch) {
  60 + int updown = Integer.parseInt(sch.getXlDir());
  61 + List<StationRoute> srs = GeoCacheData.getStationRoute(sch.getXlBm(), updown);
  62 + StationRoute station = GeoUtils.gpsInStation(gps, srs);
  63 + if (station != null) {
  64 + gps.setUpDown(updown);
  65 + gps.setStopNo(station.getCode());
48 66 }
49   -
50   - return count;
51 67 }
52 68  
53 69 /**
54   - * 车辆运行轨迹(最近20分钟)
55   - * 0:上行 1:下行 -1:未知
  70 + * 是否是从异常状态恢复的第一个信号
56 71 *
57 72 * @param gps
  73 + * @param prevs
58 74 * @return
59 75 */
60   - protected int runTrack(GpsEntity gps, CircleQueue<GpsEntity> prevs) {
61   - int rs = -1, count = 0;
62   -
63   - long et = gps.getTimestamp() - (1000 * 60 * 20);
64   - Object[] array = prevs.getQueue();
65   - GpsEntity prev;
66   - for(Object obj : array){
67   - prev = (GpsEntity) obj;
68   - if(prev.getTimestamp() < et)
69   - break;
70   -
  76 + protected boolean abnormalRecovery(GpsEntity gps, CircleQueue<GpsEntity> prevs) {
  77 + if (prevs == null || prevs.size() == 0)
  78 + return false;
71 79  
  80 + GpsEntity prev = prevs.getTail();
  81 + //从漂移状态恢复
  82 + if (isDriftSignal(prev)
  83 + && !isDriftSignal(gps)) {
  84 + return true;
72 85 }
73   - //for()
74   - return 0;
75   - }
76 86  
77   -}
  87 + return false;
  88 + }
  89 +}
78 90 \ No newline at end of file
... ...
src/main/java/com/bsth/data/gpsdata/arrival/entity/RouteReverse.java
... ... @@ -5,6 +5,7 @@ package com.bsth.data.gpsdata.arrival.entity;
5 5 */
6 6 public class RouteReverse {
7 7  
  8 + private String nbbm;
8 9 //反转个数
9 10 private int count;
10 11  
... ... @@ -14,18 +15,18 @@ public class RouteReverse {
14 15 //掉头站点
15 16 private String turned;
16 17  
17   - //开始时间
18   - private long st;
19   -
20 18 //掉头时间
21 19 private long zt;
22 20  
23   - //结束时间
24   - private long et;
  21 + //检测时间
  22 + private long ct;
25 23  
26 24 //是否闭合
27 25 private boolean close;
28 26  
  27 + //信号不明确
  28 + private boolean vague;
  29 +
29 30 public int getCount() {
30 31 return count;
31 32 }
... ... @@ -50,22 +51,6 @@ public class RouteReverse {
50 51 this.turned = turned;
51 52 }
52 53  
53   - public long getSt() {
54   - return st;
55   - }
56   -
57   - public void setSt(long st) {
58   - this.st = st;
59   - }
60   -
61   - public long getEt() {
62   - return et;
63   - }
64   -
65   - public void setEt(long et) {
66   - this.et = et;
67   - }
68   -
69 54 public boolean isClose() {
70 55 return close;
71 56 }
... ... @@ -81,4 +66,28 @@ public class RouteReverse {
81 66 public void setZt(long zt) {
82 67 this.zt = zt;
83 68 }
84   -}
  69 +
  70 + public long getCt() {
  71 + return ct;
  72 + }
  73 +
  74 + public void setCt(long ct) {
  75 + this.ct = ct;
  76 + }
  77 +
  78 + public String getNbbm() {
  79 + return nbbm;
  80 + }
  81 +
  82 + public void setNbbm(String nbbm) {
  83 + this.nbbm = nbbm;
  84 + }
  85 +
  86 + public boolean isVague() {
  87 + return vague;
  88 + }
  89 +
  90 + public void setVague(boolean vague) {
  91 + this.vague = vague;
  92 + }
  93 +}
85 94 \ No newline at end of file
... ...
src/main/java/com/bsth/data/gpsdata/arrival/entity/SignalAbnormal.java 0 → 100644
  1 +package com.bsth.data.gpsdata.arrival.entity;
  2 +
  3 +/**
  4 + * 班次信号异常(漂移 或 断线)
  5 + * Created by panzhao on 2016/12/31.
  6 + */
  7 +public class SignalAbnormal {
  8 +
  9 + private Long et;
  10 +
  11 + /** drift or reconnection */
  12 + private String abnormalType;
  13 +
  14 + private Long st;
  15 +
  16 + private String nearPoint;
  17 +
  18 + private String destCode;
  19 +
  20 + private Long ct;
  21 +
  22 + //0: 发车 1:到站
  23 + private int outOrIn;
  24 +
  25 + public Long getEt() {
  26 + return et;
  27 + }
  28 +
  29 + public void setEt(Long et) {
  30 + this.et = et;
  31 + }
  32 +
  33 + public String getAbnormalType() {
  34 + return abnormalType;
  35 + }
  36 +
  37 + public void setAbnormalType(String abnormalType) {
  38 + this.abnormalType = abnormalType;
  39 + }
  40 +
  41 + public Long getSt() {
  42 + return st;
  43 + }
  44 +
  45 + public void setSt(Long st) {
  46 + this.st = st;
  47 + }
  48 +
  49 + public String getNearPoint() {
  50 + return nearPoint;
  51 + }
  52 +
  53 + public void setNearPoint(String nearPoint) {
  54 + this.nearPoint = nearPoint;
  55 + }
  56 +
  57 + public Long getCt() {
  58 + return ct;
  59 + }
  60 +
  61 + public void setCt(Long ct) {
  62 + this.ct = ct;
  63 + }
  64 +
  65 + public int getOutOrIn() {
  66 + return outOrIn;
  67 + }
  68 +
  69 + public void setOutOrIn(int outOrIn) {
  70 + this.outOrIn = outOrIn;
  71 + }
  72 +
  73 + public String getDestCode() {
  74 + return destCode;
  75 + }
  76 +
  77 + public void setDestCode(String destCode) {
  78 + this.destCode = destCode;
  79 + }
  80 +}
... ...
src/main/java/com/bsth/data/gpsdata/arrival/entity/SignalState.java 0 → 100644
  1 +package com.bsth.data.gpsdata.arrival.entity;
  2 +
  3 +import com.bsth.data.BasicData;
  4 +import com.bsth.entity.realcontrol.ScheduleRealInfo;
  5 +import org.joda.time.format.DateTimeFormat;
  6 +import org.joda.time.format.DateTimeFormatter;
  7 +
  8 +/**
  9 + * 信号状态
  10 + * Created by panzhao on 2016/12/30.
  11 + */
  12 +public class SignalState {
  13 +
  14 + private String type;
  15 +
  16 + private Long st;
  17 +
  18 + //private Long checkTime;
  19 +
  20 + private Long schId;
  21 +
  22 + private String lineCode;
  23 +
  24 + private String text;
  25 +
  26 + private RouteReverse reverse;
  27 +
  28 + private SignalAbnormal signalAbnormal;
  29 +
  30 + private static DateTimeFormatter fmtHHmm = DateTimeFormat.forPattern("HH:mm");
  31 +
  32 + /**
  33 + * 记录区间调头
  34 + *
  35 + * @param sch
  36 + * @param reverse
  37 + * @return
  38 + */
  39 + public static SignalState reverseSignalSTate(ScheduleRealInfo sch, RouteReverse reverse) {
  40 + if(reverse.isVague())
  41 + return null;
  42 +
  43 + SignalState state = new SignalState();
  44 + state.setSchId(sch.getId());
  45 + state.setType("route_reverse");
  46 + //state.setCheckTime(System.currentTimeMillis());
  47 +
  48 + String stationName = BasicData.stationCode2NameMap.get(sch.getXlBm() + "_" + sch.getXlDir() + "_" + reverse.getTurned());
  49 + state.setText(fmtHHmm.print(reverse.getZt()) + " 从 " + stationName + " 站掉头");
  50 + state.setSt(sch.getFcsjActualTime());
  51 + state.setLineCode(sch.getXlBm());
  52 + state.setReverse(reverse);
  53 + return state;
  54 + }
  55 +
  56 + public static SignalState abnormalSignalSTate(ScheduleRealInfo sch, SignalAbnormal signalAbnormal) {
  57 + SignalState state = new SignalState();
  58 + state.setSchId(sch.getId());
  59 + state.setType("abnormal_signal");
  60 + //state.setCheckTime(signalAbnormal.getCt());
  61 + state.setLineCode(sch.getXlBm());
  62 +
  63 + String text = (fmtHHmm.print(signalAbnormal.getSt()) + " ~ " + fmtHHmm.print(signalAbnormal.getEt()));
  64 + String abnormType = signalAbnormal.getAbnormalType();
  65 + if (abnormType.equals("drift"))
  66 + text += "(GPS无效)";
  67 + else if (abnormType.equals("reconnection"))
  68 + text += "(信号丢失)";
  69 +
  70 + state.setText(text);
  71 + state.setSignalAbnormal(signalAbnormal);
  72 + return state;
  73 + }
  74 +
  75 + public String getType() {
  76 + return type;
  77 + }
  78 +
  79 + public void setType(String type) {
  80 + this.type = type;
  81 + }
  82 +
  83 + public long getSchId() {
  84 + return schId;
  85 + }
  86 +
  87 + public void setSchId(long schId) {
  88 + this.schId = schId;
  89 + }
  90 +
  91 + public String getLineCode() {
  92 + return lineCode;
  93 + }
  94 +
  95 + public void setLineCode(String lineCode) {
  96 + this.lineCode = lineCode;
  97 + }
  98 +
  99 + public Long getSt() {
  100 + return st;
  101 + }
  102 +
  103 + public void setSt(Long st) {
  104 + this.st = st;
  105 + }
  106 +
  107 + public String getText() {
  108 + return text;
  109 + }
  110 +
  111 + public void setText(String text) {
  112 + this.text = text;
  113 + }
  114 +
  115 + public RouteReverse getReverse() {
  116 + return reverse;
  117 + }
  118 +
  119 + public void setReverse(RouteReverse reverse) {
  120 + this.reverse = reverse;
  121 + }
  122 +
  123 + public SignalAbnormal getSignalAbnormal() {
  124 + return signalAbnormal;
  125 + }
  126 +
  127 + public void setSignalAbnormal(SignalAbnormal signalAbnormal) {
  128 + this.signalAbnormal = signalAbnormal;
  129 + }
  130 +}
... ...
src/main/java/com/bsth/data/gpsdata/arrival/handlers/InOutStationSignalHandle.java
1   -package com.bsth.data.gpsdata.arrival.handlers;
2   -
3   -import com.bsth.data.LineConfigData;
4   -import com.bsth.data.gpsdata.GpsEntity;
5   -import com.bsth.data.gpsdata.arrival.GeoCacheData;
6   -import com.bsth.data.gpsdata.arrival.SignalHandle;
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.GeoUtils;
10   -import com.bsth.data.schedule.DayOfSchedule;
11   -import com.bsth.entity.realcontrol.LineConfig;
12   -import com.bsth.entity.realcontrol.ScheduleRealInfo;
13   -import com.bsth.service.directive.DirectiveService;
14   -import com.bsth.websocket.handler.SendUtils;
15   -import org.slf4j.Logger;
16   -import org.slf4j.LoggerFactory;
17   -import org.springframework.beans.factory.annotation.Autowired;
18   -import org.springframework.stereotype.Component;
19   -
20   -import java.util.List;
21   -
22   -/**
23   - * 进出站动作处理
24   - * Created by panzhao on 2016/12/27.
25   - */
26   -@Component
27   -public class InOutStationSignalHandle extends SignalHandle{
28   -
29   - Logger logger = LoggerFactory.getLogger(this.getClass());
30   -
31   - @Autowired
32   - DayOfSchedule dayOfSchedule;
33   -
34   - @Autowired
35   - LineConfigData lineConfigData;
36   -
37   - @Autowired
38   - SendUtils sendUtils;
39   -
40   - @Autowired
41   - DirectiveService directiveService;
42   -
43   - @Override
44   - public boolean handle(GpsEntity gps, CircleQueue<GpsEntity> prevs) {
45   -
46   - if(isNotEmpty(prevs)){
47   - GpsEntity prev = prevs.getTail();
48   - if(isOutStation(gps, prev))
49   - outStation(gps, prev);
50   -
51   -
52   - if(isInStation(gps, prev))
53   - inStation(gps, prev);
54   - }
55   -
56   - return true;
57   - }
58   -
59   - private boolean isOutStation(GpsEntity gps, GpsEntity prev){
60   - //从站内到站外
61   - if(prev.getInstation() > 0 && gps.getInstation() == 0)
62   - return true;
63   -
64   - //从站内到另一个站内
65   - if(prev.getInstation() > 0 && gps.getInstation() > 0
66   - && !prev.getStopNo().equals(gps.getStopNo()))
67   - return true;
68   - return false;
69   - }
70   -
71   - private boolean isInStation(GpsEntity gps, GpsEntity prev){
72   - //从站外到站内
73   - if(prev.getInstation() == 0 && gps.getInstation() > 0
74   - /*&& !prev.getStopNo().equals(gps.getStopNo())*/){
75   - return true;
76   - }
77   -
78   - //从站内到另一个站内
79   - if(prev.getInstation() > 0 && gps.getInstation() > 0
80   - && !prev.getStopNo().equals(gps.getStopNo()))
81   - return true;
82   - return false;
83   - }
84   -
85   - /**
86   - * 出站
87   - * @param gps 当前点
88   - * @param prev 上一个点
89   - */
90   - private void outStation(GpsEntity gps, GpsEntity prev) {
91   - ScheduleRealInfo sch = dayOfSchedule.executeCurr(gps.getNbbm());
92   - String qdzCode = sch.getQdzCode();
93   -
94   -
95   - //if(sch.getFcsjActual() != )
96   -
97   - //起点发车
98   - if(qdzCode != null && prev.getStopNo().equals(qdzCode)
99   - && !willDepart(gps, prev, sch)){
100   -
101   - sch.setFcsjActualAll(gps.getTimestamp());
102   - //通知客户端
103   - sendUtils.sendFcsj(sch);
104   - //持久化
105   - dayOfSchedule.save(sch);
106   -
107   - //出站既出场
108   - outStationAndOutPark(sch);
109   - logger.info("班次:" + sch.getDfsj() + "发车, 时间:" + sch.getFcsjActual());
110   - }
111   - }
112   -
113   - private void outStationAndOutPark(ScheduleRealInfo sch){
114   - LineConfig config = lineConfigData.get(sch.getXlBm());
115   - if (config != null && config.getOutConfig() == 2) {
116   - //出站既出场
117   - ScheduleRealInfo schPrev = dayOfSchedule.prev(sch);
118   - if (schPrev != null && schPrev.getBcType().equals("out")) {
119   - schPrev.setFcsjActualAll(sch.getFcsjActual());
120   - schPrev.setZdsjActualAll(sch.getFcsjActual());
121   - }
122   - }
123   - }
124   -
125   - /**
126   - * 进站
127   - * @param gps 当前点
128   - * @param prev 上一个点
129   - */
130   - private void inStation(GpsEntity gps, GpsEntity prev){
131   - ScheduleRealInfo sch = dayOfSchedule.executeCurr(gps.getNbbm());
132   - String zdzCode = sch.getZdzCode();
133   -
134   - if(zdzCode != null && gps.getStopNo().equals(zdzCode)){
135   -
136   - sch.setZdsjActualAll(gps.getTimestamp());
137   - //已完成班次数
138   - int doneSum = dayOfSchedule.doneSum(sch.getClZbh());
139   - ScheduleRealInfo next = dayOfSchedule.next(sch);
140   - //通知客户端
141   - sendUtils.sendZdsj(sch, next, doneSum);
142   - //持久化
143   - dayOfSchedule.save(sch);
144   - //下发调度指令
145   - //directiveService.send60Dispatch(next, doneSum, "到站@系统");
146   -
147   - //准备执行下一个班次
148   - if (next != null) {
149   - next.setQdzArrDatesj(sch.getZdsjActual());
150   - dayOfSchedule.addExecPlan(next);
151   -
152   - //进站既进场
153   - inStationAndInPark(sch, next);
154   -
155   - //将gps转换为下一个班次走向的站内信号
156   - int updown = Integer.parseInt(next.getXlDir());
157   - List<StationRoute> srs = GeoCacheData.getStationRoute(next.getXlBm(), updown);
158   - StationRoute station = GeoUtils.gpsInStation(gps, srs);
159   - if (station != null) {
160   - gps.setUpDown(updown);
161   - gps.setStopNo(station.getCode());
162   - }
163   - }
164   - }
165   - /* //如果出场班次计划终点时间5分钟后还未完成,检查一下车辆轨迹,是否已经在执行线路上班次
166   - else if(sch.getBcType().equals("out")
167   - && sch.getZdsj() != null
168   - && gps.getTimestamp() - sch.getZdsjT() >= 1000 * 60 * 5){
169   - logger.info("出场班次计划终点时间5分钟后还未完成");
170   -
171   - }*/
172   - }
173   -
174   - /**
175   - * 进站既进场
176   - * @param sch
177   - */
178   - private void inStationAndInPark(ScheduleRealInfo sch, ScheduleRealInfo next){
179   - LineConfig config = lineConfigData.get(sch.getXlBm());
180   - if (next.getBcType().equals("in") &&
181   - config != null && config.getOutConfig() == 2) {
182   - next.setFcsjActualAll(sch.getZdsjActual());
183   - next.setZdsjActualAll(sch.getZdsjActual());
184   - }
185   - }
186   -
187   - /**
188   - * 发车漂移判定(这里出现的误判,由车辆到达中途站的时候补偿)
189   - * @param gps
190   - * @param prev
191   - * @param task
192   - * @return
193   - */
194   - private boolean willDepart(GpsEntity gps, GpsEntity prev, Object task){
195   -
196   -/* ScheduleRealInfo sch = (ScheduleRealInfo) task;
197   - ScheduleRealInfo prevTask = dayOfSchedule.prev(sch);
198   - if(prevTask == null || prevTask.getBcType().equals("out"))
199   - return false;
200   -
201   - //计划停站时间
202   - int stopTimePlan = (int) (sch.getDfsjT() - prevTask.getZdsjT());
203   -
204   - if(stopTimePlan < 1000 * 60 * 10)
205   - return false;
206   -
207   - //实际停站时间
208   - if(prevTask.getZdsjActual() != null){
209   - int actualTime = (int) (gps.getTimestamp() - prevTask.getZdsjActualTime());
210   -
211   - if(actualTime < stopTimePlan * 0.8){
212   - logger.info("漂移判定");
213   -
214   - return true;
215   - }
216   - }*/
217   - return false;
218   - }
219   -}
  1 +package com.bsth.data.gpsdata.arrival.handlers;
  2 +
  3 +import com.bsth.data.LineConfigData;
  4 +import com.bsth.data.gpsdata.GpsEntity;
  5 +import com.bsth.data.gpsdata.arrival.SignalHandle;
  6 +import com.bsth.data.gpsdata.arrival.utils.CircleQueue;
  7 +import com.bsth.data.gpsdata.arrival.utils.ScheduleSignalState;
  8 +import com.bsth.data.gpsdata.arrival.utils.SignalSchPlanMatcher;
  9 +import com.bsth.data.schedule.DayOfSchedule;
  10 +import com.bsth.entity.realcontrol.LineConfig;
  11 +import com.bsth.entity.realcontrol.ScheduleRealInfo;
  12 +import com.bsth.service.directive.DirectiveService;
  13 +import com.bsth.websocket.handler.SendUtils;
  14 +import org.apache.commons.lang3.StringUtils;
  15 +import org.slf4j.Logger;
  16 +import org.slf4j.LoggerFactory;
  17 +import org.springframework.beans.factory.annotation.Autowired;
  18 +import org.springframework.stereotype.Component;
  19 +
  20 +/**
  21 + * 进出站动作处理
  22 + * Created by panzhao on 2016/12/27.
  23 + */
  24 +@Component
  25 +public class InOutStationSignalHandle extends SignalHandle{
  26 +
  27 + Logger logger = LoggerFactory.getLogger(this.getClass());
  28 +
  29 + @Autowired
  30 + DayOfSchedule dayOfSchedule;
  31 +
  32 + @Autowired
  33 + LineConfigData lineConfigData;
  34 +
  35 + @Autowired
  36 + SendUtils sendUtils;
  37 +
  38 + @Autowired
  39 + DirectiveService directiveService;
  40 +
  41 + @Autowired
  42 + ScheduleSignalState scheduleSignalState;
  43 +
  44 + @Autowired
  45 + SignalSchPlanMatcher signalSchPlanMatcher;
  46 +
  47 + private final static int MAX_BEFORE_TIME = 1000 * 60 * 72;
  48 +
  49 + @Override
  50 + public boolean handle(GpsEntity gps, CircleQueue<GpsEntity> prevs) {
  51 + //忽略漂移信号
  52 + if(isDriftSignal(gps))
  53 + return false;
  54 +
  55 + //从异常状态恢复的第一个信号
  56 + if(abnormalRecovery(gps, prevs)){
  57 + //回溯一下之前的轨迹
  58 + scheduleSignalState.signalRetrospect(gps);
  59 + }
  60 +
  61 + if(isNotEmpty(prevs)){
  62 + GpsEntity prev = prevs.getTail();
  63 + if(isOutStation(gps, prev))
  64 + outStation(gps, prev);
  65 +
  66 +
  67 + if(isInStation(gps, prev))
  68 + inStation(gps, prev);
  69 + }
  70 +
  71 + return true;
  72 + }
  73 +
  74 + private boolean isOutStation(GpsEntity gps, GpsEntity prev){
  75 + //从站内到站外
  76 + if(prev.getInstation() > 0 && gps.getInstation() == 0)
  77 + return true;
  78 +
  79 + //从站内到另一个站内
  80 + if(prev.getInstation() > 0 && gps.getInstation() > 0
  81 + && !prev.getStopNo().equals(gps.getStopNo()))
  82 + return true;
  83 + return false;
  84 + }
  85 +
  86 + private boolean isInStation(GpsEntity gps, GpsEntity prev){
  87 + //从站外到站内
  88 + if(prev.getInstation() == 0 && gps.getInstation() > 0
  89 + /*&& !prev.getStopNo().equals(gps.getStopNo())*/){
  90 + return true;
  91 + }
  92 +
  93 + //从站内到另一个站内
  94 + if(prev.getInstation() > 0 && gps.getInstation() > 0
  95 + && !prev.getStopNo().equals(gps.getStopNo()))
  96 + return true;
  97 + return false;
  98 + }
  99 +
  100 + /**
  101 + * 出站
  102 + * @param gps 当前点
  103 + * @param prev 上一个点
  104 + */
  105 + private void outStation(GpsEntity gps, GpsEntity prev) {
  106 + ScheduleRealInfo sch = dayOfSchedule.executeCurr(gps.getNbbm());
  107 + String qdzCode = sch.getQdzCode();
  108 +
  109 + //首班出场最多提前1.2小时
  110 + if(dayOfSchedule.isFirstOut(sch) && sch.getDfsjT() - gps.getTimestamp() > MAX_BEFORE_TIME)
  111 + return;
  112 +
  113 + //起点发车
  114 + if(qdzCode != null && prev.getStopNo().equals(qdzCode)
  115 + && !willDepart(gps, prev, sch)){
  116 +
  117 + //发车班次匹配
  118 + signalSchPlanMatcher.outMatch(gps, sch);
  119 + sch = dayOfSchedule.executeCurr(gps.getNbbm());
  120 +
  121 + //实发时间不覆盖
  122 + if(StringUtils.isNotEmpty(sch.getFcsjActual()))
  123 + return;
  124 +
  125 + //实发时间
  126 + sch.setFcsjActualAll(gps.getTimestamp());
  127 + //通知客户端
  128 + sendUtils.sendFcsj(sch);
  129 + //持久化
  130 + dayOfSchedule.save(sch);
  131 +
  132 + //出站既出场
  133 + outStationAndOutPark(sch);
  134 + logger.info("班次:" + sch.getDfsj() + "发车, 时间:" + sch.getFcsjActual());
  135 + }
  136 + else if(sch.getBcType().equals("out")){
  137 + ScheduleRealInfo next = dayOfSchedule.nextSame(sch);
  138 + if(prev.getStopNo().equals(next.getQdzCode())){
  139 + //发下一个班次
  140 + dayOfSchedule.addExecPlan(next);
  141 + outStation(gps, prev);
  142 + }
  143 + }
  144 + }
  145 +
  146 +
  147 + private void outStationAndOutPark(ScheduleRealInfo sch){
  148 + LineConfig config = lineConfigData.get(sch.getXlBm());
  149 + if (config != null && config.getOutConfig() == 2) {
  150 + //出站既出场
  151 + ScheduleRealInfo schPrev = dayOfSchedule.prev(sch);
  152 + if (schPrev != null && schPrev.getBcType().equals("out")) {
  153 + schPrev.setFcsjActualAll(sch.getFcsjActualTime());
  154 + schPrev.setZdsjActualAll(sch.getFcsjActualTime());
  155 +
  156 + sendUtils.refreshSch(schPrev);
  157 + }
  158 + }
  159 + }
  160 +
  161 + /**
  162 + * 进站
  163 + * @param gps 当前点
  164 + * @param prev 上一个点
  165 + */
  166 + private void inStation(GpsEntity gps, GpsEntity prev){
  167 + ScheduleRealInfo sch = dayOfSchedule.executeCurr(gps.getNbbm());
  168 +
  169 + if(gps.getStopNo().equals(sch.getZdzCode())){
  170 +
  171 + //实达时间不覆盖
  172 + if(StringUtils.isNotEmpty(sch.getZdsjActual()))
  173 + return;
  174 +
  175 + sch.setZdsjActualAll(gps.getTimestamp());
  176 + //已完成班次数
  177 + int doneSum = dayOfSchedule.doneSum(sch.getClZbh());
  178 + ScheduleRealInfo next = dayOfSchedule.next(sch);
  179 + //通知客户端
  180 + sendUtils.sendZdsj(sch, next, doneSum);
  181 + //持久化
  182 + dayOfSchedule.save(sch);
  183 + //下发调度指令
  184 + //directiveService.send60Dispatch(next, doneSum, "到站@系统");
  185 +
  186 + //准备执行下一个班次
  187 + if (next != null) {
  188 + next.setQdzArrDatesj(sch.getZdsjActual());
  189 + dayOfSchedule.addExecPlan(next);
  190 + //进站既进场
  191 + inStationAndInPark(sch, next);
  192 + //将gps转换为下一个班次走向的站内信号
  193 + transformUpdown(gps, sch);
  194 + }
  195 + }
  196 + else if(sch.getFcsjActual() == null){
  197 + //有进站,但班次没有实发,向前追溯一下信号
  198 + scheduleSignalState.signalRetrospect(gps, sch);
  199 + }
  200 + }
  201 +
  202 + /**
  203 + * 进站既进场
  204 + * @param sch
  205 + */
  206 + private void inStationAndInPark(ScheduleRealInfo sch, ScheduleRealInfo next){
  207 + LineConfig config = lineConfigData.get(sch.getXlBm());
  208 + if (next.getBcType().equals("in") &&
  209 + config != null && config.getOutConfig() == 2) {
  210 + next.setFcsjActualAll(sch.getZdsjActualTime());
  211 + next.setZdsjActualAll(sch.getZdsjActualTime());
  212 +
  213 + sendUtils.refreshSch(next);
  214 + }
  215 + }
  216 +
  217 + /**
  218 + * 发车漂移判定(这里出现的误判,由车辆到达中途站的时候补偿)
  219 + * @param gps
  220 + * @param prev
  221 + * @param task
  222 + * @return
  223 + */
  224 + private boolean willDepart(GpsEntity gps, GpsEntity prev, Object task){
  225 +
  226 + /*ScheduleRealInfo sch = (ScheduleRealInfo) task;
  227 + ScheduleRealInfo prevTask = dayOfSchedule.prev(sch);
  228 + if(prevTask == null || prevTask.getBcType().equals("out"))
  229 + return false;
  230 +
  231 + //计划停站时间
  232 + int stopTimePlan = (int) (sch.getDfsjT() - prevTask.getZdsjT());
  233 +
  234 + if(stopTimePlan < 1000 * 60 * 10)
  235 + return false;
  236 +
  237 + //实际停站时间
  238 + if(prevTask.getZdsjActual() != null){
  239 + int actualTime = (int) (gps.getTimestamp() - prevTask.getZdsjActualTime());
  240 +
  241 + if(actualTime < stopTimePlan * 0.8){
  242 + logger.info("漂移判定");
  243 +
  244 + return true;
  245 + }
  246 + }*/
  247 + return false;
  248 + }
  249 +}
220 250 \ No newline at end of file
... ...
src/main/java/com/bsth/data/gpsdata/arrival/handlers/OfflineSignalHandle.java
... ... @@ -13,16 +13,17 @@ import org.springframework.stereotype.Component;
13 13 @Component
14 14 public class OfflineSignalHandle extends SignalHandle{
15 15  
16   - //断开3分钟,标记为重连信号
17   - private final static int OFFLINE_TIME = 1000 * 60 * 3;
  16 + //断开2分钟,标记为重连信号
  17 + private final static int OFFLINE_TIME = 1000 * 60 * 2;
18 18  
19 19 //断开70分钟,之前的信号不再有参考价值
20 20 private final static int CLEAR_TIME = 1000 * 60 * 70;
21 21  
22 22 @Override
23 23 public boolean handle(GpsEntity gps, CircleQueue<GpsEntity> prevs) {
24   - //异常信号不管
25   - if(isAbnormal(gps)){
  24 + //漂移信号不管
  25 + if(isDriftSignal(gps)){
  26 + gps.setSignalState("drift");
26 27 return true;
27 28 }
28 29  
... ... @@ -39,4 +40,4 @@ public class OfflineSignalHandle extends SignalHandle{
39 40 }
40 41 return true;
41 42 }
42   -}
  43 +}
43 44 \ No newline at end of file
... ...
src/main/java/com/bsth/data/gpsdata/arrival/handlers/ReverseSignalHandle.java
1 1 package com.bsth.data.gpsdata.arrival.handlers;
2 2  
3   -import com.alibaba.fastjson.JSON;
4 3 import com.bsth.data.gpsdata.GpsEntity;
5 4 import com.bsth.data.gpsdata.arrival.GeoCacheData;
6 5 import com.bsth.data.gpsdata.arrival.SignalHandle;
7 6 import com.bsth.data.gpsdata.arrival.entity.RouteReverse;
8 7 import com.bsth.data.gpsdata.arrival.entity.StationRoute;
9 8 import com.bsth.data.gpsdata.arrival.utils.CircleQueue;
  9 +import com.bsth.data.gpsdata.arrival.utils.ScheduleSignalState;
10 10 import com.bsth.data.schedule.DayOfSchedule;
11   -import com.bsth.entity.realcontrol.ScheduleRealInfo;
12 11 import org.slf4j.Logger;
13 12 import org.slf4j.LoggerFactory;
14 13 import org.springframework.beans.factory.annotation.Autowired;
... ... @@ -26,6 +25,9 @@ public class ReverseSignalHandle extends SignalHandle {
26 25 @Autowired
27 26 DayOfSchedule dayOfSchedule;
28 27  
  28 + @Autowired
  29 + ScheduleSignalState scheduleSignalState;
  30 +
29 31 @Override
30 32 public boolean handle(GpsEntity gps, CircleQueue<GpsEntity> prevs) {
31 33 if (!isNotEmpty(prevs))
... ... @@ -36,17 +38,10 @@ public class ReverseSignalHandle extends SignalHandle {
36 38 if (isReverse(gps, prev)) {
37 39 RouteReverse reverse = reverseSearch(prevs, gps);
38 40  
39   - if (reverse.getCount() >= 2) {
40   - //切换到下一个班次
41   - ScheduleRealInfo sch = dayOfSchedule.executeCurr(gps.getNbbm());
42   - if (sch.getBcType().equals("out") && sch.getZdsjT() != null && sch.getZdsjT() > gps.getTimestamp()) {
43   - return false;
44   - }
45   - dayOfSchedule.addExecPlan(dayOfSchedule.next(sch));
46   -
47   - if (reverse.isClose()) {
48   - logger.info("区间掉头,车辆:" + gps.getNbbm() + " -" + JSON.toJSONString(reverse));
49   - }
  41 + if (reverse.getCount() >= 4
  42 + && reverse.isClose()
  43 + && !GeoCacheData.isEndStation(gps.getLineId(), gps.getUpDown(), reverse.getTurned())) {
  44 + scheduleSignalState.reverseAnalyse(reverse);
50 45 }
51 46 }
52 47 return false;
... ... @@ -63,7 +58,8 @@ public class ReverseSignalHandle extends SignalHandle {
63 58 RouteReverse routeReverse = new RouteReverse();
64 59 int count = 0;
65 60 String path = "";
66   - String turned = null;
  61 + long zt = 0L;
  62 + boolean half = false;
67 63  
68 64 //当前站点
69 65 StationRoute curr = GeoCacheData.getRouteCode(gps), sr;
... ... @@ -72,22 +68,29 @@ public class ReverseSignalHandle extends SignalHandle {
72 68 for (int i = array.length - 1; i > 0; i--) {
73 69 prev = (GpsEntity) array[i];
74 70  
75   - if(!prev.getUpDown().equals(gps.getUpDown()))
  71 + if (!prev.getUpDown().equals(gps.getUpDown())
  72 + || prev.getSignalState().equals("reconnection"))
76 73 break;
77 74  
78 75 if (prev.getInstation() == 1) {
79 76 sr = GeoCacheData.getRouteCode(prev);
80 77  
81 78 if (sr.getRouteSort() > curr.getRouteSort()) {
  79 + if(half){
  80 + routeReverse.setVague(true);
  81 + }
  82 +
82 83 path += (curr.getCode() + ",");
83 84 count++;
  85 + zt = prev.getTimestamp();
84 86 } else if (sr.getRouteSort() < curr.getRouteSort()) {
85   - path += (curr.getCode() + ",");
86   - //掉头点
87   - if (turned == null)
88   - turned = prev.getStopNo();
  87 + if (routeReverse.getTurned() == null) {
  88 + routeReverse.setTurned(curr.getCode());
  89 + half = true;
  90 + }
89 91  
90   - //路径闭合
  92 + path += (curr.getCode() + ",");
  93 + //掉头前当前站
91 94 if (sr.getCode().equals(gps.getStopNo())) {
92 95 routeReverse.setClose(true);
93 96 path += sr.getCode();
... ... @@ -99,9 +102,11 @@ public class ReverseSignalHandle extends SignalHandle {
99 102 }
100 103 }
101 104  
  105 + routeReverse.setZt(zt);
102 106 routeReverse.setCount(count);
103 107 routeReverse.setDetail(path);
104   - routeReverse.setTurned(turned);
  108 + routeReverse.setCt(gps.getTimestamp());
  109 + routeReverse.setNbbm(gps.getNbbm());
105 110 return routeReverse;
106 111 }
107 112  
... ... @@ -129,4 +134,4 @@ public class ReverseSignalHandle extends SignalHandle {
129 134 }
130 135 return false;
131 136 }
132   -}
  137 +}
133 138 \ No newline at end of file
... ...
src/main/java/com/bsth/data/gpsdata/arrival/utils/CircleQueue.java
... ... @@ -105,8 +105,8 @@ public class CircleQueue&lt;T&gt; {
105 105 }
106 106 }
107 107 } else {
108   - elementDataSort = new Object[tail];
109   - for (int i = 0; i < tail; i++) {
  108 + elementDataSort = new Object[tail + 1];
  109 + for (int i = 0; i <= tail; i++) {
110 110 elementDataSort[i] = elementDataCopy[i];
111 111 }
112 112 }
... ...
src/main/java/com/bsth/data/gpsdata/arrival/utils/ScheduleSignalState.java 0 → 100644
  1 +package com.bsth.data.gpsdata.arrival.utils;
  2 +
  3 +import com.bsth.data.LineConfigData;
  4 +import com.bsth.data.gpsdata.GpsEntity;
  5 +import com.bsth.data.gpsdata.SignalStateData;
  6 +import com.bsth.data.gpsdata.arrival.GeoCacheData;
  7 +import com.bsth.data.gpsdata.arrival.entity.RouteReverse;
  8 +import com.bsth.data.gpsdata.arrival.entity.SignalAbnormal;
  9 +import com.bsth.data.gpsdata.arrival.entity.SignalState;
  10 +import com.bsth.data.schedule.DayOfSchedule;
  11 +import com.bsth.entity.realcontrol.LineConfig;
  12 +import com.bsth.entity.realcontrol.ScheduleRealInfo;
  13 +import org.slf4j.Logger;
  14 +import org.slf4j.LoggerFactory;
  15 +import org.springframework.beans.factory.annotation.Autowired;
  16 +import org.springframework.stereotype.Component;
  17 +
  18 +/**
  19 + * 班次信号状态分析
  20 + * Created by panzhao on 2016/12/29.
  21 + */
  22 +@Component
  23 +public class ScheduleSignalState {
  24 +
  25 + @Autowired
  26 + DayOfSchedule dayOfSchedule;
  27 +
  28 + Logger logger = LoggerFactory.getLogger(this.getClass());
  29 +
  30 + @Autowired
  31 + LineConfigData lineConfigData;
  32 +
  33 + @Autowired
  34 + SignalStateData signalStateData;
  35 +
  36 + /**
  37 + * 路由反向分析
  38 + */
  39 + public void reverseAnalyse(RouteReverse reverse) {
  40 + ScheduleRealInfo sch = dayOfSchedule.executeCurr(reverse.getNbbm());
  41 +
  42 + String bcType = sch.getBcType();
  43 +
  44 + switch (bcType) {
  45 + case "out":
  46 + outReverseAnalyse(sch, reverse);
  47 + break;
  48 + case "normal":
  49 + normalReverseAnalyse(sch, reverse);
  50 + break;
  51 + }
  52 + }
  53 +
  54 + /**
  55 + * 出场班次路由反向分析
  56 + *
  57 + * @param sch
  58 + */
  59 + private void outReverseAnalyse(ScheduleRealInfo sch, RouteReverse reverse) {
  60 + long t = reverse.getCt();
  61 + //出场班次终点时间前,允许反向轨迹
  62 + if (sch.getZdsjT() != null && sch.getZdsjT() > t) {
  63 + return;
  64 + }
  65 +
  66 + int rt;
  67 + //从实发 到 当前时间 < 计划运送时间 * 0.9
  68 + if (sch.getFcsjActual() != null && sch.getBcsj() != null) {
  69 + rt = (int) (t - sch.getFcsjActualTime());
  70 + if (rt < sch.getBcsj() * 0.9)
  71 + return;
  72 + }
  73 +
  74 + ScheduleRealInfo next = dayOfSchedule.next(sch);
  75 + if (next.getXlDir().equals(sch.getXlDir()))
  76 + return;
  77 +
  78 + //时间足够下一个班次待发时间运行到当前站
  79 + int runTime = reverse.getCount() * 1500 * 60;
  80 + if (next.getDfsjT() + runTime < t) {
  81 + //跳到下一个班次
  82 + dayOfSchedule.addExecPlan(next);
  83 + }
  84 + }
  85 +
  86 + /**
  87 + * 正常班次路由反向分析
  88 + *
  89 + * @param sch
  90 + * @param reverse
  91 + */
  92 + private void normalReverseAnalyse(ScheduleRealInfo sch, RouteReverse reverse) {
  93 + LineConfig conf = lineConfigData.get(sch.getXlBm());
  94 +
  95 + if (conf.isReadReverse()) {
  96 + //跳下一个班次
  97 + ScheduleRealInfo next = dayOfSchedule.next(sch);
  98 + if (next != null)
  99 + dayOfSchedule.addExecPlan(next);
  100 +
  101 + //记录信号状态
  102 + SignalState signalState = SignalState.reverseSignalSTate(sch, reverse);
  103 + if(signalState != null)
  104 + signalStateData.put(signalState);
  105 + }
  106 + }
  107 +
  108 + public void signalRetrospect(GpsEntity gps) {
  109 + signalRetrospect(gps, dayOfSchedule.executeCurr(gps.getNbbm()));
  110 + }
  111 +
  112 + /**
  113 + * 信号追溯
  114 + *
  115 + * @param gps
  116 + * @param sch
  117 + */
  118 + public void signalRetrospect(GpsEntity gps, ScheduleRealInfo sch) {
  119 + //回放数据,是否有掉线或者漂移
  120 + CircleQueue<GpsEntity> queue = GeoCacheData.getGps(gps.getNbbm());
  121 + if (queue == null || queue.size() == 0 /*|| gps.getInstation() == 0*/)
  122 + return;
  123 +
  124 + //起始时间点
  125 + long st = 0;
  126 + ScheduleRealInfo prev = dayOfSchedule.prev(sch);
  127 +
  128 + if (prev != null) {
  129 + if (prev.getZdsjActual() != null)
  130 + st = prev.getZdsjActualTime();
  131 + else
  132 + st = (GeoCacheData.midwayStation(gps.getLineId(), gps.getUpDown(), sch.getQdzCode(), gps.getStopNo()).size() + 1) * (1000 * 60 * 5);
  133 + }
  134 +
  135 + Object[] tempArray = queue.getQueue();
  136 + int len = tempArray.length;
  137 +
  138 + Object[] array = new Object[len + 1];
  139 + System.arraycopy(tempArray, 0, array, 0, len);
  140 + array[len] = gps;
  141 +
  142 + String gpsState = "";
  143 + GpsEntity tempGps, nearGps = null;
  144 + int i = len - 1;
  145 + for (; i >= 0; i--) {
  146 + tempGps = (GpsEntity) array[i];
  147 +
  148 + gpsState = tempGps.getSignalState();
  149 + if (gpsState.equals("truncation"))
  150 + break;
  151 + else if (gpsState.equals("drift")) {
  152 + nearGps = (GpsEntity) array[i + 1];
  153 + break;
  154 + } else if (gpsState.equals("reconnection")) {
  155 + nearGps = tempGps;
  156 + break;
  157 + }
  158 +
  159 + if (tempGps.getTimestamp() < st)
  160 + break;
  161 + }
  162 +
  163 + if (nearGps != null && i > 0) {
  164 + createSignalAbnormal(gpsState, nearGps, i, array, sch);
  165 + }
  166 + }
  167 +
  168 + private void createSignalAbnormal(String gpsState, GpsEntity nearGps, int i, Object[] array, ScheduleRealInfo sch) {
  169 + switch (gpsState) {
  170 + case "drift":
  171 + driftSignalAbnormal(nearGps, i, array, sch);
  172 + break;
  173 + case "reconnection":
  174 + offlineSignalAbnormal(nearGps, ((GpsEntity) array[i - 1]), sch);
  175 + break;
  176 + }
  177 + }
  178 +
  179 + /**
  180 + * 掉线异常状态记录
  181 + *
  182 + * @param e
  183 + * @param s
  184 + */
  185 + private void offlineSignalAbnormal(GpsEntity e, GpsEntity s, ScheduleRealInfo sch) {
  186 + long st = s.getTimestamp(), et = e.getTimestamp();
  187 +
  188 + //掉线超过10分钟才记录
  189 + if (et - st < (1000 * 60 * 10))
  190 + return;
  191 +
  192 + SignalAbnormal signalAbnormal = new SignalAbnormal();
  193 + signalAbnormal.setSt(st);
  194 + signalAbnormal.setEt(et);
  195 + signalAbnormal.setAbnormalType("reconnection");
  196 + signalAbnormal.setDestCode(sch.getQdzCode());
  197 + signalAbnormal.setOutOrIn(0);
  198 +
  199 + //截断GPS
  200 + e.setSignalState("truncation");
  201 +
  202 + //记录信号状态
  203 + SignalState signalState = SignalState.abnormalSignalSTate(sch, signalAbnormal);
  204 + signalStateData.put(signalState);
  205 + }
  206 +
  207 + /**
  208 + * 漂移异常状态记录
  209 + *
  210 + * @param nearGps
  211 + * @param i
  212 + * @param array
  213 + */
  214 + private void driftSignalAbnormal(GpsEntity nearGps, int i, Object[] array, ScheduleRealInfo sch) {
  215 + GpsEntity gps, s = null;
  216 + //找到漂移开始时间
  217 + for (; i >= 0; i--) {
  218 + gps = (GpsEntity) array[i];
  219 +
  220 + if (!gps.getSignalState().equals("drift") || i == 0
  221 + || gps.getSignalState().equals("truncation")) {
  222 + s = gps;
  223 + break;
  224 + }
  225 + }
  226 +
  227 + long st = s.getTimestamp(), et = nearGps.getTimestamp();
  228 + if (et - st < (1000 * 60 * 3))
  229 + return;
  230 + /*if (s != null){
  231 + st = s.getTimestamp();
  232 + //漂移小于3分钟
  233 + if(et - st < (1000 * 60 * 3))
  234 + return;
  235 + }*/
  236 +
  237 +
  238 + SignalAbnormal signalAbnormal = new SignalAbnormal();
  239 + signalAbnormal.setSt(st);
  240 + signalAbnormal.setEt(et);
  241 + signalAbnormal.setAbnormalType("drift");
  242 + signalAbnormal.setDestCode(sch.getQdzCode());
  243 + signalAbnormal.setOutOrIn(0);
  244 +
  245 + //截断GPS
  246 + nearGps.setSignalState("truncation");
  247 +
  248 + //记录信号状态
  249 + SignalState signalState = SignalState.abnormalSignalSTate(sch, signalAbnormal);
  250 + signalStateData.put(signalState);
  251 + }
  252 +}
0 253 \ No newline at end of file
... ...
src/main/java/com/bsth/data/gpsdata/arrival/utils/SignalSchPlanMatcher.java 0 → 100644
  1 +package com.bsth.data.gpsdata.arrival.utils;
  2 +
  3 +import com.bsth.data.gpsdata.GpsEntity;
  4 +import com.bsth.data.schedule.DayOfSchedule;
  5 +import com.bsth.entity.realcontrol.ScheduleRealInfo;
  6 +import org.springframework.beans.factory.annotation.Autowired;
  7 +import org.springframework.stereotype.Component;
  8 +
  9 +/**
  10 + * 班次匹配器
  11 + * Created by panzhao on 2016/12/31.
  12 + */
  13 +@Component
  14 +public class SignalSchPlanMatcher {
  15 +
  16 + @Autowired
  17 + DayOfSchedule dayOfSchedule;
  18 +
  19 + /**
  20 + * 发车信号匹配
  21 + * @param outSigal
  22 + * @param sch
  23 + * @return
  24 + */
  25 + public void outMatch(GpsEntity outSigal, ScheduleRealInfo sch){
  26 + long t = outSigal.getTimestamp();
  27 + if(t < sch.getDfsjT())
  28 + return;
  29 +
  30 + //下一个相同走向的班次
  31 + ScheduleRealInfo next = dayOfSchedule.nextSame(sch);
  32 + if(next == null || !next.getQdzCode().equals(sch.getQdzCode()))
  33 + return;
  34 +
  35 + //晚于班次间隔百分之70,跳下一个班次
  36 + double s = (int) (next.getDfsjT() - sch.getDfsjT());
  37 + double r = (int) (t - sch.getDfsjT());
  38 + if(r / s > 0.7){
  39 + dayOfSchedule.addExecPlan(next);
  40 + outMatch(outSigal, next);
  41 + }
  42 + }
  43 +}
... ...
src/main/java/com/bsth/data/gpsdata/recovery/GpsDataRecovery.java
... ... @@ -28,7 +28,7 @@ import java.util.concurrent.Executors;
28 28 * Created by panzhao on 2016/12/24.
29 29 */
30 30 @Component
31   -public class GpsDataRecovery implements ApplicationContextAware{
  31 +public class GpsDataRecovery implements ApplicationContextAware {
32 32  
33 33 static Logger logger = LoggerFactory.getLogger(GpsDataRecovery.class);
34 34  
... ... @@ -48,7 +48,7 @@ public class GpsDataRecovery implements ApplicationContextAware{
48 48 //按车辆分组数据
49 49 ArrayListMultimap<String, GpsEntity> listMap = ArrayListMultimap.create();
50 50 for (GpsEntity gps : list) {
51   - if(gps.getNbbm() != null)
  51 + if (gps.getNbbm() != null)
52 52 listMap.put(gps.getNbbm(), gps);
53 53 }
54 54  
... ... @@ -60,6 +60,8 @@ public class GpsDataRecovery implements ApplicationContextAware{
60 60 for (String nbbm : keys) {
61 61 Collections.sort(listMap.get(nbbm), comp);
62 62 threadPool.execute(new RecoveryThread(listMap.get(nbbm), count));
  63 + /*if(nbbm.equals("YT-CD008"))
  64 + new RecoveryThread(listMap.get(nbbm), count).run();*/
63 65 }
64 66  
65 67 try {
... ... @@ -124,7 +126,7 @@ public class GpsDataRecovery implements ApplicationContextAware{
124 126 reverseSignalHandle = applicationContext.getBean(ReverseSignalHandle.class);
125 127 }
126 128  
127   - public static class GpsComp implements Comparator<GpsEntity>{
  129 + public static class GpsComp implements Comparator<GpsEntity> {
128 130  
129 131 @Override
130 132 public int compare(GpsEntity g1, GpsEntity g2) {
... ... @@ -132,26 +134,28 @@ public class GpsDataRecovery implements ApplicationContextAware{
132 134 }
133 135 }
134 136  
135   - public static class RecoveryThread implements Runnable{
  137 + public static class RecoveryThread implements Runnable {
136 138 List<GpsEntity> list;
137 139 CountDownLatch count;
138 140  
139   - RecoveryThread(List<GpsEntity> list, CountDownLatch count){
  141 + RecoveryThread(List<GpsEntity> list, CountDownLatch count) {
140 142 this.list = list;
141 143 this.count = count;
142 144 }
  145 +
143 146 @Override
144 147 public void run() {
145 148 try {
146 149 //循环gps恢复数据
147 150 CircleQueue<GpsEntity> prevs;
148 151  
149   - for(GpsEntity gps : list){
  152 + for (GpsEntity gps : list) {
  153 +
150 154 prevs = GeoCacheData.getGps(gps.getNbbm());
151 155 //掉线处理
152 156 offlineSignalHandle.handle(gps, prevs);
153 157 //状态处理
154   - if(!correctSignalHandle.handle(gps, prevs))
  158 + if (!correctSignalHandle.handle(gps, prevs))
155 159 continue;
156 160 //场,站内外判断
157 161 stationInsideHandle.handle(gps, prevs);
... ... @@ -160,11 +164,12 @@ public class GpsDataRecovery implements ApplicationContextAware{
160 164 //进出站动作处理
161 165 inOutStationSignalHandle.handle(gps, prevs);
162 166 GeoCacheData.putGps(gps);
  167 +
  168 + //Thread.sleep(50);
163 169 }
164   - }catch (Exception e){
  170 + } catch (Exception e) {
165 171 logger.error("", e);
166   - }
167   - finally {
  172 + } finally {
168 173 count.countDown();
169 174 }
170 175 }
... ...
src/main/java/com/bsth/data/schedule/DayOfSchedule.java
... ... @@ -29,6 +29,7 @@ import org.slf4j.Logger;
29 29 import org.slf4j.LoggerFactory;
30 30 import org.springframework.beans.factory.annotation.Autowired;
31 31 import org.springframework.boot.CommandLineRunner;
  32 +import org.springframework.core.annotation.Order;
32 33 import org.springframework.stereotype.Component;
33 34  
34 35 import java.text.ParseException;
... ... @@ -43,6 +44,7 @@ import java.util.concurrent.TimeUnit;
43 44 * @date 2016年8月15日 上午10:16:12
44 45 */
45 46 @Component
  47 +@Order(value = 3)
46 48 public class DayOfSchedule implements CommandLineRunner {
47 49  
48 50 Logger logger = LoggerFactory.getLogger(this.getClass());
... ... @@ -83,6 +85,9 @@ public class DayOfSchedule implements CommandLineRunner {
83 85 @Autowired
84 86 GpsRealData gpsRealData;
85 87  
  88 + @Autowired
  89 + BasicData.BasicDataLoader basicDataLoader;
  90 +
86 91 /**
87 92 * 线路当前使用的排班的日期
88 93 */
... ... @@ -117,28 +122,24 @@ public class DayOfSchedule implements CommandLineRunner {
117 122 LineConfigData lineConfigs;
118 123  
119 124 @Autowired
120   - BasicData.BasicDataLoader dataLoader;
121   -
122   - @Autowired
123 125 GpsDataRecovery gpsDataRecovery;
124 126  
125 127 private static DateTimeFormatter fmtyyyyMMdd = DateTimeFormat.forPattern("yyyy-MM-dd"), fmtHHmm = DateTimeFormat.forPattern("HH:mm");
126 128  
127 129 @Override
128 130 public void run(String... arg0) throws Exception {
129   - //加载基础数据
130   - dataLoader.loadAllData();
  131 + basicDataLoader.loadAllData();
131 132 //从数据库恢复排班
132 133 dataRecovery();
133 134  
134 135 //翻班线程
135   -// Application.mainServices.scheduleWithFixedDelay(scheduleRefreshThread, 15, 240, TimeUnit.SECONDS);
  136 + Application.mainServices.scheduleWithFixedDelay(scheduleRefreshThread, 15, 240, TimeUnit.SECONDS);
136 137 //入库
137   -// Application.mainServices.scheduleWithFixedDelay(schedulePstThread, 60, 60, TimeUnit.SECONDS);
  138 + Application.mainServices.scheduleWithFixedDelay(schedulePstThread, 60, 60, TimeUnit.SECONDS);
138 139 //首班出场指令补发器
139 140 // Application.mainServices.scheduleWithFixedDelay(firstScheduleCheckThread, 30, 240, TimeUnit.SECONDS);
140 141 //班次误点扫描
141   - Application.mainServices.scheduleWithFixedDelay(scheduleLateThread, 60, 60, TimeUnit.SECONDS);
  142 +// Application.mainServices.scheduleWithFixedDelay(scheduleLateThread, 60, 60, TimeUnit.SECONDS);
142 143  
143 144 //每天凌晨2点20提交数据到运管处
144 145 long diff = (DateUtils.getTimestamp() + 1000 * 60 * 140) - System.currentTimeMillis();
... ... @@ -224,15 +225,8 @@ public class DayOfSchedule implements CommandLineRunner {
224 225 reCalcExecPlan(nbbm);
225 226 }
226 227  
227   - //是否是出站即出场
228   - LineConfig conf = lineConfigData.get(lineCode);
229   - if (conf.getOutConfig() == 2) {
230   - for (String nbbm : cars)
231   - schAttrCalculator.connectOutSchedule(nbbmScheduleMap.get(nbbm));
232   - }
233   -
234 228 // 页面 翻班通知
235   - sendUtils.shiftSchedule(lineCode);
  229 + //sendUtils.shiftSchedule(lineCode);
236 230 } catch (Exception e) {
237 231 logger.error("", e);
238 232 return -1;
... ... @@ -503,6 +497,41 @@ public class DayOfSchedule implements CommandLineRunner {
503 497 }
504 498  
505 499 /**
  500 + * 下一个相同走向的班次
  501 + * @param sch
  502 + * @return
  503 + */
  504 + public ScheduleRealInfo nextSame(ScheduleRealInfo sch){
  505 + List<ScheduleRealInfo> list = nbbmScheduleMap.get(sch.getClZbh());
  506 + int outConfig = -1;
  507 + LineConfig config = lineConfigData.get(sch.getXlBm());
  508 + if (config != null)
  509 + outConfig = config.getOutConfig();
  510 +
  511 + boolean flag = false;
  512 + ScheduleRealInfo next = null;
  513 + for (ScheduleRealInfo temp : list) {
  514 + if (temp.getId() == sch.getId()) {
  515 + flag = true;
  516 + continue;
  517 + }
  518 + //忽略烂班
  519 + if (temp.isDestroy())
  520 + continue;
  521 +
  522 + //出站既出场,忽略出场班次
  523 + if (outConfig == 2 && temp.getBcType().equals("out"))
  524 + continue;
  525 +
  526 + if (flag && temp.getXlDir().equals(sch.getXlDir())) {
  527 + next = temp;
  528 + break;
  529 + }
  530 + }
  531 + return next;
  532 + }
  533 +
  534 + /**
506 535 * 上一个班次
507 536 *
508 537 * @param sch
... ... @@ -527,6 +556,18 @@ public class DayOfSchedule implements CommandLineRunner {
527 556 return prev;
528 557 }
529 558  
  559 + /**
  560 + * 是否是首班出场
  561 + * @param sch
  562 + * @return
  563 + */
  564 + public boolean isFirstOut(ScheduleRealInfo sch){
  565 + List<ScheduleRealInfo> list = nbbmScheduleMap.get(sch.getClZbh());
  566 + if(list.get(0).equals(sch) && sch.getBcType().equals("out"))
  567 + return true;
  568 + return false;
  569 + }
  570 +
530 571 public void put(ScheduleRealInfo sch) {
531 572 schAttrCalculator
532 573 .calcRealDate(sch)
... ...
src/main/java/com/bsth/data/schedule/SchAttrCalculator.java
... ... @@ -62,13 +62,13 @@ public class SchAttrCalculator {
62 62 sch.setDfsjAll(fmtyyyyMMddHHmm.parseMillis(sch.getScheduleDateStr()+sch.getDfsj()));
63 63  
64 64 //實發時間
65   - if(sch.getFcsjActual() != null &&
  65 + if(StringUtils.isNotEmpty(sch.getFcsjActual()) &&
66 66 sch.getFcsjActual().compareTo(conf.getStartOpt()) < 0){
67 67 sch.setFcsjActualAll(fmtyyyyMMddHHmm.parseMillis(sch.getScheduleDateStr()+sch.getFcsjActual()) + DAY_TIME);
68 68 }
69 69  
70 70 //實際終點時間
71   - if(sch.getZdsjActual() != null &&
  71 + if(StringUtils.isNotEmpty(sch.getZdsjActual()) &&
72 72 sch.getZdsjActual().compareTo(conf.getStartOpt()) < 0){
73 73 sch.setZdsjActualAll(fmtyyyyMMddHHmm.parseMillis(sch.getScheduleDateStr()+sch.getZdsjActual()) + DAY_TIME);
74 74 }
... ... @@ -162,34 +162,6 @@ public class SchAttrCalculator {
162 162  
163 163 return updateList;
164 164 }
165   -
166   - /**
167   - *
168   - * @Title: connectOutSchedule
169   - * @Description: TODO(关联出场班次)
170   - */
171   - public void connectOutSchedule(List<ScheduleRealInfo> list){
172   - Collections.sort(list, new ScheduleComparator.FCSJ());
173   -
174   - int len = list.size();
175   - if(len == 0)
176   - return;
177   -
178   - ScheduleRealInfo prve = list.get(0), curr;
179   - for(int i = 1; i < len; i ++){
180   - curr = list.get(i);
181   -
182   - //出站即出场关联
183   - if(prve.getBcType().equals("out") && prve.getJhlc() == null)
184   - curr.setTwinsSch(prve);
185   -
186   - //进站即进场关联
187   - if(curr.getBcType().equals("in") && curr.getJhlc() == null)
188   - prve.setTwinsSch(curr);
189   -
190   - prve = curr;
191   - }
192   - }
193 165  
194 166 public SchAttrCalculator calcFcsjTime(ScheduleRealInfo sch) throws ParseException {
195 167 sch.setFcsjT(fmtyyyyMMddHHmm.parseMillis(sch.getRealExecDate() + sch.getFcsj()));
... ...
src/main/java/com/bsth/entity/mcy_forms/Daily.java 0 → 100644
  1 +package com.bsth.entity.mcy_forms;
  2 +
  3 +public class Daily {
  4 +
  5 + private String rq;//日期
  6 +
  7 + public String getRq() {
  8 + return rq;
  9 + }
  10 +
  11 + public void setRq(String rq) {
  12 + this.rq = rq;
  13 + }
  14 +
  15 + private String zbh;//车牌号
  16 +
  17 + private String jgh;//员工号
  18 +
  19 + private String jName;//驾驶员
  20 +
  21 + private String zlc;//里程
  22 +
  23 + private String jzl1;//空驶公里
  24 +
  25 + private String yh;//油耗
  26 +
  27 + private String bc;//班次
  28 +
  29 + public String getZbh() {
  30 + return zbh;
  31 + }
  32 +
  33 + public void setZbh(String zbh) {
  34 + this.zbh = zbh;
  35 + }
  36 +
  37 + public String getJgh() {
  38 + return jgh;
  39 + }
  40 +
  41 + public void setJgh(String jgh) {
  42 + this.jgh = jgh;
  43 + }
  44 +
  45 + public String getjName() {
  46 + return jName;
  47 + }
  48 +
  49 + public void setjName(String jName) {
  50 + this.jName = jName;
  51 + }
  52 +
  53 + public String getZlc() {
  54 + return zlc;
  55 + }
  56 +
  57 + public void setZlc(String zlc) {
  58 + this.zlc = zlc;
  59 + }
  60 +
  61 + public String getJzl1() {
  62 + return jzl1;
  63 + }
  64 +
  65 + public void setJzl1(String jzl1) {
  66 + this.jzl1 = jzl1;
  67 + }
  68 +
  69 + public String getYh() {
  70 + return yh;
  71 + }
  72 +
  73 + public void setYh(String yh) {
  74 + this.yh = yh;
  75 + }
  76 +
  77 + public String getBc() {
  78 + return bc;
  79 + }
  80 +
  81 + public void setBc(String bc) {
  82 + this.bc = bc;
  83 + }
  84 +
  85 +
  86 +
  87 +
  88 +
  89 +}
... ...
src/main/java/com/bsth/entity/realcontrol/LineConfig.java
... ... @@ -53,6 +53,9 @@ public class LineConfig {
53 53 /** 调度指令模板 */
54 54 private String schDirectiveTemp;
55 55  
  56 + /** 识别区间调头 */
  57 + private boolean readReverse;
  58 +
56 59 @OneToMany(cascade = CascadeType.ALL)
57 60 private Set<D80ReplyTemp> d80Temps = new HashSet<>();
58 61  
... ... @@ -140,4 +143,12 @@ public class LineConfig {
140 143 public void setD80Temps(Set<D80ReplyTemp> d80Temps) {
141 144 this.d80Temps = d80Temps;
142 145 }
  146 +
  147 + public boolean isReadReverse() {
  148 + return readReverse;
  149 + }
  150 +
  151 + public void setReadReverse(boolean readReverse) {
  152 + this.readReverse = readReverse;
  153 + }
143 154 }
... ...
src/main/java/com/bsth/entity/realcontrol/ScheduleRealInfo.java
... ... @@ -94,11 +94,6 @@ public class ScheduleRealInfo {
94 94 * 班次类型 TODO:正常班次、出场、进场、加油、区间班次、放空班次、放大站班次、两点间空驶
95 95 */
96 96 private String bcType;
97   -
98   - /** 出站即出场 , 关联的进出场班次 */
99   - @JsonIgnore
100   - @Transient
101   - private ScheduleRealInfo twinsSch;
102 97  
103 98 /** 创建人 */
104 99 @JsonIgnore
... ... @@ -258,21 +253,6 @@ public class ScheduleRealInfo {
258 253 this.ccno = ccno;
259 254 }
260 255  
261   - public static DateTimeFormatter getFmtHHmm() {
262   - return fmtHHmm;
263   - }
264   -
265   - public static void setFmtHHmm(DateTimeFormatter fmtHHmm) {
266   - ScheduleRealInfo.fmtHHmm = fmtHHmm;
267   - }
268   -
269   - public static DateTimeFormatter getFmtyyyyMMddHHmm() {
270   - return fmtyyyyMMddHHmm;
271   - }
272   -
273   - public static void setFmtyyyyMMddHHmm(DateTimeFormatter fmtyyyyMMddHHmm) {
274   - ScheduleRealInfo.fmtyyyyMMddHHmm = fmtyyyyMMddHHmm;
275   - }
276 256  
277 257 /** ----------------
278 258 @OneToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
... ... @@ -804,13 +784,13 @@ public class ScheduleRealInfo {
804 784 this.opDirectiveState = opDirectiveState;
805 785 }
806 786  
807   - public ScheduleRealInfo getTwinsSch() {
  787 +/* public ScheduleRealInfo getTwinsSch() {
808 788 return twinsSch;
809 789 }
810 790  
811 791 public void setTwinsSch(ScheduleRealInfo twinsSch) {
812 792 this.twinsSch = twinsSch;
813   - }
  793 + }*/
814 794  
815 795 public boolean isLate() {
816 796 return late;
... ...
src/main/java/com/bsth/repository/realcontrol/ScheduleRealInfoRepository.java
... ... @@ -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') "
... ...
src/main/java/com/bsth/service/forms/ExportService.java
... ... @@ -2,6 +2,7 @@ package com.bsth.service.forms;
2 2  
3 3 import java.util.List;
4 4  
  5 +import com.bsth.entity.mcy_forms.Daily;
5 6 import com.bsth.entity.mcy_forms.Linepasswengerflow;
6 7 import com.bsth.entity.mcy_forms.Operationservice;
7 8 import com.bsth.entity.mcy_forms.Shifday;
... ... @@ -28,6 +29,6 @@ public interface ExportService {
28 29 public void operationservice(String startDate, String endDate, String lpName,
29 30 List<Operationservice> resList);
30 31  
31   -
  32 +
32 33  
33 34 }
... ...
src/main/java/com/bsth/service/forms/FormsService.java
... ... @@ -5,6 +5,7 @@ import java.util.Map;
5 5  
6 6 import com.bsth.entity.mcy_forms.Allline;
7 7 import com.bsth.entity.mcy_forms.Changetochange;
  8 +import com.bsth.entity.mcy_forms.Daily;
8 9 import com.bsth.entity.mcy_forms.Executionrate;
9 10 import com.bsth.entity.mcy_forms.Linepasswengerflow;
10 11 import com.bsth.entity.mcy_forms.Operationservice;
... ... @@ -39,4 +40,6 @@ public interface FormsService {
39 40 public List<Executionrate> executionrate(Map<String, Object> map);
40 41  
41 42 public List<Allline> allline(Map<String, Object> map);
  43 +
  44 + public List<Daily> daily(Map<String, Object> map);
42 45 }
... ...
src/main/java/com/bsth/service/forms/impl/FormsServiceImpl.java
... ... @@ -25,6 +25,7 @@ import com.bsth.entity.mcy_forms.Vehicleloading;
25 25 import com.bsth.entity.mcy_forms.Waybillday;
26 26 import com.bsth.entity.mcy_forms.Allline;
27 27 import com.bsth.entity.mcy_forms.Changetochange;
  28 +import com.bsth.entity.mcy_forms.Daily;
28 29 import com.bsth.entity.mcy_forms.Executionrate;
29 30 import com.bsth.service.forms.CommonService;
30 31 import com.bsth.service.forms.FormsService;
... ... @@ -615,8 +616,8 @@ public class FormsServiceImpl implements FormsService {
615 616 tu.setRq(rq);
616 617 tu.setGs(arg0.getString("gs_name").toString());
617 618 tu.setZhgs(arg0.getString("fgs_name").toString());
618   - //tu.setXl(arg0.getString("xlgs"));这个是根据公司判断线路有几条
619   - tu.setXl(arg0.getString("sxl"));
  619 + tu.setXl(arg0.getString("xlgs"));//这个是根据公司判断线路有几条
  620 + //tu.setXl(arg0.getString("sxl"));
620 621 tu.setXlmc(arg0.getString("sxl"));
621 622 tu.setCchjh(arg0.getString("jcl").toString());
622 623 tu.setCchsj(arg0.getString("scl").toString());
... ... @@ -708,4 +709,46 @@ public class FormsServiceImpl implements FormsService {
708 709  
709 710 return list;
710 711 }
  712 +
  713 + @Override
  714 + public List<Daily> daily(Map<String, Object> map) {
  715 +
  716 + String sql ="select r.schedule_date_str,r.xl_bm,r.xl_name,r.cl_zbh,r.j_gh,r.j_name,y.YH,r.gs_bm,r.gs_name,r.fgs_bm,r.fgs_name "
  717 + + " from bsth_c_s_sp_info_real r LEFT JOIN bsth_c_ylb y ON r.cl_zbh = y.nbbm "
  718 + + " WHERE 1 = 1"
  719 + + " and r.xl_bm='" + map.get("line").toString() + "'"
  720 + + " and to_days(r.schedule_date)=to_days('"+map.get("date").toString()+"')"
  721 + + " AND r.gs_bm is not null";
  722 +
  723 + if(map.get("gsdmDaily").toString()!=""){
  724 + sql+=" and r.gs_bm='"+map.get("gsdmDaily").toString()+"'";
  725 + }
  726 + if(map.get("fgsdmDaily").toString()!=""){
  727 + sql+=" and r.fgs_bm='"+map.get("fgsdmDaily").toString()+"'";
  728 + }
  729 + sql += " GROUP BY r.schedule_date_str,r.xl_bm,r.xl_name,r.cl_zbh,r.j_gh,r.j_name,y.YH,r.gs_bm,r.gs_name,r.fgs_bm,r.fgs_name ";
  730 +
  731 + List<Daily> list = jdbcTemplate.query(sql, new RowMapper<Daily>() {
  732 + @Override
  733 + public Daily mapRow(ResultSet arg0, int arg1) throws SQLException {
  734 + Daily daily = new Daily();
  735 + daily.setRq(arg0.getString("schedule_date_str"));
  736 + daily.setZbh(arg0.getString("cl_zbh"));
  737 + daily.setJgh(arg0.getString("j_gh"));
  738 + daily.setjName(arg0.getString("j_name"));
  739 + daily.setYh(arg0.getString("YH"));
  740 + return daily;
  741 + }
  742 + });
  743 +
  744 + for(int i=0;i<list.size();i++){
  745 + Daily d=list.get(i);
  746 + Map<String, Object> maps = new HashMap<>();
  747 + maps = commonService.findKMBC2(d.getJgh(),d.getZbh(),d.getRq());
  748 + d.setJzl1(maps.get("ksgl").toString());
  749 + d.setZlc(maps.get("realMileage").toString());
  750 + d.setBc(maps.get("sjbc").toString());
  751 + }
  752 + return list;
  753 + }
711 754 }
... ...
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/java/com/bsth/websocket/handler/SendUtils.java
1 1 package com.bsth.websocket.handler;
2 2  
3   -import java.text.SimpleDateFormat;
4   -import java.util.ArrayList;
5   -import java.util.Date;
6   -import java.util.HashMap;
7   -import java.util.List;
8   -import java.util.Map;
9   -
10   -import org.slf4j.Logger;
11   -import org.slf4j.LoggerFactory;
12   -import org.springframework.beans.factory.annotation.Autowired;
13   -import org.springframework.stereotype.Component;
14   -
15 3 import com.alibaba.fastjson.JSONObject;
16 4 import com.bsth.data.BasicData;
17 5 import com.bsth.data.LineConfigData;
18   -import com.bsth.data.schedule.DayOfSchedule;
  6 +import com.bsth.data.gpsdata.arrival.entity.SignalState;
19 7 import com.bsth.entity.directive.D80;
20 8 import com.bsth.entity.realcontrol.ScheduleRealInfo;
21 9 import com.fasterxml.jackson.core.JsonProcessingException;
22 10 import com.fasterxml.jackson.databind.ObjectMapper;
  11 +import org.slf4j.Logger;
  12 +import org.slf4j.LoggerFactory;
  13 +import org.springframework.beans.factory.annotation.Autowired;
  14 +import org.springframework.stereotype.Component;
  15 +
  16 +import java.text.SimpleDateFormat;
  17 +import java.util.*;
23 18  
24 19 @Component
25 20 public class SendUtils{
... ... @@ -40,7 +35,7 @@ public class SendUtils{
40 35 */
41 36 public void sendFcsj(ScheduleRealInfo sch) {
42 37 //处理出站即出场的班次
43   - connectOutSchTime(sch);
  38 + //connectOutSchTime(sch);
44 39  
45 40 Map<String, Object> map = new HashMap<>();
46 41 map.put("fn", "faChe");
... ... @@ -86,7 +81,7 @@ public class SendUtils{
86 81 */
87 82 public void sendZdsj(ScheduleRealInfo sch, ScheduleRealInfo nextSch, int finish) {
88 83 //处理进站即进场的班次
89   - connectInSchTime(sch);
  84 + //connectInSchTime(sch);
90 85  
91 86 Map<String, Object> map = new HashMap<>();
92 87 map.put("fn", "zhongDian");
... ... @@ -103,12 +98,30 @@ public class SendUtils{
103 98 logger.error("", e);
104 99 }
105 100 }
  101 +
  102 + /**
  103 + * 推送班次信号状态
  104 + * @param state
  105 + */
  106 + public void sendSignalState(SignalState state){
  107 + Map<String, Object> map = new HashMap<>();
  108 + map.put("fn", "signal_state");
  109 + map.put("data", state);
  110 +
  111 + ObjectMapper mapper = new ObjectMapper();
  112 +
  113 + try {
  114 + socketHandler.sendMessageToLine(state.getLineCode(), mapper.writeValueAsString(map));
  115 + } catch (Exception e) {
  116 + logger.error("", e);
  117 + }
  118 + }
106 119  
107 120 /**
108 121 *
109 122 * @Title: shiftSchedule
110 123 * @Description: TODO(线路翻班通知)
111   - */
  124 +
112 125 public void shiftSchedule(String lineCode){
113 126 Map<String, Object> map = new HashMap<>();
114 127 map.put("fn", "systemNotice");
... ... @@ -124,7 +137,7 @@ public class SendUtils{
124 137 logger.error("", e);
125 138 }
126 139 }
127   -
  140 + */
128 141 /**
129 142 *
130 143 * @Title: sendDirectiveToPage
... ... @@ -157,39 +170,4 @@ public class SendUtils{
157 170 list.add(sch);
158 171 refreshSch(list);
159 172 }
160   -
161   -
162   - //出站即出场
163   - public void connectOutSchTime(ScheduleRealInfo sch){
164   - try{
165   - ScheduleRealInfo twins = sch.getTwinsSch();
166   - if(twins != null
167   - && lineConfigData.get(sch.getXlBm()).getOutConfig() == 2
168   - && twins.getBcType().equals("out")){
169   -
170   - twins.setFcsjActualAll(sch.getFcsjActualTime());
171   - //刷新关联的出场班次
172   - //refreshSch(twins);
173   - }
174   - }catch(Exception e){
175   - logger.error("", e);
176   - }
177   - }
178   -
179   - //进站即出场
180   - public void connectInSchTime(ScheduleRealInfo sch){
181   - try{
182   - ScheduleRealInfo twins = sch.getTwinsSch();
183   - if(twins != null
184   - && lineConfigData.get(sch.getXlBm()).getOutConfig() == 2
185   - && twins.getBcType().equals("in")){
186   -
187   - twins.setZdsjActualAll(sch.getZdsjActualTime());
188   - //刷新关联的出场班次
189   - //refreshSch(twins);
190   - }
191   - }catch(Exception e){
192   - logger.error("", e);
193   - }
194   - }
195 173 }
... ...
src/main/resources/application-dev.properties
... ... @@ -7,13 +7,13 @@ spring.jpa.hibernate.naming_strategy= org.hibernate.cfg.ImprovedNamingStrategy
7 7 #DATABASE
8 8 spring.jpa.database= MYSQL
9 9 spring.jpa.show-sql= true
10   -spring.datasource.driver-class-name= com.mysql.jdbc.Driver
11   -spring.datasource.url= jdbc:mysql://127.0.0.1/qp_control?useUnicode=true&characterEncoding=utf-8&useSSL=false
12   -spring.datasource.username= root
13   -spring.datasource.password=
14   -#spring.datasource.url= jdbc:mysql://192.168.168.117/pd_control?useUnicode=true&characterEncoding=utf-8&useSSL=false
  10 +#spring.datasource.driver-class-name= com.mysql.jdbc.Driver
  11 +#spring.datasource.url= jdbc:mysql://192.168.168.201/mh_control?useUnicode=true&characterEncoding=utf-8&useSSL=false
15 12 #spring.datasource.username= root
16   -#spring.datasource.password= root
  13 +#spring.datasource.password= 123456
  14 +spring.datasource.url= jdbc:mysql://localhost/mh_control?useUnicode=true&characterEncoding=utf-8&useSSL=false
  15 +spring.datasource.username= root
  16 +spring.datasource.password= root
17 17 #DATASOURCE
18 18 spring.datasource.max-active=100
19 19 spring.datasource.max-idle=8
... ...
src/main/resources/ms-jdbc.properties
... ... @@ -4,6 +4,6 @@
4 4 #ms.mysql.password= 123456
5 5  
6 6 ms.mysql.driver= com.mysql.jdbc.Driver
7   -ms.mysql.url= jdbc:mysql://192.168.168.171:3306/ms?useUnicode=true&characterEncoding=utf-8
  7 +ms.mysql.url= jdbc:mysql://192.168.168.117:3306/ms?useUnicode=true&characterEncoding=utf-8
8 8 ms.mysql.username= root
9   -ms.mysql.password= root2jsp
10 9 \ No newline at end of file
  10 +ms.mysql.password= root
11 11 \ No newline at end of file
... ...
src/main/resources/static/pages/forms/mould/allline.xls
No preview for this file type
src/main/resources/static/pages/forms/mould/daily.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/pages/forms/statement/daily.html
... ... @@ -26,7 +26,15 @@
26 26 <div class="col-md-12">
27 27 <div class="portlet light porttlet-fit bordered">
28 28 <div class="portlet-title">
29   - <form class="form-inline" action="">
  29 + <form class="form-inline" action="">
  30 + <div style="display: inline-block; margin-left: 33px;" id="gsdmDiv_daily">
  31 + <span class="item-label" style="width: 80px;">公司: </span>
  32 + <select class="form-control" name="company" id="gsdmDaily" style="width: 140px;"></select>
  33 + </div>
  34 + <div style="display: inline-block; margin-left: 24px;" id="fgsdmDiv_daily">
  35 + <span class="item-label" style="width: 80px;">分公司: </span>
  36 + <select class="form-control" name="subCompany" id="fgsdmDaily" style="width: 140px;"></select>
  37 + </div>
30 38 <div style="display: inline-block;">
31 39 <span class="item-label" style="width: 80px;">线路: </span>
32 40 <select class="form-control" name="line" id="line" style="width: 180px;"></select>
... ... @@ -64,15 +72,15 @@
64 72 <td>班次</td>
65 73 </tr>
66 74 </thead>
67   - <tbody class="dailyInfo">
  75 + <tbody id="tbody">
68 76  
69 77 </tbody>
70 78 <tr>
71 79 <td colspan="3">小计</td>
72 80 <td><span id="total_zgl">&nbsp;</span></td>
73   - <td><span id="total_ksgl">&nbsp;</span></td>
  81 + <td><span id="total_ks">&nbsp;</span></td>
74 82 <td><span id="total_yh">&nbsp;</span></td>
75   - <td><span id="total_bcs">&nbsp;</span></td>
  83 + <td><span id="total_bc">&nbsp;</span></td>
76 84 </tr>
77 85 </table>
78 86 </div>
... ... @@ -82,7 +90,9 @@
82 90 </div>
83 91  
84 92 <script>
85   - $(function(){
  93 + $(function(){
  94 + var reqCodeMap = {"0xA1": '请求恢复运营', "0xA2": '申请调档', "0xA3": '出场请求', "0xA5": '进场请求', "0xA7": '加油请求', "0x50": '车辆故障', "0x70": '路阻报告', "0x60": '事故报告', "0x11": '扣证纠纷', "0x12" : '报警'};
  95 +
86 96 // 关闭左侧栏
87 97 if (!$('body').hasClass('page-sidebar-closed'))
88 98 $('.menu-toggler.sidebar-toggler').click();
... ... @@ -92,6 +102,42 @@
92 102 locale : 'zh-cn'
93 103 });
94 104  
  105 + var obj = [];
  106 + $.get('/user/companyData', function(result){
  107 + obj = result;
  108 + var options = '';
  109 + for(var i = 0; i < obj.length; i++){
  110 + options += '<option value="'+obj[i].companyCode+'">'+obj[i].companyName+'</option>';
  111 + }
  112 +
  113 + if(obj.length ==0){
  114 + $("#gsdmDiv_daily").css('display','none');
  115 + $('#gsdmDiv_daily').css('display','none');
  116 + }else if(obj.length ==1){
  117 + $("#fgsdmDiv_daily").css('display','none');
  118 + if(obj[0].children.length == 1 || obj[0].children.length ==0)
  119 + $('#fgsdmDiv_daily').css('display','none');
  120 + }
  121 + $('#gsdmDaily').html(options);
  122 + updateCompany();
  123 + });
  124 +
  125 + $("#gsdmDaily").on("change",updateCompany);
  126 + function updateCompany(){
  127 + var company = $('#gsdmDaily').val();
  128 + var options = '';
  129 + for(var i = 0; i < obj.length; i++){
  130 + if(obj[i].companyCode == company){
  131 + var children = obj[i].children;
  132 + for(var j = 0; j < children.length; j++){
  133 + options += '<option value="'+children[j].code+'">'+children[j].name+'</option>';
  134 + }
  135 + }
  136 + }
  137 + $('#fgsdmDaily').html(options);
  138 + }
  139 +
  140 +
95 141 $.get('/basic/lineCode2Name',function(result){
96 142 var data=[];
97 143  
... ... @@ -101,50 +147,82 @@
101 147 initPinYinSelect2('#line',data,'');
102 148  
103 149 })
104   - var line;
105   - var date;
106   - $("#query").on("click",function(){
107   - line = $("#line").val();
108   - var lineName=$("#select2-line-container").html();
109   - date = $("#date").val();
110   - $get('/realSchedule/dailyInfo',{line:line,date:date,type:'query'},function(result){
111   - $("#form_line").text(lineName);
112   - $("#form_date").text(date);
113   - var total_zgl = 0,total_ksgl = 0,total_yh = 0,total_bcs = 0;
114   - $.each(result, function(i, obj) {
115   - total_zgl = Number(obj.zgl)+Number(total_zgl);
116   - total_ksgl = Number(obj.ksgl)+Number(total_ksgl);
117   - total_yh = Number(0)+Number(total_yh);
118   - total_bcs = Number(obj.bcs)+Number(total_bcs);
119   - });
120   - $("#total_zgl").text(total_zgl.toFixed(2));
121   - $("#total_ksgl").text(total_ksgl.toFixed(2));
122   - $("#total_yh").text(total_yh.toFixed(2));
123   - $("#total_bcs").text(total_bcs);
124   -
125   - // 把数据填充到模版中
126   - var tbodyHtml = template('dailyInfo',{list:result});
127   - // 把渲染好的模版html文本追加到表格中
128   - $('#forms .dailyInfo').html(tbodyHtml);
129   - });
  150 +
  151 + var line;
  152 + var date;
  153 + var gsdmDaily;
  154 + var fgsdmDaily;
  155 + $("#query").on("click",function(){
  156 +
  157 + line = $("#line").val();
  158 + var lineName=$("#select2-line-container").html();
  159 + date = $("#date").val();
  160 + gsdmDaily=$("#gsdmDaily").val();
  161 + fgsdmDaily = $("#fgsdmDaily").val();
  162 +
  163 + $post('/mcy_forms/daily',{gsdmDaily:gsdmDaily,fgsdmDaily:fgsdmDaily, line:line,date:date,type:'query'},function(result){
  164 + $("#form_line").text(lineName);
  165 + $("#form_date").text(date);
  166 + // 把数据填充到模版中
  167 + var tbodyHtml = template('dailyInfo',{list:result});
  168 + // 把渲染好的模版html文本追加到表格中
  169 + $('#tbody').html(tbodyHtml);
  170 + line = $("#line").val();
  171 +
  172 + startDate = $("#startDate").val();
  173 + endDate = $("#endDate").val();
  174 + $("#sDate").text(startDate);
  175 + $("#eDate").text(endDate);
  176 +
  177 + var total_zgl = 0,total_ks = 0;
  178 + var total_yh = 0,total_bc = 0;
  179 +
  180 + $.each(result, function(i, obj) {
  181 + total_zgl +=Number(obj.zlc);
  182 + total_ks +=Number(obj.jzl1);
  183 + total_yh += Number(obj.yh);
  184 + total_bc += Number(obj.bc);
  185 +
  186 + });
  187 + $("#total_zgl").text(total_zgl.toFixed(2));
  188 + $("#total_ks").text(total_ks.toFixed(2));
  189 + $("#total_yh").text(total_yh.toFixed(2));
  190 + $("#total_bc").text(total_bc.toFixed(2));
  191 +
  192 + var temp = {};
  193 + var today_account = 0;
  194 +
  195 + temp["line"] = $("#line").text();
  196 + $.each(result, function(i, obj) {
  197 + if(moment(obj.schedule_date_str).format("YYYY-MM-DD") == moment(obj.startDate).format("YYYY-MM-DD")){
  198 + today_account++;
  199 + }
  200 + obj.updateDate = moment(obj.startDate).format("YYYY-MM-DD HH:mm:ss");
  201 + });
  202 + })
  203 + });
  204 +
  205 + $("#export").on("click",function(){
  206 + line = $("#line").val();
  207 + date = $("#date").val();
  208 + gsdmDaily=$("#gsdmDaily").val();
  209 + fgsdmDaily = $("#fgsdmDaily").val();
  210 + $post('/mcy_export/dailyExport',{gsdmDaily:gsdmDaily,fgsdmDaily:fgsdmDaily,line:line,date:date,type:'export'},function(result){
  211 + window.open("/downloadFile/download?fileName=班次日报表"+moment(date).format("YYYYMMDD"));
130 212 });
131   - $("#export").on("click",function(){
132   - $get('/realSchedule/dailyInfo',{line:line,date:date,type:'export'},function(result){
133   - window.open("/downloadFile/download?fileName=班次日报"+moment(date).format("YYYYMMDD"));
134   - });
135   - });
136   - });
  213 + });
  214 +});
137 215 </script>
138 216 <script type="text/html" id="dailyInfo">
139 217 {{each list as obj i}}
140 218 <tr>
141   - <td>{{obj.clZbh}}</td>
142   - <td>{{obj.jGh}}</td>
  219 + <td>{{obj.zbh}}</td>
  220 + <td>{{obj.jgh}}</td>
143 221 <td>{{obj.jName}}</td>
144   - <td>{{obj.zgl}}</td>
145   - <td>{{obj.ksgl}}</td>
146   - <td>0</td>
147   - <td>{{obj.bcs}}</td>
  222 + <td>{{obj.zlc}}</td>
  223 + <td>{{obj.jzl1}}</td>
  224 + <td>{{obj.yh}}</td>
  225 + <td>{{obj.bc}}</td>
148 226 </tr>
149 227 {{/each}}
150 228 {{if list.length == 0}}
... ...
src/main/resources/static/pages/mforms/alllines/allline.html
... ... @@ -230,8 +230,7 @@
230 230 var total_bcjh = 0, total_bcsj = 0, total_bczxl = 0;
231 231 var total_gs = 0;
232 232 var total_zhgs = 0;
233   - $
234   - .each(
  233 + $.each(
235 234 result,
236 235 function(i, obj) {
237 236 total_gs += Number(obj.gsgs);
... ...
src/main/resources/static/real_control_v2/css/line_schedule.css
... ... @@ -55,7 +55,7 @@
55 55 padding: 0;
56 56 }
57 57  
58   -.line_schedule .schedule-wrap i.uk-icon-question-circle{
  58 +.line_schedule .schedule-wrap .header-title i.uk-icon-question-circle{
59 59 cursor: pointer;
60 60 font-size: 14px;
61 61 color: #cccaca;
... ... @@ -528,6 +528,7 @@ div.drop-rail[data-type=&quot;car&quot;]:before {
528 528  
529 529 dl.relevance-active dd:nth-child(n+2) {
530 530 background: #f1efef !important;
  531 + color: #333;
531 532 }
532 533  
533 534 dl.relevance-active.intimity dd:nth-child(n+2) {
... ... @@ -1022,4 +1023,27 @@ dd.fcsjActualCell div.last-sch-sunken span._badge{
1022 1023 .ct_table>.ct_table_body dl.dl-last-sch:hover div.last-sch-sunken,
1023 1024 .ct_table>.ct_table_body dl.dl-last-sch.context-menu-active div.last-sch-sunken{
1024 1025 background: #f5fbff;
  1026 +}
  1027 +
  1028 +dd.fcsjActualCell{
  1029 + position: relative;
  1030 +}
  1031 +
  1032 +i.signal_state_icon{
  1033 + position: absolute;
  1034 + right: 5px;
  1035 + top: 7px;
  1036 + box-shadow: 0px 0px 11px 0 rgba(0, 0, 0, 0.2), -1px 3px 8px 0 rgba(0, 0, 0, 0.19);
  1037 + text-indent: 0;
  1038 + border-radius: 15px;
  1039 + cursor: pointer;
  1040 +}
  1041 +
  1042 +i.signal_state_icon.uk-icon-question-circle{
  1043 + color: #e85252 !important;
  1044 +}
  1045 +
  1046 +i.signal_state_icon.uk-icon-reply{
  1047 + color: #4134e3 !important;
  1048 + box-shadow: none;
1025 1049 }
1026 1050 \ No newline at end of file
... ...
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/line_schedule/sch_table.html
... ... @@ -83,7 +83,7 @@
83 83 <dd data-sort-val={{sch.dfsjT}} dbclick dbclick-type="dfsj" dbclick-val="{{sch.dfsj}}">
84 84 {{sch.dfsj}}
85 85 </dd>
86   - <dd class="
  86 + <dd data-uk-observe class="
87 87 {{if sch.status==-1}}
88 88 tl-qrlb
89 89 {{else if sch.status==2}}
... ... @@ -130,7 +130,7 @@
130 130 </script>
131 131  
132 132 <script id="line-schedule-sfsj-temp" type="text/html">
133   - <dd class="
  133 + <dd data-uk-observe class="
134 134 {{if status==-1}}
135 135 tl-qrlb
136 136 {{else if status==2}}
... ...
src/main/resources/static/real_control_v2/fragments/north/nav/signal_state_config.html 0 → 100644
  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 +</div>
0 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/data/json/north_toolbar.json
... ... @@ -93,6 +93,11 @@
93 93 "id": 3.1,
94 94 "text": "TTS",
95 95 "event": "tts_config"
  96 + },
  97 + {
  98 + "id": 3.2,
  99 + "text": "信号标记",
  100 + "event": "signal_state"
96 101 }
97 102 ]
98 103 }
... ...
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/layout.js
... ... @@ -22,7 +22,7 @@ var gb_line_layout = (function() {
22 22 };
23 23  
24 24 //图例icon tootip
25   - $(document).on('mouseenter', '.schedule-wrap i.uk-icon-question-circle', function() {
  25 + $(document).on('mouseenter', '.schedule-wrap .header-title i.uk-icon-question-circle', function() {
26 26 $(this).qtip({
27 27 show: {
28 28 ready: true,
... ...
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,15 +232,19 @@ 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>');
236 241 else
237 242 $(dds[8]).html('');
238 243  
  244 + //信号状态标记
  245 + gb_signal_state.marker_sch(sch);
239 246 //班次是车辆的最后一班
240   - if(dl.hasClass('dl-last-sch'))
  247 + if (dl.hasClass('dl-last-sch'))
241 248 markerLastSch([sch]);
242 249 };
243 250  
... ... @@ -418,13 +425,13 @@ var gb_schedule_table = (function () {
418 425  
419 426 //清除线路下指定班次的 末班标记
420 427 var removeMarkers = function (lineCode, array) {
421   - var idx=[];
  428 + var idx = [];
422 429 $.each(array, function () {
423 430 idx.push(this.id);
424 431 });
425 432  
426   - $('dl.dl-last-sch','li.line_schedule[data-id=' + lineCode + ']').each(function () {
427   - 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'))) {
428 435 $(this).removeClass('dl-last-sch').find('.last-sch-sunken').remove();
429 436 }
430 437 });
... ... @@ -446,6 +453,7 @@ var gb_schedule_table = (function () {
446 453 return car_yfwf_map[lineCode];
447 454 },
448 455 scroToDl: scroToDl,
449   - reset_drag_active_all: reset_drag_active_all
  456 + reset_drag_active_all: reset_drag_active_all,
  457 + getDl: getDl
450 458 };
451 459 })();
... ...
src/main/resources/static/real_control_v2/js/main.js
1 1 //主调和监控模式
2 2 var operationMode = window.localStorage.getItem('operationMode');
3   -if(operationMode == 0){
  3 +if (operationMode == 0) {
4 4 $('body>.north').addClass('monitor');
5 5 $(document).on('ajaxSend', interceptPOST);
6 6 }
... ... @@ -8,8 +8,8 @@ else
8 8 $('body>.north').addClass('main');
9 9  
10 10 //拦截POST请求
11   -function interceptPOST(e, xhr, t){
12   - if(t && (t.method == 'POST' || t.type == 'POST')){
  11 +function interceptPOST(e, xhr, t) {
  12 + if (t && (t.method == 'POST' || t.type == 'POST')) {
13 13 console.log(e, xhr, t);
14 14 xhr.abort();
15 15 notify_err('监控模式!');
... ... @@ -18,54 +18,56 @@ function interceptPOST(e, xhr, t){
18 18  
19 19 /* main js */
20 20 var gb_main_ep = new EventProxy(),
21   - res_load_ep = EventProxy.create('load_data_basic', 'load_tab', 'load_home_layout', 'load_home_line_panel', function() {
  21 + res_load_ep = EventProxy.create('load_data_basic', 'load_tab', 'load_home_layout', 'load_home_line_panel', function () {
22 22 var eq = gb_main_ep;
23 23 // basic data end
24 24 eq.once('data-basic', g_emit('tab'));
25 25 // tabs
26   - eq.once('tab', function() {
  26 + eq.once('tab', function () {
27 27 gb_tabs.init(
28 28 g_emit('home-layout')
29 29 );
30 30 });
31 31 //home layout
32   - eq.once('home-layout', function() {
  32 + eq.once('home-layout', function () {
33 33 gb_home_layout.layout(
34 34 g_emit('home-line-panel')
35 35 );
36 36 });
37 37 //home line panel
38   - eq.once('home-line-panel', function() {
  38 + eq.once('home-line-panel', function () {
39 39 gb_home_line_panel.init(g_emit('gps-time-refresh'));
40 40 });
41 41  
42 42 //start fixed time refresh gps
43   - eq.once('gps-time-refresh', function() {
  43 + eq.once('gps-time-refresh', function () {
44 44 gb_data_gps.fixedTimeRefresh();
45 45 g_emit('line-schedule-layout')();
46 46 });
47 47  
48 48 //line schedule layout
49   - eq.once('line-schedule-layout', function() {
  49 + eq.once('line-schedule-layout', function () {
50 50 gb_line_layout.layout(g_emit('render-sch-table'));
51 51 });
52 52  
53 53 //render schedule table
54   - eq.once('render-sch-table', function() {
55   - gb_schedule_table.show(function(){
56   - //搜索框
57   - gb_sch_search.init();
  54 + eq.once('render-sch-table', function () {
  55 + gb_schedule_table.show(function () {
  56 + //搜索框
  57 + gb_sch_search.init();
  58 + //加载信号状态
  59 + gb_signal_state.init();
58 60 });
59 61  
60 62 //嵌入地图页面
61   - $('li.map-panel','#main-tab-content').load('/real_control_v2/mapmonitor/real.html');
62   -
  63 + $('li.map-panel', '#main-tab-content').load('/real_control_v2/mapmonitor/real.html');
  64 + //弹出更新说明
63 65 showUpdateDescription();
64 66 });
65 67  
66 68 function g_emit(id) {
67 69 console.log('g_emit [' + id + ']');
68   - return function() {
  70 + return function () {
69 71 console.log('eq.emitLater(' + id + ')');
70 72 return eq.emitLater(id);
71 73 };
... ... @@ -73,17 +75,17 @@ var gb_main_ep = new EventProxy(),
73 75 });
74 76  
75 77 //modal hide remove dom
76   -$(document).on('hide.uk.modal', '.uk-modal', function() {
  78 +$(document).on('hide.uk.modal', '.uk-modal', function () {
77 79 $(this).remove();
78 80 });
79 81  
80 82 $(document).on('click', '.ct-bottom-drawer-close', function () {
81   - $(this).parents('.ct-bottom-drawer').removeClass('open');
  83 + $(this).parents('.ct-bottom-drawer').removeClass('open');
82 84 });
83 85  
84 86 function connectArr(arr, separator, transFun) {
85 87 var rs = '';
86   - $.each(arr, function(i, item) {
  88 + $.each(arr, function (i, item) {
87 89 if (transFun)
88 90 item = transFun(item);
89 91 rs += (separator + item);
... ... @@ -102,26 +104,26 @@ var gb_form_validation_opts = {
102 104 };
103 105  
104 106  
105   -var notify_wait = function(t) {
  107 +var notify_wait = function (t) {
106 108 UIkit.notify("<i class='uk-icon-spinner uk-icon-spin'></i> " + t, {
107 109 status: 'info'
108 110 });
109 111 };
110 112  
111   -var notify_succ = function(t) {
  113 +var notify_succ = function (t) {
112 114 UIkit.notify("<i class='uk-icon-check'></i> " + t, {
113 115 status: 'success'
114 116 });
115 117 };
116 118  
117   -var notify_err = function(t) {
  119 +var notify_err = function (t) {
118 120 UIkit.notify("<i class='uk-icon-times'></i> " + t, {
119 121 status: 'danger'
120 122 });
121 123 };
122 124  
123   -var alt_confirm = function(content, succ, okBtn) {
124   - var modalEl = UIkit.modal.confirm(content, function() {
  125 +var alt_confirm = function (content, succ, okBtn) {
  126 + var modalEl = UIkit.modal.confirm(content, function () {
125 127 succ && succ();
126 128 modalEl.hide();
127 129 }, {
... ... @@ -129,15 +131,15 @@ var alt_confirm = function(content, succ, okBtn) {
129 131 Ok: okBtn,
130 132 Cancel: '取消'
131 133 }
132   - ,center: true
  134 + , center: true
133 135 });
134 136 };
135 137  
136   -var isArray = function(obj) {
  138 +var isArray = function (obj) {
137 139 return Object.prototype.toString.call(obj) === '[object Array]';
138 140 };
139 141  
140   -var notify_err_form = function(t, form) {
  142 +var notify_err_form = function (t, form) {
141 143 $('.uk-alert-danger', form).remove();
142 144 $('.uk-modal-footer', form).before('<div class="uk-alert uk-alert-danger" data-uk-alert="">' +
143 145 '<a href="" class="uk-alert-close uk-close"></a>' +
... ... @@ -147,29 +149,29 @@ var notify_err_form = function(t, form) {
147 149 enable_submit_btn(form);
148 150 };
149 151  
150   -var enable_submit_btn = function(form) {
  152 +var enable_submit_btn = function (form) {
151 153 var subBtn = $('button[type=submit]', form);
152 154 if (subBtn) {
153 155 subBtn.removeClass('disabled').removeAttr('disabled');
154 156 }
155 157 }
156 158  
157   -var disabled_submit_btn = function(form) {
  159 +var disabled_submit_btn = function (form) {
158 160 var subBtn = $('button[type=submit]', form);
159 161 if (subBtn) {
160   - subBtn.addClass('disabled').attr('disabled','disabled');
  162 + subBtn.addClass('disabled').attr('disabled', 'disabled');
161 163 }
162 164 };
163 165  
164   -var show_modal = function(id, dom) {
  166 +var show_modal = function (id, dom) {
165 167 $(document.body).append(dom);
166 168 return UIkit.modal(id, {
167 169 bgclose: false
168 170 }).show();
169 171 };
170 172  
171   -var open_modal = function(pageUrl, data, opt) {
172   - $.get(pageUrl, function(dom) {
  173 +var open_modal = function (pageUrl, data, opt) {
  174 + $.get(pageUrl, function (dom) {
173 175 if (!$(dom).hasClass('uk-modal')) {
174 176 alert('无效的dom片段!');
175 177 return;
... ... @@ -188,20 +190,20 @@ var open_modal = function(pageUrl, data, opt) {
188 190  
189 191 function showUpdateDescription() {
190 192 //更新说明
191   - var updateDescription={
  193 + var updateDescription = {
192 194 date: '2016-12-20',
193 195 text: '<h5>1、回场子任务开放使用。</h5>'
194 196 };
195 197  
196 198 var storage = window.localStorage
197   - ,key = 'update_' + updateDescription.date;
  199 + , key = 'update_' + updateDescription.date;
198 200 var text = storage.getItem(key);
199   - if(!text){
200   - var modal = '<div class="uk-modal" id="update-description-modal">'+
201   - ' <div class="uk-modal-dialog">'+
202   - ' <a class="uk-modal-close uk-close"></a>'+
203   - ' <div class="uk-modal-header">'+
204   - ' <h2>'+updateDescription.date+' 更新说明</h2></div>'+updateDescription.text+
  201 + if (!text) {
  202 + var modal = '<div class="uk-modal" id="update-description-modal">' +
  203 + ' <div class="uk-modal-dialog">' +
  204 + ' <a class="uk-modal-close uk-close"></a>' +
  205 + ' <div class="uk-modal-header">' +
  206 + ' <h2>' + updateDescription.date + ' 更新说明</h2></div>' + updateDescription.text +
205 207 ' </div>';
206 208  
207 209 show_modal('#update-description-modal', modal);
... ...
src/main/resources/static/real_control_v2/js/north/toolbar.js
... ... @@ -71,6 +71,9 @@ var gb_northToolbar = (function() {
71 71 },
72 72 gps_play_back: function () {
73 73 gb_map_play_back.initParams();
  74 + },
  75 + signal_state: function () {
  76 + open_modal('/real_control_v2/fragments/north/nav/signal_state_config.html', {}, modal_opts);
74 77 }
75 78 }
76 79 })();
... ...
src/main/resources/static/real_control_v2/js/signal_state/signal_state.js 0 → 100644
  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 +})();
0 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/js/websocket/sch_websocket.js
... ... @@ -26,7 +26,7 @@ var gb_sch_websocket = (function () {
26 26 var data = {
27 27 operCode: 'register_line',
28 28 idx: gb_data_basic.line_idx
29   - }
  29 + };
30 30 schSock.send(JSON.stringify(data));
31 31 console.log('regListen....', data);
32 32 }
... ... @@ -45,21 +45,21 @@ var gb_sch_websocket = (function () {
45 45 var calcUntreated = function (lineCode) {
46 46 var size = $('li.line_schedule[data-id=' + lineCode + '] .sys-mailbox .sys-mail-item').length;
47 47 $('#badge_untreated_num_' + lineCode).text(size);
48   - }
  48 + };
49 49  
50 50 var calcUntreatedAll = function () {
51 51 $('#main-tab-content li.line_schedule').each(function () {
52 52 calcUntreated($(this).data('id'));
53 53 });
54   - }
  54 + };
55 55  
56 56  
57 57 //80协议上报
58 58 var report80 = function (msg) {
59 59 msg.dateStr = moment(msg.timestamp).format('HH:mm');
60 60 msg.text = gb_common.reqCode80[msg.data.requestCode];
61   - if(!msg.text)
62   - msg.text='(未知的请求码 '+msg.data.requestCode+')';
  61 + if (!msg.text)
  62 + msg.text = '(未知的请求码 ' + msg.data.requestCode + ')';
63 63  
64 64 var $item = $(temps['sys-note-80-temp'](msg));
65 65 findMailBox(msg.data.lineId).prepend($item);
... ... @@ -68,7 +68,7 @@ var gb_sch_websocket = (function () {
68 68 gb_tts.speak(ttsMsg, msg.data.lineId);
69 69  
70 70 calcUntreated(msg.data.lineId);
71   - }
  71 + };
72 72  
73 73 var waitRemoves = [];
74 74 //车辆发出
... ... @@ -89,7 +89,7 @@ var gb_sch_websocket = (function () {
89 89 gb_schedule_table.calc_yfwf_num(msg.t.xlBm);
90 90  
91 91 calcUntreated(msg.t.xlBm);
92   - }
  92 + };
93 93  
94 94 //到达终点
95 95 var zhongDian = function (msg) {
... ... @@ -107,20 +107,20 @@ var gb_sch_websocket = (function () {
107 107 gb_tts.speak(ttsMsg, msg.t.xlBm);
108 108  
109 109 calcUntreated(msg.t.xlBm);
110   - }
  110 + };
111 111  
112 112 //服务器通知刷新班次
113 113 var refreshSch = function (msg) {
114 114 gb_schedule_table.updateSchedule(msg.ts);
115 115 /*//重新计算应发未发
116   - var idx={};
117   - $.each(msg.ts, function(i, t){
118   - if(idx[t.xlBm])
119   - return true;
120   - gb_schedule_table.calc_yfwf_num(t.xlBm);
121   - idx[t.xlBm]=1;
122   - });*/
123   - }
  116 + var idx={};
  117 + $.each(msg.ts, function(i, t){
  118 + if(idx[t.xlBm])
  119 + return true;
  120 + gb_schedule_table.calc_yfwf_num(t.xlBm);
  121 + idx[t.xlBm]=1;
  122 + });*/
  123 + };
124 124  
125 125 //80消息确认
126 126 var d80Confirm = function (msg) {
... ... @@ -129,12 +129,17 @@ var gb_sch_websocket = (function () {
129 129 calcUntreated(msg.lineId);
130 130 //重新计算应发未发
131 131 gb_schedule_table.calc_yfwf_num(msg.lineId);
132   - }
  132 + };
133 133  
134 134 //指令状态改变
135   - var directiveStatus = function(msg){
  135 + var directiveStatus = function (msg) {
136 136 gb_schedule_table.updateSchedule(msg.t);
137   - }
  137 + };
  138 +
  139 + //班次信号状态
  140 + var signalState = function (msg) {
  141 + gb_signal_state.put(msg.data);
  142 + };
138 143  
139 144 var msgHandle = {
140 145 report80: report80,
... ... @@ -142,8 +147,9 @@ var gb_sch_websocket = (function () {
142 147 zhongDian: zhongDian,
143 148 refreshSch: refreshSch,
144 149 d80Confirm: d80Confirm,
145   - directive: directiveStatus
146   - }
  150 + directive: directiveStatus,
  151 + signal_state: signalState
  152 + };
147 153  
148 154 function currentSecond() {
149 155 return Date.parse(new Date()) / 1000;
... ... @@ -167,15 +173,15 @@ var gb_sch_websocket = (function () {
167 173 $(this).parents('.sys-note-42').remove();
168 174  
169 175 var size = $(this).parents('.sys-mailbox').find('.sys-mail-item').length
170   - ,lineCode = $(this).parents('li.line_schedule').data('id');
  176 + , lineCode = $(this).parents('li.line_schedule').data('id');
171 177  
172 178 $('#badge_untreated_num_' + lineCode).text(size);
173 179 });
174 180  
175 181 //42消息点击
176 182 $(document).on('click', '.sys-mailbox .sys-note-42', function () {
177   - var lineCode=$(this).parents('li.line_schedule').data('id')
178   - ,id=$(this).data('id');
  183 + var lineCode = $(this).parents('li.line_schedule').data('id')
  184 + , id = $(this).data('id');
179 185 var sch = gb_schedule_table.findScheduleByLine(lineCode)[id];
180 186 var dl = gb_schedule_table.scroToDl(sch);
181 187 //高亮
... ... @@ -205,7 +211,7 @@ var gb_sch_websocket = (function () {
205 211 notify_succ(rs.msg);
206 212 cb && cb();
207 213 });
208   - }
  214 + };
209 215  
210 216  
211 217 //定时到离站信使清理掉
... ...
src/main/resources/static/real_control_v2/main.html
... ... @@ -142,6 +142,8 @@
142 142 <script src="/real_control_v2/assets/echarts-3/echarts.js"></script>
143 143 <!-- Geolib -->
144 144 <script src="/real_control_v2/geolib/geolib.js"></script>
  145 +
  146 + <script src="/real_control_v2/js/signal_state/signal_state.js"></script>
145 147 </body>
146 148  
147 149 </html>
... ...
src/main/resources/static/real_control_v2/mapmonitor/fragments/playback/run.html
... ... @@ -148,10 +148,14 @@
148 148 var logs = [];
149 149 for (var i = 0; i <= ei; i++) {
150 150 trailArray.push(new BMap.Point(gpsArray[i].bd_lon, gpsArray[i].bd_lat));
151   - if(i > 0 && logs[logs.length - 1].road.ROAD_CODE == gpsArray[i].road.ROAD_CODE)
152   - logs.pop();
153   -
154   - logs.push(gpsArray[i]);
  151 + try {
  152 + if(i > 0 && logs[logs.length - 1].road.ROAD_CODE == gpsArray[i].road.ROAD_CODE)
  153 + logs.pop();
  154 + }
  155 + catch (e){}
  156 +
  157 + if(gpsArray[i].road)
  158 + logs.push(gpsArray[i]);
155 159 }
156 160 trailPolyline.setPath(trailArray);
157 161  
... ... @@ -302,6 +306,9 @@
302 306 gb_ct_table.fixedHead(logWrap);
303 307  
304 308 function logWrite(gps, prve) {
  309 + if(!gps.road || !gps.road.ROAD_CODE)
  310 + return;
  311 +
305 312 var code = gps.road.ROAD_CODE;
306 313 if (!prve || code != prve.road.ROAD_CODE) {
307 314 logPanel.append('<dl data-code="' + code + '" ><dd>' + gps.timeStr + '</dd><dd>' + gps.speed + '</dd><dd>' + gps.road.ROAD_NAME + '</dd><dd>正常</dd></dl>');
... ...
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);
... ...