Commit 4bbb49029219165ade2df19a44aa3ba577b2015a

Authored by 潘钊
2 parents 88a1c131 112c42c9

Merge branch 'minhang' into pudong

Showing 54 changed files with 2584 additions and 1107 deletions

Too many changes to show.

To preserve performance only 54 of 132 files are displayed.

src/main/java/com/bsth/controller/forms/ExportController.java
... ... @@ -13,8 +13,10 @@ import org.springframework.web.bind.annotation.RequestMethod;
13 13 import org.springframework.web.bind.annotation.RequestParam;
14 14 import org.springframework.web.bind.annotation.RestController;
15 15  
  16 +import com.bsth.data.BasicData;
16 17 import com.bsth.entity.mcy_forms.Allline;
17 18 import com.bsth.entity.mcy_forms.Changetochange;
  19 +import com.bsth.entity.mcy_forms.Daily;
18 20 import com.bsth.entity.mcy_forms.Executionrate;
19 21 import com.bsth.entity.mcy_forms.Linepasswengerflow;
20 22 import com.bsth.entity.mcy_forms.Operationservice;
... ... @@ -231,7 +233,7 @@ public class ExportController {
231 233 listI.add(resList.iterator());
232 234 String path = this.getClass().getResource("/").getPath() + "static\\pages\\forms\\";
233 235 ee.excelReplace(listI, new Object[] { map }, path + "mould\\vehicleloading.xls",
234   - path + "export\\车辆加注" + sdfSimple.format(sdfMonth.parse(map.get("dat").toString())) + ".xls");
  236 + path + "export\\车辆加注" + sdfSimple.format(sdfMonth.parse(map.get("data").toString())) + ".xls");
235 237 } catch (Exception e) {
236 238 e.printStackTrace();
237 239 }
... ... @@ -319,8 +321,31 @@ public class ExportController {
319 321 List<Turnoutrate> turnoutrate = formsService.turnoutrate(map);
320 322 Map<String, Object> map1 = new HashMap<String, Object>();
321 323 List<Map<String, Object>> resList = new ArrayList<Map<String, Object>>();
  324 + /*Float xlts=0f;
  325 + Float jh=0f;
  326 + Float sj=0f;
  327 + Float qz=0f;
  328 + Float ccl=0f;
  329 + Float bcjh=0f;
  330 + Float bcsj=0f;
  331 + Float bczxl=0f;
  332 + Float gs=0f;
  333 + Float zhgs=0f;*/
  334 +
322 335 for (Turnoutrate l : turnoutrate) {
323 336 Map<String, Object> m = new HashMap<String, Object>();
  337 +
  338 + /* xlts +=l.getGs()==""?0f:Float.valueOf(l.getGs());
  339 + jh +=l.getZhgs()==""?0f:Float.valueOf(l.getZhgs());
  340 + sj +=l.getXl()==""?0f:Float.valueOf(l.getXl());
  341 + ccl +=l.getCchjh()==""?0f:Float.valueOf(l.getCchjh());
  342 + bcjh +=l.getCchsj()==""?0f:Float.valueOf(l.getCchsj());
  343 + bcsj +=l.getChl()==""?0f:Float.valueOf(l.getChl());
  344 + bczxl +=l.getBcjh()==""?0f:Float.valueOf(l.getBcjh());
  345 + gs +=l.getBbzxl()==""?0f:Float.valueOf(l.getBbzxl());
  346 + zhgs +=l.getBbzxl()==""?0f:Float.valueOf(l.getBbzxl());
  347 +
  348 + */
324 349 m.put("rq", l.getRq());
325 350 m.put("gs", l.getGs());
326 351 m.put("zhgs", l.getZhgs());
... ... @@ -334,6 +359,19 @@ public class ExportController {
334 359 m.put("bbzxl", l.getBbzxl());
335 360 m.put("sm", l.getSm());
336 361 resList.add(m);
  362 +
  363 + /*m=new HashMap<String,Object>();
  364 + m.put("total_xlts", jh);
  365 + m.put("total_jh", jh);
  366 + m.put("total_sj", sj);
  367 + m.put("total_qz", qz);
  368 + m.put("total_ccl", ccl);
  369 + m.put("total_bcjh", bcjh);
  370 + m.put("total_bcsj", bcsj);
  371 + m.put("total_bczxl", bczxl);
  372 + m.put("total_gs", gs);
  373 + m.put("total_zhgs", zhgs);
  374 + */
337 375 }
338 376  
339 377 try {
... ... @@ -356,8 +394,29 @@ public class ExportController {
356 394 List<Executionrate> executionrate = formsService.executionrate(map);
357 395 Map<String, Object> map1 = new HashMap<String, Object>();
358 396 List<Map<String, Object>> resList = new ArrayList<Map<String, Object>>();
  397 + /* Float xlts=0f;
  398 + Float jh=0f;
  399 + Float sj=0f;
  400 + Float ccl=0f;
  401 + Float bcjh=0f;
  402 + Float bcsj=0f;
  403 + Float bczxl=0f;
  404 + Float gs=0f;
  405 + Float zhgs=0f;*/
  406 +
359 407 for (Executionrate l : executionrate) {
360 408 Map<String, Object> m = new HashMap<String, Object>();
  409 + /* xlts +=l.getGs()==""?0f:Float.valueOf(l.getGs());
  410 + jh +=l.getZhgs()==""?0f:Float.valueOf(l.getZhgs());
  411 + sj +=l.getXl()==""?0f:Float.valueOf(l.getXl());
  412 + ccl +=l.getCchjh()==""?0f:Float.valueOf(l.getCchjh());
  413 + bcjh +=l.getCchsj()==""?0f:Float.valueOf(l.getCchsj());
  414 + bcsj +=l.getChl()==""?0f:Float.valueOf(l.getChl());
  415 + bczxl +=l.getBcjh()==""?0f:Float.valueOf(l.getBcjh());
  416 + gs +=l.getBbzxl()==""?0f:Float.valueOf(l.getBbzxl());
  417 + zhgs +=l.getBbzxl()==""?0f:Float.valueOf(l.getBbzxl());
  418 +
  419 + */
361 420 m.put("rq", l.getRq());
362 421 m.put("gs", l.getGs());
363 422 m.put("zhgs", l.getZhgs());
... ... @@ -370,6 +429,19 @@ public class ExportController {
370 429 m.put("bbzxl", l.getBbzxl());
371 430 m.put("sm", l.getSm());
372 431 resList.add(m);
  432 +
  433 +
  434 + /* m=new HashMap<String,Object>();
  435 + m.put("total_xlts", jh);
  436 + m.put("total_jh", jh);
  437 + m.put("total_sj", sj);
  438 + m.put("total_ccl", ccl);
  439 + m.put("total_bcjh", bcjh);
  440 + m.put("total_bcsj", bcsj);
  441 + m.put("total_bczxl", bczxl);
  442 + m.put("total_gs", gs);
  443 + m.put("total_zhgs", zhgs);*/
  444 +
373 445 }
374 446  
375 447 try {
... ... @@ -393,12 +465,31 @@ public class ExportController {
393 465 List<Allline> allline = formsService.allline(map);
394 466 Map<String, Object> map1 = new HashMap<String, Object>();
395 467 List<Map<String, Object>> resList = new ArrayList<Map<String, Object>>();
  468 + /* Integer jh=0;
  469 + Integer sj=0;
  470 + Integer ccl=0;
  471 + Integer bcjh=0;
  472 + Float bcsj=0f;
  473 + Integer bczxl=0;
  474 + Integer gs=0;
  475 + Float zhgs=0f;
  476 + */
396 477 for (Allline l : allline) {
397 478 Map<String, Object> m = new HashMap<String, Object>();
  479 +
  480 + /*jh +=l.getGsgs()=="" ? 0: Integer.valueOf(l.getGsgs());
  481 + sj +=l.getFgsgs()==""?0: Integer.valueOf(l.getFgsgs());
  482 + ccl +=l.getCchjh()==""?0: Integer.valueOf(l.getCchjh());
  483 + bcjh +=l.getCchsj()==""?0: Integer.valueOf(l.getCchsj());
  484 + bcsj +=l.getChl()==""?0f:Float.valueOf(l.getChl());
  485 + bczxl +=l.getBcjh()==""?0: Integer.valueOf(l.getBcjh());
  486 + gs +=l.getBbzxl()==""?0: Integer.valueOf(l.getBbzxl());
  487 + zhgs +=l.getBbzxl()==""?0f:Float.valueOf(l.getBbzxl());
  488 + */
398 489 m.put("rq", l.getRq());
399   - m.put("gs", l.getGs());
400   - m.put("zhgs", l.getZhgs());
401   - m.put("xl", l.getXl());
  490 + m.put("gs", l.getGsgs());
  491 + m.put("zhgs", l.getFgsgs());
  492 + //m.put("xl", l.getXl());
402 493 m.put("cchjh", l.getCchjh());
403 494 m.put("cchsj", l.getCchsj());
404 495 m.put("chl", l.getChl());
... ... @@ -407,6 +498,17 @@ public class ExportController {
407 498 m.put("bbzxl", l.getBbzxl());
408 499 m.put("sm", l.getSm());
409 500 resList.add(m);
  501 +
  502 + /*m=new HashMap<String,Object>();
  503 + m.put("total_jh", jh);
  504 + m.put("total_sj", sj);
  505 + m.put("total_ccl", ccl);
  506 + m.put("total_bcjh", bcjh);
  507 + m.put("total_bcsj", bcsj);
  508 + m.put("total_bczxl", bczxl);
  509 + m.put("total_gs", gs);
  510 + m.put("total_zhgs", zhgs);
  511 + */
410 512 }
411 513  
412 514 try {
... ... @@ -422,6 +524,56 @@ public class ExportController {
422 524  
423 525  
424 526  
  527 + //班次日报表
  528 + @RequestMapping(value = "/dailyExport", method = RequestMethod.POST)
  529 + public List<Map<String, Object>> dailyExport(@RequestParam Map<String, Object> map) {
  530 + SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"), sdfSimple = new SimpleDateFormat("yyyyMMdd");
  531 + List<Iterator<?>> listI = new ArrayList<Iterator<?>>();
  532 + ReportUtils ee = new ReportUtils();
  533 + List<Daily> allline = formsService.daily(map);
  534 +
  535 + List<Map<String, Object>> resList = new ArrayList<Map<String, Object>>();
  536 + Float zgl=0f;
  537 + Float ks=0f;
  538 + Float yh=0f;
  539 + Float bc=0f;
  540 + Map<String, Object> m ;
  541 + for (Daily d : allline) {
  542 + m = new HashMap<String, Object>();
  543 + zgl +=d.getZlc()==""?0f:Float.valueOf(d.getZlc());
  544 + ks +=d.getJzl1()==""?0f:Float.valueOf(d.getJzl1());
  545 + yh +=d.getYh()==""?0f:Float.valueOf(d.getYh());
  546 + bc +=d.getBc()==""?0f:Float.valueOf(d.getBc());
  547 + m.put("zbh", d.getZbh());
  548 + m.put("jgh",d.getJgh());
  549 + m.put("jName", d.getjName());
  550 + m.put("zlc", d.getZlc());
  551 + m.put("jzl1", d.getJzl1());
  552 + m.put("yh", d.getYh());
  553 + m.put("bc", d.getBc());
  554 +
  555 + resList.add(m);
  556 + }
  557 +
  558 + m=new HashMap<String,Object>();
  559 + m.put("total_zgl", zgl);
  560 + m.put("total_ks", ks);
  561 + m.put("total_yh", yh);
  562 + m.put("total_bc", bc);
  563 +
  564 + m.put("line", BasicData.lineCode2NameMap.get(map.get("line").toString()));
  565 + m.put("date", map.get("date").toString());
  566 + try {
  567 + listI.add(resList.iterator());
  568 + String path = this.getClass().getResource("/").getPath() + "static\\pages\\forms\\";
  569 + ee.excelReplace(listI, new Object[] { m }, path + "mould\\daily.xls", path + "export\\班次日报表"
  570 + + sdfSimple.format(sdfMonth.parse(map.get("date").toString())) + ".xls");
  571 + } catch (Exception e) {
  572 + e.printStackTrace();
  573 + }
  574 + return resList;
  575 + }
  576 +
425 577  
426 578  
427 579 }
... ...
src/main/java/com/bsth/controller/forms/MCY_FormsController.java
... ... @@ -11,6 +11,7 @@ import org.springframework.web.bind.annotation.RestController;
11 11  
12 12 import com.bsth.entity.mcy_forms.Allline;
13 13 import com.bsth.entity.mcy_forms.Changetochange;
  14 +import com.bsth.entity.mcy_forms.Daily;
14 15 import com.bsth.entity.mcy_forms.Executionrate;
15 16 import com.bsth.entity.mcy_forms.Linepasswengerflow;
16 17 import com.bsth.entity.mcy_forms.Operationservice;
... ... @@ -112,4 +113,12 @@ public class MCY_FormsController {
112 113  
113 114 return formsService.allline(map);
114 115 }
  116 +
  117 + // 营运线路名称统计表
  118 + @RequestMapping(value = "/daily", method = RequestMethod.POST)
  119 + public List<Daily> daily(@RequestParam Map<String, Object> map) {
  120 +
  121 + return formsService.daily(map);
  122 + }
  123 +
115 124 }
... ...
src/main/java/com/bsth/controller/realcontrol/SignalStateController.java 0 → 100644
  1 +package com.bsth.controller.realcontrol;
  2 +
  3 +import com.bsth.data.gpsdata.SignalStateData;
  4 +import com.bsth.data.gpsdata.arrival.entity.SignalState;
  5 +import org.springframework.beans.factory.annotation.Autowired;
  6 +import org.springframework.web.bind.annotation.RequestMapping;
  7 +import org.springframework.web.bind.annotation.RequestParam;
  8 +import org.springframework.web.bind.annotation.RestController;
  9 +
  10 +import java.util.List;
  11 +
  12 +/**
  13 + * Created by panzhao on 2016/12/30.
  14 + */
  15 +@RestController
  16 +@RequestMapping("signalState")
  17 +public class SignalStateController {
  18 +
  19 + @Autowired
  20 + SignalStateData signalStateData;
  21 +
  22 + @RequestMapping("/multi")
  23 + public List<SignalState> findByMultiLine(@RequestParam String idx){
  24 + return signalStateData.get(idx);
  25 + }
  26 +}
... ...
src/main/java/com/bsth/controller/report/ReportController.java
... ... @@ -64,6 +64,11 @@ public class ReportController {
64 64 return service.tbodyTime3(line, ttinfo);
65 65 }
66 66  
  67 + @RequestMapping(value = "/tbodyTime4", method = RequestMethod.GET)
  68 + public List<Map<String, Object>> tbodyTime4(@RequestParam String line,@RequestParam String ttinfo) {
  69 + return service.tbodyTime4(line, ttinfo);
  70 + }
  71 +
67 72 @RequestMapping(value = "/tbodyTime5", method = RequestMethod.GET)
68 73 public List<Map<String, Object>> tbodyTime5(@RequestParam String line,@RequestParam String ttinfo) {
69 74 return service.tbodyTime5(line, ttinfo);
... ...
src/main/java/com/bsth/data/BasicData.java
1 1 package com.bsth.data;
2 2  
3 3 import com.bsth.Application;
4   -import com.bsth.data.gpsdata.analyse.GeoCacheData;
  4 +import com.bsth.data.gpsdata.arrival.GeoCacheData;
5 5 import com.bsth.entity.*;
6 6 import com.bsth.entity.schedule.CarConfigInfo;
7 7 import com.bsth.repository.*;
... ... @@ -13,6 +13,7 @@ import org.slf4j.Logger;
13 13 import org.slf4j.LoggerFactory;
14 14 import org.springframework.beans.factory.annotation.Autowired;
15 15 import org.springframework.boot.CommandLineRunner;
  16 +import org.springframework.core.annotation.Order;
16 17 import org.springframework.stereotype.Component;
17 18  
18 19 import java.util.*;
... ... @@ -25,13 +26,14 @@ import java.util.concurrent.TimeUnit;
25 26 * @date 2016年8月10日 下午3:27:45
26 27 */
27 28 @Component
  29 +@Order(value = 1)
28 30 public class BasicData implements CommandLineRunner {
29   -
30   - //公司代码和公司名对照(K: 公司编码,V:公司名)
31   - public static Map<String, String> businessCodeNameMap;
32   -
33   - //分公司公司代码和分公司公司名对照(K: 公司编码+分公司编码,V:分公司公司名)
34   - public static Map<String, String> businessFgsCodeNameMap;
  31 +
  32 + //公司代码和公司名对照(K: 公司编码,V:公司名)
  33 + public static Map<String, String> businessCodeNameMap;
  34 +
  35 + //分公司公司代码和分公司公司名对照(K: 公司编码+分公司编码,V:分公司公司名)
  36 + public static Map<String, String> businessFgsCodeNameMap;
35 37  
36 38 //设备号和车辆自编号 (K: 设备编码 ,V:车辆自编号)
37 39 public static BiMap<String, String> deviceId2NbbmMap;
... ... @@ -39,27 +41,21 @@ public class BasicData implements CommandLineRunner {
39 41 //车辆自编号和公司代码对照 (K: 车辆自编号 ,V:公司代码)
40 42 public static Map<String, String> nbbm2CompanyCodeMap;
41 43  
42   - //站点编码和名称对照,包括停车场 (K: 站点编码 ,V:站点名称)
  44 + //站点编码和名称对照,包括停车场 (K: lineCode_updown_stationCode ,V:站点名称)
43 45 public static Map<String, String> stationCode2NameMap;
44 46  
45 47 //线路起终点对照(线路编码_上下行_起终点) 1024_0_B (1024上行起点)
46   - public static Map<String, String> lineSEPointMap;
  48 + //public static Map<String, String> lineSEPointMap;
47 49  
48 50 //车辆和线路对照
49 51 public static Map<String, Line> nbbm2LineMap;
50 52  
51   - //线路和用户对照 用于webSocket定向推送消息(用户进入线调时写入数据)
52   - //public static TreeMultimap<String, String> lineCode2SocketUserMap = TreeMultimap.create();
53   -
54 53 //线路ID和code 对照
55 54 public static BiMap<Integer, String> lineId2CodeMap;
56 55  
57 56 //线路编码和名称对照
58 57 public static Map<String, String> lineCode2NameMap;
59 58  
60   - //线路编码_站点编码 == 0|1 上下行
61   - //public static Map<String, Integer> lineStationUpDownMap;
62   -
63 59 //停车场
64 60 public static List<String> parkCodeList;
65 61  
... ... @@ -77,7 +73,7 @@ public class BasicData implements CommandLineRunner {
77 73 public static Map<String, String> allPerson;
78 74  
79 75 //站点名和运管处编号 对照
80   - public static Map<String,Integer> stationName2YgcNumber;
  76 + public static Map<String, Integer> stationName2YgcNumber;
81 77  
82 78  
83 79 static Logger logger = LoggerFactory.getLogger(BasicData.class);
... ... @@ -87,7 +83,7 @@ public class BasicData implements CommandLineRunner {
87 83  
88 84 @Override
89 85 public void run(String... arg0) throws Exception {
90   - Application.mainServices.scheduleWithFixedDelay(dataLoader, 2, 2, TimeUnit.HOURS);
  86 + Application.mainServices.scheduleWithFixedDelay(dataLoader, 0, 2, TimeUnit.HOURS);
91 87 }
92 88  
93 89  
... ... @@ -114,7 +110,7 @@ public class BasicData implements CommandLineRunner {
114 110  
115 111 @Autowired
116 112 PersonnelRepository personnelRepository;
117   -
  113 +
118 114 @Autowired
119 115 BusinessRepository businessRepository;
120 116  
... ... @@ -156,47 +152,24 @@ public class BasicData implements CommandLineRunner {
156 152 return 0;
157 153 }
158 154  
159   -
160   -/* private void loadStationRouteInfo() {
161   - Iterator<StationRoute> iterator = stationRouteRepository.findAllEffective().iterator();
162   -
163   - Map<String, String> sePointMap = new HashMap<>();
164   - //lineSEPointMap
165   - Map<String, Integer> map = new HashMap<>();
166   -
167   - StationRoute route;
168   - while (iterator.hasNext()) {
169   - route = iterator.next();
170   - map.put(route.getLineCode() + "_" + route.getStationCode(), route.getDirections());
171   -
172   - if (route.getStationMark() != null &&
173   - (route.getStationMark().equals("B") || route.getStationMark().equals("E"))) {
174   - sePointMap.put(route.getLineCode() + "_"
175   - + route.getDirections()
176   - + "_" + route.getStationMark(), route.getStationCode());
177   - }
178   - }
179   - lineStationUpDownMap = map;
180   - lineSEPointMap = sePointMap;
181   - }*/
182   -
183 155 /**
184 156 * loadBusinessInfo
185 157 * (公司代码公司名对照)
186 158 */
187   - public void loadBusinessInfo(){
188   - Map<String, String> businessMap=new HashMap<String,String>();
189   - Map<String, String> businessFgsMap=new HashMap<String,String>();
190   - Iterator<Business> busIter=businessRepository.findAll().iterator();
191   - Business t;
192   - while(busIter.hasNext()){
193   - t=busIter.next();
194   - businessMap.put(t.getBusinessCode(), t.getBusinessName());
195   - businessFgsMap.put(t.getBusinessCode()+"_"+t.getUpCode(), t.getBusinessName());
196   - }
197   - businessCodeNameMap=businessMap;
198   - businessFgsCodeNameMap=businessFgsMap;
  159 + public void loadBusinessInfo() {
  160 + Map<String, String> businessMap = new HashMap<String, String>();
  161 + Map<String, String> businessFgsMap = new HashMap<String, String>();
  162 + Iterator<Business> busIter = businessRepository.findAll().iterator();
  163 + Business t;
  164 + while (busIter.hasNext()) {
  165 + t = busIter.next();
  166 + businessMap.put(t.getBusinessCode(), t.getBusinessName());
  167 + businessFgsMap.put(t.getBusinessCode() + "_" + t.getUpCode(), t.getBusinessName());
  168 + }
  169 + businessCodeNameMap = businessMap;
  170 + businessFgsCodeNameMap = businessFgsMap;
199 171 }
  172 +
200 173 /**
201 174 * @Title: loadDeviceInfo
202 175 * @Description: TODO(加载设备相关信息)
... ... @@ -223,13 +196,13 @@ public class BasicData implements CommandLineRunner {
223 196 */
224 197 public void loadStationInfo() {
225 198 Map<String, String> stationCode2Name = new HashMap<>();
226   - Iterator<Station> iterator = stationRepository.findAll().iterator();
227   - //站点
228   - Station station;
  199 + Iterator<StationRoute> iterator = stationRouteRepository.findAll().iterator();
  200 + StationRoute sroute;
229 201 while (iterator.hasNext()) {
230   - station = iterator.next();
231   - stationCode2Name.put(station.getStationCod(), station.getStationName());
  202 + sroute = iterator.next();
  203 + stationCode2Name.put(sroute.getLineCode() + "_" + sroute.getDirections() + "_" + sroute.getStationCode(), sroute.getStationName());
232 204 }
  205 +
233 206 //停车场
234 207 Iterator<CarPark> iterator2 = carParkRepository.findAll().iterator();
235 208  
... ... @@ -266,7 +239,7 @@ public class BasicData implements CommandLineRunner {
266 239 * @Title: loadLineInfo
267 240 * @Description: TODO(加载线路相关信息)
268 241 */
269   - public void loadLineInfo(){
  242 + public void loadLineInfo() {
270 243 Iterator<Line> iterator = lineRepository.findAll().iterator();
271 244  
272 245 Line line;
... ... @@ -276,36 +249,36 @@ public class BasicData implements CommandLineRunner {
276 249 Map<String, String> code2SHcode = new HashMap<String, String>();
277 250 Map<String, Integer> tempStationName2YgcNumber = new HashMap<String, Integer>();
278 251  
279   - while(iterator.hasNext()){
  252 + while (iterator.hasNext()) {
280 253 line = iterator.next();
281 254 biMap.put(line.getId(), line.getLineCode());
282 255 code2name.put(line.getLineCode(), line.getName());
283   - id2SHcode.put(line.getId(),line.getShanghaiLinecode());
  256 + id2SHcode.put(line.getId(), line.getShanghaiLinecode());
284 257 code2SHcode.put(line.getLineCode(), line.getShanghaiLinecode());
285 258  
286 259 /**
287 260 * 加载运管处的站点及序号
288 261 * 上行从1开始,下行顺序续编
289 262  
290   - List<Object[]> ygcLines = stationRouteRepository.findAllLineWithYgc();
291   - if(ygcLines != null && ygcLines.size() > 0){
292   - int size = ygcLines.size();
293   - Object[] tempArray ;
294   - int num = 1;
295   - String key;
296   - String lineCode = "";
297   - for (int i = 0; i < size; i ++){
298   - tempArray = ygcLines.get(i);
299   - if(lineCode.equals("")){
300   - lineCode = tempArray[0]+"";
301   - }else if(!lineCode.equals(tempArray[0]+"")){
302   - num = 1;
303   - lineCode = tempArray[0]+"";
304   - }
305   - key = tempArray[0] + "_"+tempArray[1] + "_"+tempArray[2];
306   - tempStationName2YgcNumber.put(key,num++);
307   - }
308   - }*/
  263 + List<Object[]> ygcLines = stationRouteRepository.findAllLineWithYgc();
  264 + if(ygcLines != null && ygcLines.size() > 0){
  265 + int size = ygcLines.size();
  266 + Object[] tempArray ;
  267 + int num = 1;
  268 + String key;
  269 + String lineCode = "";
  270 + for (int i = 0; i < size; i ++){
  271 + tempArray = ygcLines.get(i);
  272 + if(lineCode.equals("")){
  273 + lineCode = tempArray[0]+"";
  274 + }else if(!lineCode.equals(tempArray[0]+"")){
  275 + num = 1;
  276 + lineCode = tempArray[0]+"";
  277 + }
  278 + key = tempArray[0] + "_"+tempArray[1] + "_"+tempArray[2];
  279 + tempStationName2YgcNumber.put(key,num++);
  280 + }
  281 + }*/
309 282 }
310 283  
311 284 lineId2CodeMap = biMap;
... ...
src/main/java/com/bsth/data/LineConfigData.java
... ... @@ -10,6 +10,7 @@ import org.slf4j.Logger;
10 10 import org.slf4j.LoggerFactory;
11 11 import org.springframework.beans.factory.annotation.Autowired;
12 12 import org.springframework.boot.CommandLineRunner;
  13 +import org.springframework.core.annotation.Order;
13 14 import org.springframework.stereotype.Component;
14 15  
15 16 import java.util.*;
... ... @@ -23,6 +24,7 @@ import java.util.*;
23 24 *
24 25 */
25 26 @Component
  27 +@Order(value = 2)
26 28 public class LineConfigData implements CommandLineRunner {
27 29  
28 30 Logger logger = LoggerFactory.getLogger(this.getClass());
... ...
src/main/java/com/bsth/data/gpsdata/GpsEntity.java
1 1 package com.bsth.data.gpsdata;
2 2  
3   -import com.bsth.data.gpsdata.analyse.StationRoute;
  3 +import com.bsth.data.gpsdata.arrival.entity.StationRoute;
4 4 import com.fasterxml.jackson.annotation.JsonIgnore;
5 5  
6 6 /**
... ... @@ -78,15 +78,15 @@ public class GpsEntity {
78 78 private boolean sEPoint;
79 79 */
80 80  
81   - /** 站内 */
82   - private boolean instation;
  81 + /** 0: 站外 1:站内 2:场内 */
  82 + private int instation;
83 83  
84 84 /** 站点信息,站内时有值 */
85 85 @JsonIgnore
86 86 private StationRoute station;
87 87  
88 88 /** 状态 */
89   - private String state2;
  89 + private String signalState = "normal";
90 90  
91 91 public Integer getCompanyCode() {
92 92 return companyCode;
... ... @@ -233,14 +233,6 @@ public class GpsEntity {
233 233 this.version = version;
234 234 }
235 235  
236   - public boolean isInstation() {
237   - return instation;
238   - }
239   -
240   - public void setInstation(boolean instation) {
241   - this.instation = instation;
242   - }
243   -
244 236 public StationRoute getStation() {
245 237 return station;
246 238 }
... ... @@ -257,11 +249,19 @@ public class GpsEntity {
257 249 this.abnormal = abnormal;
258 250 }
259 251  
260   - public String getState2() {
261   - return state2;
  252 + public String getSignalState() {
  253 + return signalState;
262 254 }
263 255  
264   - public void setState2(String state2) {
265   - this.state2 = state2;
  256 + public void setSignalState(String signalState) {
  257 + this.signalState = signalState;
  258 + }
  259 +
  260 + public int getInstation() {
  261 + return instation;
  262 + }
  263 +
  264 + public void setInstation(int instation) {
  265 + this.instation = instation;
266 266 }
267 267 }
... ...
src/main/java/com/bsth/data/gpsdata/GpsRealData.java
... ... @@ -2,11 +2,9 @@ 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   -import com.bsth.data.gpsdata.analyse.GeoCacheData;
9   -import com.bsth.data.gpsdata.analyse.GpsAnalyse;
  7 +import com.bsth.data.gpsdata.arrival.GpsRealAnalyse;
10 8 import com.bsth.data.gpsdata.recovery.GpsDataRecovery;
11 9 import com.bsth.data.schedule.DayOfSchedule;
12 10 import com.bsth.entity.realcontrol.ScheduleRealInfo;
... ... @@ -27,262 +25,202 @@ import org.springframework.stereotype.Component;
27 25 import java.io.BufferedReader;
28 26 import java.io.InputStreamReader;
29 27 import java.util.*;
30   -import java.util.concurrent.TimeUnit;
31 28  
32 29 /**
33   - *
  30 + * @author PanZhao
34 31 * @ClassName: GpsRealData
35 32 * @Description: TODO(实时GPS数据集合)
36   - * @author PanZhao
37 33 * @date 2016年8月12日 下午2:04:41
38   - *
39 34 */
40 35 @Component
41   -public class GpsRealData implements CommandLineRunner{
42   -
43   - static Logger logger = LoggerFactory.getLogger(GpsRealData.class);
44   -
45   - private static Map<String, GpsEntity> gpsMap;
46   -
47   - //按线路分组设备号
48   - private static TreeMultimap<String, String> lineCode2Devices;
49   -
50   - // 网关数据接口地址
51   - private static String url;
52   -
53   - @Autowired
54   - GpsDataLoader gpsDataLoader;
55   -
56   - @Autowired
57   - DayOfSchedule dayOfSchedule;
58   -
59   - @Autowired
60   - ForecastRealServer forecastRealServer;
61   -
62   - /**
63   - * 构造函数
64   - */
65   - public GpsRealData(){
66   - gpsMap = new HashMap<>();
67   - lineCode2Devices = TreeMultimap.create();
68   - url = ConfigUtil.get("http.gps.real.url");
69   - }
70   -
71   - @Override
72   - public void run(String... arg0) throws Exception {
73   - logger.info("gpsDataLoader,20,6");
74   - Application.mainServices.scheduleWithFixedDelay(gpsDataLoader, 40, 6, TimeUnit.SECONDS);
75   - }
76   -
77   - static final long CLEAR_DIFF = 1000 * 60 * 60 * 2;
78   - public GpsEntity add(GpsEntity gps) {
79   - String device = gps.getDeviceId();
80   - GpsEntity old = gpsMap.get(device);
81   -
82   - //断线2个小时,清除缓存数据
83   - if(gps.getTimestamp() - old.getTimestamp() > CLEAR_DIFF && gps.getNbbm() != null)
84   - GeoCacheData.clear(gps.getNbbm());
85   -
86   - //分析gps
87   - if(isAvailable(gps) && (old == null || old.getTimestamp() != gps.getTimestamp()))
88   - GpsAnalyse.start(gps);
89   -
90   - if(!StringUtils.isEmpty(gps.getStopNo())){
91   - //定时定距数据附带站点编码改变
92   - if(null == old || !gps.getStopNo().equals(old.getStopNo())){
93   - gps.setArrTime(gps.getTimestamp());
94   - //预测到达终点时间
95   - forecastRealServer.forecast(gps.getNbbm(), gps);
96   - }
97   - else{
98   - gps.setArrTime(old.getArrTime());
99   - //不预测, 重新计算终点时间
100   - gps.setExpectStopTime(forecastRealServer.expectStopTime(gps.getNbbm()));
101   - }
102   - }
103   -
104   - gpsMap.put(device, gps);
105   - if(StringUtils.isNotBlank(gps.getLineId()))
106   - lineCode2Devices.put(gps.getLineId(), device);
107   - return gps;
108   - }
109   -
110   - public boolean isAvailable(GpsEntity gps){
111   - return StringUtils.isNotEmpty(gps.getLineId()) &&
112   - dayOfSchedule.getCurrSchDate().containsKey(gps.getLineId());
113   - }
114   -
115   - /**
116   - *
117   - * @Title: get @Description: TODO(设备号获取GPS)
118   - */
119   - public GpsEntity get(String deviceId) {
120   - return gpsMap.get(deviceId);
121   - }
122   -
123   - /**
124   - *
125   - * @Title: get @Description: TODO(线路编码获取GPS集合) @throws
126   - */
127   - public List<GpsEntity> getByLine(String lineCode) {
128   - NavigableSet<String> set = lineCode2Devices.get(lineCode);
129   -
130   - List<GpsEntity> rs = new ArrayList<>();
131   - GpsEntity gps;
132   - ScheduleRealInfo sch;
133   - for(String device : set){
134   - gps = gpsMap.get(device);
135   - //过滤异常GPS数据
136   - if(gps.isAbnormal())
137   - continue;
138   -
139   - sch = dayOfSchedule.execPlanMap().get(gps.getNbbm());
140   - if(null != sch)
141   - gps.setSchId(sch.getId());
142   - rs.add(gps);
143   - }
144   -
145   - return rs;
146   - }
147   -
148   - public List<GpsEntity> get(List<String> pArray){
149   - List<GpsEntity> list = new ArrayList<>();
150   -
151   - for(String code : pArray)
152   - list.addAll(getByLine(code));
153   - return list;
154   - }
155   -
156   - public Set<String> allDevices(){
157   - return gpsMap.keySet();
158   - }
159   -
160   - public GpsEntity findByDeviceId(String deviceId) {
161   - return gpsMap.get(deviceId);
162   - }
163   -
164   - public Collection<GpsEntity> all(){
165   - return gpsMap.values();
166   - }
167   -
168   - public void remove(String device){
169   - gpsMap.remove(device);
170   - }
171   - @Component
172   - public static class GpsDataLoader extends Thread{
173   -
174   - Logger logger = LoggerFactory.getLogger(GpsDataLoader.class);
175   -
176   - @Autowired
177   - GpsRealData gpsRealData;
178   -
179   - @Override
180   - public void run() {
181   - try{
182   - //如果正在恢复数据
183   - if(GpsDataRecovery.run){
184   - return;
185   - }
186   -
187   - load();
188   - }catch(Exception e){
189   - logger.error("", e);
190   - }
191   - }
192   -
193   - public void load() throws Exception {
194   - List<GpsEntity> list = new ArrayList<>();
195   - CloseableHttpClient httpClient = null;
196   - CloseableHttpResponse response = null;
197   - try {
198   - httpClient = HttpClients.createDefault();
199   - HttpGet get = new HttpGet(url);
200   -
201   - response = httpClient.execute(get);
202   -
203   - HttpEntity entity = response.getEntity();
204   - if (null != entity) {
205   - // 返回数据量比较大,建议以流的形式读取
206   - BufferedReader br = new BufferedReader(new InputStreamReader(entity.getContent()));
207   - StringBuffer stringBuffer = new StringBuffer();
208   - String str = "";
209   - while ((str = br.readLine()) != null)
210   - stringBuffer.append(str);
211   -
212   - JSONObject jsonObj = JSON.parseObject(stringBuffer.toString());
213   -
214   - if (jsonObj != null)
215   - list = JSON.parseArray(jsonObj.getString("data"), GpsEntity.class);
216   -
217   - String nbbm;
218   - for(GpsEntity gps : list){
219   - //没有设备号
220   - if(StringUtils.isBlank(gps.getDeviceId()))
221   - continue;
222   -
223   - nbbm = BasicData.deviceId2NbbmMap.get(gps.getDeviceId());
224   - if(StringUtils.isBlank(nbbm))
225   - gps.setAbnormal(true);//标记为异常数据
226   - else
227   - gps.setNbbm(nbbm);
228   -
229   - gps.setStationName(BasicData.stationCode2NameMap.get(gps.getStopNo()));
230   - gpsRealData.add(gps);
231   -
232   - //纠正走向
233   - //correctUpdown(gps);
234   - }
235   - } else
236   - logger.error("result is null");
237   - } catch(Exception e){
238   - logger.error("", e);
239   - }
240   - finally {
241   - if (null != httpClient)
242   - httpClient.close();
243   - if(null != response)
244   - response.close();
245   - }
246   - }
247   -
248   - /**
249   - * 是否是起终点
250   - * @param gps
251   - * @return
252   -
253   - public boolean isSEPoint(GpsEntity gps){
254   - String key = gps.getLineId()+"_"+gps.getUpDown()+"_"
255   - ,stationCode;
256   -
257   - if(BasicData.lineSEPointMap.containsKey(key+"B")){
258   - stationCode = BasicData.lineSEPointMap.get(key+"B");
259   - if(gps.getStopNo().equals(stationCode)){
260   - gps.setsEPoint(true);
261   - return true;
262   - }
263   - }
264   -
265   - if(BasicData.lineSEPointMap.containsKey(key+"E")){
266   - stationCode = BasicData.lineSEPointMap.get(key+"E");
267   - if(gps.getStopNo().equals(stationCode)){
268   - gps.setsEPoint(true);
269   - return true;
270   - }
271   - }
272   - return false;
273   - }*/
274   -
275   - /**
276   - * 纠正上下行
277   - * @param gps
278   -
279   - public void correctUpdown(GpsEntity gps){
280   - Integer updown=BasicData.lineStationUpDownMap.get(gps.getLineId()+"_"+gps.getStopNo());
281   - if(updown != null && !updown.equals(gps.getUpDown()))
282   - gps.setUpDown(updown);
283   -
284   - if(isSEPoint(gps))
285   - return;
286   - }*/
287   - }
  36 +public class GpsRealData implements CommandLineRunner {
  37 +
  38 + static Logger logger = LoggerFactory.getLogger(GpsRealData.class);
  39 +
  40 + private static Map<String, GpsEntity> gpsMap;
  41 +
  42 + //按线路分组设备号
  43 + private static TreeMultimap<String, String> lineCode2Devices;
  44 +
  45 + // 网关数据接口地址
  46 + private static String url;
  47 +
  48 + @Autowired
  49 + GpsDataLoader gpsDataLoader;
  50 +
  51 + @Autowired
  52 + DayOfSchedule dayOfSchedule;
  53 +
  54 + @Autowired
  55 + ForecastRealServer forecastRealServer;
  56 +
  57 + /**
  58 + * 构造函数
  59 + */
  60 + public GpsRealData() {
  61 + gpsMap = new HashMap<>();
  62 + lineCode2Devices = TreeMultimap.create();
  63 + url = ConfigUtil.get("http.gps.real.url");
  64 + }
  65 +
  66 + @Override
  67 + public void run(String... arg0) throws Exception {
  68 + logger.info("gpsDataLoader,20,5");
  69 + //Application.mainServices.scheduleWithFixedDelay(gpsDataLoader, 20, 6, TimeUnit.SECONDS);
  70 + }
  71 +
  72 + public void put(GpsEntity gps) {
  73 + String device = gps.getDeviceId();
  74 + gpsMap.put(device, gps);
  75 +
  76 + if (StringUtils.isNotBlank(gps.getLineId())){
  77 + //站点名称
  78 + gps.setStationName(getStationName(gps));
  79 + lineCode2Devices.put(gps.getLineId(), device);
  80 + }
  81 + }
  82 +
  83 + public String getStationName(GpsEntity gps){
  84 + return BasicData.stationCode2NameMap.get(gps.getLineId() + "_" + gps.getUpDown() + gps.getStopNo());
  85 + }
  86 +
  87 + /**
  88 + * @Title: get @Description: TODO(设备号获取GPS)
  89 + */
  90 + public GpsEntity get(String deviceId) {
  91 + return gpsMap.get(deviceId);
  92 + }
  93 +
  94 + /**
  95 + * @Title: get @Description: TODO(线路编码获取GPS集合) @throws
  96 + */
  97 + public List<GpsEntity> getByLine(String lineCode) {
  98 + NavigableSet<String> set = lineCode2Devices.get(lineCode);
  99 +
  100 + List<GpsEntity> rs = new ArrayList<>();
  101 + GpsEntity gps;
  102 + ScheduleRealInfo sch;
  103 + for (String device : set) {
  104 + gps = gpsMap.get(device);
  105 + //过滤异常GPS数据
  106 + if (gps.isAbnormal())
  107 + continue;
  108 +
  109 + sch = dayOfSchedule.execPlanMap().get(gps.getNbbm());
  110 + if (null != sch)
  111 + gps.setSchId(sch.getId());
  112 + rs.add(gps);
  113 + }
  114 +
  115 + return rs;
  116 + }
  117 +
  118 + public List<GpsEntity> get(List<String> pArray) {
  119 + List<GpsEntity> list = new ArrayList<>();
  120 +
  121 + for (String code : pArray)
  122 + list.addAll(getByLine(code));
  123 + return list;
  124 + }
  125 +
  126 + public Set<String> allDevices() {
  127 + return gpsMap.keySet();
  128 + }
  129 +
  130 + public GpsEntity findByDeviceId(String deviceId) {
  131 + return gpsMap.get(deviceId);
  132 + }
  133 +
  134 + public Collection<GpsEntity> all() {
  135 + return gpsMap.values();
  136 + }
  137 +
  138 + public void remove(String device) {
  139 + gpsMap.remove(device);
  140 + }
  141 +
  142 + @Component
  143 + public static class GpsDataLoader extends Thread {
  144 +
  145 + Logger logger = LoggerFactory.getLogger(GpsDataLoader.class);
  146 +
  147 + @Autowired
  148 + GpsRealData gpsRealData;
  149 +
  150 + @Autowired
  151 + GpsRealAnalyse gpsRealAnalyse;
  152 +
  153 + @Override
  154 + public void run() {
  155 + try {
  156 + //如果正在恢复数据
  157 + if (GpsDataRecovery.run)
  158 + return;
  159 +
  160 + load();
  161 + } catch (Exception e) {
  162 + logger.error("", e);
  163 + }
  164 + }
  165 +
  166 + public void load() throws Exception {
  167 + List<GpsEntity> list = null;
  168 + List<GpsEntity> updateList = new ArrayList<>();
  169 + CloseableHttpClient httpClient = null;
  170 + CloseableHttpResponse response = null;
  171 + try {
  172 + httpClient = HttpClients.createDefault();
  173 + HttpGet get = new HttpGet(url);
  174 +
  175 + response = httpClient.execute(get);
  176 +
  177 + HttpEntity entity = response.getEntity();
  178 + if (null != entity) {
  179 + BufferedReader br = new BufferedReader(new InputStreamReader(entity.getContent()));
  180 + StringBuffer stringBuffer = new StringBuffer();
  181 + String str = "";
  182 + while ((str = br.readLine()) != null)
  183 + stringBuffer.append(str);
  184 +
  185 + JSONObject jsonObj = JSON.parseObject(stringBuffer.toString());
  186 +
  187 + if (jsonObj != null)
  188 + list = JSON.parseArray(jsonObj.getString("data"), GpsEntity.class);
  189 +
  190 + String nbbm;
  191 + GpsEntity old;
  192 + for (GpsEntity gps : list) {
  193 + //没有设备号
  194 + if (StringUtils.isBlank(gps.getDeviceId()))
  195 + continue;
  196 +
  197 + old = gpsMap.get(gps.getDeviceId());
  198 + if (old != null &&
  199 + old.getTimestamp() == gps.getTimestamp())
  200 + continue;
  201 +
  202 + nbbm = BasicData.deviceId2NbbmMap.get(gps.getDeviceId());
  203 + if (StringUtils.isBlank(nbbm))
  204 + gps.setAbnormal(true);//标记为异常数据
  205 + else
  206 + gps.setNbbm(nbbm);
  207 + //有更新的点位
  208 + updateList.add(gps);
  209 + //实时GPS数据集
  210 + gpsRealData.put(gps);
  211 + }
  212 + //分析数据
  213 + gpsRealAnalyse.analyse(updateList);
  214 + } else
  215 + logger.error("real gps result is null");
  216 + } catch (Exception e) {
  217 + logger.error("", e);
  218 + } finally {
  219 + if (null != httpClient)
  220 + httpClient.close();
  221 + if (null != response)
  222 + response.close();
  223 + }
  224 + }
  225 + }
288 226 }
289 227 \ No newline at end of file
... ...
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/analyse/GpsAnalyse.java deleted 100644 → 0
1   -package com.bsth.data.gpsdata.analyse;
2   -
3   -import com.bsth.data.gpsdata.GpsEntity;
4   -import com.bsth.data.gpsdata.analyse.components.GpsArrival;
5   -import org.slf4j.Logger;
6   -import org.slf4j.LoggerFactory;
7   -
8   -import java.util.concurrent.ExecutorService;
9   -import java.util.concurrent.Executors;
10   -
11   -/**
12   - * 分析gps状态信息
13   - * Created by panzhao on 2016/12/23.
14   - */
15   -public class GpsAnalyse {
16   -
17   - static Logger logger = LoggerFactory.getLogger(GpsAnalyse.class);
18   -
19   - //线程池
20   - static ExecutorService threadPool = Executors.newFixedThreadPool(50);
21   -
22   - public static void start(GpsEntity gps) {
23   - threadPool.execute(new ArrivalMatchThread(gps));
24   - }
25   -
26   - public static class ArrivalMatchThread implements Runnable {
27   -
28   - private GpsEntity gps;
29   -
30   - public ArrivalMatchThread(GpsEntity gps) {
31   - this.gps = gps;
32   - }
33   -
34   - @Override
35   - public void run() {
36   - GpsArrival.arrival(gps);
37   - }
38   - }
39   -}
40 0 \ No newline at end of file
src/main/java/com/bsth/data/gpsdata/analyse/components/GpsArrival.java deleted 100644 → 0
1   -package com.bsth.data.gpsdata.analyse.components;
2   -
3   -import com.bsth.data.LineConfigData;
4   -import com.bsth.data.gpsdata.GpsEntity;
5   -import com.bsth.data.gpsdata.analyse.CircleQueue;
6   -import com.bsth.data.gpsdata.analyse.GeoCacheData;
7   -import com.bsth.data.gpsdata.analyse.StationRoute;
8   -import com.bsth.data.gpsdata.analyse.util.GeoUtils;
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.slf4j.Logger;
15   -import org.slf4j.LoggerFactory;
16   -import org.springframework.beans.BeansException;
17   -import org.springframework.context.ApplicationContext;
18   -import org.springframework.context.ApplicationContextAware;
19   -import org.springframework.stereotype.Component;
20   -
21   -import java.util.List;
22   -
23   -/**
24   - * gps 到离站判断
25   - * Created by panzhao on 2016/12/24.
26   - */
27   -@Component
28   -public class GpsArrival implements ApplicationContextAware {
29   -
30   - static Logger logger = LoggerFactory.getLogger(GpsArrival.class);
31   -
32   - static DayOfSchedule dayOfSchedule;
33   - static LineConfigData lineConfigData;
34   - static SendUtils sendUtils;
35   - static DirectiveService directiveService;
36   -
37   - public static void arrival(GpsEntity gps) {
38   -
39   - if (gps.getLat() == 0 || gps.getLon() == 0) {
40   - //logger.error("无效的gps");
41   - return;
42   - }
43   -
44   - Object task = DayOfSchedule.executeCurr(gps.getNbbm());
45   - if (task == null)
46   - return;
47   - if (task.getClass().isAssignableFrom(ScheduleRealInfo.class)) {
48   - ScheduleRealInfo sch = (ScheduleRealInfo) task;
49   - //和班次同步走向
50   - gps.setUpDown(Integer.parseInt(sch.getXlDir()));
51   -
52   - //出场
53   - if (sch.getBcType().equals("out")) {
54   - outCarpark(gps, sch);
55   - } else if (sch.getBcType().equals("normal"))
56   - normalInOut(gps, sch);
57   - else if (sch.getBcType().equals("in")) {
58   - inCarpark(gps, sch);
59   - }
60   - }
61   -
62   - GeoCacheData.putGps(gps);
63   - }
64   -
65   - /**
66   - * 正常班次
67   - *
68   - * @param gps
69   - * @param sch
70   - */
71   - private static void normalInOut(GpsEntity gps, ScheduleRealInfo sch) {
72   - CircleQueue<GpsEntity> queue = GeoCacheData.getGps(gps.getNbbm());
73   - GpsEntity prev = null;
74   - if (queue != null)
75   - prev = queue.getTail();
76   -
77   - List<StationRoute> srs = GeoCacheData.getStationRoute(sch.getXlBm(), gps.getUpDown());
78   - StationRoute station = GeoUtils.gpsInStation(gps, srs);
79   -
80   - if (station != null) {
81   - //站内
82   - gps.setStopNo(station.getCode());
83   - gps.setInstation(true);
84   - stationInside(gps, prev, sch);
85   - } else {
86   - //站外
87   - stationOutside(gps, prev, sch);
88   - }
89   - }
90   -
91   - /**
92   - * GPS在站点内
93   - *
94   - * @param gps
95   - * @param prev
96   - * @param sch
97   - */
98   - private static void stationInside(GpsEntity gps, GpsEntity prev, ScheduleRealInfo sch) {
99   - if (prev == null)
100   - return;
101   -
102   - if (gps.getStopNo().equals(sch.getZdzCode()) && sch.getZdsjActual() == null) {
103   - //到终点站
104   - arriveEnd(sch, gps);
105   - return;
106   - }
107   -
108   - //上一个点在站外
109   - if (!prev.isInstation())
110   - return;
111   - //超过 (待发时间 + 90%的单程运送时间) 并且超过下一个班次的待发时间,还在起点站。默认烂一圈
112   - if (prev.getStopNo().equals(gps.getStopNo())) {
113   - if (gps.getStopNo().equals(sch.getQdzCode())
114   - && gps.getTimestamp() > sch.getDfsjT() + (sch.getBcsj() * 60 * 1000 * 0.9)) {
115   -
116   - ScheduleRealInfo next = dayOfSchedule.next(sch);
117   - if(gps.getTimestamp() > next.getDfsjT())
118   - dayOfSchedule.addExecPlan(dayOfSchedule.next(next));
119   - }
120   - return;
121   - }
122   -
123   - //发车
124   - if (prev.getStopNo().equals(sch.getQdzCode())) {
125   - busWillDepart(sch, gps);
126   - return;
127   - }
128   -
129   - if (gps.getUpDown() != prev.getUpDown())
130   - return;
131   -
132   - //中途站
133   - StationRoute prevStation = GeoCacheData.getStation(prev.getLineId(), prev.getUpDown(), prev.getStopNo());
134   - StationRoute currStation = GeoCacheData.getStation(gps.getLineId(), gps.getUpDown(), gps.getStopNo());
135   - if (currStation.getRouteSort() < prevStation.getRouteSort()) {
136   - //开始下一个班次
137   - finishPlan(sch);
138   -
139   - logger.info("路由反向。。。。。。:" + gps.getTimestamp());
140   - //为班次补上实际时间
141   - }
142   - }
143   -
144   - /**
145   - * GPS在站点外
146   - *
147   - * @param gps
148   - * @param prev
149   - * @param sch
150   - */
151   - private static void stationOutside(GpsEntity gps, GpsEntity prev, ScheduleRealInfo sch) {
152   - if (prev == null)
153   - return;
154   -
155   - gps.setStopNo(prev.getStopNo());
156   - if (prev.isInstation() && prev.getStopNo().equals(sch.getQdzCode())) {
157   - //发车
158   - busWillDepart(sch, gps);
159   - return;
160   - }
161   - }
162   -
163   - /**
164   - * 公交车起点发出
165   - */
166   - final static long DRIFT_VAL_TIME = 1000 * 60 * 10;
167   - //班次最大差值2小时
168   - final static long MAX_DIFF = 1000 * 60 * 60 * 2;
169   -
170   - private static void busWillDepart(ScheduleRealInfo sch, GpsEntity gps) {
171   - //实发时间不覆盖
172   - if (sch.getFcsjActual() == null && Math.abs(gps.getTimestamp() - sch.getDfsjT()) < MAX_DIFF) {
173   -
174   - //提前10分钟以上发出,判断一下是否是漂移
175   - /*if (sch.getDfsjT() - gps.getTimestamp() > DRIFT_VAL_TIME) {
176   - ScheduleRealInfo schPrev = dayOfSchedule.prev(sch);
177   - if (schPrev != null && schPrev.getZdsjActual() != null) {
178   - //计划停站时间
179   - long stopTimeJH = sch.getDfsjT() - schPrev.getZdsjT();
180   - //实际停站时间
181   - long actualStopTime = gps.getTimestamp() - schPrev.getZdsjActualTime();
182   - *//*
183   - 没停够计划百分之30的,算漂移
184   - (这里出现的误判,由程序在车辆到中途站的时候进行补偿)
185   - *//*
186   - if (stopTimeJH * 0.3 > actualStopTime) {
187   - logger.info("漂移.... 车辆:" + gps.getNbbm() + " ts: " + gps.getTimestamp());
188   - return;
189   - }
190   - }
191   - }*/
192   -
193   - LineConfig config = lineConfigData.get(sch.getXlBm());
194   - if (config != null && config.getOutConfig() == 2) {
195   - //出站既出场
196   - ScheduleRealInfo schPrev = dayOfSchedule.prev(sch);
197   - if (schPrev.getBcType().equals("out")) {
198   - schPrev.setFcsjActualAll(gps.getTimestamp());
199   - schPrev.setZdsjActualAll(gps.getTimestamp());
200   - }
201   - }
202   -
203   - sch.setFcsjActualAll(gps.getTimestamp());
204   - //通知客户端
205   - sendUtils.sendFcsj(sch);
206   - //持久化
207   - dayOfSchedule.save(sch);
208   - logger.info("(站外)班次:" + sch.getDfsj() + "发车, 时间:" + sch.getFcsjActual());
209   - }
210   - }
211   -
212   - /**
213   - * 公交车到达终点
214   - *
215   - * @param sch
216   - * @param gps
217   - */
218   - private static void arriveEnd(ScheduleRealInfo sch, GpsEntity gps) {
219   - if(Math.abs(gps.getTimestamp() - sch.getZdsjT()) >= MAX_DIFF)
220   - return;
221   -
222   - sch.setZdsjActualAll(gps.getTimestamp());
223   - ScheduleRealInfo next = finishPlan(sch);
224   - //已完成班次数
225   - int doneSum = dayOfSchedule.doneSum(sch.getClZbh());
226   - //通知客户端
227   - sendUtils.sendZdsj(sch, next, doneSum);
228   - //持久化
229   - dayOfSchedule.save(sch);
230   - logger.info("班次:" + sch.getDfsj() + "到达终点, 时间:" + sch.getZdsjActual());
231   -
232   - if (next == null)
233   - return;
234   -
235   - LineConfig config = lineConfigData.get(sch.getXlBm());
236   - //进站既进场
237   - if (next.getBcType().equals("in") &&
238   - config != null && config.getOutConfig() == 2) {
239   - next.setFcsjActualAll(gps.getTimestamp());
240   - next.setZdsjActualAll(gps.getTimestamp());
241   -
242   - finishPlan(next);
243   - } else {
244   - //下发调度指令
245   - directiveService.send60Dispatch(next, doneSum, "到站@系统");
246   -
247   - //套跑 -下发线路切换指令
248   - /* if (!next.getXlBm().equals(sch.getXlBm()))
249   - directiveService.lineChange(sch.getClZbh(), next.getXlBm(), "套跑@系统");*/
250   - }
251   -
252   - //将gps转换为下一个班次走向的站内信号
253   - int updown = Integer.parseInt(next.getXlDir());
254   - List<StationRoute> srs = GeoCacheData.getStationRoute(next.getXlBm(), updown);
255   - StationRoute station = GeoUtils.gpsInStation(gps, srs);
256   - if (station != null) {
257   - gps.setUpDown(updown);
258   - gps.setStopNo(station.getCode());
259   - }
260   - }
261   -
262   - /**
263   - * 出场班次
264   - *
265   - * @param gps
266   - * @param sch
267   - */
268   - private static void outCarpark(GpsEntity gps, ScheduleRealInfo sch) {
269   - CircleQueue<GpsEntity> queue = GeoCacheData.getGps(gps.getNbbm());
270   - GpsEntity prev = null;
271   - if (queue != null)
272   - prev = queue.getTail();
273   -
274   - //是否在停车场内
275   - String carpark = GeoUtils.gpsInCarpark(gps);
276   - if (carpark != null && carpark.equals(sch.getQdzCode())) {
277   - gps.setInstation(true);
278   - gps.setStopNo(carpark);
279   - return; // 还在场内
280   - }
281   -
282   - List<StationRoute> srs = GeoCacheData.getStationRoute(sch.getXlBm(), gps.getUpDown());
283   - StationRoute station = GeoUtils.gpsInStation(gps, srs);
284   - //线路上 站点内
285   - if (station != null) {
286   - gps.setInstation(true);
287   - gps.setStopNo(station.getCode());
288   -
289   - //上一个点附带的站点站标记
290   - if (prev != null && prev.getStopNo() != null
291   - && prev.getStopNo().equals(sch.getZdzCode()))
292   - return;
293   -
294   - //到达终点
295   - if (station.getCode().equals(sch.getZdzCode()))
296   - arriveEnd(sch, gps);
297   - }
298   -
299   - //上一个点在场内
300   - if (prev != null && prev.isInstation() && prev.getStopNo().equals(sch.getQdzCode())) {
301   - //当前点在场外
302   - if (carpark == null) {
303   - gps.setStopNo(prev.getStopNo());
304   - //停车场发出
305   - busWillDepart(sch, gps);
306   - return;
307   - }
308   - }
309   - }
310   -
311   -
312   - /**
313   - * 进场班次
314   - *
315   - * @param gps
316   - * @param sch
317   - */
318   - private static void inCarpark(GpsEntity gps, ScheduleRealInfo sch) {
319   - String carpark = GeoUtils.gpsInCarpark(gps);
320   - if (carpark != null && carpark.equals(sch.getZdzCode())) {
321   - //进场班次取第一个实际进场时间
322   - if (sch.getZdsjActual() != null)
323   - return;
324   -
325   - //进场
326   - arriveEnd(sch, gps);
327   - return;
328   - }
329   -
330   - CircleQueue<GpsEntity> queue = GeoCacheData.getGps(gps.getNbbm());
331   - if (queue == null)
332   - return;
333   - //上一个gps
334   - GpsEntity prev = queue.getTail();
335   -
336   - if (carpark == null && prev.isInstation() && prev.getStopNo().equals(sch.getQdzCode())) {
337   - gps.setStopNo(prev.getStopNo());
338   - //进场班次发出
339   - busWillDepart(sch, gps);
340   - return;
341   - }
342   - }
343   -
344   - /**
345   - * 完成班次 -返回下一个班次
346   - *
347   - * @param sch
348   - */
349   - private static ScheduleRealInfo finishPlan(ScheduleRealInfo sch) {
350   - ScheduleRealInfo next = dayOfSchedule.next(sch);
351   - if (next != null) {
352   - next.setQdzArrDatesj(sch.getZdsjActual());
353   - dayOfSchedule.addExecPlan(next);
354   - }
355   - return next;
356   - }
357   -
358   - @Override
359   - public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
360   - dayOfSchedule = applicationContext.getBean(DayOfSchedule.class);
361   - lineConfigData = applicationContext.getBean(LineConfigData.class);
362   - sendUtils = applicationContext.getBean(SendUtils.class);
363   - directiveService = applicationContext.getBean(DirectiveService.class);
364   - }
365   -}
src/main/java/com/bsth/data/gpsdata/analyse/components/GpsStateCorrective.java deleted 100644 → 0
1   -package com.bsth.data.gpsdata.analyse.components;
2   -
3   -import com.bsth.data.gpsdata.GpsEntity;
4   -import com.bsth.data.schedule.DayOfSchedule;
5   -import com.bsth.entity.realcontrol.ScheduleRealInfo;
6   -import com.vividsolutions.jts.geom.GeometryFactory;
7   -import org.joda.time.format.DateTimeFormat;
8   -import org.joda.time.format.DateTimeFormatter;
9   -import org.slf4j.Logger;
10   -import org.slf4j.LoggerFactory;
11   -import org.springframework.beans.BeansException;
12   -import org.springframework.context.ApplicationContext;
13   -import org.springframework.context.ApplicationContextAware;
14   -import org.springframework.stereotype.Component;
15   -
16   -/**
17   - * GPS状态纠正
18   - * Created by panzhao on 2016/12/23.
19   - */
20   -@Component
21   -public class GpsStateCorrective implements ApplicationContextAware {
22   -
23   - static Logger logger = LoggerFactory.getLogger(GpsStateCorrective.class);
24   -
25   - static DayOfSchedule dayOfSchedule;
26   -
27   - private static GeometryFactory geometryFactory = new GeometryFactory();
28   -
29   - public static void correct(GpsEntity gps, ScheduleRealInfo sch){
30   -/* int upDown = Integer.parseInt(sch.getXlDir());
31   - gps.setUpDown(upDown);
32   - List<StationRoute> srs = GeoCacheData.getStationRoute(sch.getXlBm(), upDown);
33   -
34   - Point point = geometryFactory.createPoint(new Coordinate(gps.getLat(), gps.getLon()));
35   -
36   - //之前的点位
37   - CircleQueue<GpsEntity> queue = GeoCacheData.getGps(gps.getNbbm());
38   - GpsEntity prev = null;
39   - if(queue != null)
40   - prev = queue.getTail();
41   -
42   - //线路上,站点间
43   - StationRoute station = GeoUtils.pointInStation(point, srs);
44   - //在站内
45   - if(station != null){
46   - gps.setStopNo(station.getCode());
47   - gps.setInstation(true);
48   - gps.setStation(station);
49   -
50   - if(prev != null && prev.getUpDown() == upDown){
51   - StationRoute prevStation = GeoCacheData.getStation(prev.getLineId(), upDown, prev.getStopNo());
52   -
53   - //倒着开??
54   - if(prevStation.getRouteSort() > station.getRouteSort()){
55   - reversalHandle(gps, prev, sch);
56   - }
57   - }
58   - }
59   - else{
60   - if(prev != null)
61   - gps.setStopNo(prev.getStopNo());
62   - }
63   -
64   - //是否在停车场内
65   - Map<String, Polygon> carparkMap = GeoCacheData.tccMap;
66   - Set<String> codes = carparkMap.keySet();
67   - Polygon p;
68   - for(String code : codes){
69   - p = carparkMap.get(code);
70   - //场内
71   - if(p.contains(point)){
72   - gps.setCarparkNo(code);
73   - if(sch.getBcType().equals("out")){
74   - gps.setInstation(true);
75   - gps.setStopNo(code);
76   - }
77   - }
78   - }*/
79   - }
80   -
81   - private static DateTimeFormatter fmt = DateTimeFormat.forPattern("HH:mm");
82   -
83   - private static void reversalHandle(GpsEntity gps, GpsEntity prev, ScheduleRealInfo sch){
84   - /*if(sch.getBcType().equals("out") && gps.getTimestamp() < sch.getZdsjT())
85   - return;
86   -
87   - //先假设没到终点,直接开始了下一个班次
88   - ScheduleRealInfo next = dayOfSchedule.next(sch);
89   - String log = "倒着开??? nbbm: " + gps.getNbbm() + " 当前:" + gps.getStopNo() + " 上一站:" + prev.getStopNo() + " 当前班次:" + sch.getDfsj();
90   - if(next != null){
91   - dayOfSchedule.addExecPlan(next);
92   -
93   - log += (" 下一个班次:" + next.getDfsj());
94   - }
95   -
96   - log += (" GPS时间:" + fmt.print(gps.getTimestamp()));
97   -
98   - logger.info(log);*/
99   - }
100   -
101   - @Override
102   - public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
103   - dayOfSchedule = applicationContext.getBean(DayOfSchedule.class);
104   - }
105   -}
src/main/java/com/bsth/data/gpsdata/analyse/GeoCacheData.java renamed to src/main/java/com/bsth/data/gpsdata/arrival/GeoCacheData.java
1   -package com.bsth.data.gpsdata.analyse;
  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;
  5 +import com.bsth.data.gpsdata.arrival.utils.CircleQueue;
  6 +import com.bsth.data.gpsdata.arrival.utils.StationRouteComp;
4 7 import com.google.common.collect.ArrayListMultimap;
5 8 import com.vividsolutions.jts.geom.Coordinate;
6 9 import com.vividsolutions.jts.geom.GeometryFactory;
... ... @@ -26,8 +29,8 @@ public class GeoCacheData {
26 29  
27 30 static Logger logger = LoggerFactory.getLogger(GeoCacheData.class);
28 31  
29   - //每辆车缓存最后200条gps
30   - private static final int CACHE_SIZE = 200;
  32 + //每辆车缓存最后1000条gps
  33 + private static final int CACHE_SIZE = 1000;
31 34 private static Map<String, CircleQueue<GpsEntity>> gpsCacheMap = new HashMap<>();
32 35  
33 36 //线路路段走向
... ... @@ -36,6 +39,9 @@ public class GeoCacheData {
36 39 //线路站点路由
37 40 private static ArrayListMultimap<String, StationRoute> stationCacheMap;
38 41  
  42 + //线路_上下行_站点编码 ——> 站点
  43 + private static Map<String, StationRoute> routeCodeMap;
  44 +
39 45 //停车场
40 46 public static Map<String, Polygon> tccMap;
41 47  
... ... @@ -49,9 +55,9 @@ public class GeoCacheData {
49 55 public static void putGps(GpsEntity gps) {
50 56 CircleQueue<GpsEntity> queue = gpsCacheMap.get(gps.getNbbm());
51 57 if (queue == null) {
52   - //第一个点从站内开始
53   - if (!gps.isInstation())
54   - return;
  58 + /*//第一个点从站内开始
  59 + if (gps.getInstation() == 0)
  60 + return;*/
55 61  
56 62 queue = new CircleQueue<>(CACHE_SIZE);
57 63 gpsCacheMap.put(gps.getNbbm(), queue);
... ... @@ -69,6 +75,10 @@ public class GeoCacheData {
69 75 }
70 76 }
71 77  
  78 + public static StationRoute getRouteCode(GpsEntity gps) {
  79 + return routeCodeMap.get(gps.getLineId() + "_" + gps.getUpDown() + "_" + gps.getStopNo());
  80 + }
  81 +
72 82 public static List<StationRoute> getStationRoute(String lineCode, int directions) {
73 83 return stationCacheMap.get(lineCode + "_" + directions);
74 84 }
... ... @@ -84,6 +94,21 @@ public class GeoCacheData {
84 94 return null;
85 95 }
86 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 +
87 112 public static Polygon getTccPolygon(String code) {
88 113 return tccMap.get(code);
89 114 }
... ... @@ -91,7 +116,7 @@ public class GeoCacheData {
91 116 public void loadData() {
92 117 final GeometryFactory geometryFactory = new GeometryFactory();
93 118 //加载站点路由
94   - String sql = "select r.LINE_CODE,r.DIRECTIONS,r.STATION_CODE,r.STATION_MARK,s.SHAPES_TYPE,s.G_LONX,s.G_LATY,ST_AsText(s.G_POLYGON_GRID) as G_POLYGON_GRID,s.RADIUS, r.STATION_ROUTE_CODE from bsth_c_stationroute r left join bsth_c_station s on r.station=s.id where r.destroy=0 order by r.station_route_code";
  119 + String sql = "select r.LINE_CODE,r.DIRECTIONS,r.STATION_CODE,r.STATION_MARK,s.SHAPES_TYPE,s.G_LONX,s.G_LATY,ST_AsText(s.G_POLYGON_GRID) as G_POLYGON_GRID,s.RADIUS, r.STATION_ROUTE_CODE,s.STATION_NAME from bsth_c_stationroute r left join bsth_c_station s on r.station=s.id where r.destroy=0 order by r.station_route_code";
95 120 List<StationRoute> routeList = jdbcTemplate.query(sql, new RowMapper<StationRoute>() {
96 121 @Override
97 122 public StationRoute mapRow(ResultSet rs, int rowNum) throws SQLException {
... ... @@ -103,6 +128,7 @@ public class GeoCacheData {
103 128 sRoute.setRadius(rs.getFloat("RADIUS"));
104 129 sRoute.setRouteSort(rs.getInt("STATION_ROUTE_CODE"));
105 130 sRoute.setMark(rs.getString("STATION_MARK"));
  131 + sRoute.setName(rs.getString("STATION_NAME"));
106 132  
107 133 String shapesType = rs.getString("SHAPES_TYPE");
108 134 //多边形电子围栏
... ... @@ -115,8 +141,11 @@ public class GeoCacheData {
115 141 //按线路和走向分组
116 142 if (routeList.size() > 0) {
117 143 ArrayListMultimap<String, StationRoute> tempMap = ArrayListMultimap.create();
  144 + Map<String, StationRoute> codeMap = new HashMap<>(routeList.size());
118 145 for (StationRoute sr : routeList) {
119 146 tempMap.put(sr.getLineCode() + "_" + sr.getDirections(), sr);
  147 + //站点编码 ——> 和路由顺序对照
  148 + codeMap.put(sr.getLineCode() + "_" + sr.getDirections() + "_" + sr.getCode(), sr);
120 149 }
121 150  
122 151 StationRouteComp srCom = new StationRouteComp();
... ... @@ -128,6 +157,7 @@ public class GeoCacheData {
128 157 }
129 158  
130 159 stationCacheMap = tempMap;
  160 + routeCodeMap = codeMap;
131 161 }
132 162  
133 163 //加载停车场数据
... ... @@ -176,4 +206,16 @@ public class GeoCacheData {
176 206 }
177 207 return cds;
178 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 + }
179 221 }
180 222 \ No newline at end of file
... ...
src/main/java/com/bsth/data/gpsdata/arrival/GpsRealAnalyse.java 0 → 100644
  1 +package com.bsth.data.gpsdata.arrival;
  2 +
  3 +import com.bsth.data.gpsdata.GpsEntity;
  4 +import com.bsth.data.gpsdata.arrival.handlers.*;
  5 +import com.bsth.data.gpsdata.arrival.utils.CircleQueue;
  6 +import org.slf4j.Logger;
  7 +import org.slf4j.LoggerFactory;
  8 +import org.springframework.beans.factory.annotation.Autowired;
  9 +import org.springframework.stereotype.Component;
  10 +
  11 +import java.util.List;
  12 +import java.util.concurrent.CountDownLatch;
  13 +import java.util.concurrent.ExecutorService;
  14 +import java.util.concurrent.Executors;
  15 +
  16 +/**
  17 + * gps 实时数据分析
  18 + * Created by panzhao on 2016/12/27.
  19 + */
  20 +@Component
  21 +public class GpsRealAnalyse {
  22 +
  23 + Logger logger = LoggerFactory.getLogger(this.getClass());
  24 +
  25 + @Autowired
  26 + OfflineSignalHandle offlineSignalHandle;
  27 + @Autowired
  28 + CorrectSignalHandle correctSignalHandle;
  29 + @Autowired
  30 + StationInsideHandle stationInsideHandle;
  31 + @Autowired
  32 + InOutStationSignalHandle inOutStationSignalHandle;
  33 + @Autowired
  34 + ReverseSignalHandle reverseSignalHandle;
  35 +
  36 + //50个线程
  37 + static ExecutorService threadPool = Executors.newFixedThreadPool(50);
  38 +
  39 + public void analyse(List<GpsEntity> list) {
  40 + CountDownLatch count = new CountDownLatch(list.size());
  41 +
  42 + for(GpsEntity gps : list)
  43 + threadPool.execute(new SignalHandleThread(gps, count));
  44 +
  45 + try {
  46 + //等待子线程结束
  47 + count.await();
  48 + } catch (InterruptedException e) {
  49 + logger.error("", e);
  50 + }
  51 + }
  52 +
  53 + public class SignalHandleThread implements Runnable {
  54 +
  55 + GpsEntity gps;
  56 + CountDownLatch count;
  57 +
  58 + SignalHandleThread(GpsEntity gps, CountDownLatch count) {
  59 + this.gps = gps;
  60 + this.count = count;
  61 + }
  62 +
  63 + @Override
  64 + public void run() {
  65 +
  66 + try {
  67 + CircleQueue<GpsEntity> prevs = GeoCacheData.getGps(gps.getNbbm());
  68 + //掉线处理
  69 + offlineSignalHandle.handle(gps, prevs);
  70 + //状态处理
  71 + if(!correctSignalHandle.handle(gps, prevs))
  72 + return;
  73 + //场,站内外判断
  74 + stationInsideHandle.handle(gps, prevs);
  75 + //反向处理
  76 + reverseSignalHandle.handle(gps, prevs);
  77 + //进出站动作处理
  78 + inOutStationSignalHandle.handle(gps, prevs);
  79 + GeoCacheData.putGps(gps);
  80 +
  81 + } catch (Exception e) {
  82 + logger.error("", e);
  83 + } finally {
  84 + count.countDown();
  85 + }
  86 + }
  87 + }
  88 +}
... ...
src/main/java/com/bsth/data/gpsdata/arrival/SignalHandle.java 0 → 100644
  1 +package com.bsth.data.gpsdata.arrival;
  2 +
  3 +import com.bsth.data.gpsdata.GpsEntity;
  4 +import com.bsth.data.gpsdata.arrival.entity.StationRoute;
  5 +import com.bsth.data.gpsdata.arrival.utils.CircleQueue;
  6 +import com.bsth.data.gpsdata.arrival.utils.GeoUtils;
  7 +import com.bsth.entity.realcontrol.ScheduleRealInfo;
  8 +
  9 +import java.util.List;
  10 +
  11 +/**
  12 + * Created by panzhao on 2016/12/27.
  13 + */
  14 +public abstract class SignalHandle {
  15 +
  16 + public abstract boolean handle(GpsEntity gps, CircleQueue<GpsEntity> prevs);
  17 +
  18 + protected boolean isNotEmpty(CircleQueue<GpsEntity> prevs) {
  19 + return prevs != null && prevs.size() > 0 && prevs.getTail() != null;
  20 + }
  21 +
  22 + protected boolean isDriftSignal(GpsEntity gps) {
  23 + return gps.getLat() == 0 || gps.getLon() == 0;
  24 + }
  25 +
  26 + /**
  27 + * 是不是异常信号
  28 + *
  29 + * @param gps
  30 + * @return protected boolean isAbnormal(GpsEntity gps) {
  31 + return gps.getLat() == 0 || gps.getLon() == 0;
  32 + }*/
  33 +
  34 + /**
  35 + * 连续异常信号个数统计
  36 + *
  37 + * @param prevs
  38 + * @return protected int abnormalCount(CircleQueue<GpsEntity> prevs) {
  39 + * int count = 0;
  40 + * <p>
  41 + * if (!isNotEmpty(prevs))
  42 + * return count;
  43 + * <p>
  44 + * GpsEntity[] array = (GpsEntity[]) prevs.getQueue();
  45 + * GpsEntity gps;
  46 + * for (int i = array.length - 1; i > 0; i--) {
  47 + * gps = array[i];
  48 + * <p>
  49 + * if (isAbnormal(gps))
  50 + * count++;
  51 + * else
  52 + * break;
  53 + * }
  54 + * <p>
  55 + * return count;
  56 + * }
  57 + */
  58 +
  59 + protected void transformUpdown(GpsEntity gps, ScheduleRealInfo sch) {
  60 + int updown = Integer.parseInt(sch.getXlDir());
  61 + List<StationRoute> srs = GeoCacheData.getStationRoute(sch.getXlBm(), updown);
  62 + StationRoute station = GeoUtils.gpsInStation(gps, srs);
  63 + if (station != null) {
  64 + gps.setUpDown(updown);
  65 + gps.setStopNo(station.getCode());
  66 + }
  67 + }
  68 +
  69 + /**
  70 + * 是否是从异常状态恢复的第一个信号
  71 + *
  72 + * @param gps
  73 + * @param prevs
  74 + * @return
  75 + */
  76 + protected boolean abnormalRecovery(GpsEntity gps, CircleQueue<GpsEntity> prevs) {
  77 + if (prevs == null || prevs.size() == 0)
  78 + return false;
  79 +
  80 + GpsEntity prev = prevs.getTail();
  81 + //从漂移状态恢复
  82 + if (isDriftSignal(prev)
  83 + && !isDriftSignal(gps)) {
  84 + return true;
  85 + }
  86 +
  87 + return false;
  88 + }
  89 +}
0 90 \ No newline at end of file
... ...
src/main/java/com/bsth/data/gpsdata/arrival/entity/RouteReverse.java 0 → 100644
  1 +package com.bsth.data.gpsdata.arrival.entity;
  2 +
  3 +/** 路由反转
  4 + * Created by panzhao on 2016/12/28.
  5 + */
  6 +public class RouteReverse {
  7 +
  8 + private String nbbm;
  9 + //反转个数
  10 + private int count;
  11 +
  12 + //详细 1,2,3,2,1
  13 + private String detail;
  14 +
  15 + //掉头站点
  16 + private String turned;
  17 +
  18 + //掉头时间
  19 + private long zt;
  20 +
  21 + //检测时间
  22 + private long ct;
  23 +
  24 + //是否闭合
  25 + private boolean close;
  26 +
  27 + //信号不明确
  28 + private boolean vague;
  29 +
  30 + public int getCount() {
  31 + return count;
  32 + }
  33 +
  34 + public void setCount(int count) {
  35 + this.count = count;
  36 + }
  37 +
  38 + public String getDetail() {
  39 + return detail;
  40 + }
  41 +
  42 + public void setDetail(String detail) {
  43 + this.detail = detail;
  44 + }
  45 +
  46 + public String getTurned() {
  47 + return turned;
  48 + }
  49 +
  50 + public void setTurned(String turned) {
  51 + this.turned = turned;
  52 + }
  53 +
  54 + public boolean isClose() {
  55 + return close;
  56 + }
  57 +
  58 + public void setClose(boolean close) {
  59 + this.close = close;
  60 + }
  61 +
  62 + public long getZt() {
  63 + return zt;
  64 + }
  65 +
  66 + public void setZt(long zt) {
  67 + this.zt = zt;
  68 + }
  69 +
  70 + public long getCt() {
  71 + return ct;
  72 + }
  73 +
  74 + public void setCt(long ct) {
  75 + this.ct = ct;
  76 + }
  77 +
  78 + public String getNbbm() {
  79 + return nbbm;
  80 + }
  81 +
  82 + public void setNbbm(String nbbm) {
  83 + this.nbbm = nbbm;
  84 + }
  85 +
  86 + public boolean isVague() {
  87 + return vague;
  88 + }
  89 +
  90 + public void setVague(boolean vague) {
  91 + this.vague = vague;
  92 + }
  93 +}
0 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/analyse/StationRoute.java renamed to src/main/java/com/bsth/data/gpsdata/arrival/entity/StationRoute.java
1   -package com.bsth.data.gpsdata.analyse;
  1 +package com.bsth.data.gpsdata.arrival.entity;
2 2  
3 3 import com.vividsolutions.jts.geom.Point;
4 4 import com.vividsolutions.jts.geom.Polygon;
... ... @@ -58,6 +58,8 @@ public class StationRoute {
58 58 */
59 59 private StationRoute prve;
60 60  
  61 + private String name;
  62 +
61 63 public String getCode() {
62 64 return code;
63 65 }
... ... @@ -137,5 +139,13 @@ public class StationRoute {
137 139 public void setMark(String mark) {
138 140 this.mark = mark;
139 141 }
  142 +
  143 + public String getName() {
  144 + return name;
  145 + }
  146 +
  147 + public void setName(String name) {
  148 + this.name = name;
  149 + }
140 150 }
141 151  
... ...
src/main/java/com/bsth/data/gpsdata/arrival/handlers/CorrectSignalHandle.java 0 → 100644
  1 +package com.bsth.data.gpsdata.arrival.handlers;
  2 +
  3 +import com.bsth.data.gpsdata.GpsEntity;
  4 +import com.bsth.data.gpsdata.arrival.SignalHandle;
  5 +import com.bsth.data.gpsdata.arrival.utils.CircleQueue;
  6 +import com.bsth.data.schedule.DayOfSchedule;
  7 +import com.bsth.entity.realcontrol.ChildTaskPlan;
  8 +import com.bsth.entity.realcontrol.ScheduleRealInfo;
  9 +import org.springframework.beans.factory.annotation.Autowired;
  10 +import org.springframework.stereotype.Component;
  11 +
  12 +/**
  13 + * 信号状态纠正
  14 + * Created by panzhao on 2016/12/27.
  15 + */
  16 +@Component
  17 +public class CorrectSignalHandle extends SignalHandle {
  18 +
  19 + @Autowired
  20 + DayOfSchedule dayOfSchedule;
  21 +
  22 + @Override
  23 + public boolean handle(GpsEntity gps, CircleQueue<GpsEntity> prevs) {
  24 + Object task = dayOfSchedule.executeCurr(gps.getNbbm());
  25 + if(task == null)
  26 + return false;
  27 + ScheduleRealInfo sch;
  28 +
  29 + //子任务
  30 + if(task.getClass().isAssignableFrom(ChildTaskPlan.class)){
  31 + ChildTaskPlan childTask = (ChildTaskPlan) task;
  32 + sch = childTask.getSchedule();
  33 + }
  34 + else
  35 + sch = (ScheduleRealInfo) task;
  36 +
  37 + int updown = Integer.parseInt(sch.getXlDir());
  38 + //走向
  39 + if(gps.getUpDown() != updown){
  40 + gps.setUpDown(updown);
  41 + gps.setState(0);
  42 + }
  43 +
  44 +
  45 + return true;
  46 + }
  47 +}
... ...
src/main/java/com/bsth/data/gpsdata/arrival/handlers/InOutStationSignalHandle.java 0 → 100644
  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 +}
... ...
src/main/java/com/bsth/data/gpsdata/arrival/handlers/OfflineSignalHandle.java 0 → 100644
  1 +package com.bsth.data.gpsdata.arrival.handlers;
  2 +
  3 +import com.bsth.data.gpsdata.GpsEntity;
  4 +import com.bsth.data.gpsdata.arrival.GeoCacheData;
  5 +import com.bsth.data.gpsdata.arrival.SignalHandle;
  6 +import com.bsth.data.gpsdata.arrival.utils.CircleQueue;
  7 +import org.springframework.stereotype.Component;
  8 +
  9 +/**
  10 + * 信号断线重连处理
  11 + * Created by panzhao on 2016/12/27.
  12 + */
  13 +@Component
  14 +public class OfflineSignalHandle extends SignalHandle{
  15 +
  16 + //断开2分钟,标记为重连信号
  17 + private final static int OFFLINE_TIME = 1000 * 60 * 2;
  18 +
  19 + //断开70分钟,之前的信号不再有参考价值
  20 + private final static int CLEAR_TIME = 1000 * 60 * 70;
  21 +
  22 + @Override
  23 + public boolean handle(GpsEntity gps, CircleQueue<GpsEntity> prevs) {
  24 + //漂移信号不管
  25 + if(isDriftSignal(gps)){
  26 + gps.setSignalState("drift");
  27 + return true;
  28 + }
  29 +
  30 + if(isNotEmpty(prevs)){
  31 + GpsEntity prev = prevs.getTail();
  32 + int space = (int) (gps.getTimestamp() - prev.getTimestamp());
  33 + if(space > OFFLINE_TIME)
  34 + gps.setSignalState("reconnection");
  35 +
  36 + if(space > CLEAR_TIME){
  37 + //清理缓存的信号
  38 + GeoCacheData.clear(gps.getNbbm());
  39 + }
  40 + }
  41 + return true;
  42 + }
  43 +}
0 44 \ No newline at end of file
... ...
src/main/java/com/bsth/data/gpsdata/arrival/handlers/ReverseSignalHandle.java 0 → 100644
  1 +package com.bsth.data.gpsdata.arrival.handlers;
  2 +
  3 +import com.bsth.data.gpsdata.GpsEntity;
  4 +import com.bsth.data.gpsdata.arrival.GeoCacheData;
  5 +import com.bsth.data.gpsdata.arrival.SignalHandle;
  6 +import com.bsth.data.gpsdata.arrival.entity.RouteReverse;
  7 +import com.bsth.data.gpsdata.arrival.entity.StationRoute;
  8 +import com.bsth.data.gpsdata.arrival.utils.CircleQueue;
  9 +import com.bsth.data.gpsdata.arrival.utils.ScheduleSignalState;
  10 +import com.bsth.data.schedule.DayOfSchedule;
  11 +import org.slf4j.Logger;
  12 +import org.slf4j.LoggerFactory;
  13 +import org.springframework.beans.factory.annotation.Autowired;
  14 +import org.springframework.stereotype.Component;
  15 +
  16 +/**
  17 + * 路由反向信号处理
  18 + * Created by panzhao on 2016/12/28.
  19 + */
  20 +@Component
  21 +public class ReverseSignalHandle extends SignalHandle {
  22 +
  23 + Logger logger = LoggerFactory.getLogger(this.getClass());
  24 +
  25 + @Autowired
  26 + DayOfSchedule dayOfSchedule;
  27 +
  28 + @Autowired
  29 + ScheduleSignalState scheduleSignalState;
  30 +
  31 + @Override
  32 + public boolean handle(GpsEntity gps, CircleQueue<GpsEntity> prevs) {
  33 + if (!isNotEmpty(prevs))
  34 + return false;
  35 +
  36 + GpsEntity prev = prevs.getTail();
  37 +
  38 + if (isReverse(gps, prev)) {
  39 + RouteReverse reverse = reverseSearch(prevs, gps);
  40 +
  41 + if (reverse.getCount() >= 4
  42 + && reverse.isClose()
  43 + && !GeoCacheData.isEndStation(gps.getLineId(), gps.getUpDown(), reverse.getTurned())) {
  44 + scheduleSignalState.reverseAnalyse(reverse);
  45 + }
  46 + }
  47 + return false;
  48 + }
  49 +
  50 + /**
  51 + * 搜索路由反向详细
  52 + *
  53 + * @param prevs
  54 + * @param gps
  55 + * @return
  56 + */
  57 + public RouteReverse reverseSearch(CircleQueue<GpsEntity> prevs, GpsEntity gps) {
  58 + RouteReverse routeReverse = new RouteReverse();
  59 + int count = 0;
  60 + String path = "";
  61 + long zt = 0L;
  62 + boolean half = false;
  63 +
  64 + //当前站点
  65 + StationRoute curr = GeoCacheData.getRouteCode(gps), sr;
  66 + GpsEntity prev;
  67 + Object[] array = prevs.getQueue();
  68 + for (int i = array.length - 1; i > 0; i--) {
  69 + prev = (GpsEntity) array[i];
  70 +
  71 + if (!prev.getUpDown().equals(gps.getUpDown())
  72 + || prev.getSignalState().equals("reconnection"))
  73 + break;
  74 +
  75 + if (prev.getInstation() == 1) {
  76 + sr = GeoCacheData.getRouteCode(prev);
  77 +
  78 + if (sr.getRouteSort() > curr.getRouteSort()) {
  79 + if(half){
  80 + routeReverse.setVague(true);
  81 + }
  82 +
  83 + path += (curr.getCode() + ",");
  84 + count++;
  85 + zt = prev.getTimestamp();
  86 + } else if (sr.getRouteSort() < curr.getRouteSort()) {
  87 + if (routeReverse.getTurned() == null) {
  88 + routeReverse.setTurned(curr.getCode());
  89 + half = true;
  90 + }
  91 +
  92 + path += (curr.getCode() + ",");
  93 + //掉头前当前站
  94 + if (sr.getCode().equals(gps.getStopNo())) {
  95 + routeReverse.setClose(true);
  96 + path += sr.getCode();
  97 + break;
  98 + }
  99 + }
  100 +
  101 + curr = sr;
  102 + }
  103 + }
  104 +
  105 + routeReverse.setZt(zt);
  106 + routeReverse.setCount(count);
  107 + routeReverse.setDetail(path);
  108 + routeReverse.setCt(gps.getTimestamp());
  109 + routeReverse.setNbbm(gps.getNbbm());
  110 + return routeReverse;
  111 + }
  112 +
  113 + /**
  114 + * 是否反向
  115 + *
  116 + * @param gps
  117 + * @param prev
  118 + * @return
  119 + */
  120 + public boolean isReverse(GpsEntity gps, GpsEntity prev) {
  121 + if (gps.getInstation() == 1
  122 + &&
  123 + gps.getUpDown().equals(prev.getUpDown())
  124 + && !gps.getStopNo().equals(prev.getStopNo())) {
  125 +
  126 + StationRoute currStation = GeoCacheData.getRouteCode(gps);
  127 + StationRoute prevStation = GeoCacheData.getRouteCode(prev);
  128 +
  129 + if (currStation == null || prevStation == null)
  130 + return false;
  131 +
  132 + if (currStation.getRouteSort() < prevStation.getRouteSort())
  133 + return true;
  134 + }
  135 + return false;
  136 + }
  137 +}
0 138 \ No newline at end of file
... ...
src/main/java/com/bsth/data/gpsdata/arrival/handlers/StationInsideHandle.java 0 → 100644
  1 +package com.bsth.data.gpsdata.arrival.handlers;
  2 +
  3 +import com.bsth.data.gpsdata.GpsEntity;
  4 +import com.bsth.data.gpsdata.arrival.GeoCacheData;
  5 +import com.bsth.data.gpsdata.arrival.SignalHandle;
  6 +import com.bsth.data.gpsdata.arrival.entity.StationRoute;
  7 +import com.bsth.data.gpsdata.arrival.utils.CircleQueue;
  8 +import com.bsth.data.gpsdata.arrival.utils.GeoUtils;
  9 +import org.springframework.stereotype.Component;
  10 +
  11 +import java.util.List;
  12 +
  13 +/**
  14 + * 站内站外判定
  15 + * Created by panzhao on 2016/12/27.
  16 + */
  17 +@Component
  18 +public class StationInsideHandle extends SignalHandle {
  19 +
  20 +
  21 + @Override
  22 + public boolean handle(GpsEntity gps, CircleQueue<GpsEntity> prevs) {
  23 + //是否在场内
  24 + String parkCode = GeoUtils.gpsInCarpark(gps);
  25 + if (parkCode != null) {
  26 + gps.setInstation(2);
  27 + gps.setStopNo(parkCode);
  28 + }
  29 +
  30 + //是否在站内
  31 + List<StationRoute> srs = GeoCacheData.getStationRoute(gps.getLineId(), gps.getUpDown());
  32 + StationRoute station = GeoUtils.gpsInStation(gps, srs);
  33 + if (station != null) {
  34 + gps.setInstation(1);
  35 + gps.setStopNo(station.getCode());
  36 + gps.setStation(station);
  37 + }
  38 +
  39 + //在场,站外
  40 + if(gps.getInstation() == 0 && isNotEmpty(prevs)){
  41 + //继承上一个点的站点编码
  42 + GpsEntity prev = prevs.getTail();
  43 + gps.setStopNo(prev.getStopNo());
  44 + }
  45 +
  46 + return true;
  47 + }
  48 +}
... ...
src/main/java/com/bsth/data/gpsdata/analyse/CircleQueue.java renamed to src/main/java/com/bsth/data/gpsdata/arrival/utils/CircleQueue.java
1   -package com.bsth.data.gpsdata.analyse;
  1 +package com.bsth.data.gpsdata.arrival.utils;
2 2  
3 3 import java.util.Arrays;
4 4  
... ... @@ -19,12 +19,12 @@ public class CircleQueue&lt;T&gt; {
19 19 public Object[] elementData;
20 20  
21 21 /**
22   - * 队头(先进先出)
  22 + *
23 23 */
24 24 public int head = 0;
25 25  
26 26 /**
27   - *
  27 + *
28 28 */
29 29 public int tail = 0;
30 30  
... ... @@ -39,7 +39,7 @@ public class CircleQueue&lt;T&gt; {
39 39 }
40 40  
41 41 /**
42   - * 获取循环队列的大小(包含元素的个数)
  42 + * 获取循环队列的大小
43 43 */
44 44 public int size() {
45 45 if (isEmpty()) {
... ... @@ -87,10 +87,12 @@ public class CircleQueue&lt;T&gt; {
87 87 * @return 取 循环队列里的值(先进的index=0)
88 88 */
89 89 public Object[] getQueue() {
90   - final Object[] elementDataSort = new Object[capacity];
  90 + final Object[] elementDataSort;
91 91 final Object[] elementDataCopy = elementData.clone();
92 92 if (isEmpty()) {
  93 + elementDataSort = new Object[0];
93 94 } else if (isFull()) {
  95 + elementDataSort = new Object[capacity];
94 96 int indexMax = capacity;
95 97 int indexSort = 0;
96 98 for (int i = head; i < indexMax;) {
... ... @@ -103,13 +105,18 @@ public class CircleQueue&lt;T&gt; {
103 105 }
104 106 }
105 107 } else {
106   - for (int i = 0; i < tail; i++) {
  108 + elementDataSort = new Object[tail + 1];
  109 + for (int i = 0; i <= tail; i++) {
107 110 elementDataSort[i] = elementDataCopy[i];
108 111 }
109 112 }
110 113 return elementDataSort;
111 114 }
112 115  
  116 + /**
  117 + * 取最后一个值
  118 + * @return
  119 + */
113 120 public T getTail(){
114 121 return elementData[tail] == null?null:(T)elementData[tail];
115 122 }
... ...
src/main/java/com/bsth/data/gpsdata/analyse/util/GeoUtils.java renamed to src/main/java/com/bsth/data/gpsdata/arrival/utils/GeoUtils.java
1   -package com.bsth.data.gpsdata.analyse.util;
  1 +package com.bsth.data.gpsdata.arrival.utils;
2 2  
3 3 import com.bsth.data.gpsdata.GpsEntity;
4   -import com.bsth.data.gpsdata.analyse.GeoCacheData;
5   -import com.bsth.data.gpsdata.analyse.StationRoute;
  4 +import com.bsth.data.gpsdata.arrival.GeoCacheData;
  5 +import com.bsth.data.gpsdata.arrival.entity.StationRoute;
6 6 import com.vividsolutions.jts.geom.Coordinate;
7 7 import com.vividsolutions.jts.geom.GeometryFactory;
8 8 import com.vividsolutions.jts.geom.Point;
... ...
src/main/java/com/bsth/data/gpsdata/arrival/utils/ScheduleSignalState.java 0 → 100644
  1 +package com.bsth.data.gpsdata.arrival.utils;
  2 +
  3 +import com.bsth.data.LineConfigData;
  4 +import com.bsth.data.gpsdata.GpsEntity;
  5 +import com.bsth.data.gpsdata.SignalStateData;
  6 +import com.bsth.data.gpsdata.arrival.GeoCacheData;
  7 +import com.bsth.data.gpsdata.arrival.entity.RouteReverse;
  8 +import com.bsth.data.gpsdata.arrival.entity.SignalAbnormal;
  9 +import com.bsth.data.gpsdata.arrival.entity.SignalState;
  10 +import com.bsth.data.schedule.DayOfSchedule;
  11 +import com.bsth.entity.realcontrol.LineConfig;
  12 +import com.bsth.entity.realcontrol.ScheduleRealInfo;
  13 +import org.slf4j.Logger;
  14 +import org.slf4j.LoggerFactory;
  15 +import org.springframework.beans.factory.annotation.Autowired;
  16 +import org.springframework.stereotype.Component;
  17 +
  18 +/**
  19 + * 班次信号状态分析
  20 + * Created by panzhao on 2016/12/29.
  21 + */
  22 +@Component
  23 +public class ScheduleSignalState {
  24 +
  25 + @Autowired
  26 + DayOfSchedule dayOfSchedule;
  27 +
  28 + Logger logger = LoggerFactory.getLogger(this.getClass());
  29 +
  30 + @Autowired
  31 + LineConfigData lineConfigData;
  32 +
  33 + @Autowired
  34 + SignalStateData signalStateData;
  35 +
  36 + /**
  37 + * 路由反向分析
  38 + */
  39 + public void reverseAnalyse(RouteReverse reverse) {
  40 + ScheduleRealInfo sch = dayOfSchedule.executeCurr(reverse.getNbbm());
  41 +
  42 + String bcType = sch.getBcType();
  43 +
  44 + switch (bcType) {
  45 + case "out":
  46 + outReverseAnalyse(sch, reverse);
  47 + break;
  48 + case "normal":
  49 + normalReverseAnalyse(sch, reverse);
  50 + break;
  51 + }
  52 + }
  53 +
  54 + /**
  55 + * 出场班次路由反向分析
  56 + *
  57 + * @param sch
  58 + */
  59 + private void outReverseAnalyse(ScheduleRealInfo sch, RouteReverse reverse) {
  60 + long t = reverse.getCt();
  61 + //出场班次终点时间前,允许反向轨迹
  62 + if (sch.getZdsjT() != null && sch.getZdsjT() > t) {
  63 + return;
  64 + }
  65 +
  66 + int rt;
  67 + //从实发 到 当前时间 < 计划运送时间 * 0.9
  68 + if (sch.getFcsjActual() != null && sch.getBcsj() != null) {
  69 + rt = (int) (t - sch.getFcsjActualTime());
  70 + if (rt < sch.getBcsj() * 0.9)
  71 + return;
  72 + }
  73 +
  74 + ScheduleRealInfo next = dayOfSchedule.next(sch);
  75 + if (next.getXlDir().equals(sch.getXlDir()))
  76 + return;
  77 +
  78 + //时间足够下一个班次待发时间运行到当前站
  79 + int runTime = reverse.getCount() * 1500 * 60;
  80 + if (next.getDfsjT() + runTime < t) {
  81 + //跳到下一个班次
  82 + dayOfSchedule.addExecPlan(next);
  83 + }
  84 + }
  85 +
  86 + /**
  87 + * 正常班次路由反向分析
  88 + *
  89 + * @param sch
  90 + * @param reverse
  91 + */
  92 + private void normalReverseAnalyse(ScheduleRealInfo sch, RouteReverse reverse) {
  93 + LineConfig conf = lineConfigData.get(sch.getXlBm());
  94 +
  95 + if (conf.isReadReverse()) {
  96 + //跳下一个班次
  97 + ScheduleRealInfo next = dayOfSchedule.next(sch);
  98 + if (next != null)
  99 + dayOfSchedule.addExecPlan(next);
  100 +
  101 + //记录信号状态
  102 + SignalState signalState = SignalState.reverseSignalSTate(sch, reverse);
  103 + signalStateData.put(signalState);
  104 + }
  105 + }
  106 +
  107 + public void signalRetrospect(GpsEntity gps) {
  108 + signalRetrospect(gps, dayOfSchedule.executeCurr(gps.getNbbm()));
  109 + }
  110 +
  111 + /**
  112 + * 信号追溯
  113 + *
  114 + * @param gps
  115 + * @param sch
  116 + */
  117 + public void signalRetrospect(GpsEntity gps, ScheduleRealInfo sch) {
  118 + //回放数据,是否有掉线或者漂移
  119 + CircleQueue<GpsEntity> queue = GeoCacheData.getGps(gps.getNbbm());
  120 + if (queue == null || queue.size() == 0 /*|| gps.getInstation() == 0*/)
  121 + return;
  122 +
  123 + //起始时间点
  124 + long st = 0;
  125 + ScheduleRealInfo prev = dayOfSchedule.prev(sch);
  126 +
  127 + if (prev != null) {
  128 + if (prev.getZdsjActual() != null)
  129 + st = prev.getZdsjActualTime();
  130 + else
  131 + st = (GeoCacheData.midwayStation(gps.getLineId(), gps.getUpDown(), sch.getQdzCode(), gps.getStopNo()).size() + 1) * (1000 * 60 * 5);
  132 + }
  133 +
  134 + Object[] tempArray = queue.getQueue();
  135 + int len = tempArray.length;
  136 +
  137 + Object[] array = new Object[len + 1];
  138 + System.arraycopy(tempArray, 0, array, 0, len);
  139 + array[len] = gps;
  140 +
  141 + String gpsState = "";
  142 + GpsEntity tempGps, nearGps = null;
  143 + int i = len - 1;
  144 + for (; i >= 0; i--) {
  145 + tempGps = (GpsEntity) array[i];
  146 +
  147 + gpsState = tempGps.getSignalState();
  148 + if (gpsState.equals("truncation"))
  149 + break;
  150 + else if (gpsState.equals("drift")) {
  151 + nearGps = (GpsEntity) array[i + 1];
  152 + break;
  153 + } else if (gpsState.equals("reconnection")) {
  154 + nearGps = tempGps;
  155 + break;
  156 + }
  157 +
  158 + if (tempGps.getTimestamp() < st)
  159 + break;
  160 + }
  161 +
  162 + if (nearGps != null && i > 0) {
  163 + createSignalAbnormal(gpsState, nearGps, i, array, sch);
  164 + }
  165 + }
  166 +
  167 + private void createSignalAbnormal(String gpsState, GpsEntity nearGps, int i, Object[] array, ScheduleRealInfo sch) {
  168 + switch (gpsState) {
  169 + case "drift":
  170 + driftSignalAbnormal(nearGps, i, array, sch);
  171 + break;
  172 + case "reconnection":
  173 + offlineSignalAbnormal(nearGps, ((GpsEntity) array[i - 1]), sch);
  174 + break;
  175 + }
  176 + }
  177 +
  178 + /**
  179 + * 掉线异常状态记录
  180 + *
  181 + * @param e
  182 + * @param s
  183 + */
  184 + private void offlineSignalAbnormal(GpsEntity e, GpsEntity s, ScheduleRealInfo sch) {
  185 + long st = s.getTimestamp(), et = e.getTimestamp();
  186 +
  187 + //掉线超过10分钟才记录
  188 + if (et - st < (1000 * 60 * 10))
  189 + return;
  190 +
  191 + SignalAbnormal signalAbnormal = new SignalAbnormal();
  192 + signalAbnormal.setSt(st);
  193 + signalAbnormal.setEt(et);
  194 + signalAbnormal.setAbnormalType("reconnection");
  195 + signalAbnormal.setDestCode(sch.getQdzCode());
  196 + signalAbnormal.setOutOrIn(0);
  197 +
  198 + //截断GPS
  199 + e.setSignalState("truncation");
  200 +
  201 + //记录信号状态
  202 + SignalState signalState = SignalState.abnormalSignalSTate(sch, signalAbnormal);
  203 + signalStateData.put(signalState);
  204 + }
  205 +
  206 + /**
  207 + * 漂移异常状态记录
  208 + *
  209 + * @param nearGps
  210 + * @param i
  211 + * @param array
  212 + */
  213 + private void driftSignalAbnormal(GpsEntity nearGps, int i, Object[] array, ScheduleRealInfo sch) {
  214 + GpsEntity gps, s = null;
  215 + //找到漂移开始时间
  216 + for (; i >= 0; i--) {
  217 + gps = (GpsEntity) array[i];
  218 +
  219 + if (!gps.getSignalState().equals("drift") || i == 0
  220 + || gps.getSignalState().equals("truncation")) {
  221 + s = gps;
  222 + break;
  223 + }
  224 + }
  225 +
  226 + long st = s.getTimestamp(), et = nearGps.getTimestamp();
  227 + if (et - st < (1000 * 60 * 3))
  228 + return;
  229 + /*if (s != null){
  230 + st = s.getTimestamp();
  231 + //漂移小于3分钟
  232 + if(et - st < (1000 * 60 * 3))
  233 + return;
  234 + }*/
  235 +
  236 +
  237 + SignalAbnormal signalAbnormal = new SignalAbnormal();
  238 + signalAbnormal.setSt(st);
  239 + signalAbnormal.setEt(et);
  240 + signalAbnormal.setAbnormalType("drift");
  241 + signalAbnormal.setDestCode(sch.getQdzCode());
  242 + signalAbnormal.setOutOrIn(0);
  243 +
  244 + //截断GPS
  245 + nearGps.setSignalState("truncation");
  246 +
  247 + //记录信号状态
  248 + SignalState signalState = SignalState.abnormalSignalSTate(sch, signalAbnormal);
  249 + signalStateData.put(signalState);
  250 + }
  251 +}
... ...
src/main/java/com/bsth/data/gpsdata/arrival/utils/SignalSchPlanMatcher.java 0 → 100644
  1 +package com.bsth.data.gpsdata.arrival.utils;
  2 +
  3 +import com.bsth.data.gpsdata.GpsEntity;
  4 +import com.bsth.data.schedule.DayOfSchedule;
  5 +import com.bsth.entity.realcontrol.ScheduleRealInfo;
  6 +import org.springframework.beans.factory.annotation.Autowired;
  7 +import org.springframework.stereotype.Component;
  8 +
  9 +/**
  10 + * 班次匹配器
  11 + * Created by panzhao on 2016/12/31.
  12 + */
  13 +@Component
  14 +public class SignalSchPlanMatcher {
  15 +
  16 + @Autowired
  17 + DayOfSchedule dayOfSchedule;
  18 +
  19 + /**
  20 + * 发车信号匹配
  21 + * @param outSigal
  22 + * @param sch
  23 + * @return
  24 + */
  25 + public void outMatch(GpsEntity outSigal, ScheduleRealInfo sch){
  26 + long t = outSigal.getTimestamp();
  27 + if(t < sch.getDfsjT())
  28 + return;
  29 +
  30 + //下一个相同走向的班次
  31 + ScheduleRealInfo next = dayOfSchedule.nextSame(sch);
  32 + if(next == null || !next.getQdzCode().equals(sch.getQdzCode()))
  33 + return;
  34 +
  35 + //晚于班次间隔百分之70,跳下一个班次
  36 + double s = (int) (next.getDfsjT() - sch.getDfsjT());
  37 + double r = (int) (t - sch.getDfsjT());
  38 + if(r / s > 0.7){
  39 + dayOfSchedule.addExecPlan(next);
  40 + outMatch(outSigal, next);
  41 + }
  42 + }
  43 +}
... ...
src/main/java/com/bsth/data/gpsdata/analyse/StationRouteComp.java renamed to src/main/java/com/bsth/data/gpsdata/arrival/utils/StationRouteComp.java
1   -package com.bsth.data.gpsdata.analyse;
  1 +package com.bsth.data.gpsdata.arrival.utils;
  2 +
  3 +import com.bsth.data.gpsdata.arrival.entity.StationRoute;
2 4  
3 5 import java.util.Comparator;
4 6  
... ...
src/main/java/com/bsth/data/gpsdata/recovery/GpsDataRecovery.java
... ... @@ -2,13 +2,19 @@ package com.bsth.data.gpsdata.recovery;
2 2  
3 3 import com.bsth.data.BasicData;
4 4 import com.bsth.data.gpsdata.GpsEntity;
5   -import com.bsth.data.gpsdata.analyse.components.GpsArrival;
  5 +import com.bsth.data.gpsdata.arrival.GeoCacheData;
  6 +import com.bsth.data.gpsdata.arrival.handlers.*;
  7 +import com.bsth.data.gpsdata.arrival.utils.CircleQueue;
6 8 import com.bsth.util.db.DBUtils_MS;
7 9 import com.google.common.collect.ArrayListMultimap;
8 10 import org.slf4j.Logger;
9 11 import org.slf4j.LoggerFactory;
  12 +import org.springframework.beans.BeansException;
  13 +import org.springframework.context.ApplicationContext;
  14 +import org.springframework.context.ApplicationContextAware;
10 15 import org.springframework.jdbc.core.JdbcTemplate;
11 16 import org.springframework.jdbc.core.RowMapper;
  17 +import org.springframework.stereotype.Component;
12 18  
13 19 import java.sql.ResultSet;
14 20 import java.sql.SQLException;
... ... @@ -18,42 +24,50 @@ import java.util.concurrent.ExecutorService;
18 24 import java.util.concurrent.Executors;
19 25  
20 26 /**
21   - * 数据恢复
  27 + * gps数据恢复
22 28 * Created by panzhao on 2016/12/24.
23 29 */
24   -public class GpsDataRecovery {
  30 +@Component
  31 +public class GpsDataRecovery implements ApplicationContextAware {
25 32  
26 33 static Logger logger = LoggerFactory.getLogger(GpsDataRecovery.class);
27 34  
28 35 public static boolean run;
29 36  
30   - static ExecutorService threadPool = Executors.newFixedThreadPool(50);
  37 + static ExecutorService threadPool = Executors.newFixedThreadPool(10);
31 38  
32   - private static CountDownLatch count;
  39 + static OfflineSignalHandle offlineSignalHandle;
  40 + static CorrectSignalHandle correctSignalHandle;
  41 + static StationInsideHandle stationInsideHandle;
  42 + static InOutStationSignalHandle inOutStationSignalHandle;
  43 + static ReverseSignalHandle reverseSignalHandle;
33 44  
34   - public static void recovery() {
  45 + public void recovery() {
35 46 List<GpsEntity> list = loadData();
36 47  
37 48 //按车辆分组数据
38 49 ArrayListMultimap<String, GpsEntity> listMap = ArrayListMultimap.create();
39 50 for (GpsEntity gps : list) {
40   - if(gps.getNbbm() != null)
  51 + if (gps.getNbbm() != null)
41 52 listMap.put(gps.getNbbm(), gps);
42 53 }
43 54  
44   - count = new CountDownLatch(listMap.keySet().size());
45 55  
46 56 Set<String> keys = listMap.keySet();
  57 +
  58 + CountDownLatch count = new CountDownLatch(keys.size());
  59 + GpsComp comp = new GpsComp();
47 60 for (String nbbm : keys) {
48   - threadPool.execute(new RecoveryDataThread(listMap.get(nbbm), count));
49   - /*if(nbbm.equals("W9H-003"))
50   - new RecoveryDataThread(listMap.get(nbbm), count).run();*/
  61 + Collections.sort(listMap.get(nbbm), comp);
  62 + threadPool.execute(new RecoveryThread(listMap.get(nbbm), count));
  63 + /*if(nbbm.equals("YT-CD008"))
  64 + new RecoveryThread(listMap.get(nbbm), count).run();*/
51 65 }
  66 +
52 67 try {
53   - //等待子线程结束
54 68 count.await();
55   - logger.info("GPS 数据恢复完成....");
56 69 run = false;
  70 + logger.info("数据恢复完成....");
57 71 } catch (InterruptedException e) {
58 72 logger.error("", e);
59 73 }
... ... @@ -64,7 +78,7 @@ public class GpsDataRecovery {
64 78 *
65 79 * @return
66 80 */
67   - public static List<GpsEntity> loadData() {
  81 + public List<GpsEntity> loadData() {
68 82 Calendar calendar = Calendar.getInstance();
69 83 int dayOfYear = calendar.get(Calendar.DAY_OF_YEAR);
70 84  
... ... @@ -103,12 +117,28 @@ public class GpsDataRecovery {
103 117 return (((serviceState & 0x10000000) == 0x10000000) ? 1 : 0);
104 118 }
105 119  
106   - public static class RecoveryDataThread implements Runnable {
  120 + @Override
  121 + public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
  122 + offlineSignalHandle = applicationContext.getBean(OfflineSignalHandle.class);
  123 + correctSignalHandle = applicationContext.getBean(CorrectSignalHandle.class);
  124 + stationInsideHandle = applicationContext.getBean(StationInsideHandle.class);
  125 + inOutStationSignalHandle = applicationContext.getBean(InOutStationSignalHandle.class);
  126 + reverseSignalHandle = applicationContext.getBean(ReverseSignalHandle.class);
  127 + }
  128 +
  129 + public static class GpsComp implements Comparator<GpsEntity> {
  130 +
  131 + @Override
  132 + public int compare(GpsEntity g1, GpsEntity g2) {
  133 + return g1.getTimestamp().compareTo(g2.getTimestamp());
  134 + }
  135 + }
107 136  
  137 + public static class RecoveryThread implements Runnable {
108 138 List<GpsEntity> list;
109 139 CountDownLatch count;
110 140  
111   - public RecoveryDataThread(List<GpsEntity> list, CountDownLatch count) {
  141 + RecoveryThread(List<GpsEntity> list, CountDownLatch count) {
112 142 this.list = list;
113 143 this.count = count;
114 144 }
... ... @@ -116,19 +146,26 @@ public class GpsDataRecovery {
116 146 @Override
117 147 public void run() {
118 148 try {
119   - //排序
120   - Collections.sort(list, new GpsComp());
121   - //依次跑完gps
122   - //int i = 0;
123   - for(GpsEntity gps : list){
124   - /* i++;
125   - if(i == 4527){
126   - System.out.println("aaa");
127   - }
128   -
129   - if(gps.getTimestamp() == 1482726071000L)
130   - System.out.println("bbb");*/
131   - GpsArrival.arrival(gps);
  149 + //循环gps恢复数据
  150 + CircleQueue<GpsEntity> prevs;
  151 +
  152 + for (GpsEntity gps : list) {
  153 +
  154 + prevs = GeoCacheData.getGps(gps.getNbbm());
  155 + //掉线处理
  156 + offlineSignalHandle.handle(gps, prevs);
  157 + //状态处理
  158 + if (!correctSignalHandle.handle(gps, prevs))
  159 + continue;
  160 + //场,站内外判断
  161 + stationInsideHandle.handle(gps, prevs);
  162 + //反向处理
  163 + reverseSignalHandle.handle(gps, prevs);
  164 + //进出站动作处理
  165 + inOutStationSignalHandle.handle(gps, prevs);
  166 + GeoCacheData.putGps(gps);
  167 +
  168 + //Thread.sleep(50);
132 169 }
133 170 } catch (Exception e) {
134 171 logger.error("", e);
... ... @@ -137,12 +174,4 @@ public class GpsDataRecovery {
137 174 }
138 175 }
139 176 }
140   -
141   - public static class GpsComp implements Comparator<GpsEntity>{
142   -
143   - @Override
144   - public int compare(GpsEntity g1, GpsEntity g2) {
145   - return (int) (g1.getTimestamp() - g2.getTimestamp());
146   - }
147   - }
148 177 }
149 178 \ No newline at end of file
... ...
src/main/java/com/bsth/data/schedule/DayOfSchedule.java
... ... @@ -2,8 +2,6 @@ package com.bsth.data.schedule;
2 2  
3 3 import com.alibaba.fastjson.JSON;
4 4 import com.alibaba.fastjson.JSONArray;
5   -import com.bsth.Application;
6   -import com.bsth.data.BasicData;
7 5 import com.bsth.data.LineConfigData;
8 6 import com.bsth.data.directive.FirstScheduleCheckThread;
9 7 import com.bsth.data.gpsdata.GpsRealData;
... ... @@ -29,12 +27,12 @@ import org.slf4j.Logger;
29 27 import org.slf4j.LoggerFactory;
30 28 import org.springframework.beans.factory.annotation.Autowired;
31 29 import org.springframework.boot.CommandLineRunner;
  30 +import org.springframework.core.annotation.Order;
32 31 import org.springframework.stereotype.Component;
33 32  
34 33 import java.text.ParseException;
35 34 import java.text.SimpleDateFormat;
36 35 import java.util.*;
37   -import java.util.concurrent.TimeUnit;
38 36  
39 37 /**
40 38 * @author PanZhao
... ... @@ -43,6 +41,7 @@ import java.util.concurrent.TimeUnit;
43 41 * @date 2016年8月15日 上午10:16:12
44 42 */
45 43 @Component
  44 +@Order(value = 3)
46 45 public class DayOfSchedule implements CommandLineRunner {
47 46  
48 47 Logger logger = LoggerFactory.getLogger(this.getClass());
... ... @@ -117,25 +116,23 @@ public class DayOfSchedule implements CommandLineRunner {
117 116 LineConfigData lineConfigs;
118 117  
119 118 @Autowired
120   - BasicData.BasicDataLoader dataLoader;
  119 + GpsDataRecovery gpsDataRecovery;
121 120  
122 121 private static DateTimeFormatter fmtyyyyMMdd = DateTimeFormat.forPattern("yyyy-MM-dd"), fmtHHmm = DateTimeFormat.forPattern("HH:mm");
123 122  
124 123 @Override
125 124 public void run(String... arg0) throws Exception {
126   - //加载基础数据
127   - dataLoader.loadAllData();
128 125 //从数据库恢复排班
129 126 //dataRecovery();
130 127  
131 128 //翻班线程
132   - Application.mainServices.scheduleWithFixedDelay(scheduleRefreshThread, 15, 240, TimeUnit.SECONDS);
  129 +// Application.mainServices.scheduleWithFixedDelay(scheduleRefreshThread, 15, 240, TimeUnit.SECONDS);
133 130 //入库
134   - Application.mainServices.scheduleWithFixedDelay(schedulePstThread, 60, 60, TimeUnit.SECONDS);
  131 +// Application.mainServices.scheduleWithFixedDelay(schedulePstThread, 60, 60, TimeUnit.SECONDS);
135 132 //首班出场指令补发器
136 133 // Application.mainServices.scheduleWithFixedDelay(firstScheduleCheckThread, 30, 240, TimeUnit.SECONDS);
137 134 //班次误点扫描
138   - Application.mainServices.scheduleWithFixedDelay(scheduleLateThread, 60, 60, TimeUnit.SECONDS);
  135 +// Application.mainServices.scheduleWithFixedDelay(scheduleLateThread, 60, 60, TimeUnit.SECONDS);
139 136  
140 137 //每天凌晨2点20提交数据到运管处
141 138 long diff = (DateUtils.getTimestamp() + 1000 * 60 * 140) - System.currentTimeMillis();
... ... @@ -160,7 +157,7 @@ public class DayOfSchedule implements CommandLineRunner {
160 157 }
161 158  
162 159 //恢复gps数据
163   - GpsDataRecovery.recovery();
  160 + gpsDataRecovery.recovery();
164 161 }
165 162  
166 163 public Map<String, String> getCurrSchDate() {
... ... @@ -221,15 +218,8 @@ public class DayOfSchedule implements CommandLineRunner {
221 218 reCalcExecPlan(nbbm);
222 219 }
223 220  
224   - //是否是出站即出场
225   - LineConfig conf = lineConfigData.get(lineCode);
226   - if (conf.getOutConfig() == 2) {
227   - for (String nbbm : cars)
228   - schAttrCalculator.connectOutSchedule(nbbmScheduleMap.get(nbbm));
229   - }
230   -
231 221 // 页面 翻班通知
232   - sendUtils.shiftSchedule(lineCode);
  222 + //sendUtils.shiftSchedule(lineCode);
233 223 } catch (Exception e) {
234 224 logger.error("", e);
235 225 return -1;
... ... @@ -500,6 +490,41 @@ public class DayOfSchedule implements CommandLineRunner {
500 490 }
501 491  
502 492 /**
  493 + * 下一个相同走向的班次
  494 + * @param sch
  495 + * @return
  496 + */
  497 + public ScheduleRealInfo nextSame(ScheduleRealInfo sch){
  498 + List<ScheduleRealInfo> list = nbbmScheduleMap.get(sch.getClZbh());
  499 + int outConfig = -1;
  500 + LineConfig config = lineConfigData.get(sch.getXlBm());
  501 + if (config != null)
  502 + outConfig = config.getOutConfig();
  503 +
  504 + boolean flag = false;
  505 + ScheduleRealInfo next = null;
  506 + for (ScheduleRealInfo temp : list) {
  507 + if (temp.getId() == sch.getId()) {
  508 + flag = true;
  509 + continue;
  510 + }
  511 + //忽略烂班
  512 + if (temp.isDestroy())
  513 + continue;
  514 +
  515 + //出站既出场,忽略出场班次
  516 + if (outConfig == 2 && temp.getBcType().equals("out"))
  517 + continue;
  518 +
  519 + if (flag && temp.getXlDir().equals(sch.getXlDir())) {
  520 + next = temp;
  521 + break;
  522 + }
  523 + }
  524 + return next;
  525 + }
  526 +
  527 + /**
503 528 * 上一个班次
504 529 *
505 530 * @param sch
... ... @@ -524,6 +549,18 @@ public class DayOfSchedule implements CommandLineRunner {
524 549 return prev;
525 550 }
526 551  
  552 + /**
  553 + * 是否是首班出场
  554 + * @param sch
  555 + * @return
  556 + */
  557 + public boolean isFirstOut(ScheduleRealInfo sch){
  558 + List<ScheduleRealInfo> list = nbbmScheduleMap.get(sch.getClZbh());
  559 + if(list.get(0).equals(sch) && sch.getBcType().equals("out"))
  560 + return true;
  561 + return false;
  562 + }
  563 +
527 564 public void put(ScheduleRealInfo sch) {
528 565 schAttrCalculator
529 566 .calcRealDate(sch)
... ... @@ -706,7 +743,8 @@ public class DayOfSchedule implements CommandLineRunner {
706 743 }
707 744  
708 745 public void addExecPlan(ScheduleRealInfo sch) {
709   - carExecutePlanMap.put(sch.getClZbh(), sch);
  746 + if(sch != null)
  747 + carExecutePlanMap.put(sch.getClZbh(), sch);
710 748 }
711 749  
712 750 public void removeExecPlan(String clzbh) {
... ... @@ -723,7 +761,7 @@ public class DayOfSchedule implements CommandLineRunner {
723 761 * @param nbbm
724 762 * @return
725 763 */
726   - public static ScheduleRealInfo executeCurr(String nbbm) {
  764 + public ScheduleRealInfo executeCurr(String nbbm) {
727 765 return carExecutePlanMap.get(nbbm);
728 766 }
729 767  
... ... @@ -763,6 +801,41 @@ public class DayOfSchedule implements CommandLineRunner {
763 801 }
764 802  
765 803 /**
  804 + * 是否在执行首班出场
  805 + * @param nbbm
  806 + * @return
  807 + */
  808 + public boolean isExecFirstOut(String nbbm, long time){
  809 + try {
  810 + List<ScheduleRealInfo> list = nbbmScheduleMap.get(nbbm);
  811 + ScheduleRealInfo second = list.get(2),
  812 + first = executeCurr(nbbm);
  813 +
  814 + if(first.getBcType().equals("out")
  815 + && first.getDfsjT() < second.getDfsjT()
  816 + && doneSum(nbbm) == 0 && second.getDfsjT() > time)
  817 + return true;
  818 + } catch (Exception e) {
  819 + logger.error("", e);
  820 + }
  821 +
  822 + return false;
  823 + }
  824 +
  825 + /**
  826 + * 获取班次的计划停站时间
  827 + * @param sch
  828 + * @return
  829 +
  830 + public int stopTimePlan(Object task) {
  831 +
  832 + ScheduleRealInfo sch = prev((ScheduleRealInfo) task);
  833 +
  834 + sch.getzdsj
  835 + return -1;
  836 + }*/
  837 +
  838 + /**
766 839 *
767 840 * @Title: linkToSchPlan
768 841 * @Description: TODO(车辆关联到班次)
... ...
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/Cars.java
... ... @@ -23,7 +23,7 @@ import java.util.Date;
23 23  
24 24 @Entity
25 25 @Table(name = "bsth_c_cars")
26   -@JsonIgnoreProperties(value={"hibernateLazyInitializer","handler","fieldHandler"})
  26 +@JsonIgnoreProperties(value={"hibernateLazyInitializer","handlers","fieldHandler"})
27 27 public class Cars extends BEntity implements Serializable {
28 28  
29 29 /** 主键Id */
... ...
src/main/java/com/bsth/entity/Line.java
... ... @@ -24,7 +24,7 @@ import java.util.Date;
24 24  
25 25 @Entity
26 26 @Table(name = "bsth_c_line")
27   -@JsonIgnoreProperties(value={"hibernateLazyInitializer","handler","fieldHandler"})
  27 +@JsonIgnoreProperties(value={"hibernateLazyInitializer","handlers","fieldHandler"})
28 28 public class Line implements Serializable {
29 29  
30 30 @Id
... ...
src/main/java/com/bsth/entity/Personnel.java
... ... @@ -21,7 +21,7 @@ import javax.persistence.*;
21 21  
22 22 @Entity
23 23 @Table(name = "bsth_c_personnel")
24   -@JsonIgnoreProperties(value={"hibernateLazyInitializer","handler","fieldHandler"})
  24 +@JsonIgnoreProperties(value={"hibernateLazyInitializer","handlers","fieldHandler"})
25 25 public class Personnel extends BEntity {
26 26  
27 27 /** 主键Id */
... ...
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/entity/schedule/CarConfigInfo.java
... ... @@ -19,7 +19,7 @@ import java.util.Date;
19 19 @NamedAttributeNode("cl")
20 20 })
21 21 })
22   -@JsonIgnoreProperties(value={"hibernateLazyInitializer","handler","fieldHandler"})
  22 +@JsonIgnoreProperties(value={"hibernateLazyInitializer","handlers","fieldHandler"})
23 23 public class CarConfigInfo extends BEntity implements Serializable {
24 24  
25 25 /** 主健Id */
... ...
src/main/java/com/bsth/entity/schedule/EmployeeConfigInfo.java
... ... @@ -22,7 +22,7 @@ import java.io.Serializable;
22 22 @NamedAttributeNode("xl")
23 23 })
24 24 })
25   -@JsonIgnoreProperties(value={"hibernateLazyInitializer","handler","fieldHandler"})
  25 +@JsonIgnoreProperties(value={"hibernateLazyInitializer","handlers","fieldHandler"})
26 26 public class EmployeeConfigInfo extends BEntity implements Serializable {
27 27  
28 28 /** 主键Id */
... ...
src/main/java/com/bsth/entity/schedule/GuideboardInfo.java
... ... @@ -15,7 +15,7 @@ import javax.persistence.*;
15 15 @NamedAttributeNode("xl")
16 16 })
17 17 })
18   -@JsonIgnoreProperties(value={"hibernateLazyInitializer","handler","fieldHandler"})
  18 +@JsonIgnoreProperties(value={"hibernateLazyInitializer","handlers","fieldHandler"})
19 19 public class GuideboardInfo extends BEntity {
20 20  
21 21 /** 主键Id */
... ...
src/main/java/com/bsth/entity/sys/SysUser.java
... ... @@ -9,7 +9,7 @@ import java.util.Set;
9 9  
10 10 @Entity
11 11 @Table(name = "bsth_c_sys_user")
12   -@JsonIgnoreProperties(value={"hibernateLazyInitializer","handler","fieldHandler"})
  12 +@JsonIgnoreProperties(value={"hibernateLazyInitializer","handlers","fieldHandler"})
13 13 public class SysUser {
14 14  
15 15 @Id
... ...
src/main/java/com/bsth/repository/realcontrol/ScheduleRealInfoRepository.java
... ... @@ -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') FROM bsth_v_report_80 r LEFT JOIN bsth_c_cars c ON c.equipment_code = r.device_id where FROM_UNIXTIME(r.timestamp/1000,'%Y-%m-%d') = ?2 and r.line_id = ?1 and c.inside_code = ?3",nativeQuery=true)
  74 + @Query(value="SELECT c.company,r.request_code,FROM_UNIXTIME(r.timestamp/1000,'%Y-%m-%d %T'),c.inside_code FROM bsth_v_report_80 r LEFT JOIN bsth_c_cars c ON c.equipment_code = r.device_id where FROM_UNIXTIME(r.timestamp/1000,'%Y-%m-%d') = ?2 and r.line_id like %?1% and c.inside_code like %?3%",nativeQuery=true)
75 75 List<Object[]> account(String line,String date,String code);
76 76  
77 77 @Query(value="select s from ScheduleRealInfo s where s.xlBm = ?1 and s.scheduleDate >= str_to_date(?2,'%Y-%m-%d') "
... ... @@ -125,4 +125,4 @@ public interface ScheduleRealInfoRepository extends BaseRepository&lt;ScheduleRealI
125 125 @Query(value="select new map(xlBm as xlBm) from ScheduleRealInfo s where DATE_FORMAT(s.scheduleDate,'%Y-%m-%d') = ?1 GROUP BY xlBm ORDER BY xlBm")
126 126 List<Map<String,Object>> setDDRBGroup(String date);
127 127  
128   -}
  128 +}
129 129 \ No newline at end of file
... ...
src/main/java/com/bsth/service/excep/impl/OfflineServiceImpl.java
... ... @@ -46,23 +46,33 @@ public class OfflineServiceImpl implements OfflineService {
46 46 Object line=map.get("line");
47 47 Object nbbm=map.get("nbbm");
48 48 Object updown=map.get("updown");
49   -
  49 + Object date=map.get("date");
50 50  
51 51 if(line!=null){
52   - if(line.toString()!="")
53   - sql +=" and line="+line;
  52 + sql +=" and line like'%"+line.toString()+"%'";
54 53 }
55 54  
56 55 if(nbbm!=null){
57   - if(nbbm.toString()!="")
58   - sql +=" and vehicle like '%"+nbbm+"%'";
  56 + sql +=" and vehicle like '%"+nbbm.toString()+"%'";
59 57 }
60 58  
61 59 if(updown!=null){
62   - if(updown.toString() !="")
63   - sql +="and up_down ="+updown;
  60 + sql +="and up_down like '%"+updown.toString()+"%'";
  61 + }
  62 + if(date!=null){
  63 + if (date.toString().length()>0) {
  64 + SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:MM:SS");
  65 + try {
  66 + Long t1=sdf.parse(date.toString()+" 00:00:00").getTime();
  67 + Long t2=sdf.parse(date.toString()+" 23:59:59").getTime();
  68 + sql += " and timestamp >="+t1 +" and timestamp <="+t2;
  69 + } catch (ParseException e) {
  70 + // TODO Auto-generated catch block
  71 + e.printStackTrace();
  72 + }
  73 + }
  74 +
64 75 }
65   -
66 76 sql +=" order by id limit ?,?";
67 77  
68 78 try {
... ... @@ -118,19 +128,32 @@ public class OfflineServiceImpl implements OfflineService {
118 128 Object nbbm=map.get("nbbm");
119 129 Object updown=map.get("updown");
120 130  
  131 + Object date=map.get("date");
  132 +
121 133 if(line!=null){
122   - if(line.toString()!="")
123   - sql +=" and line="+line;
  134 + sql +=" and line like'%"+line.toString()+"%'";
124 135 }
125 136  
126 137 if(nbbm!=null){
127   - if(nbbm.toString()!="")
128   - sql +=" and vehicle like '%"+nbbm+"%'";
  138 + sql +=" and vehicle like '%"+nbbm.toString()+"%'";
129 139 }
130 140  
131 141 if(updown!=null){
132   - if(updown.toString() !="")
133   - sql +="and up_down ="+updown;
  142 + sql +="and up_down like '%"+updown.toString()+"%'";
  143 + }
  144 + if(date!=null){
  145 + if (date.toString().length()>0) {
  146 + SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:MM:SS");
  147 + try {
  148 + Long t1=sdf.parse(date.toString()+" 00:00:00").getTime();
  149 + Long t2=sdf.parse(date.toString()+" 23:59:59").getTime();
  150 + sql += " and timestamp >="+t1 +" and timestamp <="+t2;
  151 + } catch (ParseException e) {
  152 + // TODO Auto-generated catch block
  153 + e.printStackTrace();
  154 + }
  155 + }
  156 +
134 157 }
135 158  
136 159 Connection conn = null;
... ...
src/main/java/com/bsth/service/excep/impl/OutboundServiceImpl.java
... ... @@ -36,23 +36,33 @@ public class OutboundServiceImpl implements OutboundService{
36 36 Object line=map.get("line");
37 37 Object nbbm=map.get("nbbm");
38 38 Object updown=map.get("updown");
  39 + Object date=map.get("date");
39 40  
40   -
41 41 if(line!=null){
42   - if(line.toString()!="")
43   - sql +=" and line="+line;
  42 + sql +=" and line like'%"+line.toString()+"%'";
44 43 }
45 44  
46 45 if(nbbm!=null){
47   - if(nbbm.toString()!="")
48   - sql +=" and vehicle like '%"+nbbm+"%'";
  46 + sql +=" and vehicle like '%"+nbbm.toString()+"%'";
49 47 }
50 48  
51 49 if(updown!=null){
52   - if(updown.toString() !="")
53   - sql +="and up_down ="+updown;
  50 + sql +="and up_down like '%"+updown.toString()+"%'";
  51 + }
  52 + if(date!=null){
  53 + if (date.toString().length()>0) {
  54 + SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:MM:SS");
  55 + try {
  56 + Long t1=sdf.parse(date.toString()+" 00:00:00").getTime();
  57 + Long t2=sdf.parse(date.toString()+" 23:59:59").getTime();
  58 + sql += " and timestamp >="+t1 +" and timestamp <="+t2;
  59 + } catch (ParseException e) {
  60 + // TODO Auto-generated catch block
  61 + e.printStackTrace();
  62 + }
  63 + }
  64 +
54 65 }
55   -
56 66 sql +=" order by id limit ?,?";
57 67  
58 68  
... ... @@ -102,20 +112,32 @@ public class OutboundServiceImpl implements OutboundService{
102 112 Object line=map.get("line");
103 113 Object nbbm=map.get("nbbm");
104 114 Object updown=map.get("updown");
105   -
  115 + Object date=map.get("date");
106 116 if(line!=null){
107   - if(line.toString()!="")
108   - sql +=" and line="+line;
  117 + sql +=" and line like '%"+line.toString()+"%'";
  118 +
109 119 }
110 120  
111 121 if(nbbm!=null){
112   - if(nbbm.toString()!="")
113   - sql +=" and vehicle like '%"+nbbm+"%'";
  122 + sql +=" and vehicle like '%"+nbbm.toString()+"%'";
114 123 }
115 124  
116 125 if(updown!=null){
117   - if(updown.toString() !="")
118   - sql +="and up_down ="+updown;
  126 + sql +=" and up_down like '%"+updown.toString()+"%'";
  127 + }
  128 + if(date!=null){
  129 + if (date.toString().length()>0) {
  130 + SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  131 + try {
  132 + Long t1=sdf.parse(date.toString()+" 00:00:00").getTime();
  133 + Long t2=sdf.parse(date.toString()+" 23:59:59").getTime();
  134 + sql += " and timestamp >="+t1 +" and timestamp <="+t2;
  135 + } catch (ParseException e) {
  136 + // TODO Auto-generated catch block
  137 + e.printStackTrace();
  138 + }
  139 + }
  140 +
119 141 }
120 142 Connection conn = null;
121 143 PreparedStatement ps = null;
... ... @@ -214,7 +236,7 @@ public class OutboundServiceImpl implements OutboundService{
214 236 times=sdf.format(new Date());
215 237 }
216 238 SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
217   - String times1=times+" 00:00:01";
  239 + String times1=times+" 00:00:00";
218 240 String times2=times+" 23:59:59";
219 241  
220 242 Connection conn = null;
... ...
src/main/java/com/bsth/service/excep/impl/SpeedingServiceImpl.java
... ... @@ -38,22 +38,34 @@ public class SpeedingServiceImpl implements SpeedingService {
38 38 Object line=map.get("line");
39 39 Object nbbm=map.get("nbbm");
40 40 Object updown=map.get("updown");
41   -
  41 + Object date=map.get("date");
42 42  
43 43 if(line!=null){
44   - if(line.toString()!="")
45   - sql +=" and line="+line;
  44 + sql +=" and line like'%"+line.toString()+"%'";
46 45 }
47 46  
48 47 if(nbbm!=null){
49   - if(nbbm.toString()!="")
50   - sql +=" and vehicle like '%"+nbbm+"%'";
  48 + sql +=" and vehicle like '%"+nbbm.toString()+"%'";
51 49 }
52 50  
53 51 if(updown!=null){
54   - if(updown.toString() !="")
55   - sql +="and up_down ="+updown;
  52 + sql +="and up_down like '%"+updown.toString()+"%'";
  53 + }
  54 + if(date!=null){
  55 + if (date.toString().length()>0) {
  56 + SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:MM:SS");
  57 + try {
  58 + Long t1=sdf.parse(date.toString()+" 00:00:00").getTime();
  59 + Long t2=sdf.parse(date.toString()+" 23:59:59").getTime();
  60 + sql += " and timestamp >="+t1 +" and timestamp <="+t2;
  61 + } catch (ParseException e) {
  62 + // TODO Auto-generated catch block
  63 + e.printStackTrace();
  64 + }
  65 + }
  66 +
56 67 }
  68 +
57 69  
58 70 sql +=" order by id limit ?,?";
59 71  
... ... @@ -103,19 +115,32 @@ public class SpeedingServiceImpl implements SpeedingService {
103 115 Object nbbm=map.get("nbbm");
104 116 Object updown=map.get("updown");
105 117  
  118 + Object date=map.get("date");
  119 +
106 120 if(line!=null){
107   - if(line.toString()!="")
108   - sql +=" and line="+line;
  121 + sql +=" and line like'%"+line.toString()+"%'";
109 122 }
110 123  
111 124 if(nbbm!=null){
112   - if(nbbm.toString()!="")
113   - sql +=" and vehicle like '%"+nbbm+"%'";
  125 + sql +=" and vehicle like '%"+nbbm.toString()+"%'";
114 126 }
115 127  
116 128 if(updown!=null){
117   - if(updown.toString() !="")
118   - sql +="and up_down ="+updown;
  129 + sql +="and up_down like '%"+updown.toString()+"%'";
  130 + }
  131 + if(date!=null){
  132 + if (date.toString().length()>0) {
  133 + SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:MM:SS");
  134 + try {
  135 + Long t1=sdf.parse(date.toString()+" 00:00:00").getTime();
  136 + Long t2=sdf.parse(date.toString()+" 23:59:59").getTime();
  137 + sql += " and timestamp >="+t1 +" and timestamp <="+t2;
  138 + } catch (ParseException e) {
  139 + // TODO Auto-generated catch block
  140 + e.printStackTrace();
  141 + }
  142 + }
  143 +
119 144 }
120 145 Connection conn = null;
121 146 PreparedStatement ps = null;
... ...
src/main/java/com/bsth/service/forms/ExportService.java
... ... @@ -2,6 +2,7 @@ package com.bsth.service.forms;
2 2  
3 3 import java.util.List;
4 4  
  5 +import com.bsth.entity.mcy_forms.Daily;
5 6 import com.bsth.entity.mcy_forms.Linepasswengerflow;
6 7 import com.bsth.entity.mcy_forms.Operationservice;
7 8 import com.bsth.entity.mcy_forms.Shifday;
... ... @@ -28,6 +29,6 @@ public interface ExportService {
28 29 public void operationservice(String startDate, String endDate, String lpName,
29 30 List<Operationservice> resList);
30 31  
31   -
  32 +
32 33  
33 34 }
... ...
src/main/java/com/bsth/service/forms/FormsService.java
... ... @@ -5,6 +5,7 @@ import java.util.Map;
5 5  
6 6 import com.bsth.entity.mcy_forms.Allline;
7 7 import com.bsth.entity.mcy_forms.Changetochange;
  8 +import com.bsth.entity.mcy_forms.Daily;
8 9 import com.bsth.entity.mcy_forms.Executionrate;
9 10 import com.bsth.entity.mcy_forms.Linepasswengerflow;
10 11 import com.bsth.entity.mcy_forms.Operationservice;
... ... @@ -39,4 +40,6 @@ public interface FormsService {
39 40 public List<Executionrate> executionrate(Map<String, Object> map);
40 41  
41 42 public List<Allline> allline(Map<String, Object> map);
  43 +
  44 + public List<Daily> daily(Map<String, Object> map);
42 45 }
... ...
src/main/java/com/bsth/service/forms/impl/FormsServiceImpl.java
... ... @@ -25,6 +25,7 @@ import com.bsth.entity.mcy_forms.Vehicleloading;
25 25 import com.bsth.entity.mcy_forms.Waybillday;
26 26 import com.bsth.entity.mcy_forms.Allline;
27 27 import com.bsth.entity.mcy_forms.Changetochange;
  28 +import com.bsth.entity.mcy_forms.Daily;
28 29 import com.bsth.entity.mcy_forms.Executionrate;
29 30 import com.bsth.service.forms.CommonService;
30 31 import com.bsth.service.forms.FormsService;
... ... @@ -290,6 +291,7 @@ public class FormsServiceImpl implements FormsService {
290 291  
291 292 List<Changetochange> list = jdbcTemplate.query(sql, new RowMapper<Changetochange>() {
292 293  
  294 +
293 295 @Override
294 296 public Changetochange mapRow(ResultSet arg0, int arg1) throws SQLException {
295 297 Changetochange chan = new Changetochange();
... ... @@ -314,6 +316,7 @@ public class FormsServiceImpl implements FormsService {
314 316 return list;
315 317 }
316 318  
  319 +
317 320 // 路单数据
318 321 @Override
319 322 public List<Singledata> singledata(Map<String, Object> map) {
... ... @@ -706,4 +709,46 @@ public class FormsServiceImpl implements FormsService {
706 709  
707 710 return list;
708 711 }
  712 +
  713 + @Override
  714 + public List<Daily> daily(Map<String, Object> map) {
  715 +
  716 + String sql ="select r.schedule_date_str,r.xl_bm,r.xl_name,r.cl_zbh,r.j_gh,r.j_name,y.YH,r.gs_bm,r.gs_name,r.fgs_bm,r.fgs_name "
  717 + + " from bsth_c_s_sp_info_real r LEFT JOIN bsth_c_ylb y ON r.cl_zbh = y.nbbm "
  718 + + " WHERE 1 = 1"
  719 + + " and r.xl_bm='" + map.get("line").toString() + "'"
  720 + + " and to_days(r.schedule_date)=to_days('"+map.get("date").toString()+"')"
  721 + + " AND r.gs_bm is not null";
  722 +
  723 + if(map.get("gsdmDaily").toString()!=""){
  724 + sql+=" and r.gs_bm='"+map.get("gsdmDaily").toString()+"'";
  725 + }
  726 + if(map.get("fgsdmDaily").toString()!=""){
  727 + sql+=" and r.fgs_bm='"+map.get("fgsdmDaily").toString()+"'";
  728 + }
  729 + sql += " GROUP BY r.schedule_date_str,r.xl_bm,r.xl_name,r.cl_zbh,r.j_gh,r.j_name,y.YH,r.gs_bm,r.gs_name,r.fgs_bm,r.fgs_name ";
  730 +
  731 + List<Daily> list = jdbcTemplate.query(sql, new RowMapper<Daily>() {
  732 + @Override
  733 + public Daily mapRow(ResultSet arg0, int arg1) throws SQLException {
  734 + Daily daily = new Daily();
  735 + daily.setRq(arg0.getString("schedule_date_str"));
  736 + daily.setZbh(arg0.getString("cl_zbh"));
  737 + daily.setJgh(arg0.getString("j_gh"));
  738 + daily.setjName(arg0.getString("j_name"));
  739 + daily.setYh(arg0.getString("YH"));
  740 + return daily;
  741 + }
  742 + });
  743 +
  744 + for(int i=0;i<list.size();i++){
  745 + Daily d=list.get(i);
  746 + Map<String, Object> maps = new HashMap<>();
  747 + maps = commonService.findKMBC2(d.getJgh(),d.getZbh(),d.getRq());
  748 + d.setJzl1(maps.get("ksgl").toString());
  749 + d.setZlc(maps.get("realMileage").toString());
  750 + d.setBc(maps.get("sjbc").toString());
  751 + }
  752 + return list;
  753 + }
709 754 }
... ...
src/main/java/com/bsth/service/impl/BusIntervalServiceImpl.java
... ... @@ -1102,7 +1102,7 @@ public class BusIntervalServiceImpl implements BusIntervalService {
1102 1102 }
1103 1103 for(String key : keyMap.keySet()){
1104 1104 Map<String, Object> tempMap = new HashMap<String, Object>();
1105   - int jhbc = 0, sjbc = 0, kbc = 0, mbc = 0;
  1105 + int jhbc = 0, sjbc = 0, wdfz = 0;
1106 1106 long jhdf = 0l, sjdf = 0l, wddf1 = 0l, wddf2 = 0l;
1107 1107 long jhfc = 0l, sjfc = 0l, wdfc1 = 0l, wdfc2 = 0l;
1108 1108 long jhys = 0l, sjys = 0l, yssjMax = 0l, yssjMin = 0l;
... ... @@ -1127,10 +1127,10 @@ public class BusIntervalServiceImpl implements BusIntervalService {
1127 1127 yssj += schedule.getZdsjActualTime() - schedule.getFcsjActualTime();
1128 1128 if(schedule.getFcsjActualTime() - schedule.getFcsjT() < 0){
1129 1129 wdfc1 += schedule.getFcsjT() - schedule.getFcsjActualTime();
1130   - kbc++;
  1130 +// kbc++;
1131 1131 } else if(schedule.getFcsjActualTime() - schedule.getFcsjT() > 0){
1132 1132 wdfc2 += schedule.getFcsjActualTime() - schedule.getFcsjT();
1133   - mbc++;
  1133 +// mbc++;
1134 1134 }
1135 1135  
1136 1136 if(schedule.getDfsj() != null){
... ... @@ -1197,8 +1197,16 @@ public class BusIntervalServiceImpl implements BusIntervalService {
1197 1197 tempMap.put("pjys", "0分");
1198 1198 tempMap.put("pjtz", "0分");
1199 1199 }
1200   - tempMap.put("kbc", kbc);
1201   - tempMap.put("mbc", mbc);
  1200 +// tempMap.put("kbc", kbc);
  1201 +// tempMap.put("mbc", mbc);
  1202 + if(!tempMap.get("jhfc").toString().equals("/") && !tempMap.get("sjfc").toString().equals("/")){
  1203 + String[] temp1 = tempMap.get("jhfc").toString().split(":");
  1204 + String[] temp2 = tempMap.get("sjfc").toString().split(":");
  1205 + tempMap.put("wdfz", (Integer.valueOf(temp2[0])*60 + Integer.valueOf(temp2[1]))
  1206 + - (Integer.valueOf(temp1[0])*60 + Integer.valueOf(temp1[1])));
  1207 + }else{
  1208 + tempMap.put("wdfz", "/");
  1209 + }
1202 1210 tempMap.put("jhys", jhys);
1203 1211 tempMap.put("sjys", sjys);
1204 1212 tempMap.put("yssjMin", yssjMin);
... ...
src/main/java/com/bsth/service/realcontrol/buffer/GetSchedulePlanThread.java
... ... @@ -20,7 +20,7 @@
20 20 //import com.bsth.repository.realcontrol.ScheduleRealInfoRepository;
21 21 //import com.bsth.repository.schedule.SchedulePlanInfoRepository;
22 22 //import com.bsth.util.BatchSaveUtils;
23   -//import com.bsth.websocket.handler.RealControlSocketHandler;
  23 +//import com.bsth.websocket.handlers.RealControlSocketHandler;
24 24 //
25 25 ///**
26 26 // *
... ...
src/main/java/com/bsth/service/realcontrol/impl/ScheduleRealInfoServiceImpl.java
... ... @@ -1212,7 +1212,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
1212 1212 map.put("ljbc", ljbc);
1213 1213 map.put("sjbc", jhbc-cjbc+ljbc);
1214 1214 map.put("jcclc", jcclc);
1215   - map.put("zkslc", ksgl+jcclc);
  1215 + map.put("zkslc", format.format(ksgl+jcclc));
1216 1216 return map;
1217 1217 }
1218 1218  
... ... @@ -1226,7 +1226,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
1226 1226 if(obj != null){
1227 1227 map = new HashMap<String,Object>();
1228 1228 map.put("xlName", xlName);
1229   - map.put("clZbh", code);
  1229 + map.put("clZbh", obj[3]);
1230 1230 map.put("company", obj[0]);
1231 1231 map.put("requestType", "0x" + Integer.toHexString(Integer.parseInt(obj[1]+"")).toUpperCase());
1232 1232 map.put("requestTime", obj[2]);
... ...
src/main/java/com/bsth/service/report/ReportService.java
... ... @@ -24,6 +24,8 @@ public interface ReportService {
24 24 Map<String, Object> tbodyTime2(String line ,String ttinfo);
25 25  
26 26 List<Map<String, Object>> tbodyTime3(String line ,String ttinfo);
  27 +
  28 + List<Map<String, Object>> tbodyTime4(String line ,String ttinfo);
27 29 List<Map<String, Object>> tbodyTime5(String line ,String ttinfo);
28 30  
29 31 List<Map<String, Object>> getTtinfo(Map<String, Object> map);
... ...
src/main/java/com/bsth/service/report/impl/ReportServiceImpl.java
... ... @@ -451,21 +451,36 @@ public class ReportServiceImpl implements ReportService{
451 451 System.out.println(609360%60);
452 452 }
453 453 @Override
454   - public List<Map<String, Object>> tbodyTime3(String line, String date) {
  454 + public List<Map<String, Object>> tbodyTime3(String line, String ttinfo) {
455 455 // TODO Auto-generated method stub
456 456 List<Map<String, Object>> list=new ArrayList<Map<String,Object>>();
457   - String sqlZd=" select qdz_name, count(cl_zbh) as cls , 'zqc' as lx from bsth_c_s_sp_info where "
458   - + " DATE_FORMAT(schedule_date,'%Y-%m-%d') ='"+date+"' and xl_bm='"+line+"' and bc_type='normal' "
459   - + " and fcsj>'06:31' and fcsj<'08:00' group by qdz_name union "
460   - + " select qdz_name, count(cl_zbh) as cls , 'wqc' as lx from bsth_c_s_sp_info "
461   - + " where DATE_FORMAT(schedule_date,'%Y-%m-%d') ='"+date+"' and xl_bm='"+line+"' "
462   - + " and bc_type='normal' and fcsj>'16:01' and fcsj<'18:00' group by qdz_name union "
463   - + " select qdz_name, count(cl_zbh) as cls , 'zqj' as lx from bsth_c_s_sp_info "
464   - + " where DATE_FORMAT(schedule_date,'%Y-%m-%d') ='"+date+"' and xl_bm='"+line+"' "
465   - + " and bc_type='region' and fcsj>'06:31' and fcsj<'08:00' group by qdz_name union "
466   - + " select qdz_name, count(cl_zbh) as cls , 'wqj' as lx from bsth_c_s_sp_info "
467   - + " where DATE_FORMAT(schedule_date,'%Y-%m-%d') ='"+date+"' and xl_bm='"+line+"' "
468   - + " and bc_type='region' and fcsj>'16:01' and fcsj<'18:00'group by qdz_name";
  457 +
  458 +
  459 +
  460 + String sqlZd=" select t.*,x.station_name as qdz_name from ("
  461 + + " select qdz,count(lp) as cls,lx from ( select qdz,lp, 'zqc' as lx "
  462 + + " from bsth_c_s_ttinfo_detail where "
  463 + + " bc_type='normal' and ttinfo ='"+ttinfo+"' "
  464 + + " and fcsj>'06:31' and fcsj<'08:00' group by qdz,lp) t1"
  465 + + " group by qdz "
  466 + + " union "
  467 + + " select qdz,count(lp) as cls,lx from ( select qdz,lp, 'wqc' as lx "
  468 + + " from bsth_c_s_ttinfo_detail where "
  469 + + " bc_type='normal' and ttinfo ='"+ttinfo+"' "
  470 + + " and fcsj>'16:01' and fcsj<'18:00' group by qdz,lp) t2"
  471 + + " group by qdz "
  472 + + " union "
  473 + + " select qdz,count(lp) as cls,lx from ( select qdz,lp, 'zqj' as lx "
  474 + + " from bsth_c_s_ttinfo_detail where "
  475 + + " bc_type='region' and ttinfo ='"+ttinfo+"' "
  476 + + " and fcsj>'06:31' and fcsj<'08:00' group by qdz,lp) t3"
  477 + + " group by qdz "
  478 + + " union "
  479 + + " select qdz,count(lp) as cls,lx from ( select qdz,lp, 'wqj' as lx "
  480 + + " from bsth_c_s_ttinfo_detail where "
  481 + + " bc_type='region' and ttinfo ='"+ttinfo+"' "
  482 + + " and fcsj>'16:01' and fcsj<'18:00' group by qdz,lp) t4"
  483 + + " group by qdz ) t left join bsth_c_station x on t.qdz=x.id";
469 484  
470 485 List<Map<String, Object>> lists= jdbcTemplate.query(sqlZd,
471 486 new RowMapper<Map<String, Object>>(){
... ... @@ -526,55 +541,238 @@ public class ReportServiceImpl implements ReportService{
526 541 }
527 542 return list;
528 543 }
  544 +
529 545 @Override
530   - public List<Map<String, Object>> tbodyTime5(String line, String date) {
  546 + public List<Map<String, Object>> tbodyTime4(String line, String ttinfo) {
  547 + List<Map<String, Object>> list =new ArrayList<>();
531 548 // TODO Auto-generated method stub
532   - String sql="select min(fcsj) as fcsj,'lx0' as lx from bsth_c_s_sp_info where "
533   - + " DATE_FORMAT(schedule_date,'%Y-%m-%d') ='"+date+"' and xl_bm='"+line+"'"
534   - + " and bc_type='out' and xl_dir=0 union "
535   - + " select min(fcsj) as fcsj,'lx1' as lx from bsth_c_s_sp_info where "
536   - + " DATE_FORMAT(schedule_date,'%Y-%m-%d') ='"+date+"' and xl_bm='"+line+"'"
537   - + " and bc_type='out' and xl_dir=1";
538   - List<Map<String, Object>> lists= jdbcTemplate.query(sql,
539   - new RowMapper<Map<String, Object>>(){
  549 + //最早营运时间 区分夜宵线
  550 + String sqlMinYysj="select start_opt from bsth_c_line_config where line = '"+BasicData.lineId2CodeMap.inverse().get(line) +"'";
  551 + String minfcsj=jdbcTemplate.queryForObject(sqlMinYysj, String.class);
  552 +
  553 + //查询全程
  554 + String sqlqc="select t.*,x.station_name as qdz_name from ( "
  555 + + "(SELECT fcsj,qdz,2 as xh,xl_dir FROM bsth_c_s_ttinfo_detail "
  556 + + " where ttinfo ='"+ttinfo+"' and bc_type='normal' and fcsj <='"+minfcsj+"' ) "
  557 + + " union "
  558 + + " (SELECT fcsj,qdz,1 as xh,xl_dir FROM bsth_c_s_ttinfo_detail "
  559 + + " where ttinfo ='"+ttinfo+"' and bc_type='normal' and fcsj > '"+minfcsj+"') "
  560 + + "order by xl_dir,xh,fcsj ) t left join bsth_c_station x on t.qdz=x.id";
  561 + List<Map<String, String>> qclist= jdbcTemplate.query(sqlqc,
  562 + new RowMapper<Map<String, String>>(){
540 563 @Override
541   - public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException {
542   - Map<String, Object> m=new HashMap<String,Object>();
543   - m.put("lx", rs.getString("lx"));
  564 + public Map<String, String> mapRow(ResultSet rs, int rowNum) throws SQLException {
  565 + Map<String, String> m=new HashMap<String,String>();
  566 + m.put("qdz_name", rs.getString("qdz_name"));
544 567 m.put("fcsj", rs.getString("fcsj"));
  568 + m.put("xl", rs.getString("xl_dir"));
545 569 return m;
546 570 }
  571 +
547 572 });
  573 +
  574 + Map<String, Object> qcMap=new HashMap<String,Object>();
  575 + int num=0;
  576 + String sxfcsj="";
  577 + String xxfcsj="";
  578 + String sxzd="";
  579 + String xxzd="";
  580 + for (int i = 0; i < qclist.size(); i++) {
  581 + Map<String, String> map=qclist.get(i);
  582 + if(map.get("xl").equals("0")){
  583 + if(sxzd.equals("")){
  584 + sxzd=map.get("qdz_name").toString();
  585 + qcMap.put("sxzm", sxzd);
  586 + sxfcsj +=map.get("fcsj").toString()+"-";
  587 + }
  588 + if(!(qclist.get(i+1).get("xl").equals("0"))){
  589 + sxfcsj +=map.get("fcsj").toString();
  590 + qcMap.put("sxsj",sxfcsj);
  591 + qcMap.put("sxbc", i+1);
  592 + num=i+1;
  593 + }
  594 + }
  595 + if(map.get("xl").equals("1")){
  596 + if(xxzd.equals("")){
  597 + xxzd=map.get("qdz_name").toString();
  598 + xxfcsj+=map.get("fcsj").toString()+"-";
  599 + qcMap.put("xxzm", xxzd);
  600 + }
  601 + }
  602 + }
  603 + xxfcsj +=qclist.get(qclist.size()-1).get("fcsj").toString();
  604 + qcMap.put("xxsj", xxfcsj);
  605 + qcMap.put("xxbc", qclist.size()-num);
  606 + list.add(qcMap);
548 607  
549   - String sqlList="select * from bsth_c_s_sp_info where "
550   - + "DATE_FORMAT(schedule_date,'%Y-%m-%d') ='"+date+"' and xl_bm='"+line+"'"
551   - + " and bc_type='normal' order by fcsj";
552   - List<SchedulePlanInfo> list= jdbcTemplate.query(sqlList,
553   - new RowMapper<SchedulePlanInfo>(){
  608 +
  609 + //查询区间
  610 + String sqlqj="select t.*,x.station_name as qdz_name from ( "
  611 + + "(SELECT fcsj,qdz,'1' as gf,xl_dir FROM bsth_c_s_ttinfo_detail "
  612 + + "where ttinfo ='"+ttinfo+"' and bc_type='region' and fcsj >='06:31'"
  613 + + "and fcsj <'08:30')"
  614 + + " union ( SELECT fcsj,qdz,'2' as gf,xl_dir FROM bsth_c_s_ttinfo_detail "
  615 + + "where ttinfo ='"+ttinfo+"' and bc_type='region' "
  616 + + "and fcsj > '16:01' and fcsj < '18:00') order by xl_dir,gf,fcsj ) t "
  617 + + "left join bsth_c_station x on t.qdz=x.id";
  618 +
  619 + List<Map<String, String>> qjlist= jdbcTemplate.query(sqlqj,
  620 + new RowMapper<Map<String, String>>(){
554 621 @Override
555   - public SchedulePlanInfo mapRow(ResultSet rs, int rowNum) throws SQLException {
556   - SchedulePlanInfo m=new SchedulePlanInfo();
557   - m.setBcsj(rs.getInt("bcsj"));
558   - m.setXlDir(rs.getString("xl_dir"));
559   - m.setFcsj(rs.getString("fcsj"));
  622 + public Map<String, String> mapRow(ResultSet rs, int rowNum) throws SQLException {
  623 + Map<String, String> m=new HashMap<String,String>();
  624 + m.put("qdz_name", rs.getString("qdz_name"));
  625 + m.put("fcsj", rs.getString("fcsj"));
  626 + m.put("xl", rs.getString("xl_dir"));
  627 + m.put("gf", rs.getString("gf"));
560 628 return m;
561 629 }
562 630 });
563   - //上下行最早发车时间 (用于与夜班线 跨零点的班次进行比较)
564   - String lx0="";
565   - String lx1="";
566   - for (int x = 0; x < lists.size(); x++) {
567   - if(lists.get(x).get("lx").equals("lx0")){
568   - lx0=lists.get(x).get("fcsj")==null?"0:0":lists.get(x).get("fcsj").toString();
  631 +
  632 + Map<String, Object> qjzMap=new HashMap<String,Object>();
  633 + Map<String, Object> qjwMap=new HashMap<String,Object>();
  634 + int numqj=0;
  635 + String sxfcsjqj="";
  636 + String xxfcsjqj="";
  637 + String sxzdqj="";
  638 + String xxzdqj="";
  639 + for(int i=0;i<qjlist.size();i++){
  640 + Map<String, String> map=qjlist.get(i);
  641 + if(map.get("xl").toString().equals("0")){
  642 + if(map.get("gf").toString().equals("1")){
  643 + if(sxzdqj.equals("")){
  644 + sxzdqj =map.get("qdz_name").toString();
  645 + qjzMap.put("sxzm", sxzdqj);
  646 + sxfcsjqj +=map.get("fcsj").toString()+"-";
  647 + }
  648 + if(i<qjlist.size()-1){
  649 + if(!(qjlist.get(i+1).get("gf").equals("1"))){
  650 + sxfcsjqj +=map.get("fcsj").toString();
  651 + qjzMap.put("sxsj",sxfcsjqj);
  652 + qjzMap.put("sxbc", i+1);
  653 + numqj=i+1;
  654 + sxzdqj ="";
  655 + sxfcsjqj="";
  656 + }
  657 + }else{
  658 + qjzMap.put("sxsj",sxfcsjqj+"-"+map.get("fcsj").toString());
  659 + qjzMap.put("sxbc", i+1);
  660 + numqj=i+1;
  661 + sxzdqj ="";
  662 + sxfcsjqj="";
  663 + }
  664 + }
  665 + if(map.get("gf").toString().equals("2")){
  666 + if(sxzdqj.equals("")){
  667 + sxzdqj =map.get("qdz_name").toString();
  668 + qjwMap.put("sxzm", sxzdqj);
  669 + sxfcsjqj +=map.get("fcsj").toString()+"-";
  670 + }
  671 + if(i<qjlist.size()-1){
  672 + if(!(qjlist.get(i+1).get("xl").equals("0"))){
  673 + sxfcsjqj +=map.get("fcsj").toString();
  674 + qjwMap.put("sxsj",sxfcsjqj);
  675 + qjwMap.put("sxbc", i+1-numqj);
  676 + numqj=i+1;
  677 + }
  678 + }else{
  679 + qjwMap.put("sxsj",sxfcsjqj+"-"+map.get("fcsj").toString());
  680 + qjwMap.put("sxbc", i+1-numqj);
  681 + numqj=i+1;
  682 + }
  683 + }
  684 +
569 685 }else{
570   - lx1=lists.get(x).get("fcsj")==null?"0:0":lists.get(x).get("fcsj").toString();
  686 + if(map.get("gf").toString().equals("1")){
  687 + if(xxzdqj.equals("")){
  688 + xxzdqj =map.get("qdz_name").toString();
  689 + qjzMap.put("xxzm", xxzdqj);
  690 + xxfcsjqj +=map.get("fcsj").toString()+"-";
  691 + }
  692 + if(i<qjlist.size()-1){
  693 + if(!(qjlist.get(i+1).get("gf").equals("1"))){
  694 + xxfcsjqj +=map.get("fcsj").toString();
  695 + qjzMap.put("xxsj",xxfcsjqj);
  696 + qjzMap.put("xxbc", i+1-numqj);
  697 + numqj=i+1;
  698 + xxzdqj ="";
  699 + xxfcsjqj="";
  700 + }
  701 + }else{
  702 + qjzMap.put("xxsj",xxfcsjqj+"-"+map.get("fcsj").toString());
  703 + qjzMap.put("xxbc", i+1-numqj);
  704 + numqj=i+1;
  705 + xxzdqj ="";
  706 + xxfcsjqj="";
  707 + }
  708 + }
  709 + if(map.get("gf").toString().equals("2")){
  710 + if(xxzdqj.equals("")){
  711 + xxzdqj =map.get("qdz_name").toString();
  712 + qjwMap.put("xxzm", xxzdqj);
  713 + xxfcsjqj +=map.get("fcsj").toString()+"-";
  714 + }
  715 + if(i<qjlist.size()){
  716 + if(i==qjlist.size()-1){
  717 + xxfcsjqj +=map.get("fcsj").toString();
  718 + qjwMap.put("xxsj",xxfcsjqj);
  719 + qjwMap.put("xxbc", i+1-numqj);
  720 + numqj=i+1;
  721 + }
  722 + }else{
  723 + qjwMap.put("xxsj",xxfcsjqj+"-"+xxfcsjqj);
  724 + qjwMap.put("xxbc", i+1-numqj);
  725 + numqj=i+1;
  726 + }
  727 + }
  728 +
  729 +
571 730 }
572 731 }
573 732  
574   - String[] lx0sj = lx0.split(":");
575   - int sxFc=Integer.parseInt(lx0sj[0])*60+Integer.parseInt(lx0sj[1]);
576   - String[] lx1sj = lx1.split(":");
577   - int xxFc=Integer.parseInt(lx1sj[0])*60+Integer.parseInt(lx1sj[1]);
  733 + if(!qjzMap.isEmpty()){
  734 + list.add(qjzMap);
  735 + }
  736 + if(!qjwMap.isEmpty()){
  737 + list.add(qjwMap);
  738 +
  739 + }
  740 + return list;
  741 + }
  742 + @Override
  743 + public List<Map<String, Object>> tbodyTime5(String line, String ttinfo) {
  744 + // TODO Auto-generated method stub
  745 + //最早营运时间 区分夜宵线
  746 + String sqlMinYysj="select start_opt from bsth_c_line_config where line = '"+BasicData.lineId2CodeMap.inverse().get(line) +"'";
  747 + String minfcsj=jdbcTemplate.queryForObject(sqlMinYysj, String.class);
  748 + String[] minSjs = minfcsj.split(":");
  749 + int minSj=Integer.parseInt(minSjs[0])*60+Integer.parseInt(minSjs[1]);
  750 + //查询时间里程
  751 + String sqlPc=" (SELECT jhlc,fcsj,bcsj,bc_type,lp,xl_dir,2 as xh FROM "
  752 + + " bsth_c_s_ttinfo_detail where ttinfo ='"+ttinfo+"' and "
  753 + + " fcsj <='"+minfcsj+"' and bc_type = 'normal') "
  754 + + " union "
  755 + + " (SELECT jhlc,fcsj,bcsj,bc_type,lp,xl_dir,1 as xh FROM "
  756 + + " bsth_c_s_ttinfo_detail where ttinfo ='"+ttinfo+"' and "
  757 + + " fcsj >'"+minfcsj+"' and bc_type ='normal') "
  758 + + " order by xl_dir, xh,fcsj";
  759 +
  760 + Map<String, Object> map=new HashMap<String,Object>();
  761 + List<Map<String, Object>> list= jdbcTemplate.query(sqlPc,
  762 + new RowMapper<Map<String, Object>>(){
  763 + @Override
  764 + public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException {
  765 + Map<String, Object> m=new HashMap<String,Object>();
  766 + m.put("fcsj", rs.getString("fcsj"));
  767 + m.put("yygl", rs.getString("jhlc")==null?"0":rs.getString("jhlc"));
  768 + m.put("bcsj", rs.getString("bcsj"));
  769 + m.put("bcType", rs.getString("bc_type"));
  770 + m.put("lp", rs.getString("lp"));
  771 + m.put("dir", rs.getString("xl_dir"));
  772 + return m;
  773 + }
  774 + });
  775 +
578 776 //班次
579 777 int sj_0 = 6*60+31,sj_1 = 8*60+30,sj_2 = 16*60+1,sj_3 = 18*60;
580 778  
... ... @@ -587,17 +785,17 @@ public class ReportServiceImpl implements ReportService{
587 785 //车距 (发车时间的间距) i--MIN a--MAX
588 786 int iC=999,aC=-1,iZg=999,aZg=-1,iZw=999,aZw=-1,iWg=999,aWg=-1,iJcZ=999,aJcZ=-1,iJcW=999,aJcW=-1;
589 787 int iC1=999,aC1=-1,iZg1=999,aZg1=-1,iZw1=999,aZw1=-1,iWg1=999,aWg1=-1,iJc1Z=999,aJc1Z=-1,iJc1W=999,aJc1W=-1;
590   -// List<ScheduleRealInfo> list = scheduleRealInfoRepository.scheduleByDateAndLine(line, date);
  788 +
591 789 for(int i=0;i<list.size();i++){
592   - SchedulePlanInfo t=list.get(i);
593   - String xlDir=t.getXlDir();
594   - int bcsj=t.getBcsj();
595   - String fcsj=t.getFcsj();
  790 + Map<String, Object> ttMap=list.get(i);
  791 + String xlDir=ttMap.get("dir").toString();
  792 + int bcsj=Integer.parseInt(ttMap.get("bcsj").toString());
  793 + String fcsj=ttMap.get("fcsj").toString();
596 794 String[] fcsjs=fcsj.split(":");
597 795 int fcsjNum=Integer.parseInt(fcsjs[0])*60+Integer.parseInt(fcsjs[1]);
598 796  
599 797 if(xlDir.equals("0")){
600   - if(fcsjNum>=sxFc && fcsjNum<sj_0){
  798 + if(fcsjNum>=minSj && fcsjNum<sj_0){
601 799 ccsj0 +=bcsj;
602 800 if(aC<0){
603 801 cfc0 =fcsjNum;
... ... @@ -672,7 +870,7 @@ public class ReportServiceImpl implements ReportService{
672 870 }
673 871 jcfc0W=fcsjNum;
674 872 }
675   - }else if(fcsjNum<sxFc){
  873 + }else if(fcsjNum<minSj){
676 874 jcsj0 +=bcsj;
677 875 if(aJcZ<0){
678 876 jcfc0Z=fcsjNum;
... ... @@ -690,7 +888,7 @@ public class ReportServiceImpl implements ReportService{
690 888  
691 889  
692 890 }else{
693   - if(fcsjNum>=xxFc && fcsjNum<sj_0){
  891 + if(fcsjNum>=minSj && fcsjNum<sj_0){
694 892 ccsj1 +=bcsj;
695 893 if(aC1<0){
696 894 cfc1=fcsjNum;
... ... @@ -762,7 +960,7 @@ public class ReportServiceImpl implements ReportService{
762 960  
763 961 jcfc1W=fcsjNum;
764 962 }
765   - }else if(fcsjNum<xxFc){
  963 + }else if(fcsjNum<minSj){
766 964 jcsj1 +=bcsj;
767 965 if(aJc1Z<0){
768 966 jcfc1Z=fcsjNum;
... ... @@ -860,4 +1058,5 @@ public class ReportServiceImpl implements ReportService{
860 1058 }
861 1059 return list;
862 1060 }
  1061 +
863 1062 }
... ...