Commit de20530f59303fb9222c0b8e9b22f7ca9e7ba07b

Authored by 廖磊
2 parents 41e4b946 93a8257b

Merge branch 'pudong' of http://222.66.0.204:8090/panzhaov5/bsth_control

into pudong
Showing 115 changed files with 7519 additions and 4458 deletions
... ... @@ -250,15 +250,6 @@
250 250 <version>1.7.4</version>
251 251 </dependency>
252 252  
253   -
254   - <!-- <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId>
255   - <optional>true</optional> </dependency> -->
256   - <dependency>
257   - <groupId>com.vividsolutions</groupId>
258   - <artifactId>jts</artifactId>
259   - <version>1.13</version>
260   - </dependency>
261   -
262 253 <dependency>
263 254 <groupId>org.dbunit</groupId>
264 255 <artifactId>dbunit</artifactId>
... ...
src/main/java/com/bsth/XDApplication.java
... ... @@ -5,10 +5,10 @@ import com.bsth.data.ThreadMonotor;
5 5 import com.bsth.data.car_out_info.UpdateDBThread;
6 6 import com.bsth.data.directive.DirectivesPstThread;
7 7 import com.bsth.data.forecast.SampleTimeDataLoader;
8   -import com.bsth.data.gpsdata.thread.GpsDataLoaderThread;
9   -import com.bsth.data.gpsdata.thread.OfflineMonitorThread;
  8 +import com.bsth.data.gpsdata_v2.thread.GpsDataLoaderThread;
10 9 import com.bsth.data.msg_queue.DirectivePushQueue;
11 10 import com.bsth.data.msg_queue.WebSocketPushQueue;
  11 +import com.bsth.data.schedule.DayOfSchedule;
12 12 import com.bsth.data.schedule.auto_exec.AutoExecScanThread;
13 13 import com.bsth.data.schedule.edit_logs.SeiPstThread;
14 14 import com.bsth.data.schedule.late_adjust.ScheduleLateThread;
... ... @@ -42,10 +42,6 @@ public class XDApplication implements CommandLineRunner {
42 42 @Autowired
43 43 UpdateDBThread fcxxUpdateThread;
44 44 @Autowired
45   - GpsDataLoaderThread gpsDataLoader;
46   - @Autowired
47   - OfflineMonitorThread offlineMonitorThread;
48   - @Autowired
49 45 ScheduleRefreshThread scheduleRefreshThread;
50 46 @Autowired
51 47 SchedulePstThread schedulePstThread;
... ... @@ -68,6 +64,9 @@ public class XDApplication implements CommandLineRunner {
68 64 @Autowired
69 65 AutoExecScanThread autoExecScanThread;
70 66  
  67 + @Autowired
  68 + GpsDataLoaderThread gpsDataLoader;
  69 +
71 70 private static long timeDiff;
72 71 private static long timeDiffTraffic;
73 72  
... ... @@ -103,15 +102,15 @@ public class XDApplication implements CommandLineRunner {
103 102 }
104 103 }
105 104  
106   - //@Autowired
107   - //DayOfSchedule dayOfSchedule;
  105 + @Autowired
  106 + DayOfSchedule dayOfSchedule;
108 107 public void devInit(){
109 108 log.info("devInit...");
110 109 ScheduledExecutorService sexec = Application.mainServices;
111 110 //抓取GPS数据
112 111 gpsDataLoader.setFlag(-1);
113 112 //dayOfSchedule.dataRecovery();
114   - //sexec.scheduleWithFixedDelay(gpsDataLoader, 30, 2, TimeUnit.SECONDS);
  113 + //sexec.scheduleWithFixedDelay(gpsDataLoader, 60, 4, TimeUnit.SECONDS);
115 114 //实际排班更新线程
116 115 //sexec.scheduleWithFixedDelay(scheduleRefreshThread, 15, 240, TimeUnit.SECONDS);
117 116 //sexec.scheduleWithFixedDelay(autoExecScanThread, 100, 50, TimeUnit.SECONDS);//班次自动执行
... ... @@ -135,7 +134,7 @@ public class XDApplication implements CommandLineRunner {
135 134 sexec.scheduleWithFixedDelay(scheduleLateThread, 70, 30, TimeUnit.SECONDS);//检查班次误点
136 135 sexec.scheduleWithFixedDelay(gpsDataLoader, 100, 2, TimeUnit.SECONDS);//抓取GPS数据
137 136  
138   - sexec.scheduleWithFixedDelay(offlineMonitorThread, 120, 60, TimeUnit.SECONDS);//GPS设备掉离线
  137 + //sexec.scheduleWithFixedDelay(offlineMonitorThread, 120, 60, TimeUnit.SECONDS);//GPS设备掉离线
139 138 sexec.scheduleWithFixedDelay(schedulePstThread, 120, 10, TimeUnit.SECONDS);//班次延迟入库线程
140 139 sexec.scheduleWithFixedDelay(seiPstThread, 160, 60, TimeUnit.SECONDS);//班次修正日志入库
141 140 sexec.scheduleWithFixedDelay(directivesPstThread, 180, 120, TimeUnit.SECONDS);//调度指令延迟入库
... ...
src/main/java/com/bsth/controller/DeviceGpsController.java
1 1 package com.bsth.controller;
2 2  
3   -import com.bsth.data.gpsdata.GpsEntity;
4   -import com.bsth.data.gpsdata.GpsRealData;
  3 +import com.bsth.data.gpsdata_v2.GpsRealData;
  4 +import com.bsth.data.gpsdata_v2.entity.GpsEntity;
5 5 import com.fasterxml.jackson.core.JsonParseException;
6 6 import com.fasterxml.jackson.databind.JsonMappingException;
7 7 import com.fasterxml.jackson.databind.ObjectMapper;
... ...
src/main/java/com/bsth/controller/LineVersionsController.java
... ... @@ -77,28 +77,7 @@ public class LineVersionsController extends BaseController&lt;LineVersions, Integer
77 77  
78 78 @RequestMapping(value = "add", method = RequestMethod.POST)
79 79 public Map<String, Object> add(@RequestParam Map<String, Object> map) {
80   - SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
81   -
82   - LineVersions lineVersions = new LineVersions();
83   - try {
84   - Date startDate = simpleDateFormat.parse(map.get("startDate").toString());
85   - Date endDate = simpleDateFormat.parse(map.get("endDate").toString());
86   - Line line = lineRepository.findOne(Integer.valueOf(map.get("lineId").toString()));
87   - lineVersions.setName(map.get("name").toString());
88   - lineVersions.setLine(line);
89   - lineVersions.setLineCode(map.get("lineCode").toString());
90   - lineVersions.setStartDate(new java.sql.Date(startDate.getTime()));
91   - lineVersions.setEndDate(new java.sql.Date(endDate.getTime()));
92   - lineVersions.setVersions(Integer.valueOf(map.get("versions").toString()));
93   - lineVersions.setStatus(Integer.valueOf(map.get("status").toString()));
94   - lineVersions.setRemark(map.get("remark").toString());
95   -
96   -
97   - } catch (ParseException e) {
98   - // TODO Auto-generated catch block
99   - e.printStackTrace();
100   - }
101   - return service.save(lineVersions);
  80 + return service.add(map);
102 81 }
103 82  
104 83 }
... ...
src/main/java/com/bsth/controller/calc/CalcWaybillController.java 0 → 100644
  1 +package com.bsth.controller.calc;
  2 +
  3 +import java.util.HashMap;
  4 +import java.util.List;
  5 +import java.util.Map;
  6 +
  7 +import com.bsth.common.ResponseCode;
  8 +import com.bsth.controller.BaseController;
  9 +import com.bsth.entity.calc.CalcWaybill;
  10 +import com.bsth.service.calc.CalcWaybillService;
  11 +
  12 +import org.springframework.beans.factory.annotation.Autowired;
  13 +import org.springframework.web.bind.annotation.RequestMapping;
  14 +import org.springframework.web.bind.annotation.RequestParam;
  15 +import org.springframework.web.bind.annotation.RestController;
  16 +
  17 +/**
  18 + * Created by 17/10/23.
  19 + */
  20 +@RestController
  21 +@RequestMapping("calcWaybill")
  22 +public class CalcWaybillController extends BaseController<CalcWaybill, Integer> {
  23 +
  24 + @Autowired
  25 + private CalcWaybillService calcWaybillService;
  26 +
  27 + @RequestMapping(value="/generateNew")
  28 + public Map<String, Object> generateNews(@RequestParam Map<String, Object> map) throws Exception{
  29 + String date = "", line = "";
  30 + if(map.get("date")!=null){
  31 + date=map.get("date").toString().trim();
  32 + }
  33 + if(map.get("line")!=null){
  34 + line=map.get("line").toString().trim();
  35 + }
  36 +
  37 + Map<String, Object> m = new HashMap<String, Object>();
  38 + try {
  39 +
  40 + m = calcWaybillService.generateNew(date, line);
  41 +
  42 + } catch (Exception e) {
  43 + // TODO: handle exception
  44 + e.printStackTrace();
  45 + m.put("status", ResponseCode.ERROR);
  46 + return m;
  47 + }
  48 +
  49 + return m;
  50 + }
  51 +
  52 + @RequestMapping(value="/statisticsDailyTj")
  53 + public List<Map<String,Object>> statisticsDailyTj(@RequestParam Map<String, Object> map){
  54 + String gsdm="";
  55 + if(map.get("gsdm")!=null){
  56 + gsdm=map.get("gsdm").toString().trim();
  57 + }
  58 + String fgsdm="";
  59 + if(map.get("fgsdm")!=null){
  60 + fgsdm=map.get("fgsdm").toString().trim();
  61 + }
  62 + String line="";
  63 + if(map.get("line")!=null){
  64 + line=map.get("line").toString().trim();
  65 + }
  66 + String date="";
  67 + if(map.get("date")!=null){
  68 + date=map.get("date").toString().trim();
  69 + }
  70 + String date2="";
  71 + if(map.get("date2")!=null){
  72 + date2=map.get("date2").toString().trim();
  73 + }
  74 + String xlName="";
  75 + if(map.get("xlName")!=null){
  76 + xlName=map.get("xlName").toString().trim();
  77 + }
  78 + String type="";
  79 + if(map.get("type")!=null){
  80 + type=map.get("type").toString().trim();
  81 + }
  82 + return calcWaybillService.statisticsDailyTj(gsdm,fgsdm,line,date,date2,xlName,type);
  83 + }
  84 +
  85 +}
... ...
src/main/java/com/bsth/controller/gps/GpsController.java
1 1 package com.bsth.controller.gps;
2 2  
3 3 import com.bsth.data.BasicData;
4   -import com.bsth.data.gpsdata.GpsEntity;
5   -import com.bsth.data.gpsdata.GpsRealData;
6   -import com.bsth.entity.excep.Speeding;
  4 +import com.bsth.data.gpsdata_v2.GpsRealData;
  5 +import com.bsth.data.gpsdata_v2.entity.GpsEntity;
7 6 import com.bsth.service.gps.GpsService;
8 7 import com.bsth.service.gps.entity.GpsSpeed;
9   -import com.bsth.util.PageObject;
10 8 import com.google.common.base.Splitter;
11 9 import org.springframework.beans.factory.annotation.Autowired;
12 10 import org.springframework.web.bind.annotation.*;
13 11  
14 12 import javax.servlet.http.HttpServletResponse;
15   -
16 13 import java.text.ParseException;
17 14 import java.util.ArrayList;
18 15 import java.util.List;
... ...
src/main/java/com/bsth/controller/realcontrol/RealMapController.java
1 1 package com.bsth.controller.realcontrol;
2 2  
3   -import com.bsth.data.gpsdata.arrival.GeoCacheData;
4   -import com.bsth.data.gpsdata.arrival.entity.TimedEnableStationRoute;
5 3 import com.bsth.service.realcontrol.RealMapService;
6 4 import org.springframework.beans.factory.annotation.Autowired;
7 5 import org.springframework.web.bind.annotation.RequestMapping;
8   -import org.springframework.web.bind.annotation.RequestMethod;
9 6 import org.springframework.web.bind.annotation.RequestParam;
10 7 import org.springframework.web.bind.annotation.RestController;
11 8  
... ... @@ -77,9 +74,4 @@ public class RealMapController {
77 74 public Map<String, Object> multiSectionRoute(@RequestParam String codeIdx){
78 75 return realMapService.multiSectionRoute(codeIdx);
79 76 }
80   -
81   - @RequestMapping(value = "/lockAndFlxedTimeEnabled", method = RequestMethod.POST)
82   - public void lockAndFlxedTimeEnabled(TimedEnableStationRoute tes){
83   - GeoCacheData.tesMap.put(tes.getLineCode(), tes);
84   - }
85 77 }
... ...
src/main/java/com/bsth/controller/realcontrol/ServiceDataInterface.java
1 1 package com.bsth.controller.realcontrol;
2 2  
3 3 import com.alibaba.fastjson.JSON;
4   -import com.alibaba.fastjson.JSONObject;
5 4 import com.bsth.data.BasicData;
6 5 import com.bsth.data.directive.DayOfDirectives;
7 6 import com.bsth.data.directive.DirectiveCreator;
8 7 import com.bsth.data.directive.GatewayHttpUtils;
9   -import com.bsth.data.gpsdata.GpsEntity;
10   -import com.bsth.data.gpsdata.GpsRealData;
  8 +import com.bsth.data.gpsdata_v2.GpsRealData;
  9 +import com.bsth.data.gpsdata_v2.entity.GpsEntity;
11 10 import com.bsth.data.schedule.DayOfSchedule;
12 11 import com.bsth.entity.directive.D60;
13 12 import com.bsth.entity.realcontrol.ScheduleRealInfo;
... ... @@ -50,33 +49,35 @@ public class ServiceDataInterface {
50 49 * @return
51 50 */
52 51 @RequestMapping("/execSchList")
53   - public List<JSONObject> execSchList(@RequestParam String secretKey){
  52 + public List<Map<String, Object>> execSchList(@RequestParam String secretKey){
54 53 if (StringUtils.isEmpty(secretKey) || !secretKey.equals(SECRE_KEY))
55 54 return null;
56 55  
57   - List<JSONObject> rs = new ArrayList<>();
  56 + List<Map<String, Object>> rs = new ArrayList<>();
58 57 Collection<ScheduleRealInfo> list = dayOfSchedule.execPlanMap().values();
59 58  
60   - JSONObject obj;
  59 + Map<String, Object> map;
61 60 for(ScheduleRealInfo sch : list){
62   - obj = new JSONObject();
63   - obj.put("clZbh", sch.getClZbh());
64   - obj.put("jGh", sch.getjGh());
65   - obj.put("sGh", sch.getsGh());
66   - obj.put("lpName", sch.getLpName());
67   - obj.put("xlBm", sch.getXlBm());
68   - obj.put("xlName", sch.getXlName());
69   - obj.put("xlDir", sch.getXlDir());
70   - obj.put("qdzName", sch.getQdzName());
71   - obj.put("zdzName", sch.getZdzName());
72   - obj.put("fcsj", sch.getFcsj());
73   - obj.put("dfsj", sch.getDfsj());
74   - obj.put("zdsj", sch.getZdsj());
75   - obj.put("bcType", sch.getBcType());
76   - obj.put("remarks", sch.getRemark());
77   - obj.put("status", sch.getStatus());
78   -
79   - rs.add(obj);
  61 + if(null == sch)
  62 + continue;
  63 + map = new HashMap<>();
  64 + map.put("clZbh", sch.getClZbh());
  65 + map.put("jGh", sch.getjGh());
  66 + map.put("sGh", sch.getsGh());
  67 + map.put("lpName", sch.getLpName());
  68 + map.put("xlBm", sch.getXlBm());
  69 + map.put("xlName", sch.getXlName());
  70 + map.put("xlDir", sch.getXlDir());
  71 + map.put("qdzName", sch.getQdzName());
  72 + map.put("zdzName", sch.getZdzName());
  73 + map.put("fcsj", sch.getFcsj());
  74 + map.put("dfsj", sch.getDfsj());
  75 + map.put("zdsj", sch.getZdsj());
  76 + map.put("bcType", sch.getBcType());
  77 + map.put("remarks", sch.getRemark());
  78 + map.put("status", sch.getStatus());
  79 +
  80 + rs.add(map);
80 81 }
81 82 return rs;
82 83 }
... ...
src/main/java/com/bsth/controller/realcontrol/SignalStateController.java
1   -package com.bsth.controller.realcontrol;
2   -
3   -import com.bsth.data.gpsdata.SignalStateData;
4   -import com.bsth.data.gpsdata.arrival.entity.SignalState;
5   -import org.springframework.beans.factory.annotation.Autowired;
6   -import org.springframework.web.bind.annotation.RequestMapping;
7   -import org.springframework.web.bind.annotation.RequestParam;
8   -import org.springframework.web.bind.annotation.RestController;
9   -
10   -import java.util.List;
11   -
12   -/**
13   - * Created by panzhao on 2016/12/30.
14   - */
15   -@RestController
16   -@RequestMapping("signalState")
17   -public class SignalStateController {
18   -
19   - @Autowired
20   - SignalStateData signalStateData;
21   -
22   - @RequestMapping("/multi")
23   - public List<SignalState> findByMultiLine(@RequestParam String idx){
24   - return signalStateData.get(idx);
25   - }
26   -}
  1 +//package com.bsth.controller.realcontrol;
  2 +//
  3 +//import com.bsth.data.gpsdata.SignalStateData;
  4 +//import com.bsth.data.gpsdata.arrival.entity.SignalState;
  5 +//import org.springframework.beans.factory.annotation.Autowired;
  6 +//import org.springframework.web.bind.annotation.RequestMapping;
  7 +//import org.springframework.web.bind.annotation.RequestParam;
  8 +//import org.springframework.web.bind.annotation.RestController;
  9 +//
  10 +//import java.util.List;
  11 +//
  12 +///**
  13 +// * Created by panzhao on 2016/12/30.
  14 +// */
  15 +//@RestController
  16 +//@RequestMapping("signalState")
  17 +//public class SignalStateController {
  18 +//
  19 +// @Autowired
  20 +// SignalStateData signalStateData;
  21 +//
  22 +// @RequestMapping("/multi")
  23 +// public List<SignalState> findByMultiLine(@RequestParam String idx){
  24 +// return signalStateData.get(idx);
  25 +// }
  26 +//}
... ...
src/main/java/com/bsth/controller/realcontrol/anomalyCheckController.java
1 1 package com.bsth.controller.realcontrol;
2 2  
3   -import com.bsth.data.gpsdata.arrival.GeoCacheData;
4   -import com.bsth.data.gpsdata.arrival.GpsRealAnalyse;
5   -import com.bsth.data.gpsdata.thread.GpsDataLoaderThread;
  3 +import com.bsth.data.gpsdata_v2.cache.GeoCacheData;
  4 +import com.bsth.data.gpsdata_v2.thread.GpsDataLoaderThread;
6 5 import com.bsth.data.msg_queue.DirectivePushQueue;
7 6 import com.bsth.data.msg_queue.WebSocketPushQueue;
8 7 import com.bsth.data.schedule.DayOfSchedule;
... ... @@ -59,11 +58,6 @@ public class anomalyCheckController {
59 58 }
60 59 }
61 60  
62   - @RequestMapping(value = "/shutdownThreadPool")
63   - public void shutdownThreadPool(){
64   - GpsRealAnalyse.shutdown();
65   - }
66   -
67 61 @RequestMapping(value = "/directivePushQueue")
68 62 public void directivePushQueue(){
69 63 DirectivePushQueue.start();
... ...
src/main/java/com/bsth/data/BasicData.java
1 1 package com.bsth.data;
2 2  
3   -import com.bsth.data.gpsdata.arrival.GeoCacheData;
  3 +import com.bsth.data.gpsdata_v2.cache.GeoCacheData;
4 4 import com.bsth.data.pinyin.PersionPinYinBuffer;
5 5 import com.bsth.entity.*;
6 6 import com.bsth.entity.schedule.CarConfigInfo;
... ...
src/main/java/com/bsth/data/LineConfigData.java
... ... @@ -2,7 +2,6 @@ package com.bsth.data;
2 2  
3 3 import com.bsth.Application;
4 4 import com.bsth.entity.Line;
5   -import com.bsth.entity.realcontrol.D80ReplyTemp;
6 5 import com.bsth.entity.realcontrol.LineConfig;
7 6 import com.bsth.entity.realcontrol.ScheduleRealInfo;
8 7 import com.bsth.service.LineService;
... ... @@ -135,31 +134,15 @@ public class LineConfigData implements CommandLineRunner {
135 134 conf.setLine(line);
136 135 //开始运营时间
137 136 conf.setStartOpt("02:00");
138   - //托管状态
139   - conf.setTrust(true);
140 137 //出场时间类型
141 138 conf.setOutConfig(0);
142   - //进场时间类型
143   - //conf.setInConfig(1);
144   - //短语模板
145   - conf.setPhraseTemps("");
146 139 //调度指令模板
147 140 conf.setSchDirectiveTemp("");
148 141  
149   - //80指令回复 闵行用
150   - D80ReplyTemp t50 = new D80ReplyTemp(conf, (short) 0x50, "同意,回电详谈", "不同意,请回电"), t60 = new D80ReplyTemp(conf, (short) 0x60, "同意,回电详谈", "不同意,请回电"), tA2 = new D80ReplyTemp(conf, (short) 0xA2, "同意,回电详谈", "不同意,请回电"), t70 = new D80ReplyTemp(conf, (short) 0x70, "同意,回电详谈", "不同意,请回电"), t11 = new D80ReplyTemp(conf, (short) 0x11, "同意,回电详谈", "不同意,请回电");
151   -
152 142 //应急停靠默认值
153 143 conf.setYjtkStart("00:00");
154 144 conf.setYjtkEnd("23:59");
155 145  
156   - Set<D80ReplyTemp> temps = conf.getD80Temps();
157   - temps.add(t50);
158   - temps.add(t60);
159   - temps.add(tA2);
160   - temps.add(t70);
161   - temps.add(t11);
162   -
163 146 set(conf);
164 147 }
165 148 }
... ...
src/main/java/com/bsth/data/LineVersionsData.java
... ... @@ -21,7 +21,7 @@ import com.bsth.service.StationRouteService;
21 21 */
22 22 @Component
23 23 @Order(20)
24   -public class LineVersionsData implements CommandLineRunner {
  24 +public class LineVersionsData extends Thread {
25 25  
26 26 static Logger logger = LoggerFactory.getLogger(LineVersionsData.class);
27 27  
... ... @@ -33,9 +33,7 @@ public class LineVersionsData implements CommandLineRunner {
33 33 StationRouteService stationRouteService;
34 34  
35 35 @Override
36   - public void run(String... arg0) throws Exception {
37   -
38   -
  36 + public void run() {
39 37 try {
40 38 List<LineVersions> list = lineVersionsService.lineUpdate();
41 39 for (LineVersions lineVersions : list) {
... ... @@ -44,10 +42,11 @@ public class LineVersionsData implements CommandLineRunner {
44 42 Map<String, Object> map = new HashMap<>();
45 43 map.put("lineId", lineId);
46 44 stationRouteService.usingSingle(map);
  45 + logger.info("线路版本更新成功!");
47 46 }
48 47 } catch (Exception e) {
49   - // TODO Auto-generated catch block
50 48 e.printStackTrace();
  49 + logger.error("线路版本更新出现异常!", e);
51 50 }
52 51 }
53 52 }
... ...
src/main/java/com/bsth/data/ThreadMonotor.java
1 1 package com.bsth.data;
2 2  
3   -import com.bsth.data.gpsdata.arrival.GpsRealAnalyse;
4   -import com.bsth.data.gpsdata.thread.GpsDataLoaderThread;
5   -import com.bsth.data.msg_queue.DirectivePushQueue;
6   -import com.bsth.data.msg_queue.WebSocketPushQueue;
7 3 import org.slf4j.Logger;
8 4 import org.slf4j.LoggerFactory;
9 5 import org.springframework.stereotype.Component;
... ... @@ -20,26 +16,26 @@ public class ThreadMonotor extends Thread{
20 16 public void run() {
21 17  
22 18 //线调GPS分析主线程
23   - if(GpsRealAnalyse.isBlock()){
  19 + /*if(GpsRealAnalyse.isBlock()){
24 20 log.warn("GpsRealAnalyse isBlock true !!!!");
25 21 GpsRealAnalyse.shutdown();
26   - }
  22 + }*/
27 23  
28   - if(GpsRealAnalyse.isIdle()){
  24 + /*if(GpsRealAnalyse.isIdle()){
29 25 //切换到备用的网关实时GPS对照数据
30 26 GpsDataLoaderThread.setFlag(-1);
31   - }
  27 + }*/
32 28  
33 29 //webSocket 消息推送队列
34   - if(WebSocketPushQueue.isIdle()){
  30 + /*if(WebSocketPushQueue.isIdle()){
35 31 log.warn("WebSocketPushQueue isIdle true !!!!");
36 32 WebSocketPushQueue.start();
37   - }
  33 + }*/
38 34  
39 35 //网关指令推送队列(系统自动发送的)
40   - if(DirectivePushQueue.isIdle()){
  36 + /*if(DirectivePushQueue.isIdle()){
41 37 log.warn("DirectivePushQueue isIdle true !!!!");
42 38 DirectivePushQueue.start();
43   - }
  39 + }*/
44 40 }
45 41 }
46 42 \ No newline at end of file
... ...
src/main/java/com/bsth/data/directive/DayOfDirectives.java
... ... @@ -152,13 +152,14 @@ public class DayOfDirectives {
152 152  
153 153 public void clear(String device){
154 154 int c60 = 0, c64 = 0;
155   - //找到该设备的60数据
  155 +
156 156 Collection<D60> d60s = d60Map.values();
157 157 List<D60> rem60List = new ArrayList<>();
158 158 for(D60 d60 : d60s){
159 159 if(device.equals(d60.getDeviceId()))
160 160 rem60List.add(d60);
161 161 }
  162 +
162 163 //清除60数据
163 164 for(D60 d60 : rem60List){
164 165 if(d60.getReply47() == null)
... ... @@ -166,6 +167,8 @@ public class DayOfDirectives {
166 167 if(null != d60Map.remove(d60.getMsgId()))
167 168 c60 ++;
168 169 }
  170 +
  171 + rem60List.clear();
169 172 if(c60 > 0)
170 173 logger.info("清除60数据 ," + c60);
171 174  
... ... @@ -186,6 +189,7 @@ public class DayOfDirectives {
186 189 c64 ++;
187 190 }
188 191  
  192 + rem64List.clear();
189 193 if(c64 > 0)
190 194 logger.info("清除64数据 ," + c64);
191 195 }
... ...
src/main/java/com/bsth/data/forecast/ForecastRealServer.java
... ... @@ -4,8 +4,8 @@ import com.bsth.data.forecast.entity.ForecastResult;
4 4 import com.bsth.data.forecast.entity.ForecastResult.ForecastResultItem;
5 5 import com.bsth.data.forecast.entity.SimpleRoute;
6 6 import com.bsth.data.forecast.entity.SimpleRoute.TimeRange;
7   -import com.bsth.data.gpsdata.GpsEntity;
8   -import com.bsth.data.gpsdata.GpsRealData;
  7 +import com.bsth.data.gpsdata_v2.GpsRealData;
  8 +import com.bsth.data.gpsdata_v2.entity.GpsEntity;
9 9 import com.bsth.data.schedule.DayOfSchedule;
10 10 import com.bsth.entity.realcontrol.ScheduleRealInfo;
11 11 import com.google.common.collect.ArrayListMultimap;
... ...
src/main/java/com/bsth/data/gpsdata/SignalStateData.java deleted 100644 → 0
1   -package com.bsth.data.gpsdata;
2   -
3   -import com.bsth.data.gpsdata.arrival.entity.SignalState;
4   -import com.bsth.websocket.handler.SendUtils;
5   -import com.google.common.base.Splitter;
6   -import com.google.common.collect.ArrayListMultimap;
7   -import org.springframework.beans.factory.annotation.Autowired;
8   -import org.springframework.stereotype.Component;
9   -
10   -import java.util.ArrayList;
11   -import java.util.List;
12   -
13   -/**
14   - * 信号状态数据
15   - * Created by panzhao on 2016/12/30.
16   - */
17   -@Component
18   -public class SignalStateData {
19   -
20   - @Autowired
21   - SendUtils sendUtils;
22   -
23   - private static ArrayListMultimap<String, SignalState> listMultimap = ArrayListMultimap.create();
24   -
25   - public void put(SignalState state){
26   - //listMultimap.put(state.getLineCode(), state);
27   - //推送到客户端
28   - //sendUtils.sendSignalState(state);
29   - }
30   -
31   - public List<SignalState> get(String idx){
32   - List<SignalState> rs = new ArrayList<>();
33   - List<String> ids = Splitter.on(",").splitToList(idx);
34   -
35   - for(String lineCode : ids){
36   - rs.addAll(listMultimap.get(lineCode));
37   - }
38   - return rs;
39   - }
40   -}
src/main/java/com/bsth/data/gpsdata/arrival/GeoCacheData.java deleted 100644 → 0
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.entity.TimedEnableStationRoute;
6   -import com.bsth.data.gpsdata.arrival.precondition.entity.PreconditionGeo;
7   -import com.bsth.data.gpsdata.arrival.utils.CircleQueue;
8   -import com.bsth.data.gpsdata.arrival.utils.StationRouteComp;
9   -import com.google.common.base.Splitter;
10   -import com.google.common.collect.ArrayListMultimap;
11   -import com.vividsolutions.jts.geom.Coordinate;
12   -import com.vividsolutions.jts.geom.GeometryFactory;
13   -import com.vividsolutions.jts.geom.LineString;
14   -import com.vividsolutions.jts.geom.Polygon;
15   -import org.apache.commons.lang3.StringUtils;
16   -import org.slf4j.Logger;
17   -import org.slf4j.LoggerFactory;
18   -import org.springframework.beans.factory.annotation.Autowired;
19   -import org.springframework.jdbc.core.BeanPropertyRowMapper;
20   -import org.springframework.jdbc.core.JdbcTemplate;
21   -import org.springframework.jdbc.core.RowMapper;
22   -import org.springframework.stereotype.Component;
23   -
24   -import java.sql.ResultSet;
25   -import java.sql.SQLException;
26   -import java.util.*;
27   -
28   -/**
29   - * Created by panzhao on 2016/12/23.
30   - */
31   -@Component
32   -public class GeoCacheData {
33   -
34   - static Logger logger = LoggerFactory.getLogger(GeoCacheData.class);
35   -
36   - //每辆车缓存最后500条gps
37   - private static final int CACHE_SIZE = 500;
38   - private static Map<String, CircleQueue<GpsEntity>> gpsCacheMap = new HashMap<>();
39   -
40   - //线路路段走向
41   - private static ArrayListMultimap<String, LineString> sectionCacheMap;
42   -
43   - //路段编码和名称对照
44   - private static Map<String, String> sectionCode2Name;
45   -
46   - //线路站点路由
47   - private static ArrayListMultimap<String, StationRoute> stationCacheMap;
48   - //线路前置进站围栏
49   - public static ArrayListMultimap<String, PreconditionGeo> premiseGeoMap;
50   -
51   - //线路_上下行_站点编码 ——> 站点
52   - private static Map<String, StationRoute> routeCodeMap;
53   -
54   - //停车场
55   - public static Map<String, Polygon> tccMap;
56   - //停车场
57   - public static Map<String, com.bsth.util.Geo.Polygon> tccMap2;
58   -
59   - //线路限速信息
60   - private static Map<String, Double> speedLimitMap;
61   -
62   - //需要定时刷新的站点路由
63   - public static Map<String, TimedEnableStationRoute> tesMap = new HashMap<>();
64   -
65   - @Autowired
66   - JdbcTemplate jdbcTemplate;
67   -
68   - public static CircleQueue<GpsEntity> getGps(String nbbm) {
69   - return gpsCacheMap.get(nbbm);
70   - }
71   -
72   - public static void putGps(GpsEntity gps) {
73   - CircleQueue<GpsEntity> queue = gpsCacheMap.get(gps.getNbbm());
74   - if (queue == null) {
75   - queue = new CircleQueue<>(CACHE_SIZE);
76   - gpsCacheMap.put(gps.getNbbm(), queue);
77   - }
78   - queue.add(gps);
79   - }
80   -
81   - public static void clear(String nbbm) {
82   - try {
83   - CircleQueue<GpsEntity> queue = gpsCacheMap.get(nbbm);
84   - if (queue != null)
85   - queue.clear();
86   - } catch (Exception e) {
87   - logger.error("", e);
88   - }
89   - }
90   -
91   - public static Map<String, String> sectionCode2NameMap(){
92   - return sectionCode2Name;
93   - }
94   -
95   - public static StationRoute getRouteCode(GpsEntity gps) {
96   - return routeCodeMap.get(gps.getLineId() + "_" + gps.getUpDown() + "_" + gps.getStopNo());
97   - }
98   -
99   - public static List<StationRoute> getStationRoute(String lineCode, int directions) {
100   - return stationCacheMap.get(lineCode + "_" + directions);
101   - }
102   -
103   - public static StationRoute getStation(String lineCode, int directions, String code) {
104   - List<StationRoute> list = getStationRoute(lineCode, directions);
105   -
106   - for (StationRoute sr : list) {
107   - if (sr.getCode().equals(code)) {
108   - return sr;
109   - }
110   - }
111   - return null;
112   - }
113   -
114   - public static Double speedLimit(String lineCode){
115   - return speedLimitMap.get(lineCode);
116   - }
117   -
118   - public static List<LineString> getLineStringList(GpsEntity gps){
119   - return sectionCacheMap.get(gps.getLineId() + "_" + gps.getUpDown());
120   - }
121   -
122   - public static List<StationRoute> midwayStation(String lineCode, int directions, String sCode, String eCode) {
123   - List<StationRoute> list = getStationRoute(lineCode, directions), rs = new ArrayList<>();
124   -
125   - boolean flag = false;
126   - for (StationRoute sr : list) {
127   - if (flag)
128   - rs.add(sr);
129   - if (sr.getCode().equals(sCode))
130   - flag = true;
131   - else if (sr.getCode().equals(eCode))
132   - break;
133   - }
134   - return rs;
135   - }
136   -
137   - public static Polygon getTccPolygon(String code) {
138   - return tccMap.get(code);
139   - }
140   -
141   - GeometryFactory geometryFactory = new GeometryFactory();
142   - public void loadData() {
143   - loadStationRoutesData();
144   - loadTccMapData();
145   - loadSpeedLimit();
146   -
147   - //加载路段信息
148   - loadRoadsData();
149   -
150   - //加载前置进站围栏
151   - loadPremiseGeoData();
152   - }
153   -
154   - private void loadPremiseGeoData() {
155   - ArrayListMultimap<String, PreconditionGeo> premiseGeoMapCopy = ArrayListMultimap.create();
156   -
157   - String sql = "select * from bsth_f_geo_premise";
158   - List<PreconditionGeo> list = jdbcTemplate.query(sql, BeanPropertyRowMapper.newInstance(PreconditionGeo.class));
159   -
160   - List<String> coordList;
161   - String[] cs;
162   - com.bsth.util.Geo.Point point;
163   - List<com.bsth.util.Geo.Point> ps;
164   - StationRoute sr;
165   - for(PreconditionGeo p : list){
166   - try{
167   - sr = routeCodeMap.get(p.getLineCode()+"_"+p.getUpDown()+"_"+p.getStationCode());
168   - p.setOrder(sr.getRouteSort());
169   - //polygon
170   - ps = new ArrayList<>();
171   - coordList = Splitter.on(",").trimResults().splitToList(p.getCoords());
172   - for(String c : coordList){
173   - cs = c.split(" ");
174   - point = new com.bsth.util.Geo.Point(Double.parseDouble(cs[0]), Double.parseDouble(cs[1]));
175   - ps.add(point);
176   - }
177   -
178   - p.setPolygon(new com.bsth.util.Geo.Polygon(ps));
179   -
180   - sr.setPremise(true);
181   - //按线路,走向分组
182   - premiseGeoMapCopy.put(p.getLineCode()+"_"+p.getUpDown(), p);
183   - }catch (Exception e){
184   - logger.error("", e);
185   - }
186   - }
187   -
188   - //排序
189   - Set<String> ks = premiseGeoMapCopy.keySet();
190   - PreconditionGeoComp comp = new PreconditionGeoComp();
191   - for(String k : ks){
192   - Collections.sort(premiseGeoMapCopy.get(k), comp);
193   - }
194   -
195   - premiseGeoMap = premiseGeoMapCopy;
196   - }
197   -
198   - private static class PreconditionGeoComp implements Comparator<PreconditionGeo>{
199   -
200   - @Override
201   - public int compare(PreconditionGeo p1, PreconditionGeo p2) {
202   - return p1.getOrder() - p2.getOrder();
203   - }
204   - }
205   -
206   - private void loadRoadsData() {
207   - //加载线路下路段空间数据
208   - String sql = "select r.LINE_CODE,r.SECTION_CODE,r.SECTIONROUTE_CODE,s.SECTION_NAME,ST_AsText(s.GSECTION_VECTOR) as GSECTION_VECTOR, r.DIRECTIONS, s.CROSES_ROAD from bsth_c_sectionroute r INNER JOIN bsth_c_section s on r.section=s.id where r.destroy=0 and GSECTION_VECTOR is not null order by line_code,directions,sectionroute_code";
209   - List<Map<String, Object>> secList = jdbcTemplate.queryForList(sql);
210   -
211   - String polygonStr, key;
212   - String[] coords;
213   - int i, len;
214   - ArrayListMultimap<String, LineString> sectionCacheTempMap = ArrayListMultimap.create();
215   - Coordinate[] cds;
216   - String[] temps1, temps2;
217   - for (Map<String, Object> tMap : secList) {
218   - //空间数据映射
219   - polygonStr = tMap.get("GSECTION_VECTOR").toString();
220   - key = tMap.get("LINE_CODE") + "_" + tMap.get("DIRECTIONS");
221   -
222   - coords = polygonStr.substring(11, polygonStr.length() - 1).split(",");
223   - len = coords.length - 1;
224   - //每2个点连一条线
225   - for(i = 0; i < len; i ++){
226   - temps1 = coords[i].split(" ");
227   - temps2 = coords[i + 1].split(" ");
228   -
229   - cds = new Coordinate[2];
230   - cds[0] = new Coordinate(Float.parseFloat(temps1[1]), Float.parseFloat(temps1[0]));
231   - cds[1] = new Coordinate(Float.parseFloat(temps2[1]), Float.parseFloat(temps2[0]));
232   -
233   - sectionCacheTempMap.put(key, geometryFactory.createLineString(cds));
234   - }
235   - }
236   -
237   - if(sectionCacheTempMap.size() > 0)
238   - sectionCacheMap = sectionCacheTempMap;
239   -
240   - Map<String, String> sectionCode2NameTemp = new HashMap<>();
241   -
242   - //加载全量路段编码和名称对照
243   - sql = "select SECTION_CODE,SECTION_NAME,CROSES_ROAD from bsth_c_section";
244   - secList = jdbcTemplate.queryForList(sql);
245   - String name = null, code;
246   - for (Map<String, Object> tMap : secList) {
247   - if(tMap.get("CROSES_ROAD") != null && StringUtils.isNotEmpty(tMap.get("CROSES_ROAD").toString()))
248   - name = tMap.get("CROSES_ROAD").toString();
249   - else if(tMap.get("SECTION_NAME") != null && StringUtils.isNotEmpty(tMap.get("SECTION_NAME").toString()))
250   - name = tMap.get("SECTION_NAME").toString();
251   -
252   - code = tMap.get("SECTION_CODE").toString();
253   - sectionCode2NameTemp.put(code, name);
254   - }
255   - if(sectionCode2NameTemp.size() > 0)
256   - sectionCode2Name = sectionCode2NameTemp;
257   - }
258   -
259   - private void loadTccMapData(){
260   - //加载停车场数据
261   - String sql = "select PARK_CODE, ST_AsText(G_PARK_POINT) as G_PARK_POINT from bsth_c_car_park where park_code is not null and b_park_point is not null";
262   - List<Map<String, Object>> tccList = jdbcTemplate.queryForList(sql);
263   - Map<String, Polygon> tccTempMap = new HashMap<>();
264   -
265   - Polygon polygon;
266   - for (Map<String, Object> tMap : tccList) {
267   -
268   - try {
269   - polygon = geometryFactory.createPolygon(parsePolygon(tMap.get("G_PARK_POINT").toString()));
270   - tccTempMap.put(tMap.get("PARK_CODE").toString()
271   - , polygon);
272   - } catch (Exception e) {
273   - logger.error("停车场:" + tMap.get("PARK_CODE"), e);
274   - }
275   - }
276   - if (tccTempMap.size() > 0){
277   - tccMap = tccTempMap;
278   - tccMap2 = convertPolygonMap(tccMap);
279   - }
280   - }
281   -
282   - private Map<String, com.bsth.util.Geo.Polygon> convertPolygonMap(Map<String, Polygon> tccMap) {
283   - Map<String, com.bsth.util.Geo.Polygon> rsMap = new HashMap<>();
284   - Set<String> ks = tccMap.keySet();
285   - for(String k : ks){
286   - rsMap.put(k, convertPolygon(tccMap.get(k)));
287   - }
288   - return rsMap;
289   - }
290   -
291   - public static com.bsth.util.Geo.Polygon convertPolygon(Polygon polygon) {
292   - List<com.bsth.util.Geo.Point> ps = new ArrayList<>();
293   - com.bsth.util.Geo.Point p;
294   -
295   - Coordinate[] cs = polygon.getCoordinates();
296   - for(int i = 0; i < cs.length;i ++){
297   - p = new com.bsth.util.Geo.Point(cs[i].y, cs[i].x);
298   - ps.add(p);
299   - }
300   - return new com.bsth.util.Geo.Polygon(ps);
301   - }
302   -
303   - private void loadStationRoutesData(){
304   - //加载站点路由
305   - 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";
306   - List<StationRoute> routeList = jdbcTemplate.query(sql, new RowMapper<StationRoute>() {
307   - @Override
308   - public StationRoute mapRow(ResultSet rs, int rowNum) throws SQLException {
309   - StationRoute sRoute = new StationRoute();
310   - sRoute.setCode(rs.getString("STATION_CODE"));
311   - sRoute.setLineCode(rs.getString("LINE_CODE"));
312   - sRoute.setDirections(rs.getInt("DIRECTIONS"));
313   - sRoute.setPoint(geometryFactory.createPoint(new Coordinate(rs.getFloat("G_LATY"), rs.getFloat("G_LONX"))));
314   - sRoute.setRadius(rs.getFloat("RADIUS"));
315   - sRoute.setRouteSort(rs.getInt("STATION_ROUTE_CODE"));
316   - sRoute.setMark(rs.getString("STATION_MARK"));
317   - sRoute.setName(rs.getString("STATION_NAME"));
318   -
319   - String shapesType = rs.getString("SHAPES_TYPE");
320   - //多边形电子围栏
321   - if (StringUtils.isNotEmpty(shapesType) && shapesType.equals("d")) {
322   - sRoute.setPolygon(geometryFactory.createPolygon(parsePolygon(rs.getString("G_POLYGON_GRID"))));
323   - }
324   - return sRoute;
325   - }
326   - });
327   - //按线路和走向分组
328   - if (routeList.size() > 0) {
329   - ArrayListMultimap<String, StationRoute> tempMap = ArrayListMultimap.create();
330   - Map<String, StationRoute> codeMap = new HashMap<>(routeList.size());
331   - for (StationRoute sr : routeList) {
332   - tempMap.put(sr.getLineCode() + "_" + sr.getDirections(), sr);
333   - //站点编码 ——> 和路由顺序对照
334   - codeMap.put(sr.getLineCode() + "_" + sr.getDirections() + "_" + sr.getCode(), sr);
335   - }
336   -
337   - StationRouteComp srCom = new StationRouteComp();
338   - //连接路由
339   - Set<String> set = tempMap.keySet();
340   - for (String key : set) {
341   - Collections.sort(tempMap.get(key), srCom);
342   - connectStationRoute(tempMap.get(key));
343   - }
344   -
345   - //定时启用的站点走向
346   - if(tesMap.size() > 0){
347   - List<String> rems = new ArrayList<>();
348   - long t = System.currentTimeMillis();
349   - for(TimedEnableStationRoute tes : tesMap.values()){
350   - if(tes.getEnableTime() > t){
351   - logger.info("锁住站点路由," + tes.getLineCode());
352   - tempMap.replaceValues(tes.getLineCode() + "_0", stationCacheMap.get(tes.getLineCode() + "_0"));
353   - tempMap.replaceValues(tes.getLineCode() + "_1", stationCacheMap.get(tes.getLineCode() + "_1"));
354   - }
355   - else
356   - rems.add(tes.getLineCode());
357   - }
358   -
359   - //remove
360   - if(rems.size() > 0){
361   - for(String lineCode : rems){
362   - logger.info("启用路由," + lineCode);
363   - tesMap.remove(lineCode);
364   - }
365   - }
366   - }
367   - stationCacheMap = tempMap;
368   - routeCodeMap = codeMap;
369   - }
370   - }
371   -
372   - private void loadSpeedLimit(){
373   - //加载线路限速信息
374   - String sql = "select l.LINE_CODE,i.SPEEDING from bsth_c_line_information i left join bsth_c_line l on i.line=l.id where i.speed_limit is not null";
375   - List<Map<String, Object>> speedMap = jdbcTemplate.queryForList(sql);
376   - Map<String, Double> speedTempMap = new HashMap<>();
377   - for (Map<String, Object> tMap : speedMap) {
378   - try {
379   - speedTempMap.put(tMap.get("LINE_CODE").toString(), Double.parseDouble(tMap.get("SPEEDING").toString()));
380   - } catch (NumberFormatException e) {
381   - logger.error("speeding is null...");
382   - }
383   - }
384   - speedLimitMap = speedTempMap;
385   - }
386   -
387   - private void connectStationRoute(List<StationRoute> list) {
388   - int size = list.size();
389   - StationRoute sr = null;
390   - for (int i = 0; i < size; i++) {
391   - sr = list.get(i);
392   - //上一个
393   - if (i > 0)
394   - sr.setPrve(list.get(i - 1));
395   - //下一个
396   - if (i < size - 1)
397   - sr.setNext(list.get(i + 1));
398   - }
399   - }
400   -
401   - public Coordinate[] parsePolygon(String polygonStr) {
402   - String[] coords = polygonStr.substring(9, polygonStr.length() - 2).split(","), temps;
403   -
404   - Coordinate[] cds = new Coordinate[coords.length];
405   - int len = coords.length;
406   - for (int i = 0; i < len; i++) {
407   - temps = coords[i].split(" ");
408   - cds[i] = new Coordinate(Float.parseFloat(temps[1]), Float.parseFloat(temps[0]));
409   - }
410   - return cds;
411   - }
412   -
413   - /**
414   - * 是不是终点站
415   - *
416   - * @param lineId
417   - * @param upDown
418   - * @param stationCode
419   - * @return
420   - */
421   - public static boolean isEndStation(String lineId, Byte upDown, String stationCode) {
422   - StationRoute station = routeCodeMap.get(lineId + "_" + upDown + "_" + stationCode);
423   - return station != null && station.getMark().equals("E");
424   - }
425   -}
426 0 \ No newline at end of file
src/main/java/com/bsth/data/gpsdata/arrival/SignalHandle.java deleted 100644 → 0
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   -import org.joda.time.format.DateTimeFormat;
9   -import org.joda.time.format.DateTimeFormatter;
10   -import org.slf4j.Logger;
11   -import org.slf4j.LoggerFactory;
12   -
13   -import java.util.List;
14   -
15   -/**
16   - * Created by panzhao on 2016/12/27.
17   - */
18   -public abstract class SignalHandle {
19   -
20   - public abstract boolean handle(GpsEntity gps, CircleQueue<GpsEntity> prevs);
21   -
22   - protected boolean isNotEmpty(CircleQueue<GpsEntity> prevs) {
23   - return prevs != null && prevs.size() > 0 && prevs.getTail() != null;
24   - }
25   -
26   -/* protected boolean isDriftSignal(GpsEntity gps) {
27   - return gps.getLat() == 0 || gps.getLon() == 0;
28   - }*/
29   -
30   - /**
31   - * gps掉线
32   - * @param gps
33   - * @return
34   - */
35   - protected boolean isGpsOffline(GpsEntity gps){
36   - return gps.getLat() == 0 || gps.getLon() == 0;
37   - }
38   -
39   - protected boolean isOffline(GpsEntity gps){
40   - return gps.getAbnormalStatus() != null && gps.getAbnormalStatus().equals("offline");
41   - }
42   - /**
43   - * 是不是异常信号
44   - *
45   - * @param gps
46   - * @return protected boolean isAbnormal(GpsEntity gps) {
47   - return gps.getLat() == 0 || gps.getLon() == 0;
48   - }*/
49   -
50   - /**
51   - * 连续异常信号个数统计
52   - *
53   - * @param
54   - * @return protected int abnormalCount(CircleQueue<GpsEntity> prevs) {
55   - * int count = 0;
56   - * <p>
57   - * if (!isNotEmpty(prevs))
58   - * return count;
59   - * <p>
60   - * GpsEntity[] array = (GpsEntity[]) prevs.getQueue();
61   - * GpsEntity gps;
62   - * for (int i = array.length - 1; i > 0; i--) {
63   - * gps = array[i];
64   - * <p>
65   - * if (isAbnormal(gps))
66   - * count++;
67   - * else
68   - * break;
69   - * }
70   - * <p>
71   - * return count;
72   - * }
73   - */
74   -
75   - Logger logger = LoggerFactory.getLogger(this.getClass());
76   - private static DateTimeFormatter fmtHHmm = DateTimeFormat.forPattern("HH:mm");
77   - protected void transformUpdown(GpsEntity gps, ScheduleRealInfo sch) {
78   - byte updown = Byte.parseByte(sch.getXlDir());
79   - //gps 切换走向
80   - gps.setUpDown(updown);
81   - gps.setPremiseCode(null);
82   -
83   - List<StationRoute> srs = GeoCacheData.getStationRoute(sch.getXlBm(), updown);
84   - StationRoute station = GeoUtils.gpsInStation(gps, srs);
85   - if (station != null) {
86   - gps.setStopNo(station.getCode());
87   - }
88   -
89   - logger.info(gps.getTimestamp() + " -" + fmtHHmm.print(gps.getTimestamp()) + " 车辆 :" + gps.getNbbm() + " 切换到走向 : " + updown);
90   - }
91   -
92   - /**
93   - * 是否是从异常状态恢复的第一个信号
94   - *
95   - * @param gps
96   - * @param prevs
97   - * @return
98   - */
99   - protected boolean abnormalRecovery(GpsEntity gps, CircleQueue<GpsEntity> prevs) {
100   - if (prevs == null || prevs.size() == 0)
101   - return false;
102   -
103   - GpsEntity prev = prevs.getTail();
104   - //从异常状态恢复
105   - if (isGpsOffline(prev)
106   - && !isGpsOffline(gps)) {
107   - return true;
108   - }
109   -
110   - return false;
111   - }
112   -}
113 0 \ No newline at end of file
src/main/java/com/bsth/data/gpsdata/arrival/entity/ArrivalInfo.java deleted 100644 → 0
1   -package com.bsth.data.gpsdata.arrival.entity;
2   -
3   -/**
4   - * 到离站信息
5   - * Created by panzhao on 2017/2/20.
6   - */
7   -public class ArrivalInfo {
8   -
9   - private String lineCode;
10   -
11   - private String deviceId;
12   -
13   - /** 时间戳 */
14   - private Long ts;
15   -
16   - private String stop;
17   -
18   - private Integer upDown;
19   -
20   - private int inOut;
21   -
22   -
23   -}
src/main/java/com/bsth/data/gpsdata/arrival/entity/RouteReverse.java deleted 100644 → 0
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   -}
94 0 \ No newline at end of file
src/main/java/com/bsth/data/gpsdata/arrival/entity/SignalAbnormal.java deleted 100644 → 0
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 deleted 100644 → 0
1   -package com.bsth.data.gpsdata.arrival.entity;
2   -
3   -import com.bsth.data.BasicData;
4   -import com.bsth.entity.realcontrol.ScheduleRealInfo;
5   -import org.joda.time.format.DateTimeFormat;
6   -import org.joda.time.format.DateTimeFormatter;
7   -
8   -/**
9   - * 信号状态
10   - * Created by panzhao on 2016/12/30.
11   - */
12   -public class SignalState {
13   -
14   - private String type;
15   -
16   - private Long st;
17   -
18   - //private Long checkTime;
19   -
20   - private Long schId;
21   -
22   - private String lineCode;
23   -
24   - private String text;
25   -
26   - private RouteReverse reverse;
27   -
28   - private SignalAbnormal signalAbnormal;
29   -
30   - private static DateTimeFormatter fmtHHmm = DateTimeFormat.forPattern("HH:mm");
31   -
32   - /**
33   - * 记录区间调头
34   - *
35   - * @param sch
36   - * @param reverse
37   - * @return
38   - */
39   - public static SignalState reverseSignalSTate(ScheduleRealInfo sch, RouteReverse reverse) {
40   - /*if(reverse.isVague())
41   - return null;*/
42   -
43   - SignalState state = new SignalState();
44   - state.setSchId(sch.getId());
45   - state.setType("route_reverse");
46   - //state.setCheckTime(System.currentTimeMillis());
47   -
48   - String stationName = BasicData.stationCode2NameMap.get(sch.getXlBm() + "_" + sch.getXlDir() + "_" + reverse.getTurned());
49   - state.setText(fmtHHmm.print(reverse.getZt()) + " 从 " + stationName + " 站掉头");
50   - state.setSt(sch.getFcsjActualTime());
51   - state.setLineCode(sch.getXlBm());
52   - state.setReverse(reverse);
53   - return state;
54   - }
55   -
56   - public static SignalState abnormalSignalSTate(ScheduleRealInfo sch, SignalAbnormal signalAbnormal) {
57   - SignalState state = new SignalState();
58   - state.setSchId(sch.getId());
59   - state.setType("abnormal_signal");
60   - //state.setCheckTime(signalAbnormal.getCt());
61   - state.setLineCode(sch.getXlBm());
62   -
63   - String text = (fmtHHmm.print(signalAbnormal.getSt()) + " ~ " + fmtHHmm.print(signalAbnormal.getEt()));
64   - String abnormType = signalAbnormal.getAbnormalType();
65   - if (abnormType.equals("drift"))
66   - text += "(GPS无效)";
67   - else if (abnormType.equals("reconnection"))
68   - text += "(信号丢失)";
69   -
70   - state.setText(text);
71   - state.setSignalAbnormal(signalAbnormal);
72   - return state;
73   - }
74   -
75   - public String getType() {
76   - return type;
77   - }
78   -
79   - public void setType(String type) {
80   - this.type = type;
81   - }
82   -
83   - public long getSchId() {
84   - return schId;
85   - }
86   -
87   - public void setSchId(long schId) {
88   - this.schId = schId;
89   - }
90   -
91   - public String getLineCode() {
92   - return lineCode;
93   - }
94   -
95   - public void setLineCode(String lineCode) {
96   - this.lineCode = lineCode;
97   - }
98   -
99   - public Long getSt() {
100   - return st;
101   - }
102   -
103   - public void setSt(Long st) {
104   - this.st = st;
105   - }
106   -
107   - public String getText() {
108   - return text;
109   - }
110   -
111   - public void setText(String text) {
112   - this.text = text;
113   - }
114   -
115   - public RouteReverse getReverse() {
116   - return reverse;
117   - }
118   -
119   - public void setReverse(RouteReverse reverse) {
120   - this.reverse = reverse;
121   - }
122   -
123   - public SignalAbnormal getSignalAbnormal() {
124   - return signalAbnormal;
125   - }
126   -
127   - public void setSignalAbnormal(SignalAbnormal signalAbnormal) {
128   - this.signalAbnormal = signalAbnormal;
129   - }
130   -}
src/main/java/com/bsth/data/gpsdata/arrival/entity/TimedEnableStationRoute.java deleted 100644 → 0
1   -package com.bsth.data.gpsdata.arrival.entity;
2   -
3   -/**
4   - * 定时启用站点路由
5   - * Created by panzhao on 2017/8/28.
6   - */
7   -public class TimedEnableStationRoute {
8   -
9   - private String lineCode;
10   -
11   - private Long enableTime;
12   -
13   - public String getLineCode() {
14   - return lineCode;
15   - }
16   -
17   - public void setLineCode(String lineCode) {
18   - this.lineCode = lineCode;
19   - }
20   -
21   - public Long getEnableTime() {
22   - return enableTime;
23   - }
24   -
25   - public void setEnableTime(Long enableTime) {
26   - this.enableTime = enableTime;
27   - }
28   -}
src/main/java/com/bsth/data/gpsdata/arrival/handlers/CorrectSignalHandle.java deleted 100644 → 0
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.gpsdata.status_manager.GpsStatusManager;
7   -import com.bsth.data.schedule.DayOfSchedule;
8   -import com.bsth.entity.realcontrol.ScheduleRealInfo;
9   -import com.bsth.service.directive.DirectiveService;
10   -import org.slf4j.Logger;
11   -import org.slf4j.LoggerFactory;
12   -import org.springframework.beans.factory.annotation.Autowired;
13   -import org.springframework.stereotype.Component;
14   -
15   -/**
16   - * 信号状态纠正
17   - * Created by panzhao on 2016/12/27.
18   - */
19   -@Component
20   -public class CorrectSignalHandle extends SignalHandle {
21   -
22   - @Autowired
23   - DayOfSchedule dayOfSchedule;
24   - @Autowired
25   - DirectiveService directiveService;
26   -
27   - @Autowired
28   - GpsStatusManager gpsStatusManager;
29   -
30   - Logger logger = LoggerFactory.getLogger(this.getClass());
31   -
32   - @Override
33   - public boolean handle(GpsEntity gps, CircleQueue<GpsEntity> prevs) {
34   - ScheduleRealInfo task = dayOfSchedule.executeCurr(gps.getNbbm());
35   - if(task == null)
36   - return false;
37   - //ScheduleRealInfo sch;
38   -
39   - //子任务
40   - /*if(task.getClass().isAssignableFrom(ChildTaskPlan.class)){
41   - ChildTaskPlan childTask = (ChildTaskPlan) task;
42   - sch = childTask.getSchedule();
43   - }
44   - else
45   - sch = (ScheduleRealInfo) task;*/
46   -
47   - byte updown = Byte.parseByte(task.getXlDir());
48   - //走向
49   - if(gps.getUpDown() != updown){
50   - gps.setUpDown(updown);
51   - //gps.setState(0);
52   - }
53   -
54   - //(转发的数据不管)
55   - if(gps.getSource() != 0){
56   - //gps=非营运 或走向不对 && 班次=非空驶 ;切换到营运状态
57   - if((!gps.isService() || gps.getUpDown() != updown) &&
58   - !dayOfSchedule.emptyService(task)){
59   - gpsStatusManager.changeServiceState(gps.getNbbm(), updown, 0, "同步@系统");
60   - }
61   -
62   - //需要切换线路
63   - if(!task.getXlBm().equals(gps.getLineId())){
64   - gpsStatusManager.changeLine(gps.getNbbm(), task.getXlBm(), "同步@系统");
65   - }
66   - }
67   -
68   - return true;
69   - }
70   -}
71 0 \ No newline at end of file
src/main/java/com/bsth/data/gpsdata/arrival/handlers/InOutStationSignalHandle.java deleted 100644 → 0
1   -package com.bsth.data.gpsdata.arrival.handlers;
2   -
3   -import com.bsth.data.LineConfigData;
4   -import com.bsth.data.gpsdata.GpsEntity;
5   -import com.bsth.data.gpsdata.arrival.GeoCacheData;
6   -import com.bsth.data.gpsdata.arrival.SignalHandle;
7   -import com.bsth.data.gpsdata.arrival.entity.StationRoute;
8   -import com.bsth.data.gpsdata.arrival.utils.CircleQueue;
9   -import com.bsth.data.gpsdata.arrival.utils.ScheduleSignalState;
10   -import com.bsth.data.gpsdata.arrival.utils.SignalSchPlanMatcher;
11   -import com.bsth.data.gpsdata.status_manager.GpsStatusManager;
12   -import com.bsth.data.msg_queue.DirectivePushQueue;
13   -import com.bsth.data.schedule.DayOfSchedule;
14   -import com.bsth.data.schedule.ScheduleComparator;
15   -import com.bsth.data.schedule.late_adjust.LateAdjustHandle;
16   -import com.bsth.entity.realcontrol.LineConfig;
17   -import com.bsth.entity.realcontrol.ScheduleRealInfo;
18   -import com.bsth.websocket.handler.SendUtils;
19   -import org.apache.commons.lang3.StringUtils;
20   -import org.slf4j.Logger;
21   -import org.slf4j.LoggerFactory;
22   -import org.springframework.beans.factory.annotation.Autowired;
23   -import org.springframework.stereotype.Component;
24   -
25   -import java.util.Collections;
26   -import java.util.List;
27   -
28   -/**
29   - * 进出站动作处理
30   - * Created by panzhao on 2016/12/27.
31   - */
32   -@Component
33   -public class InOutStationSignalHandle extends SignalHandle{
34   -
35   - Logger logger = LoggerFactory.getLogger(this.getClass());
36   -
37   - @Autowired
38   - DayOfSchedule dayOfSchedule;
39   -
40   - @Autowired
41   - LineConfigData lineConfigData;
42   -
43   - @Autowired
44   - SendUtils sendUtils;
45   -
46   - @Autowired
47   - ScheduleSignalState scheduleSignalState;
48   -
49   - @Autowired
50   - SignalSchPlanMatcher signalSchPlanMatcher;
51   -
52   - @Autowired
53   - GpsStatusManager gpsStatusManager;
54   -
55   - private final static int MAX_BEFORE_TIME = 1000 * 60 * 120;
56   -
57   - //最大的班次时间差,防止异常的GPS时间打乱数据
58   - private final static int MAX_NORMAL_DIFF = 1000 * 60 * 60 * 12;
59   -
60   - @Override
61   - public boolean handle(GpsEntity gps, CircleQueue<GpsEntity> prevs) {
62   - //忽略掉线信号
63   - if(isGpsOffline(gps))
64   - return false;
65   -
66   - /*//从异常状态恢复的第一个信号*/
67   - if(abnormalRecovery(gps, prevs)){
68   - //回溯一下之前的轨迹
69   - //scheduleSignalState.signalRetrospect(gps);
70   - return false;
71   - }
72   -
73   - try{
74   - if(isNotEmpty(prevs)){
75   - GpsEntity prev = prevs.getTail();
76   - if(isOutStation(gps, prev))
77   - outStation(gps, prev);
78   -
79   -
80   - if(isInStation(gps, prev))
81   - inStation(gps, prev);
82   - }
83   - }catch (Exception e){
84   - logger.error("in out error info ..", e);
85   - }
86   -
87   - return true;
88   - }
89   -
90   - private boolean isOutStation(GpsEntity gps, GpsEntity prev){
91   - //从站内到站外
92   - if(prev.getInstation() > 0 && gps.getInstation() == 0)
93   - return true;
94   -
95   - //从站内到另一个站内
96   - if(prev.getInstation() > 0 && gps.getInstation() > 0
97   - && !prev.getStopNo().equals(gps.getStopNo()))
98   - return true;
99   -
100   - //在被起点站覆盖的情况下出场
101   - if(isOutPark(gps, prev)){
102   - return true;
103   - }
104   - return false;
105   - }
106   -
107   - private boolean isInStation(GpsEntity gps, GpsEntity prev){
108   - //从站外到站内
109   - if(prev.getInstation() == 0 && gps.getInstation() > 0
110   - /*&& !prev.getStopNo().equals(gps.getStopNo())*/){
111   - return true;
112   - }
113   -
114   - //从站内到另一个站内
115   - if(prev.getInstation() == 1 && gps.getInstation() == 1
116   - && !prev.getStopNo().equals(gps.getStopNo())
117   - && !prev.getStation().getName().equals(gps.getStation().getName()))
118   - return true;
119   -
120   - //从场内到站内
121   - if(prev.getInstation() == 2 && gps.getInstation() == 1){
122   - return true;
123   - }
124   -
125   - //被起点站覆盖的情况下进场
126   - if(isInPark(gps, prev))
127   - return true;
128   - return false;
129   - }
130   -
131   - /**
132   - * 出站/出场
133   - * @param gps 当前点
134   - * @param prev 上一个点
135   - */
136   - private void outStation(GpsEntity gps, GpsEntity prev) {
137   - ScheduleRealInfo sch = dayOfSchedule.executeCurr(gps.getNbbm());
138   - String qdzCode = sch.getQdzCode();
139   -
140   - int diff = (int) (sch.getDfsjT() - gps.getTimestamp());
141   -
142   - //首班出场最多提前2小时
143   - if((dayOfSchedule.isFirstOut(sch) && diff > MAX_BEFORE_TIME) || diff > MAX_BEFORE_TIME / 2)
144   - return;
145   -
146   - //正常班次最大时间差
147   - if(Math.abs(diff) > MAX_NORMAL_DIFF)
148   - return;
149   -
150   - //起点发车
151   - if(qdzCode != null
152   - && prev.getStopNo().equals(qdzCode)
153   - && (gps.getInstation()==0 || !gps.getStopNo().equals(prev.getStopNo()))
154   - && !willDepart(gps, prev, sch)){
155   -
156   - gps.setPremiseCode(null);
157   - //发车班次匹配
158   - signalSchPlanMatcher.outMatch(gps, sch);
159   - sch = dayOfSchedule.executeCurr(gps.getNbbm());
160   -
161   - //班次已经实发
162   - if(StringUtils.isNotEmpty(sch.getFcsjActual())
163   - && !outManyFit(gps, sch)){
164   - return;
165   - }
166   -
167   - //应用到离站缓冲区设置参数
168   - long rsT = lineConfigData.applyOut(sch, gps.getTimestamp());
169   -
170   - //实发时间
171   - sch.setFcsjActualAll(rsT);
172   - sch.setSiginCompate(1);
173   -
174   - //出站既出场
175   - outStationAndOutPark(sch);
176   - //通知客户端
177   - sendUtils.sendFcsj(sch);
178   - //持久化
179   - dayOfSchedule.save(sch);
180   -
181   - //清理应发未发标记
182   - LateAdjustHandle.remove(sch.getClZbh());
183   -
184   - if(!gps.isService() && !dayOfSchedule.emptyService(sch)){
185   - //切换成营运状态
186   - gpsStatusManager.changeServiceState(sch.getClZbh(), sch.getXlDir(), 0, "发车@系统");
187   - }
188   -
189   - logger.info("车辆:" + sch.getClZbh() + " 班次:" + sch.getDfsj() + "发车, 时间:" + sch.getFcsjActual());
190   - }
191   - else if(isOutSch(sch)){
192   - //有出场动作(起点站覆盖停车场时,并且不设置出站既出场,逻辑可能会走到这里)
193   - try{
194   - if(isOutPark(gps, prev)){
195   - if(prev.getCarparkNo().equals(sch.getQdzCode())){
196   - //再试一下出场
197   - GpsEntity prevClone = (GpsEntity) prev.clone(),
198   - gpsClone = (GpsEntity) gps.clone();
199   - prevClone.setStopNo(prevClone.getCarparkNo());
200   - gpsClone.setInstation(0);
201   - outStation(gpsClone, prevClone);
202   - return;
203   - }
204   - }
205   - }catch (Exception e){logger.error("",e);}
206   -
207   - ScheduleRealInfo next = dayOfSchedule.nextSame(sch);
208   - //如果下一个班次是区间,并且是环线
209   - if(next != null && next.getBcType().equals("region")){
210   - next = dayOfSchedule.nextSame(next);
211   - if(next == null || !next.getQdzName().equals(next.getZdzName())){
212   - return;
213   - }
214   - }
215   - if(next != null && prev.getStopNo().equals(next.getQdzCode())){
216   - //发下一个班次
217   - if(dayOfSchedule.addExecPlan(next))
218   - outStation(gps, prev);
219   - }
220   - }
221   - //当前班次是区间
222   - else if(sch.getBcType().equals("region")){
223   - ScheduleRealInfo next = dayOfSchedule.nextSame(sch);
224   - if(next==null || !next.getQdzName().equals(next.getZdzName())){
225   - return;
226   - }
227   - //是环线
228   - if(prev.getStopNo().equals(next.getQdzCode())){
229   - //发下一个班次
230   - if(dayOfSchedule.addExecPlan(next))
231   - outStation(gps, prev);
232   - }
233   - }
234   - }
235   -
236   - /**
237   - * 是否是一个更合适的发车信号
238   - * @param gps
239   - * @param sch
240   - * @return
241   - */
242   - private boolean outManyFit(GpsEntity gps, ScheduleRealInfo sch) {
243   - LineConfig conf = lineConfigData.get(sch.getXlBm());
244   - if(null != conf && conf.isLockFirstOutTime())
245   - return false;//锁定第一个发车信号,不匹配最佳
246   -
247   - if(StringUtils.isNotEmpty(sch.getZdsjActual()))
248   - return false;
249   -
250   - long t1 = sch.getFcsjActualTime();
251   - long t2 = gps.getTimestamp();
252   - long c = sch.getDfsjT();
253   -
254   - /*if(c - t1 > 1000 * 60 * 15 && Math.abs(t2 - c) < 1000 * 60 * 5){
255   - return true;
256   - }*/
257   - int threshold = 1000 * 60 * 5;
258   - if(Math.abs(t2 - c) < threshold && c - t1 > threshold){
259   - return true;
260   - }
261   - //if(Math.abs(t2 - c) < 1000 * 60 * 5 && c - t1 > 1000 * 60 * 5)
262   - return false;
263   - }
264   -
265   -
266   - private void outStationAndOutPark(ScheduleRealInfo sch){
267   - try{
268   - LineConfig config = lineConfigData.get(sch.getXlBm());
269   - //限定出站既出场的停车场
270   - String park = config.getTwinsPark();
271   - boolean limitPark = StringUtils.isNotEmpty(park);
272   -
273   - if (config != null && config.getOutConfig() == 2) {
274   - //出站既出场
275   - ScheduleRealInfo schPrev = dayOfSchedule.prev(sch);
276   - if (schPrev != null && schPrev.getBcType().equals("out") && (schPrev.getBcsj()==0 || schPrev.getJhlcOrig().intValue()==0)
277   - && (!limitPark || park.equals(schPrev.getQdzCode()))) {
278   -
279   - schPrev.setFcsjActualAll(sch.getFcsjActualTime());
280   - schPrev.setZdsjActualAll(sch.getFcsjActualTime());
281   - //起点实到
282   - sch.setQdzArrDatesj(schPrev.getZdsjActual());
283   -
284   - sendUtils.refreshSch(schPrev);
285   - dayOfSchedule.save(schPrev);
286   - }
287   - }
288   - }catch (Exception e){
289   - logger.error("", e);
290   - }
291   - }
292   -
293   - /**
294   - * 进站
295   - * @param gps 当前点
296   - * @param prev 上一个点
297   - */
298   - private void inStation(GpsEntity gps, GpsEntity prev){
299   - ScheduleRealInfo sch = dayOfSchedule.executeCurr(gps.getNbbm());
300   -
301   - if(gps.getStopNo().equals(sch.getZdzCode())
302   - && (!gps.getStopNo().equals(prev.getStopNo()) || gps.getStopNo().equals(prev.getPremiseCode()))){
303   -
304   - int diff = 0;
305   - try{
306   - diff = (int) (sch.getZdsjT() - gps.getTimestamp());
307   - }catch(NullPointerException e){
308   - logger.info("NullPointerException " + sch.getXlName() + " 有班次无班次历时,,,检查一下是否需要出站既出场。");
309   - }
310   - //进场最多提前1.2小时
311   - if((sch.getBcType().equals("in") && diff > MAX_BEFORE_TIME) || diff > MAX_BEFORE_TIME/2)
312   - return;
313   -
314   - //正常班次最大时间差
315   - if(Math.abs(diff) > MAX_NORMAL_DIFF)
316   - return;
317   -
318   - //校验进站前置约束
319   - if(!validInPremise(gps)){
320   - return;
321   - }
322   -
323   - //环线或内外圈 ,飘出去再回来
324   - if(sch.getQdzCode().equals(sch.getZdzCode())
325   - && StringUtils.isNotEmpty(sch.getFcsjActual())
326   - && gps.getTimestamp() - sch.getFcsjActualTime() < 1000 * 60 * 3){
327   - sch.clearFcsjActual();
328   - sendUtils.refreshSch(sch);
329   - return;
330   - }
331   -
332   - //实达时间不覆盖
333   - if(StringUtils.isNotEmpty(sch.getZdsjActual()))
334   - return;
335   -
336   - //应用到离站缓冲区设置参数
337   - long rsT = lineConfigData.applyIn(sch, gps.getTimestamp());
338   -
339   - sch.setZdsjActualAll(rsT);
340   - sch.setSiginCompate(2);
341   - //通知误点停靠程序,有车辆到站
342   - LateAdjustHandle.carArrive(gps);
343   -
344   - //已完成班次数
345   - int doneSum = dayOfSchedule.doneSum(sch.getClZbh());
346   - ScheduleRealInfo next = dayOfSchedule.next(sch);
347   - //持久化
348   - dayOfSchedule.save(sch);
349   -
350   - if(next != null){
351   - dayOfSchedule.addExecPlan(next);
352   - //进站既进场
353   - inStationAndInPark(sch, next);
354   - }
355   -
356   - //该路牌的下一个班次,起点实际到达时间
357   - ScheduleRealInfo lpNext = dayOfSchedule.nextByLp(sch);
358   - if(lpNext != null){
359   - lpNext.setQdzArrDatesj(sch.getZdsjActual());
360   - }
361   -
362   - //通知客户端
363   - sendUtils.sendZdsj(sch, lpNext, doneSum);
364   - logger.info("车辆:" + sch.getClZbh() + " 班次:" + sch.getDfsj() + "到终点, 时间:" + sch.getZdsjActual());
365   - //清除车辆误点调整监听
366   - LateAdjustHandle.remove(sch.getClZbh());
367   - //准备执行下一个班次
368   - if (next != null) {
369   - //将gps转换为下一个班次走向的站内信号
370   - transformUpdown(gps, next);
371   - //下发调度指令
372   - DirectivePushQueue.put6002(next, doneSum, "到站@系统");
373   -
374   - //套跑 -下发线路切换指令
375   - if(!next.getXlBm().equals(sch.getXlBm())){
376   - gpsStatusManager.changeLine(next.getClZbh(), next.getXlBm(), "套跑@系统");
377   - }
378   -
379   - //下一个班次是空驶班次
380   - if(dayOfSchedule.emptyService(next))
381   - nonService(sch, "空驶@系统");
382   - } else
383   - nonService(sch, "结束@系统");
384   - }
385   - else {
386   - /*if(sch.getFcsjActual() == null){
387   - //有进站,但班次没有实发,向前追溯一下信号
388   - scheduleSignalState.signalRetrospect(gps, sch);
389   - }
390   -*/
391   - //被起点站覆盖的情况下进场,没有设置出站既是出场,逻辑会走到这里(模拟进站信号)
392   - if(isInSch(sch)){
393   - try{
394   - if(isInPark(gps, prev)){
395   - if(gps.getCarparkNo().equals(sch.getZdzCode())){
396   - //再试一下进场
397   - GpsEntity gpsClone = (GpsEntity) gps.clone(),
398   - prevClone = (GpsEntity) prev.clone();
399   - gpsClone.setStopNo(gpsClone.getCarparkNo());
400   - prevClone.setStopNo(null);
401   - inStation(gpsClone, prevClone);
402   - return;
403   - }
404   - }
405   - }catch (Exception e){
406   - logger.error("", e);
407   - }
408   - }
409   -
410   - //如果当前班次是出场,并且进的是下一个班次的终点
411   - if(sch.getBcType().equals("out")){
412   - ScheduleRealInfo next = dayOfSchedule.next(sch);
413   - if(next != null && next.getZdzCode().equals(gps.getStopNo())){
414   - List<ScheduleRealInfo> halfList = dayOfSchedule.findByNbbm(sch.getClZbh());
415   - //和当前进站信号最匹配的一个班次
416   - ScheduleRealInfo nearSch = nearScheduleByGpsIn(gps, halfList);
417   -
418   - if(nearSch != null){
419   - //直接跳到这个班次
420   - if(dayOfSchedule.addExecPlan(nearSch))
421   - inStation(gps, prev);//重新进站
422   - }
423   - }
424   - }
425   - }
426   - }
427   -
428   - /**
429   - * 校验进站前置约束
430   - * @param gps
431   - * @return
432   - */
433   - private boolean validInPremise(GpsEntity gps) {
434   - StationRoute sr = gps.getStation();
435   - if(null == sr || !sr.isPremise())
436   - return true;
437   -
438   - String premiseCode = gps.getPremiseCode();
439   -
440   - if(StringUtils.isNotEmpty(premiseCode) && premiseCode.equals(gps.getStopNo())){
441   - logger.info("满足前置进站约束 " + premiseCode);
442   - return true;
443   - }
444   - else{
445   - logger.info(gps.getNbbm() + " not premiseCode 不满足前置进站约束 " + premiseCode);
446   - }
447   - return false;
448   - }
449   -
450   - /**
451   - * 和当前进站信号最匹配的一个班次
452   - * @param gps
453   - * @param halfList
454   - * @return
455   - */
456   - private ScheduleRealInfo nearScheduleByGpsIn(GpsEntity gps, List<ScheduleRealInfo> halfList){
457   - if(halfList == null || halfList.size() == 0)
458   - return null;
459   -
460   - //排序
461   - Collections.sort(halfList, new ScheduleComparator.FCSJ());
462   - ScheduleRealInfo near = null;// = halfList.get(0);
463   - ScheduleRealInfo sch;
464   -
465   - String stopId = gps.getStopNo();
466   - for(int i = 0; i < halfList.size(); i ++){
467   - sch = halfList.get(i);
468   - if(!sch.getZdzCode().equals(stopId) || sch.getStatus()==2)
469   - continue;
470   -
471   - if(sch.getZdsjT() < gps.getTimestamp())
472   - near = sch;
473   - else
474   - break;
475   -
476   - }
477   - return near;
478   - }
479   -
480   - /**
481   - * 进站既进场
482   - * @param sch
483   - */
484   - private void inStationAndInPark(ScheduleRealInfo sch, ScheduleRealInfo next){
485   - LineConfig config = lineConfigData.get(sch.getXlBm());
486   - //限定出站既出场的停车场
487   - String park = config.getTwinsPark();
488   - boolean limitPark = StringUtils.isNotEmpty(park);
489   -
490   -
491   - if (next.getBcType().equals("in") && config.getOutConfig() == 2 && (next.getBcsj()==0 || next.getJhlcOrig().intValue()==0)
492   - && (!limitPark || park.equals(next.getZdzCode()))) {
493   -
494   - next.setFcsjActualAll(sch.getZdsjActualTime());
495   - next.setZdsjActualAll(sch.getZdsjActualTime());
496   -
497   - sendUtils.refreshSch(next);
498   - dayOfSchedule.save(next);
499   -
500   - //分班的时候,需要再跳过1个班次
501   - next = dayOfSchedule.next(next);
502   - if(next != null)
503   - dayOfSchedule.addExecPlan(next);
504   -
505   - //进场,切换成非营运状态
506   - nonService(sch, "进场@系统");
507   - }
508   - }
509   -
510   - /**
511   - * 发车漂移判定(这里出现的误判,由车辆到达中途站的时候补偿)
512   - * @param gps
513   - * @param prev
514   - * @param task
515   - * @return
516   - */
517   - private boolean willDepart(GpsEntity gps, GpsEntity prev, Object task){
518   -
519   - /*ScheduleRealInfo sch = (ScheduleRealInfo) task;
520   - ScheduleRealInfo prevTask = dayOfSchedule.prev(sch);
521   - if(prevTask == null || prevTask.getBcType().equals("out"))
522   - return false;
523   -
524   - //计划停站时间
525   - int stopTimePlan = (int) (sch.getDfsjT() - prevTask.getZdsjT());
526   -
527   - if(stopTimePlan < 1000 * 60 * 10)
528   - return false;
529   -
530   - //实际停站时间
531   - if(prevTask.getZdsjActual() != null){
532   - int actualTime = (int) (gps.getTimestamp() - prevTask.getZdsjActualTime());
533   -
534   - if(actualTime < stopTimePlan * 0.8){
535   - logger.info("漂移判定");
536   -
537   - return true;
538   - }
539   - }*/
540   - return false;
541   - }
542   -
543   - private boolean isOutPark(GpsEntity gps, GpsEntity prve){
544   - if(StringUtils.isNotEmpty(prve.getCarparkNo()) && StringUtils.isEmpty(gps.getCarparkNo()))
545   - return true;
546   - return false;
547   - }
548   -
549   - private boolean isInPark(GpsEntity gps, GpsEntity prve){
550   - if(StringUtils.isNotEmpty(gps.getCarparkNo()) && StringUtils.isEmpty(prve.getCarparkNo()))
551   - return true;
552   - return false;
553   - }
554   -
555   - private boolean isOutSch(ScheduleRealInfo sch){
556   - return sch.getBcType().equals("out") || GeoCacheData.tccMap.keySet().contains(sch.getQdzCode());
557   - }
558   -
559   - private boolean isInSch(ScheduleRealInfo sch){
560   - return sch.getBcType().equals("in") || GeoCacheData.tccMap.keySet().contains(sch.getZdzCode());
561   - }
562   -
563   - /**
564   - * 切换为非营运状态
565   - * @param sch
566   - * @param sender
567   - */
568   - private void nonService(ScheduleRealInfo sch, String sender){
569   - gpsStatusManager.changeServiceState(sch.getClZbh(), sch.getXlDir(), 1, sender);
570   - }
571   -}
572 0 \ No newline at end of file
src/main/java/com/bsth/data/gpsdata/arrival/handlers/OfflineSignalHandle.java deleted 100644 → 0
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   - //断开4分钟,标记为重连信号
17   - private final static int OFFLINE_TIME = 1000 * 60 * 4;
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(isGpsOffline(gps)){
26   - gps.setSignalState("gps-offline");
27   - gps.setAbnormalStatus("gps-offline");
28   - return true;
29   - }
30   -
31   - if(isNotEmpty(prevs)){
32   - GpsEntity prev = prevs.getTail();
33   - //间隔太大就丢弃,不管之前还是之后
34   - int space = Math.abs((int) (gps.getTimestamp() - prev.getTimestamp()));
35   - if(space > OFFLINE_TIME)
36   - gps.setSignalState("reconnection");
37   -
38   - if(space > CLEAR_TIME){
39   - //清理缓存的信号
40   - GeoCacheData.clear(gps.getNbbm());
41   - }
42   - }
43   - return true;
44   - }
45   -}
46 0 \ No newline at end of file
src/main/java/com/bsth/data/gpsdata/arrival/handlers/ReverseSignalHandle.java deleted 100644 → 0
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 != null && reverse.getCount() >= 3
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   - if(sr == null)
78   - return null;
79   -
80   - if (sr.getRouteSort() > curr.getRouteSort()) {
81   - if(half){
82   - routeReverse.setVague(true);
83   - }
84   -
85   - path += (curr.getCode() + ",");
86   - count++;
87   - zt = prev.getTimestamp();
88   - } else if (sr.getRouteSort() < curr.getRouteSort()) {
89   - if (routeReverse.getTurned() == null) {
90   - routeReverse.setTurned(curr.getCode());
91   - half = true;
92   - }
93   -
94   - path += (curr.getCode() + ",");
95   - //掉头前当前站
96   - if (sr.getCode().equals(gps.getStopNo())) {
97   - routeReverse.setClose(true);
98   - path += sr.getCode();
99   - break;
100   - }
101   - }
102   -
103   - curr = sr;
104   - }
105   - }
106   -
107   - routeReverse.setZt(zt);
108   - routeReverse.setCount(count);
109   - routeReverse.setDetail(path);
110   - routeReverse.setCt(gps.getTimestamp());
111   - routeReverse.setNbbm(gps.getNbbm());
112   - return routeReverse;
113   - }
114   -
115   - /**
116   - * 是否反向
117   - *
118   - * @param gps
119   - * @param prev
120   - * @return
121   - */
122   - public boolean isReverse(GpsEntity gps, GpsEntity prev) {
123   - if (gps.getInstation() == 1
124   - &&
125   - gps.getUpDown().equals(prev.getUpDown())
126   - && !gps.getStopNo().equals(prev.getStopNo())) {
127   -
128   - StationRoute currStation = GeoCacheData.getRouteCode(gps);
129   - StationRoute prevStation = GeoCacheData.getRouteCode(prev);
130   -
131   - if (currStation == null || prevStation == null)
132   - return false;
133   -
134   - if (currStation.getRouteSort() < prevStation.getRouteSort())
135   - return true;
136   - }
137   - return false;
138   - }
139   -}
140 0 \ No newline at end of file
src/main/java/com/bsth/data/gpsdata/arrival/precondition/InPreconditionHandler.java deleted 100644 → 0
1   -package com.bsth.data.gpsdata.arrival.precondition;
2   -
3   -import com.bsth.data.gpsdata.GpsEntity;
4   -import org.springframework.stereotype.Component;
5   -
6   -/**
7   - * 进站(前置电子围栏)
8   - * Created by panzhao on 2017/9/23.
9   - */
10   -@Component
11   -public class InPreconditionHandler {
12   -
13   - /**
14   - * 进站动作是否有通过前置围栏
15   - * @param gps
16   - * @param prev
17   - * @return
18   - */
19   - public boolean isPass(GpsEntity gps, GpsEntity prev){
20   - return false;
21   - }
22   -}
src/main/java/com/bsth/data/gpsdata/arrival/utils/ScheduleSignalState.java deleted 100644 → 0
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 != null && next.getXlDir().equals(sch.getXlDir()))
76   - return;
77   -
78   - if(next == null)
79   - return;
80   - //时间足够下一个班次待发时间运行到当前站
81   - int runTime = reverse.getCount() * 1500 * 60;
82   - if (next.getDfsjT() + runTime < t) {
83   - //跳到下一个班次
84   - dayOfSchedule.addExecPlan(next);
85   - }
86   - }
87   -
88   - /**
89   - * 正常班次路由反向分析
90   - *
91   - * @param sch
92   - * @param reverse
93   - */
94   - private void normalReverseAnalyse(ScheduleRealInfo sch, RouteReverse reverse) {
95   - LineConfig conf = lineConfigData.get(sch.getXlBm());
96   -
97   - if (conf.isReadReverse()) {
98   - //跳下一个班次
99   - ScheduleRealInfo next = dayOfSchedule.next(sch);
100   - if (next != null)
101   - dayOfSchedule.addExecPlan(next);
102   -
103   - //记录信号状态
104   - SignalState signalState = SignalState.reverseSignalSTate(sch, reverse);
105   - if(signalState != null)
106   - signalStateData.put(signalState);
107   - }
108   - }
109   -
110   - public void signalRetrospect(GpsEntity gps) {
111   - signalRetrospect(gps, dayOfSchedule.executeCurr(gps.getNbbm()));
112   - }
113   -
114   - /**
115   - * 信号追溯
116   - *
117   - * @param gps
118   - * @param sch
119   - */
120   - public void signalRetrospect(GpsEntity gps, ScheduleRealInfo sch) {
121   - //回放数据,是否有掉线或者漂移
122   - CircleQueue<GpsEntity> queue = GeoCacheData.getGps(gps.getNbbm());
123   - if (queue == null || queue.size() == 0 /*|| gps.getInstation() == 0*/)
124   - return;
125   -
126   - //起始时间点
127   - long st = 0;
128   - ScheduleRealInfo prev = dayOfSchedule.prev(sch);
129   -
130   - if (prev != null) {
131   - if (prev.getZdsjActual() != null)
132   - st = prev.getZdsjActualTime();
133   - else
134   - st = (GeoCacheData.midwayStation(gps.getLineId(), gps.getUpDown(), sch.getQdzCode(), gps.getStopNo()).size() + 1) * (1000 * 60 * 5);
135   - }
136   -
137   - Object[] tempArray = queue.getQueue();
138   - int len = tempArray.length;
139   -
140   - Object[] array = new Object[len + 1];
141   - System.arraycopy(tempArray, 0, array, 0, len);
142   - array[len] = gps;
143   -
144   - String gpsState = "";
145   - GpsEntity tempGps, nearGps = null;
146   - int i = len - 1;
147   - for (; i >= 0; i--) {
148   - tempGps = (GpsEntity) array[i];
149   -
150   - gpsState = tempGps.getSignalState();
151   - if (gpsState.equals("truncation"))
152   - break;
153   - else if (gpsState.equals("drift")) {
154   - nearGps = (GpsEntity) array[i + 1];
155   - break;
156   - } else if (gpsState.equals("reconnection")) {
157   - nearGps = tempGps;
158   - break;
159   - }
160   -
161   - if (tempGps.getTimestamp() < st)
162   - break;
163   - }
164   -
165   - if (nearGps != null && i > 0) {
166   - createSignalAbnormal(gpsState, nearGps, i, array, sch);
167   - }
168   - }
169   -
170   - private void createSignalAbnormal(String gpsState, GpsEntity nearGps, int i, Object[] array, ScheduleRealInfo sch) {
171   - switch (gpsState) {
172   - case "drift":
173   - driftSignalAbnormal(nearGps, i, array, sch);
174   - break;
175   - case "reconnection":
176   - offlineSignalAbnormal(nearGps, ((GpsEntity) array[i - 1]), sch);
177   - break;
178   - }
179   - }
180   -
181   - /**
182   - * 掉线异常状态记录
183   - *
184   - * @param e
185   - * @param s
186   - */
187   - private void offlineSignalAbnormal(GpsEntity e, GpsEntity s, ScheduleRealInfo sch) {
188   - long st = s.getTimestamp(), et = e.getTimestamp();
189   -
190   - //掉线超过10分钟才记录
191   - if (et - st < (1000 * 60 * 10))
192   - return;
193   -
194   - SignalAbnormal signalAbnormal = new SignalAbnormal();
195   - signalAbnormal.setSt(st);
196   - signalAbnormal.setEt(et);
197   - signalAbnormal.setAbnormalType("reconnection");
198   - signalAbnormal.setDestCode(sch.getQdzCode());
199   - signalAbnormal.setOutOrIn(0);
200   -
201   - //截断GPS
202   - e.setSignalState("truncation");
203   -
204   - //记录信号状态
205   - SignalState signalState = SignalState.abnormalSignalSTate(sch, signalAbnormal);
206   - signalStateData.put(signalState);
207   - }
208   -
209   - /**
210   - * 漂移异常状态记录
211   - *
212   - * @param nearGps
213   - * @param i
214   - * @param array
215   - */
216   - private void driftSignalAbnormal(GpsEntity nearGps, int i, Object[] array, ScheduleRealInfo sch) {
217   - GpsEntity gps, s = null;
218   - //找到漂移开始时间
219   - for (; i >= 0; i--) {
220   - gps = (GpsEntity) array[i];
221   -
222   - if (!gps.getSignalState().equals("drift") || i == 0
223   - || gps.getSignalState().equals("truncation")) {
224   - s = gps;
225   - break;
226   - }
227   - }
228   -
229   - long st = s.getTimestamp(), et = nearGps.getTimestamp();
230   - if (et - st < (1000 * 60 * 3))
231   - return;
232   - /*if (s != null){
233   - st = s.getTimestamp();
234   - //漂移小于3分钟
235   - if(et - st < (1000 * 60 * 3))
236   - return;
237   - }*/
238   -
239   -
240   - SignalAbnormal signalAbnormal = new SignalAbnormal();
241   - signalAbnormal.setSt(st);
242   - signalAbnormal.setEt(et);
243   - signalAbnormal.setAbnormalType("drift");
244   - signalAbnormal.setDestCode(sch.getQdzCode());
245   - signalAbnormal.setOutOrIn(0);
246   -
247   - //截断GPS
248   - nearGps.setSignalState("truncation");
249   -
250   - //记录信号状态
251   - SignalState signalState = SignalState.abnormalSignalSTate(sch, signalAbnormal);
252   - signalStateData.put(signalState);
253   - }
254   -}
255 0 \ No newline at end of file
src/main/java/com/bsth/data/gpsdata/arrival/utils/SignalSchPlanMatcher.java deleted 100644 → 0
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.slf4j.Logger;
7   -import org.slf4j.LoggerFactory;
8   -import org.springframework.beans.factory.annotation.Autowired;
9   -import org.springframework.stereotype.Component;
10   -
11   -/**
12   - * 班次匹配器
13   - * Created by panzhao on 2016/12/31.
14   - */
15   -@Component
16   -public class SignalSchPlanMatcher {
17   -
18   - @Autowired
19   - DayOfSchedule dayOfSchedule;
20   -
21   - Logger log = LoggerFactory.getLogger(this.getClass());
22   -
23   - /**
24   - * 发车信号匹配
25   - * @param outSigal
26   - * @param sch
27   - * @return
28   - */
29   - public void outMatch(GpsEntity outSigal, ScheduleRealInfo sch){
30   - long t = outSigal.getTimestamp();
31   - if(t < sch.getDfsjT())
32   - return;
33   -
34   - try{
35   - //会不会是分班没有完成
36   - if(sch.getBcType().equals("in") && t - sch.getDfsjT() > 1000 * 60 * 20){
37   - ScheduleRealInfo fbFirst = dayOfSchedule.nextByBcType(sch, "normal");
38   -
39   - if(fbFirst == null || !fbFirst.getQdzCode().equals(outSigal.getStopNo()))
40   - return;
41   -
42   - long dt = fbFirst.getDfsjT();
43   - //晚于待发前4分钟 -执行分班的首个营运
44   - if(dt - t < 1000 * 60 * 4){
45   - dayOfSchedule.addExecPlan(fbFirst);
46   - return;
47   - }
48   - }
49   -
50   - //线路编码不匹配
51   - if("out".equals(sch.getBcType()) && !sch.getXlBm().equals(outSigal.getLineId())){
52   - ScheduleRealInfo nextOut = dayOfSchedule.nextByBcType(sch, "out");
53   - if(nextOut != null && nextOut.getXlBm().equals(outSigal.getLineId())
54   - && fcSpace(sch, outSigal) > fcSpace(nextOut, outSigal)){
55   - dayOfSchedule.addExecPlan(nextOut);
56   - return;
57   - }
58   - }
59   - }catch (Exception e){
60   - log.error("", e);
61   - }
62   -
63   - //下一个相同走向的班次
64   - ScheduleRealInfo next = dayOfSchedule.nextSame(sch);
65   - if(next == null || !next.getQdzCode().equals(sch.getQdzCode()))
66   - return;
67   -
68   - //晚于班次间隔百分之70,跳下一个班次
69   - double s = (int) (next.getDfsjT() - sch.getDfsjT());
70   - double r = (int) (t - sch.getDfsjT());
71   - if(r / s > 0.7){
72   - if(dayOfSchedule.addExecPlan(next))
73   - outMatch(outSigal, next);
74   - }
75   - }
76   -
77   - public static int fcSpace(ScheduleRealInfo sch, GpsEntity gps){
78   - return (int) Math.abs((sch.getDfsjT() - gps.getTimestamp()));
79   - }
80   -}
src/main/java/com/bsth/data/gpsdata/thread/GpsDataLoaderThread.java deleted 100644 → 0
1   -package com.bsth.data.gpsdata.thread;
2   -
3   -import com.alibaba.fastjson.JSON;
4   -import com.alibaba.fastjson.JSONObject;
5   -import com.bsth.data.BasicData;
6   -import com.bsth.data.gpsdata.GpsEntity;
7   -import com.bsth.data.gpsdata.GpsRealData;
8   -import com.bsth.data.gpsdata.arrival.GpsRealAnalyse;
9   -import com.bsth.util.ConfigUtil;
10   -import org.apache.commons.lang3.StringUtils;
11   -import org.apache.http.HttpEntity;
12   -import org.apache.http.client.config.RequestConfig;
13   -import org.apache.http.client.methods.CloseableHttpResponse;
14   -import org.apache.http.client.methods.HttpGet;
15   -import org.apache.http.impl.client.CloseableHttpClient;
16   -import org.apache.http.impl.client.HttpClients;
17   -import org.slf4j.Logger;
18   -import org.slf4j.LoggerFactory;
19   -import org.springframework.beans.factory.annotation.Autowired;
20   -import org.springframework.stereotype.Component;
21   -
22   -import java.io.BufferedReader;
23   -import java.io.InputStreamReader;
24   -import java.util.ArrayList;
25   -import java.util.List;
26   -
27   -/**
28   - * Created by panzhao on 2017/1/11.
29   - */
30   -@Component
31   -public class GpsDataLoaderThread extends Thread {
32   -
33   - Logger logger = LoggerFactory.getLogger(GpsDataLoaderThread.class);
34   -
35   - /**
36   - * 构造函数
37   - */
38   - public GpsDataLoaderThread() {
39   - url = ConfigUtil.get("http.gps.real.url");
40   - clientUrl = ConfigUtil.get("http.gps.real.cache.url");
41   - }
42   -
43   - // 网关数据接口地址
44   - private static String url;
45   - // GPS客户端内存数据接口
46   - private static String clientUrl;
47   -
48   - //0:从GPS客户端内存获取 -1:从网关获取
49   - private static int flag = 0;
50   -
51   - public static void setFlag(int v) {
52   - flag = v;
53   - }
54   -
55   - public static int getFlag(int v) {
56   - return flag;
57   - }
58   -
59   - @Autowired
60   - GpsRealData gpsRealData;
61   -
62   - @Autowired
63   - GpsRealAnalyse gpsRealAnalyse;
64   -
65   - @Override
66   - public void run() {
67   - try {
68   - if (flag == 0)
69   - load();
70   - else
71   - loadByGateway();
72   - } catch (Exception e) {
73   - logger.error("", e);
74   - }
75   - }
76   -
77   - /**
78   - * 从网关获取实时GPS数据
79   - *
80   - * @throws Exception
81   - */
82   - public void loadByGateway() throws Exception {
83   - List<GpsEntity> list = null;
84   - List<GpsEntity> updateList = new ArrayList<>();
85   - CloseableHttpClient httpClient = null;
86   - CloseableHttpResponse response = null;
87   - try {
88   - httpClient = HttpClients.createDefault();
89   - HttpGet get = new HttpGet(url);
90   - //超时时间
91   - RequestConfig requestConfig = RequestConfig.custom()
92   - .setConnectTimeout(1500).setConnectionRequestTimeout(1000)
93   - .setSocketTimeout(1500).build();
94   - get.setConfig(requestConfig);
95   -
96   - response = httpClient.execute(get);
97   -
98   - HttpEntity entity = response.getEntity();
99   - if (null != entity) {
100   - BufferedReader br = new BufferedReader(new InputStreamReader(entity.getContent()));
101   - StringBuilder stringBuffer = new StringBuilder();
102   - String str = "";
103   - while ((str = br.readLine()) != null)
104   - stringBuffer.append(str);
105   -
106   - JSONObject jsonObj = JSON.parseObject(stringBuffer.toString());
107   -
108   - if (jsonObj != null)
109   - list = JSON.parseArray(jsonObj.getString("data"), GpsEntity.class);
110   -
111   - //过滤掉无效的点位
112   - list = filterInvalid(list);
113   -
114   - String nbbm;
115   - GpsEntity old;
116   - for (GpsEntity gps : list) {
117   -
118   - //没有设备号
119   - if (StringUtils.isBlank(gps.getDeviceId()))
120   - continue;
121   -
122   - old = gpsRealData.get(gps.getDeviceId());
123   - if (old != null &&
124   - old.getTimestamp().equals(gps.getTimestamp()) &&
125   - old.getLat().equals(gps.getLat()) &&
126   - old.getLon().equals(gps.getLon()))
127   - continue;
128   -
129   - nbbm = BasicData.deviceId2NbbmMap.get(gps.getDeviceId());
130   - if (StringUtils.isBlank(nbbm))
131   - gps.setIncomplete(true);//标记为异常数据
132   - else
133   - gps.setNbbm(nbbm);
134   - //有更新的点位
135   - updateList.add(gps);
136   - }
137   - logger.info("全量点:" + list.size() + ",更新点" + updateList.size());
138   - //分析数据
139   - gpsRealAnalyse.analyse(updateList);
140   - } else
141   - logger.error("real gps result is null");
142   - } catch (Exception e) {
143   - logger.error("", e);
144   - } finally {
145   - if (null != httpClient)
146   - httpClient.close();
147   - if (null != response)
148   - response.close();
149   - }
150   - }
151   -
152   - /**
153   - * 过滤无效的gps点位
154   - *
155   - * @param list
156   - * @return
157   - */
158   - private List<GpsEntity> filterInvalid(List<GpsEntity> list) {
159   - List<GpsEntity> rsList = new ArrayList<>();
160   -
161   - try {
162   - for (GpsEntity gps : list) {
163   - if (gps.getValid() == 0)
164   - rsList.add(gps);
165   - }
166   -
167   - if (rsList.size() < list.size())
168   - logger.info("过滤无效的点位 : " + (list.size() - rsList.size()));
169   - } catch (Exception e) {
170   - logger.error("", e);
171   - rsList = list;
172   - }
173   - return rsList;
174   - }
175   -
176   - /**
177   - * 从客户端内存获取GPS数据
178   - */
179   - public void load() throws Exception {
180   - List<GpsEntity> list = null;
181   - CloseableHttpClient httpClient = null;
182   - CloseableHttpResponse response = null;
183   -
184   - try {
185   - logger.info("load start...");
186   - httpClient = HttpClients.createDefault();
187   - HttpGet get = new HttpGet(clientUrl);
188   - //超时时间
189   - RequestConfig requestConfig = RequestConfig.custom()
190   - .setConnectTimeout(2000).setConnectionRequestTimeout(1000)
191   - .setSocketTimeout(3000).build();
192   - get.setConfig(requestConfig);
193   -
194   - response = httpClient.execute(get);
195   -
196   - HttpEntity entity = response.getEntity();
197   - if (null != entity) {
198   - BufferedReader br = new BufferedReader(new InputStreamReader(entity.getContent()));
199   - StringBuilder stringBuffer = new StringBuilder();
200   - String str = "";
201   - while ((str = br.readLine()) != null)
202   - stringBuffer.append(str);
203   -
204   - list = JSON.parseArray(stringBuffer.toString(), GpsEntity.class);
205   -
206   - //过滤掉无效的点位
207   - list = filterInvalid(list);
208   -
209   - String nbbm;
210   - logger.info("load end!");
211   - for (GpsEntity gps : list) {
212   -
213   - //没有设备号
214   - if (StringUtils.isBlank(gps.getDeviceId()))
215   - continue;
216   -
217   - nbbm = BasicData.deviceId2NbbmMap.get(gps.getDeviceId());
218   - if (StringUtils.isBlank(nbbm))
219   - gps.setIncomplete(true);//标记为异常数据
220   - else
221   - gps.setNbbm(nbbm);
222   - }
223   - //分析数据
224   - gpsRealAnalyse.analyse(list);
225   - } else
226   - logger.error("client gps result is null");
227   - } catch (Exception e) {
228   - logger.error("", e);
229   - } finally {
230   - if (null != httpClient)
231   - httpClient.close();
232   - if (null != response)
233   - response.close();
234   - }
235   - }
236   -}
237 0 \ No newline at end of file
src/main/java/com/bsth/data/gpsdata/thread/OfflineMonitorThread.java deleted 100644 → 0
1   -package com.bsth.data.gpsdata.thread;
2   -
3   -import com.bsth.data.gpsdata.GpsEntity;
4   -import com.bsth.data.gpsdata.GpsRealData;
5   -import com.bsth.websocket.handler.SendUtils;
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.Collection;
12   -
13   -/**
14   - * GPS掉离线监控
15   - * Created by panzhao on 2017/1/11.
16   - */
17   -@Component
18   -public class OfflineMonitorThread extends Thread{
19   -
20   - @Autowired
21   - GpsRealData gpsRealData;
22   -
23   - //掉线阈值
24   - private final static int LOSE_TIME = 1000 * 60 * 10;
25   -
26   - Logger logger = LoggerFactory.getLogger(this.getClass());
27   -
28   - @Autowired
29   - SendUtils sendUtils;
30   -
31   - //无任务时 离线阈值
32   - //private final static int OFFLINE_TIME = 1000 * 60 * 10;
33   -
34   - @Override
35   - public void run() {
36   - try{
37   - long t = System.currentTimeMillis();
38   - Collection<GpsEntity> list = gpsRealData.all();
39   -
40   - String state;
41   - for(GpsEntity gps : list){
42   - state = gps.getAbnormalStatus();
43   -
44   - if(state != null && state.equals("offline"))
45   - continue;
46   -
47   - if (t - gps.getTimestamp() > LOSE_TIME){
48   - gps.offline();
49   -
50   - //通知页面有设备掉线
51   - sendUtils.deviceOffline(gps);
52   - }
53   - }
54   - }catch (Exception e){
55   - logger.error("", e);
56   - }
57   - }
58   -}
src/main/java/com/bsth/data/gpsdata/arrival/GpsRealAnalyse.java renamed to src/main/java/com/bsth/data/gpsdata_v2/DataHandleProcess.java
1   -package com.bsth.data.gpsdata.arrival;
  1 +package com.bsth.data.gpsdata_v2;
2 2  
3   -import com.bsth.data.gpsdata.GpsEntity;
4   -import com.bsth.data.gpsdata.GpsRealData;
5   -import com.bsth.data.gpsdata.arrival.handlers.*;
6   -import com.bsth.data.gpsdata.arrival.utils.CircleQueue;
7   -import com.bsth.data.gpsdata.recovery.GpsDataRecovery;
  3 +import com.bsth.data.gpsdata_v2.cache.GpsCacheData;
  4 +import com.bsth.data.gpsdata_v2.entity.GpsEntity;
  5 +import com.bsth.data.gpsdata_v2.handlers.*;
8 6 import com.google.common.collect.ArrayListMultimap;
9 7 import org.slf4j.Logger;
10 8 import org.slf4j.LoggerFactory;
11 9 import org.springframework.beans.factory.annotation.Autowired;
12 10 import org.springframework.stereotype.Component;
13 11  
14   -import java.util.*;
  12 +import java.util.ArrayList;
  13 +import java.util.List;
  14 +import java.util.Set;
15 15 import java.util.concurrent.CountDownLatch;
16 16 import java.util.concurrent.ExecutorService;
17 17 import java.util.concurrent.Executors;
  18 +import java.util.concurrent.ThreadFactory;
18 19  
19 20 /**
20   - * gps 实时数据分析
21   - * Created by panzhao on 2016/12/27.
  21 + * 实时信号数据处理
  22 + * Created by panzhao on 2017/11/15.
22 23 */
23 24 @Component
24   -public class GpsRealAnalyse {
  25 +public class DataHandleProcess {
25 26  
26   - static Logger logger = LoggerFactory.getLogger(GpsRealAnalyse.class);
  27 + static Logger logger = LoggerFactory.getLogger(DataHandleProcess.class);
  28 + final static int POOL_SIZE = 25;
  29 +
  30 + static ExecutorService threadPool = Executors.newFixedThreadPool(POOL_SIZE + 1, new HandlerThreadFactory());
  31 + public static CountDownLatch count;
27 32  
28 33 @Autowired
29   - OfflineSignalHandle offlineSignalHandle;
  34 + GpsStateProcess gpsStateProcess;
30 35 @Autowired
31   - CorrectSignalHandle correctSignalHandle;
  36 + StationInsideProcess stationInsideProcess;
32 37 @Autowired
33   - StationInsideHandle stationInsideHandle;
  38 + AbnormalStateProcess abnormalStateProcess;
34 39 @Autowired
35   - InOutStationSignalHandle inOutStationSignalHandle;
  40 + InStationProcess inStationProcess;
36 41 @Autowired
37   - ReverseSignalHandle reverseSignalHandle;
  42 + OutStationProcess outStationProcess;
38 43 @Autowired
39   - AbnormalStateHandle abnormalStateHandle;
  44 + ReverseRouteProcess reverseRouteProcess;
40 45  
41 46 @Autowired
42 47 GpsRealData gpsRealData;
43 48  
44   - final static int POOL_SIZE = 25;
45   - static ExecutorService threadPool = Executors.newFixedThreadPool(POOL_SIZE + 1);
46   -
47   - public static long st;
48   - public static CountDownLatch count;
49   -
50   - public static boolean isBlock() {
51   - return System.currentTimeMillis() - st > 1000 * 20;
52   - }
53   -
54   - public static boolean isIdle(){
55   - return System.currentTimeMillis() - st > 1000 * 60;
56   - }
57   -
58   - public void analyse(List<GpsEntity> list) {
  49 + public void handle(List<GpsEntity> list) {
59 50 try {
60   - if(list.size() == 0 || GpsDataRecovery.run)
61   - return;
62   - st = System.currentTimeMillis();
63   -
64   - //按设备号分组数据(一个设备号的多条数据,必须在一个线程里跑)
  51 + //按设备号分组数据(一个设备的多条数据,必须在一个线程里跑)
65 52 ArrayListMultimap multimap = ArrayListMultimap.create();
66 53 for (GpsEntity gps : list) {
67 54 multimap.put(gps.getDeviceId(), gps);
... ... @@ -70,10 +57,10 @@ public class GpsRealAnalyse {
70 57  
71 58 //数据均分给线程
72 59 ArrayListMultimap dataListMap = ArrayListMultimap.create();
73   - int size = deviceList.size(), threadIndex=0, threadSize = size / POOL_SIZE;
74   - for(int i = 0; i < size; i++){
75   - if(i % threadSize == 0)
76   - threadIndex ++;
  60 + int size = deviceList.size(), threadIndex = 0, threadSize = size / POOL_SIZE;
  61 + for (int i = 0; i < size; i++) {
  62 + if (i % threadSize == 0)
  63 + threadIndex++;
77 64 dataListMap.putAll(threadIndex, multimap.get(deviceList.get(i)));
78 65 }
79 66 Set<Integer> ks = dataListMap.keySet();
... ... @@ -81,7 +68,7 @@ public class GpsRealAnalyse {
81 68 count = new CountDownLatch(ks.size());
82 69  
83 70 for (Integer index : ks) {
84   - threadPool.execute(new SignalHandleThread(dataListMap.get(index), count));
  71 + threadPool.submit(new SignalHandleThread(dataListMap.get(index), count));
85 72 }
86 73  
87 74 //等待子线程结束
... ... @@ -90,26 +77,11 @@ public class GpsRealAnalyse {
90 77 //加入实时gps对照
91 78 for (GpsEntity gps : list)
92 79 gpsRealData.put(gps);
93   -
94   - logger.info("time , " + (System.currentTimeMillis() - st));
95 80 } catch (Exception e) {
96 81 logger.error("", e);
97 82 }
98 83 }
99 84  
100   - public static void shutdown() {
101   - logger.warn("GpsRealAnalyse shutdown!!");
102   - threadPool.shutdownNow();
103   - long len = count.getCount();
104   - for (int i = 0; i < len; i++) {
105   - count.countDown();
106   - }
107   -
108   - threadPool = Executors.newFixedThreadPool(100);
109   - }
110   -
111   - static GpsComp comp = new GpsComp();
112   -
113 85 public class SignalHandleThread implements Runnable {
114 86  
115 87 List<GpsEntity> list;
... ... @@ -122,31 +94,18 @@ public class GpsRealAnalyse {
122 94  
123 95 @Override
124 96 public void run() {
125   -
126 97 try {
127   - Collections.sort(list, comp);
128 98 for (GpsEntity gps : list) {
129   - try {
130   - //是否有任务
131   - boolean task;
132   - CircleQueue<GpsEntity> prevs = GeoCacheData.getGps(gps.getNbbm());
133   - //掉线处理
134   - offlineSignalHandle.handle(gps, prevs);
135   - //状态处理
136   - task = correctSignalHandle.handle(gps, prevs);
137   - //场,站内外判断
138   - stationInsideHandle.handle(gps, prevs);
139   - //异常判定(越界/超速)
140   - abnormalStateHandle.handle(gps, prevs);
141   -
142   - if (!task)
143   - continue; //无任务的,到这里就结束
144   -
145   - //反向处理
146   - reverseSignalHandle.handle(gps, prevs);
147   - //进出站动作处理
148   - inOutStationSignalHandle.handle(gps, prevs);
149   - GeoCacheData.putGps(gps);
  99 + try{
  100 + gpsStateProcess.process(gps);//状态处理
  101 + stationInsideProcess.process(gps);//场站内外判定
  102 + reverseRouteProcess.process(gps);//反向路由处理
  103 + abnormalStateProcess.process(gps);//超速越界
  104 +
  105 + inStationProcess.process(gps);//进站
  106 + outStationProcess.process(gps);//出站
  107 +
  108 + GpsCacheData.putGps(gps);//历史gps缓存
150 109 }catch (Exception e){
151 110 logger.error("", e);
152 111 }
... ... @@ -158,11 +117,19 @@ public class GpsRealAnalyse {
158 117 }
159 118 }
160 119  
161   - public static class GpsComp implements Comparator<GpsEntity> {
  120 + static class MyUncaughtExceptionHandler implements Thread.UncaughtExceptionHandler {
  121 + @Override
  122 + public void uncaughtException(Thread t, Throwable e) {
  123 + logger.error("caught " , e);
  124 + }
  125 + }
162 126  
  127 + static class HandlerThreadFactory implements ThreadFactory {
163 128 @Override
164   - public int compare(GpsEntity g1, GpsEntity g2) {
165   - return g1.getTimestamp().compareTo(g2.getTimestamp());
  129 + public Thread newThread(Runnable r) {
  130 + Thread t = new Thread(r);
  131 + t.setUncaughtExceptionHandler(new MyUncaughtExceptionHandler());
  132 + return t;
166 133 }
167 134 }
168 135 }
... ...
src/main/java/com/bsth/data/gpsdata/GpsRealData.java renamed to src/main/java/com/bsth/data/gpsdata_v2/GpsRealData.java
1   -package com.bsth.data.gpsdata;
  1 +package com.bsth.data.gpsdata_v2;
2 2  
3 3 import com.bsth.data.BasicData;
4 4 import com.bsth.data.forecast.ForecastRealServer;
  5 +import com.bsth.data.gpsdata_v2.entity.GpsEntity;
5 6 import com.bsth.data.schedule.DayOfSchedule;
6 7 import com.bsth.entity.realcontrol.ScheduleRealInfo;
7 8 import com.google.common.collect.TreeMultimap;
... ... @@ -130,7 +131,7 @@ public class GpsRealData {
130 131 for (String device : set) {
131 132 gps = gpsMap.get(device);
132 133 //过滤异常GPS数据
133   - if (gps == null || gps.isIncomplete())
  134 + if (gps == null || StringUtils.isBlank(gps.getNbbm()))
134 135 continue;
135 136  
136 137 sch = dayOfSchedule.execPlanMap().get(gps.getNbbm());
... ...
src/main/java/com/bsth/data/gpsdata_v2/cache/GeoCacheData.java 0 → 100644
  1 +package com.bsth.data.gpsdata_v2.cache;
  2 +
  3 +import com.bsth.data.gpsdata_v2.entity.CtLineString;
  4 +import com.bsth.data.gpsdata_v2.entity.GpsEntity;
  5 +import com.bsth.data.gpsdata_v2.entity.PreconditionGeo;
  6 +import com.bsth.data.gpsdata_v2.entity.StationRoute;
  7 +import com.bsth.data.gpsdata_v2.utils.StationRouteComp;
  8 +import com.bsth.util.Geo.Point;
  9 +import com.bsth.util.Geo.Polygon;
  10 +import com.google.common.base.Splitter;
  11 +import com.google.common.collect.ArrayListMultimap;
  12 +import org.apache.commons.lang3.StringUtils;
  13 +import org.slf4j.Logger;
  14 +import org.slf4j.LoggerFactory;
  15 +import org.springframework.beans.factory.annotation.Autowired;
  16 +import org.springframework.jdbc.core.BeanPropertyRowMapper;
  17 +import org.springframework.jdbc.core.JdbcTemplate;
  18 +import org.springframework.jdbc.core.RowMapper;
  19 +import org.springframework.stereotype.Component;
  20 +
  21 +import java.sql.ResultSet;
  22 +import java.sql.SQLException;
  23 +import java.util.*;
  24 +
  25 +/**
  26 + * 空间数据缓存
  27 + * Created by panzhao on 2017/11/15.
  28 + */
  29 +@Component
  30 +public class GeoCacheData {
  31 +
  32 + static Logger logger = LoggerFactory.getLogger(GeoCacheData.class);
  33 +
  34 + /**
  35 + * 线路路段走向
  36 + */
  37 + private static ArrayListMultimap<String, CtLineString> sectionCacheMap;
  38 + /**
  39 + * 路段编码和名称对照
  40 + */
  41 + private static Map<String, String> sectionCode2Name;
  42 + /**
  43 + * 线路站点路由
  44 + */
  45 + private static ArrayListMultimap<String, StationRoute> stationCacheMap;
  46 + /**
  47 + * 线路前置进站围栏
  48 + */
  49 + public static ArrayListMultimap<String, PreconditionGeo> premiseGeoMap;
  50 + /**
  51 + * 线路_上下行_站点编码 ——> 站点
  52 + */
  53 + private static Map<String, StationRoute> routeCodeMap;
  54 + /**
  55 + * 停车场
  56 + */
  57 + public static Map<String, Polygon> tccMap;
  58 + /**
  59 + * 线路限速信息
  60 + */
  61 + private static Map<String, Double> speedLimitMap;
  62 +
  63 + @Autowired
  64 + JdbcTemplate jdbcTemplate;
  65 +
  66 + public void loadData() {
  67 + loadStationRoutesData();
  68 + loadTccMapData();
  69 + loadSpeedLimit();
  70 +
  71 + //加载路段信息
  72 + loadRoadsData();
  73 +
  74 + //加载前置进站围栏
  75 + loadPremiseGeoData();
  76 + }
  77 +
  78 + public static List<StationRoute> getStationRoute(String lineCode, int directions) {
  79 + return stationCacheMap.get(lineCode + "_" + directions);
  80 + }
  81 +
  82 + public static StationRoute getRouteCode(GpsEntity gps) {
  83 + return routeCodeMap.get(gps.getLineId() + "_" + gps.getUpDown() + "_" + gps.getStopNo());
  84 + }
  85 +
  86 + public static Double speedLimit(String lineCode){
  87 + return speedLimitMap.get(lineCode);
  88 + }
  89 +
  90 + public static List<CtLineString> getLineStringList(GpsEntity gps){
  91 + return sectionCacheMap.get(gps.getLineId() + "_" + gps.getUpDown());
  92 + }
  93 +
  94 + private void loadStationRoutesData(){
  95 + 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";
  96 + List<StationRoute> routeList = jdbcTemplate.query(sql, new RowMapper<StationRoute>() {
  97 +
  98 + @Override
  99 + public StationRoute mapRow(ResultSet rs, int rowNum) throws SQLException {
  100 + StationRoute sRoute = new StationRoute();
  101 + sRoute.setCode(rs.getString("STATION_CODE"));
  102 + sRoute.setLineCode(rs.getString("LINE_CODE"));
  103 + sRoute.setDirections(rs.getInt("DIRECTIONS"));
  104 + sRoute.setPoint(new Point(rs.getFloat("G_LONX"), rs.getFloat("G_LATY")));
  105 + sRoute.setRadius(rs.getFloat("RADIUS"));
  106 + sRoute.setRouteSort(rs.getInt("STATION_ROUTE_CODE"));
  107 + sRoute.setMark(rs.getString("STATION_MARK"));
  108 + sRoute.setName(rs.getString("STATION_NAME"));
  109 +
  110 + String shapesType = rs.getString("SHAPES_TYPE");
  111 + //多边形电子围栏
  112 + if (StringUtils.isNotEmpty(shapesType) && shapesType.equals("d"))
  113 + sRoute.setPolygon(parsePolygon(rs.getString("G_POLYGON_GRID")));
  114 + return sRoute;
  115 + }
  116 + });
  117 +
  118 + //按线路和走向分组
  119 + if (routeList.size() > 0) {
  120 + ArrayListMultimap<String, StationRoute> tempMap = ArrayListMultimap.create();
  121 + Map<String, StationRoute> codeMap = new HashMap<>(routeList.size());
  122 + for (StationRoute sr : routeList) {
  123 + tempMap.put(sr.getLineCode() + "_" + sr.getDirections(), sr);
  124 + //站点编码 ——> 和路由顺序对照
  125 + codeMap.put(sr.getLineCode() + "_" + sr.getDirections() + "_" + sr.getCode(), sr);
  126 + }
  127 +
  128 + StationRouteComp srCom = new StationRouteComp();
  129 + //连接路由
  130 + Set<String> set = tempMap.keySet();
  131 + for (String key : set) {
  132 + Collections.sort(tempMap.get(key), srCom);
  133 + connectStationRoute(tempMap.get(key));
  134 + }
  135 + stationCacheMap = tempMap;
  136 + routeCodeMap = codeMap;
  137 + }
  138 + }
  139 +
  140 + private void loadTccMapData(){
  141 + //加载停车场数据
  142 + String sql = "select PARK_CODE, ST_AsText(G_PARK_POINT) as G_PARK_POINT from bsth_c_car_park where park_code is not null and b_park_point is not null";
  143 + List<Map<String, Object>> tccList = jdbcTemplate.queryForList(sql);
  144 + Map<String, Polygon> tccTempMap = new HashMap<>();
  145 +
  146 + Polygon polygon;
  147 + for (Map<String, Object> tMap : tccList) {
  148 +
  149 + try {
  150 + polygon = parsePolygon(tMap.get("G_PARK_POINT").toString());
  151 + tccTempMap.put(tMap.get("PARK_CODE").toString()
  152 + , polygon);
  153 + } catch (Exception e) {
  154 + logger.error("停车场:" + tMap.get("PARK_CODE"), e);
  155 + }
  156 + }
  157 + if (tccTempMap.size() > 0){
  158 + tccMap = tccTempMap;
  159 + }
  160 + }
  161 +
  162 + private void loadSpeedLimit(){
  163 + //加载线路限速信息
  164 + String sql = "select l.LINE_CODE,i.SPEEDING from bsth_c_line_information i left join bsth_c_line l on i.line=l.id where i.speed_limit is not null";
  165 + List<Map<String, Object>> speedMap = jdbcTemplate.queryForList(sql);
  166 + Map<String, Double> speedTempMap = new HashMap<>();
  167 + for (Map<String, Object> tMap : speedMap) {
  168 + try {
  169 + speedTempMap.put(tMap.get("LINE_CODE").toString(), Double.parseDouble(tMap.get("SPEEDING").toString()));
  170 + } catch (NumberFormatException e) {
  171 + logger.error("speeding is null...");
  172 + }
  173 + }
  174 + speedLimitMap = speedTempMap;
  175 + }
  176 +
  177 + private void loadRoadsData() {
  178 + //加载线路下路段空间数据
  179 + String sql = "select r.LINE_CODE,r.SECTION_CODE,r.SECTIONROUTE_CODE,s.SECTION_NAME,ST_AsText(s.GSECTION_VECTOR) as GSECTION_VECTOR, r.DIRECTIONS, s.CROSES_ROAD from bsth_c_sectionroute r INNER JOIN bsth_c_section s on r.section=s.id where r.destroy=0 and GSECTION_VECTOR is not null order by line_code,directions,sectionroute_code";
  180 + List<Map<String, Object>> secList = jdbcTemplate.queryForList(sql);
  181 +
  182 + String polygonStr, key;
  183 + String[] coords;
  184 + int i, len;
  185 + ArrayListMultimap<String, CtLineString> sectionCacheTempMap = ArrayListMultimap.create();
  186 + String[] temps1, temps2;
  187 + CtLineString lineString;
  188 + for (Map<String, Object> tMap : secList) {
  189 + //空间数据映射
  190 + polygonStr = tMap.get("GSECTION_VECTOR").toString();
  191 + key = tMap.get("LINE_CODE") + "_" + tMap.get("DIRECTIONS");
  192 +
  193 + coords = polygonStr.substring(11, polygonStr.length() - 1).split(",");
  194 + len = coords.length - 1;
  195 + //每2个点连一条线
  196 + for(i = 0; i < len; i ++){
  197 + temps1 = coords[i].split(" ");
  198 + temps2 = coords[i + 1].split(" ");
  199 +
  200 + lineString = new CtLineString();
  201 + lineString.setS(new Point(Float.parseFloat(temps1[0]), Float.parseFloat(temps1[1])));
  202 + lineString.setE(new Point(Float.parseFloat(temps2[0]), Float.parseFloat(temps2[1])));
  203 +
  204 + sectionCacheTempMap.put(key, lineString);
  205 + }
  206 + }
  207 +
  208 + if(sectionCacheTempMap.size() > 0)
  209 + sectionCacheMap = sectionCacheTempMap;
  210 +
  211 + Map<String, String> sectionCode2NameTemp = new HashMap<>();
  212 +
  213 + //加载全量路段编码和名称对照
  214 + sql = "select SECTION_CODE,SECTION_NAME,CROSES_ROAD from bsth_c_section";
  215 + secList = jdbcTemplate.queryForList(sql);
  216 + String name = null, code;
  217 + for (Map<String, Object> tMap : secList) {
  218 + if(tMap.get("CROSES_ROAD") != null && StringUtils.isNotEmpty(tMap.get("CROSES_ROAD").toString()))
  219 + name = tMap.get("CROSES_ROAD").toString();
  220 + else if(tMap.get("SECTION_NAME") != null && StringUtils.isNotEmpty(tMap.get("SECTION_NAME").toString()))
  221 + name = tMap.get("SECTION_NAME").toString();
  222 +
  223 + code = tMap.get("SECTION_CODE").toString();
  224 + sectionCode2NameTemp.put(code, name);
  225 + }
  226 + if(sectionCode2NameTemp.size() > 0)
  227 + sectionCode2Name = sectionCode2NameTemp;
  228 + }
  229 +
  230 + private void loadPremiseGeoData() {
  231 + ArrayListMultimap<String, PreconditionGeo> premiseGeoMapCopy = ArrayListMultimap.create();
  232 +
  233 + String sql = "select * from bsth_f_geo_premise";
  234 + List<PreconditionGeo> list = jdbcTemplate.query(sql, BeanPropertyRowMapper.newInstance(PreconditionGeo.class));
  235 +
  236 + List<String> coordList;
  237 + String[] cs;
  238 + Point point;
  239 + List<Point> ps;
  240 + StationRoute sr;
  241 + for(PreconditionGeo p : list){
  242 + try{
  243 + sr = routeCodeMap.get(p.getLineCode()+"_"+p.getUpDown()+"_"+p.getStationCode());
  244 + p.setOrder(sr.getRouteSort());
  245 + //polygon
  246 + ps = new ArrayList<>();
  247 + coordList = Splitter.on(",").trimResults().splitToList(p.getCoords());
  248 + for(String c : coordList){
  249 + cs = c.split(" ");
  250 + point = new Point(Double.parseDouble(cs[0]), Double.parseDouble(cs[1]));
  251 + ps.add(point);
  252 + }
  253 +
  254 + p.setPolygon(new Polygon(ps));
  255 +
  256 + sr.setPremise(true);
  257 + //按线路,走向分组
  258 + premiseGeoMapCopy.put(p.getLineCode()+"_"+p.getUpDown(), p);
  259 + }catch (Exception e){
  260 + logger.error("", e);
  261 + }
  262 + }
  263 +
  264 + //排序
  265 + Set<String> ks = premiseGeoMapCopy.keySet();
  266 + PreconditionGeoComp comp = new PreconditionGeoComp();
  267 + for(String k : ks){
  268 + Collections.sort(premiseGeoMapCopy.get(k), comp);
  269 + }
  270 +
  271 + premiseGeoMap = premiseGeoMapCopy;
  272 + }
  273 +
  274 + public Polygon parsePolygon(String polygonStr) {
  275 + String[] coords = polygonStr.substring(9, polygonStr.length() - 2).split(","), temps;
  276 +
  277 + List<Point> cds = new ArrayList<>(coords.length);
  278 + int len = coords.length;
  279 + for (int i = 0; i < len; i++) {
  280 + temps = coords[i].split(" ");
  281 + cds.add(new Point(Float.parseFloat(temps[1]), Float.parseFloat(temps[0])));
  282 + }
  283 + return new Polygon(cds);
  284 + }
  285 +
  286 + private void connectStationRoute(List<StationRoute> list) {
  287 + int size = list.size();
  288 + StationRoute sr = null;
  289 + for (int i = 0; i < size; i++) {
  290 + sr = list.get(i);
  291 + //上一个
  292 + if (i > 0)
  293 + sr.setPrve(list.get(i - 1));
  294 + //下一个
  295 + if (i < size - 1)
  296 + sr.setNext(list.get(i + 1));
  297 + }
  298 + }
  299 +
  300 + private static class PreconditionGeoComp implements Comparator<PreconditionGeo>{
  301 +
  302 + @Override
  303 + public int compare(PreconditionGeo p1, PreconditionGeo p2) {
  304 + return p1.getOrder() - p2.getOrder();
  305 + }
  306 + }
  307 +
  308 + public static Map<String, String> sectionCode2NameMap(){
  309 + return sectionCode2Name;
  310 + }
  311 +}
... ...
src/main/java/com/bsth/data/gpsdata_v2/cache/GpsCacheData.java 0 → 100644
  1 +package com.bsth.data.gpsdata_v2.cache;
  2 +
  3 +import com.bsth.data.gpsdata_v2.entity.GpsEntity;
  4 +import com.bsth.data.gpsdata_v2.entity.StationRoute;
  5 +import com.bsth.data.gpsdata_v2.entity.trail.GpsExecTrail;
  6 +import com.bsth.data.gpsdata_v2.utils.CircleQueue;
  7 +import com.google.common.collect.ArrayListMultimap;
  8 +import org.slf4j.Logger;
  9 +import org.slf4j.LoggerFactory;
  10 +
  11 +import java.util.*;
  12 +
  13 +/**
  14 + * gps 数据缓存
  15 + * Created by panzhao on 2017/11/15.
  16 + */
  17 +public class GpsCacheData {
  18 +
  19 + /**
  20 + * 每辆车缓存最后300条gps
  21 + */
  22 + private static final int CACHE_SIZE = 300;
  23 + private static Map<String, CircleQueue<GpsEntity>> gpsCacheMap = new HashMap<>();
  24 +
  25 + /**
  26 + * 车辆执行班次的详细 进出站数据
  27 + */
  28 + private static ArrayListMultimap<String, GpsExecTrail> trailListMultimap = ArrayListMultimap.create();
  29 +
  30 + static Logger logger = LoggerFactory.getLogger(GpsCacheData.class);
  31 +
  32 + public static CircleQueue<GpsEntity> getGps(String device) {
  33 + return gpsCacheMap.get(device);
  34 + }
  35 +
  36 + public static GpsExecTrail gpsExecTrail(String nbbm){
  37 + List<GpsExecTrail> list = trailListMultimap.get(nbbm);
  38 +
  39 + GpsExecTrail trail;
  40 + if(null == list || list.size() == 0
  41 + || list.get(list.size() - 1).isEnd()){
  42 + trail = new GpsExecTrail();
  43 +
  44 + trailListMultimap.put(nbbm, trail);
  45 + }
  46 + else{
  47 + trail = list.get(list.size() - 1);
  48 + }
  49 +
  50 + return trail;
  51 + }
  52 +
  53 + public static void out(GpsEntity gps){
  54 + GpsExecTrail trail = gpsExecTrail(gps.getNbbm());
  55 + trail.getSrs().add(gps);
  56 +
  57 + }
  58 +
  59 + public static void in(GpsEntity gps, boolean end){
  60 + GpsExecTrail trail = gpsExecTrail(gps.getNbbm());
  61 + trail.getSrs().add(gps);
  62 + trail.setEnd(end);
  63 + }
  64 +
  65 + public static GpsEntity getPrev(GpsEntity gps){
  66 + CircleQueue<GpsEntity> queue = gpsCacheMap.get(gps.getDeviceId());
  67 + if(queue != null)
  68 + return queue.getTail();
  69 + return null;
  70 + }
  71 +
  72 + public static void putGps(GpsEntity gps) {
  73 + CircleQueue<GpsEntity> queue = gpsCacheMap.get(gps.getDeviceId());
  74 + if (queue == null) {
  75 + queue = new CircleQueue<>(CACHE_SIZE);
  76 + gpsCacheMap.put(gps.getDeviceId(), queue);
  77 + }
  78 + queue.add(gps);
  79 + }
  80 +
  81 + public static void clear(String deviceId) {
  82 + try {
  83 + CircleQueue<GpsEntity> queue = gpsCacheMap.get(deviceId);
  84 + if (queue != null)
  85 + queue.clear();
  86 + } catch (Exception e) {
  87 + logger.error("", e);
  88 + }
  89 + }
  90 +
  91 + public static StationRoute prevStation(GpsEntity gps) {
  92 + List<GpsExecTrail> trails = trailListMultimap.get(gps.getNbbm());
  93 + if(null == trails || trails.size() == 0)
  94 + return null;
  95 +
  96 + GpsEntity prev;
  97 + for(int i = trails.size() - 1; i > 0; i--){
  98 + prev = trails.get(i).getSrs().peekLast();
  99 +
  100 + if(prev != null){
  101 + return GeoCacheData.getRouteCode(prev);
  102 + }
  103 + }
  104 + return null;
  105 + }
  106 +
  107 + public static List<StationRoute> prevMultiStation(GpsEntity gps) {
  108 + List<StationRoute> rs = new ArrayList<>();
  109 + List<GpsExecTrail> trails = trailListMultimap.get(gps.getNbbm());
  110 + if(null == trails || trails.size() == 0)
  111 + return null;
  112 +
  113 + for(int i = trails.size() - 1; i > 0; i--){
  114 + rs.addAll(searchLinked(trails.get(i).getSrs(), gps.getUpDown()));
  115 + if(rs.size() > 3)
  116 + break;
  117 + }
  118 + return rs;
  119 + }
  120 +
  121 + private static List<StationRoute> searchLinked(LinkedList<GpsEntity> list, int upDown){
  122 + List<StationRoute> rs = new ArrayList<>();
  123 + Iterator<GpsEntity> iterator = list.iterator();
  124 + GpsEntity gps;
  125 + int prevCode=0;
  126 + while (iterator.hasNext()){
  127 + gps = iterator.next();
  128 + if(gps.getInstation()!=1)
  129 + continue;
  130 +
  131 + if(gps.getUpDown() != upDown)
  132 + break;
  133 +
  134 + if(gps.getStation().getRouteSort() != prevCode)
  135 + rs.add(gps.getStation());
  136 +
  137 + prevCode = gps.getStation().getRouteSort();
  138 +
  139 + if(rs.size() >= 3)
  140 + break;
  141 + }
  142 + return rs;
  143 + }
  144 +}
... ...
src/main/java/com/bsth/data/gpsdata_v2/entity/CtLineString.java 0 → 100644
  1 +package com.bsth.data.gpsdata_v2.entity;
  2 +
  3 +import com.bsth.util.Geo.Point;
  4 +
  5 +import java.util.List;
  6 +
  7 +/**
  8 + * Created by panzhao on 2017/11/15.
  9 + */
  10 +public class CtLineString {
  11 +
  12 + public CtLineString(){}
  13 + public CtLineString(List<Point> ps){
  14 + s = ps.get(0);
  15 + e = ps.get(1);
  16 + }
  17 +
  18 + Point s;
  19 +
  20 + Point e;
  21 +
  22 + public Point getS() {
  23 + return s;
  24 + }
  25 +
  26 + public void setS(Point s) {
  27 + this.s = s;
  28 + }
  29 +
  30 + public Point getE() {
  31 + return e;
  32 + }
  33 +
  34 + public void setE(Point e) {
  35 + this.e = e;
  36 + }
  37 +}
... ...
src/main/java/com/bsth/data/gpsdata/GpsEntity.java renamed to src/main/java/com/bsth/data/gpsdata_v2/entity/GpsEntity.java
1   -package com.bsth.data.gpsdata;
  1 +package com.bsth.data.gpsdata_v2.entity;
2 2  
3   -import com.bsth.data.gpsdata.arrival.entity.StationRoute;
4 3 import com.fasterxml.jackson.annotation.JsonIgnore;
5 4  
6 5 /**
... ... @@ -66,9 +65,6 @@ public class GpsEntity implements Cloneable{
66 65  
67 66 /** 当前执行班次ID */
68 67 private Long schId;
69   -
70   - /** 是否是不完整的数据 */
71   - private boolean incomplete;
72 68  
73 69 private int version;
74 70  
... ... @@ -258,14 +254,6 @@ public class GpsEntity implements Cloneable{
258 254 this.abnormalStatus = abnormalStatus;
259 255 }
260 256  
261   - public boolean isIncomplete() {
262   - return incomplete;
263   - }
264   -
265   - public void setIncomplete(boolean incomplete) {
266   - this.incomplete = incomplete;
267   - }
268   -
269 257 public double getOutOfBoundDistance() {
270 258 return outOfBoundDistance;
271 259 }
... ...
src/main/java/com/bsth/data/gpsdata/arrival/precondition/entity/PreconditionGeo.java renamed to src/main/java/com/bsth/data/gpsdata_v2/entity/PreconditionGeo.java
1   -package com.bsth.data.gpsdata.arrival.precondition.entity;
  1 +package com.bsth.data.gpsdata_v2.entity;
2 2  
3 3 import com.bsth.util.Geo.Polygon;
4 4  
... ...
src/main/java/com/bsth/data/gpsdata/arrival/entity/StationRoute.java renamed to src/main/java/com/bsth/data/gpsdata_v2/entity/StationRoute.java
1   -package com.bsth.data.gpsdata.arrival.entity;
  1 +package com.bsth.data.gpsdata_v2.entity;
2 2  
3   -import com.vividsolutions.jts.geom.Point;
4   -import com.vividsolutions.jts.geom.Polygon;
  3 +import com.bsth.util.Geo.Point;
  4 +import com.bsth.util.Geo.Polygon;
5 5  
6 6 /**
7 7 * Created by panzhao on 2016/12/23.
... ...
src/main/java/com/bsth/data/gpsdata_v2/entity/trail/GpsExecTrail.java 0 → 100644
  1 +package com.bsth.data.gpsdata_v2.entity.trail;
  2 +
  3 +import com.bsth.data.gpsdata_v2.entity.GpsEntity;
  4 +
  5 +import java.util.LinkedList;
  6 +
  7 +/**
  8 + * GPS 班次执行轨迹,过程数据
  9 + * Created by panzhao on 2017/11/16.
  10 + */
  11 +public class GpsExecTrail {
  12 +
  13 + /**
  14 + * 执行的班次ID
  15 + */
  16 + private Long schId;
  17 +
  18 + /**
  19 + * 实际经过的站点路由
  20 + */
  21 + private LinkedList<GpsEntity> srs = new LinkedList<>();
  22 +
  23 + /**
  24 + * 车辆编码
  25 + */
  26 + private String nbbm;
  27 +
  28 + /**
  29 + * 是否结束
  30 + */
  31 + private boolean end;
  32 +
  33 + public Long getSchId() {
  34 + return schId;
  35 + }
  36 +
  37 + public void setSchId(Long schId) {
  38 + this.schId = schId;
  39 + }
  40 +
  41 + public LinkedList<GpsEntity> getSrs() {
  42 + return srs;
  43 + }
  44 +
  45 + public void setSrs(LinkedList<GpsEntity> srs) {
  46 + this.srs = srs;
  47 + }
  48 +
  49 + public String getNbbm() {
  50 + return nbbm;
  51 + }
  52 +
  53 + public void setNbbm(String nbbm) {
  54 + this.nbbm = nbbm;
  55 + }
  56 +
  57 + public boolean isEnd() {
  58 + return end;
  59 + }
  60 +
  61 + public void setEnd(boolean end) {
  62 + this.end = end;
  63 + }
  64 +}
... ...
src/main/java/com/bsth/data/gpsdata/arrival/handlers/AbnormalStateHandle.java renamed to src/main/java/com/bsth/data/gpsdata_v2/handlers/AbnormalStateProcess.java
1   -package com.bsth.data.gpsdata.arrival.handlers;
2   -
3   -import com.bsth.data.gpsdata.GpsEntity;
4   -import com.bsth.data.gpsdata.arrival.GeoCacheData;
5   -import com.bsth.data.gpsdata.arrival.SignalHandle;
6   -import com.bsth.data.gpsdata.arrival.utils.CircleQueue;
7   -import com.bsth.data.gpsdata.arrival.utils.GeoUtils;
8   -import com.vividsolutions.jts.geom.Coordinate;
9   -import com.vividsolutions.jts.geom.GeometryFactory;
10   -import com.vividsolutions.jts.geom.LineString;
11   -import com.vividsolutions.jts.geom.Point;
  1 +package com.bsth.data.gpsdata_v2.handlers;
  2 +
  3 +import com.bsth.data.gpsdata_v2.cache.GeoCacheData;
  4 +import com.bsth.data.gpsdata_v2.entity.CtLineString;
  5 +import com.bsth.data.gpsdata_v2.entity.GpsEntity;
  6 +import com.bsth.data.gpsdata_v2.utils.GeoUtils;
  7 +import com.bsth.util.Geo.Point;
12 8 import org.springframework.stereotype.Component;
13 9  
14 10 import java.util.List;
15 11  
16 12 /**
17   - * GPS异常状态判定 (越界/超速)
18   - * Created by panzhao on 2017/1/10.
  13 + * 越界/超速 判断
  14 + * Created by panzhao on 2017/11/16.
19 15 */
20 16 @Component
21   -public class AbnormalStateHandle extends SignalHandle{
  17 +public class AbnormalStateProcess {
22 18  
23   - //默认限速
  19 + /**
  20 + * 默认限速
  21 + */
24 22 private static final double DEFAULT_SPEED_LIMIT = 60;
25   - //越界阈值
  23 + /**
  24 + * 越界阈值
  25 + */
26 26 private static final double OUT_BOUNDS_THRESHOLD = 100;
27 27  
28   - GeometryFactory geometryFactory = new GeometryFactory();
29   -
30   - @Override
31   - public boolean handle(GpsEntity gps, CircleQueue<GpsEntity> prevs) {
32 28  
  29 + public void process(GpsEntity gps) {
33 30 if(isOffline(gps))
34   - return false;
  31 + return;
35 32  
36 33 if(overspeed(gps))
37   - return true;
  34 + return;
38 35  
39 36 if(outOfBounds((gps)))
40   - return true;
  37 + return;
  38 + }
41 39  
42   - return false;
  40 + private boolean isOffline(GpsEntity gps){
  41 + return gps.getAbnormalStatus() != null && gps.getAbnormalStatus().equals("offline");
43 42 }
44 43  
  44 +
45 45 /**
46 46 * 是否超速
47 47 * @param gps
48 48 * @return
49 49 */
50   - public boolean overspeed(GpsEntity gps){
  50 + private boolean overspeed(GpsEntity gps){
51 51 double maxSpeed = DEFAULT_SPEED_LIMIT;
52 52 if(GeoCacheData.speedLimit(gps.getLineId()) != null)
53 53 maxSpeed = GeoCacheData.speedLimit(gps.getLineId());
... ... @@ -59,24 +59,25 @@ public class AbnormalStateHandle extends SignalHandle{
59 59 return false;
60 60 }
61 61  
  62 +
62 63 /**
63 64 * 是否越界
64 65 * @param gps
65 66 * @return
66 67 */
67 68 public boolean outOfBounds(GpsEntity gps){
68   - //只处理电子围栏外的车
  69 + //只处理场站外的车
69 70 if(gps.getInstation() != 0){
70 71 return false;
71 72 }
72 73  
73   - List<LineString> list = GeoCacheData.getLineStringList(gps);
74   - Point point = geometryFactory.createPoint(new Coordinate(gps.getLat(), gps.getLon()));
  74 + List<CtLineString> list = GeoCacheData.getLineStringList(gps);
  75 + Point point = new Point(gps.getLon(), gps.getLat());
75 76  
76 77 double min = -1, distance;
77 78  
78   - for(LineString lineString : list){
79   - distance = GeoUtils.getDistanceFromLine(lineString, point);
  79 + for(CtLineString lineString : list){
  80 + distance = GeoUtils.getDistanceFromLine(lineString.getS(),lineString.getE(), point);
80 81  
81 82 if(min == -1 || min > distance)
82 83 min = distance;
... ...
src/main/java/com/bsth/data/gpsdata_v2/handlers/GpsStateProcess.java 0 → 100644
  1 +package com.bsth.data.gpsdata_v2.handlers;
  2 +
  3 +import com.bsth.data.gpsdata_v2.entity.GpsEntity;
  4 +import com.bsth.data.gpsdata_v2.status_manager.GpsStatusManager;
  5 +import com.bsth.data.schedule.DayOfSchedule;
  6 +import com.bsth.entity.realcontrol.ScheduleRealInfo;
  7 +import org.springframework.beans.factory.annotation.Autowired;
  8 +import org.springframework.stereotype.Component;
  9 +
  10 +/**
  11 + * GPS 状态处理
  12 + * Created by panzhao on 2017/11/15.
  13 + */
  14 +@Component
  15 +public class GpsStateProcess {
  16 +
  17 + @Autowired
  18 + DayOfSchedule dayOfSchedule;
  19 +
  20 + @Autowired
  21 + GpsStatusManager gpsStatusManager;
  22 +
  23 + public void process(GpsEntity gps){
  24 + //在执行的任务
  25 + ScheduleRealInfo sch = dayOfSchedule.executeCurr(gps.getNbbm());
  26 +
  27 + if(null == sch)
  28 + return;
  29 +
  30 + byte upDown = Byte.parseByte(sch.getXlDir());
  31 +
  32 + if(gps.getUpDown() != upDown){
  33 + gps.setUpDown(upDown);//修正走向
  34 + }
  35 +
  36 + if((!gps.isService() || gps.getUpDown() != upDown) &&
  37 + !dayOfSchedule.emptyService(sch)){
  38 + //下发指令纠正车载的 营运状态 和 走向
  39 + gpsStatusManager.changeServiceState(gps.getNbbm(), upDown, 0, "同步@系统");
  40 + }
  41 +
  42 + if(!sch.getXlBm().equals(gps.getLineId())){
  43 + //切换车载的 线路编码
  44 + gpsStatusManager.changeLine(gps.getNbbm(), sch.getXlBm(), "同步@系统");
  45 + }
  46 + }
  47 +}
... ...
src/main/java/com/bsth/data/gpsdata_v2/handlers/InStationProcess.java 0 → 100644
  1 +package com.bsth.data.gpsdata_v2.handlers;
  2 +
  3 +import com.bsth.data.LineConfigData;
  4 +import com.bsth.data.gpsdata_v2.cache.GeoCacheData;
  5 +import com.bsth.data.gpsdata_v2.cache.GpsCacheData;
  6 +import com.bsth.data.gpsdata_v2.entity.GpsEntity;
  7 +import com.bsth.data.gpsdata_v2.entity.StationRoute;
  8 +import com.bsth.data.gpsdata_v2.status_manager.GpsStatusManager;
  9 +import com.bsth.data.gpsdata_v2.utils.GeoUtils;
  10 +import com.bsth.data.msg_queue.DirectivePushQueue;
  11 +import com.bsth.data.schedule.DayOfSchedule;
  12 +import com.bsth.data.schedule.late_adjust.LateAdjustHandle;
  13 +import com.bsth.entity.realcontrol.LineConfig;
  14 +import com.bsth.entity.realcontrol.ScheduleRealInfo;
  15 +import com.bsth.websocket.handler.SendUtils;
  16 +import org.apache.commons.lang3.StringUtils;
  17 +import org.slf4j.Logger;
  18 +import org.slf4j.LoggerFactory;
  19 +import org.springframework.beans.factory.annotation.Autowired;
  20 +import org.springframework.stereotype.Component;
  21 +
  22 +import java.util.List;
  23 +
  24 +/**
  25 + * 车辆到站处理程序
  26 + * Created by panzhao on 2017/11/16.
  27 + */
  28 +@Component
  29 +public class InStationProcess {
  30 +
  31 + @Autowired
  32 + DayOfSchedule dayOfSchedule;
  33 +
  34 + @Autowired
  35 + LineConfigData lineConfigData;
  36 +
  37 + @Autowired
  38 + SendUtils sendUtils;
  39 +
  40 + @Autowired
  41 + GpsStatusManager gpsStatusManager;
  42 +
  43 + Logger logger = LoggerFactory.getLogger(this.getClass());
  44 +
  45 + public void process(GpsEntity gps){
  46 + GpsEntity prev = GpsCacheData.getPrev(gps);
  47 +
  48 + if(isInsideStation(gps) &&
  49 + (prev == null || !isInsideStation(prev) || !prev.getStopNo().equals(gps.getStopNo()))){
  50 + inStation(gps, prev); //进站
  51 + }
  52 + }
  53 +
  54 + private boolean isInsideStation(GpsEntity gps){
  55 + return gps.getInstation() >= 1;
  56 + }
  57 +
  58 + /**
  59 + * 进站
  60 + * @param gps
  61 + * @param prev
  62 + */
  63 + private void inStation(GpsEntity gps, GpsEntity prev){
  64 + boolean flow=true;
  65 + //要经过一个中途站才能进
  66 + StationRoute s = GpsCacheData.prevStation(gps);
  67 + List<StationRoute> routes = GeoCacheData.getStationRoute(gps.getLineId(), gps.getUpDown());
  68 + if(routes.size() > 3 && null != s && s.getName().equals(gps.getStation().getName())){
  69 + logger.info("没有进中途站,拒绝进站... -" + gps.getNbbm() + " -time:" + gps.getTimestamp());
  70 + flow = false;
  71 + }
  72 +
  73 +
  74 + ScheduleRealInfo sch = dayOfSchedule.executeCurr(gps.getNbbm());
  75 + boolean isEnd=false;
  76 +
  77 + //进终点
  78 + if(flow && null != sch && sch.getZdzCode().equals(gps.getStopNo())){
  79 + inEndStation(sch, gps);
  80 + isEnd = true;
  81 + }
  82 +
  83 + GpsCacheData.in(gps, isEnd);
  84 + }
  85 +
  86 + /**
  87 + * 进班次终点
  88 + * @param gps
  89 + */
  90 + private void inEndStation(ScheduleRealInfo sch, GpsEntity gps) {
  91 + String nbbm = sch.getClZbh();
  92 + //校验进站前置约束
  93 + if(!validInPremise(gps))
  94 + return;
  95 +
  96 + //实达时间不覆盖
  97 + if(StringUtils.isNotEmpty(sch.getZdsjActual()))
  98 + return;
  99 +
  100 + //应用到离站缓冲区设置参数
  101 + long rsT = lineConfigData.applyIn(sch, gps.getTimestamp());
  102 +
  103 + sch.setZdsjActualAll(rsT);
  104 + sch.setSiginCompate(2);
  105 + //通知误点停靠程序,有车辆到站
  106 + LateAdjustHandle.carArrive(gps);
  107 +
  108 + //持久化
  109 + dayOfSchedule.save(sch);
  110 +
  111 + //车辆的下一个班次
  112 + ScheduleRealInfo next = dayOfSchedule.next(sch);
  113 + if(next != null){
  114 + dayOfSchedule.addExecPlan(next);
  115 + inStationAndInPark(sch, next);//进站既进场
  116 + }
  117 +
  118 + //路牌的下一个班次,页面显示起点实际到达时间
  119 + ScheduleRealInfo lpNext = dayOfSchedule.nextByLp(sch);
  120 + if(lpNext != null){
  121 + lpNext.setQdzArrDatesj(sch.getZdsjActual());
  122 + }
  123 +
  124 + //已完成班次数
  125 + int doneSum = dayOfSchedule.doneSum(nbbm);
  126 + //webSocket
  127 + sendUtils.sendZdsj(sch, lpNext, doneSum);
  128 +
  129 + logger.info("车辆:" + nbbm + " 班次:" + sch.getDfsj() + "到终点, 时间:" + sch.getZdsjActual());
  130 +
  131 + //清除车辆误点调整监听
  132 + LateAdjustHandle.remove(nbbm);
  133 +
  134 + //将gps转换成下一个班次走向的站内信号(应对只有一个站内信号 即 发出时)
  135 + transformUpDown(gps, next);
  136 +
  137 + //下发调度指令
  138 + DirectivePushQueue.put6002(next, doneSum, "到站@系统");
  139 +
  140 + //套跑 -下发线路切换指令
  141 + if(null != next && !next.getXlBm().equals(sch.getXlBm())){
  142 + gpsStatusManager.changeLine(next.getClZbh(), next.getXlBm(), "套跑@系统");
  143 + }
  144 +
  145 + if(null == next && gps.isService())
  146 + nonService(sch, "结束@系统");//班次结束
  147 + else if(dayOfSchedule.emptyService(next))
  148 + nonService(sch, "空驶@系统");//下一班非营运
  149 + }
  150 +
  151 + /**
  152 + * 校验进站前置约束
  153 + * @param gps
  154 + * @return
  155 + */
  156 + private boolean validInPremise(GpsEntity gps) {
  157 + StationRoute sr = gps.getStation();
  158 + if(null == sr || !sr.isPremise())
  159 + return true;
  160 +
  161 + String premiseCode = gps.getPremiseCode();
  162 +
  163 + if(StringUtils.isNotEmpty(premiseCode) && premiseCode.equals(gps.getStopNo())){
  164 + logger.info("满足前置进站约束 " + premiseCode);
  165 + return true;
  166 + }
  167 + else{
  168 + logger.info(gps.getNbbm() + " not premiseCode 不满足前置进站约束 " + premiseCode);
  169 + }
  170 + return false;
  171 + }
  172 +
  173 + /**
  174 + * 进站既进场
  175 + * @param sch
  176 + */
  177 + private void inStationAndInPark(ScheduleRealInfo sch, ScheduleRealInfo next){
  178 + LineConfig config = lineConfigData.get(sch.getXlBm());
  179 + //限定出站既出场的停车场
  180 + String park = config.getTwinsPark();
  181 + boolean limitPark = StringUtils.isNotEmpty(park);
  182 +
  183 +
  184 + if (next.getBcType().equals("in") && config.getOutConfig() == 2 && isEmptyMileage(next)
  185 + && (!limitPark || park.equals(next.getZdzCode()))) {
  186 +
  187 + endSch(next, sch.getZdsjActualTime());
  188 +
  189 + sendUtils.refreshSch(next);
  190 + dayOfSchedule.save(next);
  191 +
  192 + //分班的时候,需要再跳过1个班次
  193 + next = dayOfSchedule.next(next);
  194 + if(next != null)
  195 + dayOfSchedule.addExecPlan(next);
  196 +
  197 + //进场,切换成非营运状态
  198 + nonService(sch, "进场@系统");
  199 + }
  200 + }
  201 +
  202 +
  203 + private boolean isEmptyMileage(ScheduleRealInfo sch){
  204 + return sch.getBcsj()==0 || sch.getJhlcOrig().intValue()==0;
  205 + }
  206 +
  207 +
  208 + /**
  209 + * 切换为非营运状态
  210 + * @param sch
  211 + * @param sender
  212 + */
  213 + private void nonService(ScheduleRealInfo sch, String sender){
  214 + gpsStatusManager.changeServiceState(sch.getClZbh(), sch.getXlDir(), 1, sender);
  215 + }
  216 +
  217 + private void endSch(ScheduleRealInfo sch, Long t){
  218 + sch.setFcsjActualAll(t);
  219 + sch.setZdsjActualAll(t);
  220 + }
  221 +
  222 + private void transformUpDown(GpsEntity gps, ScheduleRealInfo sch) {
  223 + if(null == sch)
  224 + return;
  225 + byte upDown = Byte.parseByte(sch.getXlDir());
  226 + //gps 切换走向
  227 + gps.setUpDown(upDown);
  228 + gps.setPremiseCode(null);
  229 +
  230 + List<StationRoute> srs = GeoCacheData.getStationRoute(sch.getXlBm(), upDown);
  231 + StationRoute station = GeoUtils.gpsInStation(gps, srs);
  232 + if (station != null) {
  233 + gps.setStopNo(station.getCode());
  234 + }
  235 + }
  236 +}
... ...
src/main/java/com/bsth/data/gpsdata_v2/handlers/OutStationProcess.java 0 → 100644
  1 +package com.bsth.data.gpsdata_v2.handlers;
  2 +
  3 +import com.bsth.data.LineConfigData;
  4 +import com.bsth.data.gpsdata_v2.cache.GpsCacheData;
  5 +import com.bsth.data.gpsdata_v2.entity.GpsEntity;
  6 +import com.bsth.data.gpsdata_v2.status_manager.GpsStatusManager;
  7 +import com.bsth.data.schedule.DayOfSchedule;
  8 +import com.bsth.data.schedule.late_adjust.LateAdjustHandle;
  9 +import com.bsth.entity.realcontrol.LineConfig;
  10 +import com.bsth.entity.realcontrol.ScheduleRealInfo;
  11 +import com.bsth.websocket.handler.SendUtils;
  12 +import org.apache.commons.lang3.StringUtils;
  13 +import org.slf4j.Logger;
  14 +import org.slf4j.LoggerFactory;
  15 +import org.springframework.beans.factory.annotation.Autowired;
  16 +import org.springframework.stereotype.Component;
  17 +
  18 +/**
  19 + * 车辆出站处理程序
  20 + * Created by panzhao on 2017/11/16.
  21 + */
  22 +@Component
  23 +public class OutStationProcess {
  24 +
  25 + @Autowired
  26 + DayOfSchedule dayOfSchedule;
  27 +
  28 + Logger logger = LoggerFactory.getLogger(this.getClass());
  29 +
  30 + @Autowired
  31 + LineConfigData lineConfigData;
  32 +
  33 + @Autowired
  34 + SendUtils sendUtils;
  35 +
  36 + @Autowired
  37 + GpsStatusManager gpsStatusManager;
  38 +
  39 + public void process(GpsEntity gps){
  40 + GpsEntity prev = GpsCacheData.getPrev(gps);
  41 + if(gps.getInstation()==0 && prev!=null && isInsideStation(prev)){
  42 + outStation(gps); //出站
  43 + }
  44 + }
  45 +
  46 + private boolean isInsideStation(GpsEntity gps){
  47 + return gps.getInstation() >= 1;
  48 + }
  49 +
  50 + /**
  51 + * 出站
  52 + * @param gps
  53 + */
  54 + private void outStation(GpsEntity gps) {
  55 + ScheduleRealInfo sch = dayOfSchedule.executeCurr(gps.getNbbm());
  56 +
  57 + //起点发车
  58 + if (null != sch && sch.getQdzCode().equals(gps.getStopNo())){
  59 + gps.setPremiseCode(null);//清除前置围栏标记
  60 +
  61 + if(StringUtils.isNotEmpty(sch.getFcsjActual())
  62 + && !outManyFit(gps, sch)){
  63 + return;//班次已经实发
  64 + }
  65 +
  66 + //应用到离站缓冲区设置参数
  67 + long rsT = lineConfigData.applyOut(sch, gps.getTimestamp());
  68 + //实发时间
  69 + sch.setFcsjActualAll(rsT);
  70 + sch.setSiginCompate(1);
  71 +
  72 + //出站既出场
  73 + outStationAndOutPark(sch);
  74 +
  75 + //webSocket
  76 + sendUtils.sendFcsj(sch);
  77 +
  78 + //持久化
  79 + dayOfSchedule.save(sch);
  80 +
  81 + //清理应发未发标记
  82 + LateAdjustHandle.remove(sch.getClZbh());
  83 +
  84 + //发车的时候,同步一下状态
  85 + if(!gps.isService() && !dayOfSchedule.emptyService(sch))
  86 + gpsStatusManager.changeServiceState(sch.getClZbh(), sch.getXlDir(), 0, "发车@系统");
  87 +
  88 + logger.info("车辆:" + sch.getClZbh() + " 班次:" + sch.getDfsj() + "发车, 时间:" + sch.getFcsjActual());
  89 + }
  90 +
  91 + GpsCacheData.out(gps);
  92 + }
  93 +
  94 + /**
  95 + * 是否是一个更合适的发车信号
  96 + * @param gps
  97 + * @param sch
  98 + * @return
  99 + */
  100 + private boolean outManyFit(GpsEntity gps, ScheduleRealInfo sch) {
  101 + LineConfig conf = lineConfigData.get(sch.getXlBm());
  102 + if(null != conf && conf.isLockFirstOutTime())
  103 + return false;
  104 +
  105 + if(StringUtils.isNotEmpty(sch.getZdsjActual()))
  106 + return false;
  107 +
  108 + long t1 = sch.getFcsjActualTime();
  109 + long t2 = gps.getTimestamp();
  110 + long c = sch.getDfsjT();
  111 +
  112 + int threshold = 1000 * 60 * 5;
  113 + if(Math.abs(t2 - c) < threshold && c - t1 > threshold){
  114 + return true;
  115 + }
  116 + return false;
  117 + }
  118 +
  119 + private void outStationAndOutPark(ScheduleRealInfo sch){
  120 + try{
  121 + LineConfig config = lineConfigData.get(sch.getXlBm());
  122 + //限定出站既出场的停车场
  123 + String park = config.getTwinsPark();
  124 + boolean limitPark = StringUtils.isNotEmpty(park);
  125 +
  126 + if (config != null && config.getOutConfig() == 2) {
  127 + //出站既出场
  128 + ScheduleRealInfo schPrev = dayOfSchedule.prev(sch);
  129 + if (isOut(schPrev) && isEmptyMileage(schPrev)
  130 + && (!limitPark || park.equals(schPrev.getQdzCode()))) {
  131 +
  132 + endSch(schPrev, sch.getFcsjActualTime());
  133 +
  134 + //起点实到
  135 + sch.setQdzArrDatesj(schPrev.getZdsjActual());
  136 +
  137 + sendUtils.refreshSch(schPrev);
  138 + dayOfSchedule.save(schPrev);
  139 + }
  140 + }
  141 + }catch (Exception e){
  142 + logger.error("", e);
  143 + }
  144 + }
  145 +
  146 + private boolean isEmptyMileage(ScheduleRealInfo sch){
  147 + return sch.getBcsj()==0 || sch.getJhlcOrig().intValue()==0;
  148 + }
  149 +
  150 + private boolean isOut(ScheduleRealInfo sch){
  151 + return sch != null && sch.getBcType().equals("out");
  152 + }
  153 +
  154 + private void endSch(ScheduleRealInfo sch, Long t){
  155 + sch.setFcsjActualAll(t);
  156 + sch.setZdsjActualAll(t);
  157 + }
  158 +}
... ...
src/main/java/com/bsth/data/gpsdata_v2/handlers/ReverseRouteProcess.java 0 → 100644
  1 +package com.bsth.data.gpsdata_v2.handlers;
  2 +
  3 +import com.bsth.data.gpsdata_v2.cache.GpsCacheData;
  4 +import com.bsth.data.gpsdata_v2.entity.GpsEntity;
  5 +import com.bsth.data.gpsdata_v2.entity.StationRoute;
  6 +import com.bsth.data.schedule.DayOfSchedule;
  7 +import com.bsth.entity.realcontrol.ScheduleRealInfo;
  8 +import org.springframework.beans.factory.annotation.Autowired;
  9 +import org.springframework.stereotype.Component;
  10 +
  11 +import java.util.List;
  12 +
  13 +/**
  14 + * 反向路由处理(进站的时候处理)
  15 + * Created by panzhao on 2017/11/20.
  16 + */
  17 +@Component
  18 +public class ReverseRouteProcess {
  19 +
  20 + private static final int REVER_THRESHOLD = 3;
  21 +
  22 + private static final long TIME_THRESHOLD = 1000 * 60 * 120;
  23 +
  24 + @Autowired
  25 + DayOfSchedule dayOfSchedule;
  26 +
  27 + public void process(GpsEntity gps){
  28 + if(reversRoute(gps)){
  29 + ScheduleRealInfo sch = dayOfSchedule.executeCurr(gps.getNbbm());
  30 + if(isInOut(sch) || !sch.getXlBm().equals(gps.getLineId()))
  31 + return;
  32 +
  33 + //next
  34 + ScheduleRealInfo next = dayOfSchedule.next(sch);
  35 + if(isInOut(next))
  36 + return;
  37 +
  38 + //跳下一个班次
  39 + if(Math.abs(next.getDfsjT() - gps.getTimestamp()) < TIME_THRESHOLD)
  40 + dayOfSchedule.addExecPlan(next);
  41 + }
  42 + }
  43 +
  44 + private boolean reversRoute(GpsEntity gps) {
  45 + if(gps.getInstation() != 1)
  46 + return false;
  47 +
  48 + int sortNo = gps.getStation().getRouteSort();
  49 + StationRoute prev = GpsCacheData.prevStation(gps);
  50 + //和上一个站点是反向
  51 + if(null != prev && sortNo < prev.getRouteSort()){
  52 +
  53 + //满足3个进站反向信号
  54 + List<StationRoute> prevs = GpsCacheData.prevMultiStation(gps);
  55 +
  56 + int count = 0;
  57 + for(StationRoute s : prevs){
  58 + if(sortNo < s.getRouteSort())
  59 + count ++;
  60 + sortNo = s.getRouteSort();
  61 + }
  62 +
  63 + if(count >= REVER_THRESHOLD)
  64 + return true;
  65 + }
  66 +
  67 + return false;
  68 + }
  69 +
  70 + private boolean isInOut(ScheduleRealInfo sch){
  71 + return sch.getBcType().equals("in") || sch.getBcType().equals("out");
  72 + }
  73 +}
... ...
src/main/java/com/bsth/data/gpsdata/arrival/handlers/StationInsideHandle.java renamed to src/main/java/com/bsth/data/gpsdata_v2/handlers/StationInsideProcess.java
1   -package com.bsth.data.gpsdata.arrival.handlers;
  1 +package com.bsth.data.gpsdata_v2.handlers;
2 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.slf4j.Logger;
10   -import org.slf4j.LoggerFactory;
  3 +import com.bsth.data.gpsdata_v2.cache.GeoCacheData;
  4 +import com.bsth.data.gpsdata_v2.cache.GpsCacheData;
  5 +import com.bsth.data.gpsdata_v2.entity.GpsEntity;
  6 +import com.bsth.data.gpsdata_v2.entity.StationRoute;
  7 +import com.bsth.data.gpsdata_v2.utils.GeoUtils;
11 8 import org.springframework.stereotype.Component;
12 9  
13 10 import java.util.List;
14 11  
15 12 /**
16   - * 站内站外判定
17   - * Created by panzhao on 2016/12/27.
  13 + * 站内 场内判定
  14 + * Created by panzhao on 2017/11/16.
18 15 */
19 16 @Component
20   -public class StationInsideHandle extends SignalHandle {
  17 +public class StationInsideProcess {
21 18  
22   - Logger logger = LoggerFactory.getLogger(this.getClass());
23   -
24   - @Override
25   - public boolean handle(GpsEntity gps, CircleQueue<GpsEntity> prevs) {
  19 + public void process(GpsEntity gps){
26 20 //是否在场内
27 21 String parkCode = GeoUtils.gpsInCarpark(gps);
  22 +
28 23 if (parkCode != null) {
29 24 gps.setInstation(2);
30 25 gps.setStopNo(parkCode);
... ... @@ -44,37 +39,18 @@ public class StationInsideHandle extends SignalHandle {
44 39 String premiseCode = GeoUtils.gpsInPremiseGeo(gps);
45 40 gps.setPremiseCode(premiseCode);
46 41  
47   - if(isNotEmpty(prevs)){
48   - try {
49   - GpsEntity prev = prevs.getTail();
50   - //继承前置围栏
51   - if(null == premiseCode && null != prev.getPremiseCode())
52   - gps.setPremiseCode(prev.getPremiseCode());
  42 + //上一个点位
  43 + GpsEntity prev = GpsCacheData.getPrev(gps);
53 44  
54   - //在场,站外
55   - if(gps.getInstation() == 0){
56   - //继承上一个点的站点编码
57   - gps.setStopNo(prev.getStopNo());
  45 + if(null != prev){
  46 + //继承前置围栏状态
  47 + if(null == premiseCode && null != prev.getPremiseCode())
  48 + gps.setPremiseCode(prev.getPremiseCode());
58 49  
59   - /*if(null == premiseCode && null != prev.getPremiseCode())
60   - gps.setPremiseCode(prev.getPremiseCode());*/
61   - }
62   - /*else if(null != gps.getPremiseCode() && !gps.getStopNo().equals(gps.getPremiseCode())){
63   - gps.setPremiseCode(null);
64   - }*/
65   - }catch (Exception e){
66   - logger.error("", e);
  50 + //在场,站外
  51 + if(gps.getInstation() == 0){
  52 + gps.setStopNo(prev.getStopNo());//继承上一个点的站点编码
67 53 }
68 54 }
69   -
70   -/*
71   - //在场,站外
72   - if(gps.getInstation() == 0 && isNotEmpty(prevs)){
73   - //继承上一个点的站点编码
74   - GpsEntity prev = prevs.getTail();
75   - gps.setStopNo(prev.getStopNo());
76   - }
77   -*/
78   - return true;
79 55 }
80 56 }
... ...
src/main/java/com/bsth/data/gpsdata_v2/load/GatewayHttpLoader.java 0 → 100644
  1 +package com.bsth.data.gpsdata_v2.load;
  2 +
  3 +import com.alibaba.fastjson.JSON;
  4 +import com.bsth.data.BasicData;
  5 +import com.bsth.data.gpsdata_v2.GpsRealData;
  6 +import com.bsth.data.gpsdata_v2.entity.GpsEntity;
  7 +import com.bsth.data.gpsdata_v2.utils.GpsDataUtils;
  8 +import com.bsth.util.ConfigUtil;
  9 +import org.apache.commons.lang3.StringUtils;
  10 +import org.apache.http.HttpEntity;
  11 +import org.apache.http.client.config.RequestConfig;
  12 +import org.apache.http.client.methods.CloseableHttpResponse;
  13 +import org.apache.http.client.methods.HttpGet;
  14 +import org.apache.http.impl.client.CloseableHttpClient;
  15 +import org.apache.http.impl.client.HttpClients;
  16 +import org.slf4j.Logger;
  17 +import org.slf4j.LoggerFactory;
  18 +import org.springframework.beans.BeansException;
  19 +import org.springframework.context.ApplicationContext;
  20 +import org.springframework.context.ApplicationContextAware;
  21 +import org.springframework.stereotype.Component;
  22 +
  23 +import java.io.BufferedReader;
  24 +import java.io.InputStreamReader;
  25 +import java.util.ArrayList;
  26 +import java.util.List;
  27 +
  28 +/**
  29 + * 从网关http 接口加载数据
  30 + * Created by panzhao on 2017/11/15.
  31 + */
  32 +@Component
  33 +public class GatewayHttpLoader implements ApplicationContextAware{
  34 +
  35 + static Logger logger = LoggerFactory.getLogger(GatewayHttpLoader.class);
  36 +
  37 + static String url;
  38 + static List<GpsEntity> list;
  39 + static CloseableHttpClient httpClient = null;
  40 + static HttpGet get;
  41 + static RequestConfig requestConfig;
  42 + static CloseableHttpResponse response;
  43 + static HttpEntity entity;
  44 + static BufferedReader br;
  45 +
  46 + static GpsRealData gpsRealData;
  47 +
  48 + static{
  49 + url = ConfigUtil.get("http.gps.real.url");
  50 + list = new ArrayList<>();
  51 + httpClient = HttpClients.createDefault();
  52 + get = new HttpGet(url);
  53 + requestConfig = RequestConfig.custom()
  54 + .setConnectTimeout(1500).setConnectionRequestTimeout(1000)
  55 + .setSocketTimeout(1500).build();
  56 + get.setConfig(requestConfig);
  57 + }
  58 +
  59 + public static List<GpsEntity> load(){
  60 + try{
  61 + if(list.size() > 0)
  62 + list.clear();
  63 +
  64 + response = httpClient.execute(get);
  65 + entity = response.getEntity();
  66 +
  67 + if(null == entity)
  68 + return list;
  69 +
  70 + br = new BufferedReader(new InputStreamReader(entity.getContent()));
  71 +
  72 + StringBuilder sb = new StringBuilder();
  73 + String str;
  74 + while ((str = br.readLine()) != null)
  75 + sb.append(str);
  76 +
  77 + list = JSON.parseArray(JSON.parseObject(sb.toString()).getString("data"), GpsEntity.class);
  78 + //过滤掉无效的点位
  79 + list = GpsDataUtils.clearInvalid(list);
  80 +
  81 + List<GpsEntity> ups = new ArrayList<>();
  82 + String nbbm;
  83 + for (GpsEntity gps : list) {
  84 + if (StringUtils.isBlank(gps.getDeviceId()))
  85 + continue;
  86 +
  87 + if (gps_equals(gpsRealData.get(gps.getDeviceId()), gps))
  88 + continue;
  89 +
  90 + nbbm = BasicData.deviceId2NbbmMap.get(gps.getDeviceId());
  91 + gps.setNbbm(nbbm);
  92 + ups.add(gps);
  93 + }
  94 + list = ups;
  95 +
  96 + if (null != response)
  97 + response.close();
  98 + }catch (Exception e){
  99 + logger.error("", e);
  100 + }
  101 + return list;
  102 + }
  103 +
  104 +
  105 + private static boolean gps_equals(GpsEntity old, GpsEntity gps){
  106 + if(old != null &&
  107 + old.getTimestamp().equals(gps.getTimestamp()) &&
  108 + old.getLat().equals(gps.getLat()) &&
  109 + old.getLon().equals(gps.getLon()))
  110 + return true;
  111 + return false;
  112 + }
  113 +
  114 + @Override
  115 + public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
  116 + gpsRealData = applicationContext.getBean(GpsRealData.class);
  117 + }
  118 +}
... ...
src/main/java/com/bsth/data/gpsdata_v2/load/SocketClientLoader.java 0 → 100644
  1 +package com.bsth.data.gpsdata_v2.load;
  2 +
  3 +import com.alibaba.fastjson.JSON;
  4 +import com.bsth.data.BasicData;
  5 +import com.bsth.data.gpsdata_v2.entity.GpsEntity;
  6 +import com.bsth.data.gpsdata_v2.utils.GpsDataUtils;
  7 +import com.bsth.util.ConfigUtil;
  8 +import org.apache.http.HttpEntity;
  9 +import org.apache.http.client.config.RequestConfig;
  10 +import org.apache.http.client.methods.CloseableHttpResponse;
  11 +import org.apache.http.client.methods.HttpGet;
  12 +import org.apache.http.impl.client.CloseableHttpClient;
  13 +import org.apache.http.impl.client.HttpClients;
  14 +import org.slf4j.Logger;
  15 +import org.slf4j.LoggerFactory;
  16 +import org.springframework.stereotype.Component;
  17 +
  18 +import java.io.BufferedReader;
  19 +import java.io.InputStreamReader;
  20 +import java.util.ArrayList;
  21 +import java.util.List;
  22 +
  23 +/**
  24 + * 从专用的socket client 加载数据
  25 + * Created by panzhao on 2017/11/15.
  26 + */
  27 +@Component
  28 +public class SocketClientLoader {
  29 +
  30 + static Logger logger = LoggerFactory.getLogger(SocketClientLoader.class);
  31 +
  32 + static String url;
  33 + static List<GpsEntity> list;
  34 + static CloseableHttpClient httpClient = null;
  35 + static HttpGet get;
  36 + static RequestConfig requestConfig;
  37 + static CloseableHttpResponse response;
  38 + static HttpEntity entity;
  39 + static BufferedReader br;
  40 +
  41 + static {
  42 + url = ConfigUtil.get("http.gps.real.cache.url");
  43 + list = new ArrayList<>();
  44 + httpClient = HttpClients.createDefault();
  45 + get = new HttpGet(url);
  46 + requestConfig = RequestConfig.custom()
  47 + .setConnectTimeout(1500).setConnectionRequestTimeout(1000)
  48 + .setSocketTimeout(1500).build();
  49 + get.setConfig(requestConfig);
  50 + }
  51 +
  52 + public static List<GpsEntity> load(){
  53 + try {
  54 + if(list.size() > 0)
  55 + list.clear();
  56 + logger.info("load start...");
  57 + response = httpClient.execute(get);
  58 + entity = response.getEntity();
  59 + if(null == entity)
  60 + return list;
  61 +
  62 + br = new BufferedReader(new InputStreamReader(entity.getContent()));
  63 + StringBuilder sb = new StringBuilder();
  64 + String str;
  65 + while ((str = br.readLine()) != null)
  66 + sb.append(str);
  67 +
  68 + list = JSON.parseArray(sb.toString(), GpsEntity.class);
  69 +
  70 + //过滤掉无效的点位
  71 + list = GpsDataUtils.clearInvalid(list);
  72 +
  73 + logger.info("load end!");
  74 + for (GpsEntity gps : list) {
  75 + gps.setNbbm(BasicData.deviceId2NbbmMap.get(gps.getDeviceId()));
  76 + }
  77 +
  78 + if (null != response)
  79 + response.close();
  80 + } catch (Exception e) {
  81 + logger.error("", e);
  82 + }
  83 +
  84 + return list;
  85 + }
  86 +}
... ...
src/main/java/com/bsth/data/gpsdata_v2/rfid/UploadRfidDataService.java 0 → 100644
  1 +package com.bsth.data.gpsdata_v2.rfid;
  2 +
  3 +import com.bsth.data.gpsdata_v2.rfid.entity.RfidInoutStation;
  4 +import com.bsth.data.gpsdata_v2.rfid.handle.RfidSignalHandle;
  5 +import org.springframework.beans.factory.annotation.Autowired;
  6 +import org.springframework.web.bind.annotation.RequestBody;
  7 +import org.springframework.web.bind.annotation.RequestMapping;
  8 +import org.springframework.web.bind.annotation.RestController;
  9 +
  10 +import java.util.List;
  11 +
  12 +/**
  13 + * RFID 数据上传入口
  14 + * Created by panzhao on 2017/11/22.
  15 + */
  16 +@RestController
  17 +@RequestMapping("/up/rfid")
  18 +public class UploadRfidDataService {
  19 +
  20 + @Autowired
  21 + RfidSignalHandle rfidSignalHandle;
  22 +
  23 + @RequestMapping("inside")
  24 + public void inside(@RequestBody List<RfidInoutStation> list) {
  25 + rfidSignalHandle.handle(list);
  26 + }
  27 +}
... ...
src/main/java/com/bsth/data/gpsdata_v2/rfid/entity/RfidInoutStation.java 0 → 100644
  1 +package com.bsth.data.gpsdata_v2.rfid.entity;
  2 +
  3 +/**
  4 + * RFID 进出数据
  5 + * Created by panzhao on 2017/11/22.
  6 + */
  7 +public class RfidInoutStation {
  8 +
  9 + private String nbbm;
  10 +
  11 + private String station;
  12 +
  13 + /**
  14 + * 0 进
  15 + * 1 出
  16 + */
  17 + private int type;
  18 +
  19 + /**
  20 + * 信号时间
  21 + */
  22 + private long t;
  23 +
  24 + public String getNbbm() {
  25 + return nbbm;
  26 + }
  27 +
  28 + public void setNbbm(String nbbm) {
  29 + this.nbbm = nbbm;
  30 + }
  31 +
  32 + public String getStation() {
  33 + return station;
  34 + }
  35 +
  36 + public void setStation(String station) {
  37 + this.station = station;
  38 + }
  39 +
  40 + public int getType() {
  41 + return type;
  42 + }
  43 +
  44 + public void setType(int type) {
  45 + this.type = type;
  46 + }
  47 +
  48 + public long getT() {
  49 + return t;
  50 + }
  51 +
  52 + public void setT(long t) {
  53 + this.t = t;
  54 + }
  55 +}
... ...
src/main/java/com/bsth/data/gpsdata_v2/rfid/handle/RfidSignalHandle.java 0 → 100644
  1 +package com.bsth.data.gpsdata_v2.rfid.handle;
  2 +
  3 +import com.bsth.data.gpsdata_v2.rfid.entity.RfidInoutStation;
  4 +import com.bsth.data.gpsdata_v2.status_manager.GpsStatusManager;
  5 +import com.bsth.data.msg_queue.DirectivePushQueue;
  6 +import com.bsth.data.schedule.DayOfSchedule;
  7 +import com.bsth.entity.realcontrol.ScheduleRealInfo;
  8 +import com.bsth.websocket.handler.SendUtils;
  9 +import org.apache.commons.lang3.StringUtils;
  10 +import org.slf4j.Logger;
  11 +import org.slf4j.LoggerFactory;
  12 +import org.springframework.beans.factory.annotation.Autowired;
  13 +import org.springframework.stereotype.Component;
  14 +
  15 +import java.util.List;
  16 +
  17 +/**
  18 + * RFID信号处理
  19 + * Created by panzhao on 2017/11/22.
  20 + */
  21 +@Component
  22 +public class RfidSignalHandle {
  23 +
  24 + @Autowired
  25 + DayOfSchedule dayOfSchedule;
  26 +
  27 + @Autowired
  28 + SendUtils sendUtils;
  29 +
  30 + @Autowired
  31 + GpsStatusManager gpsStatusManager;
  32 +
  33 + Logger logger = LoggerFactory.getLogger(this.getClass());
  34 +
  35 + public void handle(List<RfidInoutStation> list){
  36 + for(RfidInoutStation signal : list){
  37 + if(signal.getType()==0)
  38 + in(signal);
  39 + else if(signal.getType()==1)
  40 + out(signal);
  41 + }
  42 + }
  43 +
  44 + /**
  45 + * 出
  46 + * @param signal
  47 + */
  48 + private void out(RfidInoutStation signal) {
  49 + try{
  50 + String nbbm = signal.getNbbm();
  51 + ScheduleRealInfo sch = dayOfSchedule.executeCurr(nbbm);
  52 +
  53 + if(null == sch)
  54 + return;
  55 +
  56 + if(sch.getQdzCode().equals(signal.getStation())
  57 + && StringUtils.isEmpty(sch.getFcsjActual())){
  58 +
  59 + //班次发车
  60 + sch.setFcsjActualAll(signal.getT());
  61 +
  62 + //webSocket
  63 + sendUtils.sendFcsj(sch);
  64 +
  65 + //持久化
  66 + dayOfSchedule.save(sch);
  67 +
  68 + logger.info("RFID; 车辆:" + sch.getClZbh() + " 班次:" + sch.getDfsj() + "发车, 时间:" + sch.getFcsjActual());
  69 + }
  70 + }catch (Exception e){
  71 + logger.error("", e);
  72 + }
  73 + }
  74 +
  75 + /**
  76 + * 进
  77 + * @param signal
  78 + */
  79 + private void in(RfidInoutStation signal) {
  80 + try{
  81 + String nbbm = signal.getNbbm();
  82 + ScheduleRealInfo sch = dayOfSchedule.executeCurr(nbbm);
  83 +
  84 + if(sch.getZdzCode().equals(signal.getStation())
  85 + && StringUtils.isEmpty(sch.getZdsjActual())){
  86 +
  87 + sch.setZdsjActualAll(signal.getT());
  88 +
  89 +
  90 + //持久化
  91 + dayOfSchedule.save(sch);
  92 +
  93 + //车辆的下一个班次
  94 + ScheduleRealInfo next = dayOfSchedule.next(sch);
  95 + if(next != null){
  96 + dayOfSchedule.addExecPlan(next);
  97 + //inStationAndInPark(sch, next);//进站既进场
  98 + }
  99 +
  100 + //路牌的下一个班次,页面显示起点实际到达时间
  101 + ScheduleRealInfo lpNext = dayOfSchedule.nextByLp(sch);
  102 + if(lpNext != null){
  103 + lpNext.setQdzArrDatesj(sch.getZdsjActual());
  104 + }
  105 +
  106 + //已完成班次数
  107 + int doneSum = dayOfSchedule.doneSum(nbbm);
  108 +
  109 + //webSocket
  110 + sendUtils.sendZdsj(sch, lpNext, doneSum);
  111 +
  112 + logger.info("RFID; 车辆:" + nbbm + " 班次:" + sch.getDfsj() + "到终点, 时间:" + sch.getZdsjActual());
  113 +
  114 + //下发调度指令
  115 + DirectivePushQueue.put6002(next, doneSum, "rfid@系统");
  116 +
  117 + //套跑 -下发线路切换指令
  118 + if(null != next && !next.getXlBm().equals(sch.getXlBm())){
  119 + gpsStatusManager.changeLine(next.getClZbh(), next.getXlBm(), "rfid@系统");
  120 + }
  121 +
  122 + if(null == next)
  123 + nonService(sch, "rfid1@系统");//班次结束
  124 + else if(dayOfSchedule.emptyService(next))
  125 + nonService(sch, "rfid2@系统");//下一班非营运
  126 + }
  127 + }catch (Exception e){
  128 + logger.error("", e);
  129 + }
  130 + }
  131 +
  132 + /**
  133 + * 将车载设备切换为非营运状态
  134 + * @param sch
  135 + * @param sender
  136 + */
  137 + private void nonService(ScheduleRealInfo sch, String sender){
  138 + gpsStatusManager.changeServiceState(sch.getClZbh(), sch.getXlDir(), 1, sender);
  139 + }
  140 +}
... ...
src/main/java/com/bsth/data/gpsdata/status_manager/GpsStatusManager.java renamed to src/main/java/com/bsth/data/gpsdata_v2/status_manager/GpsStatusManager.java
1   -package com.bsth.data.gpsdata.status_manager;
  1 +package com.bsth.data.gpsdata_v2.status_manager;
2 2  
3 3 import com.bsth.Application;
4   -import com.bsth.data.gpsdata.status_manager.gps_line_state.LineStateHandle;
5   -import com.bsth.data.gpsdata.status_manager.gps_service_state.ServiceStateHandle;
  4 +import com.bsth.data.gpsdata_v2.status_manager.gps_line_state.LineStateHandle;
  5 +import com.bsth.data.gpsdata_v2.status_manager.gps_service_state.ServiceStateHandle;
6 6 import org.springframework.beans.factory.annotation.Autowired;
7 7 import org.springframework.boot.CommandLineRunner;
8 8 import org.springframework.stereotype.Component;
... ...
src/main/java/com/bsth/data/gpsdata/status_manager/gps_line_state/ChangeBean.java renamed to src/main/java/com/bsth/data/gpsdata_v2/status_manager/gps_line_state/ChangeBean.java
1   -package com.bsth.data.gpsdata.status_manager.gps_line_state;
  1 +package com.bsth.data.gpsdata_v2.status_manager.gps_line_state;
2 2  
3 3 /**
4 4 * Created by panzhao on 2017/7/13.
... ...
src/main/java/com/bsth/data/gpsdata/status_manager/gps_line_state/LineStateHandle.java renamed to src/main/java/com/bsth/data/gpsdata_v2/status_manager/gps_line_state/LineStateHandle.java
1   -package com.bsth.data.gpsdata.status_manager.gps_line_state;
  1 +package com.bsth.data.gpsdata_v2.status_manager.gps_line_state;
2 2  
3   -import com.bsth.data.gpsdata.GpsEntity;
4   -import com.bsth.data.gpsdata.GpsRealData;
  3 +import com.bsth.data.gpsdata_v2.GpsRealData;
  4 +import com.bsth.data.gpsdata_v2.entity.GpsEntity;
5 5 import com.bsth.data.msg_queue.DirectivePushQueue;
6 6 import com.bsth.service.directive.DirectiveService;
7 7 import org.slf4j.Logger;
... ...
src/main/java/com/bsth/data/gpsdata/status_manager/gps_service_state/ServiceStateHandle.java renamed to src/main/java/com/bsth/data/gpsdata_v2/status_manager/gps_service_state/ServiceStateHandle.java
1   -package com.bsth.data.gpsdata.status_manager.gps_service_state;
  1 +package com.bsth.data.gpsdata_v2.status_manager.gps_service_state;
2 2  
3   -import com.bsth.data.gpsdata.GpsEntity;
4   -import com.bsth.data.gpsdata.GpsRealData;
  3 +import com.bsth.data.gpsdata_v2.GpsRealData;
  4 +import com.bsth.data.gpsdata_v2.entity.GpsEntity;
5 5 import com.bsth.data.msg_queue.DirectivePushQueue;
6 6 import com.bsth.service.directive.DirectiveService;
7 7 import org.slf4j.Logger;
... ...
src/main/java/com/bsth/data/gpsdata/status_manager/gps_service_state/StateBean.java renamed to src/main/java/com/bsth/data/gpsdata_v2/status_manager/gps_service_state/StateBean.java
1   -package com.bsth.data.gpsdata.status_manager.gps_service_state;
  1 +package com.bsth.data.gpsdata_v2.status_manager.gps_service_state;
2 2  
3 3 /**
4 4 * Created by panzhao on 2017/7/13.
... ...
src/main/java/com/bsth/data/gpsdata_v2/thread/GpsDataLoaderThread.java 0 → 100644
  1 +package com.bsth.data.gpsdata_v2.thread;
  2 +
  3 +import com.bsth.data.gpsdata_v2.DataHandleProcess;
  4 +import com.bsth.data.gpsdata_v2.entity.GpsEntity;
  5 +import com.bsth.data.gpsdata_v2.load.GatewayHttpLoader;
  6 +import com.bsth.data.gpsdata_v2.load.SocketClientLoader;
  7 +import org.slf4j.Logger;
  8 +import org.slf4j.LoggerFactory;
  9 +import org.springframework.beans.factory.annotation.Autowired;
  10 +import org.springframework.stereotype.Component;
  11 +
  12 +import java.util.List;
  13 +
  14 +/**
  15 + * Created by panzhao on 2017/1/11.
  16 + */
  17 +@Component
  18 +public class GpsDataLoaderThread extends Thread {
  19 +
  20 + Logger logger = LoggerFactory.getLogger(this.getClass());
  21 +
  22 + //0:从GPS客户端内存获取 -1:从网关获取
  23 + private static int flag = 0;
  24 +
  25 + public static void setFlag(int v) {
  26 + flag = v;
  27 + }
  28 +
  29 + @Autowired
  30 + DataHandleProcess handleProcess;
  31 +
  32 + @Override
  33 + public void run() {
  34 + try {
  35 + List<GpsEntity> list;
  36 + if (flag == 0)
  37 + list = SocketClientLoader.load();
  38 + else
  39 + list = GatewayHttpLoader.load();
  40 +
  41 + if(null != list && list.size() > 0)
  42 + handleProcess.handle(list);
  43 + } catch (Exception e) {
  44 + logger.error("", e);
  45 + }
  46 + }
  47 +}
0 48 \ No newline at end of file
... ...
src/main/java/com/bsth/data/gpsdata/arrival/utils/CircleQueue.java renamed to src/main/java/com/bsth/data/gpsdata_v2/utils/CircleQueue.java
1   -package com.bsth.data.gpsdata.arrival.utils;
  1 +package com.bsth.data.gpsdata_v2.utils;
2 2  
3 3 import java.util.Arrays;
4 4  
... ...
src/main/java/com/bsth/data/gpsdata/arrival/utils/GeoUtils.java renamed to src/main/java/com/bsth/data/gpsdata_v2/utils/GeoUtils.java
1   -package com.bsth.data.gpsdata.arrival.utils;
  1 +package com.bsth.data.gpsdata_v2.utils;
2 2  
3   -import com.bsth.data.gpsdata.GpsEntity;
4   -import com.bsth.data.gpsdata.arrival.GeoCacheData;
5   -import com.bsth.data.gpsdata.arrival.entity.StationRoute;
6   -import com.bsth.data.gpsdata.arrival.precondition.entity.PreconditionGeo;
7   -import com.vividsolutions.jts.geom.Coordinate;
8   -import com.vividsolutions.jts.geom.GeometryFactory;
9   -import com.vividsolutions.jts.geom.LineString;
10   -import com.vividsolutions.jts.geom.Point;
  3 +import com.bsth.data.gpsdata_v2.cache.GeoCacheData;
  4 +import com.bsth.data.gpsdata_v2.cache.GpsCacheData;
  5 +import com.bsth.data.gpsdata_v2.entity.CtLineString;
  6 +import com.bsth.data.gpsdata_v2.entity.GpsEntity;
  7 +import com.bsth.data.gpsdata_v2.entity.PreconditionGeo;
  8 +import com.bsth.data.gpsdata_v2.entity.StationRoute;
  9 +import com.bsth.util.Geo.Bounds;
  10 +import com.bsth.util.Geo.Point;
  11 +import com.bsth.util.Geo.Polygon;
11 12  
12   -import java.util.List;
13   -import java.util.Map;
14   -import java.util.Set;
  13 +import java.util.*;
15 14  
16 15 /**
17 16 * Created by panzhao on 2016/12/23.
18 17 */
19 18 public class GeoUtils {
20 19  
21   - private final static double EARTHRADIUS = 6378137;
  20 + private final static double EARTH_RADIUS = 6378137;
22 21  
23   - private static GeometryFactory geometryFactory = new GeometryFactory();
  22 + private static StationRouteComp sComp = new StationRouteComp();
24 23 /**
25 24 * gps是否在路由上的某个站内
26 25 *
... ... @@ -29,51 +28,61 @@ public class GeoUtils {
29 28 * @return
30 29 */
31 30 public static StationRoute gpsInStation(GpsEntity gps, List<StationRoute> srs) {
32   - Point point = geometryFactory.createPoint(new Coordinate(gps.getLat(), gps.getLon()));
33   - double min = -1, distance;
34   - StationRoute stationRoute = null;
  31 + List<StationRoute> rs = new ArrayList<>();
  32 +
  33 + Point point = new Point(gps.getLon(), gps.getLat());
  34 + double distance;
35 35  
36 36 for (StationRoute sr : srs) {
37 37 if (sr.getPolygon() == null) {
38 38 //圆形
39   - distance = getDistance(sr.getPoint(), point);//sr.getPoint().distance(point);
  39 + distance = getDistance(sr.getPoint(), point);
40 40  
41 41 if (distance > sr.getRadius())
42 42 continue;
43 43  
44   - if (min > distance || min == -1) {
45   - min = distance;
46   - stationRoute = sr;
47   - }
48   - } else {
49   - //多边形
50   - /*if (sr.getPolygon().contains(point)) {
51   - stationRoute = sr;
52   - break;
53   - }*/
54   - com.bsth.util.Geo.Polygon polygon2 = GeoCacheData.convertPolygon(sr.getPolygon());
55   - com.bsth.util.Geo.Point point2 = new com.bsth.util.Geo.Point(gps.getLon(), gps.getLat());
56   - if(com.bsth.util.Geo.GeoUtils.isPointInPolygon(point2, polygon2)){
57   - stationRoute = sr;
58   - break;
  44 + rs.add(sr);
  45 + } else if(isPointInPolygon(point, sr.getPolygon())){
  46 + rs.add(sr);
  47 + }
  48 + }
  49 +
  50 + if(rs.size() == 0)
  51 + return null;
  52 + else
  53 + return findNearStation(rs, gps);
  54 + }
  55 +
  56 + private static StationRoute findNearStation(List<StationRoute> rs, GpsEntity gps) {
  57 + if(rs.size() > 1){
  58 + //按路由顺序排序
  59 + Collections.sort(rs, sComp);
  60 +
  61 + //上一个进出的站点
  62 + StationRoute ps = GpsCacheData.prevStation(gps);
  63 + if(null != ps){
  64 + for(StationRoute s : rs){
  65 + if(s.getRouteSort() >= ps.getRouteSort())
  66 + return s;
59 67 }
60 68 }
61 69 }
62   - return stationRoute;
  70 + return rs.get(0);
63 71 }
64 72  
  73 +
65 74 public static double getDistance(Point p1, Point p2) {
66   - double lng1 = getLoop(p1.getY(), -180, 180), lat1 = getRange(
67   - p1.getX(), -74, 74);
68   - double lng2 = getLoop(p2.getY(), -180, 180), lat2 = getRange(
69   - p2.getX(), -74, 74);
  75 + double lng1 = getLoop(p1.getLon(), -180, 180), lat1 = getRange(
  76 + p1.getLat(), -74, 74);
  77 + double lng2 = getLoop(p2.getLon(), -180, 180), lat2 = getRange(
  78 + p2.getLat(), -74, 74);
70 79  
71 80 double x1, x2, y1, y2;
72 81 x1 = degreeToRad(lng1);
73 82 y1 = degreeToRad(lat1);
74 83 x2 = degreeToRad(lng2);
75 84 y2 = degreeToRad(lat2);
76   - return EARTHRADIUS
  85 + return EARTH_RADIUS
77 86 * Math.acos((Math.sin(y1) * Math.sin(y2) + Math.cos(y1)
78 87 * Math.cos(y2) * Math.cos(x2 - x1)));
79 88 }
... ... @@ -97,18 +106,16 @@ public class GeoUtils {
97 106 return Math.PI * degree / 180;
98 107 }
99 108  
  109 + public static double getDistanceFromLine(CtLineString lineString, Point p){
  110 + return getDistanceFromLine(lineString.getS(), lineString.getE(), p);
  111 + }
  112 +
100 113 /**
101 114 * 计算点 到 线的距离
102 115 * @param line
103 116 * @param p
104 117 * @return
105 118 */
106   - public static double getDistanceFromLine(LineString line, Point p){
107   - Point s = line.getStartPoint();
108   - Point e = line.getEndPoint();
109   - return getDistanceFromLine(s, e, p);
110   - }
111   -
112 119 public static double getDistanceFromLine(Point s, Point e, Point p){
113 120 double d1 = getDistance(s, p);
114 121 double d2 = getDistance(p, e);
... ... @@ -130,39 +137,18 @@ public class GeoUtils {
130 137 return distance;
131 138 }
132 139  
133   -
134 140 /**
135 141 * gps 是否在某个停车场内
136 142 * @param gps
137 143 * @return
  144 + */
138 145 public static String gpsInCarpark(GpsEntity gps){
139   - Point point = geometryFactory.createPoint(new Coordinate(gps.getLat(), gps.getLon()));
140   -
  146 + Point point = new Point(gps.getLon(), gps.getLat());
141 147 Map<String, Polygon> carparkMap = GeoCacheData.tccMap;
142   - Set<String> codes = carparkMap.keySet();
143   - Polygon polygon;
144   - for(String code : codes){
145   - polygon = carparkMap.get(code);
146   - if(point.within(polygon)){
147   - return code;
148   - }
149   - }
150   - return null;
151   - }*/
152 148  
153   - /**
154   - * gps 是否在某个停车场内
155   - * @param gps
156   - * @return
157   - */
158   - public static String gpsInCarpark(GpsEntity gps){
159   - com.bsth.util.Geo.Point point = new com.bsth.util.Geo.Point(gps.getLon(), gps.getLat());
160   - Map<String, com.bsth.util.Geo.Polygon> carparkMap = GeoCacheData.tccMap2;
161   - com.bsth.util.Geo.Polygon polygon;
162 149 Set<String> codes = carparkMap.keySet();
163 150 for(String code : codes){
164   - polygon = carparkMap.get(code);
165   - if(com.bsth.util.Geo.GeoUtils.isPointInPolygon(point, polygon)){
  151 + if(isPointInPolygon(point, carparkMap.get(code))){
166 152 return code;
167 153 }
168 154 }
... ... @@ -180,11 +166,9 @@ public class GeoUtils {
180 166 if(null == list || list.size()==0)
181 167 return null;
182 168  
183   - com.bsth.util.Geo.Point point = new com.bsth.util.Geo.Point(gps.getLon(), gps.getLat());
184   - com.bsth.util.Geo.Polygon polygon;
  169 + Point point = new Point(gps.getLon(), gps.getLat());
185 170 for(PreconditionGeo p : list){
186   - polygon = p.getPolygon();
187   - if(com.bsth.util.Geo.GeoUtils.isPointInPolygon(point, polygon)){
  171 + if(isPointInPolygon(point, p.getPolygon())){
188 172 return p.getStationCode();
189 173 }
190 174 }
... ... @@ -211,17 +195,17 @@ public class GeoUtils {
211 195 */
212 196 public static double getDistanceLineToLine(Point p1, Point p2, Point p3, Point p4){
213 197 double distance;
214   - double x1 = p1.getX(); //A点坐标(x1,y1,z1)
215   - double y1 = p1.getY();
  198 + double x1 = p1.getLat(); //A点坐标(x1,y1,z1)
  199 + double y1 = p1.getLon();
216 200 double z1 = 0;
217   - double x2 = p2.getX(); //B点坐标(x2,y2,z2)
218   - double y2 = p2.getY();
  201 + double x2 = p2.getLat(); //B点坐标(x2,y2,z2)
  202 + double y2 = p2.getLon();
219 203 double z2 = 0;
220   - double x3 = p3.getX(); //C点坐标(x3,y3,z3)
221   - double y3 = p3.getY();
  204 + double x3 = p3.getLat(); //C点坐标(x3,y3,z3)
  205 + double y3 = p3.getLon();
222 206 double z3 = 0;
223   - double x4 = p4.getX(); //D点坐标(x4,y4,z4)
224   - double y4 = p4.getY();
  207 + double x4 = p4.getLat(); //D点坐标(x4,y4,z4)
  208 + double y4 = p4.getLon();
225 209 double z4 = 0;
226 210  
227 211 double a = (x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)+(z2-z1)*(z2-z1);
... ... @@ -256,8 +240,9 @@ public class GeoUtils {
256 240 double U = x3+t*(x4-x3);
257 241 double V = y3+t*(y4-y3);
258 242 double W = z3+t*(z4-z3);
259   - Point p = geometryFactory.createPoint(new Coordinate(X, Y, Z));
260   - Point q = geometryFactory.createPoint(new Coordinate(U, V, W));
  243 +
  244 + Point p = new Point(Y, X);
  245 + Point q = new Point(V, U);
261 246 distance = getDistance(p, q);
262 247 }
263 248 else
... ... @@ -282,10 +267,135 @@ public class GeoUtils {
282 267 * @return
283 268 */
284 269 public static Point perpendularPoint(Point lp1, Point lp2, Point p){
285   - double a = lp1.getX() - lp2.getX(), b = lp2.getY() - lp1.getY(), c = lp1.getY() * lp2.getX() - lp2.getY() * lp1.getX();
286   - double lon = (Math.pow(b, 2) * p.getY() - a * b * p.getX() - a * c) / (Math.pow(a, 2) + Math.pow(b, 2));
287   - double lat = (Math.pow(a, 2) * p.getX() - a * b * p.getY() - b * c) / (Math.pow(a, 2) + Math.pow(b, 2));
  270 + double a = lp1.getLat() - lp2.getLat(), b = lp2.getLon() - lp1.getLon(), c = lp1.getLon() * lp2.getLat() - lp2.getLon() * lp1.getLat();
  271 + double lon = (Math.pow(b, 2) * p.getLon() - a * b * p.getLat() - a * c) / (Math.pow(a, 2) + Math.pow(b, 2));
  272 + double lat = (Math.pow(a, 2) * p.getLat() - a * b * p.getLon() - b * c) / (Math.pow(a, 2) + Math.pow(b, 2));
  273 +
  274 + return new Point(lon, lat);
  275 + }
288 276  
289   - return geometryFactory.createPoint(new Coordinate(lat, lon));
  277 + public static boolean isPointInRect(Point point, Bounds bounds) {
  278 + Point sw = bounds.getSouthWest(); // 西南脚点
  279 + Point ne = bounds.getNorthEast(); // 东北脚点
  280 + return (point.getLon() >= sw.getLon() && point.getLon() <= ne.getLon()
  281 + && point.getLat() >= sw.getLat() && point.getLat() <= ne
  282 + .getLat());
290 283 }
  284 +
  285 + public static boolean isPointInPolygon(Point point, Polygon polygon) {
  286 + Bounds polygonBounds = polygon.getBounds();
  287 + if (!isPointInRect(point, polygonBounds)) {
  288 + return false;
  289 + }
  290 +
  291 + List<Point> pts = polygon.getPoints();// 获取多边形点
  292 +
  293 + // 下述代码来源:http://paulbourke.net/geometry/insidepoly/,进行了部分修改
  294 + // 基本思想是利用射线法,计算射线与多边形各边的交点,如果是偶数,则点在多边形外,否则
  295 + // 在多边形内。还会考虑一些特殊情况,如点在多边形顶点上,点在多边形边上等特殊情况。
  296 +
  297 + int N = pts.size();
  298 + boolean boundOrVertex = true; // 如果点位于多边形的顶点或边上,也算做点在多边形内,直接返回true
  299 + int intersectCount = 0;// cross points count of x
  300 + double precision = 2e-10; // 浮点类型计算时候与0比较时候的容差
  301 + Point p1, p2;// neighbour bound vertices
  302 + Point p = point; // 测试点
  303 +
  304 + p1 = pts.get(0);// left vertex
  305 + for (int i = 1; i <= N; ++i) {// check all rays
  306 + if (p.equals(p1)) {
  307 + return boundOrVertex;// p is an vertex
  308 + }
  309 +
  310 + p2 = pts.get(i % N);// right vertex
  311 + if (p.getLat() < Math.min(p1.getLat(), p2.getLat())
  312 + || p.getLat() > Math.max(p1.getLat(), p2.getLat())) {// ray
  313 + // is
  314 + // outside
  315 + // of
  316 + // our
  317 + // interests
  318 + p1 = p2;
  319 + continue;// next ray left point
  320 + }
  321 +
  322 + if (p.getLat() > Math.min(p1.getLat(), p2.getLat())
  323 + && p.getLat() < Math.max(p1.getLat(), p2.getLat())) {// ray
  324 + // is
  325 + // crossing
  326 + // over
  327 + // by
  328 + // the
  329 + // algorithm
  330 + // (common
  331 + // part
  332 + // of)
  333 + if (p.getLon() <= Math.max(p1.getLon(), p2.getLon())) {// x is
  334 + // before
  335 + // of
  336 + // ray
  337 + if (p1.getLat() == p2.getLat()
  338 + && p.getLon() >= Math.min(p1.getLon(), p2.getLon())) {// overlies
  339 + // on
  340 + // a
  341 + // horizontal
  342 + // ray
  343 + return boundOrVertex;
  344 + }
  345 +
  346 + if (p1.getLon() == p2.getLon()) {// ray is vertical
  347 + if (p1.getLon() == p.getLon()) {// overlies on a
  348 + // vertical ray
  349 + return boundOrVertex;
  350 + } else {// before ray
  351 + ++intersectCount;
  352 + }
  353 + } else {// cross point on the left side
  354 + double xinters = (p.getLat() - p1.getLat())
  355 + * (p2.getLon() - p1.getLon())
  356 + / (p2.getLat() - p1.getLat()) + p1.getLon();// cross
  357 + // point
  358 + // of
  359 + // lng
  360 + if (Math.abs(p.getLon() - xinters) < precision) {// overlies
  361 + // on
  362 + // a
  363 + // ray
  364 + return boundOrVertex;
  365 + }
  366 +
  367 + if (p.getLon() < xinters) {// before ray
  368 + ++intersectCount;
  369 + }
  370 + }
  371 + }
  372 + } else {// special case when ray is crossing through the vertex
  373 + if (p.getLat() == p2.getLat() && p.getLon() <= p2.getLon()) {// p
  374 + // crossing
  375 + // over
  376 + // p2
  377 + Point p3 = pts.get((i + 1) % N); // next vertex
  378 + if (p.getLat() >= Math.min(p1.getLat(), p3.getLat())
  379 + && p.getLat() <= Math.max(p1.getLat(), p3.getLat())) {// p.lat
  380 + // lies
  381 + // between
  382 + // p1.lat
  383 + // &
  384 + // p3.lat
  385 + ++intersectCount;
  386 + } else {
  387 + intersectCount += 2;
  388 + }
  389 + }
  390 + }
  391 + p1 = p2;// next ray left point
  392 + }
  393 +
  394 + if (intersectCount % 2 == 0) {// 偶数在多边形外
  395 + return false;
  396 + } else { // 奇数在多边形内
  397 + return true;
  398 + }
  399 + }
  400 +
291 401 }
... ...
src/main/java/com/bsth/data/gpsdata/recovery/GpsDataRecovery.java renamed to src/main/java/com/bsth/data/gpsdata_v2/utils/GpsDataRecovery.java
1   -package com.bsth.data.gpsdata.recovery;
  1 +package com.bsth.data.gpsdata_v2.utils;
2 2  
3 3 import com.bsth.data.BasicData;
4   -import com.bsth.data.gpsdata.GpsEntity;
5   -import com.bsth.data.gpsdata.arrival.GeoCacheData;
6   -import com.bsth.data.gpsdata.arrival.handlers.*;
7   -import com.bsth.data.gpsdata.arrival.utils.CircleQueue;
  4 +import com.bsth.data.gpsdata_v2.cache.GpsCacheData;
  5 +import com.bsth.data.gpsdata_v2.entity.GpsEntity;
  6 +import com.bsth.data.gpsdata_v2.handlers.*;
8 7 import com.bsth.util.db.DBUtils_MS;
9 8 import com.google.common.collect.ArrayListMultimap;
10 9 import org.slf4j.Logger;
... ... @@ -36,11 +35,11 @@ public class GpsDataRecovery implements ApplicationContextAware {
36 35  
37 36 static ExecutorService threadPool = Executors.newFixedThreadPool(10);
38 37  
39   - static OfflineSignalHandle offlineSignalHandle;
40   - static CorrectSignalHandle correctSignalHandle;
41   - static StationInsideHandle stationInsideHandle;
42   - static InOutStationSignalHandle inOutStationSignalHandle;
43   - static ReverseSignalHandle reverseSignalHandle;
  38 + static GpsStateProcess gpsStateProcess;
  39 + static StationInsideProcess stationInsideProcess;
  40 + static InStationProcess inStationProcess;
  41 + static OutStationProcess outStationProcess;
  42 + static AbnormalStateProcess abnormalStateProcess;
44 43  
45 44 public void recovery() {
46 45 List<GpsEntity> list = loadData();
... ... @@ -59,7 +58,7 @@ public class GpsDataRecovery implements ApplicationContextAware {
59 58 GpsComp comp = new GpsComp();
60 59 for (String nbbm : keys) {
61 60 Collections.sort(listMap.get(nbbm), comp);
62   - threadPool.execute(new RecoveryThread(listMap.get(nbbm), count));
  61 + threadPool.submit(new RecoveryThread(listMap.get(nbbm), count));
63 62 /*if(nbbm.equals("W2H-015"))
64 63 new RecoveryThread(listMap.get(nbbm), count).run();*/
65 64 /*if(lineId.equals("60028"))
... ... @@ -84,7 +83,7 @@ public class GpsDataRecovery implements ApplicationContextAware {
84 83 Calendar calendar = Calendar.getInstance();
85 84 int dayOfYear = calendar.get(Calendar.DAY_OF_YEAR);
86 85  
87   - String sql = "select DEVICE_ID,LAT,LON,TS,SPEED_GPS,LINE_ID,SERVICE_STATE from bsth_c_gps_info where days_year=285";// + dayOfYear;
  86 + String sql = "select DEVICE_ID,LAT,LON,TS,SPEED_GPS,LINE_ID,SERVICE_STATE from bsth_c_gps_info where days_year=" + dayOfYear;
88 87 JdbcTemplate jdbcTemplate = new JdbcTemplate(DBUtils_MS.getDataSource());
89 88  
90 89 List<GpsEntity> list =
... ... @@ -121,11 +120,11 @@ public class GpsDataRecovery implements ApplicationContextAware {
121 120  
122 121 @Override
123 122 public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
124   - offlineSignalHandle = applicationContext.getBean(OfflineSignalHandle.class);
125   - correctSignalHandle = applicationContext.getBean(CorrectSignalHandle.class);
126   - stationInsideHandle = applicationContext.getBean(StationInsideHandle.class);
127   - inOutStationSignalHandle = applicationContext.getBean(InOutStationSignalHandle.class);
128   - reverseSignalHandle = applicationContext.getBean(ReverseSignalHandle.class);
  123 + gpsStateProcess = applicationContext.getBean(GpsStateProcess.class);
  124 + stationInsideProcess = applicationContext.getBean(StationInsideProcess.class);
  125 + inStationProcess = applicationContext.getBean(InStationProcess.class);
  126 + outStationProcess = applicationContext.getBean(OutStationProcess.class);
  127 + abnormalStateProcess = applicationContext.getBean(AbnormalStateProcess.class);
129 128 }
130 129  
131 130 public static class GpsComp implements Comparator<GpsEntity> {
... ... @@ -149,33 +148,19 @@ public class GpsDataRecovery implements ApplicationContextAware {
149 148 public void run() {
150 149 try {
151 150 //循环gps恢复数据
152   - CircleQueue<GpsEntity> prevs;
153   - boolean task;
154 151 for (GpsEntity gps : list) {
155 152 try {
156   - /*if(gps.getTimestamp() >= 1506216540000L){
157   - System.out.println("debugger...");
158   - }*/
159   - //是否有任务
160   -
161   - prevs = GeoCacheData.getGps(gps.getNbbm());
162   - //掉线处理
163   - offlineSignalHandle.handle(gps, prevs);
164   - //状态处理
165   - task = correctSignalHandle.handle(gps, prevs);
166   - //场,站内外判断
167   - stationInsideHandle.handle(gps, prevs);
168   - //异常判定(越界/超速)
169   - //abnormalStateHandle.handle(gps, prevs);
170   -
171   - if (!task)
172   - continue; //无任务的,到这里就结束
173   -
174   - //反向处理
175   - reverseSignalHandle.handle(gps, prevs);
176   - //进出站动作处理
177   - inOutStationSignalHandle.handle(gps, prevs);
178   - GeoCacheData.putGps(gps);
  153 +
  154 + gpsStateProcess.process(gps);//状态处理
  155 + stationInsideProcess.process(gps);//场站内外判定
  156 +
  157 +
  158 + abnormalStateProcess.process(gps);//超速越界
  159 +
  160 + inStationProcess.process(gps);//进站
  161 + outStationProcess.process(gps);//出站
  162 +
  163 + GpsCacheData.putGps(gps);//历史gps缓存
179 164 } catch (Exception e) {
180 165 logger.error("", e);
181 166 }
... ...
src/main/java/com/bsth/data/gpsdata_v2/utils/GpsDataUtils.java 0 → 100644
  1 +package com.bsth.data.gpsdata_v2.utils;
  2 +
  3 +import com.bsth.data.gpsdata_v2.entity.GpsEntity;
  4 +import org.slf4j.Logger;
  5 +import org.slf4j.LoggerFactory;
  6 +
  7 +import java.util.ArrayList;
  8 +import java.util.List;
  9 +
  10 +/**
  11 + * Created by panzhao on 2017/11/15.
  12 + */
  13 +public class GpsDataUtils {
  14 +
  15 + static Logger logger = LoggerFactory.getLogger(GpsDataUtils.class);
  16 +
  17 + /**
  18 + * 过滤无效的gps点位
  19 + *
  20 + * @param list
  21 + * @return
  22 + */
  23 + public static List<GpsEntity> clearInvalid(List<GpsEntity> list) {
  24 + List<GpsEntity> rs = new ArrayList<>();
  25 +
  26 + try {
  27 + for (GpsEntity gps : list) {
  28 + if (gps.getValid() == 0)
  29 + rs.add(gps);
  30 + }
  31 +
  32 + if (rs.size() < list.size())
  33 + logger.info("过滤无效的点位 : " + (list.size() - rs.size()));
  34 + } catch (Exception e) {
  35 + logger.error("", e);
  36 + rs = list;
  37 + }
  38 + return rs;
  39 + }
  40 +}
... ...
src/main/java/com/bsth/data/gpsdata/arrival/utils/StationRouteComp.java renamed to src/main/java/com/bsth/data/gpsdata_v2/utils/StationRouteComp.java
1   -package com.bsth.data.gpsdata.arrival.utils;
  1 +package com.bsth.data.gpsdata_v2.utils;
2 2  
3   -import com.bsth.data.gpsdata.arrival.entity.StationRoute;
  3 +
  4 +import com.bsth.data.gpsdata_v2.entity.StationRoute;
4 5  
5 6 import java.util.Comparator;
6 7  
... ...
src/main/java/com/bsth/data/msg_queue/DirectivePushQueue.java
... ... @@ -29,6 +29,8 @@ public class DirectivePushQueue implements ApplicationContextAware {
29 29 }
30 30  
31 31 public static void put6002(ScheduleRealInfo sch, int finish, String sender){
  32 + if(null == sch)
  33 + return;
32 34 QueueData_Directive qd6002 = new QueueData_Directive();
33 35 qd6002.setSch(sch);
34 36 qd6002.setFinish(finish);
... ...
src/main/java/com/bsth/data/pilot80/PilotReport.java
... ... @@ -2,15 +2,12 @@ package com.bsth.data.pilot80;
2 2  
3 3 import com.bsth.data.BasicData;
4 4 import com.bsth.data.LineConfigData;
5   -import com.bsth.data.gpsdata.GpsEntity;
6   -import com.bsth.data.gpsdata.GpsRealData;
7   -import com.bsth.data.gpsdata.status_manager.GpsStatusManager;
  5 +import com.bsth.data.gpsdata_v2.GpsRealData;
  6 +import com.bsth.data.gpsdata_v2.status_manager.GpsStatusManager;
8 7 import com.bsth.data.msg_queue.DirectivePushQueue;
9 8 import com.bsth.data.schedule.DayOfSchedule;
10   -import com.bsth.entity.Line;
11 9 import com.bsth.entity.directive.D80;
12 10 import com.bsth.entity.directive.DC0_A4;
13   -import com.bsth.entity.realcontrol.D80ReplyTemp;
14 11 import com.bsth.entity.realcontrol.LineConfig;
15 12 import com.bsth.entity.realcontrol.ScheduleRealInfo;
16 13 import com.bsth.repository.directive.D80Repository;
... ... @@ -56,14 +53,11 @@ public class PilotReport {
56 53 @Autowired
57 54 GpsStatusManager gpsStatusManager;
58 55  
59   - //private static ArrayListMultimap<String, D80> d80MultiMap;
60   -
61 56 private static ConcurrentHashMap<Integer, D80> d80Maps;
62 57  
63 58 Logger logger = LoggerFactory.getLogger(PilotReport.class);
64 59  
65 60 static {
66   - //d80MultiMap = ArrayListMultimap.create();
67 61 d80Maps = new ConcurrentHashMap<>();
68 62 }
69 63  
... ... @@ -75,7 +69,6 @@ public class PilotReport {
75 69 d80Repository.save(d80);
76 70 //入缓存
77 71 d80Maps.put(d80.getId(), d80);
78   - //d80MultiMap.put(d80.getData().getLineId().toString(), d80);
79 72  
80 73 String nbbm = BasicData.deviceId2NbbmMap.get(d80.getDeviceId());
81 74 //上报时,在执行的班次
... ... @@ -94,34 +87,19 @@ public class PilotReport {
94 87 //没有计划里程的出场班次,出场既是首发站,发送下一班次的调度指令
95 88 if (outSch.getJhlc() == null)
96 89 outSch = dayOfSchedule.next(outSch);
97   -
98 90 //下发调度指令
99   - String deviceId = d80.getDeviceId();
100 91 DirectivePushQueue.put6002(outSch, dayOfSchedule.doneSum(nbbm), "请出@系统");
101   -
102   - //下发线路切换指令
103   - DirectivePushQueue.put64(outSch.getClZbh(), outSch.getXlBm(), "请出@系统");
104   -
105   - try {
106   - GpsEntity gps = gpsRealData.get(deviceId);
107   - if(gps != null && !gps.isService()){
108   - //切换到营运状态
109   - gpsStatusManager.changeServiceState(nbbm, outSch.getXlDir() ,0, "请出@系统");
110   - }
111   - }catch (Exception e){
112   - logger.error("请出切换营运状态异常", e);
113   - }
114 92 }
115 93 break;
116 94 }
117 95  
118   - //推送到页面
119   - sendUtils.send80ToPage(d80);
120   -
121 96 //反射搜索用 瞬时字段
122 97 d80.setLineId(d80.getData().getLineId());
123 98 d80.setNbbm(d80.getData().getNbbm());
124 99 d80.setRequestCode(d80.getData().getRequestCode());
  100 +
  101 + //推送到页面
  102 + sendUtils.send80ToPage(d80);
125 103 } catch (Exception e) {
126 104 logger.error("", e);
127 105 }
... ... @@ -141,10 +119,7 @@ public class PilotReport {
141 119 * @Description: TODO(调度员回复)
142 120 */
143 121 public void reply(D80 d80) {
144   - String nbbm = BasicData.deviceId2NbbmMap.get(d80.getDeviceId());
145 122 Short reqCode = d80.getData().getRequestCode();
146   - //默认短语回复
147   - //defaultReply(nbbm, reqCode, d80.getConfirmRs() == 0?true:false);
148 123  
149 124 switch (reqCode) {
150 125 case 0xA3:
... ... @@ -229,54 +204,6 @@ public class PilotReport {
229 204 return v == null || v.equals(0.0);
230 205 }
231 206  
232   - public void defaultReply(String nbbm, short requestCode, boolean agree) {
233   - Line line = BasicData.nbbm2LineMap.get(nbbm);
234   - String lineCode = null;
235   -
236   - if (line != null)
237   - lineCode = line.getLineCode();
238   - else {
239   - try {
240   - lineCode = gpsRealData.get(BasicData.deviceId2NbbmMap.inverse().get(nbbm)).getLineId().toString();
241   - } catch (Exception e) {
242   - logger.error("", e);
243   - }
244   - }
245   -
246   - if (null == lineCode)
247   - return;
248   -
249   - LineConfig conf = lineConfigData.get(lineCode);
250   - D80ReplyTemp temp = conf.findByCode(requestCode);
251   -
252   - if (null == temp)
253   - return;
254   -
255   - String text;
256   - if (agree)
257   - text = temp.getAgreeText();
258   - else
259   - text = temp.getRejectText();
260   -
261   - directiveService.send60Phrase(nbbm, text, "系统");
262   - }
263   -
264   - /**
265   - * @Title: resumeOperation
266   - * @Description: TODO(恢复营运)
267   - */
268   - public void resumeOperation(D80 d80) {
269   -
270   - }
271   -
272   - /**
273   - * @Title: applyTiaodang
274   - * @Description: TODO(申请调档)
275   - */
276   - public void applyTiaodang(D80 d80) {
277   -
278   - }
279   -
280 207 /**
281 208 * @Title: unconfirmed80
282 209 * @Description: TODO(根据lineCode 获取未处理的80数据)
... ... @@ -304,10 +231,6 @@ public class PilotReport {
304 231 return d80Maps.get(id);
305 232 }
306 233  
307   -/* public String coordHtmlStr(GpsEntity gps) {
308   -
309   - return "<span class=\"nt-coord\" data-lon=\"" + gps.getLon() + "\" data-lat=\"" + gps.getLat() + "\"></span>";
310   - }*/
311 234  
312 235 public Collection<D80> findAll() {
313 236 return d80Maps.values();
... ... @@ -319,20 +242,8 @@ public class PilotReport {
319 242 for (D80 d80 : rems) {
320 243 d80Maps.remove(d80.getId());
321 244 }
322   - logger.info("清除 80数据 after: " + d80Maps.size());
323   - }
324   -
325   - public Collection<? extends D80> findByCar(String nbbm) {
326   - List<D80> rs = new ArrayList<>();
327   - String deviceId = BasicData.deviceId2NbbmMap.inverse().get(nbbm);
328   - if (null == deviceId)
329   - return rs;
330 245  
331   - Collection<D80> all = findAll();
332   - for (D80 d80 : all) {
333   - if (d80.getDeviceId().equals(deviceId))
334   - rs.add(d80);
335   - }
336   - return rs;
  246 + rems.clear();
  247 + logger.info("清除 80数据 after: " + d80Maps.size());
337 248 }
338 249 }
... ...
src/main/java/com/bsth/data/schedule/DayOfSchedule.java
... ... @@ -5,8 +5,8 @@ import com.alibaba.fastjson.JSONArray;
5 5 import com.bsth.common.Constants;
6 6 import com.bsth.common.ResponseCode;
7 7 import com.bsth.data.LineConfigData;
8   -import com.bsth.data.gpsdata.GpsRealData;
9   -import com.bsth.data.gpsdata.recovery.GpsDataRecovery;
  8 +import com.bsth.data.gpsdata_v2.GpsRealData;
  9 +import com.bsth.data.gpsdata_v2.utils.GpsDataRecovery;
10 10 import com.bsth.data.schedule.f_a_l.FirstAndLastHandler;
11 11 import com.bsth.entity.realcontrol.LineConfig;
12 12 import com.bsth.entity.realcontrol.ScheduleRealInfo;
... ... @@ -111,8 +111,6 @@ public class DayOfSchedule {
111 111  
112 112 //数据恢复
113 113 public void dataRecovery() {
114   - GpsDataRecovery.run = true;
115   -
116 114 Collection<LineConfig> confs = lineConfigs.getAll();
117 115 String lineCode, currSchDate;
118 116 for (LineConfig conf : confs) {
... ... @@ -260,8 +258,8 @@ public class DayOfSchedule {
260 258 public void clearRAMData(String lineCode) {
261 259 int count = 0;
262 260 List<ScheduleRealInfo> remList = new ArrayList<>();
263   - Collection<ScheduleRealInfo> schs = nbbmScheduleMap.values();
264   - for (ScheduleRealInfo sch : schs) {
  261 + Collection<ScheduleRealInfo> all = id2SchedulMap.values();
  262 + for (ScheduleRealInfo sch : all) {
265 263 if (sch.getXlBm().equals(lineCode))
266 264 remList.add(sch);
267 265 }
... ... @@ -271,22 +269,19 @@ public class DayOfSchedule {
271 269 nbbmScheduleMap.remove(sch.getClZbh(), sch);
272 270 id2SchedulMap.remove(sch.getId());
273 271 count++;
274   - }
275   - }
276 272  
277   - //清理路牌对照
278   - List<String> lprms = new ArrayList<>();
279   - Set<String> lps = lpScheduleMap.keySet();
280   - for (String lp : lps) {
281   - if (lp.startsWith(lineCode + "_"))
282   - lprms.add(lp);
283   - }
  273 + //清理路牌对照
  274 + lpScheduleMap.removeAll(sch.getXlBm() + "_" + sch.getLpName());
284 275  
285   - for (String lp : lprms){
286   - logger.info("清理路牌映射 " + lp);
287   - lpScheduleMap.removeAll(lp);
  276 + //清除车辆 ——> 执行班次对照
  277 + carExecutePlanMap.remove(sch.getClZbh());
  278 + }
288 279 }
  280 + //清理计划排班
  281 + schedulePlanMap.remove(lineCode);
289 282  
  283 + remList.clear();
  284 + remList = null;
290 285 logger.info(lineCode + "排班清理 " + count);
291 286 }
292 287  
... ... @@ -512,35 +507,6 @@ public class DayOfSchedule {
512 507 return item.getXlDir().equals(sch.getXlDir());
513 508 }
514 509 });
515   - /*int outConfig = -1;
516   - LineConfig config = lineConfigData.get(sch.getXlBm());
517   - if (config != null)
518   - outConfig = config.getOutConfig();
519   -
520   - //限定出站既出场的停车场
521   - String park = config.getTwinsPark();
522   - boolean limitPark = StringUtils.isNotEmpty(park);
523   - boolean flag = false;
524   - ScheduleRealInfo next = null;
525   - for (ScheduleRealInfo temp : list) {
526   - if (temp.getId() == sch.getId()) {
527   - flag = true;
528   - continue;
529   - }
530   - //忽略烂班
531   - if (temp.isDestroy())
532   - continue;
533   -
534   - //出站既出场,忽略出场班次
535   - if (outConfig == 2 && temp.getBcType().equals("out")
536   - && (!limitPark || park.equals(temp.getQdzCode())))
537   - continue;
538   -
539   - if (flag && temp.getXlDir().equals(sch.getXlDir())) {
540   - next = temp;
541   - break;
542   - }
543   - }*/
544 510 return next(subList, sch);
545 511 }
546 512  
... ... @@ -724,12 +690,6 @@ public class DayOfSchedule {
724 690 }
725 691 }
726 692  
727   -
728   -/* public List<ScheduleRealInfo> updateQdzTimePlan(String nbbm) {
729   - Collections.sort(nbbmScheduleMap.get(nbbm), schFCSJComparator);
730   - return schAttrCalculator.updateQdzTimePlan(nbbmScheduleMap.get(nbbm));
731   - }*/
732   -
733 693 public List<ScheduleRealInfo> updateQdzTimePlan(String lpName) {
734 694 List<ScheduleRealInfo> list = lpScheduleMap.get(lpName);
735 695 Collections.sort(list, schFCSJComparator);
... ... @@ -755,45 +715,6 @@ public class DayOfSchedule {
755 715 return rs;
756 716 }
757 717  
758   - /**
759   - * @Title: prveNotExecNum
760   - * @Description: TODO(班次之前未执行班次数量)
761   -
762   - public int prveNotExecNum(ScheduleRealInfo sch) {
763   - int n = 0;
764   - List<ScheduleRealInfo> list = nbbmScheduleMap.get(sch.getClZbh());
765   - for (ScheduleRealInfo s : list) {
766   - if (s.getFcsjActual() == null && !s.isDestroy())
767   - n++;
768   -
769   - if (s.getId().equals(sch.getId()))
770   - break;
771   - }
772   - return n;
773   - }*/
774   -
775   - /**
776   - * @Title: validEndTime
777   - * @Description: TODO(是否是有效的到达时间)
778   -
779   - public boolean validEndTime(ScheduleRealInfo sch, Long ts) {
780   - if (sch.getFcsjActualTime() != null && sch.getFcsjActualTime() > ts)
781   - return false;
782   -
783   - return validTime(sch, ts);
784   - }*/
785   -
786   - /**
787   - * @Title: validStartTime
788   - * @Description: TODO(是否是合适的发车时间)
789   -
790   - public boolean validStartTime(ScheduleRealInfo sch, Long ts) {
791   - if (sch.getZdsjActualTime() != null && sch.getZdsjActualTime() < ts)
792   - return false;
793   -
794   - return validTime(sch, ts);
795   - }*/
796   -
797 718 public boolean validTime(ScheduleRealInfo sch, Long ts) {
798 719 List<ScheduleRealInfo> list = nbbmScheduleMap.get(sch.getClZbh());
799 720 int ci = list.indexOf(sch);
... ... @@ -825,7 +746,6 @@ public class DayOfSchedule {
825 746 }
826 747  
827 748 public void save(ScheduleRealInfo sch) {
828   - //schRepository.save(sch);
829 749 sch.setUpdateDate(new Date());
830 750 pstBuffer.add(sch);
831 751 }
... ... @@ -904,10 +824,6 @@ public class DayOfSchedule {
904 824 return outList;
905 825 }
906 826  
907   -/* public Set<String> allCar() {
908   - return nbbmScheduleMap.keySet();
909   - }*/
910   -
911 827 public Collection<ScheduleRealInfo> findAll() {
912 828 return nbbmScheduleMap.values();
913 829 }
... ... @@ -961,10 +877,6 @@ public class DayOfSchedule {
961 877 nbbmScheduleMap.put(newClZbh, sch);
962 878 }
963 879  
964   - //重新计算班次应到时间
965   - //ups.addAll(updateQdzTimePlan(oldClzbh));
966   - //ups.addAll(updateQdzTimePlan(newClZbh));
967   -
968 880 //重新计算车辆当前执行班次
969 881 reCalcExecPlan(newClZbh);
970 882 reCalcExecPlan(sch.getClZbh());
... ... @@ -986,50 +898,6 @@ public class DayOfSchedule {
986 898  
987 899 ScheduleRealInfo sch = schAttrCalculator.calcCurrentExecSch(list);
988 900 carExecutePlanMap.put(nbbm, sch);
989   -
990   -
991   - /* try{
992   - GpsEntity gps = gpsRealData.get(BasicData.deviceId2NbbmMap.inverse().get(nbbm));
993   - if (gps == null || !gps.isOnline())
994   - return;//设备不在线
995   -
996   - *//*if(sch == null && gps.isService())
997   - DirectivePushQueue.put6003(nbbm, 1, 0, null, "系统");//无任务*//*
998   -
999   - //String bcType = sch.getBcType();
1000   - *//*if(bcType.equals("normal")
1001   - || bcType.equals("region")
1002   - || bcType.equals("major")){
1003   - //全程、区间、放站,切换到营运状态
1004   - if(!gps.isService()){
1005   - DirectivePushQueue.put6003(nbbm, 0, Integer.parseInt(sch.getXlDir()), sch, "系统");
1006   - }
1007   - }
1008   - else if(gps.isService()){
1009   - DirectivePushQueue.put6003(nbbm, 1, 0, null, "系统");//空驶任务
1010   - }*//*
1011   - }catch (Exception e){
1012   - logger.error("", e);
1013   - }
1014   - *//*try {
1015   - //切换设备状态
1016   - GpsEntity gps = gpsRealData.get(BasicData.deviceId2NbbmMap.inverse().get(nbbm));
1017   - if (gps == null || !gps.isOnline())
1018   - return;
1019   - if (sch == null) {
1020   - logger.info("车辆" + nbbm + "无可执行任务,切换至非营运状态");
1021   - DirectivePushQueue.put6003(nbbm, 1, 0, null, "系统");
1022   - return;
1023   - }
1024   -
1025   - if (StringUtils.isNotEmpty(gps.getLineId()) && !gps.getLineId().equals(sch.getXlBm())) {
1026   - //下发线路切换指令
1027   - DirectivePushQueue.put64(nbbm, sch.getXlBm(), "系统");
1028   - logger.info("车辆" + nbbm + "切换至" + sch.getXlBm() + " -原" + gps.getLineId() + " --重新计算当前执行班次!");
1029   - }
1030   - } catch (Exception e) {
1031   - logger.error("", e);
1032   - }*/
1033 901 }
1034 902  
1035 903 /**
... ... @@ -1043,30 +911,6 @@ public class DayOfSchedule {
1043 911 return type.equals("out") || type.equals("in") || type.equals("venting") || type.equals("ldks");
1044 912 }
1045 913  
1046   - /**
1047   - * 是否在执行首班出场
1048   - *
1049   - * @param nbbm
1050   - * @return
1051   -
1052   - public boolean isExecFirstOut(String nbbm, long time) {
1053   - try {
1054   - List<ScheduleRealInfo> list = nbbmScheduleMap.get(nbbm);
1055   - ScheduleRealInfo second = list.get(2),
1056   - first = executeCurr(nbbm);
1057   -
1058   - if (first.getBcType().equals("out")
1059   - && first.getDfsjT() < second.getDfsjT()
1060   - && doneSum(nbbm) == 0 && second.getDfsjT() > time)
1061   - return true;
1062   - } catch (Exception e) {
1063   - logger.error("", e);
1064   - }
1065   -
1066   - return false;
1067   - }*/
1068   -
1069   -
1070 914 @Autowired
1071 915 JdbcTemplate jdbcTemplate;
1072 916  
... ...
src/main/java/com/bsth/data/schedule/SchAttrCalculator.java
... ... @@ -208,7 +208,7 @@ public class SchAttrCalculator {
208 208 public ScheduleRealInfo calcCurrentExecSch(List<ScheduleRealInfo> list) {
209 209 String lineCode = list.get(0).getXlBm();
210 210 LineConfig conf = lineConfigData.get(lineCode);
211   - long t = System.currentTimeMillis();
  211 +
212 212 int outConfig = -1;
213 213 //限定出站既出场的停车场
214 214 String park = null;
... ... @@ -218,7 +218,10 @@ public class SchAttrCalculator {
218 218 }
219 219 boolean limitPark = StringUtils.isNotEmpty(park);
220 220  
221   - for (ScheduleRealInfo sch : list) {
  221 + ScheduleRealInfo sch, prev = null;
  222 + for(int i = list.size() - 1; i > 0; i --){
  223 + sch = list.get(i);
  224 +
222 225 //如果是出站既出场,忽略出场班次
223 226 if (outConfig == 2 && sch.getBcType().equals("out")
224 227 && (!limitPark || park.equals(sch.getQdzCode()))
... ... @@ -229,81 +232,11 @@ public class SchAttrCalculator {
229 232 if (sch.isDestroy())
230 233 continue;
231 234  
232   - //已执行
233 235 if (StringUtils.isNotEmpty(sch.getZdsjActual()))
234   - continue;
235   -
236   - if (Math.abs((t - sch.getDfsjT())) > 1000 * 60 * 60) {
237   - //差值较大,倒着找看有没有更合适的
238   - ScheduleRealInfo schReverse = calcCurrentExecSchReverse(list, outConfig, limitPark, park);
239   - if (null != schReverse && !schReverse.getId().equals(sch.getId())) {
240   - logger.info("calc_current_exec_sch_reverse... -" + schReverse.getId());
241   - return suitableExecSch(schReverse, sch, t);
242   - }
243   - }
244   - return sch;
245   - }
246   - return null;
247   - }
248   -
249   - /**
250   - * 反转匹配一个班次
251   - *
252   - * @param list
253   - * @param outConfig
254   - * @param limitPark
255   - * @param park
256   - * @return
257   - */
258   - private ScheduleRealInfo calcCurrentExecSchReverse(List<ScheduleRealInfo> list, int outConfig, boolean limitPark, String park) {
259   - ScheduleRealInfo near = null;
260   - for (ScheduleRealInfo sch : list) {
261   - //如果是出站既出场,忽略出场班次
262   - if (outConfig == 2 && isInout(sch)
263   - && (!limitPark || park.equals(sch.getQdzCode()) || park.equals(sch.getZdzCode()))
264   - && (sch.getBcsj()==0 || sch.getJhlcOrig().intValue()==0))
265   - continue;
266   -
267   - //忽略烂班
268   - if (sch.isDestroy())
269   - continue;
270   -
271   - if (StringUtils.isNotEmpty(sch.getZdsjActual())) {
272   - near = null;
273   - continue;
274   - }
  236 + break;
275 237  
276   - if (null == near)
277   - near = sch;
  238 + prev = sch;
278 239 }
279   - return near;
280   - }
281   -
282   - /**
283   - * 比较2个班次,谁是指定时间更合适执行的
284   - *
285   - * @param schReverse
286   - * @param sch
287   - * @param t
288   - * @return
289   - */
290   - private ScheduleRealInfo suitableExecSch(ScheduleRealInfo schReverse, ScheduleRealInfo sch, long t) {
291   - return Math.abs(t - schReverse.getDfsjT()) > Math.abs(t - sch.getDfsjT()) ? sch : schReverse;
292   - }
293   -
294   - private boolean isInout(ScheduleRealInfo sch) {
295   - return sch.getBcType().equals("out") || sch.getBcType().equals("in");
296   - }
297   -
298   - /**
299   - *
300   - * @param fcsjT
301   - * @param zdsjT
302   - */
303   - public boolean isValid(Long fcsjT, Long zdsjT) {
304   - if(null != fcsjT && null != zdsjT)
305   - return fcsjT < zdsjT;
306   -
307   - return true;
  240 + return prev;
308 241 }
309 242 }
... ...
src/main/java/com/bsth/data/schedule/auto_exec/RealScheduleAutoExecHandler.java
1 1 package com.bsth.data.schedule.auto_exec;
2 2  
3   -import com.bsth.data.gpsdata.status_manager.GpsStatusManager;
  3 +import com.bsth.data.gpsdata_v2.status_manager.GpsStatusManager;
4 4 import com.bsth.data.schedule.DayOfSchedule;
5 5 import com.bsth.entity.realcontrol.ScheduleRealInfo;
6 6 import com.bsth.websocket.handler.SendUtils;
... ...
src/main/java/com/bsth/data/schedule/late_adjust/LateAdjustHandle.java
... ... @@ -3,7 +3,7 @@ package com.bsth.data.schedule.late_adjust;
3 3  
4 4 import com.bsth.data.BasicData;
5 5 import com.bsth.data.LineConfigData;
6   -import com.bsth.data.gpsdata.GpsEntity;
  6 +import com.bsth.data.gpsdata_v2.entity.GpsEntity;
7 7 import com.bsth.entity.realcontrol.LineConfig;
8 8 import com.bsth.entity.realcontrol.ScheduleRealInfo;
9 9 import com.bsth.util.Arith;
... ...
src/main/java/com/bsth/data/schedule/thread/ScheduleRefreshThread.java
... ... @@ -28,10 +28,7 @@ public class ScheduleRefreshThread extends Thread{
28 28  
29 29 @Autowired
30 30 DayOfSchedule dayOfSchedule;
31   -
32   - /*@Autowired
33   - ArrivalData_GPS arrivalData;*/
34   -
  31 +
35 32 @Autowired
36 33 LineConfigData lineConfs;
37 34  
... ...
src/main/java/com/bsth/entity/calc/CalcWaybill.java 0 → 100644
  1 +package com.bsth.entity.calc;
  2 +
  3 +import java.util.Date;
  4 +
  5 +import javax.persistence.Entity;
  6 +import javax.persistence.GeneratedValue;
  7 +import javax.persistence.Id;
  8 +import javax.persistence.Table;
  9 +
  10 +@Entity
  11 +@Table(name = "calc_waybill")
  12 +public class CalcWaybill {
  13 + /* 主键*/
  14 + @Id
  15 + @GeneratedValue
  16 + private Long id;
  17 + /* 公司代码*/
  18 + private String gsdm;
  19 + /* 公司名称*/
  20 + private String gsname;
  21 + /* 分公司代码*/
  22 + private String fgsdm;
  23 + /* 分公司名称*/
  24 + private String fgsname;
  25 + /* 日期*/
  26 + private Date rq;
  27 + /* 日期字符串*/
  28 + private String rqStr;
  29 + /* 线路编码*/
  30 + private String xl;
  31 + /* 线路名称*/
  32 + private String xlName;
  33 + /* 车辆自编号*/
  34 + private String cl;
  35 + /* 路牌名字*/
  36 + private String lp;
  37 + /* 驾驶员工号*/
  38 + private String jGh;
  39 + /* 驾驶员名字*/
  40 + private String jName;
  41 + /* 售票员工号*/
  42 + private String sGh;
  43 + /* 售票员名字*/
  44 + private String sName;
  45 + /* 计划营运班次*/
  46 + private int jhyybc;
  47 + /* 计划早高峰营运班次*/
  48 + private int jhyybczgf;
  49 + /* 计划晚高峰营运班次*/
  50 + private int jhyybcwgf;
  51 + /* 计划非营运班次*/
  52 + private int jhfyybc;
  53 + /* 计划营运里程*/
  54 + private Double jhyylc;
  55 + /* 计划非营运里程*/
  56 + private Double jhfyylc;
  57 + /* 实际营运班次*/
  58 + private int sjyybc;
  59 + /* 实际早高峰营运班次*/
  60 + private int sjyybczgf;
  61 + /* 实际晚高峰营运班次*/
  62 + private int sjyybcwgf;
  63 + /* 实际非营运班次*/
  64 + private int sjfyybc;
  65 + /* 实际营运里程*/
  66 + private Double sjyylc;
  67 + /* 实际非营运里程*/
  68 + private Double sjfyylc;
  69 + /* 临加班次*/
  70 + private int ljbc;
  71 + /* 临加早高峰班次*/
  72 + private int ljbczgf;
  73 + /* 临加晚高峰班次*/
  74 + private int ljbcwgf;
  75 + /* 临加营运里程*/
  76 + private Double ljyylc;
  77 + /* 临加非营运里程*/
  78 + private Double ljfyylc;
  79 + /* 烂班班次*/
  80 + private int lbbc;
  81 + /* 烂班里程*/
  82 + private Double lblc;
  83 + /* 路阻*/
  84 + private Double lblcLz;
  85 + /* 吊慢*/
  86 + private Double lblcDm;
  87 + /* 故障*/
  88 + private Double lblcGz;
  89 + /* 纠纷*/
  90 + private Double lblcJf;
  91 + /* 肇事*/
  92 + private Double lblcZs;
  93 + /* 缺人*/
  94 + private Double lblcQr;
  95 + /* 缺车*/
  96 + private Double lblcQc;
  97 + /* 客稀*/
  98 + private Double lblcKx;
  99 + /* 气候*/
  100 + private Double lblcQh;
  101 + /* 援外*/
  102 + private Double lblcYw;
  103 + /* 其他*/
  104 + private Double lblcQt;
  105 + /* 放站班次*/
  106 + private int fzbc;
  107 + /* 放站早高峰班次*/
  108 + private int fzbczgf;
  109 + /* 放站晚高峰班次*/
  110 + private int fzbcwgf;
  111 + /* 掉头班次*/
  112 + private int dtbc;
  113 + /* 掉头早高峰班次*/
  114 + private int dtbczgf;
  115 + /* 掉头晚高峰班次*/
  116 + private int dtbcwgf;
  117 + /* 创建时间*/
  118 + private Date createTime;
  119 + /* 修改时间*/
  120 + private Date updateTime;
  121 + public Long getId() {
  122 + return id;
  123 + }
  124 + public void setId(Long id) {
  125 + this.id = id;
  126 + }
  127 + public String getGsdm() {
  128 + return gsdm;
  129 + }
  130 + public void setGsdm(String gsdm) {
  131 + this.gsdm = gsdm;
  132 + }
  133 + public String getGsname() {
  134 + return gsname;
  135 + }
  136 + public void setGsname(String gsname) {
  137 + this.gsname = gsname;
  138 + }
  139 + public String getFgsdm() {
  140 + return fgsdm;
  141 + }
  142 + public void setFgsdm(String fgsdm) {
  143 + this.fgsdm = fgsdm;
  144 + }
  145 + public String getFgsname() {
  146 + return fgsname;
  147 + }
  148 + public void setFgsname(String fgsname) {
  149 + this.fgsname = fgsname;
  150 + }
  151 + public Date getRq() {
  152 + return rq;
  153 + }
  154 + public void setRq(Date rq) {
  155 + this.rq = rq;
  156 + }
  157 + public String getRqStr() {
  158 + return rqStr;
  159 + }
  160 + public void setRqStr(String rqStr) {
  161 + this.rqStr = rqStr;
  162 + }
  163 + public String getXl() {
  164 + return xl;
  165 + }
  166 + public void setXl(String xl) {
  167 + this.xl = xl;
  168 + }
  169 + public String getXlName() {
  170 + return xlName;
  171 + }
  172 + public void setXlName(String xlName) {
  173 + this.xlName = xlName;
  174 + }
  175 + public String getCl() {
  176 + return cl;
  177 + }
  178 + public void setCl(String cl) {
  179 + this.cl = cl;
  180 + }
  181 + public String getLp() {
  182 + return lp;
  183 + }
  184 + public void setLp(String lp) {
  185 + this.lp = lp;
  186 + }
  187 + public String getjGh() {
  188 + return jGh;
  189 + }
  190 + public void setjGh(String jGh) {
  191 + this.jGh = jGh;
  192 + }
  193 + public String getjName() {
  194 + return jName;
  195 + }
  196 + public void setjName(String jName) {
  197 + this.jName = jName;
  198 + }
  199 + public String getsGh() {
  200 + return sGh;
  201 + }
  202 + public void setsGh(String sGh) {
  203 + this.sGh = sGh;
  204 + }
  205 + public String getsName() {
  206 + return sName;
  207 + }
  208 + public void setsName(String sName) {
  209 + this.sName = sName;
  210 + }
  211 + public int getJhyybc() {
  212 + return jhyybc;
  213 + }
  214 + public void setJhyybc(int jhyybc) {
  215 + this.jhyybc = jhyybc;
  216 + }
  217 + public int getJhyybczgf() {
  218 + return jhyybczgf;
  219 + }
  220 + public void setJhyybczgf(int jhyybczgf) {
  221 + this.jhyybczgf = jhyybczgf;
  222 + }
  223 + public int getJhyybcwgf() {
  224 + return jhyybcwgf;
  225 + }
  226 + public void setJhyybcwgf(int jhyybcwgf) {
  227 + this.jhyybcwgf = jhyybcwgf;
  228 + }
  229 + public int getJhfyybc() {
  230 + return jhfyybc;
  231 + }
  232 + public void setJhfyybc(int jhfyybc) {
  233 + this.jhfyybc = jhfyybc;
  234 + }
  235 + public Double getJhyylc() {
  236 + return jhyylc;
  237 + }
  238 + public void setJhyylc(Double jhyylc) {
  239 + this.jhyylc = jhyylc;
  240 + }
  241 + public Double getJhfyylc() {
  242 + return jhfyylc;
  243 + }
  244 + public void setJhfyylc(Double jhfyylc) {
  245 + this.jhfyylc = jhfyylc;
  246 + }
  247 + public int getSjyybc() {
  248 + return sjyybc;
  249 + }
  250 + public void setSjyybc(int sjyybc) {
  251 + this.sjyybc = sjyybc;
  252 + }
  253 + public int getSjyybczgf() {
  254 + return sjyybczgf;
  255 + }
  256 + public void setSjyybczgf(int sjyybczgf) {
  257 + this.sjyybczgf = sjyybczgf;
  258 + }
  259 + public int getSjyybcwgf() {
  260 + return sjyybcwgf;
  261 + }
  262 + public void setSjyybcwgf(int sjyybcwgf) {
  263 + this.sjyybcwgf = sjyybcwgf;
  264 + }
  265 + public int getSjfyybc() {
  266 + return sjfyybc;
  267 + }
  268 + public void setSjfyybc(int sjfyybc) {
  269 + this.sjfyybc = sjfyybc;
  270 + }
  271 + public Double getSjyylc() {
  272 + return sjyylc;
  273 + }
  274 + public void setSjyylc(Double sjyylc) {
  275 + this.sjyylc = sjyylc;
  276 + }
  277 + public Double getSjfyylc() {
  278 + return sjfyylc;
  279 + }
  280 + public void setSjfyylc(Double sjfyylc) {
  281 + this.sjfyylc = sjfyylc;
  282 + }
  283 + public int getLjbc() {
  284 + return ljbc;
  285 + }
  286 + public void setLjbc(int ljbc) {
  287 + this.ljbc = ljbc;
  288 + }
  289 + public int getLjbczgf() {
  290 + return ljbczgf;
  291 + }
  292 + public void setLjbczgf(int ljbczgf) {
  293 + this.ljbczgf = ljbczgf;
  294 + }
  295 + public int getLjbcwgf() {
  296 + return ljbcwgf;
  297 + }
  298 + public void setLjbcwgf(int ljbcwgf) {
  299 + this.ljbcwgf = ljbcwgf;
  300 + }
  301 + public Double getLjyylc() {
  302 + return ljyylc;
  303 + }
  304 + public void setLjyylc(Double ljyylc) {
  305 + this.ljyylc = ljyylc;
  306 + }
  307 + public Double getLjfyylc() {
  308 + return ljfyylc;
  309 + }
  310 + public void setLjfyylc(Double ljfyylc) {
  311 + this.ljfyylc = ljfyylc;
  312 + }
  313 + public int getLbbc() {
  314 + return lbbc;
  315 + }
  316 + public void setLbbc(int lbbc) {
  317 + this.lbbc = lbbc;
  318 + }
  319 + public Double getLblc() {
  320 + return lblc;
  321 + }
  322 + public void setLblc(Double lblc) {
  323 + this.lblc = lblc;
  324 + }
  325 + public Double getLblcLz() {
  326 + return lblcLz;
  327 + }
  328 + public void setLblcLz(Double lblcLz) {
  329 + this.lblcLz = lblcLz;
  330 + }
  331 + public Double getLblcDm() {
  332 + return lblcDm;
  333 + }
  334 + public void setLblcDm(Double lblcDm) {
  335 + this.lblcDm = lblcDm;
  336 + }
  337 + public Double getLblcGz() {
  338 + return lblcGz;
  339 + }
  340 + public void setLblcGz(Double lblcGz) {
  341 + this.lblcGz = lblcGz;
  342 + }
  343 + public Double getLblcJf() {
  344 + return lblcJf;
  345 + }
  346 + public void setLblcJf(Double lblcJf) {
  347 + this.lblcJf = lblcJf;
  348 + }
  349 + public Double getLblcZs() {
  350 + return lblcZs;
  351 + }
  352 + public void setLblcZs(Double lblcZs) {
  353 + this.lblcZs = lblcZs;
  354 + }
  355 + public Double getLblcQr() {
  356 + return lblcQr;
  357 + }
  358 + public void setLblcQr(Double lblcQr) {
  359 + this.lblcQr = lblcQr;
  360 + }
  361 + public Double getLblcQc() {
  362 + return lblcQc;
  363 + }
  364 + public void setLblcQc(Double lblcQc) {
  365 + this.lblcQc = lblcQc;
  366 + }
  367 + public Double getLblcKx() {
  368 + return lblcKx;
  369 + }
  370 + public void setLblcKx(Double lblcKx) {
  371 + this.lblcKx = lblcKx;
  372 + }
  373 + public Double getLblcQh() {
  374 + return lblcQh;
  375 + }
  376 + public void setLblcQh(Double lblcQh) {
  377 + this.lblcQh = lblcQh;
  378 + }
  379 + public Double getLblcYw() {
  380 + return lblcYw;
  381 + }
  382 + public void setLblcYw(Double lblcYw) {
  383 + this.lblcYw = lblcYw;
  384 + }
  385 + public Double getLblcQt() {
  386 + return lblcQt;
  387 + }
  388 + public void setLblcQt(Double lblcQt) {
  389 + this.lblcQt = lblcQt;
  390 + }
  391 + public int getFzbc() {
  392 + return fzbc;
  393 + }
  394 + public void setFzbc(int fzbc) {
  395 + this.fzbc = fzbc;
  396 + }
  397 + public int getFzbczgf() {
  398 + return fzbczgf;
  399 + }
  400 + public void setFzbczgf(int fzbczgf) {
  401 + this.fzbczgf = fzbczgf;
  402 + }
  403 + public int getFzbcwgf() {
  404 + return fzbcwgf;
  405 + }
  406 + public void setFzbcwgf(int fzbcwgf) {
  407 + this.fzbcwgf = fzbcwgf;
  408 + }
  409 + public int getDtbc() {
  410 + return dtbc;
  411 + }
  412 + public void setDtbc(int dtbc) {
  413 + this.dtbc = dtbc;
  414 + }
  415 + public int getDtbczgf() {
  416 + return dtbczgf;
  417 + }
  418 + public void setDtbczgf(int dtbczgf) {
  419 + this.dtbczgf = dtbczgf;
  420 + }
  421 + public int getDtbcwgf() {
  422 + return dtbcwgf;
  423 + }
  424 + public void setDtbcwgf(int dtbcwgf) {
  425 + this.dtbcwgf = dtbcwgf;
  426 + }
  427 + public Date getCreateTime() {
  428 + return createTime;
  429 + }
  430 + public void setCreateTime(Date createTime) {
  431 + this.createTime = createTime;
  432 + }
  433 + public Date getUpdateTime() {
  434 + return updateTime;
  435 + }
  436 + public void setUpdateTime(Date updateTime) {
  437 + this.updateTime = updateTime;
  438 + }
  439 +
  440 +
  441 +
  442 +}
... ...
src/main/java/com/bsth/entity/realcontrol/D80ReplyTemp.java deleted 100644 → 0
1   -package com.bsth.entity.realcontrol;
2   -
3   -import javax.persistence.Entity;
4   -import javax.persistence.GeneratedValue;
5   -import javax.persistence.Id;
6   -import javax.persistence.ManyToOne;
7   -import javax.persistence.Table;
8   -
9   -import com.fasterxml.jackson.annotation.JsonIgnore;
10   -
11   -/**
12   - *
13   - * @ClassName: D80ReplyTemp
14   - * @Description: TODO(80处理后自动回复模板)
15   - * @author PanZhao
16   - * @date 2016年8月22日 下午11:30:10
17   - *
18   - */
19   -@Entity
20   -@Table(name = "bsth_v_d80_reply_temp")
21   -public class D80ReplyTemp {
22   -
23   - public D80ReplyTemp(LineConfig conf, short requestCode, String agreeText, String rejectText){
24   - this.conf = conf;
25   - this.requestCode = requestCode;
26   - this.agreeText = agreeText;
27   - this.rejectText = rejectText;
28   - }
29   -
30   - public D80ReplyTemp(){}
31   -
32   - @Id
33   - @GeneratedValue
34   - private Integer id;
35   -
36   - @JsonIgnore
37   - @ManyToOne
38   - private LineConfig conf;
39   -
40   - private Short requestCode;
41   -
42   - /** 同意时下发文本 */
43   - private String agreeText;
44   -
45   - /** 拒绝时下发文本 */
46   - private String rejectText;
47   -
48   - public Integer getId() {
49   - return id;
50   - }
51   -
52   - public void setId(Integer id) {
53   - this.id = id;
54   - }
55   -
56   - public LineConfig getConf() {
57   - return conf;
58   - }
59   -
60   - public void setConf(LineConfig conf) {
61   - this.conf = conf;
62   - }
63   -
64   - public Short getRequestCode() {
65   - return requestCode;
66   - }
67   -
68   - public void setRequestCode(Short requestCode) {
69   - this.requestCode = requestCode;
70   - }
71   -
72   - public String getAgreeText() {
73   - return agreeText;
74   - }
75   -
76   - public void setAgreeText(String agreeText) {
77   - this.agreeText = agreeText;
78   - }
79   -
80   - public String getRejectText() {
81   - return rejectText;
82   - }
83   -
84   - public void setRejectText(String rejectText) {
85   - this.rejectText = rejectText;
86   - }
87   -}
src/main/java/com/bsth/entity/realcontrol/LineConfig.java
... ... @@ -3,8 +3,6 @@ package com.bsth.entity.realcontrol;
3 3 import com.bsth.entity.Line;
4 4  
5 5 import javax.persistence.*;
6   -import java.util.HashSet;
7   -import java.util.Set;
8 6  
9 7 /**
10 8 *
... ... @@ -18,8 +16,7 @@ import java.util.Set;
18 16 @Table(name = "bsth_c_line_config")
19 17 @NamedEntityGraphs({
20 18 @NamedEntityGraph(name = "lineConfig_line_80temps", attributeNodes = {
21   - @NamedAttributeNode("line"),
22   - @NamedAttributeNode("d80Temps")
  19 + @NamedAttributeNode("line")
23 20 })
24 21 })
25 22 public class LineConfig {
... ... @@ -33,13 +30,6 @@ public class LineConfig {
33 30  
34 31 /** 开始运营时间 HH:mm */
35 32 private String startOpt;
36   -
37   - /** 当天开始营运时间戳
38   - @Transient
39   - private long currStartTime;*/
40   -
41   - /** 托管状态 */
42   - private boolean trust;
43 33  
44 34 /** 出场时间设置 0:真实出场(设备离开缓冲区时间) 1:请求出场时间 2:出站即出场 */
45 35 private int outConfig;
... ... @@ -50,9 +40,6 @@ public class LineConfig {
50 40 /** 出站既出场 对应的起点站 */
51 41 private String twinsStation;
52 42  
53   - /** 短语模板 , 号分隔多个 */
54   - private String phraseTemps;
55   -
56 43 /** 调度指令模板 */
57 44 private String schDirectiveTemp;
58 45  
... ... @@ -62,6 +49,7 @@ public class LineConfig {
62 49 /** 原线路回场 */
63 50 private boolean inParkForSource;
64 51  
  52 + /** 自动执行 */
65 53 private boolean autoExec;
66 54  
67 55 /**
... ... @@ -93,10 +81,6 @@ public class LineConfig {
93 81 */
94 82 private boolean lockFirstOutTime;
95 83  
96   -
97   - @OneToMany(cascade = CascadeType.ALL)
98   - private Set<D80ReplyTemp> d80Temps = new HashSet<>();
99   -
100 84 public Integer getId() {
101 85 return id;
102 86 }
... ... @@ -121,14 +105,6 @@ public class LineConfig {
121 105 this.startOpt = startOpt;
122 106 }
123 107  
124   - public boolean isTrust() {
125   - return trust;
126   - }
127   -
128   - public void setTrust(boolean trust) {
129   - this.trust = trust;
130   - }
131   -
132 108 public int getOutConfig() {
133 109 return outConfig;
134 110 }
... ... @@ -137,14 +113,6 @@ public class LineConfig {
137 113 this.outConfig = outConfig;
138 114 }
139 115  
140   - public String getPhraseTemps() {
141   - return phraseTemps;
142   - }
143   -
144   - public void setPhraseTemps(String phraseTemps) {
145   - this.phraseTemps = phraseTemps;
146   - }
147   -
148 116 public String getSchDirectiveTemp() {
149 117 return schDirectiveTemp;
150 118 }
... ... @@ -153,35 +121,6 @@ public class LineConfig {
153 121 this.schDirectiveTemp = schDirectiveTemp;
154 122 }
155 123  
156   -/* public long getCurrStartTime() {
157   - Date d = null;
158   - try {
159   - SimpleDateFormat sdfyyyyMMddHHmm = new SimpleDateFormat("yyyy-MM-ddHH:mm")
160   - ,sdfyyyyMMdd = new SimpleDateFormat("yyyy-MM-dd");
161   - d = sdfyyyyMMddHHmm.parse(sdfyyyyMMdd.format(new Date()) + this.startOpt);
162   - } catch (ParseException e) {
163   - e.printStackTrace();
164   - }
165   - return d.getTime();
166   - }*/
167   -
168   - public D80ReplyTemp findByCode(short code){
169   - for(D80ReplyTemp temp : d80Temps){
170   - if(temp.getRequestCode() == code)
171   - return temp;
172   - }
173   -
174   - return null;
175   - }
176   -
177   - public Set<D80ReplyTemp> getD80Temps() {
178   - return d80Temps;
179   - }
180   -
181   - public void setD80Temps(Set<D80ReplyTemp> d80Temps) {
182   - this.d80Temps = d80Temps;
183   - }
184   -
185 124 public boolean isReadReverse() {
186 125 return readReverse;
187 126 }
... ...
src/main/java/com/bsth/repository/LineVersionsRepository.java
... ... @@ -31,7 +31,7 @@ public interface LineVersionsRepository extends BaseRepository&lt;LineVersions, Int
31 31 * 获取线路所有版本
32 32 */
33 33 @Query(value = " SELECT lv FROM LineVersions lv where lv.line.id = ?1")
34   - public List<LineVersions> findBylineCode(int lineId);
  34 + public List<LineVersions> findBylineId(int lineId);
35 35  
36 36 @Transactional
37 37 @Modifying
... ... @@ -66,5 +66,11 @@ public interface LineVersionsRepository extends BaseRepository&lt;LineVersions, Int
66 66 */
67 67 @Query(value = "select lv2 from LineVersions lv2 where lv2.line.id =?1 and lv2.versions=(SELECT max(lv.versions) FROM LineVersions lv where lv.line.id = ?1) ")
68 68 public LineVersions findLineVersionsMax(int lineId);
  69 +
  70 + /**
  71 + * 获取线路版本的上一个版本
  72 + */
  73 + @Query(value = " SELECT lv FROM LineVersions lv where lv.line.id = ?1 and lv.versions = (?2 - "+1+")")
  74 + public LineVersions findBylineIdAndVersions(Integer id, Integer versions);
69 75  
70 76 }
... ...
src/main/java/com/bsth/repository/calc/CalcWaybillRepository.java 0 → 100644
  1 +package com.bsth.repository.calc;
  2 +
  3 +import java.util.List;
  4 +
  5 +import javax.transaction.Transactional;
  6 +
  7 +import com.bsth.entity.calc.CalcWaybill;
  8 +import com.bsth.entity.realcontrol.ScheduleRealInfo;
  9 +import com.bsth.repository.BaseRepository;
  10 +
  11 +import org.springframework.data.jpa.repository.EntityGraph;
  12 +import org.springframework.data.jpa.repository.Modifying;
  13 +import org.springframework.data.jpa.repository.Query;
  14 +import org.springframework.stereotype.Repository;
  15 +
  16 +/**
  17 + *
  18 + */
  19 +@Repository
  20 +public interface CalcWaybillRepository extends BaseRepository<CalcWaybill, Integer>{
  21 +
  22 + //按照时间段统计,公司下线路
  23 + @Query(value="select DISTINCT c from CalcWaybill c where c.xl like %?1% and c.rqStr between ?2 and ?3 and c.gsdm like %?4% and c.fgsdm like %?5% order by c.xl")
  24 + List<CalcWaybill> scheduleByDateAndLineTj(String line,String date,String date2,String gsdm,String fgsdm);
  25 +
  26 + //按照时间段统计,单条线路
  27 + @Query(value="select DISTINCT c from CalcWaybill c where c.xl = ?1 and c.rqStr between ?2 and ?3 order by c.xl")
  28 + List<CalcWaybill> scheduleByDateAndLineTj2(String line,String date,String date2);
  29 +
  30 + //按照日期和线路删除数据
  31 + @Modifying
  32 + @Transactional
  33 + @Query(value = "delete CalcWaybill c where c.rqStr=?1 and c.xl=?2")
  34 + void deleteByDateAndLine(String date, String line);
  35 +
  36 + //按照日期删除数据
  37 + @Modifying
  38 + @Transactional
  39 + @Query(value = "delete CalcWaybill c where c.rqStr=?1")
  40 + void deleteByDate(String date);
  41 +
  42 + /**
  43 + * 根据日期和线路编码获取班次信息
  44 + * @param schDate
  45 + * @param lineCode
  46 + * @return
  47 + */
  48 + @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH)
  49 + @Query("select DISTINCT s from ScheduleRealInfo s where s.scheduleDateStr=?1 and s.xlBm=?2")
  50 + List<ScheduleRealInfo> findAllSchedule(String schDate, String lineCode);
  51 +
  52 +}
... ...
src/main/java/com/bsth/service/LineVersionsService.java
... ... @@ -34,4 +34,6 @@ public interface LineVersionsService extends BaseService&lt;LineVersions, Integer&gt;
34 34  
35 35 LineVersions findLineVersionsMax(int lineId);
36 36  
  37 + Map<String, Object> add(Map<String, Object> map);
  38 +
37 39 }
... ...
src/main/java/com/bsth/service/calc/CalcCulateMileageService.java 0 → 100644
  1 +package com.bsth.service.calc;
  2 +
  3 +import java.util.List;
  4 +
  5 +import com.bsth.entity.realcontrol.ScheduleRealInfo;
  6 +
  7 +
  8 +public interface CalcCulateMileageService {
  9 +
  10 + int culateJhyybc(List<ScheduleRealInfo> lists,String item);//计划营运班次
  11 + double culateJhyylc(List<ScheduleRealInfo> lists);//计划营运里程
  12 + int culateJhfyybc(List<ScheduleRealInfo> lists);//计划非营运班次
  13 + double culateJhfyylc(List<ScheduleRealInfo> lists);//计划非营运里程
  14 + int culateSjyybc(List<ScheduleRealInfo> lists,String item);//实际班次
  15 + double culateSjyylc(List<ScheduleRealInfo> lists);//实际营运里程(驾售)
  16 + double culateSjyylc_j(List<ScheduleRealInfo> lists);//实际营运里程(驾)
  17 + double culateSjfyylc(List<ScheduleRealInfo> lists);//实际非营运里程(驾售)
  18 + double culateSjfyylc_j(List<ScheduleRealInfo> lists);//实际非营运里程(驾售)
  19 + int culateLjbc(List<ScheduleRealInfo> lists,String item);//临加营运班次
  20 + double culateLjyylc(List<ScheduleRealInfo> lists);//临加营运里程(驾售)
  21 + double culateLjyylc_j(List<ScheduleRealInfo> lists);//临加营运里程(驾)
  22 + double culateLjfyylc(List<ScheduleRealInfo> lists);//临加非营运里程(驾售)
  23 + double culateLjfyylc_j(List<ScheduleRealInfo> lists);//临加非营运里程(驾)
  24 + int culateLbbc(List<ScheduleRealInfo> lists);//烂班班次
  25 + double culateLbgl(List<ScheduleRealInfo> lists);//烂班公里
  26 + double culateCJLC(List<ScheduleRealInfo> lists,String item);//烂班公里详细
  27 + int culateDtfzbc(List<ScheduleRealInfo> lists,String type,String item);//掉头放站班次
  28 +
  29 +}
  30 +
... ...
src/main/java/com/bsth/service/calc/CalcToolService.java 0 → 100644
  1 +package com.bsth.service.calc;
  2 +
  3 +import java.util.List;
  4 +
  5 +import com.bsth.entity.calc.CalcWaybill;
  6 +
  7 +/**
  8 + * Created by 17/11/16.
  9 + */
  10 +public interface CalcToolService {
  11 +
  12 + List<CalcWaybill> findAll(String date, String line);
  13 +
  14 +}
... ...
src/main/java/com/bsth/service/calc/CalcWaybillService.java 0 → 100644
  1 +package com.bsth.service.calc;
  2 +
  3 +import java.util.List;
  4 +import java.util.Map;
  5 +
  6 +import com.bsth.entity.calc.CalcWaybill;
  7 +import com.bsth.service.BaseService;
  8 +
  9 +/**
  10 + * Created by 17/11/16.
  11 + */
  12 +public interface CalcWaybillService extends BaseService<CalcWaybill, Integer> {
  13 +
  14 + Map<String, Object> generateNew(String date, String line) throws Exception;
  15 +
  16 + List<Map<String, Object>> statisticsDailyTj(String gsdm,String fgsdm, String line, String date, String date2, String xlName, String type);
  17 +
  18 +}
... ...
src/main/java/com/bsth/service/calc/impl/CalcCulateMileageServiceImpl.java 0 → 100644
  1 +package com.bsth.service.calc.impl;
  2 +
  3 +import java.util.Iterator;
  4 +import java.util.List;
  5 +import java.util.Set;
  6 +
  7 +import org.apache.commons.lang.StringUtils;
  8 +import org.springframework.beans.factory.annotation.Autowired;
  9 +import org.springframework.jdbc.core.JdbcTemplate;
  10 +import org.springframework.stereotype.Service;
  11 +
  12 +import com.bsth.entity.realcontrol.ChildTaskPlan;
  13 +import com.bsth.entity.realcontrol.ScheduleRealInfo;
  14 +import com.bsth.service.calc.CalcCulateMileageService;
  15 +import com.bsth.util.Arith;
  16 +
  17 +@Service
  18 +public class CalcCulateMileageServiceImpl implements CalcCulateMileageService{
  19 + @Autowired
  20 + JdbcTemplate jdbcTemplate;
  21 + private static long zgf1 = 6 * 60 + 31,
  22 + zgf2 = 8 * 60 + 30,
  23 + wgf1 = 16 * 60 + 1,
  24 + wgf2 = 18 * 60;
  25 + public static boolean isInOut(ScheduleRealInfo s){
  26 + boolean fage=false;
  27 + if(s.getBcType().equals("in")){
  28 + fage=true;
  29 + }
  30 + if(s.getBcType().equals("out")){
  31 + fage=true;
  32 + }
  33 + if(s.getBcType().equals("ldks")){
  34 + fage=true;
  35 + }
  36 +
  37 + return fage;
  38 + }
  39 +
  40 + @Override
  41 + public int culateJhyybc(List<ScheduleRealInfo> lists,String item) {
  42 + //计划班次
  43 + int jhbc=0;
  44 + for (int i = 0; i < lists.size(); i++) {
  45 + ScheduleRealInfo scheduleRealInfo=lists.get(i);
  46 + if (!isInOut(scheduleRealInfo)) {
  47 + if(!scheduleRealInfo.isSflj() && !scheduleRealInfo.isCcService()){
  48 + String[] fcsjStr = scheduleRealInfo.getFcsj().split(":");
  49 + long fcsj= Long.parseLong(fcsjStr[0])*60+Long.parseLong(fcsjStr[1]);
  50 + if(item.equals("zgf")){
  51 + if(fcsj>=zgf1 && fcsj<=zgf2)
  52 + jhbc++;
  53 + }else if(item.equals("wgf")){
  54 + if(fcsj>=wgf1 && fcsj<=wgf2)
  55 + jhbc++;
  56 + }else{
  57 + jhbc++;
  58 + }
  59 +
  60 + }
  61 + }
  62 + }
  63 + return jhbc;
  64 + }
  65 +
  66 + @Override
  67 + public double culateJhyylc(List<ScheduleRealInfo> lists) {
  68 + //计划营运里程
  69 + double jhgl=0;
  70 + for (int i = 0; i < lists.size(); i++) {
  71 + ScheduleRealInfo scheduleRealInfo=lists.get(i);
  72 + if (!isInOut(scheduleRealInfo)) {
  73 + if(!scheduleRealInfo.isSflj() && !scheduleRealInfo.isCcService()){
  74 + jhgl=Arith.add(jhgl,scheduleRealInfo.getJhlcOrig()==null?0:scheduleRealInfo.getJhlcOrig());
  75 + }
  76 + }
  77 + }
  78 + return jhgl;
  79 + }
  80 +
  81 + @Override
  82 + public int culateJhfyybc(List<ScheduleRealInfo> lists) {
  83 + // 计划非营运里程
  84 + int fyybc =0;
  85 + for (int i = 0; i < lists.size(); i++) {
  86 + ScheduleRealInfo scheduleRealInfo=lists.get(i);
  87 + if(!scheduleRealInfo.isSflj() && !scheduleRealInfo.isCcService()){
  88 + if (scheduleRealInfo.getBcType().equals("in")
  89 + || scheduleRealInfo.getBcType().equals("out")|| scheduleRealInfo.getBcType().equals("ldks")) {
  90 + if(!scheduleRealInfo.isSflj()){
  91 + fyybc++;
  92 + }
  93 + }
  94 + }
  95 + }
  96 + return fyybc;
  97 + }
  98 + @Override
  99 + public double culateJhfyylc(List<ScheduleRealInfo> lists) {
  100 + // 计划非营运里程
  101 + double fyylc =0;
  102 + for (int i = 0; i < lists.size(); i++) {
  103 + ScheduleRealInfo scheduleRealInfo=lists.get(i);
  104 + if(!scheduleRealInfo.isSflj() && !scheduleRealInfo.isCcService()){
  105 + if (scheduleRealInfo.getBcType().equals("in")
  106 + || scheduleRealInfo.getBcType().equals("out")|| scheduleRealInfo.getBcType().equals("ldks")) {
  107 + if(!scheduleRealInfo.isSflj()){
  108 + fyylc =Arith.add(fyylc, scheduleRealInfo.getJhlcOrig()==null?0:scheduleRealInfo.getJhlcOrig());
  109 + }
  110 + }
  111 + }
  112 + }
  113 + return fyylc;
  114 + }
  115 +
  116 + @Override
  117 + public int culateSjyybc(List<ScheduleRealInfo> lists,String item) {
  118 + // 实际班次
  119 + int sjbc=0;
  120 + for (int i = 0; i < lists.size(); i++) {
  121 + ScheduleRealInfo scheduleRealInfo=lists.get(i);
  122 + if (!isInOut(scheduleRealInfo)) {
  123 + if(!scheduleRealInfo.isSflj() && !scheduleRealInfo.isCcService()){
  124 + String time="";
  125 + if(item.equals("zgf") || item.equals("wgf")){
  126 + if(scheduleRealInfo.getFcsjActual()!=null){
  127 + time=scheduleRealInfo.getFcsjActual();
  128 + }
  129 + if(time.equals("")){
  130 + if(scheduleRealInfo.getDfsj()!=null){
  131 + time=scheduleRealInfo.getDfsj();
  132 + }
  133 + }
  134 + }else{
  135 + time=scheduleRealInfo.getFcsj();
  136 + }
  137 + if(!time.equals("")){
  138 + String[] fcsjStr = time.split(":");
  139 + long fcsj= Long.parseLong(fcsjStr[0])*60+Long.parseLong(fcsjStr[1]);
  140 + if(scheduleRealInfo.getStatus()!=-1){
  141 + if(item.equals("zgf")){
  142 + if(fcsj>=zgf1 && fcsj<=zgf2){
  143 + sjbc++;
  144 + }
  145 + }else if(item.equals("wgf")){
  146 + if(fcsj>=wgf1 && fcsj<=wgf2){
  147 + sjbc++;
  148 + }
  149 + }else{
  150 + sjbc++;
  151 + }
  152 +
  153 + }
  154 + }
  155 + }
  156 + }
  157 + }
  158 + return sjbc;
  159 + }
  160 +
  161 + @Override
  162 + public double culateSjyylc(List<ScheduleRealInfo> lists) {
  163 + // 实际营运里程
  164 + double sjgl =0;
  165 + for (int i = 0; i < lists.size(); i++) {
  166 + ScheduleRealInfo scheduleRealInfo=lists.get(i);
  167 + if (!isInOut(scheduleRealInfo)) {
  168 + Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks();
  169 + if(!scheduleRealInfo.isSflj()){
  170 + if(childTaskPlans.isEmpty()){
  171 + if(!scheduleRealInfo.isDestroy()){
  172 + double jhlcOrig=scheduleRealInfo.getJhlcOrig()==null?0:scheduleRealInfo.getJhlcOrig();
  173 + double jhlc=scheduleRealInfo.getJhlc()==null?0:scheduleRealInfo.getJhlc();
  174 + if(jhlc-jhlcOrig>0){
  175 + sjgl=Arith.add(sjgl,jhlcOrig);
  176 + }else{
  177 + sjgl=Arith.add(sjgl,jhlc);
  178 + }
  179 + }
  180 + }else{
  181 + Iterator<ChildTaskPlan> it = childTaskPlans.iterator();
  182 + while (it.hasNext()) {
  183 + ChildTaskPlan childTaskPlan = it.next();
  184 + if(childTaskPlan.getMileageType().equals("service")
  185 + &&"正常".equals(childTaskPlan.getType1())
  186 + && childTaskPlan.getCcId()==null
  187 + && (!childTaskPlan.isNoClerk())){
  188 + if (!childTaskPlan.isDestroy()) {
  189 + Float jhgl=childTaskPlan.getMileage()==null?0:childTaskPlan.getMileage();
  190 + sjgl=Arith.add(sjgl,jhgl);
  191 + }
  192 + }
  193 + }
  194 + }
  195 + }
  196 + }
  197 + }
  198 + return sjgl;
  199 + }
  200 +
  201 + @Override
  202 + public double culateSjyylc_j(List<ScheduleRealInfo> lists) {
  203 + // 实际营运里程
  204 + double sjgl =0;
  205 + for (int i = 0; i < lists.size(); i++) {
  206 + ScheduleRealInfo scheduleRealInfo=lists.get(i);
  207 + if (!isInOut(scheduleRealInfo)) {
  208 + Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks();
  209 + if(!scheduleRealInfo.isSflj()){
  210 + if(!childTaskPlans.isEmpty()){
  211 + Iterator<ChildTaskPlan> it = childTaskPlans.iterator();
  212 + while (it.hasNext()) {
  213 + ChildTaskPlan childTaskPlan = it.next();
  214 + if(childTaskPlan.getMileageType().equals("service")
  215 + &&"正常".equals(childTaskPlan.getType1())
  216 + && childTaskPlan.getCcId()==null
  217 + && childTaskPlan.isNoClerk()){
  218 + if (!childTaskPlan.isDestroy()) {
  219 + Float jhgl=childTaskPlan.getMileage()==null?0:childTaskPlan.getMileage();
  220 + sjgl=Arith.add(sjgl,jhgl);
  221 + }
  222 + }
  223 + }
  224 + }
  225 + }
  226 + }
  227 + }
  228 + return sjgl;
  229 + }
  230 +
  231 + @Override
  232 + public double culateSjfyylc(List<ScheduleRealInfo> lists) {
  233 + // 实际非营运里程(驾售)
  234 + double sjgl =0;
  235 + for (int i = 0; i < lists.size(); i++) {
  236 + ScheduleRealInfo scheduleRealInfo=lists.get(i);
  237 +// if(!scheduleRealInfo.isSflj()){
  238 + Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks();
  239 + if(childTaskPlans.isEmpty()){
  240 + if (scheduleRealInfo.getBcType().equals("in") || scheduleRealInfo.getBcType().equals("out")
  241 + ||scheduleRealInfo.getBcType().equals("ldks")) {
  242 + if(!scheduleRealInfo.isDestroy()){
  243 + double jhlcOrig=scheduleRealInfo.getJhlcOrig()==null?0:scheduleRealInfo.getJhlcOrig();
  244 + double jhlc=scheduleRealInfo.getJhlc()==null?0:scheduleRealInfo.getJhlc();
  245 +// if(jhlc-jhlcOrig>0){
  246 +// sjgl=Arith.add(sjgl,jhlcOrig);
  247 +// }else{
  248 + sjgl=Arith.add(sjgl,jhlc);
  249 +// }
  250 + }
  251 + }
  252 + }else{
  253 + Iterator<ChildTaskPlan> it = childTaskPlans.iterator();
  254 + while (it.hasNext()) {
  255 + ChildTaskPlan childTaskPlan = it.next();
  256 + if(childTaskPlan.getMileageType().equals("empty")
  257 +// &&"正常".equals(childTaskPlan.getType1())
  258 + && (!childTaskPlan.isNoClerk())
  259 + && childTaskPlan.getCcId()==null){
  260 + if (!childTaskPlan.isDestroy()) {
  261 + Float jhgl=childTaskPlan.getMileage()==null?0:childTaskPlan.getMileage();
  262 + sjgl=Arith.add(sjgl,jhgl);
  263 + }
  264 + }
  265 + }
  266 + }
  267 +// }
  268 + }
  269 + return sjgl;
  270 + }
  271 +
  272 + @Override
  273 + public double culateSjfyylc_j(List<ScheduleRealInfo> lists) {
  274 + // 实际非营运里程(驾)
  275 + double sjgl =0;
  276 + for (int i = 0; i < lists.size(); i++) {
  277 + ScheduleRealInfo scheduleRealInfo=lists.get(i);
  278 + if(!scheduleRealInfo.isSflj()){
  279 + Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks();
  280 + if(!childTaskPlans.isEmpty()){
  281 + Iterator<ChildTaskPlan> it = childTaskPlans.iterator();
  282 + while (it.hasNext()) {
  283 + ChildTaskPlan childTaskPlan = it.next();
  284 + if(childTaskPlan.getMileageType().equals("empty")
  285 + &&"正常".equals(childTaskPlan.getType1())
  286 + && childTaskPlan.getCcId()==null
  287 + && childTaskPlan.isNoClerk()){
  288 + if (!childTaskPlan.isDestroy()) {
  289 + Float jhgl=childTaskPlan.getMileage()==null?0:childTaskPlan.getMileage();
  290 + sjgl=Arith.add(sjgl,jhgl);
  291 + }
  292 + }
  293 + }
  294 + }
  295 + }
  296 + }
  297 + return sjgl;
  298 + }
  299 +
  300 + @Override
  301 + public int culateLjbc(List<ScheduleRealInfo> lists,String item) {
  302 + // 临加班次
  303 + int ljbc=0;
  304 + for (int i = 0; i < lists.size(); i++) {
  305 + ScheduleRealInfo scheduleRealInfo=lists.get(i);
  306 + if (!isInOut(scheduleRealInfo)) {
  307 + if(scheduleRealInfo.isSflj()){
  308 + if(item.equals("zgf") || item.equals("wgf")){
  309 + String time="";
  310 + if(scheduleRealInfo.getFcsjActual()!=null)
  311 + time=scheduleRealInfo.getFcsjActual();
  312 + if(time.equals("")){
  313 + if(scheduleRealInfo.getDfsj()!=null)
  314 + time=scheduleRealInfo.getDfsj();
  315 + }
  316 + if(!time.equals("")){
  317 + String[] fcsjStr = time.split(":");
  318 + long fcsj= Long.parseLong(fcsjStr[0])*60+Long.parseLong(fcsjStr[1]);
  319 + if(item.equals("zgf")){
  320 + if(fcsj>=zgf1 && fcsj<=zgf2)
  321 + ljbc++;
  322 + }else if(item.equals("wgf")){
  323 + if(fcsj>=wgf1 && fcsj<=wgf2)
  324 + ljbc++;
  325 + }
  326 + }
  327 + }else{
  328 + ljbc++;
  329 + }
  330 + }
  331 + }
  332 + }
  333 + return ljbc;
  334 + }
  335 +
  336 +
  337 + @Override
  338 + public double culateLjyylc(List<ScheduleRealInfo> lists) {
  339 + // 临加营运里程(驾售)
  340 + double ljgl =0;
  341 + for (int i = 0; i < lists.size(); i++) {
  342 + ScheduleRealInfo scheduleRealInfo=lists.get(i);
  343 + if (!isInOut(scheduleRealInfo)) {
  344 + Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks();
  345 + if(scheduleRealInfo.isSflj()){
  346 + if(childTaskPlans.isEmpty()){
  347 + if(!scheduleRealInfo.isDestroy())
  348 + ljgl=Arith.add(ljgl,scheduleRealInfo.getJhlc()==null?0:scheduleRealInfo.getJhlc());
  349 + }else{
  350 + Iterator<ChildTaskPlan> it = childTaskPlans.iterator();
  351 + while (it.hasNext()) {
  352 + ChildTaskPlan childTaskPlan = it.next();
  353 + if(childTaskPlan.getMileageType().equals("service")
  354 + && childTaskPlan.getCcId() == null
  355 + && (!childTaskPlan.isNoClerk())){
  356 + if (!childTaskPlan.isDestroy()) {
  357 + Float jhgl=childTaskPlan.getMileage()==null?0:childTaskPlan.getMileage();
  358 + ljgl=Arith.add(ljgl,jhgl);
  359 + }
  360 + }
  361 + }
  362 + }
  363 + }else{
  364 + if(childTaskPlans.isEmpty()){
  365 + double jhlc=scheduleRealInfo.getJhlc()==null?0:scheduleRealInfo.getJhlc();
  366 + double jhlcOrig=scheduleRealInfo.getJhlcOrig()==null?0:scheduleRealInfo.getJhlcOrig();
  367 + double zjlc=Arith.sub(jhlc, jhlcOrig);
  368 + if(zjlc>0){
  369 + ljgl=Arith.add(zjlc, ljgl);
  370 + }
  371 + }else{
  372 + Iterator<ChildTaskPlan> it = childTaskPlans.iterator();
  373 + while (it.hasNext()) {
  374 + ChildTaskPlan childTaskPlan = it.next();
  375 + if("service".equals(childTaskPlan.getMileageType())
  376 + &&"临加".equals(childTaskPlan.getType1())
  377 + && childTaskPlan.getCcId() == null
  378 + && (!childTaskPlan.isNoClerk())){
  379 + if (!childTaskPlan.isDestroy()) {
  380 + Float jhgl=childTaskPlan.getMileage()==null?0:childTaskPlan.getMileage();
  381 + ljgl=Arith.add(ljgl,jhgl);
  382 + }
  383 + }
  384 + }
  385 + }
  386 + }
  387 + }
  388 + }
  389 + return ljgl;
  390 + }
  391 +
  392 + @Override
  393 + public double culateLjyylc_j(List<ScheduleRealInfo> lists) {
  394 + // 临加营运里程(驾)
  395 + double ljgl =0;
  396 + for (int i = 0; i < lists.size(); i++) {
  397 + ScheduleRealInfo scheduleRealInfo=lists.get(i);
  398 + if (!isInOut(scheduleRealInfo)) {
  399 + Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks();
  400 + if(scheduleRealInfo.isSflj()){
  401 + if(!childTaskPlans.isEmpty()){
  402 + Iterator<ChildTaskPlan> it = childTaskPlans.iterator();
  403 + while (it.hasNext()) {
  404 + ChildTaskPlan childTaskPlan = it.next();
  405 + if(childTaskPlan.getMileageType().equals("service")
  406 + && childTaskPlan.getCcId()==null
  407 + && childTaskPlan.isNoClerk()){
  408 + if (!childTaskPlan.isDestroy()) {
  409 + Float jhgl=childTaskPlan.getMileage()==null?0:childTaskPlan.getMileage();
  410 + ljgl=Arith.add(ljgl,jhgl);
  411 + }
  412 + }
  413 + }
  414 + }
  415 + }else{
  416 + if(childTaskPlans.isEmpty()){
  417 + Iterator<ChildTaskPlan> it = childTaskPlans.iterator();
  418 + while (it.hasNext()) {
  419 + ChildTaskPlan childTaskPlan = it.next();
  420 + if("service".equals(childTaskPlan.getMileageType())
  421 + &&"临加".equals(childTaskPlan.getType1())
  422 + && childTaskPlan.getCcId()==null
  423 + && childTaskPlan.isNoClerk()){
  424 + if (!childTaskPlan.isDestroy()) {
  425 + Float jhgl=childTaskPlan.getMileage()==null?0:childTaskPlan.getMileage();
  426 + ljgl=Arith.add(ljgl,jhgl);
  427 + }
  428 + }
  429 + }
  430 + }
  431 + }
  432 + }
  433 + }
  434 + return ljgl;
  435 + }
  436 +
  437 + @Override
  438 + public double culateLjfyylc(List<ScheduleRealInfo> lists) {
  439 + // 临加非营运里程(驾售)
  440 + double ljgl =0;
  441 + for (int i = 0; i < lists.size(); i++) {
  442 + ScheduleRealInfo scheduleRealInfo=lists.get(i);
  443 + Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks();
  444 + if (isInOut(scheduleRealInfo)) {
  445 + if(scheduleRealInfo.isSflj()){
  446 + if(childTaskPlans.isEmpty()){
  447 + if(!scheduleRealInfo.isDestroy())
  448 + ljgl=Arith.add(ljgl,scheduleRealInfo.getJhlc()==null?0:scheduleRealInfo.getJhlc());
  449 + }else{
  450 + Iterator<ChildTaskPlan> it = childTaskPlans.iterator();
  451 + while (it.hasNext()) {
  452 + ChildTaskPlan childTaskPlan = it.next();
  453 + if(childTaskPlan.getMileageType().equals("empty")
  454 + && childTaskPlan.getCcId() == null
  455 + && (!childTaskPlan.isNoClerk())){
  456 + if (!childTaskPlan.isDestroy()) {
  457 + Float jhgl=childTaskPlan.getMileage()==null?0:childTaskPlan.getMileage();
  458 + ljgl=Arith.add(ljgl,jhgl);
  459 + }
  460 + }
  461 + }
  462 + }
  463 + }else{
  464 + if(childTaskPlans.isEmpty()){
  465 + double jhlc=scheduleRealInfo.getJhlc()==null?0:scheduleRealInfo.getJhlc();
  466 + double jhlcOrig=scheduleRealInfo.getJhlcOrig()==null?0:scheduleRealInfo.getJhlcOrig();
  467 + double zjlc=Arith.sub(jhlc, jhlcOrig);
  468 + if(zjlc>0){
  469 + ljgl=Arith.add(zjlc, ljgl);
  470 + }
  471 + }else{
  472 + Iterator<ChildTaskPlan> it = childTaskPlans.iterator();
  473 + while (it.hasNext()) {
  474 + ChildTaskPlan childTaskPlan = it.next();
  475 + if("empty".equals(childTaskPlan.getMileageType())
  476 + &&"临加".equals(childTaskPlan.getType1())
  477 + && childTaskPlan.getCcId() == null
  478 + && (!childTaskPlan.isNoClerk())){
  479 + if (!childTaskPlan.isDestroy()) {
  480 + Float jhgl=childTaskPlan.getMileage()==null?0:childTaskPlan.getMileage();
  481 + ljgl=Arith.add(ljgl,jhgl);
  482 + }
  483 + }
  484 + }
  485 + }
  486 + }
  487 + }else{
  488 + if (!childTaskPlans.isEmpty()) {
  489 + Iterator<ChildTaskPlan> it = childTaskPlans.iterator();
  490 + while (it.hasNext()) {
  491 + ChildTaskPlan childTaskPlan = it.next();
  492 + if ("empty".equals(childTaskPlan.getMileageType())
  493 + && "临加".equals(childTaskPlan.getType1())
  494 + && childTaskPlan.getCcId() == null
  495 + && (!childTaskPlan.isNoClerk())) {
  496 + if (!childTaskPlan.isDestroy()) {
  497 + Float jhgl = childTaskPlan.getMileage() == null ? 0 : childTaskPlan.getMileage();
  498 + ljgl = Arith.add(ljgl, jhgl);
  499 + }
  500 + }
  501 + }
  502 + }
  503 + }
  504 + }
  505 + return ljgl;
  506 + }
  507 +
  508 + @Override
  509 + public double culateLjfyylc_j(List<ScheduleRealInfo> lists) {
  510 + // 临加非营运里程(驾)
  511 + double ljgl =0;
  512 + for (int i = 0; i < lists.size(); i++) {
  513 + ScheduleRealInfo scheduleRealInfo=lists.get(i);
  514 + if (!isInOut(scheduleRealInfo)) {
  515 + Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks();
  516 + if(scheduleRealInfo.isSflj()){
  517 + if(!childTaskPlans.isEmpty()){
  518 + Iterator<ChildTaskPlan> it = childTaskPlans.iterator();
  519 + while (it.hasNext()) {
  520 + ChildTaskPlan childTaskPlan = it.next();
  521 + if(childTaskPlan.getMileageType().equals("empty")
  522 + && childTaskPlan.getCcId()==null
  523 + && childTaskPlan.isNoClerk()){
  524 + if (!childTaskPlan.isDestroy()) {
  525 + Float jhgl=childTaskPlan.getMileage()==null?0:childTaskPlan.getMileage();
  526 + ljgl=Arith.add(ljgl,jhgl);
  527 + }
  528 + }
  529 + }
  530 + }
  531 + }else{
  532 + if(childTaskPlans.isEmpty()){
  533 + Iterator<ChildTaskPlan> it = childTaskPlans.iterator();
  534 + while (it.hasNext()) {
  535 + ChildTaskPlan childTaskPlan = it.next();
  536 + if("empty".equals(childTaskPlan.getMileageType())
  537 + &&"临加".equals(childTaskPlan.getType1())
  538 + && childTaskPlan.getCcId()==null
  539 + && childTaskPlan.isNoClerk()){
  540 + if (!childTaskPlan.isDestroy()) {
  541 + Float jhgl=childTaskPlan.getMileage()==null?0:childTaskPlan.getMileage();
  542 + ljgl=Arith.add(ljgl,jhgl);
  543 + }
  544 + }
  545 + }
  546 + }
  547 + }
  548 + }
  549 + }
  550 + return ljgl;
  551 + }
  552 +
  553 + @Override
  554 + public int culateLbbc(List<ScheduleRealInfo> lists) {
  555 + // 烂班班次
  556 + int lbbc=0;
  557 + for (int i = 0; i < lists.size(); i++) {
  558 + ScheduleRealInfo scheduleRealInfo=lists.get(i);
  559 + if (!isInOut(scheduleRealInfo) && !scheduleRealInfo.isCcService()) {
  560 + if(scheduleRealInfo.getStatus() == -1){
  561 + lbbc++;
  562 + }
  563 + }
  564 + }
  565 + return lbbc;
  566 + }
  567 +
  568 + @Override
  569 + public double culateLbgl(List<ScheduleRealInfo> lists) {
  570 + // TODO Auto-generated method stub
  571 + double zlblc =0.0;
  572 + for (int i = 0; i < lists.size(); i++) {
  573 + ScheduleRealInfo scheduleRealInfo=lists.get(i);
  574 + if (!isInOut(scheduleRealInfo)) {
  575 + Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks();
  576 + if(childTaskPlans.isEmpty()){
  577 + if(scheduleRealInfo.isDestroy()){
  578 + zlblc=Arith.add(zlblc,scheduleRealInfo.getJhlcOrig()==null?0:scheduleRealInfo.getJhlcOrig());
  579 + }else{
  580 + double jhlc=scheduleRealInfo.getJhlc()==null?0:scheduleRealInfo.getJhlc();
  581 + double jhlcOrig=scheduleRealInfo.getJhlcOrig()==null?0:scheduleRealInfo.getJhlcOrig();
  582 + double cjlc=Arith.sub(jhlcOrig,jhlc);
  583 + if(cjlc>0){
  584 + zlblc=Arith.add(zlblc, cjlc);
  585 + }
  586 + }
  587 + }else{
  588 + Iterator<ChildTaskPlan> it = childTaskPlans.iterator();
  589 + while (it.hasNext()) {
  590 + ChildTaskPlan childTaskPlan = it.next();
  591 + if(childTaskPlan.getMileageType().equals("service") && childTaskPlan.getCcId() == null){
  592 + if (childTaskPlan.isDestroy()) {
  593 + zlblc=Arith.add(zlblc,childTaskPlan.getMileage()==null?0:childTaskPlan.getMileage());
  594 + }
  595 + }
  596 + }
  597 + }
  598 + }
  599 + }
  600 + return zlblc;
  601 + }
  602 +
  603 + @Override
  604 + public double culateCJLC(List<ScheduleRealInfo> list, String item) {
  605 + // TODO Auto-generated method stub
  606 + double sum = 0;
  607 + Set<ChildTaskPlan> cts;
  608 + for(ScheduleRealInfo sch : list){
  609 + if (sch.isSflj())
  610 + continue;
  611 + cts = sch.getcTasks();
  612 + //有子任务
  613 + if (cts != null && cts.size() > 0) {
  614 + for(ChildTaskPlan c : cts){
  615 + if(c.getCcId() == null){
  616 + if(item.equals("其他")){
  617 + if(c.isDestroy() &&
  618 + ((c.getDestroyReason()==null?"": c.getDestroyReason()).equals(item)||
  619 + (c.getDestroyReason()==null?"": c.getDestroyReason()).equals("")))
  620 + sum = Arith.add(sum, c.getMileage());
  621 + }else{
  622 + if(c.isDestroy() && (c.getDestroyReason()==null?"": c.getDestroyReason()).equals(item))
  623 + sum = Arith.add(sum, c.getMileage());
  624 + }
  625 + }
  626 + }
  627 + }
  628 + else if(isInOut(sch))
  629 + continue;
  630 + //主任务烂班
  631 + else if(sch.getStatus() == -1){
  632 + if(sch.getAdjustExps().equals(item) ||
  633 + (StringUtils.isEmpty(sch.getAdjustExps()) && item.equals("其他"))){
  634 + sum = Arith.add(sum, sch.getJhlcOrig());
  635 + }
  636 + }
  637 + else if(item.equals("其他")){
  638 + double diff = Arith.sub(sch.getJhlcOrig(), sch.getJhlc());
  639 + if(diff > 0){
  640 + sum = Arith.add(sum, diff);
  641 + }
  642 + }
  643 + }
  644 + return sum;
  645 + }
  646 +
  647 + @Override
  648 + public int culateDtfzbc(List<ScheduleRealInfo> lists,String type,String item){
  649 + int bc=0;
  650 + for (int i = 0; i < lists.size(); i++) {
  651 + ScheduleRealInfo s=lists.get(i);
  652 + if (s.getBcType().equals(type)) {
  653 + if (s.getFcsjActual() != null) {
  654 + if (!s.isDestroy()) {
  655 + String fcsjs = s.getFcsjActual();
  656 + String[] fcsjStr = fcsjs.split(":");
  657 + long fcsj = Long.parseLong(fcsjStr[0]) * 60 + Long.parseLong(fcsjStr[1]);
  658 + if (item.equals("zgf")) {
  659 + if (fcsj > zgf1 && fcsj < zgf2)
  660 + bc++;
  661 + } else if (item.equals("wgf")) {
  662 + if (fcsj > wgf1 && fcsj < wgf2)
  663 + bc++;
  664 + } else {
  665 + bc++;
  666 + }
  667 + }
  668 + }
  669 + }
  670 + }
  671 + return bc;
  672 + }
  673 +}
... ...
src/main/java/com/bsth/service/calc/impl/CalcToolServiceImpl.java 0 → 100644
  1 +package com.bsth.service.calc.impl;
  2 +
  3 +import java.sql.ResultSet;
  4 +import java.sql.SQLException;
  5 +import java.util.ArrayList;
  6 +import java.util.Date;
  7 +import java.util.HashMap;
  8 +import java.util.List;
  9 +import java.util.Map;
  10 +import java.util.Set;
  11 +
  12 +import com.bsth.entity.calc.CalcWaybill;
  13 +import com.bsth.entity.realcontrol.ChildTaskPlan;
  14 +import com.bsth.entity.realcontrol.ScheduleRealInfo;
  15 +import com.bsth.repository.calc.CalcWaybillRepository;
  16 +import com.bsth.service.calc.CalcToolService;
  17 +import com.bsth.service.calc.CalcCulateMileageService;
  18 +import com.bsth.service.report.CulateMileageService;
  19 +import com.bsth.util.Arith;
  20 +
  21 +import org.slf4j.Logger;
  22 +import org.slf4j.LoggerFactory;
  23 +import org.springframework.beans.factory.annotation.Autowired;
  24 +import org.springframework.jdbc.core.JdbcTemplate;
  25 +import org.springframework.jdbc.core.RowMapper;
  26 +import org.springframework.stereotype.Service;
  27 +
  28 +/**
  29 + * Created by 17/11/16.
  30 + */
  31 +@Service
  32 +public class CalcToolServiceImpl implements CalcToolService {
  33 +
  34 + @Autowired
  35 + private CalcWaybillRepository clacRepository;
  36 +
  37 + @Autowired
  38 + private CalcCulateMileageService culateMileageService;
  39 +
  40 + @Autowired
  41 + private CulateMileageService culateMileageService2;
  42 +
  43 + @Autowired
  44 + JdbcTemplate jdbcTemplate;
  45 +
  46 +
  47 + Logger logger = LoggerFactory.getLogger(this.getClass());
  48 +
  49 +
  50 + @Override
  51 + public List<CalcWaybill> findAll(String rq, String lineCode) {
  52 + List<CalcWaybill> listCal=new ArrayList<CalcWaybill>();
  53 + List<ScheduleRealInfo> list = clacRepository.findAllSchedule(rq,lineCode);
  54 + String sql ="select r.j_gh ,r.s_gh,r.cl_zbh,r.xl_bm, r.lp_name FROM"
  55 + + " bsth_c_s_sp_info_real r where "
  56 + + " r.schedule_date_str='"+rq+"' and r.xl_bm = '"+lineCode+"'"
  57 + + " GROUP BY r.j_gh,r.s_gh,r.cl_zbh,r.xl_bm,r.lp_name ";
  58 +
  59 + List<Map<String, String>> listMap = jdbcTemplate.query(sql, new RowMapper<Map<String, String>>() {
  60 + @Override
  61 + public Map<String, String> mapRow(ResultSet arg0, int arg1) throws SQLException {
  62 + Map<String, String> c = new HashMap<String,String>();
  63 + c.put("jGh", arg0.getString("j_gh"));
  64 + c.put("sGh", arg0.getString("s_gh")==null?"":arg0.getString("s_gh"));
  65 + c.put("clZbh", arg0.getString("cl_zbh"));
  66 + c.put("xlBm", arg0.getString("xl_bm"));
  67 + c.put("lpName", arg0.getString("lp_name"));
  68 + return c;
  69 + }
  70 + });
  71 + for (int i = 0; i < listMap.size(); i++) {
  72 + Map<String, String> m=listMap.get(i);
  73 + String jGh=m.get("jGh");
  74 + String sGh=m.get("sGh");
  75 + String clZbh=m.get("clZbh");
  76 + String xlBm=m.get("xlBm");
  77 + String lpName=m.get("lpName");
  78 + //所有数据排班数据
  79 + List<ScheduleRealInfo> list_=new ArrayList<ScheduleRealInfo>();
  80 + //执行了的班次的排班数据
  81 + List<ScheduleRealInfo> lists_=new ArrayList<ScheduleRealInfo>();
  82 + for (int j = 0; j < list.size(); j++) {
  83 + ScheduleRealInfo s=list.get(j);
  84 + s.setCreateDate(new Date());
  85 + if(jGh.equals(s.getjGh())
  86 + && sGh.equals(s.getsGh()==null?"":s.getsGh())
  87 + && clZbh.equals(s.getClZbh())
  88 + && xlBm.equals(s.getXlBm())
  89 + && lpName.equals(s.getLpName())){
  90 +
  91 + list_.add(s);
  92 +
  93 + Set<ChildTaskPlan> cts = s.getcTasks();
  94 + if(cts != null && cts.size() > 0){
  95 + lists_.add(s);
  96 + }else{
  97 + if(s.getZdsjActual()!=null
  98 + && s.getFcsjActual() !=null){
  99 + lists_.add(s);
  100 + }
  101 + }
  102 + }
  103 + }
  104 +
  105 + //计算方法
  106 + if(list_.size()>0){
  107 + listCal.addAll(this.cul(list_, lists_));
  108 + }
  109 + }
  110 + while(true){
  111 + int i = 0, l = 0;
  112 + boolean flag = false;
  113 + for(; i < listCal.size(); i++){
  114 + CalcWaybill c1 = listCal.get(i);
  115 + String key = c1.getRqStr() +"-"+ c1.getXl() +"-"+ c1.getCl() +"-"+ c1.getjGh() +"-"+ c1.getsGh() +"-"+ c1.getLp();
  116 + for(l = 0; l < listCal.size(); l++){
  117 + if(l != i){
  118 + CalcWaybill c2 = listCal.get(l);
  119 + String key_ = c2.getRqStr() +"-"+ c2.getXl() +"-"+ c2.getCl() +"-"+ c2.getjGh() +"-"+ c2.getsGh() +"-"+ c2.getLp();
  120 + if(key_.equals(key)){
  121 + flag = true;
  122 + break;
  123 + }
  124 + }
  125 + }
  126 + if(flag){
  127 + break;
  128 + }
  129 + }
  130 + if(i != l){
  131 + CalcWaybill c1 = listCal.get(i);
  132 + CalcWaybill c2 = listCal.get(l);
  133 +
  134 + c1.setSjyylc(c1.getSjyylc() + c2.getSjyylc());
  135 + c1.setSjfyylc(c1.getSjfyylc() + c2.getSjfyylc());
  136 + c1.setLjyylc(c1.getLjyylc() + c2.getLjyylc());
  137 + c1.setLjfyylc(c1.getLjfyylc() + c2.getLjfyylc());
  138 +
  139 + listCal.remove(l);
  140 + } else {
  141 + break;
  142 + }
  143 + }
  144 + return listCal;
  145 + }
  146 +
  147 + //list_ 全部班次 lists_执行了的班次(实到实发不为空)
  148 + private List<CalcWaybill> cul(List<ScheduleRealInfo> list_,List<ScheduleRealInfo> lists_){
  149 + List<CalcWaybill> list=new ArrayList<CalcWaybill>();
  150 + if(list_.size()>0){
  151 + Date date=list_.get(0).getScheduleDate();
  152 + String dateStr=list_.get(0).getScheduleDateStr();
  153 + String gsdm=list_.get(0).getGsBm();
  154 + String gsname=list_.get(0).getGsName();
  155 + String fgsdm=list_.get(0).getFgsBm();
  156 + String fgsname=list_.get(0).getFgsName();
  157 + String xlbm=list_.get(0).getXlBm();
  158 + String xlname=list_.get(0).getXlName();
  159 + String lp=list_.get(0).getLpName();
  160 + String jgh=list_.get(0).getjGh();
  161 + String jname=list_.get(0).getjName();
  162 + String sgh=list_.get(0).getsGh();
  163 + String sname=list_.get(0).getsName();
  164 + String clzbh=list_.get(0).getClZbh();
  165 + int jhyybc=culateMileageService.culateJhyybc(list_, "");
  166 + int jhyybcZgf=culateMileageService.culateJhyybc(list_, "zgf");
  167 + int jhyybcWgf=culateMileageService.culateJhyybc(list_, "wgf");
  168 + double jhyylc=culateMileageService.culateJhyylc(list_);
  169 + double jhfyylc=culateMileageService.culateJhfyylc(list_);
  170 + int sjyybc=culateMileageService.culateSjyybc(lists_, "");
  171 + int sjyybcZgf=culateMileageService.culateSjyybc(lists_, "zgf");
  172 + int sjyybcWgf=culateMileageService.culateSjyybc(lists_, "wgf");
  173 + double sjyylc=culateMileageService.culateSjyylc(lists_);//驾售共有
  174 + double sjyylc_j=culateMileageService.culateSjyylc_j(lists_);//无售
  175 + double sjfyylc=culateMileageService.culateSjfyylc(lists_);//驾售
  176 + double sjfyylc_j=culateMileageService.culateSjfyylc_j(lists_);//无售
  177 + int ljbc=culateMileageService.culateLjbc(lists_, "");
  178 + int ljbcZgf=culateMileageService.culateLjbc(lists_, "zgf");
  179 + int ljbcWgf=culateMileageService.culateLjbc(lists_, "wgf");
  180 + double ljyylc=culateMileageService.culateLjyylc(lists_);//驾售
  181 + double ljyylc_j=culateMileageService.culateLjyylc_j(lists_);//无售
  182 + double ljfyylc=culateMileageService.culateLjfyylc(lists_);//驾售
  183 + double ljfyylc_j=culateMileageService.culateLjfyylc_j(lists_);//无售
  184 + int lbbc=culateMileageService.culateLbbc(list_);
  185 + double lblc=culateMileageService.culateLbgl(list_);
  186 + double ssgl_lz= culateMileageService.culateCJLC(list_, "路阻");
  187 + double ssgl_dm= culateMileageService.culateCJLC(list_, "吊慢");
  188 + double ssgl_gz= culateMileageService.culateCJLC(list_, "故障");
  189 + double ssgl_jf= culateMileageService.culateCJLC(list_, "纠纷");
  190 + double ssgl_zs= culateMileageService.culateCJLC(list_, "肇事");
  191 + double ssgl_qr= culateMileageService.culateCJLC(list_, "缺人");
  192 + double ssgl_qc= culateMileageService.culateCJLC(list_, "缺车");
  193 + double ssgl_kx= culateMileageService.culateCJLC(list_, "客稀");
  194 + double ssgl_qh= culateMileageService.culateCJLC(list_, "气候");
  195 + double ssgl_yw= culateMileageService.culateCJLC(list_, "援外");
  196 +
  197 + double ssgl_pc=culateMileageService.culateCJLC(list_, "配车");
  198 + double ssgl_by=culateMileageService.culateCJLC(list_, "保养");
  199 + double ssgl_cj=culateMileageService.culateCJLC(list_, "抽减");
  200 + double ssgl_qt=culateMileageService.culateCJLC(list_, "其他");
  201 + double ssgl_qtz=Arith.add(Arith.add(ssgl_pc, ssgl_by), Arith.add(ssgl_cj,ssgl_qt));
  202 + int fzbc=culateMileageService.culateDtfzbc(lists_, "major", "");//放站
  203 + int fzbcZgf=culateMileageService.culateDtfzbc(lists_, "major", "zgf");
  204 + int fzbcWgf=culateMileageService.culateDtfzbc(lists_, "major", "wgf");
  205 + int zfbc=culateMileageService.culateDtfzbc(lists_, "venting", "");//直放
  206 + int zfbcZgf=culateMileageService.culateDtfzbc(lists_, "venting", "zgf");
  207 + int zfbcWgf=culateMileageService.culateDtfzbc(lists_, "venting", "wgf");
  208 + CalcWaybill t=new CalcWaybill();
  209 + t.setRq(date);
  210 + t.setRqStr(dateStr);
  211 + t.setGsdm(gsdm);
  212 + t.setGsname(gsname);
  213 + t.setFgsdm(fgsdm);
  214 + t.setFgsname(fgsname);
  215 + t.setXl(xlbm);
  216 + t.setXlName(xlname);
  217 + t.setLp(lp);
  218 + t.setCl(clzbh);
  219 + t.setjGh(jgh);
  220 + t.setjName(jname);
  221 + t.setsGh(sgh);
  222 + t.setsName(sname);
  223 + t.setJhyybc(jhyybc);
  224 + t.setJhyybczgf(jhyybcZgf);
  225 + t.setJhyybcwgf(jhyybcWgf);
  226 + t.setJhyylc(jhyylc);
  227 + t.setJhfyylc(jhfyylc);
  228 + t.setSjyybc(sjyybc);
  229 + t.setSjyybczgf(sjyybcZgf);
  230 + t.setSjyybcwgf(sjyybcWgf);
  231 + t.setSjyylc(sjyylc);
  232 + t.setSjfyylc(sjfyylc);
  233 + t.setLjbc(ljbc);
  234 + t.setLjbczgf(ljbcZgf);
  235 + t.setLjbcwgf(ljbcWgf);
  236 + t.setLjyylc(ljyylc);
  237 + t.setLjfyylc(ljfyylc);
  238 + t.setLbbc(lbbc);
  239 + t.setLblc(lblc);
  240 + t.setLblcLz(ssgl_lz);
  241 + t.setLblcDm(ssgl_dm);
  242 + t.setLblcGz(ssgl_gz);
  243 + t.setLblcJf(ssgl_jf);
  244 + t.setLblcZs(ssgl_zs);
  245 + t.setLblcQr(ssgl_qr);
  246 + t.setLblcQc(ssgl_qc);
  247 + t.setLblcKx(ssgl_kx);
  248 + t.setLblcQh(ssgl_qh);
  249 + t.setLblcYw(ssgl_yw);
  250 + t.setLblcQt(ssgl_qtz);
  251 + t.setFzbc(fzbc+zfbc);
  252 + t.setFzbczgf(fzbcZgf+zfbcZgf);
  253 + t.setFzbcwgf(fzbcWgf+zfbcWgf);
  254 + t.setDtbc(0);
  255 + t.setDtbczgf(0);
  256 + t.setDtbcwgf(0);
  257 + list.add(t);
  258 + //驾驶员单独行驶里程
  259 + if(sjyylc_j>0||sjfyylc_j>0||ljyylc_j>0||ljfyylc_j>0){
  260 + CalcWaybill t_=new CalcWaybill();
  261 + t_.setRq(date);
  262 + t_.setRqStr(dateStr);
  263 + t_.setGsdm(gsdm);
  264 + t_.setGsname(gsname);
  265 + t_.setFgsdm(fgsdm);
  266 + t_.setFgsname(fgsname);
  267 + t_.setXl(xlbm);
  268 + t_.setXlName(xlname);
  269 + t_.setLp(lp);
  270 + t_.setCl(clzbh);
  271 + t_.setjGh(jgh);
  272 + t_.setjName(jname);
  273 + t_.setSjyylc(sjyylc_j);
  274 + t_.setSjfyylc(sjfyylc_j);
  275 + t_.setLjyylc(ljyylc_j);
  276 + t_.setLjfyylc(ljfyylc_j);
  277 + t_.setsGh("");
  278 + t_.setsName("");
  279 + t_.setJhyybc(0);
  280 + t_.setJhyybczgf(0);
  281 + t_.setJhyybcwgf(0);
  282 + t_.setJhyylc(0.0);
  283 + t_.setJhfyylc(0.0);
  284 + t_.setSjyybc(0);
  285 + t_.setSjyybczgf(0);
  286 + t_.setSjyybcwgf(0);
  287 + t_.setLjbc(0);
  288 + t_.setLjbczgf(0);
  289 + t_.setLjbcwgf(0);
  290 + t_.setLbbc(0);
  291 + t_.setLblc(0.0);
  292 + t_.setLblcLz(0.0);
  293 + t_.setLblcDm(0.0);
  294 + t_.setLblcGz(0.0);
  295 + t_.setLblcJf(0.0);
  296 + t_.setLblcZs(0.0);
  297 + t_.setLblcQr(0.0);
  298 + t_.setLblcQc(0.0);
  299 + t_.setLblcKx(0.0);
  300 + t_.setLblcQh(0.0);
  301 + t_.setLblcYw(0.0);
  302 + t_.setLblcQt(0.0);
  303 + t_.setFzbc(0);
  304 + t_.setFzbczgf(0);
  305 + t_.setFzbcwgf(0);
  306 + t_.setDtbc(0);
  307 + t_.setDtbczgf(0);
  308 + t_.setDtbcwgf(0);
  309 + list.add(t_);
  310 + }
  311 + }
  312 + return list;
  313 + }
  314 +
  315 +}
... ...
src/main/java/com/bsth/service/calc/impl/CalcWaybillServiceImpl.java 0 → 100644
  1 +package com.bsth.service.calc.impl;
  2 +
  3 +import java.sql.ResultSet;
  4 +import java.sql.SQLException;
  5 +import java.util.ArrayList;
  6 +import java.util.HashMap;
  7 +import java.util.HashSet;
  8 +import java.util.List;
  9 +import java.util.Map;
  10 +import java.util.Set;
  11 +
  12 +import javax.transaction.Transactional;
  13 +
  14 +import com.bsth.common.ResponseCode;
  15 +import com.bsth.entity.calc.CalcWaybill;
  16 +import com.bsth.repository.calc.CalcWaybillRepository;
  17 +import com.bsth.service.calc.CalcToolService;
  18 +import com.bsth.service.calc.CalcWaybillService;
  19 +import com.bsth.service.impl.BaseServiceImpl;
  20 +import com.bsth.util.Arith;
  21 +import com.bsth.util.BatchSaveUtils;
  22 +
  23 +import org.slf4j.Logger;
  24 +import org.slf4j.LoggerFactory;
  25 +import org.springframework.beans.factory.annotation.Autowired;
  26 +import org.springframework.jdbc.core.JdbcTemplate;
  27 +import org.springframework.jdbc.core.RowMapper;
  28 +import org.springframework.stereotype.Service;
  29 +
  30 +/**
  31 + * Created by 17/11/16.
  32 + */
  33 +@Service
  34 +public class CalcWaybillServiceImpl extends BaseServiceImpl<CalcWaybill, Integer> implements CalcWaybillService {
  35 +
  36 + @Autowired
  37 + private CalcWaybillRepository clacRepository;
  38 +
  39 + @Autowired
  40 + private CalcToolService calcToolService;
  41 +
  42 + @Autowired
  43 + JdbcTemplate jdbcTemplate;
  44 +
  45 +
  46 + Logger logger = LoggerFactory.getLogger(this.getClass());
  47 +
  48 +
  49 + @Transactional
  50 + @Override
  51 + public Map<String, Object> generateNew(String date, String line) throws Exception {
  52 + Map<String, Object> newMap = new HashMap<String, Object>();
  53 +
  54 + try {
  55 +
  56 + if(date.length() != 0 && line.length() != 0){
  57 + clacRepository.deleteByDateAndLine(date, line);
  58 + } else if(date.length() != 0){
  59 + clacRepository.deleteByDate(date);
  60 + } else {
  61 + newMap.put("status", ResponseCode.ERROR);
  62 + logger.error("save erro.", "日期不能为空");
  63 + return newMap;
  64 + }
  65 +
  66 + if(date.trim().length() == 0){
  67 + newMap.put("status", ResponseCode.ERROR);
  68 + logger.error("save erro.", "日期不能为空");
  69 + return newMap;
  70 + }
  71 +
  72 + String sql = "select c.id,c.out_config,c.start_opt,c.trust,t.line_code from bsth_c_line_config c LEFT JOIN bsth_c_line t on c.line=t.id";
  73 + if(line.length() != 0){
  74 + sql += " where t.line_code = " + line;
  75 + }
  76 +// List<LineConfig> listLineConfig = //jdbcTemplate.query(sql, new BeanPropertyRowMapper(LineConfig.class));
  77 + List<Map<String, Object>> listLineConfig = jdbcTemplate.query(sql,
  78 + new RowMapper<Map<String, Object>>(){
  79 + @Override
  80 + public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException {
  81 + Map<String, Object> m = new HashMap<String, Object>();
  82 + m.put("id", rs.getLong("id"));
  83 + m.put("out_config", rs.getString("out_config"));
  84 + m.put("start_opt", rs.getString("start_opt"));
  85 + m.put("trust", rs.getString("trust"));
  86 + m.put("line_code", rs.getString("line_code"));
  87 + return m;
  88 + }});
  89 +
  90 + Set<String> lineSet = new HashSet<String>();
  91 + for (int i = 0; i < listLineConfig.size(); i++) {
  92 + Map<String, Object> m =listLineConfig.get(i);
  93 + String lineCode=m.get("line_code").toString().trim();
  94 + String startOpt=m.get("start_opt").toString().trim();
  95 + if(!lineSet.add(lineCode))
  96 + continue;
  97 +
  98 + List<CalcWaybill> findAll = calcToolService.findAll(date, lineCode);
  99 +
  100 +// new BatchSaveUtils<CalcWaybill>().saveList2(findAll, CalcWaybill.class);
  101 +
  102 + clacRepository.save(findAll);
  103 + }
  104 +
  105 + newMap.put("status", ResponseCode.SUCCESS);
  106 + } catch (Exception e) {
  107 + // TODO: handle exception
  108 + newMap.put("status", ResponseCode.ERROR);
  109 + logger.error("save erro.", e);
  110 + throw e;
  111 + }
  112 +
  113 + return newMap;
  114 + }
  115 +
  116 + @Override
  117 + public List<Map<String, Object>> statisticsDailyTj(String gsdm,
  118 + String fgsdm, String line, String date, String date2,
  119 + String xlName, String type) {
  120 +
  121 + List<CalcWaybill> list = new ArrayList<CalcWaybill>();
  122 + List<CalcWaybill> lists = new ArrayList<CalcWaybill>();
  123 + List<Map<String, Object>> resList = new ArrayList<Map<String, Object>>();
  124 + Map<String, List<CalcWaybill>> keyMap = new HashMap<String, List<CalcWaybill>>();
  125 +
  126 + if(line.equals("")){
  127 + //查询所有线路
  128 + list = clacRepository.scheduleByDateAndLineTj(line,date,date2,gsdm,fgsdm);
  129 + }else{
  130 + //查询单条线路
  131 + list = clacRepository.scheduleByDateAndLineTj2(line,date,date2);
  132 + }
  133 +
  134 + for(CalcWaybill c : list){
  135 + String key = c.getXlName();
  136 + if(!keyMap.containsKey(key)){
  137 + keyMap.put(key, new ArrayList<CalcWaybill>());
  138 + }
  139 + keyMap.get(key).add(c);
  140 + }
  141 + for(String key : keyMap.keySet()){
  142 + CalcWaybill calc = keyMap.get(key).get(0);
  143 + for(int i = 1; i < keyMap.get(key).size(); i++){
  144 + CalcWaybill c= keyMap.get(key).get(i);
  145 + calc.setJhyylc(Arith.add(calc.getJhyylc(), c.getJhyylc()));
  146 + calc.setJhfyylc(Arith.add(calc.getJhfyylc(), c.getJhfyylc()));
  147 + calc.setSjyylc(Arith.add(calc.getSjyylc(), c.getSjyylc()));
  148 + calc.setSjfyylc(Arith.add(calc.getSjfyylc(), c.getSjfyylc()));
  149 + calc.setLblc(Arith.add(calc.getLblc(), c.getLblc()));
  150 + calc.setLbbc(calc.getLbbc() + c.getLbbc());
  151 + calc.setLblcLz(Arith.add(calc.getLblcLz(), c.getLblcLz()));
  152 + calc.setLblcDm(Arith.add(calc.getLblcDm(), c.getLblcDm()));
  153 + calc.setLblcGz(Arith.add(calc.getLblcGz(), c.getLblcGz()));
  154 + calc.setLblcJf(Arith.add(calc.getLblcJf(), c.getLblcJf()));
  155 + calc.setLblcZs(Arith.add(calc.getLblcZs(), c.getLblcZs()));
  156 + calc.setLblcQr(Arith.add(calc.getLblcQr(), c.getLblcQr()));
  157 + calc.setLblcQc(Arith.add(calc.getLblcQc(), c.getLblcQc()));
  158 + calc.setLblcKx(Arith.add(calc.getLblcKx(), c.getLblcKx()));
  159 + calc.setLblcQh(Arith.add(calc.getLblcQh(), c.getLblcQh()));
  160 + calc.setLblcYw(Arith.add(calc.getLblcYw(), c.getLblcYw()));
  161 + calc.setLblcQt(Arith.add(calc.getLblcQt(), c.getLblcQt()));
  162 + calc.setLjyylc(Arith.add(calc.getLjyylc(), c.getLjyylc()));
  163 + calc.setJhyybc(calc.getJhyybc() + c.getJhyybc());
  164 + calc.setJhyybczgf(calc.getJhyybczgf() + c.getJhyybczgf());
  165 + calc.setJhyybcwgf(calc.getJhyybcwgf() + c.getJhyybcwgf());
  166 + calc.setSjyybc(calc.getSjyybc() + c.getSjyybc());
  167 + calc.setSjyybczgf(calc.getSjyybczgf() + c.getSjyybczgf());
  168 + calc.setSjyybcwgf(calc.getSjyybcwgf() + c.getSjyybcwgf());
  169 + calc.setLjbc(calc.getLjbc() + c.getLjbc());
  170 + calc.setLjbczgf(calc.getLjbczgf() + c.getLjbczgf());
  171 + calc.setLjbcwgf(calc.getLjbcwgf() + c.getLjbcwgf());
  172 + calc.setFzbc(calc.getFzbc() + c.getFzbc());
  173 + calc.setFzbczgf(calc.getFzbczgf() + c.getFzbczgf());
  174 + calc.setFzbcwgf(calc.getFzbcwgf() + c.getFzbcwgf());
  175 + calc.setDtbc(calc.getDtbc() + c.getFzbc());
  176 + calc.setDtbczgf(calc.getDtbczgf() + c.getDtbczgf());
  177 + calc.setDtbcwgf(calc.getDtbcwgf() + c.getDtbcwgf());
  178 +
  179 + }
  180 + calc.setSjyylc(Arith.add(calc.getSjyylc(), calc.getLjyylc()));
  181 + System.out.println();
  182 + lists.add(calc);
  183 + }
  184 +
  185 + CalcWaybill sum = new CalcWaybill();
  186 + sum.setXlName("合计");
  187 + for(CalcWaybill c : lists){
  188 + sum.setJhyylc(Arith.add(sum.getJhyylc()!=null?sum.getJhyylc():0, c.getJhyylc()));
  189 + sum.setJhfyylc(Arith.add(sum.getJhfyylc()!=null?sum.getJhfyylc():0, c.getJhfyylc()));
  190 + sum.setSjyylc(Arith.add(sum.getSjyylc()!=null?sum.getSjyylc():0, c.getSjyylc()));
  191 + sum.setSjfyylc(Arith.add(sum.getSjfyylc()!=null?sum.getSjfyylc():0, c.getSjfyylc()));
  192 + sum.setLblc(Arith.add(sum.getLblc()!=null?sum.getLblc():0, c.getLblc()));
  193 + sum.setLbbc(sum.getLbbc() + c.getLbbc());
  194 + sum.setLblcLz(Arith.add(sum.getLblcLz()!=null?sum.getLblcLz():0, c.getLblcLz()));
  195 + sum.setLblcDm(Arith.add(sum.getLblcDm()!=null?sum.getLblcDm():0, c.getLblcDm()));
  196 + sum.setLblcGz(Arith.add(sum.getLblcGz()!=null?sum.getLblcGz():0, c.getLblcGz()));
  197 + sum.setLblcJf(Arith.add(sum.getLblcJf()!=null?sum.getLblcJf():0, c.getLblcJf()));
  198 + sum.setLblcZs(Arith.add(sum.getLblcZs()!=null?sum.getLblcZs():0, c.getLblcZs()));
  199 + sum.setLblcQr(Arith.add(sum.getLblcQr()!=null?sum.getLblcQr():0, c.getLblcQr()));
  200 + sum.setLblcQc(Arith.add(sum.getLblcQc()!=null?sum.getLblcQc():0, c.getLblcQc()));
  201 + sum.setLblcKx(Arith.add(sum.getLblcKx()!=null?sum.getLblcKx():0, c.getLblcKx()));
  202 + sum.setLblcQh(Arith.add(sum.getLblcQh()!=null?sum.getLblcQh():0, c.getLblcQh()));
  203 + sum.setLblcYw(Arith.add(sum.getLblcYw()!=null?sum.getLblcYw():0, c.getLblcYw()));
  204 + sum.setLblcQt(Arith.add(sum.getLblcQt()!=null?sum.getLblcQt():0, c.getLblcQt()));
  205 + sum.setLjyylc(Arith.add(sum.getLjyylc()!=null?sum.getLjyylc():0, c.getLjyylc()));
  206 + sum.setJhyybc(sum.getJhyybc() + c.getJhyybc());
  207 + sum.setJhyybczgf(sum.getJhyybczgf() + c.getJhyybczgf());
  208 + sum.setJhyybcwgf(sum.getJhyybcwgf() + c.getJhyybcwgf());
  209 + sum.setSjyybc(sum.getSjyybc() + c.getSjyybc());
  210 + sum.setSjyybczgf(sum.getSjyybczgf() + c.getSjyybczgf());
  211 + sum.setSjyybcwgf(sum.getSjyybcwgf() + c.getSjyybcwgf());
  212 + sum.setLjbc(sum.getLjbc() + c.getLjbc());
  213 + sum.setLjbczgf(sum.getLjbczgf() + c.getLjbczgf());
  214 + sum.setLjbcwgf(sum.getLjbcwgf() + c.getLjbcwgf());
  215 + sum.setFzbc(sum.getFzbc() + c.getFzbc());
  216 + sum.setFzbczgf(sum.getFzbczgf() + c.getFzbczgf());
  217 + sum.setFzbcwgf(sum.getFzbcwgf() + c.getFzbcwgf());
  218 + sum.setDtbc(sum.getDtbc() + c.getFzbc());
  219 + sum.setDtbczgf(sum.getDtbczgf() + c.getDtbczgf());
  220 + sum.setDtbcwgf(sum.getDtbcwgf() + c.getDtbcwgf());
  221 + }
  222 + if(lists.size() > 0){
  223 + lists.add(sum);
  224 + }
  225 +
  226 + for(CalcWaybill c : lists){
  227 + Map<String, Object> m = new HashMap<String, Object>();
  228 + m.put("xlName", c.getXlName());
  229 + m.put("jhzlc", Arith.add(c.getJhyylc(), c.getJhfyylc()));
  230 + m.put("jhlc", c.getJhyylc());
  231 + m.put("jcclc", c.getJhfyylc());
  232 + m.put("sjzgl", Arith.add(c.getSjyylc(), c.getSjfyylc()));
  233 + m.put("sjgl", c.getSjyylc());
  234 + m.put("sjksgl", c.getSjfyylc());
  235 + m.put("ssgl", c.getLblc());
  236 + m.put("ssbc", c.getLbbc());
  237 + m.put("ssgl_lz", c.getLblcLz());
  238 + m.put("ssgl_dm", c.getLblcDm());
  239 + m.put("ssgl_gz", c.getLblcGz());
  240 + m.put("ssgl_jf", c.getLblcJf());
  241 + m.put("ssgl_zs", c.getLblcZs());
  242 + m.put("ssgl_qr", c.getLblcQr());
  243 + m.put("ssgl_qc", c.getLblcQc());
  244 + m.put("ssgl_kx", c.getLblcKx());
  245 + m.put("ssgl_qh", c.getLblcQh());
  246 + m.put("ssgl_yw", c.getLblcYw());
  247 + m.put("ssgl_other", c.getLblcQt());
  248 + m.put("ljgl", c.getLjyylc());
  249 + m.put("jhbc", c.getJhyybc());
  250 + m.put("jhbc_m", c.getJhyybczgf());
  251 + m.put("jhbc_a", c.getJhyybcwgf());
  252 + m.put("sjbc", c.getSjyybc());
  253 + m.put("sjbc_m", c.getSjyybczgf());
  254 + m.put("sjbc_a", c.getSjyybcwgf());
  255 + m.put("ljbc", c.getLjbc());
  256 + m.put("ljbc_m", c.getLjbczgf());
  257 + m.put("ljbc_a", c.getLjbcwgf());
  258 + m.put("fzbc", c.getFzbc());
  259 + m.put("fzbc_m", c.getFzbczgf());
  260 + m.put("fzbc_a", c.getFzbcwgf());
  261 + m.put("dtbc", c.getDtbc());
  262 + m.put("dtbc_m", c.getDtbczgf());
  263 + m.put("dtbc_a", c.getDtbcwgf());
  264 + m.put("djg", 0);
  265 + m.put("djg_m", 0);
  266 + m.put("djg_a", 0);
  267 + m.put("djg_time", 0);
  268 + resList.add(m);
  269 + }
  270 +
  271 + return resList;
  272 + }
  273 +
  274 +}
... ...
src/main/java/com/bsth/service/directive/DirectiveServiceImpl.java
... ... @@ -7,8 +7,8 @@ import com.bsth.data.BasicData;
7 7 import com.bsth.data.directive.DayOfDirectives;
8 8 import com.bsth.data.directive.DirectiveCreator;
9 9 import com.bsth.data.directive.GatewayHttpUtils;
10   -import com.bsth.data.gpsdata.GpsEntity;
11   -import com.bsth.data.gpsdata.GpsRealData;
  10 +import com.bsth.data.gpsdata_v2.GpsRealData;
  11 +import com.bsth.data.gpsdata_v2.entity.GpsEntity;
12 12 import com.bsth.data.pilot80.PilotReport;
13 13 import com.bsth.data.schedule.DayOfSchedule;
14 14 import com.bsth.data.utils.ListFilterUtils;
... ...
src/main/java/com/bsth/service/gps/GpsService.java
1 1 package com.bsth.service.gps;
2 2  
3   -import com.bsth.data.gpsdata.GpsEntity;
4 3 import com.bsth.service.gps.entity.GpsOutbound_DTO;
5 4 import com.bsth.service.gps.entity.GpsSpeed;
6 5 import com.bsth.service.gps.entity.GpsSpeed_DTO;
7   -import com.bsth.util.PageObject;
8 6  
9 7 import javax.servlet.http.HttpServletResponse;
10   -
11 8 import java.text.ParseException;
12 9 import java.util.List;
13 10 import java.util.Map;
... ...
src/main/java/com/bsth/service/gps/GpsServiceImpl.java
... ... @@ -3,10 +3,10 @@ package com.bsth.service.gps;
3 3 import com.bsth.common.ResponseCode;
4 4 import com.bsth.data.BasicData;
5 5 import com.bsth.data.forecast.entity.ArrivalEntity;
6   -import com.bsth.data.gpsdata.GpsEntity;
7   -import com.bsth.data.gpsdata.GpsRealData;
8   -import com.bsth.data.gpsdata.arrival.GeoCacheData;
9   -import com.bsth.data.gpsdata.arrival.utils.GeoUtils;
  6 +import com.bsth.data.gpsdata_v2.GpsRealData;
  7 +import com.bsth.data.gpsdata_v2.cache.GeoCacheData;
  8 +import com.bsth.data.gpsdata_v2.entity.GpsEntity;
  9 +import com.bsth.data.gpsdata_v2.utils.GeoUtils;
10 10 import com.bsth.data.safe_driv.SafeDriv;
11 11 import com.bsth.data.safe_driv.SafeDrivCenter;
12 12 import com.bsth.data.schedule.DayOfSchedule;
... ...
src/main/java/com/bsth/service/gps/entity/HistoryGps_DTO.java
... ... @@ -3,10 +3,8 @@ package com.bsth.service.gps.entity;
3 3 import com.alibaba.fastjson.JSON;
4 4 import com.alibaba.fastjson.JSONObject;
5 5 import com.bsth.data.forecast.entity.ArrivalEntity;
  6 +import com.bsth.util.Geo.Point;
6 7 import com.fasterxml.jackson.annotation.JsonIgnore;
7   -import com.vividsolutions.jts.geom.Coordinate;
8   -import com.vividsolutions.jts.geom.GeometryFactory;
9   -import com.vividsolutions.jts.geom.Point;
10 8  
11 9 import java.util.List;
12 10 import java.util.Map;
... ... @@ -20,10 +18,9 @@ public class HistoryGps_DTO {
20 18 public static List<HistoryGps_DTO> craete(List<Map<String, Object>> mapList) {
21 19 List<HistoryGps_DTO> list = JSONObject.parseArray(JSON.toJSONString(mapList), HistoryGps_DTO.class);
22 20  
23   - GeometryFactory geometryFactory = new GeometryFactory();
24 21 Point point;
25 22 for (HistoryGps_DTO gps : list) {
26   - point = geometryFactory.createPoint(new Coordinate(gps.getLat(), gps.getLon()));
  23 + point = new Point(gps.getLon(), gps.getLat());
27 24 gps.setPoint(point);
28 25 }
29 26 return list;
... ...
src/main/java/com/bsth/service/gps/entity/HistoryGps_DTOV3.java
... ... @@ -3,10 +3,8 @@ package com.bsth.service.gps.entity;
3 3 import com.alibaba.fastjson.JSON;
4 4 import com.alibaba.fastjson.JSONObject;
5 5 import com.bsth.data.forecast.entity.ArrivalEntity;
  6 +import com.bsth.util.Geo.Point;
6 7 import com.fasterxml.jackson.annotation.JsonIgnore;
7   -import com.vividsolutions.jts.geom.Coordinate;
8   -import com.vividsolutions.jts.geom.GeometryFactory;
9   -import com.vividsolutions.jts.geom.Point;
10 8  
11 9 import java.util.List;
12 10 import java.util.Map;
... ... @@ -20,10 +18,9 @@ public class HistoryGps_DTOV3 {
20 18 public static List<HistoryGps_DTOV3> craete(List<Map<String, Object>> mapList) {
21 19 List<HistoryGps_DTOV3> list = JSONObject.parseArray(JSON.toJSONString(mapList), HistoryGps_DTOV3.class);
22 20  
23   - GeometryFactory geometryFactory = new GeometryFactory();
24 21 Point point;
25 22 for (HistoryGps_DTOV3 gps : list) {
26   - point = geometryFactory.createPoint(new Coordinate(gps.getLat(), gps.getLon()));
  23 + point = new Point(gps.getLon(), gps.getLat());
27 24 gps.setPoint(point);
28 25 }
29 26 return list;
... ...
src/main/java/com/bsth/service/gps/entity/Road_DTO.java
... ... @@ -2,10 +2,9 @@ package com.bsth.service.gps.entity;
2 2  
3 3 import com.alibaba.fastjson.JSON;
4 4 import com.alibaba.fastjson.JSONObject;
  5 +import com.bsth.data.gpsdata_v2.entity.CtLineString;
  6 +import com.bsth.util.Geo.Point;
5 7 import com.fasterxml.jackson.annotation.JsonIgnore;
6   -import com.vividsolutions.jts.geom.Coordinate;
7   -import com.vividsolutions.jts.geom.GeometryFactory;
8   -import com.vividsolutions.jts.geom.LineString;
9 8  
10 9 import java.util.ArrayList;
11 10 import java.util.List;
... ... @@ -24,9 +23,9 @@ public class Road_DTO {
24 23 String[] coords;
25 24 int i, len;
26 25 String[] temps;//1, temps2;
27   - List<Coordinate> cds;
  26 + List<Point> cds;
28 27  
29   - GeometryFactory geometryFactory = new GeometryFactory();
  28 + //GeometryFactory geometryFactory = new GeometryFactory();
30 29 for(Road_DTO road : list){
31 30 polygonStr = road.getGROAD_VECTOR();
32 31 coords = polygonStr.substring(11, polygonStr.length() - 1).split(",");
... ... @@ -36,11 +35,10 @@ public class Road_DTO {
36 35 //每2个点连一条线
37 36 for(i = 0; i < len; i ++){
38 37 temps = coords[i].split(" ");
39   - cds.add(new Coordinate(Float.parseFloat(temps[1]), Float.parseFloat(temps[0])));
  38 + cds.add(new Point(Float.parseFloat(temps[0]), Float.parseFloat(temps[1])));
40 39 }
41 40  
42   - Coordinate[] cdsArray = new Coordinate[cds.size()];
43   - road.setLineStr(geometryFactory.createLineString(cds.toArray(cdsArray)));
  41 + road.setLineStr(new CtLineString(cds));
44 42 }
45 43 return list;
46 44 }
... ... @@ -57,7 +55,7 @@ public class Road_DTO {
57 55 private double SPEED;
58 56  
59 57 @JsonIgnore
60   - private LineString lineStr;
  58 + private CtLineString lineStr;
61 59  
62 60 public long getID() {
63 61 return ID;
... ... @@ -99,11 +97,12 @@ public class Road_DTO {
99 97 this.SPEED = SPEED;
100 98 }
101 99  
102   - public LineString getLineStr() {
  100 +
  101 + public CtLineString getLineStr() {
103 102 return lineStr;
104 103 }
105 104  
106   - public void setLineStr(LineString lineStr) {
  105 + public void setLineStr(CtLineString lineStr) {
107 106 this.lineStr = lineStr;
108 107 }
109 108 }
... ...
src/main/java/com/bsth/service/impl/LineVersionsServiceImpl.java
... ... @@ -75,7 +75,7 @@ public class LineVersionsServiceImpl extends BaseServiceImpl&lt;LineVersions, Integ
75 75  
76 76 @Override
77 77 public List<LineVersions> findByLineCode(int lineId) {
78   - return repository.findBylineCode(lineId);
  78 + return repository.findBylineId(lineId);
79 79 }
80 80  
81 81 @Override
... ... @@ -105,7 +105,6 @@ public class LineVersionsServiceImpl extends BaseServiceImpl&lt;LineVersions, Integ
105 105 // TODO Auto-generated catch block
106 106 e.printStackTrace();
107 107 resultMap.put("status", ResponseCode.ERROR);
108   - return resultMap;
109 108 }
110 109 return resultMap;
111 110 }
... ... @@ -200,18 +199,6 @@ public class LineVersionsServiceImpl extends BaseServiceImpl&lt;LineVersions, Integ
200 199 return sectionRoutes.size();
201 200 }
202 201 } );
203   - /*for (SectionRoute sectionRoute : sectionRoutes) {
204   - sectionRouteService.save(sectionRoute);
205   - }*/
206   -// sectionRouteService.bulkSave(sectionRoutes);
207   - //List<StationRoute> stationRoutes = JSONArray.parseArray(JSON.toJSONString(lsStationRoutes), StationRoute.class);
208   -// stationRouteService.batchUpdate(lineId, lineCode);
209   -
210   - //stationRouteRepository.batchDelete(lineId, lineCode);
211   - /*for (StationRoute stationRoute : stationRoutes) {
212   - stationRouteService.save(stationRoute);
213   - }*/
214   -// stationRouteService.bulkSave(stationRoutes);
215 202 // 更新线路版本
216 203 repository.updateOdlVersions(lineId, lineCode);
217 204 repository.updateNewVersions(lineId,lineCode,versions);
... ... @@ -220,9 +207,48 @@ public class LineVersionsServiceImpl extends BaseServiceImpl&lt;LineVersions, Integ
220 207 return list;
221 208 }
222 209  
  210 + /**
  211 + * 查询线路版本最大值
  212 + */
223 213 @Override
224 214 public LineVersions findLineVersionsMax(int lineId) {
225 215 return repository.findLineVersionsMax(lineId);
226 216 }
  217 +
  218 + /**
  219 + * 线路版本添加
  220 + */
  221 + @Override
  222 + public Map<String, Object> add(Map<String, Object> map) {
  223 + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  224 + Map<String, Object> resultMap = new HashMap<>();
  225 +
  226 + LineVersions lineVersions = new LineVersions();
  227 + try {
  228 + Date startDate = simpleDateFormat.parse(map.get("startDate").toString());
  229 + Date endDate = simpleDateFormat.parse(map.get("endDate").toString());
  230 + Line line = lineRepository.findOne(Integer.valueOf(map.get("lineId").toString()));
  231 + Integer versions = Integer.valueOf(map.get("versions").toString());
  232 + lineVersions.setName(map.get("name").toString());
  233 + lineVersions.setLine(line);
  234 + lineVersions.setLineCode(map.get("lineCode").toString());
  235 + lineVersions.setStartDate(new java.sql.Date(startDate.getTime()));
  236 + lineVersions.setEndDate(new java.sql.Date(endDate.getTime()));
  237 + lineVersions.setVersions(versions);
  238 + lineVersions.setStatus(Integer.valueOf(map.get("status").toString()));
  239 + lineVersions.setRemark(map.get("remark").toString());
  240 + repository.save(lineVersions);
  241 + // 更新上一版本时间
  242 + LineVersions upLineVersions = repository.findBylineIdAndVersions(line.getId(),versions);
  243 + upLineVersions.setEndDate(new java.sql.Date(startDate.getTime()));
  244 + repository.save(upLineVersions);
  245 + resultMap.put("status", ResponseCode.SUCCESS);
  246 + } catch (ParseException e) {
  247 + // TODO Auto-generated catch block
  248 + e.printStackTrace();
  249 + resultMap.put("status", ResponseCode.ERROR);
  250 + }
  251 + return resultMap;
  252 + }
227 253  
228 254 }
... ...
src/main/java/com/bsth/service/realcontrol/impl/RealMapServiceImpl.java
... ... @@ -2,15 +2,12 @@ package com.bsth.service.realcontrol.impl;
2 2  
3 3 import com.bsth.common.ResponseCode;
4 4 import com.bsth.controller.realcontrol.dto.StationSpatialData;
5   -import com.bsth.data.gpsdata.arrival.utils.GeoUtils;
6 5 import com.bsth.entity.CarPark;
7 6 import com.bsth.service.realcontrol.RealMapService;
8 7 import com.bsth.service.realcontrol.dto.SectionRouteCoords;
9 8 import com.bsth.util.TransGPS;
10   -import com.google.common.base.Joiner;
11 9 import com.google.common.base.Splitter;
12 10 import com.google.common.collect.ArrayListMultimap;
13   -import com.vividsolutions.jts.geom.*;
14 11 import org.slf4j.Logger;
15 12 import org.slf4j.LoggerFactory;
16 13 import org.springframework.beans.factory.annotation.Autowired;
... ... @@ -250,171 +247,4 @@ public class RealMapServiceImpl implements RealMapService {
250 247 }
251 248 return gcjList;
252 249 }
253   -
254   - /**
255   - * 将相连的路段拼接起来,去掉接口覆盖区域。
256   - * 主要因为前端地图绘制时,过多的路段会带来性能消耗。在这里提前拼接好以减少路段数量
257   - * @param list
258   - * @return
259   - */
260   - private List<String> jointCoords(List<String> list){
261   - List<String> rs = new ArrayList<>();
262   - int len = list.size();
263   - if(len == 0)
264   - return rs;
265   -
266   - String joinstr = list.get(0);
267   - String str;
268   - for(int i = 1; i < len; i ++){
269   - str = jointCoords(joinstr.toString(), list.get(i));
270   - if(str != null)
271   - joinstr = str;
272   - else{
273   - rs.add(joinstr.toString());
274   - joinstr = list.get(i);
275   - }
276   - }
277   - rs.add(joinstr);
278   - return rs;
279   - }
280   -
281   - static GeometryFactory geometryFactory = new GeometryFactory();
282   - private String jointCoords(String c1, String c2){
283   - String rs=null;
284   - LineString s1 = createLineString(c1);
285   - LineString s2 = createLineString(c2);
286   -
287   -
288   - /*if(s1.intersects(s2)){
289   - //2条线相交
290   - Geometry g = s1.intersection(s2);
291   - Point inPoint = geometryFactory.createPoint(g.getCoordinates()[0]);
292   - //s1 = replacePoint(s1, s1.getCoordinates().length - 1, inPoint);
293   - //s2 = replacePoint(s2, 0, inPoint);
294   -
295   - //rs = toString(s1);
296   - //rs += ("," + toString(s2));
297   - rs = replacePoint(c1, s1.getCoordinates().length - 1, inPoint);
298   - rs += ("," + replacePoint(c2, 0, null));
299   - }
300   - else {*/
301   - //距离10米内的点直接连起来
302   - double distance = GeoUtils.getDistanceLineToLine(s1.getStartPoint(), s1.getEndPoint(), s2.getStartPoint(), s2.getEndPoint());
303   - if(distance < 10){
304   - //s2 = replacePoint(s2, 0, s1.getEndPoint());
305   - rs = c1;
306   -
307   - //获取c1终点到 c2 的垂直交点
308   - //s1.getEndPoint()
309   - //rs += ("," + replacePoint(c2, 0, null));
310   - //rs = toString(s1);
311   - //rs += ("," + toString(s2));
312   - }
313   - //}
314   - return rs;
315   - }
316   -
317   - /**
318   - * 替换线段中指定的一个点位
319   - * @param index
320   - * @param p
321   -
322   - private LineString replacePoint(LineString line, int index, Point p){
323   - Coordinate[] array = line.getCoordinates();
324   - array[index] = p.getCoordinate();
325   -
326   - return geometryFactory.createLineString(array);
327   - }*/
328   -
329   - private String replacePoint(String lineStr, int index, Point p){
330   - List<String> list = new ArrayList<>(Splitter.on(",").splitToList(lineStr));
331   - list.remove(index);
332   - if(p != null){
333   - list.add(index, p.getX() + " " + p.getY());
334   - }
335   - return Joiner.on(",").join(list);
336   - }
337   -
338   - private LineString createLineString(String c){
339   - List<String> list = Splitter.on(",").splitToList(c);
340   -
341   - Coordinate[] cds = new Coordinate[list.size()];
342   - String[] strs;
343   - for(int i = 0; i < list.size(); i ++){
344   - strs = list.get(i).split(" ");
345   - cds[i] = new Coordinate(Float.parseFloat(strs[1]), Float.parseFloat(strs[0]));
346   - }
347   - return geometryFactory.createLineString(cds);
348   - }
349   -
350   - private String toString(LineString line){
351   - Coordinate[] all = line.getCoordinates();
352   -
353   - Coordinate[] cs;
354   - StringBuilder sb = new StringBuilder("");
355   - for(int i = 0; i < all.length - 1; i ++){
356   - cs = new Coordinate[2];
357   - cs[0] = all[i];
358   - cs[1] = all[i + 1];
359   -
360   - sb.append("," + cs[0].y + " " + cs[0].x);
361   - sb.append("," + cs[1].y + " " + cs[1].x);
362   - }
363   - sb.deleteCharAt(0);
364   - return sb.toString();
365   - }
366   -
367   -/* private String truncationEnd(LineString lineString, Point p){
368   - Coordinate[] all = lineString.getCoordinates();
369   - LineString sl;
370   -
371   - Coordinate[] cs;
372   - StringBuilder sb = new StringBuilder("");
373   - double threshold = 0.1,distance;
374   - for(int i = 0; i < all.length - 1; i ++){
375   - cs = new Coordinate[2];
376   - cs[0] = all[i];
377   - cs[1] = all[i + 1];
378   - sl = geometryFactory.createLineString(cs);
379   -
380   - sb.append("," + cs[0].y + " " + cs[0].x);
381   - distance = GeoUtils.getDistanceFromLine(sl, p);
382   - if(distance < threshold){
383   - sb.append("," + p.getY() + " " + p.getX());
384   - break;
385   - }
386   - else
387   - sb.append("," + cs[1].y + " " + cs[1].x);
388   - }
389   - sb.deleteCharAt(0);
390   - return sb.toString();
391   - }
392   -
393   - private String truncationStart(LineString lineString, Point p){
394   - Coordinate[] all = lineString.getCoordinates();
395   - LineString sl;
396   -
397   - Coordinate[] cs;
398   - StringBuilder sb = new StringBuilder("");
399   - double threshold = 0.1,distance;
400   - for(int i = 0; i < all.length - 1; i ++){
401   - cs = new Coordinate[2];
402   - cs[0] = all[i];
403   - cs[1] = all[i + 1];
404   - sl = geometryFactory.createLineString(cs);
405   -
406   - distance = GeoUtils.getDistanceFromLine(sl, p);
407   - if(distance < threshold){
408   - sb.append("," + p.getY() + " " + p.getX());
409   - sb.append("," + cs[1].y + " " + cs[1].x);
410   - break;
411   - }
412   - else{
413   - sb.append("," + cs[0].y + " " + cs[0].x);
414   - sb.append("," + cs[1].y + " " + cs[1].x);
415   - }
416   - }
417   - sb.deleteCharAt(0);
418   - return sb.toString();
419   - }*/
420 250 }
... ...
src/main/java/com/bsth/service/schedule/impl/PeopleCarPlanServiceImpl.java
... ... @@ -1924,13 +1924,11 @@ public class PeopleCarPlanServiceImpl implements PeopleCarPlanService {
1924 1924 }else{
1925 1925 sql_ += " and xl_bm = '"+line+"'";
1926 1926 }
1927   -
1928 1927  
1929   - String sql="SELECT r.id,r.schedule_date_str,r.xl_name,r.xl_bm,r.cl_zbh,r.j_gh,r.j_name,"
1930   - + " r.fcsj,d. TIMESTAMP,d.reply46,d.reply47,d.reply46time,d.reply47time,"
1931   - + " r.gs_name,r.fgs_name,CONCAT(r.xl_bm,'_',r.id) as line_sch FROM ("+sql_+") "
1932   - + " AS r LEFT JOIN bsth_v_directive_60 AS d ON r.id = d.sch AND d.is_dispatch = 1"
1933   - + " order by r.xl_name,r.id,d.timestamp desc ";
  1928 +
  1929 + String sql="SELECT r.id,r.schedule_date_str,r.xl_name,r.xl_bm,r.cl_zbh,r.j_gh,r.j_name,r.fcsj,"
  1930 + + " r.gs_name,r.fgs_name,CONCAT(r.xl_bm,'_',r.id) as line_sch FROM ("+sql_+") AS r"
  1931 + + " order by r.xl_name,r.id ";
1934 1932  
1935 1933 List<Map<String, Object>> list = jdbcTemplate.query(sql,
1936 1934 new RowMapper<Map<String, Object>>(){
... ... @@ -1945,17 +1943,59 @@ public class PeopleCarPlanServiceImpl implements PeopleCarPlanService {
1945 1943 map.put("jGh", rs.getString("j_gh"));
1946 1944 map.put("jName", rs.getString("j_name"));
1947 1945 map.put("fcsj", rs.getString("fcsj"));
1948   - map.put("timestamp", rs.getString("timestamp"));
  1946 + map.put("company", rs.getObject("gs_name"));
  1947 + map.put("subCompany", rs.getObject("fgs_name"));
  1948 + map.put("lineSch", rs.getString("line_sch"));
  1949 + return map;
  1950 + }
  1951 + });
  1952 +
  1953 +
  1954 + Date dateTime = new Date();
  1955 + try {
  1956 + dateTime = new SimpleDateFormat("yyyy-MM-dd").parse(date);
  1957 + } catch (ParseException e) {
  1958 + // TODO Auto-generated catch block
  1959 + e.printStackTrace();
  1960 + }
  1961 +
  1962 + sql="SELECT sch,TIMESTAMP,reply46,reply47,reply46time,reply47time"
  1963 + + " FROM bsth_v_directive_60 WHERE is_dispatch = 1 AND sch is not null"
  1964 + + " AND TIMESTAMP >= "+(dateTime.getTime())
  1965 + + " AND TIMESTAMP < "+(dateTime.getTime() + 1000*60*60*24);
  1966 +
  1967 + List<Map<String, Object>> list2 = jdbcTemplate.query(sql,
  1968 + new RowMapper<Map<String, Object>>(){
  1969 + @Override
  1970 + public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException {
  1971 + Map<String, Object> map = new HashMap<String, Object>();
  1972 + map.put("sch", rs.getString("sch"));
  1973 + map.put("TIMESTAMP", rs.getString("TIMESTAMP"));
1949 1974 map.put("reply46", rs.getString("reply46"));
1950 1975 map.put("reply47", rs.getString("reply47"));
1951 1976 map.put("reply46time", rs.getObject("reply46time"));
1952 1977 map.put("reply47time", rs.getObject("reply47time"));
1953   - map.put("company", rs.getObject("gs_name"));
1954   - map.put("subCompany", rs.getObject("fgs_name"));
1955   - map.put("lineSch", rs.getString("line_sch"));
  1978 +
1956 1979 return map;
1957 1980 }
1958 1981 });
  1982 +
  1983 + Map<String, Map<String, Object>> keyMap = new HashMap<String, Map<String,Object>>();
  1984 + for(Map<String, Object> m : list2){
  1985 + keyMap.put(m.get("sch").toString(), m);
  1986 + }
  1987 + for(Map<String, Object> m : list){
  1988 + String id = m.get("id").toString();
  1989 + if(keyMap.containsKey(id)){
  1990 + Map<String, Object> map2 = keyMap.get(id);
  1991 + m.put("TIMESTAMP", map2.get("TIMESTAMP"));
  1992 + m.put("reply46", map2.get("reply46"));
  1993 + m.put("reply47", map2.get("reply47"));
  1994 + m.put("reply46time", map2.get("reply46time"));
  1995 + m.put("reply47time", map2.get("reply47time"));
  1996 + }
  1997 + }
  1998 +
1959 1999 List<Map<String, Object>> list_=new ArrayList<Map<String,Object>>();
1960 2000 int jhs = 0,sjs=0,wqr=0;
1961 2001 Map<String, Object> m_;
... ... @@ -2063,15 +2103,11 @@ public class PeopleCarPlanServiceImpl implements PeopleCarPlanService {
2063 2103 String type = map.get("type").toString();
2064 2104  
2065 2105 String sql_="select * from bsth_c_s_sp_info_real "
2066   - + " WHERE schedule_date_str = '"+date+"' and xl_bm = '"+line+"'";
  2106 + + " WHERE schedule_date_str = '"+date+"' and xl_bm = '"+line+"'";
2067 2107  
2068   -
2069   - String sql="SELECT r.id,r.schedule_date_str,r.xl_name,r.xl_bm,r.cl_zbh,r.j_gh,r.j_name,"
2070   - + " r.fcsj,d. TIMESTAMP,d.reply46,d.reply47,d.reply46time,d.reply47time,"
2071   - + " r.gs_name,r.fgs_name,CONCAT(r.j_gh,'_',r.id) as gh_sch FROM ("+sql_+") "
2072   - + " AS r LEFT JOIN bsth_v_directive_60 AS d ON r.id = d.sch AND d.is_dispatch = 1"
2073   - + " order by r.j_gh,r.cl_zbh,r.id,d.timestamp desc ";
2074   -
  2108 + String sql="SELECT r.id,r.schedule_date_str,r.xl_name,r.xl_bm,r.cl_zbh,r.j_gh,r.j_name,r.fcsj,"
  2109 + + " r.gs_name,r.fgs_name,CONCAT(r.xl_bm,'_',r.id) as gh_sch FROM ("+sql_+") AS r"
  2110 + + " order by r.xl_name,r.id ";
2075 2111  
2076 2112 List<Map<String, Object>> list = jdbcTemplate.query(sql,
2077 2113 new RowMapper<Map<String, Object>>(){
... ... @@ -2086,17 +2122,58 @@ public class PeopleCarPlanServiceImpl implements PeopleCarPlanService {
2086 2122 map.put("jGh", rs.getString("j_gh"));
2087 2123 map.put("jName", rs.getString("j_name"));
2088 2124 map.put("fcsj", rs.getString("fcsj"));
2089   - map.put("timestamp", rs.getString("timestamp"));
  2125 + map.put("company", rs.getObject("gs_name"));
  2126 + map.put("subCompany", rs.getObject("fgs_name"));
  2127 + map.put("ghSch", rs.getString("gh_sch"));
  2128 + return map;
  2129 + }
  2130 + });
  2131 +
  2132 +
  2133 + Date dateTime = new Date();
  2134 + try {
  2135 + dateTime = new SimpleDateFormat("yyyy-MM-dd").parse(date);
  2136 + } catch (ParseException e) {
  2137 + // TODO Auto-generated catch block
  2138 + e.printStackTrace();
  2139 + }
  2140 +
  2141 + sql="SELECT sch,TIMESTAMP,reply46,reply47,reply46time,reply47time"
  2142 + + " FROM bsth_v_directive_60 WHERE is_dispatch = 1 AND sch is not null"
  2143 + + " AND TIMESTAMP >= "+(dateTime.getTime())
  2144 + + " AND TIMESTAMP < "+(dateTime.getTime() + 1000*60*60*24);
  2145 +
  2146 + List<Map<String, Object>> list2 = jdbcTemplate.query(sql,
  2147 + new RowMapper<Map<String, Object>>(){
  2148 + @Override
  2149 + public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException {
  2150 + Map<String, Object> map = new HashMap<String, Object>();
  2151 + map.put("sch", rs.getString("sch"));
  2152 + map.put("TIMESTAMP", rs.getString("TIMESTAMP"));
2090 2153 map.put("reply46", rs.getString("reply46"));
2091 2154 map.put("reply47", rs.getString("reply47"));
2092 2155 map.put("reply46time", rs.getObject("reply46time"));
2093 2156 map.put("reply47time", rs.getObject("reply47time"));
2094   - map.put("company", rs.getObject("gs_name"));
2095   - map.put("subCompany", rs.getObject("fgs_name"));
2096   - map.put("ghSch", rs.getString("gh_sch"));
  2157 +
2097 2158 return map;
2098 2159 }
2099 2160 });
  2161 +
  2162 + Map<String, Map<String, Object>> keyMap = new HashMap<String, Map<String,Object>>();
  2163 + for(Map<String, Object> m : list2){
  2164 + keyMap.put(m.get("sch").toString(), m);
  2165 + }
  2166 + for(Map<String, Object> m : list){
  2167 + String id = m.get("id").toString();
  2168 + if(keyMap.containsKey(id)){
  2169 + Map<String, Object> map2 = keyMap.get(id);
  2170 + m.put("TIMESTAMP", map2.get("TIMESTAMP"));
  2171 + m.put("reply46", map2.get("reply46"));
  2172 + m.put("reply47", map2.get("reply47"));
  2173 + m.put("reply46time", map2.get("reply46time"));
  2174 + m.put("reply47time", map2.get("reply47time"));
  2175 + }
  2176 + }
2100 2177  
2101 2178 List<Map<String, Object>> list_=new ArrayList<Map<String,Object>>();
2102 2179 int jhs = 0,sjs=0,wqr=0;
... ...
src/main/java/com/bsth/websocket/entity/WsScheduleRealInfo.java 0 → 100644
  1 +package com.bsth.websocket.entity;
  2 +
  3 +import com.bsth.entity.realcontrol.ChildTaskPlan;
  4 +import com.bsth.entity.realcontrol.ScheduleRealInfo;
  5 +
  6 +import javax.persistence.FetchType;
  7 +import javax.persistence.OneToMany;
  8 +import javax.persistence.Transient;
  9 +import java.util.ArrayList;
  10 +import java.util.HashSet;
  11 +import java.util.List;
  12 +import java.util.Set;
  13 +
  14 +/**
  15 + * 精简字段的实际排班 entity
  16 + * webSocket 传输用,去掉了页面不需要的一些字段
  17 + * Created by panzhao on 2017/11/14.
  18 + */
  19 +public class WsScheduleRealInfo {
  20 +
  21 + public static WsScheduleRealInfo getInstance(ScheduleRealInfo sch){
  22 + WsScheduleRealInfo wss = new WsScheduleRealInfo();
  23 + wss.id = sch.getId();
  24 + wss.scheduleDateStr = sch.getScheduleDateStr();
  25 + wss.realExecDate = sch.getRealExecDate();
  26 + wss.xlName = sch.getXlName();
  27 + wss.xlBm = sch.getXlBm();
  28 + wss.lpName = sch.getLpName();
  29 + wss.clZbh = sch.getClZbh();
  30 + wss.jGh = sch.getjGh();
  31 + wss.jName = sch.getjName();
  32 + wss.sGh = sch.getsGh();
  33 + wss.sName = sch.getsName();
  34 + wss.xlDir = sch.getXlDir();
  35 + wss.qdzCode = sch.getQdzCode();
  36 + wss.qdzName = sch.getQdzName();
  37 + wss.zdzCode = sch.getZdzCode();
  38 + wss.zdzName = sch.getZdzName();
  39 + wss.fcsj = sch.getFcsj();
  40 + wss.fcsjT = sch.getFcsjT();
  41 + wss.zdsj = sch.getZdsj();
  42 + wss.zdsjT = sch.getZdsjT();
  43 + wss.jhlc = sch.getJhlc();
  44 + wss.jhlcOrig = sch.getJhlcOrig();
  45 + wss.bcsj = sch.getBcsj();
  46 + wss.bcType = sch.getBcType();
  47 + wss.majorStationName = sch.getMajorStationName();
  48 + wss.fcsjActual = sch.getFcsjActual();
  49 + wss.fcsjActualTime = sch.getFcsjActualTime();
  50 + wss.zdsjActual = sch.getZdsjActual();
  51 + wss.zdsjActualTime = sch.getZdsjActualTime();
  52 + wss.status = sch.getStatus();
  53 + wss.adjustExps = sch.getAdjustExps();
  54 + wss.sflj = sch.isSflj();
  55 + wss.late = sch.isLate();
  56 + wss.late2 = sch.isLate2();
  57 + wss.lateMinute = sch.getLateMinute();
  58 + wss.remarks = sch.getRemarks();
  59 + wss.dfsj = sch.getDfsj();
  60 + wss.dfsjT = sch.getDfsjT();
  61 + wss.directiveState = sch.getDirectiveState();
  62 + wss.qdzArrDatejh = sch.getQdzArrDatejh();
  63 + wss.qdzArrDatesj = sch.getQdzArrDatesj();
  64 + wss.cTasks = sch.getcTasks();
  65 + wss.gsName = sch.getGsName();
  66 + wss.gsBm = sch.getGsBm();
  67 + wss.fgsName = sch.getFgsName();
  68 + wss.fgsBm = sch.getFgsBm();
  69 + wss.dfAuto = sch.isDfAuto();
  70 + wss.online = sch.isOnline();
  71 + wss.reissue = sch.isReissue();
  72 + wss.driftStatus = sch.getDriftStatus();
  73 + wss.ccService = sch.isCcService();
  74 + return wss;
  75 + }
  76 +
  77 +
  78 + public static List<WsScheduleRealInfo> getMultiInstance(List<ScheduleRealInfo> list){
  79 + List<WsScheduleRealInfo> rs = new ArrayList<>();
  80 + for(ScheduleRealInfo sch : list){
  81 + rs.add(getInstance(sch));
  82 + }
  83 + return rs;
  84 + }
  85 +
  86 + /** 主键Id */
  87 + private Long id;
  88 +
  89 + /** 排班日期字符串 YYYY-MM-DD */
  90 + private String scheduleDateStr;
  91 +
  92 + /** 真实执行时间 yyyy-MM-dd */
  93 + private String realExecDate;
  94 +
  95 + /** 线路名称 */
  96 + private String xlName;
  97 + /** 线路编码 */
  98 + private String xlBm;
  99 +
  100 + /** 路牌名称 */
  101 + private String lpName;
  102 +
  103 + /** 车辆自编号 */
  104 + private String clZbh;
  105 +
  106 + /** 驾驶员工号 */
  107 + private String jGh;
  108 + /** 驾驶员名字 */
  109 + private String jName;
  110 + /** 售票员工号 */
  111 + private String sGh;
  112 + /** 售票员名字 */
  113 + private String sName;
  114 +
  115 + /** 线路方向 */
  116 + private String xlDir;
  117 + /** 起点站code*/
  118 + private String qdzCode;
  119 + /** 起点站名字 */
  120 + private String qdzName;
  121 +
  122 + /** 终点站code*/
  123 + private String zdzCode;
  124 + /** 终点站名字 */
  125 + private String zdzName;
  126 +
  127 + /** 计划发车时间(格式 HH:mm) */
  128 + private String fcsj;
  129 + /** 计划发车时间戳*/
  130 + @Transient
  131 + private Long fcsjT;
  132 +
  133 + /** 计划终点时间(格式 HH:mm) */
  134 + private String zdsj;
  135 + /** 计划终点时间戳*/
  136 + @Transient
  137 + private Long zdsjT;
  138 +
  139 + /** 计划里程 */
  140 + private Double jhlc;
  141 +
  142 + /** 原始计划里程 (原计调的数据) */
  143 + private Double jhlcOrig;
  144 + /** 班次历时 */
  145 + private Integer bcsj;
  146 +
  147 + /**
  148 + * 班次类型 TODO:正常班次、出场、进场、加油、区间班次、放空班次、放大站班次、两点间空驶
  149 + */
  150 + private String bcType;
  151 +
  152 + //放站班次 站点名称
  153 + private String majorStationName;
  154 +
  155 + /** 实际发车时间*/
  156 + private String fcsjActual;
  157 + /** 实际发车时间戳*/
  158 + @Transient
  159 + private Long fcsjActualTime;
  160 + /**实际终点时间 */
  161 + private String zdsjActual;
  162 + /** 实际终点时间戳*/
  163 + @Transient
  164 + private Long zdsjActualTime;
  165 +
  166 + /**班次状态 0 未执行 1 正在执行 2 已执行 -1 已烂班 */
  167 + private int status;
  168 +
  169 + private String adjustExps;
  170 +
  171 + /** 是否是临加班次 */
  172 + private boolean sflj;
  173 +
  174 + /** 是否误点 (应发未发)*/
  175 + @Transient
  176 + private boolean late;
  177 +
  178 + /** 是否误点 (应发未到) */
  179 + @Transient
  180 + private boolean late2;
  181 + /** 误点停靠时间 */
  182 + @Transient
  183 + private float lateMinute;
  184 +
  185 + /** 备注*/
  186 + private String remarks;
  187 +
  188 + /**待发时间(格式 HH:mm) */
  189 + private String dfsj;
  190 +
  191 + /**待发时间戳 */
  192 + @Transient
  193 + private Long dfsjT;
  194 +
  195 + /** 指令下发状态 60: 已发送, 100: 设备确认收到, 200:驾驶员确认 0:失败 */
  196 + private Integer directiveState = -1;
  197 +
  198 + /** 起点站计划到达时间 */
  199 + @Transient
  200 + private String qdzArrDatejh;
  201 +
  202 + /** 起点站实际到达时间 */
  203 + @Transient
  204 + private String qdzArrDatesj;
  205 +
  206 + /** 子任务 */
  207 + @OneToMany(fetch = FetchType.LAZY, mappedBy = "schedule")
  208 + private Set<ChildTaskPlan> cTasks = new HashSet<>();
  209 +
  210 + /** 关联的公司名称 */
  211 + private String gsName;
  212 + /** 关联的公司编码 */
  213 + private String gsBm;
  214 + /** 关联的分公司名称 */
  215 + private String fgsName;
  216 + /** 关联的分公司编码 */
  217 + private String fgsBm;
  218 +
  219 + //待发调试(是否自动调整)
  220 + private boolean dfAuto;
  221 + //是否有GPS信号
  222 + private boolean online;
  223 +
  224 + /** 是否有补发GPS信号 */
  225 + private boolean reissue;
  226 +
  227 + /**
  228 + * 漂移状态
  229 + * 1: 发车漂移
  230 + * 2:到站漂移
  231 + * 3:中途漂移
  232 + */
  233 + private Integer driftStatus = 0;
  234 +
  235 + /**
  236 + * 换车营运标记 true 表示该主任务由 【中途换车子任务】 级联生成
  237 + */
  238 + private boolean ccService;
  239 +
  240 + public Long getId() {
  241 + return id;
  242 + }
  243 +
  244 + public void setId(Long id) {
  245 + this.id = id;
  246 + }
  247 +
  248 + public String getScheduleDateStr() {
  249 + return scheduleDateStr;
  250 + }
  251 +
  252 + public void setScheduleDateStr(String scheduleDateStr) {
  253 + this.scheduleDateStr = scheduleDateStr;
  254 + }
  255 +
  256 + public String getRealExecDate() {
  257 + return realExecDate;
  258 + }
  259 +
  260 + public void setRealExecDate(String realExecDate) {
  261 + this.realExecDate = realExecDate;
  262 + }
  263 +
  264 + public String getXlName() {
  265 + return xlName;
  266 + }
  267 +
  268 + public void setXlName(String xlName) {
  269 + this.xlName = xlName;
  270 + }
  271 +
  272 + public String getXlBm() {
  273 + return xlBm;
  274 + }
  275 +
  276 + public void setXlBm(String xlBm) {
  277 + this.xlBm = xlBm;
  278 + }
  279 +
  280 + public String getLpName() {
  281 + return lpName;
  282 + }
  283 +
  284 + public void setLpName(String lpName) {
  285 + this.lpName = lpName;
  286 + }
  287 +
  288 + public String getClZbh() {
  289 + return clZbh;
  290 + }
  291 +
  292 + public void setClZbh(String clZbh) {
  293 + this.clZbh = clZbh;
  294 + }
  295 +
  296 + public String getjGh() {
  297 + return jGh;
  298 + }
  299 +
  300 + public void setjGh(String jGh) {
  301 + this.jGh = jGh;
  302 + }
  303 +
  304 + public String getjName() {
  305 + return jName;
  306 + }
  307 +
  308 + public void setjName(String jName) {
  309 + this.jName = jName;
  310 + }
  311 +
  312 + public String getsGh() {
  313 + return sGh;
  314 + }
  315 +
  316 + public void setsGh(String sGh) {
  317 + this.sGh = sGh;
  318 + }
  319 +
  320 + public String getsName() {
  321 + return sName;
  322 + }
  323 +
  324 + public void setsName(String sName) {
  325 + this.sName = sName;
  326 + }
  327 +
  328 + public String getXlDir() {
  329 + return xlDir;
  330 + }
  331 +
  332 + public void setXlDir(String xlDir) {
  333 + this.xlDir = xlDir;
  334 + }
  335 +
  336 + public String getQdzCode() {
  337 + return qdzCode;
  338 + }
  339 +
  340 + public void setQdzCode(String qdzCode) {
  341 + this.qdzCode = qdzCode;
  342 + }
  343 +
  344 + public String getQdzName() {
  345 + return qdzName;
  346 + }
  347 +
  348 + public void setQdzName(String qdzName) {
  349 + this.qdzName = qdzName;
  350 + }
  351 +
  352 + public String getZdzCode() {
  353 + return zdzCode;
  354 + }
  355 +
  356 + public void setZdzCode(String zdzCode) {
  357 + this.zdzCode = zdzCode;
  358 + }
  359 +
  360 + public String getZdzName() {
  361 + return zdzName;
  362 + }
  363 +
  364 + public void setZdzName(String zdzName) {
  365 + this.zdzName = zdzName;
  366 + }
  367 +
  368 + public String getFcsj() {
  369 + return fcsj;
  370 + }
  371 +
  372 + public void setFcsj(String fcsj) {
  373 + this.fcsj = fcsj;
  374 + }
  375 +
  376 + public Long getFcsjT() {
  377 + return fcsjT;
  378 + }
  379 +
  380 + public void setFcsjT(Long fcsjT) {
  381 + this.fcsjT = fcsjT;
  382 + }
  383 +
  384 + public String getZdsj() {
  385 + return zdsj;
  386 + }
  387 +
  388 + public void setZdsj(String zdsj) {
  389 + this.zdsj = zdsj;
  390 + }
  391 +
  392 + public Long getZdsjT() {
  393 + return zdsjT;
  394 + }
  395 +
  396 + public void setZdsjT(Long zdsjT) {
  397 + this.zdsjT = zdsjT;
  398 + }
  399 +
  400 + public Double getJhlc() {
  401 + return jhlc;
  402 + }
  403 +
  404 + public void setJhlc(Double jhlc) {
  405 + this.jhlc = jhlc;
  406 + }
  407 +
  408 + public Double getJhlcOrig() {
  409 + return jhlcOrig;
  410 + }
  411 +
  412 + public void setJhlcOrig(Double jhlcOrig) {
  413 + this.jhlcOrig = jhlcOrig;
  414 + }
  415 +
  416 + public Integer getBcsj() {
  417 + return bcsj;
  418 + }
  419 +
  420 + public void setBcsj(Integer bcsj) {
  421 + this.bcsj = bcsj;
  422 + }
  423 +
  424 + public String getBcType() {
  425 + return bcType;
  426 + }
  427 +
  428 + public void setBcType(String bcType) {
  429 + this.bcType = bcType;
  430 + }
  431 +
  432 + public String getMajorStationName() {
  433 + return majorStationName;
  434 + }
  435 +
  436 + public void setMajorStationName(String majorStationName) {
  437 + this.majorStationName = majorStationName;
  438 + }
  439 +
  440 + public String getFcsjActual() {
  441 + return fcsjActual;
  442 + }
  443 +
  444 + public void setFcsjActual(String fcsjActual) {
  445 + this.fcsjActual = fcsjActual;
  446 + }
  447 +
  448 + public Long getFcsjActualTime() {
  449 + return fcsjActualTime;
  450 + }
  451 +
  452 + public void setFcsjActualTime(Long fcsjActualTime) {
  453 + this.fcsjActualTime = fcsjActualTime;
  454 + }
  455 +
  456 + public String getZdsjActual() {
  457 + return zdsjActual;
  458 + }
  459 +
  460 + public void setZdsjActual(String zdsjActual) {
  461 + this.zdsjActual = zdsjActual;
  462 + }
  463 +
  464 + public Long getZdsjActualTime() {
  465 + return zdsjActualTime;
  466 + }
  467 +
  468 + public void setZdsjActualTime(Long zdsjActualTime) {
  469 + this.zdsjActualTime = zdsjActualTime;
  470 + }
  471 +
  472 + public int getStatus() {
  473 + return status;
  474 + }
  475 +
  476 + public void setStatus(int status) {
  477 + this.status = status;
  478 + }
  479 +
  480 + public String getAdjustExps() {
  481 + return adjustExps;
  482 + }
  483 +
  484 + public void setAdjustExps(String adjustExps) {
  485 + this.adjustExps = adjustExps;
  486 + }
  487 +
  488 + public boolean isSflj() {
  489 + return sflj;
  490 + }
  491 +
  492 + public void setSflj(boolean sflj) {
  493 + this.sflj = sflj;
  494 + }
  495 +
  496 + public boolean isLate() {
  497 + return late;
  498 + }
  499 +
  500 + public void setLate(boolean late) {
  501 + this.late = late;
  502 + }
  503 +
  504 + public boolean isLate2() {
  505 + return late2;
  506 + }
  507 +
  508 + public void setLate2(boolean late2) {
  509 + this.late2 = late2;
  510 + }
  511 +
  512 + public float getLateMinute() {
  513 + return lateMinute;
  514 + }
  515 +
  516 + public void setLateMinute(float lateMinute) {
  517 + this.lateMinute = lateMinute;
  518 + }
  519 +
  520 + public String getRemarks() {
  521 + return remarks;
  522 + }
  523 +
  524 + public void setRemarks(String remarks) {
  525 + this.remarks = remarks;
  526 + }
  527 +
  528 + public String getDfsj() {
  529 + return dfsj;
  530 + }
  531 +
  532 + public void setDfsj(String dfsj) {
  533 + this.dfsj = dfsj;
  534 + }
  535 +
  536 + public Long getDfsjT() {
  537 + return dfsjT;
  538 + }
  539 +
  540 + public void setDfsjT(Long dfsjT) {
  541 + this.dfsjT = dfsjT;
  542 + }
  543 +
  544 + public Integer getDirectiveState() {
  545 + return directiveState;
  546 + }
  547 +
  548 + public void setDirectiveState(Integer directiveState) {
  549 + this.directiveState = directiveState;
  550 + }
  551 +
  552 + public String getQdzArrDatejh() {
  553 + return qdzArrDatejh;
  554 + }
  555 +
  556 + public void setQdzArrDatejh(String qdzArrDatejh) {
  557 + this.qdzArrDatejh = qdzArrDatejh;
  558 + }
  559 +
  560 + public String getQdzArrDatesj() {
  561 + return qdzArrDatesj;
  562 + }
  563 +
  564 + public void setQdzArrDatesj(String qdzArrDatesj) {
  565 + this.qdzArrDatesj = qdzArrDatesj;
  566 + }
  567 +
  568 + public Set<ChildTaskPlan> getcTasks() {
  569 + return cTasks;
  570 + }
  571 +
  572 + public void setcTasks(Set<ChildTaskPlan> cTasks) {
  573 + this.cTasks = cTasks;
  574 + }
  575 +
  576 + public String getGsName() {
  577 + return gsName;
  578 + }
  579 +
  580 + public void setGsName(String gsName) {
  581 + this.gsName = gsName;
  582 + }
  583 +
  584 + public String getGsBm() {
  585 + return gsBm;
  586 + }
  587 +
  588 + public void setGsBm(String gsBm) {
  589 + this.gsBm = gsBm;
  590 + }
  591 +
  592 + public String getFgsName() {
  593 + return fgsName;
  594 + }
  595 +
  596 + public void setFgsName(String fgsName) {
  597 + this.fgsName = fgsName;
  598 + }
  599 +
  600 + public String getFgsBm() {
  601 + return fgsBm;
  602 + }
  603 +
  604 + public void setFgsBm(String fgsBm) {
  605 + this.fgsBm = fgsBm;
  606 + }
  607 +
  608 + public boolean isDfAuto() {
  609 + return dfAuto;
  610 + }
  611 +
  612 + public void setDfAuto(boolean dfAuto) {
  613 + this.dfAuto = dfAuto;
  614 + }
  615 +
  616 + public boolean isOnline() {
  617 + return online;
  618 + }
  619 +
  620 + public void setOnline(boolean online) {
  621 + this.online = online;
  622 + }
  623 +
  624 + public boolean isReissue() {
  625 + return reissue;
  626 + }
  627 +
  628 + public void setReissue(boolean reissue) {
  629 + this.reissue = reissue;
  630 + }
  631 +
  632 + public Integer getDriftStatus() {
  633 + return driftStatus;
  634 + }
  635 +
  636 + public void setDriftStatus(Integer driftStatus) {
  637 + this.driftStatus = driftStatus;
  638 + }
  639 +
  640 + public boolean isCcService() {
  641 + return ccService;
  642 + }
  643 +
  644 + public void setCcService(boolean ccService) {
  645 + this.ccService = ccService;
  646 + }
  647 +}
... ...
src/main/java/com/bsth/websocket/handler/SendUtils.java
... ... @@ -3,11 +3,11 @@ package com.bsth.websocket.handler;
3 3 import com.alibaba.fastjson.JSONObject;
4 4 import com.bsth.data.BasicData;
5 5 import com.bsth.data.LineConfigData;
6   -import com.bsth.data.gpsdata.GpsEntity;
7   -import com.bsth.data.gpsdata.arrival.entity.SignalState;
  6 +import com.bsth.data.gpsdata_v2.entity.GpsEntity;
8 7 import com.bsth.data.safe_driv.SafeDriv;
9 8 import com.bsth.entity.directive.D80;
10 9 import com.bsth.entity.realcontrol.ScheduleRealInfo;
  10 +import com.bsth.websocket.entity.WsScheduleRealInfo;
11 11 import com.fasterxml.jackson.core.JsonProcessingException;
12 12 import com.fasterxml.jackson.databind.ObjectMapper;
13 13 import org.slf4j.Logger;
... ... @@ -39,7 +39,7 @@ public class SendUtils{
39 39  
40 40 Map<String, Object> map = new HashMap<>();
41 41 map.put("fn", "faChe");
42   - map.put("t", sch);
  42 + map.put("t", WsScheduleRealInfo.getInstance(sch));
43 43 map.put("dataStr", sdf.format(new Date()));
44 44  
45 45 ObjectMapper mapper = new ObjectMapper();
... ... @@ -63,7 +63,7 @@ public class SendUtils{
63 63  
64 64 Map<String, Object> map = new HashMap<>();
65 65 map.put("fn", "refreshSch");
66   - map.put("ts", list);
  66 + map.put("ts", WsScheduleRealInfo.getMultiInstance(list));
67 67  
68 68 ObjectMapper mapper = new ObjectMapper();
69 69  
... ... @@ -80,13 +80,11 @@ public class SendUtils{
80 80 * TODO(推送到达终点时间) @param @param schedule 班次 @throws
81 81 */
82 82 public void sendZdsj(ScheduleRealInfo sch, ScheduleRealInfo nextSch, int finish) {
83   - //处理进站即进场的班次
84   - //connectInSchTime(sch);
85 83  
86 84 Map<String, Object> map = new HashMap<>();
87 85 map.put("fn", "zhongDian");
88   - map.put("t", sch);
89   - map.put("nt", nextSch);
  86 + map.put("t", WsScheduleRealInfo.getInstance(sch));
  87 + map.put("nt", WsScheduleRealInfo.getInstance(nextSch));
90 88 map.put("finish", finish);
91 89 map.put("dataStr", sdf.format(new Date()));
92 90  
... ... @@ -102,7 +100,7 @@ public class SendUtils{
102 100 /**
103 101 * 推送班次信号状态
104 102 * @param state
105   - */
  103 +
106 104 public void sendSignalState(SignalState state){
107 105 Map<String, Object> map = new HashMap<>();
108 106 map.put("fn", "signal_state");
... ... @@ -115,29 +113,8 @@ public class SendUtils{
115 113 } catch (Exception e) {
116 114 logger.error("", e);
117 115 }
118   - }
119   -
120   - /**
121   - *
122   - * @Title: shiftSchedule
123   - * @Description: TODO(线路翻班通知)
124   -
125   - public void shiftSchedule(String lineCode){
126   - Map<String, Object> map = new HashMap<>();
127   - map.put("fn", "systemNotice");
128   - map.put("type", "info");
129   - map.put("text", BasicData.lineCode2NameMap.get(lineCode) + "切换至 "
130   - + DayOfSchedule.currSchDateMap.get(lineCode) + " 日排班");
  116 + }*/
131 117  
132   - ObjectMapper mapper = new ObjectMapper();
133   -
134   - try {
135   - socketHandler.sendMessageToLine(lineCode, mapper.writeValueAsString(map));
136   - } catch (Exception e) {
137   - logger.error("", e);
138   - }
139   - }
140   - */
141 118 /**
142 119 *
143 120 * @Title: sendDirectiveToPage
... ... @@ -147,7 +124,7 @@ public class SendUtils{
147 124  
148 125 Map<String, Object> map = new HashMap<>();
149 126 map.put("fn", "directive");
150   - map.put("t", sch);;
  127 + map.put("t", WsScheduleRealInfo.getInstance(sch));;
151 128  
152 129 ObjectMapper mapper = new ObjectMapper();
153 130  
... ...
src/main/resources/application-dev.properties
... ... @@ -8,9 +8,9 @@ spring.jpa.hibernate.naming_strategy= org.hibernate.cfg.ImprovedNamingStrategy
8 8 spring.jpa.database= MYSQL
9 9 spring.jpa.show-sql= false
10 10 spring.datasource.driver-class-name= com.mysql.jdbc.Driver
11   -spring.datasource.url= jdbc:mysql://127.0.0.1/pd_control?useUnicode=true&characterEncoding=utf-8&useSSL=false
  11 +spring.datasource.url= jdbc:mysql://127.0.0.1/control?useUnicode=true&characterEncoding=utf-8&useSSL=false
12 12 spring.datasource.username= root
13   -spring.datasource.password= root
  13 +spring.datasource.password=
14 14  
15 15 #spring.datasource.url= jdbc:mysql://192.168.168.117/pd_control?useUnicode=true&characterEncoding=utf-8&useSSL=false
16 16 #spring.datasource.username= root
... ... @@ -27,8 +27,10 @@ spring.datasource.test-on-return=true
27 27 spring.datasource.test-while-idle=true
28 28 spring.datasource.validation-query=select 1
29 29  
  30 +http.gps.real.cache.url= http://10.10.150.24:12580/realGps/all
30 31 ##
31 32 #222.66.0.204:5555
  33 +http.gps.real.cache.url= http://10.10.150.24:12580/realGps/all
32 34 http.gps.real.url= http://114.80.178.12:18080/transport_server/rtgps/
33 35 ##\u6D88\u606F\u4E0B\u53D1
34 36 #http.send.directive = http://192.168.168.201:9090/transport_server/message/
35 37 \ No newline at end of file
... ...
src/main/resources/logback.xml
... ... @@ -177,11 +177,7 @@
177 177 </pattern>
178 178 </layout>
179 179 </appender>
180   - <logger name="com.bsth.data.gpsdata.thread.GpsDataLoaderThread"
181   - level="INFO" additivity="false">
182   - <appender-ref ref="GPS_COUNT" />
183   - </logger>
184   - <logger name="com.bsth.data.gpsdata.arrival.GpsRealAnalyse"
  180 + <logger name="com.bsth.data.gpsdata_v2"
185 181 level="INFO" additivity="false">
186 182 <appender-ref ref="GPS_COUNT" />
187 183 </logger>
... ...
src/main/resources/static/pages/base/line/js/map.js
... ... @@ -14,7 +14,7 @@ var WorldsBMapLine = function () {
14 14  
15 15 /** WorldsBMapLine 全局变量定义 mapBValue:地图对象;polyUpline:走向折线;sectionList:截取过的路段 ;pointIndex:计算路段被切的次数;
16 16 * firstPoint:截取路段的第一个点;iseditStatus:路段是否在编辑状态;isCutSection : 获取路段是否在截取状态*/
17   - var mapBValue = '', polyUpline='', sectionList = [], pointIndex = 0, iseditStatus = false, firstPoint = {}, isCutSection = false;
  17 + var mapBValue = '', polyUpline='', sectionList = [], pointIndex = 0, iseditStatus = false, firstPoint = null, isCutSection = false;
18 18  
19 19 var Bmap = {
20 20  
... ... @@ -50,6 +50,10 @@ var WorldsBMapLine = function () {
50 50 getFirstPoint : function() {
51 51 return firstPoint;
52 52 },
  53 + /** 第一个切路段的点 */
  54 + setFirstPoint : function(Point) {
  55 + firstPoint = Point;
  56 + },
53 57 /** 获取地图对象 @return 地图对象map */
54 58 getmapBValue : function() {
55 59  
... ... @@ -329,17 +333,21 @@ var WorldsBMapLine = function () {
329 333 },
330 334 // 批量画点
331 335 batchPaintingPoint : function() {
  336 + // 画第一个点
  337 + var Point = WorldsBMapLine.getFirstPoint();
  338 + if(Point){
  339 + var marker = new BMap.Marker(new BMap.Point(Point.lng, Point.lat)); // 创建点
  340 + var label = new BMap.Label(1,{offset:new BMap.Size(4,0)});
  341 + label.setStyle({border :"0", color : "white",backgroundColor:"rgba(0,0,0,0)"});
  342 + marker.setLabel(label);
  343 + marker.isFlag = true;
  344 + mapBValue.addOverlay(marker);// 添加覆盖物
  345 +
  346 + WorldsBMapLine.getFirstPoint();
  347 + }
332 348 $.each(sectionList, function(index, value) {
333 349 var section = value.section;
334   - debugger
335   - if(index == 0){
336   - var marker = new BMap.Marker(new BMap.Point(section[0].lng, section[0].lat)); // 创建点
337   - var label = new BMap.Label(index+1,{offset:new BMap.Size(index>8?0:4,0)});
338   - label.setStyle({border :"0", color : "white",backgroundColor:"rgba(0,0,0,0)"});
339   - marker.setLabel(label);
340   - marker.isFlag = true;
341   - mapBValue.addOverlay(marker);// 添加覆盖物
342   - }
  350 +
343 351 var marker = new BMap.Marker(new BMap.Point(section[1].lng, section[1].lat)); // 创建点
344 352 var label = new BMap.Label(index+2,{offset:new BMap.Size(index>7?0:4,0)});
345 353 label.setStyle({border :"0", color : "white",backgroundColor:"rgba(0,0,0,0)"});
... ... @@ -704,7 +712,6 @@ var WorldsBMapLine = function () {
704 712 mapBValue.panBy(10,-200,PanOptions_);
705 713  
706 714 // 关闭按钮事件
707   - debugger
708 715 PublicFunctions.addAChangeCssAddDisabled();
709 716  
710 717 // 编辑圆监听事件
... ...
src/main/resources/static/pages/base/line/map.html
... ... @@ -130,14 +130,15 @@ $(function(){
130 130 $(pjaxContainer).append(m);
131 131 $('#edit_route_mobal').trigger('editRouteMobal.show',[TransGPS,EditRoute,WorldsBMapLine,DrawingManagerObj,GetAjaxData,PublicFunctions]);
132 132 });
133   - // 更新section_table 和缓存中的一切过的点数
  133 + // 更新section_table 和缓存中的切点
134 134 WorldsBMapLine.initCutSectionPoint();
135 135 WorldsBMapLine.setPointIndex(0);
  136 + WorldsBMapLine.setFirstPoint(null);// 删除点后清空数据(第一个点坐标)
136 137 });
137 138  
138 139 // 提交截取事件
139   - $('#cutSection').on('click', function() {
140   - if(WorldsBMapLine.getPointIndex() > 0) {
  140 + $('#cutSection').on('click', function() {
  141 + if(WorldsBMapLine.getSectionList().length != 0) {
141 142 var sectionList = WorldsBMapLine.getSectionList();
142 143 var data = {};
143 144 var section = EditSectionObj.getEitdSection();
... ... @@ -169,12 +170,12 @@ $(function(){
169 170 WorldsBMapLine.deleteCutSectionPoint(point);
170 171 WorldsBMapLine.refreshCutSectionTable();
171 172 } else if(WorldsBMapLine.getPointIndex() == 1 ) {
172   - // 点总数-1
173 173 var pointIndex = WorldsBMapLine.getPointIndex() - 1;
174 174 WorldsBMapLine.setPointIndex(pointIndex);
175 175 var firstPoint = WorldsBMapLine.getFirstPoint();
176 176 WorldsBMapLine.deleteCutSectionPoint(firstPoint);
177 177 WorldsBMapLine.setIsCutSection(false);
  178 + WorldsBMapLine.setFirstPoint(null);// 删除点后清空数据
178 179 } else {
179 180 layer.msg("没有截取路段,不可以撤销!!!");
180 181 }
... ...
src/main/resources/static/pages/base/section/js/add-input-function.js
... ... @@ -79,16 +79,12 @@ var PublicFunctions = function () {
79 79 // 获取某线路下的路段路由.
80 80 getSectionRouteInfo : function(line,callback) {
81 81 $get('/sectionroute/all',{'line.id_eq':line,'destroy_eq':0},function(result) {
82   - /*if(result.length>0)
83   - result.sort(function(a,b){return a.sectionrouteCode-b.sectionrouteCode});*/
84 82 callback && callback(result);
85 83 });
86 84 },
87 85 // 新增路段保存.
88 86 sectionSave : function(section,callback) {
89   - debugger
90 87 $post('/section/sectionSave',section,function(data) {
91   - debugger
92 88 callback && callback(data);
93 89 });
94 90 }
... ...
src/main/resources/static/pages/base/timesmodel/js/v2/ParameterObj.js
... ... @@ -18,7 +18,46 @@ var ParameterObj = function() {
18 18 }
19 19 };
20 20  
  21 + // 计算吃饭时间
  22 + var _fnEatTime = function() {
  23 + var aTime = [];
  24 + // 午饭时间
  25 + aTime.push(
  26 + isNaN(_formMap.workeLunch) || parseInt(_formMap.workeLunch) == 0 ?
  27 + 20 : parseInt(_formMap.workeLunch)
  28 + );
  29 + // 晚饭时间
  30 + aTime.push(
  31 + isNaN(_formMap.workeDinner) || parseInt(_formMap.workeDinner) == 0 ?
  32 + 20 : parseInt(_formMap.workeDinner)
  33 + );
  34 +
  35 + return aTime;
  36 + };
  37 + var _aEatTime;
  38 +
  39 + // 计算吃饭地点
  40 + var _fnEatDir = function() {
  41 + var aEatD = [];
  42 +
  43 + if (_formMap.cfdd != undefined && String(_formMap.cfdd) == "") {
  44 + aEatD = false;
  45 + } else if (parseInt(_formMap.cfdd) == 0) {
  46 + aEatD.push(true);
  47 + } else if (parseInt(_formMap.cfdd) == 1) {
  48 + aEatD.push(false);
  49 + } else if (String(_formMap.cfdd) == "allYes") {
  50 + aEatD.push(true);
  51 + aEatD.push(false);
  52 + }
  53 +
  54 + return aEatD;
  55 + };
  56 + var _aEatDir;
  57 +
  58 +
21 59 // 计算行驶时间对象
  60 + // TODO:暂时获取标准信息,之后改成历史数据,可能需要使用promise封装
22 61 var _travelTimeObj_fun = function() {
23 62 var upMoningPeakTravelTime =
24 63 isNaN(_formMap.earlyUpTime) || parseInt(_formMap.earlyUpTime) == 0 ?
... ... @@ -62,6 +101,34 @@ var ParameterObj = function() {
62 101 };
63 102 var _travelTimeObj;
64 103  
  104 + // 计算上下行进出场时间
  105 + var _inOutTimeObj_fun = function() {
  106 + var upInTime =
  107 + isNaN(_formMap.upInTimer) || parseInt(_formMap.upInTimer) == 0 ?
  108 + 20 : parseInt(_formMap.upInTimer);
  109 + var upOutTime =
  110 + isNaN(_formMap.upOutTimer) || parseInt(_formMap.upOutTimer) == 0 ?
  111 + 20 : parseInt(_formMap.upOutTimer);
  112 + var downInTime =
  113 + isNaN(_formMap.downInTimer) || parseInt(_formMap.downInTimer) == 0 ?
  114 + 20 : parseInt(_formMap.downInTimer);
  115 + var downOutTime =
  116 + isNaN(_formMap.downOutTimer) || parseInt(_formMap.downOutTimer) == 0 ?
  117 + 20 : parseInt(_formMap.downOutTimer);
  118 +
  119 + return [
  120 + { // 上行
  121 + "out": upOutTime,
  122 + "in": upInTime
  123 + },
  124 + { // 下行
  125 + "out": downOutTime,
  126 + "in": downInTime
  127 + }
  128 + ]
  129 + };
  130 + var _inOutTimeObj;
  131 +
65 132 // 计算行驶里程对象
66 133 var _travelLcObj_fun = function() {
67 134 return [
... ... @@ -274,10 +341,16 @@ var ParameterObj = function() {
274 341  
275 342 _validInternal(); // 验证
276 343  
  344 + // 吃饭时间
  345 + _aEatTime = _fnEatTime();
  346 + // 吃饭地点
  347 + _aEatDir = _fnEatDir();
277 348 // 首班车,末班车行驶时间字符串
278 349 _firstLastDepartureTimeStrObj = _firstLastDepartureTimeStrObj_fun();
279 350 // 行驶时间对象
280 351 _travelTimeObj = _travelTimeObj_fun();
  352 + // 上下行进出场时间
  353 + _inOutTimeObj = _inOutTimeObj_fun();
281 354 // 行驶里程对象
282 355 _travelLcObj = _travelLcObj_fun();
283 356 // 时间段划分对象
... ... @@ -342,6 +415,52 @@ var ParameterObj = function() {
342 415 );
343 416 },
344 417  
  418 + //-------------- 获取吃饭时间 ----------------//
  419 + /**
  420 + * 获取午饭时间。
  421 + * @returns int
  422 + */
  423 + fnGetLunchTime: function() {
  424 + _validInternal(); // 验证
  425 + return _aEatTime[0];
  426 + },
  427 + /**
  428 + * 获取晚饭时间。
  429 + * @returns int
  430 + */
  431 + fnGetDinnerTime: function() {
  432 + _validInternal(); // 验证
  433 + return _aEatTime[1];
  434 + },
  435 +
  436 + //-------------- 获取吃饭地点 ----------------//
  437 + /**
  438 + * 是否吃饭。
  439 + * @returns {boolean}
  440 + */
  441 + fnIsEat: function() {
  442 + _validInternal(); // 验证
  443 + return _aEatDir ? true : false;
  444 + },
  445 +
  446 + /**
  447 + * 是否上行吃饭。
  448 + * @returns {boolean}
  449 + */
  450 + fnIsUpEat: function() {
  451 + _validInternal(); // 验证
  452 + return this.fnIsEat() ? _aEatDir[0] : false;
  453 + },
  454 +
  455 + /**
  456 + * 是否上下行都能吃饭。
  457 + * @returns {boolean}
  458 + */
  459 + fnIsBothEat: function() {
  460 + _validInternal(); // 验证
  461 + return (this.fnIsEat() && _aEatDir.length > 1) ? true : false;
  462 + },
  463 +
345 464 //-------------- 获取行驶时间 ----------------//
346 465 /**
347 466 * 获取上行早高峰行驶时间。
... ... @@ -392,6 +511,39 @@ var ParameterObj = function() {
392 511 return _travelTimeObj.trough[1];
393 512 },
394 513  
  514 + /**
  515 + * 获取上行出场时间。
  516 + * @returns int number
  517 + */
  518 + getUpOutTime: function() {
  519 + _validInternal(); // 验证
  520 + return _inOutTimeObj[0].out;
  521 + },
  522 + /**
  523 + * 获取上行进场时间。
  524 + * @returns int number
  525 + */
  526 + getUpInTime: function() {
  527 + _validInternal(); // 验证
  528 + return _inOutTimeObj[0].in;
  529 + },
  530 + /**
  531 + * 获取下行出场时间。
  532 + * @returns int number
  533 + */
  534 + getDownOutTime: function() {
  535 + _validInternal(); // 验证
  536 + return _inOutTimeObj[1].out;
  537 + },
  538 + /**
  539 + * 获取下行进场时间。
  540 + * @returns int number
  541 + */
  542 + getDownInTime: function() {
  543 + _validInternal(); // 验证
  544 + return _inOutTimeObj[1].in;
  545 + },
  546 +
395 547 //---------------- 获取行驶里程 -----------------//
396 548 /**
397 549 * 获取上行normal班次里程。
... ... @@ -578,6 +730,15 @@ var ParameterObj = function() {
578 730 return parseInt(_formMap.jbclcount);
579 731 },
580 732  
  733 + //----------------- 获取保养信息 ------------------//
  734 + /**
  735 + * 获取例保时间。
  736 + */
  737 + getLbTime: function() {
  738 + _validInternal(); // 验证
  739 + return isNaN(_formMap.lb) || parseInt(_formMap.lb) == 0 ? 5 : parseInt(_formMap.lb);
  740 + },
  741 +
581 742 //----------------- 获取关联数据信息 -----------------//
582 743 /**
583 744 * 获取线路id。
... ... @@ -735,163 +896,186 @@ var ParameterObj = function() {
735 896  
736 897 /**
737 898 * 获取固定的停站时间(固定停站时间都是选的最大值)
738   - * @param timeObj 时间对象
739   - * @param isUp 是否上行
740   - * @returns number
  899 + * @param oTimeObj 时间对象
  900 + * @param bIsUp 是否上行
  901 + * @param iXXTime 行驶时间
  902 + * @returns int 停站时间
741 903 */
742   - calcuFixedStopNumber: function(timeObj, isUp) {
  904 + fnCalcuFixedStopNumber: function(oTimeObj, bIsUp, iXXTime) {
743 905 _validInternal(); // 验证
744   - var paramObj = this;
  906 + var oParam = this;
  907 +
  908 + var iPeakStopTime; // 高峰停站时间
  909 + var iTroughStopTime; // 低谷停站时间
  910 + var iSecondaryStopTime; // 副站停站时间
745 911  
746   - var peakStopTime; // 高峰停站时间
747   - var troughStopTime; // 低谷停站时间
748   - var secondaryStopTime; // 副站停站时间
  912 + var iXXTime_temp;
749 913  
750 914 // 双向停站
751   - if (paramObj.isTwoWayStop()) {
752   - if (isUp) { // 上行
753   - if (this.isMPeakBc(timeObj)) { // 早高峰
754   - peakStopTime = Math.floor(paramObj.getUpMPeakTime() * 0.1); // 行驶时间的10%
755   - if (peakStopTime < 3) { // 不少于3分钟
756   - peakStopTime = 3;
  915 + if (oParam.isTwoWayStop()) {
  916 + if (bIsUp) { // 上行
  917 + if (this.isMPeakBc(oTimeObj)) { // 早高峰
  918 + iXXTime_temp = iXXTime == undefined ? oParam.getUpMPeakTime() : iXXTime;
  919 + iPeakStopTime = Math.floor(iXXTime_temp * 0.1); // 行驶时间的10%
  920 + if (iPeakStopTime < 3) { // 不少于3分钟
  921 + iPeakStopTime = 3;
757 922 }
758   - return peakStopTime;
759   - } else if (this.isEPeakBc(timeObj)) { // 晚高峰
760   - peakStopTime = Math.floor(paramObj.getUpEPeakTime() * 0.1); // 行驶时间的10%
761   - if (peakStopTime < 3) { // 不少于3分钟
762   - peakStopTime = 3;
  923 + return iPeakStopTime;
  924 + } else if (this.isEPeakBc(oTimeObj)) { // 晚高峰
  925 + iXXTime_temp = iXXTime == undefined ? oParam.getUpEPeakTime() : iXXTime;
  926 + iPeakStopTime = Math.floor(iXXTime_temp * 0.1); // 行驶时间的10%
  927 + if (iPeakStopTime < 3) { // 不少于3分钟
  928 + iPeakStopTime = 3;
763 929 }
764   - return peakStopTime;
  930 + return iPeakStopTime;
765 931 } else { // 低谷
766   - if (this.isTroughBeforMPeakStartBc(timeObj)) { // 早高峰开始前
767   - troughStopTime = Math.floor(paramObj.getUpTroughTime() * 0.2); // 行驶时间20%
768   - if (troughStopTime < 10) { // 不少于10分钟
769   - troughStopTime = 10;
  932 + if (this.isTroughBeforMPeakStartBc(oTimeObj)) { // 早高峰开始前
  933 + iXXTime_temp = iXXTime == undefined ? oParam.getUpTroughTime() : iXXTime;
  934 + iTroughStopTime = Math.floor(iXXTime_temp * 0.2); // 行驶时间20%
  935 + if (iTroughStopTime < 10) { // 不少于10分钟
  936 + iTroughStopTime = 10;
770 937 }
771   - return troughStopTime;
772   - } else if (this.isTroughAfterEPeakEndBc(timeObj)) { // 晚高峰结束后
773   - troughStopTime = Math.floor(paramObj.getUpTroughTime() * 0.2); // 行驶时间20%
774   - if (troughStopTime < 10) { // 不少于10分钟
775   - troughStopTime = 10;
  938 + return iTroughStopTime;
  939 + } else if (this.isTroughAfterEPeakEndBc(oTimeObj)) { // 晚高峰结束后
  940 + iXXTime_temp = iXXTime == undefined ? oParam.getUpTroughTime() : iXXTime;
  941 + iTroughStopTime = Math.floor(iXXTime_temp * 0.2); // 行驶时间20%
  942 + if (iTroughStopTime < 10) { // 不少于10分钟
  943 + iTroughStopTime = 10;
776 944 }
777   - return troughStopTime;
  945 + return iTroughStopTime;
778 946 } else { // 早高峰,晚高峰之间
779   - troughStopTime = Math.floor(paramObj.getUpTroughTime() * 0.15); // 行驶时间15%
780   - if (troughStopTime < 10) { // 不少于10分钟
781   - troughStopTime = 10;
  947 + iXXTime_temp = iXXTime == undefined ? oParam.getUpTroughTime() : iXXTime;
  948 + iTroughStopTime = Math.floor(iXXTime_temp * 0.15); // 行驶时间15%
  949 + if (iTroughStopTime < 10) { // 不少于10分钟
  950 + iTroughStopTime = 10;
782 951 }
783   - return troughStopTime;
  952 + return iTroughStopTime;
784 953 }
785 954 }
786 955 } else { // 下行
787   - if (this.isMPeakBc(timeObj)) { // 早高峰
788   - peakStopTime = Math.floor(paramObj.getDownMPeakTime() * 0.1); // 行驶时间的10%
789   - if (peakStopTime < 3) { // 不少于3分钟
790   - peakStopTime = 3;
  956 + if (this.isMPeakBc(oTimeObj)) { // 早高峰
  957 + iXXTime_temp = iXXTime == undefined ? oParam.getDownMPeakTime() : iXXTime;
  958 + iPeakStopTime = Math.floor(iXXTime_temp * 0.1); // 行驶时间的10%
  959 + if (iPeakStopTime < 3) { // 不少于3分钟
  960 + iPeakStopTime = 3;
791 961 }
792   - return peakStopTime;
793   - } else if (this.isEPeakBc(timeObj)) { // 晚高峰
794   - peakStopTime = Math.floor(paramObj.getDownEPeakTime() * 0.1); // 行驶时间的10%
795   - if (peakStopTime < 3) { // 不少于3分钟
796   - peakStopTime = 3;
  962 + return iPeakStopTime;
  963 + } else if (this.isEPeakBc(oTimeObj)) { // 晚高峰
  964 + iXXTime_temp = iXXTime == undefined ? oParam.getDownEPeakTime() : iXXTime;
  965 + iPeakStopTime = Math.floor(iXXTime_temp * 0.1); // 行驶时间的10%
  966 + if (iPeakStopTime < 3) { // 不少于3分钟
  967 + iPeakStopTime = 3;
797 968 }
798   - return peakStopTime;
  969 + return iPeakStopTime;
799 970 } else { // 低谷
800   - if (this.isTroughBeforMPeakStartBc(timeObj)) { // 早高峰开始前
801   - troughStopTime = Math.floor(paramObj.getDownTroughTime() * 0.2); // 行驶时间20%
802   - if (troughStopTime < 10) { // 不少于10分钟
803   - troughStopTime = 10;
  971 + if (this.isTroughBeforMPeakStartBc(oTimeObj)) { // 早高峰开始前
  972 + iXXTime_temp = iXXTime == undefined ? oParam.getDownTroughTime() : iXXTime;
  973 + iTroughStopTime = Math.floor(iXXTime_temp * 0.2); // 行驶时间20%
  974 + if (iTroughStopTime < 10) { // 不少于10分钟
  975 + iTroughStopTime = 10;
804 976 }
805   - return troughStopTime;
806   - } else if (this.isTroughAfterEPeakEndBc(timeObj)) { // 晚高峰结束后
807   - troughStopTime = Math.floor(paramObj.getDownTroughTime() * 0.2); // 行驶时间20%
808   - if (troughStopTime < 10) { // 不少于10分钟
809   - troughStopTime = 10;
  977 + return iTroughStopTime;
  978 + } else if (this.isTroughAfterEPeakEndBc(oTimeObj)) { // 晚高峰结束后
  979 + iXXTime_temp = iXXTime == undefined ? oParam.getDownTroughTime() : iXXTime;
  980 + iTroughStopTime = Math.floor(iXXTime_temp * 0.2); // 行驶时间20%
  981 + if (iTroughStopTime < 10) { // 不少于10分钟
  982 + iTroughStopTime = 10;
810 983 }
811   - return troughStopTime;
  984 + return iTroughStopTime;
812 985 } else { // 早高峰,晚高峰之间
813   - troughStopTime = Math.floor(paramObj.getDownTroughTime() * 0.15); // 行驶时间15%
814   - if (troughStopTime < 10) { // 不少于10分钟
815   - troughStopTime = 10;
  986 + iXXTime_temp = iXXTime == undefined ? oParam.getDownTroughTime() : iXXTime;
  987 + iTroughStopTime = Math.floor(iXXTime_temp * 0.15); // 行驶时间15%
  988 + if (iTroughStopTime < 10) { // 不少于10分钟
  989 + iTroughStopTime = 10;
816 990 }
817   - return troughStopTime;
  991 + return iTroughStopTime;
818 992 }
819 993 }
820 994 }
821 995 } else { // 主站停站
822   - if (isUp == paramObj.isUpOneWayStop()) {
823   - if (isUp) { // 上行
824   - if (this.isMPeakBc(timeObj)) { // 早高峰
825   - peakStopTime = Math.floor(paramObj.getUpMPeakTime() * 0.1); // 行驶时间的10%
826   - if (peakStopTime < 3) { // 不少于3分钟
827   - peakStopTime = 3;
  996 + if (bIsUp == oParam.isUpOneWayStop()) {
  997 + if (bIsUp) { // 上行
  998 + if (this.isMPeakBc(oTimeObj)) { // 早高峰
  999 + iXXTime_temp = iXXTime == undefined ? oParam.getUpMPeakTime() : iXXTime;
  1000 + iPeakStopTime = Math.floor(iXXTime_temp * 0.1); // 行驶时间的10%
  1001 + if (iPeakStopTime < 3) { // 不少于3分钟
  1002 + iPeakStopTime = 3;
828 1003 }
829   - return peakStopTime;
830   - } else if (this.isEPeakBc(timeObj)) { // 晚高峰
831   - peakStopTime = Math.floor(paramObj.getUpEPeakTime() * 0.1); // 行驶时间的10%
832   - if (peakStopTime < 3) { // 不少于3分钟
833   - peakStopTime = 3;
  1004 + return iPeakStopTime;
  1005 + } else if (this.isEPeakBc(oTimeObj)) { // 晚高峰
  1006 + iXXTime_temp = iXXTime == undefined ? oParam.getUpEPeakTime() : iXXTime;
  1007 + iPeakStopTime = Math.floor(iXXTime_temp * 0.1); // 行驶时间的10%
  1008 + if (iPeakStopTime < 3) { // 不少于3分钟
  1009 + iPeakStopTime = 3;
834 1010 }
835   - return peakStopTime;
  1011 + return iPeakStopTime;
836 1012 } else { // 低谷
837   - if (this.isTroughBeforMPeakStartBc(timeObj)) { // 早高峰开始前
838   - troughStopTime = Math.floor(paramObj.getUpTroughTime() * 0.2); // 行驶时间20%
839   - if (troughStopTime < 10) { // 不少于10分钟
840   - troughStopTime = 10;
  1013 + if (this.isTroughBeforMPeakStartBc(oTimeObj)) { // 早高峰开始前
  1014 + iXXTime_temp = iXXTime == undefined ? oParam.getUpTroughTime() : iXXTime;
  1015 + iTroughStopTime = Math.floor(iXXTime_temp * 0.2); // 行驶时间20%
  1016 + if (iTroughStopTime < 10) { // 不少于10分钟
  1017 + iTroughStopTime = 10;
841 1018 }
842   - return troughStopTime;
843   - } else if (this.isTroughAfterEPeakEndBc(timeObj)) { // 晚高峰结束后
844   - troughStopTime = Math.floor(paramObj.getUpTroughTime() * 0.2); // 行驶时间20%
845   - if (troughStopTime < 10) { // 不少于10分钟
846   - troughStopTime = 10;
  1019 + return iTroughStopTime;
  1020 + } else if (this.isTroughAfterEPeakEndBc(oTimeObj)) { // 晚高峰结束后
  1021 + iXXTime_temp = iXXTime == undefined ? oParam.getUpTroughTime() : iXXTime;
  1022 + iTroughStopTime = Math.floor(iXXTime_temp * 0.2); // 行驶时间20%
  1023 + if (iTroughStopTime < 10) { // 不少于10分钟
  1024 + iTroughStopTime = 10;
847 1025 }
848   - return troughStopTime;
  1026 + return iTroughStopTime;
849 1027 } else { // 早高峰,晚高峰之间
850   - troughStopTime = Math.floor(paramObj.getUpTroughTime() * 0.15); // 行驶时间15%
851   - if (troughStopTime < 10) { // 不少于10分钟
852   - troughStopTime = 10;
  1028 + iXXTime_temp = iXXTime == undefined ? oParam.getUpTroughTime() : iXXTime;
  1029 + iTroughStopTime = Math.floor(iXXTime_temp * 0.15); // 行驶时间15%
  1030 + if (iTroughStopTime < 10) { // 不少于10分钟
  1031 + iTroughStopTime = 10;
853 1032 }
854   - return troughStopTime;
  1033 + return iTroughStopTime;
855 1034 }
856 1035 }
857 1036 } else { // 下行
858   - if (this.isMPeakBc(timeObj)) { // 早高峰
859   - peakStopTime = Math.floor(paramObj.getDownMPeakTime() * 0.1); // 行驶时间的10%
860   - if (peakStopTime < 3) { // 不少于3分钟
861   - peakStopTime = 3;
  1037 + if (this.isMPeakBc(oTimeObj)) { // 早高峰
  1038 + iXXTime_temp = iXXTime == undefined ? oParam.getDownMPeakTime() : iXXTime;
  1039 + iPeakStopTime = Math.floor(iXXTime_temp * 0.1); // 行驶时间的10%
  1040 + if (iPeakStopTime < 3) { // 不少于3分钟
  1041 + iPeakStopTime = 3;
862 1042 }
863   - return peakStopTime;
864   - } else if (this.isEPeakBc(timeObj)) { // 晚高峰
865   - peakStopTime = Math.floor(paramObj.getDownEPeakTime() * 0.1); // 行驶时间的10%
866   - if (peakStopTime < 3) { // 不少于3分钟
867   - peakStopTime = 3;
  1043 + return iPeakStopTime;
  1044 + } else if (this.isEPeakBc(oTimeObj)) { // 晚高峰
  1045 + iXXTime_temp = iXXTime == undefined ? oParam.getDownEPeakTime() : iXXTime;
  1046 + iPeakStopTime = Math.floor(iXXTime_temp * 0.1); // 行驶时间的10%
  1047 + if (iPeakStopTime < 3) { // 不少于3分钟
  1048 + iPeakStopTime = 3;
868 1049 }
869   - return peakStopTime;
  1050 + return iPeakStopTime;
870 1051 } else { // 低谷
871   - if (this.isTroughBeforMPeakStartBc(timeObj)) { // 早高峰开始前
872   - troughStopTime = Math.floor(paramObj.getDownTroughTime() * 0.2); // 行驶时间20%
873   - if (troughStopTime < 10) { // 不少于10分钟
874   - troughStopTime = 10;
  1052 + if (this.isTroughBeforMPeakStartBc(oTimeObj)) { // 早高峰开始前
  1053 + iXXTime_temp = iXXTime == undefined ? oParam.getDownTroughTime() : iXXTime;
  1054 + iTroughStopTime = Math.floor(iXXTime_temp * 0.2); // 行驶时间20%
  1055 + if (iTroughStopTime < 10) { // 不少于10分钟
  1056 + iTroughStopTime = 10;
875 1057 }
876   - return troughStopTime;
877   - } else if (this.isTroughAfterEPeakEndBc(timeObj)) { // 晚高峰结束后
878   - troughStopTime = Math.floor(paramObj.getDownTroughTime() * 0.2); // 行驶时间20%
879   - if (troughStopTime < 10) { // 不少于10分钟
880   - troughStopTime = 10;
  1058 + return iTroughStopTime;
  1059 + } else if (this.isTroughAfterEPeakEndBc(oTimeObj)) { // 晚高峰结束后
  1060 + iXXTime_temp = iXXTime == undefined ? oParam.getDownTroughTime() : iXXTime;
  1061 + iTroughStopTime = Math.floor(iXXTime_temp * 0.2); // 行驶时间20%
  1062 + if (iTroughStopTime < 10) { // 不少于10分钟
  1063 + iTroughStopTime = 10;
881 1064 }
882   - return troughStopTime;
  1065 + return iTroughStopTime;
883 1066 } else { // 早高峰,晚高峰之间
884   - troughStopTime = Math.floor(paramObj.getDownTroughTime() * 0.15); // 行驶时间15%
885   - if (troughStopTime < 10) { // 不少于10分钟
886   - troughStopTime = 10;
  1067 + iXXTime_temp = iXXTime == undefined ? oParam.getDownTroughTime() : iXXTime;
  1068 + iTroughStopTime = Math.floor(iXXTime_temp * 0.15); // 行驶时间15%
  1069 + if (iTroughStopTime < 10) { // 不少于10分钟
  1070 + iTroughStopTime = 10;
887 1071 }
888   - return troughStopTime;
  1072 + return iTroughStopTime;
889 1073 }
890 1074 }
891 1075 }
892 1076 } else { // 副站停战,2到3分钟
893   - secondaryStopTime = 3;
894   - return secondaryStopTime; // 直接返回3分钟
  1077 + iSecondaryStopTime = 3;
  1078 + return iSecondaryStopTime; // 直接返回3分钟
895 1079 }
896 1080 }
897 1081  
... ... @@ -935,20 +1119,28 @@ var ParameterObj = function() {
935 1119 var paramObj = this;
936 1120  
937 1121 if (isUp) {
938   - if (bcType == "in") {
  1122 + if (bcType == "in_") {
939 1123 return paramObj.getUpInLc();
940 1124 } else if (bcType == "out") {
941 1125 return paramObj.getUpOutLc();
  1126 + } else if (bcType == "bd") {
  1127 + return 0;
  1128 + } else if (bcType == "lc") {
  1129 + return 0;
942 1130 } else {
943 1131 // 基本班次类型,暂时不考虑区间等其他班次类型
944 1132 // 暂时不考虑高峰低谷里程的区分
945 1133 return paramObj.getUpNormalLc();
946 1134 }
947 1135 } else {
948   - if (bcType == "in") {
  1136 + if (bcType == "in_") {
949 1137 return paramObj.getDownInLc();
950 1138 } else if (bcType == "out") {
951 1139 return paramObj.getDownOutLc();
  1140 + } else if (bcType == "bd") {
  1141 + return 0;
  1142 + } else if (bcType == "lc") {
  1143 + return 0;
952 1144 } else {
953 1145 // 基本班次类型,暂时不考虑区间等其他班次类型
954 1146 // 暂时不考虑高峰低谷里程的区分
... ... @@ -969,9 +1161,9 @@ var ParameterObj = function() {
969 1161 var _time = paramObj.getMPeakStartTimeObj();
970 1162 var _zzsj = // 早高峰上行行驶时间+停站时间+早高峰下行行驶时间+停站时间
971 1163 this.calcuTravelTime(_time, true) +
972   - this.calcuFixedStopNumber(_time, true) +
  1164 + this.fnCalcuFixedStopNumber(_time, true) +
973 1165 this.calcuTravelTime(_time, false) +
974   - this.calcuFixedStopNumber(_time, false);
  1166 + this.fnCalcuFixedStopNumber(_time, false);
975 1167 return _zzsj;
976 1168 },
977 1169  
... ... @@ -987,9 +1179,9 @@ var ParameterObj = function() {
987 1179 var _time = this.addMinute(paramObj.getMPeakStartTimeObj(), -1); // 使用任意一个低谷时间
988 1180 var _zzsj = // 低谷上行行驶时间+停站时间+低谷下行行驶时间+停站时间
989 1181 this.calcuTravelTime(_time, true) +
990   - this.calcuFixedStopNumber(_time, true) +
  1182 + this.fnCalcuFixedStopNumber(_time, true) +
991 1183 this.calcuTravelTime(_time, false) +
992   - this.calcuFixedStopNumber(_time, false);
  1184 + this.fnCalcuFixedStopNumber(_time, false);
993 1185  
994 1186 return _zzsj;
995 1187 },
... ...
src/main/resources/static/pages/base/timesmodel/js/v2/core/InternalBcObj.js
... ... @@ -38,10 +38,21 @@ var InternalBcObj = function(
38 38 this._$_qdzid = otherParamObj.qdzid; // 起点站id
39 39 this._$_zdzid = otherParamObj.zdzid; // 终点站id
40 40  
  41 + // 标记参数,这个班次用于计算,最后必须删除
  42 + this._$_bDelFlag = false;
  43 +
41 44 };
42 45  
43 46 //------------------- get/set 方法 -------------------//
44 47  
  48 +InternalBcObj.prototype.fnSetDelFlag = function(bFlag) {
  49 + this._$_bDelFlag = bFlag;
  50 +};
  51 +
  52 +InternalBcObj.prototype.fnIsDelFlag = function() {
  53 + return this._$_bDelFlag;
  54 +};
  55 +
45 56 /**
46 57 * 设置路牌对象。
47 58 * @param lpObj InternalLpObj路牌对象
... ... @@ -72,6 +83,13 @@ InternalBcObj.prototype.getFcTimeObj = function() {
72 83 return this._$_fcsjObj;
73 84 };
74 85 /**
  86 + * 设置发车时间。
  87 + * @param oFcsj
  88 + */
  89 +InternalBcObj.prototype.setFcTimeObj = function(oFcsj) {
  90 + this._$_fcsjObj = oFcsj;
  91 +};
  92 +/**
75 93 * 获取到达时间。
76 94 * @returns {*|moment.Moment}
77 95 */
... ... @@ -79,6 +97,13 @@ InternalBcObj.prototype.getArrTimeObj = function() {
79 97 return this._$_arrtime;
80 98 };
81 99 /**
  100 + * 设置到达时间。
  101 + * @param oTime
  102 + */
  103 +InternalBcObj.prototype.setArrTimeObj = function(oTime) {
  104 + this._$_arrtime = oTime;
  105 +};
  106 +/**
82 107 * 获取班次时间。
83 108 * @returns int
84 109 */
... ... @@ -92,10 +117,43 @@ InternalBcObj.prototype.getBcTime = function() {
92 117 InternalBcObj.prototype.getStopTime = function() {
93 118 return this._$_stoptime;
94 119 };
  120 +/**
  121 + * 设置停站时间。
  122 + * @param t int
  123 + */
  124 +InternalBcObj.prototype.setStopTime = function(t) {
  125 + this._$_stoptime = t;
  126 +};
  127 +
  128 +/**
  129 + * 获取发车顺序号。
  130 + * @returns int
  131 + */
  132 +InternalBcObj.prototype.fnGetFcno = function() {
  133 + return this._$_fcno;
  134 +};
  135 +/**
  136 + * 设置发车顺序号。
  137 + * @param t int
  138 + */
  139 +InternalBcObj.prototype.fnSetFcno = function(t) {
  140 + this._$_fcno = t;
  141 +};
  142 +
  143 +
95 144  
96 145 //---------------------- 其他方法 -------------------------//
97 146  
98 147 /**
  148 + * 给发车时间添加时间。
  149 + * @param num
  150 + */
  151 +InternalBcObj.prototype.addMinuteToFcsj = function(num) {
  152 + this._$_fcsjObj.add(num, "m"); // 发车时间不需要clone
  153 + this._$_arrtime.add(num, "m"); // 到达时间也不需要clone
  154 +};
  155 +
  156 +/**
99 157 * 转换成显示用班次对象。
100 158 * @returns {{}}
101 159 */
... ...
src/main/resources/static/pages/base/timesmodel/js/v2/core/InternalLpObj.js
... ... @@ -12,11 +12,6 @@ var InternalLpObj = function(
12 12  
13 13 this._$_isUp = isUp;
14 14  
15   - // 距离上一个路牌的最小发车间隔时间
16   - // 用于纵向添加班次的时候使用
17   - // 默认第一个路牌为0
18   - this._$_minVerticalIntervalTime = 0;
19   -
20 15 // 路牌的圈数,注意每个路牌的圈数都是一致的,
21 16 // 但并不是每一圈都有值
22 17 // 第1圈从上标线开始
... ... @@ -32,18 +27,44 @@ var InternalLpObj = function(
32 27 this, this._$_isUp, undefined, undefined);
33 28 }
34 29  
35   - // 班型的相关变量
  30 + // 距离上一个路牌的最小发车间隔时间
  31 + // 用于纵向添加班次的时候使用
  32 + // 默认第一个路牌为0
  33 + this._$_minVerticalIntervalTime = 0;
  34 +
  35 + // 详细记录每圈每个方向上的发车间隔时间
  36 + // 第一维度表示圈数,第二维度表示第一个方向,第二个方向
  37 + // 第一个方向是否上行由 _$_isUp 决定
  38 + // 这里的间隔表示下一个路牌上的班次距离本路牌的班次发车时间间隔
  39 + // 如果当前是最后一个路牌,表示第一个路牌的下一圈同方向班次距离本班次的间隔
  40 + this._$_aVerticalIntervalTime = new Array(this._$_qCount);
  41 + var i;
  42 + for (i = 0; i < this._$_aVerticalIntervalTime.length; i++) {
  43 + this._$_aVerticalIntervalTime[i] = new Array(2);
  44 + }
  45 +
  46 + // 班型的相关变量
36 47 this._$_bx_isLb = false; // 是否连班
37 48 this._$_bx_isfb = false; // 是否分班
38 49 this._$_bx_isfb_5_2 = false; // 是否5休2分班
39 50 this._$_bx_desc; // 班型描述(默认为路牌编号)
40 51  
  52 + // 其他班次(进出场,例包,吃饭等),TODO:以后再拆
  53 + this._$_other_bc_array = [];
  54 +
41 55 // TODO:
42 56  
43 57 };
44 58  
45 59 //------------------- get/set 方法 -------------------//
46 60  
  61 +InternalLpObj.prototype.getOtherBcArray = function() {
  62 + return this._$_other_bc_array;
  63 +};
  64 +InternalLpObj.prototype.addOtherBcArray = function(ba) {
  65 + this._$_other_bc_array = this._$_other_bc_array.concat(ba);
  66 +};
  67 +
47 68 /**
48 69 * 获取圈
49 70 * @param qIndex 圈index
... ... @@ -161,6 +182,25 @@ InternalLpObj.prototype.getVerticalMinIntervalTime = function() {
161 182 return this._$_minVerticalIntervalTime;
162 183 };
163 184  
  185 +/**
  186 + * 设置纵向发车间隔。
  187 + * @param iQindex 圈index
  188 + * @param iBindex 班次index
  189 + * @param iTime 间隔时间
  190 + */
  191 +InternalLpObj.prototype.fnSetVerticalIntervalTime = function(iQindex, iBindex, iTime) {
  192 + this._$_aVerticalIntervalTime[iQindex][iBindex] = iTime;
  193 +};
  194 +
  195 +/**
  196 + * 返回纵向发车间隔。
  197 + * @param iQindex 圈index
  198 + * @param iBindex 班次index
  199 + */
  200 +InternalLpObj.prototype.fnGetVerticalIntervalTime = function(iQindex, iBindex) {
  201 + return this._$_aVerticalIntervalTime[iQindex][iBindex];
  202 +};
  203 +
164 204 //-------------------- 班次操作方法(查询,统计,删除) -----------------------//
165 205  
166 206 /**
... ... @@ -248,6 +288,149 @@ InternalLpObj.prototype.getMaxBcObjPosition = function() {
248 288 return bIndex;
249 289 };
250 290  
  291 +InternalLpObj.prototype.getMinBcObj = function() {
  292 + var i;
  293 + var bcObj;
  294 + for (i = 0; i < this._$_groupBcArray.length; i++) {
  295 + bcObj = this._$_groupBcArray[i].getBc1();
  296 + if (bcObj) {
  297 + break;
  298 + }
  299 + bcObj = this._$_groupBcArray[i].getBc2();
  300 + if (bcObj) {
  301 + break;
  302 + }
  303 + }
  304 + return bcObj;
  305 +};
  306 +InternalLpObj.prototype.getMaxBcObj = function() {
  307 + var i;
  308 + var bcObj;
  309 + for (i = this._$_groupBcArray.length - 1; i >= 0; i--) {
  310 + bcObj = this._$_groupBcArray[i].getBc2();
  311 + if (bcObj) {
  312 + break;
  313 + }
  314 + bcObj = this._$_groupBcArray[i].getBc1();
  315 + if (bcObj) {
  316 + break;
  317 + }
  318 + }
  319 + return bcObj;
  320 +};
  321 +
  322 +/**
  323 + * 获取车次链信息。
  324 + * @param num 第几个车次链
  325 + * @returns object {s_q: {开始圈索引},s_b : {开始班次索引},e_q : {结束圈索引},e_b : {结束班次索引}, bcount : {班次数}}
  326 + */
  327 +InternalLpObj.prototype.fnGetBcChainInfo = function(num) {
  328 + // 计算总的车次链信息
  329 + var aChainInfo = [];
  330 + var oChainInfo;
  331 + var aBcIndex = this.getMinBcObjPosition();
  332 + var oBc;
  333 + var iQIndex;
  334 + var iBcIndex;
  335 + var i;
  336 + var bFlag;
  337 +
  338 + var iBcount = 0;
  339 +
  340 + if (aBcIndex.length == 2) {
  341 + iBcount = 1;
  342 + oChainInfo = {s_q : aBcIndex[0], s_b : aBcIndex[1], e_q : aBcIndex[0], e_b : aBcIndex[1], bcount: 1};
  343 + aChainInfo.push(oChainInfo);
  344 + bFlag = true;
  345 +
  346 + // 下一个班次的索引
  347 + iQIndex = aBcIndex[1] == 0 ? aBcIndex[0] : aBcIndex[0] + 1;
  348 + iBcIndex = aBcIndex[1] == 0 ? 1 : 0;
  349 +
  350 + for (i = iQIndex; i < this._$_qCount; i++) {
  351 + while (iBcIndex <= 1) {
  352 + oBc = this.getBc(i, iBcIndex);
  353 + if (!oBc) {
  354 + if (bFlag) {
  355 + // 车次链结尾是这个班次的前一个班次
  356 + oChainInfo.e_q = iBcIndex == 0 ? i - 1 : i;
  357 + oChainInfo.e_b = iBcIndex == 0 ? 1 : 0;
  358 + oChainInfo.bcount = iBcount;
  359 + }
  360 +
  361 + bFlag = false;
  362 + } else {
  363 + if (bFlag) {
  364 + iBcount ++;
  365 + oChainInfo.bcount = iBcount;
  366 + } else {
  367 + // 下一个车次链开始
  368 + iBcount = 1;
  369 + oChainInfo = {s_q : i, s_b : iBcIndex, e_q : i, e_b : iBcIndex, bcount: 1};
  370 + aChainInfo.push(oChainInfo);
  371 + bFlag = true;
  372 + }
  373 + }
  374 +
  375 +
  376 + iBcIndex ++;
  377 + }
  378 + iBcIndex = 0;
  379 + }
  380 +
  381 + }
  382 +
  383 + return aChainInfo[num];
  384 +};
  385 +
  386 +/**
  387 + * 获取车次链的个数。
  388 + * @returns int
  389 + */
  390 +InternalLpObj.prototype.fnGetBcChainCount = function() {
  391 + var iChainCount = 0;
  392 + var aBcIndex = this.getMinBcObjPosition();
  393 +
  394 + var oBc;
  395 + var iQIndex;
  396 + var iBcIndex;
  397 + var i;
  398 + var bFlag;
  399 +
  400 + if (aBcIndex.length == 2) {
  401 + iChainCount = 1;
  402 + bFlag = true;
  403 +
  404 + // 下一个班次的索引
  405 + iQIndex = aBcIndex[1] == 0 ? aBcIndex[0] : aBcIndex[0] + 1;
  406 + iBcIndex = aBcIndex[1] == 0 ? 1 : 0;
  407 +
  408 + for (i = iQIndex; i < this._$_qCount; i++) {
  409 + while (iBcIndex <= 1) {
  410 + oBc = this.getBc(i, iBcIndex);
  411 + if (!oBc) {
  412 + bFlag = false;
  413 + } else {
  414 + if (bFlag) {
  415 +
  416 + } else {
  417 + iChainCount ++;
  418 + bFlag = true;
  419 + }
  420 + }
  421 +
  422 +
  423 + iBcIndex ++;
  424 + }
  425 + iBcIndex = 0;
  426 + }
  427 +
  428 + }
  429 +
  430 +
  431 + return iChainCount;
  432 +};
  433 +
251 434 /**
252 435 * 在具体位置移除班次。
253 436 * @param qIndex 第几圈
... ... @@ -266,12 +449,14 @@ InternalLpObj.prototype.removeBc = function(qIndex, bcIndex) {
266 449 * 使用指定时间匹配返回离之最近的第几圈第几个班次,
267 450 * 使用时间差的绝度值,比较,取最小的
268 451 * 如果有两个一样的时间差,取比fctime大的时间
269   - * @param fctime 比较用时间
  452 + * @param fctime moment 比较用时间
270 453 * @param groupArray 圈数组
  454 + * @param hasUp boolean 计算上行班次
  455 + * @param hasDown boolean 计算下行班次
271 456 * @returns [{第几圈},{第几个班次}]
272 457 */
273 458 InternalLpObj.prototype.getgetQBcIndexWithFcTimeFromGroupArray = function(
274   - fctime, groupArray
  459 + fctime, groupArray, hasUp, hasDown
275 460 ) {
276 461 var i;
277 462 var timediff; // 时间差取绝对值
... ... @@ -286,7 +471,7 @@ InternalLpObj.prototype.getgetQBcIndexWithFcTimeFromGroupArray = function(
286 471 for (i = 0; i < this._$_qCount; i++) {
287 472 group = groupArray[i];
288 473 if (group) {
289   - if (group.getBc1()) {
  474 + if (group.getBc1() && hasUp) {
290 475 bc1time = group.getBc1().getFcTimeObj();
291 476 tempdiff = Math.abs(bc1time.diff(fctime));
292 477  
... ... @@ -310,7 +495,7 @@ InternalLpObj.prototype.getgetQBcIndexWithFcTimeFromGroupArray = function(
310 495 }
311 496 }
312 497  
313   - if (group.getBc2()) {
  498 + if (group.getBc2() && hasDown) {
314 499 bc2time = group.getBc2().getFcTimeObj();
315 500 tempdiff = Math.abs(bc2time.diff(fctime));
316 501  
... ... @@ -347,13 +532,15 @@ InternalLpObj.prototype.getgetQBcIndexWithFcTimeFromGroupArray = function(
347 532 * 使用指定时间匹配返回离之最近的第几圈第几个班次,
348 533 * 使用时间差的绝度值,比较,取最小的
349 534 * 如果有两个一样的时间差,取比fctime大的时间
350   - * @param fctime 比较用时间
  535 + * @param fctime moment 比较用时间
  536 + * @param hasUp boolean 计算上行班次
  537 + * @param hasDown boolean 计算下行班次
351 538 * @returns [{第几圈},{第几个班次}]
352 539 */
353 540 InternalLpObj.prototype.getQBcIndexWithFcTime = function(
354   - fctime
  541 + fctime, hasUp, hasDown
355 542 ) {
356   - return this.getgetQBcIndexWithFcTimeFromGroupArray(fctime, this._$_groupBcArray);
  543 + return this.getgetQBcIndexWithFcTimeFromGroupArray(fctime, this._$_groupBcArray, hasUp, hasDown);
357 544 };
358 545  
359 546 //---------------------- 内部数据初始化方法(不同于构造函数)---------------------//
... ... @@ -393,6 +580,10 @@ InternalLpObj.prototype.initDataFromTimeToTime = function(
393 580 } while(kssj.isBefore(endTime));
394 581 bcCount--;
395 582  
  583 + //console.log("last -1;" + bcData[bcCount -2].getFcTimeObj().format("HH:mm"));
  584 + //console.log("last;" + bcData[bcCount -1].getFcTimeObj().format("HH:mm"));
  585 + //console.log("endtime: " + endTime.format("HH:mm"));
  586 +
396 587 if (bcCount > 0 && bcData[bcCount - 1].getArrTimeObj().isAfter(endTime)) {
397 588 // 如果最后一个班次的到达时间超过结束时间,也要去除
398 589 bcData.splice(bcCount - 1, 1);
... ... @@ -467,6 +658,9 @@ InternalLpObj.prototype._initDataFromLbBcArray = function(
467 658 );
468 659 _bc1Obj.setGroup(_qObj);
469 660 this._$_groupBcArray[fromQ] = _qObj;
  661 +
  662 + bcArray.splice(0, 1);
  663 + qCount2 --;
470 664 } else {
471 665 break;
472 666 }
... ... @@ -478,20 +672,102 @@ InternalLpObj.prototype._initDataFromLbBcArray = function(
478 672  
479 673 //-------------------------- 其他方法 ----------------------------//
480 674  
  675 +/**
  676 + * 从指定位置的班次开始,往后所有的班次修正发车时间
  677 + * @param groupIndex
  678 + * @param bcIndex
  679 + * @param time
  680 + */
  681 +InternalLpObj.prototype.fnAddMinuteToBcFcsj = function(groupIndex, bcIndex, time) {
  682 + var i;
  683 + var oCurBc;
  684 +
  685 + // 修正之前班次的停站时间
  686 + //oCurBc = this.getBc(
  687 + // bcIndex == 0 ? groupIndex - 1 : groupIndex,
  688 + // bcIndex == 1 ? 0 : 1
  689 + //);
  690 + //if (oCurBc) {
  691 + // oCurBc.setStopTime(oCurBc.getStopTime() + time);
  692 + //}
  693 +
  694 +
  695 + for (i = groupIndex; i < this._$_qCount; i++) {
  696 + if (bcIndex == 0) {
  697 + oCurBc = this.getBc(i, 0);
  698 + if (oCurBc) {
  699 + oCurBc.addMinuteToFcsj(time);
  700 + }
  701 + oCurBc = this.getBc(i, 1);
  702 + if (oCurBc) {
  703 + oCurBc.addMinuteToFcsj(time);
  704 + }
  705 +
  706 + } else {
  707 + oCurBc = this.getBc(i, 1);
  708 + if (oCurBc) {
  709 + oCurBc.addMinuteToFcsj(time);
  710 + }
481 711  
482   -// TODO
  712 + }
  713 +
  714 + bcIndex = 0;
  715 + }
  716 +};
483 717  
484 718 /**
485   - *
486   - *
  719 + * 在指定位置添加一个吃饭班次。
  720 + * 注1:吃饭班次不是普通班次,不记录进圈,记录进_$_other_bc_array
  721 + * 注2:添加吃饭班次时,会修改之前班次的停战时间,所以导致之后的班次的停战都会发生变化
  722 + * @param groupIndex
  723 + * @param bcIndex
  724 + * @param factory
  725 + * @param paramObj
  726 + * @returns int 相差时间(吃饭时间距离和停站时间相差值)
487 727 */
488   -InternalLpObj.prototype.calcuLpBx = function() {
  728 +InternalLpObj.prototype.fnAddEatBc = function(groupIndex, bcIndex, factory, paramObj) {
  729 + var oPreBc;
  730 + var oEatBc;
  731 + var iBcModifyTime;
  732 + oPreBc = this.getBc( // 前一个邻接班次
  733 + bcIndex == 0 ? groupIndex - 1 : groupIndex,
  734 + bcIndex == 1 ? 0 : 1);
  735 + if (oPreBc) { // 存在前一个班次
  736 + oEatBc = factory.createBcObj(
  737 + this,
  738 + "cf",
  739 + !oPreBc.isUp(), // 和上一个班次方向相反
  740 + 1,
  741 + oPreBc.getArrTimeObj(), // 使用上一个班次的到达时间作为开始时间
  742 + paramObj
  743 + );
  744 +
  745 + //iBcModifyTime = oEatBc.getBcTime() - oPreBc.getStopTime(); // 后续班次要调整的时间
  746 +
  747 + // 修正之后的班次发车时间
  748 + // 注意:之后那个班次发车时间就是吃饭班次的到达时间
  749 + iBcModifyTime = oEatBc.getArrTimeObj().diff(this.getBc(groupIndex, bcIndex).getFcTimeObj(), "m");
  750 + this.fnAddMinuteToBcFcsj(groupIndex, bcIndex, iBcModifyTime);
  751 +
  752 + oPreBc.setStopTime(0);
  753 + this._$_other_bc_array.push(oEatBc);
  754 +
  755 + return iBcModifyTime;
  756 + } else {
  757 + return false;
  758 + }
489 759  
490 760 };
491 761  
492 762  
  763 +// TODO
493 764  
  765 +/**
  766 + *
  767 + *
  768 + */
  769 +InternalLpObj.prototype.calcuLpBx = function() {
494 770  
495   -
  771 +};
496 772  
497 773  
... ...
src/main/resources/static/pages/base/timesmodel/js/v2/core/InternalScheduleObj.js
... ... @@ -14,8 +14,19 @@ var InternalScheduleObj = function(paramObj, lpArray, factory) {
14 14 var _qIsUp; // 每一圈是上行开始还是下行开始
15 15 var _qCount = 0; // 总的圈数
16 16 var _internalLpArray = []; // 内部对象数组
17   -
18   - var _initFun1 = function() { // 初始化方法1
  17 + var _aBxDesc = [ // 各种班型描述(班型名称,平均工时,平均需要的班次数,平均工时)
  18 + {'sType':'六工一休', 'fHoursV':6.66, 'fBcCount': 0, 'fAverTime': 0},
  19 + {'sType':'五工一休', 'fHoursV':6.85, 'fBcCount': 0, 'fAverTime': 0},
  20 + {'sType':'四工一休', 'fHoursV':7.14, 'fBcCount': 0, 'fAverTime': 0},
  21 + {'sType':'三工一休', 'fHoursV':7.61, 'fBcCount': 0, 'fAverTime': 0},
  22 + {'sType':'二工一休', 'fHoursV':8.57, 'fBcCount': 0, 'fAverTime': 0},
  23 + {'sType':'一工一休', 'fHoursV':11.42, 'fBcCount': 0, 'fAverTime': 0},
  24 + {'sType':'五工二休', 'fHoursV':7.99, 'fBcCount': 0, 'fAverTime': 0},
  25 + {'sType':'无工休', 'fHoursV':5.43, 'fBcCount': 0, 'fAverTime': 0}
  26 + ];
  27 +
  28 + var _fnInitFun1 = function() { // 初始化方法1
  29 + console.log("//---------------- 行车计划,初始化方法1 start ----------------//");
19 30  
20 31 //----------------------- 1、确定上标线的方向,圈的方向 -------------------//
21 32  
... ... @@ -38,8 +49,6 @@ var InternalScheduleObj = function(paramObj, lpArray, factory) {
38 49  
39 50 //------------------------ 2、计算总共有多少圈 ------------------------//
40 51  
41   -
42   -
43 52 // 以开始时间,结束时间,构造上标线用连班班次发车时间
44 53 var bcFcsjArrays = []; // 班次发车时间对象数组
45 54 var bcArsjArrays = []; // 班次到达时间对象数组
... ... @@ -49,12 +58,17 @@ var InternalScheduleObj = function(paramObj, lpArray, factory) {
49 58 var _kssj = st; // 开始时间
50 59 var _bcsj = paramObj.calcuTravelTime(_kssj, isUp); // 班次历时
51 60 var _arrsj = paramObj.addMinute(_kssj, _bcsj); // 到达时间
52   - var _stoptime = paramObj.calcuFixedStopNumber(_arrsj, !isUp); // 停站时间
  61 + var _stoptime = paramObj.fnCalcuFixedStopNumber(_arrsj, !isUp, _bcsj); // 停站时间
53 62  
54 63 do {
55 64 bcFcsjArrays.push(_kssj);
56 65 bcArsjArrays.push(_arrsj);
  66 +
57 67 _kssj = paramObj.addMinute(_kssj, _bcsj + _stoptime);
  68 + _bcsj = paramObj.calcuTravelTime(_kssj, isUp);
  69 + _arrsj = paramObj.addMinute(_kssj, _bcsj);
  70 + _stoptime = paramObj.fnCalcuFixedStopNumber(_arrsj, !isUp, _bcsj);
  71 +
58 72 bcCount ++;
59 73 isUp = !isUp;
60 74 } while(_kssj.isBefore(et));
... ... @@ -100,13 +114,105 @@ var InternalScheduleObj = function(paramObj, lpArray, factory) {
100 114 // 初始化上标线,从第1圈开始
101 115 _internalLpArray[0].initDataFromTimeToTime(bcFcsjArrays[0], et, _qIsUp, 1, _paramObj, _factory);
102 116  
103   - console.log("//---------------- 行车计划,初始化方法1 start ----------------//");
  117 + // 以上标线为基础,计算各种班型工时对应的圈数、班次数
  118 + var aBcArray = _internalLpArray[0].getBcArray();
  119 + if (aBcArray.length % 2 != 0) { // 不能整除2,去除一个班次计算
  120 + aBcArray.splice(aBcArray.length - 1, 1);
  121 + }
  122 + var sum = 0;
  123 + // 加吃饭时间
  124 + sum += _paramObj.fnGetLunchTime();
  125 + sum += _paramObj.fnGetDinnerTime();
  126 + // 加进出场时间
  127 + sum += _qIsUp ? _paramObj.getUpOutTime() : _paramObj.getDownOutTime();
  128 + sum += _qIsUp ? _paramObj.getDownInTime() : _paramObj.getUpInTime();
  129 + // 例保时间
  130 + //sum += _paramObj.getLbTime() * 2;
  131 + for (i = 0; i < aBcArray.length; i++) {
  132 + sum += aBcArray[i].getBcTime() + aBcArray[i].getStopTime();
  133 + }
  134 + for (i = 0; i < _aBxDesc.length; i++) {
  135 + _aBxDesc[i].fAverTime = sum / (aBcArray.length / 2);
  136 + _aBxDesc[i].fBcCount = ((_aBxDesc[i].fHoursV * 60) / _aBxDesc[i].fAverTime) * 2;
  137 + }
  138 +
  139 + // 在第一个班次之前再添加一个模拟班次,用于中标线的作用
  140 + // 那一圈必定是低谷,而且圈索引0,班次索引1,暂时标记,最后删除
  141 + var iFirstStopTime =
  142 + _paramObj.fnCalcuFixedStopNumber(
  143 + _paramObj.addMinute(aBcArray[0].getFcTimeObj(), -10),
  144 + _qIsUp
  145 + );
  146 + var iXXTime = _qIsUp ? _paramObj.getDownTroughTime() : _paramObj.getUpTroughTime();
  147 + var oFlagBc = _factory.createBcObj( // 标记班次
  148 + _internalLpArray[0],
  149 + "normal",
  150 + !_qIsUp,
  151 + 1,
  152 + _paramObj.addMinute(aBcArray[0].getFcTimeObj(), -(iFirstStopTime + iXXTime)),
  153 + _paramObj
  154 + );
  155 + oFlagBc.fnSetDelFlag(true); // 标记了删除记号
  156 +
  157 + _internalLpArray[0].setBc(0, 1, oFlagBc);
  158 +
  159 + // 在最后一圈也补上一个或者2个模拟班次,暂时标记,最后需要删除
  160 + var aMaxBcIndex = _internalLpArray[0].getMaxBcObjPosition();
  161 + if (aMaxBcIndex[0] == _qCount - 1) { // 可能加半圈
  162 + oFlagBc = _factory.createBcObj( // 标记班次
  163 + _internalLpArray[0],
  164 + "normal",
  165 + !_qIsUp,
  166 + 1,
  167 + _paramObj.addMinute(
  168 + _internalLpArray[0].getBc(_qCount - 1, 0).getArrTimeObj(),
  169 + _internalLpArray[0].getBc(_qCount - 1, 0).getStopTime()),
  170 + _paramObj
  171 + );
  172 + oFlagBc.fnSetDelFlag(true); // 标记了删除记号
  173 + _internalLpArray[0].setBc(_qCount - 1, 1, oFlagBc);
  174 +
  175 + } else { // 加完整的一圈
  176 + oFlagBc = _factory.createBcObj( // 标记班次
  177 + _internalLpArray[0],
  178 + "normal",
  179 + _qIsUp,
  180 + 1,
  181 + _paramObj.addMinute(
  182 + _internalLpArray[0].getBc(_qCount - 2, 1).getArrTimeObj(),
  183 + _internalLpArray[0].getBc(_qCount - 2, 1).getStopTime()),
  184 + _paramObj
  185 + );
  186 + oFlagBc.fnSetDelFlag(true); // 标记了删除记号
  187 + _internalLpArray[0].setBc(_qCount - 1, 0, oFlagBc);
  188 +
  189 + oFlagBc = _factory.createBcObj( // 标记班次
  190 + _internalLpArray[0],
  191 + "normal",
  192 + !_qIsUp,
  193 + 1,
  194 + _paramObj.addMinute(
  195 + _internalLpArray[0].getBc(_qCount - 1, 0).getArrTimeObj(),
  196 + _internalLpArray[0].getBc(_qCount - 1, 0).getStopTime()),
  197 + _paramObj
  198 + );
  199 + oFlagBc.fnSetDelFlag(true); // 标记了删除记号
  200 + _internalLpArray[0].setBc(_qCount - 1, 1, oFlagBc);
  201 +
  202 + }
  203 +
104 204 console.log("上行首班车时间:" + _paramObj.getUpFirstDTimeObj().format("HH:mm") +
105 205 "上行末班车时间:" + _paramObj.getUpLastDtimeObj().format("HH:mm"));
106 206 console.log("下行首班车时间:" + _paramObj.getDownFirstDTimeObj().format("HH:mm") +
107 207 "下行末班车时间:" + _paramObj.getDownLastDTimeObj().format("HH:mm"));
108 208 console.log("总共计算的圈数:" + _qCount);
109 209 console.log("圈的方向isUP:" + _qIsUp);
  210 + console.log("班型描述(以下):");
  211 + console.log(_aBxDesc);
  212 + console.log("所有路牌间隔描述(以下):");
  213 + for (i = 0; i < _internalLpArray.length; i++) {
  214 + console.log(_internalLpArray[i]._$_aVerticalIntervalTime);
  215 + }
110 216 console.log("//---------------- 行车计划,初始化方法1 end ----------------//");
111 217  
112 218 };
... ... @@ -117,131 +223,237 @@ var InternalScheduleObj = function(paramObj, lpArray, factory) {
117 223 var _approximate_wgfQIndex; // 预估晚高峰车辆从第几圈开始全部发出
118 224 var _approximate_wgfBIndex; // 预估晚高峰车辆从第几圈第几个班次开始全部发出(上行或下行)
119 225  
120   - // 同一圈同一方向班次发车间隔的最小值
121   - // 注意:这个值就是用来添加班次的时间增加单位,在后面相关的方法里会具体说明
122   - var _qbcMinIntervalValue;
  226 + var _fnInitFun2 = function() { // 初始化方法2
  227 + console.log("//---------------- 行车计划,初始化方法2 start ----------------//");
  228 +
  229 + //------------------------ 1、计算车辆总数 ------------------------//
  230 + // 是用高峰上行周转时间除以高峰平均间隔得到的
  231 + // 这样算还算合理,车辆不多不少,待以后有新的算法再修正
  232 + var iClCount = _paramObj.calcuClzx();
  233 +
  234 + //------------------------ 2、计算所有路牌的发车在各个圈中的间隔 --------------------//
  235 + var i;
  236 + var j;
  237 + var iBindex = 1;
  238 + var iZzsj;
  239 + var oLp;
  240 + var iC1;
  241 + var iC2;
  242 +
  243 + for (i = 0; i < _qCount - 1; i++) {
  244 + while (iBindex <= 1) {
  245 + // 每圈每个方向的周转时间不一致,以上标线为主
  246 + oLp = _internalLpArray[0];
  247 + iZzsj = oLp.getBc(i + 1, iBindex).getFcTimeObj().diff(
  248 + oLp.getBc(i, iBindex).getFcTimeObj(), "m"
  249 + );
  250 +
  251 + iC1 = Math.floor(iZzsj / iClCount);
  252 + iC2 = iZzsj % iClCount;
  253 +
  254 + for (j = 0; j < iClCount - iC2; j++) {
  255 + oLp = _internalLpArray[j];
  256 + oLp.fnSetVerticalIntervalTime(i, iBindex, iC1);
  257 + }
123 258  
124   - var _initFun2 = function() { // 初始化方法2
125   - //------------------------ 1、预估早高峰全部出车第几圈第几个班次全部出车,计算路牌之间的发车间隔 ------------------//
  259 + for (j = 0; j < iC2; j++) {
  260 + oLp = _internalLpArray[iClCount - iC2 + j];
  261 + oLp.fnSetVerticalIntervalTime(i, iBindex, iC1 + 1);
  262 + }
  263 +
  264 + iBindex ++;
  265 +
  266 + }
  267 + iBindex = 0;
  268 + }
  269 + // 最后一圈没有下一圈的参照,周转时间没发获取,由于都是低谷,所以使用倒数第二圈的间隔最为最后一圈的间隔
  270 + for (i = 0; i < _internalLpArray.length; i++) {
  271 + oLp = _internalLpArray[i];
  272 + oLp.fnSetVerticalIntervalTime(_qCount - 1, 0, oLp.fnGetVerticalIntervalTime(_qCount - 2, 0));
  273 + oLp.fnSetVerticalIntervalTime(_qCount - 1, 1, oLp.fnGetVerticalIntervalTime(_qCount - 2, 1));
  274 + }
  275 +
  276 + //------------------------ 3、预估早高峰全部出车第几圈第几个班次全部出车,计算路牌之间的发车间隔 ------------------//
126 277  
127 278 // 以上标线为标准,查找离早高峰开始时间最近的班次作为早高峰开始班次
128 279 // 以这个班次为早高峰起点,全部出车策略
129 280 var qbcIndexArray = _internalLpArray[0].getQBcIndexWithFcTime(
130   - _paramObj.getMPeakStartTimeObj());
  281 + _paramObj.getMPeakStartTimeObj(), true, true);
131 282 var qIndex = qbcIndexArray[0]; // 第几圈
132 283 var bIndex = qbcIndexArray[1]; // 第几个班次
133   - var startbc = _internalLpArray[0].getBc(qIndex, bIndex);
134   -
135   - // 计算早高峰
136   - var _clCount = _paramObj.calcuClzx();
137   - var _c1 = Math.floor(_paramObj.calcuPeakZzsj() / _clCount);
138   - var _c2 = _paramObj.calcuPeakZzsj() % _clCount;
139   - var _kssj = startbc.getFcTimeObj();
140 284  
141   - var i;
142   - for (i = 2; i <= _clCount - _c2; i++) {
143   - _kssj = _paramObj.addMinute(_kssj, _c1);
144   - _internalLpArray[i - 1].setBc(
145   - qIndex,
146   - bIndex,
147   - _factory.createBcObj(
148   - _internalLpArray[i - 1],
149   - "normal", startbc.isUp(),
150   - 1, _kssj, paramObj)
151   - );
152   - // 使用早高峰的发车间隔最为路牌纵向最小发车间隔,不能整除的话,小的放在前面的路牌
153   - _internalLpArray[i - 1].setVerticalMinIntervalTime(_c1);
154   - }
155   - for (i = 1; i <= _c2; i++) {
156   - _kssj = _paramObj.addMinute(_kssj, _c1 + 1);
157   - _internalLpArray[_clCount - _c2 + i - 1].setBc(
158   - qIndex,
159   - bIndex,
160   - _factory.createBcObj(
161   - _internalLpArray[_clCount - _c2 + i - 1],
162   - "normal", startbc.isUp(),
163   - 1, _kssj, paramObj)
164   - );
165   - // 使用早高峰的发车间隔最为路牌纵向最小发车间隔,,不能整除的话,大的放在后面的路牌
166   - _internalLpArray[_clCount - _c2 + i - 1].setVerticalMinIntervalTime(_c1);
  285 + for (i = 1; i < _internalLpArray.length; i++) {
  286 + _fnGenerateBcAndSetBc(i, qIndex, bIndex);
167 287 }
168 288  
169 289 _approximate_zgfQIndex = qIndex;
170 290 _approximate_zgfBIndex = bIndex;
171 291  
172   - //------------------------ 2、预估晚高峰全部出车第几圈第几个班次全部出车,计算路牌之间的发车间隔 ------------------//
  292 + //------------------------ 4、预估晚高峰全部出车第几圈第几个班次全部出车,计算路牌之间的发车间隔 ------------------//
173 293  
174 294 // 以上标线为标准,查找离晚高峰开始时间最近的班次作为晚高峰开始班次
175 295 // 以这个班次为早高峰起点,全部出车策略
176 296 qbcIndexArray = _internalLpArray[0].getQBcIndexWithFcTime(
177   - _paramObj.getEPeakStartTimeObj());
  297 + _paramObj.getEPeakStartTimeObj(), true, true);
178 298 qIndex = qbcIndexArray[0]; // 第几圈
179 299 bIndex = qbcIndexArray[1]; // 第几个班次
180   - startbc = _internalLpArray[0].getBc(qIndex, bIndex);
181   -
182   - // 计算晚高峰
183   - _clCount = _paramObj.calcuClzx();
184   - _c1 = Math.floor(_paramObj.calcuPeakZzsj() / _clCount);
185   - _c2 = _paramObj.calcuPeakZzsj() % _clCount;
186   - _kssj = startbc.getFcTimeObj();
187   -
188   - for (i = 2; i <= _clCount - _c2; i++) {
189   - _kssj = _paramObj.addMinute(_kssj, _c1);
190   - _internalLpArray[i - 1].setBc(
191   - qIndex,
192   - bIndex,
193   - _factory.createBcObj(
194   - _internalLpArray[i - 1],
195   - "normal", startbc.isUp(),
196   - 1, _kssj, _paramObj)
197   - );
198   - }
199   - for (i = 1; i <= _c2; i++) {
200   - _kssj = _paramObj.addMinute(_kssj, _c1 + 1);
201   - _internalLpArray[_clCount - _c2 + i - 1].setBc(
202   - qIndex,
203   - bIndex,
204   - _factory.createBcObj(
205   - _internalLpArray[_clCount - _c2 + i - 1],
206   - "normal", startbc.isUp(),
207   - 1, _kssj, _paramObj)
208   - );
  300 +
  301 + for (i = 1; i < _internalLpArray.length; i++) {
  302 + _fnGenerateBcAndSetBc(i, qIndex, bIndex);
209 303 }
210 304  
211 305 _approximate_wgfQIndex = qIndex;
212 306 _approximate_wgfBIndex = bIndex;
213   - _qbcMinIntervalValue = _c1;
214 307  
215   - console.log("//---------------- 行车计划,初始化方法2 start ----------------//");
  308 + console.log("早高峰周转时间(固定最大停战时间):" + _paramObj.calcuPeakZzsj() + "分钟");
  309 + console.log("早高峰发车时间范围:" + _paramObj.getMPeakMinFcjx() + "分钟 --- " + _paramObj.getMPeakMaxFcjx() + "分钟");
216 310 console.log("预估早高峰第" + _approximate_zgfQIndex + "(index)圈,第" + _approximate_zgfBIndex + "(index)班次车辆全部发出");
217 311 console.log("预估晚高峰第" + _approximate_wgfQIndex + "(index)圈,第" + _approximate_wgfBIndex + "(index)班次车辆全部发出");
218   - console.log("预估同圈同方向班次最小间隔(分钟):" + _qbcMinIntervalValue);
219 312 console.log("//---------------- 行车计划,初始化方法2 end ----------------//");
220 313 };
221 314  
222   - //----------------------- 初始化方法3,以及计算关联的内部变量 ----------------//
223   - var _zbx_lpIndex; // 中标线对应第几个路牌
  315 + //----------------------- 初始化方法3,计算连班分班的路牌分布 ----------------//
  316 + var _iBx_lb_lpcount; // 连班路牌数
  317 + var _iBx_5_2_fb_lpcount; // 5休2分班路牌数
  318 + var _iBx_other_fb_lpcount; // 其他分班路牌数
224 319  
225   - var _initFun3 = function() { // 初始化方法3
226   - //---------------------------- 1、模拟一个中标线,使用临时路牌 ----------------------//
  320 + var _fnInitFun3 = function() { // 初始化方法3
  321 + console.log("//---------------- 行车计划,初始化方法3 start ----------------//");
  322 +
  323 + //--------------------- 1、计算分班连班班型车辆分布数 --------------------//
  324 + // 总共车辆数(高峰最大车辆数)
  325 + var iCls = _paramObj.calcuClzx();
  326 + // 低谷最少配车(连班车数量)
  327 + var iDgminpc = Math.round(_paramObj.calcuTroughZzsj() / _paramObj.getTroughMaxFcjx());
  328 + // 加班车路牌数(做5休2的路牌数)
  329 + var i_5_2_lpes = _paramObj.getJBLpes();
  330 +
  331 + // 做些简单的验证
  332 + if (iCls < iDgminpc) {
  333 + alert("总配车数小于低谷最小配车");
  334 + throw "总配车数小于低谷最小配车";
  335 + }
  336 + if (iDgminpc < 2) {
  337 + alert("连班路牌小于2,办不到啊");
  338 + throw "连班路牌小于2,办不到啊";
  339 + }
  340 + if (iCls - iDgminpc < i_5_2_lpes) {
  341 + alert("总分班路牌数小于加班路牌数");
  342 + throw "总分班路牌数小于加班路牌数";
  343 + }
  344 +
  345 + _iBx_lb_lpcount = iDgminpc;
  346 + _iBx_5_2_fb_lpcount = i_5_2_lpes;
  347 + _iBx_other_fb_lpcount = iCls - iDgminpc - i_5_2_lpes;
  348 +
  349 + //------------------------ 2、利用间隔法计算连班路牌分布 --------------------//
  350 + var i;
  351 + var j;
  352 + var iC1 = Math.floor(_internalLpArray.length / _iBx_lb_lpcount);
  353 + var iC2 = _internalLpArray.length % _iBx_lb_lpcount;
  354 + var iLpIndex;
  355 +
  356 + for (i = 0; i < _iBx_lb_lpcount - iC2; i++) {
  357 + iLpIndex = i * iC1;
  358 + _internalLpArray[iLpIndex].setBxLb(true);
  359 + _internalLpArray[iLpIndex].setBxDesc("连班");
  360 + }
  361 + for (j = 0; j < iC2; j++) {
  362 + iLpIndex = i * iC1 + j * (iC1 + 1);
  363 + _internalLpArray[iLpIndex].setBxLb(true);
  364 + _internalLpArray[iLpIndex].setBxDesc("连班");
  365 + }
  366 +
  367 + //------------------------ 3、利用间隔法计算分班班型路牌分布 --------------------//
  368 + // 获取分班路牌索引
  369 + var aNotLbIndexes = [];
  370 + for (i = 0; i < _internalLpArray.length; i++) {
  371 + if (!_internalLpArray[i].isBxLb()) {
  372 + aNotLbIndexes.push(i);
  373 + }
  374 + }
  375 + // 先5休2分班
  376 + iC1 = Math.floor(aNotLbIndexes.length / _iBx_5_2_fb_lpcount);
  377 + iC2 = aNotLbIndexes.length % _iBx_5_2_fb_lpcount;
  378 +
  379 + for (i = 0; i < _iBx_5_2_fb_lpcount - iC2; i++) {
  380 + iLpIndex = aNotLbIndexes[i * iC1];
  381 + _internalLpArray[iLpIndex].setBxLb(false);
  382 + _internalLpArray[iLpIndex].setBxFb(true);
  383 + _internalLpArray[iLpIndex].setBxFb5_2(true);
  384 + _internalLpArray[iLpIndex].setBxDesc("5休2分班");
  385 + }
  386 + for (i = 0; i < iC2; i++) {
  387 + iLpIndex = aNotLbIndexes[_iBx_lb_lpcount - iC2 + i * (iC1 + 1)];
  388 + _internalLpArray[iLpIndex].setBxLb(false);
  389 + _internalLpArray[iLpIndex].setBxFb(true);
  390 + _internalLpArray[iLpIndex].setBxFb5_2(true);
  391 + _internalLpArray[iLpIndex].setBxDesc("5休2分班");
  392 + }
  393 + // 其他分班
  394 + for (i = 0; i < aNotLbIndexes.length; i++) {
  395 + iLpIndex = aNotLbIndexes[i];
  396 + if (!_internalLpArray[iLpIndex].isBxFb5_2()) {
  397 + _internalLpArray[iLpIndex].setBxLb(false);
  398 + _internalLpArray[iLpIndex].setBxFb(true);
  399 + _internalLpArray[iLpIndex].setBxFb5_2(false);
  400 + _internalLpArray[iLpIndex].setBxDesc("其他分班");
  401 + }
  402 + }
  403 +
  404 +
  405 + console.log("连班路牌数:" + _iBx_lb_lpcount);
  406 + console.log("5休2分班路牌数:" + _iBx_5_2_fb_lpcount);
  407 + console.log("其他分班路牌数:" + _iBx_other_fb_lpcount);
  408 + var aLbIndexes = [];
  409 + for (i = 0; i < _internalLpArray.length; i++) {
  410 + if (_internalLpArray[i].isBxLb()) {
  411 + aLbIndexes.push(i);
  412 + }
  413 + }
  414 + console.log("连班路牌indexes=" + aLbIndexes);
  415 + var a_5_2_fbIndexes = [];
  416 + for (i = 0; i < _internalLpArray.length; i++) {
  417 + if (_internalLpArray[i].isBxFb() && _internalLpArray[i].isBxFb5_2()) {
  418 + a_5_2_fbIndexes.push(i);
  419 + }
  420 + }
  421 + console.log("5休2分班路牌indexes=" + a_5_2_fbIndexes);
  422 + var a_other_fbIndexes = [];
  423 + for (i = 0; i < _internalLpArray.length; i++) {
  424 + if (_internalLpArray[i].isBxFb() && !_internalLpArray[i].isBxFb5_2()) {
  425 + a_other_fbIndexes.push(i);
  426 + }
  427 + }
  428 + console.log("其他分班路牌indexes=" + a_other_fbIndexes);
227 429  
  430 + console.log("//---------------- 行车计划,初始化方法3 end ----------------//");
  431 + };
  432 +
  433 + //----------------------- 初始化方法4,计算中标线位置 -------------------------//
  434 + var _iZbx_lpIndex; // 中标线对应第几个路牌
  435 +
  436 + var _fnInitFun4 = function() { // 初始化方法4
  437 + console.log("//---------------- 行车计划,初始化方法3 start ----------------//");
  438 +
  439 + //---------------------------- 1、模拟一个中标线,使用临时路牌 ----------------------//
228 440 // 构造中标线
229 441 // 中标线开始时间,就是方向的首班车时间
230   - var st = !_qIsUp ? _paramObj.getUpFirstDTimeObj() : _paramObj.getDownFirstDTimeObj();
  442 + var oSt = !_qIsUp ? _paramObj.getUpFirstDTimeObj() : _paramObj.getDownFirstDTimeObj();
231 443 // 上标线结束时间,使用最晚的末班车时间,结束时间的班次方向
232 444 // 上标线结束时间,使用最晚的末班车时间,结束时间的班次方向
233   - var et;
  445 + var oEt;
234 446 if (_paramObj.getUpLastDtimeObj().isBefore(
235 447 _paramObj.getDownLastDTimeObj())) {
236   - et = _paramObj.getDownLastDTimeObj();
  448 + oEt = _paramObj.getDownLastDTimeObj();
237 449 } else {
238   - et = _paramObj.getUpLastDtimeObj();
  450 + oEt = _paramObj.getUpLastDtimeObj();
239 451 }
240 452  
241   - var tempLpObj = new InternalLpObj({lpNo: -999, lpName: "-999"}, _qCount, _qIsUp);
242   - tempLpObj.initDataFromTimeToTime(
243   - st,
244   - et,
  453 + var oTempLp = new InternalLpObj({lpNo: -999, lpName: "-999"}, _qCount, _qIsUp);
  454 + oTempLp.initDataFromTimeToTime(
  455 + oSt,
  456 + oEt,
245 457 !_qIsUp,
246 458 0,
247 459 _paramObj,
... ... @@ -249,88 +461,125 @@ var InternalScheduleObj = function(paramObj, lpArray, factory) {
249 461 );
250 462  
251 463 //------------------------ 2、找出中标线的早高峰班次,计算应该插在当前路牌数组的那个位置 ----------------//
252   - // TODO:中标线的早高峰发车班次,和插入位置的早高分班次的时间会有误差的
253   - // TODO:这里是直接把中标线班次覆盖,没有根据误差调整,以后改
254   -
255 464 // 找出中标线对应的早高峰的班次对象
256   - var _zb_bcobj = tempLpObj.getBc(_approximate_zgfQIndex, _approximate_zgfBIndex);
  465 + var oZb_gf_bc = oTempLp.getBc(_approximate_zgfQIndex, _approximate_zgfBIndex);
257 466  
258   - // 把所有高峰班次重新构造成一个一个的圈数组,计算对应中标线最近的是第几个路牌
259   - var _tempq_array = [];
260   - var _temp_group;
261   - var _temp_bc;
  467 + // 把所有连班路牌高峰班次重新构造成一个一个的圈数组,计算对应中标线最近的是第几个路牌
  468 + // 中标线和上标线一样在连班路牌上
  469 + var aTempq = [];
  470 + var oTempq;
  471 + var oTempb;
262 472 var i;
  473 + var oLp;
  474 +
  475 + var aLbIndexes = []; // 连班的路牌索引
263 476 for (i = 0; i < _internalLpArray.length; i++) {
264   - _temp_bc = _internalLpArray[i].getBc(_approximate_zgfQIndex, _approximate_zgfBIndex);
265   - if (_temp_bc.isUp() == _qIsUp) {
266   - _temp_group = new InternalGroupObj(_internalLpArray[i], _qIsUp, _temp_bc, undefined);
  477 + if (_internalLpArray[i].isBxLb()) {
  478 + aLbIndexes.push(i);
  479 + }
  480 + }
  481 +
  482 + for (i = 0; i < aLbIndexes.length; i++) {
  483 + oLp = _internalLpArray[aLbIndexes[i]];
  484 +
  485 + oTempb = oLp.getBc(_approximate_zgfQIndex, _approximate_zgfBIndex);
  486 + if (oTempb.isUp() == _qIsUp) {
  487 + oTempq = new InternalGroupObj(oLp, _qIsUp, oTempb, undefined);
267 488 } else {
268   - _temp_group = new InternalGroupObj(_internalLpArray[i], _qIsUp, undefined, _temp_bc);
  489 + oTempq = new InternalGroupObj(oLp, _qIsUp, undefined, oTempb);
269 490 }
270   - _tempq_array.push(_temp_group);
  491 + aTempq.push(oTempq);
  492 +
271 493 }
272 494  
273   - var _ttindex_ = tempLpObj.getgetQBcIndexWithFcTimeFromGroupArray(
274   - _zb_bcobj.getFcTimeObj(),
275   - _tempq_array
276   - );
277   - _zbx_lpIndex = _ttindex_[0]; // 中标线放在第几个路牌
278   - tempLpObj.setLp(_lpArray[_zbx_lpIndex]); // 设置原始路牌对象
279   - tempLpObj.setVerticalMinIntervalTime( // 设置纵向最小发车间隔
280   - _internalLpArray[_zbx_lpIndex].getVerticalMinIntervalTime()
  495 + var aTtindex = oTempLp.getgetQBcIndexWithFcTimeFromGroupArray(
  496 + oZb_gf_bc.getFcTimeObj(),
  497 + aTempq,
  498 + true,
  499 + true
281 500 );
282 501  
283   - // 注意:这里直接把中标线数据替换到指定路牌位置
284   - // TODO:由初始化方法1,初始化方法2得到的2个高峰的班次会被中标线对应班次覆盖
285   - // TODO:目前使用中标线的班次覆盖,以后相互动态调整
  502 + _iZbx_lpIndex = aLbIndexes[aTtindex[0]]; // 中标线放在第几个路牌
  503 + oTempLp.setLp(_lpArray[_iZbx_lpIndex]); // 设置原始路牌对象
  504 + oTempLp._$_aVerticalIntervalTime = _internalLpArray[_iZbx_lpIndex]._$_aVerticalIntervalTime; // 设置纵向最小发车间隔
  505 + oTempLp.setBxLb(_internalLpArray[_iZbx_lpIndex].isBxLb());
  506 + oTempLp.setBxFb(_internalLpArray[_iZbx_lpIndex].isBxFb());
  507 + oTempLp.setBxFb5_2(_internalLpArray[_iZbx_lpIndex].isBxFb5_2());
  508 +
  509 + // 修正除了第一个班次外,其余其他班次
  510 + var iBcindex = 0;
  511 + for (i = 1; i < _qCount; i++) {
  512 + while (iBcindex <= 1) {
  513 + if (oTempLp.getBc(i, iBcindex)) { // 替换存在的班次
  514 + oTempLp.setBc(i, iBcindex, _fnGenerateBc(_iZbx_lpIndex, i, iBcindex));
  515 + }
  516 + iBcindex ++;
  517 + }
  518 + iBcindex = 0;
  519 + }
286 520  
287   - _internalLpArray[_zbx_lpIndex] = tempLpObj;
  521 + _internalLpArray[_iZbx_lpIndex] = oTempLp;
288 522  
289   - console.log("//---------------- 行车计划,初始化方法3 start ----------------//");
290   - console.log("中标线对应第" + (_zbx_lpIndex + 1) + "个路牌");
291   - console.log("//---------------- 行车计划,初始化方法3 end ----------------//");
  523 + console.log("中标线对应第" + (_iZbx_lpIndex + 1) + "个路牌");
292 524  
  525 + console.log("//---------------- 行车计划,初始化方法4 end ----------------//");
293 526 };
294 527  
295   - //----------------------- 初始化方法4,以及计算关联的内部变量 ----------------//
296   - var _bx_lb_lpcount; // 连班路牌数
297   - var _bx_5_2_fb_lpcount; // 5休2分班路牌数
298   - var _bx_other_fb_lpcount; // 其他分班路牌数
299   -
300   - var _initFun4 = function() { // 初始化方法4
301   - // 总共车辆数(高峰最大车辆数)
302   - var cls = _paramObj.calcuClzx();
303   - // 低谷最少配车(连班车数量)
304   - var dgminpc = Math.round(_paramObj.calcuTroughZzsj() / _paramObj.getTroughMaxFcjx());
305   - // 加班车路牌数(做5休2的路牌数)
306   - var _5_2_lpes = _paramObj.getJBLpes();
  528 + //-------------------- 重要的内部方法 -----------------------//
  529 + /**
  530 + * 核心方法,利用路牌间隔纵向生成班次。
  531 + * @param iLpindex 路牌索引
  532 + * @param iQindex 圈索引
  533 + * @param iBcindex 班次索引
  534 + * @returns object InternalBcObj,失败 false
  535 + */
  536 + var _fnGenerateBc = function(iLpindex, iQindex, iBcindex) {
  537 + // 以上标线为起始点,使用路牌在不同圈,班次索引的发车间隔,计算班次
  538 + // 注意,发车间隔是指下一个班次应该距离当前班次间隔,是从下往上的
307 539  
308   - // 做些简单的验证
309   - if (cls < dgminpc) {
310   - alert("总配车数小于低谷最小配车");
311   - throw "总配车数小于低谷最小配车";
  540 + // 1、参数验证
  541 + if (iLpindex == 0) { // 上标线的班次不需要生成
  542 + return false;
312 543 }
313   - if (dgminpc < 2) {
314   - alert("连班路牌小于2,办不到啊");
315   - throw "连班路牌小于2,办不到啊";
  544 +
  545 + // 2、计算间隔
  546 + var i;
  547 + var oLp;
  548 + var iTime = 0;
  549 + for (i = 0; i < iLpindex; i++) {
  550 + oLp = _internalLpArray[i];
  551 + iTime += oLp.fnGetVerticalIntervalTime(iQindex, iBcindex);
316 552 }
317   - if (cls - dgminpc < _5_2_lpes) {
318   - alert("总分班路牌数小于加班路牌数");
319   - throw "总分班路牌数小于加班路牌数";
  553 +
  554 + // 3、生成班次
  555 + var _oKsbc = _internalLpArray[0].getBc(iQindex, iBcindex);
  556 + if (!_oKsbc) {
  557 + return false;
320 558 }
  559 + var _oKssj = _paramObj.addMinute(_oKsbc.getFcTimeObj(), iTime);
  560 + var _oBc = _factory.createBcObj(
  561 + _internalLpArray[iLpindex],
  562 + "normal", _oKsbc.isUp(),
  563 + 1, _oKssj, _paramObj);
321 564  
322   - _bx_lb_lpcount = dgminpc;
323   - _bx_5_2_fb_lpcount = _5_2_lpes;
324   - _bx_other_fb_lpcount = cls - dgminpc - _5_2_lpes;
  565 + return _oBc;
325 566  
326   - console.log("//---------------- 行车计划,初始化方法4 start ----------------//");
327   - console.log("连班路牌数:" + _bx_lb_lpcount);
328   - console.log("5休2分班路牌数:" + _bx_5_2_fb_lpcount);
329   - console.log("其他分班路牌数:" + _bx_other_fb_lpcount);
330   - console.log("//---------------- 行车计划,初始化方法4 end ----------------//");
331 567 };
332 568  
333   - //-------------------- 重要的内部方法 -----------------------//
  569 + /**
  570 + * 核心方法,在指定位置生成班次并添加到路牌指定位置中。
  571 + * @param lpIndex 第几个路牌
  572 + * @param qIndex 第几圈
  573 + * @param bcIndex 第几个班次
  574 + */
  575 + var _fnGenerateBcAndSetBc = function(lpIndex, qIndex, bcIndex) {
  576 + var _bcObj = _fnGenerateBc(lpIndex, qIndex, bcIndex);
  577 + if (_bcObj) {
  578 + _internalLpArray[lpIndex].setBc(qIndex, bcIndex, _bcObj);
  579 + }
  580 + };
  581 +
  582 +
334 583 /**
335 584 * 在指定位置生成班次(内部重要方法)。
336 585 * @param lpIndex 第几个路牌
... ... @@ -405,6 +654,9 @@ var InternalScheduleObj = function(paramObj, lpArray, factory) {
405 654 * @returns [{路牌index},{圈index},{班次index}]
406 655 */
407 656 var _findUpClosedBcIndexWithTime = function(timeObj, isUp) {
  657 +
  658 + // dododo
  659 +
408 660 var _lpObj;
409 661 var _groupObj;
410 662 var _bcObj;
... ... @@ -530,70 +782,18 @@ var InternalScheduleObj = function(paramObj, lpArray, factory) {
530 782 /**
531 783 * 初始化数据,使用标线初始化
532 784 */
533   - initDataWithBxLayout: function() {
  785 + fnInitDataWithBxLayout: function() {
534 786 // 初始化布局1,构造上标线,计算圈数,把上标线数据放入第一个路牌中
535   - _initFun1();
536   - // 初始化布局2,从上标线的某个班次开始,构造所有路牌的早高峰班次,晚高峰班次
537   - _initFun2();
538   - // 初始化布局3,构造中标线,根据高峰班次,将中标线放入合适的路牌中
539   - _initFun3();
540   - // 初始化4,计算连班,分班相关路牌数
541   - _initFun4();
542   -
543   - // 测试添加班次
544   - //this._generateBc(8, 1, 0);
545   - //this._generateBc(10, 1, 0);
546   - //this._generateBc(11, 1, 0);
547   - //this._generateBc(12, 1, 0);
548   - //this._generateBc(13, 1, 0);
549   - //this._generateBc(14, 1, 0);
550   - //this._generateBc(15, 1, 0);
551   - //this._generateBc(16, 1, 0);
552   - //this._generateBc(17, 1, 0);
553   - //this._generateBc(18, 1, 0);
554   - //
555   - //this._generateBc(10, 1, 1);
556   - //this._generateBc(11, 1, 1);
557   - //this._generateBc(12, 1, 1);
558   - //this._generateBc(13, 1, 1);
559   - //this._generateBc(14, 1, 1);
560   - //this._generateBc(15, 1, 1);
561   - //this._generateBc(16, 1, 1);
562   - //this._generateBc(17, 1, 1);
563   - //this._generateBc(18, 1, 1);
564   -
565   - // 6:31 8:30
566   - // 16:01 18:00
567   -
568   - // 测试找上界
569   - console.log("上界:" + _findUpClosedBcIndexWithTime(_paramObj.getMPeakStartTimeObj(), false));
570   - console.log("下界:" + _findDownClosedBcIndexWithTime(_paramObj.getMPeakEndTimeObj(), false));
571   -
572   - // TODO:
573   -
574   - // 测试时间判定
575   - //console.log("班次出车时间:" + _internalLpArray[0].getQBcIndexWithFcTime(
576   - // _paramObj.getMPeakStartTimeObj()
577   - // ));
578   -
579   - //// 测试画中标线,第6个路牌的位置,下行中标
580   - //_internalLpArray[7].initDataFromTimeToTime(
581   - // _paramObj.getDownFirstDTimeObj(),
582   - // _paramObj.getUpLastDtimeObj(),
583   - // false,
584   - // 0,
585   - // _paramObj,
586   - // _factory
587   - //);
588   -
589   - // TODO:问题
590   - // 1、中标线是直接赋值在具体位置的,没有修正班次时间
591   - // 2、路牌间隔时间需要修正的
  787 + _fnInitFun1();
  788 + // 初始化布局2,从上标线的某个班次开始,构造所有路牌的早高峰班次,晚高峰班次,计算路牌在各个圈中的间隔
  789 + _fnInitFun2();
  790 + // 初始化布局3,计算连班分班路牌分布
  791 + _fnInitFun3();
  792 + // 初始化布局4,计算中标线位置
  793 + _fnInitFun4();
592 794  
593 795 },
594 796  
595   - // TODO:
596   -
597 797 /**
598 798 * 调整高峰班次,
599 799 * 初始化生成早高峰,晚高峰班次并不准确,因为根据高峰时间段,并不在一个完整圈内,应该是在两个或多个圈之间
... ... @@ -602,116 +802,271 @@ var InternalScheduleObj = function(paramObj, lpArray, factory) {
602 802 * @param isZgf 是否早高峰
603 803 * @param isUp 是否上行
604 804 */
605   - adjustGfbc : function(isZgf, isUp) {
606   - var startTime; // 开始时间
607   - var endTime; // 结束时间
608   - var startBcIndex; // 开始班次索引
609   - var endBcIndex; // 结束班次索引
610   -
611   - startTime = isZgf ? _paramObj.getMPeakStartTimeObj() : _paramObj.getEPeakStartTimeObj();
612   - endTime = isZgf ? _paramObj.getMPeakEndTimeObj() : _paramObj.getEPeakEndTimeObj();
613   -
614   - startBcIndex = _findUpClosedBcIndexWithTime(startTime, isUp);
615   - endBcIndex = _findDownClosedBcIndexWithTime(endTime, isUp);
616   -
617   - var _lpIndex;
618   - var _qIndex;
619   - var _bcIndex;
620   - var _qInternelCount; // 高峰时间段中间包含的圈数
  805 + fnAdjustGfbc : function(isZgf, isUp) {
  806 + var oStartTime; // 开始时间
  807 + var oEndTime; // 结束时间
  808 + var iStartBcIndex; // 开始班次索引
  809 + var iEndBcIndex; // 结束班次索引
  810 +
  811 + oStartTime = isZgf ? _paramObj.getMPeakStartTimeObj() : _paramObj.getEPeakStartTimeObj();
  812 + oEndTime = isZgf ? _paramObj.getMPeakEndTimeObj() : _paramObj.getEPeakEndTimeObj();
  813 +
  814 + aStartBcIndex = _findUpClosedBcIndexWithTime(oStartTime, isUp);
  815 + aEndBcIndex = _findDownClosedBcIndexWithTime(oEndTime, isUp);
  816 +
  817 + var iLpIndex;
  818 + var iQIndex;
  819 + var iBcIndex;
  820 + var iQInternelCount; // 高峰时间段中间包含的圈数
621 821 var i;
622 822 var j;
623 823  
624   - var _lp;
  824 + var oLp;
625 825  
626   - if (startBcIndex && endBcIndex) {
627   - _lpIndex = startBcIndex[0];
628   - _qIndex = startBcIndex[1];
629   - _bcIndex = startBcIndex[2];
  826 + if (aStartBcIndex && aEndBcIndex) {
  827 + iLpIndex = aStartBcIndex[0];
  828 + iQIndex = aStartBcIndex[1];
  829 + iBcIndex = aStartBcIndex[2];
630 830  
631 831 // 处理头
632 832 // 删除头部多余班次
633   - for (j = 0; j < _lpIndex; j++) {
634   - _lp = _internalLpArray[j];
635   - if (_lp.isBxFb() && _lp.getBc(_qIndex, _bcIndex)) {
636   - _lp.removeBc(_qIndex, _bcIndex);
  833 + for (j = 0; j < iLpIndex; j++) {
  834 + oLp = _internalLpArray[j];
  835 + if (oLp.isBxFb() && oLp.getBc(iQIndex, iBcIndex)) {
  836 + oLp.removeBc(iQIndex, iBcIndex);
637 837 }
638 838 }
639 839  
640   - for (j = _lpIndex; j < _internalLpArray.length; j++) {
641   - _lp = _internalLpArray[j];
642   - if (!_lp.getBc(_qIndex, _bcIndex)) {
643   - _generateBcAndSetBc(j, _qIndex, _bcIndex);
  840 + for (j = iLpIndex; j < _internalLpArray.length; j++) {
  841 + oLp = _internalLpArray[j];
  842 + if (!oLp.getBc(iQIndex, iBcIndex)) {
  843 + _fnGenerateBcAndSetBc(j, iQIndex, iBcIndex);
644 844 }
645 845 }
646 846  
647 847 // 处理中间
648   - _qInternelCount = endBcIndex[1] - startBcIndex[1] - 1;
649   - for (i = 1; i <= _qInternelCount; i++) {
650   - _lp = _internalLpArray[_qIndex + i];
651   - if (!_lp.getBc(_qIndex + i, _bcIndex)) {
652   - _generateBcAndSetBc(i, _qIndex + i, _bcIndex);
  848 + iQInternelCount = aEndBcIndex[1] - aStartBcIndex[1] - 1;
  849 + for (i = 1; i <= iQInternelCount; i++) {
  850 + oLp = _internalLpArray[iQIndex + i];
  851 + if (!oLp.getBc(iQIndex + i, iBcIndex)) {
  852 + _fnGenerateBcAndSetBc(i, iQIndex + i, iBcIndex);
653 853 }
654 854 }
655 855  
656 856 // 处理尾部
657   - _lpIndex = endBcIndex[0];
658   - _qIndex = endBcIndex[1];
659   - _bcIndex = endBcIndex[2];
660   - for (j = 0; j < _lpIndex; j++) {
661   - _lp = _internalLpArray[j];
662   - if (!_lp.getBc(_qIndex, _bcIndex)) {
663   - _generateBcAndSetBc(j, _qIndex, _bcIndex);
  857 + iLpIndex = aEndBcIndex[0];
  858 + iQIndex = aEndBcIndex[1];
  859 + iBcIndex = aEndBcIndex[2];
  860 +
  861 + // 删除尾部多余的班次
  862 + for (j = iLpIndex; j < _internalLpArray.length; j++) {
  863 + oLp = _internalLpArray[j];
  864 + if (oLp.isBxFb() && oLp.getBc(iQIndex, iBcIndex)) {
  865 + oLp.removeBc(iQIndex, iBcIndex);
664 866 }
665 867 }
666   - // 删除尾部多余的班次
667   - for (j = _lpIndex; j < _internalLpArray.length; j++) {
668   - _lp = _internalLpArray[j];
669   - if (_lp.isBxFb() && _lp.getBc(_qIndex, _bcIndex)) {
670   - _lp.removeBc(_qIndex, _bcIndex);
  868 +
  869 + if (aStartBcIndex[1] != aEndBcIndex[1]) { // 指定时间范围跨圈
  870 + for (j = 0; j < iLpIndex; j++) {
  871 + oLp = _internalLpArray[j];
  872 + if (!oLp.getBc(iQIndex, iBcIndex)) {
  873 + _fnGenerateBcAndSetBc(j, iQIndex, iBcIndex);
  874 + }
671 875 }
  876 + } else {
  877 + // 不跨圈,不用处理,处理头的时候已经加了
672 878 }
  879 +
673 880 }
674 881  
675 882 },
676 883  
677 884 /**
678   - * 补充做5休2的班型班次。
679   - * 1、做5休2的路牌总工时不能超过7个小时
680   - * 2、5休2的路牌全部从早晚高峰班次开始往前补充1个班次,组成早晚2圈
681   - * 3、再根据余下工时及早晚高峰开始时间,确定向前或者向后加班次
  885 + * 按照营运时间要求补充班次,
  886 + * 早高峰7:45分以前出场运营,
  887 + * 晚高峰16:10分以前出场运营
682 888 */
683   - calcuLpBx_5_2: function() {
684   - // 1、先在早晚高峰班次前加1个班次压压惊
  889 + fnCalcuLpBc_yy: function() {
  890 + // 补班次的时候,针对的是分班班型
685 891 var i;
686   - var _lp;
687   - var _zgfbcpos; // 早高峰班次位置
688   - var _wgfbcpos; // 晚高峰班次位置
  892 + var _oLp;
  893 + var _oBc;
  894 + var _aMinBcIndex;
  895 + var _aMaxBcIndex;
  896 +
689 897 var _qIndex;
690 898 var _bIndex;
691 899  
692   - //for (i = 0; i < _internalLpArray.length; i++) {
693   - // _lp = _internalLpArray[i];
694   - // if (_lp.isBxFb5_2()) {
695   - // _zgfbcpos = _lp.getMinBcObjPosition();
696   - // _wgfbcpos = _lp.getMaxBcObjPosition();
697   - //
698   - // // TODO:测试向前添加一个班次
699   - // _qIndex = _zgfbcpos[0];
700   - // _bIndex = _zgfbcpos[1];
701   - // _bIndex == 0 ?
702   - // _generateBcAndSetBc(i, _qIndex - 1, 1) :
703   - // _generateBcAndSetBc(i, _qIndex, 0);
704   - //
705   - // _qIndex = _wgfbcpos[0];
706   - // _bIndex = _wgfbcpos[1];
707   - // _bIndex == 0 ?
708   - // _generateBcAndSetBc(i, _qIndex - 1, 1) :
709   - // _generateBcAndSetBc(i, _qIndex, 0);
710   - //
711   - // }
712   - //}
713   -
714   - // 2、
  900 + var _zgfCDate = _paramObj.toTimeObj("7:45");
  901 + var _wgfCDate = _paramObj.toTimeObj("16:10");
  902 + var _ccsj;
  903 +
  904 + for (i = 0; i < _internalLpArray.length; i++) {
  905 + _oLp = _internalLpArray[i];
  906 + if (_oLp.isBxFb()) { // 分班路牌
  907 + // 早高峰部分
  908 + _aMinBcIndex = _oLp.getMinBcObjPosition();
  909 + _qIndex = _aMinBcIndex[0];
  910 + _bIndex = _aMinBcIndex[1];
  911 + _oBc = _oLp.getBc(_qIndex, _bIndex);
  912 + if (_qIsUp) {
  913 + _ccsj = _bIndex == 0 ?
  914 + _paramObj.getUpOutTime() :
  915 + _paramObj.getDownOutTime();
  916 + } else {
  917 + _ccsj = _bIndex == 0 ?
  918 + _paramObj.getDownOutTime() :
  919 + _paramObj.getUpOutTime();
  920 + }
  921 + if (_zgfCDate.isBefore(_paramObj.addMinute(_oBc.getFcTimeObj(), -_ccsj))) {
  922 + _fnGenerateBcAndSetBc(
  923 + i,
  924 + _bIndex == 0 ? _qIndex - 1 : _qIndex,
  925 + _bIndex == 0 ? 1 : 0
  926 + )
  927 + }
  928 +
  929 + // 晚高峰部分
  930 + _aMaxBcIndex = _oLp.getMaxBcObjPosition();
  931 + _qIndex = _aMaxBcIndex[0];
  932 + _bIndex = _aMaxBcIndex[1];
  933 + _oBc = _oLp.getBc(
  934 + _bIndex == 0 ? _qIndex - 1 : _qIndex,
  935 + _bIndex == 0 ? 1 : 0
  936 + );
  937 + if (!_oBc) { // 前一个班次不存在,再判定加不加
  938 + _oBc = _oLp.getBc(_qIndex, _bIndex);
  939 + if (_qIsUp) {
  940 + _ccsj = _bIndex == 0 ?
  941 + _paramObj.getUpOutTime() :
  942 + _paramObj.getDownOutTime();
  943 + } else {
  944 + _ccsj = _bIndex == 0 ?
  945 + _paramObj.getDownOutTime() :
  946 + _paramObj.getUpOutTime();
  947 + }
  948 + if (_wgfCDate.isBefore(_paramObj.addMinute(_oBc.getFcTimeObj(), -_ccsj))) {
  949 + _fnGenerateBcAndSetBc(
  950 + i,
  951 + _bIndex == 0 ? _qIndex - 1 : _qIndex,
  952 + _bIndex == 0 ? 1 : 0
  953 + )
  954 + }
  955 + }
  956 + }
  957 + }
  958 + },
  959 +
  960 + /**
  961 + * 补充做5休2的班型班次。
  962 + * 1、确认5_2班型大致多少圈(小数点过.7进位)
  963 + * 2、获取当前5_2两端车次链的信息,每段的班次数目,还差几个班次没加
  964 + * 3、如果前面的车次链班次少,则从前面的车次链开始加
  965 + * 4、如果车次链班次数一样,从从后面的车次链开始加
  966 + * 5、加班次时都是往车次链前方加
  967 + * 6、如果前面车次链不能再加班次了,从后面车次链加
  968 + */
  969 + fnCalcuLpBx_5_2: function() {
  970 + // 计算做5休2班型所需的班次数
  971 + var iBxBcount = _aBxDesc[6].fBcCount;
  972 + if (iBxBcount - Math.floor(iBxBcount) > 0.7) {
  973 + iBxBcount = Math.floor(iBxBcount) + 1;
  974 + } else {
  975 + iBxBcount = Math.floor(iBxBcount);
  976 + }
  977 +
  978 + var i;
  979 + var j;
  980 + var oLp;
  981 + var iAddBcCount;
  982 + var oBcChain1;
  983 + var oBcChain2;
  984 + var iQindex;
  985 + var iBindex;
  986 +
  987 + for (i = 0; i < _internalLpArray.length; i++) {
  988 + oLp = _internalLpArray[i];
  989 + if (oLp.isBxFb5_2()) {
  990 + iAddBcCount = iBxBcount - oLp.getBcArray().length; // 需要添加的班次数
  991 + for (j = 1; j <= iAddBcCount; j++) {
  992 + oBcChain1 = oLp.fnGetBcChainInfo(0);
  993 + oBcChain2 = oLp.fnGetBcChainInfo(1);
  994 +
  995 + if (oBcChain1.bcount < oBcChain2.bcount) {
  996 + iQindex = oBcChain1.s_b == 0 ? oBcChain1.s_q - 1 : oBcChain1.s_q;
  997 + iBindex = oBcChain1.s_b == 0 ? 1 : 0;
  998 + // 往车次链往前不能加,就往后加
  999 + if (_fnGenerateBc(i, iQindex, iBindex)) {
  1000 + _fnGenerateBcAndSetBc(i, iQindex, iBindex);
  1001 + } else {
  1002 + iQindex = oBcChain1.e_b == 0 ? oBcChain1.e_q : oBcChain1.e_q + 1;
  1003 + iBindex = oBcChain1.e_b == 0 ? 1 : 0;
  1004 + _fnGenerateBcAndSetBc(i, iQindex, iBindex);
  1005 + }
  1006 +
  1007 + } else if (oBcChain1.bcount > oBcChain2.bcount) {
  1008 + iQindex = oBcChain2.s_b == 0 ? oBcChain2.s_q - 1 : oBcChain2.s_q;
  1009 + iBindex = oBcChain2.s_b == 0 ? 1 : 0;
  1010 + _fnGenerateBcAndSetBc(i, iQindex, iBindex);
  1011 + } else {
  1012 + iQindex = oBcChain2.s_b == 0 ? oBcChain2.s_q - 1 : oBcChain2.s_q;
  1013 + iBindex = oBcChain2.s_b == 0 ? 1 : 0;
  1014 + _fnGenerateBcAndSetBc(i, iQindex, iBindex);
  1015 + }
  1016 + }
  1017 + }
  1018 + }
  1019 +
  1020 + },
  1021 +
  1022 + /**
  1023 + * 补其他分班班型班次。
  1024 + * 从车次链的后面开始加
  1025 + */
  1026 + fnCalcuLpBx_other: function() {
  1027 + // TODO:暂时使用做2休1的班型
  1028 + // 计算做5休2班型所需的班次数
  1029 + var iBxBcount = _aBxDesc[4].fBcCount;
  1030 + if (iBxBcount - Math.floor(iBxBcount) > 0.7) {
  1031 + iBxBcount = Math.floor(iBxBcount) + 1;
  1032 + } else {
  1033 + iBxBcount = Math.floor(iBxBcount);
  1034 + }
  1035 +
  1036 + var i;
  1037 + var j;
  1038 + var oLp;
  1039 + var iAddBcCount;
  1040 + var oBcChain1;
  1041 + var oBcChain2;
  1042 + var iQindex;
  1043 + var iBindex;
  1044 +
  1045 + for (i = 0; i < _internalLpArray.length; i++) {
  1046 + oLp = _internalLpArray[i];
  1047 + if (oLp.isBxFb() && !oLp.isBxFb5_2()) {
  1048 + iAddBcCount = iBxBcount - oLp.getBcArray().length; // 需要添加的班次数
  1049 + for (j = 1; j <= iAddBcCount; j++) {
  1050 + oBcChain1 = oLp.fnGetBcChainInfo(0);
  1051 + oBcChain2 = oLp.fnGetBcChainInfo(1);
  1052 +
  1053 + if (oBcChain1.bcount < oBcChain2.bcount) {
  1054 + iQindex = oBcChain1.e_b == 0 ? oBcChain1.e_q : oBcChain1.e_q + 1;
  1055 + iBindex = oBcChain1.e_b == 0 ? 1 : 0;
  1056 + _fnGenerateBcAndSetBc(i, iQindex, iBindex);
  1057 + } else if (oBcChain1.bcount > oBcChain2.bcount) {
  1058 + iQindex = oBcChain2.e_b == 0 ? oBcChain2.e_q : oBcChain2.e_q + 1;
  1059 + iBindex = oBcChain2.e_b == 0 ? 1 : 0;
  1060 + _fnGenerateBcAndSetBc(i, iQindex, iBindex);
  1061 + } else {
  1062 + iQindex = oBcChain2.e_b == 0 ? oBcChain2.e_q : oBcChain2.e_q + 1;
  1063 + iBindex = oBcChain2.e_b == 0 ? 1 : 0;
  1064 + _fnGenerateBcAndSetBc(i, iQindex, iBindex);
  1065 + }
  1066 + }
  1067 + }
  1068 + }
  1069 +
715 1070 },
716 1071  
717 1072 /**
... ... @@ -719,77 +1074,101 @@ var InternalScheduleObj = function(paramObj, lpArray, factory) {
719 1074 * 1、上标线,中标线中间的连班路牌班次从早高峰班次一直拉到底,从早高峰班次向上标线起始班次靠拢
720 1075 * 2、中标线以下的连班路牌班次从早高峰班次一直拉到底,从早高峰班次向中标线起始班次靠拢
721 1076 */
722   - calcuLpBx_lb: function() {
  1077 + fnCalcuLpBx_lb: function() {
723 1078 // 补充连班的班次,参照上标线,中标线补充不足的班次
724   - var _zgffcsj; // 早高峰发车时间
725   - var _etsj = // 结束时间
  1079 +
  1080 + var aLbLpindexes = []; // 除上标线,中标线的连班路牌索引
  1081 + var i;
  1082 + for (i = 0; i < _internalLpArray.length; i++) {
  1083 + if (_internalLpArray[i].isBxLb() && i != 0 && i != _iZbx_lpIndex) {
  1084 + aLbLpindexes.push(i);
  1085 + }
  1086 + }
  1087 +
  1088 + var oEndsj = // 结束时间
726 1089 _paramObj.getUpLastDtimeObj().isBefore(_paramObj.getDownLastDTimeObj()) ?
727 1090 _paramObj.getDownLastDTimeObj() :
728 1091 _paramObj.getUpLastDtimeObj();
729 1092  
730   - var _lp;
731   - var _minbcPos;
732   - var _bcObj;
733   - var i;
734   - for (i = 0; i < _internalLpArray.length; i++) {
735   - _lp = _internalLpArray[i];
736   - if (_lp.isBxLb() && i != 0 && i != _zbx_lpIndex) {
737   - _minbcPos = _lp.getMinBcObjPosition();
738   - _bcObj = _lp.getBc(_minbcPos[0], _minbcPos[1]);
739   - _zgffcsj = _bcObj.getFcTimeObj();
740   - // 重新初始化连班班型班次
741   - _lp.initDataFromTimeToTime(
742   - _zgffcsj,
743   - _etsj,
744   - _bcObj.isUp(),
745   - _minbcPos[0],
746   - _paramObj,
747   - _factory
748   - );
  1093 + var oLp;
  1094 + var aMinbcPos;
  1095 + var oBc;
  1096 + var j;
  1097 + var iTempBcIndex;
  1098 +
  1099 + // 1、从最小班次开始,往后补充班次
  1100 + for (i = 0; i < aLbLpindexes.length; i++) {
  1101 + oLp = _internalLpArray[aLbLpindexes[i]];
  1102 +
  1103 + // 最小班次索引
  1104 + aMinbcPos = oLp.getMinBcObjPosition();
  1105 + // 使用纵向分隔补充班次,从最小班次向后补
  1106 + iTempBcIndex = aMinbcPos[1] == 0 ? 1 : 0;
  1107 + j = iTempBcIndex == 0 ? aMinbcPos[0] + 1 : aMinbcPos[0];
  1108 +
  1109 + while (j < _qCount) {
  1110 + while (iTempBcIndex <= 1) {
  1111 + oBc = _fnGenerateBc(aLbLpindexes[i], j, iTempBcIndex);
  1112 + if (oBc &&
  1113 + oBc.getFcTimeObj().isBefore(oEndsj) &&
  1114 + oBc.getArrTimeObj().isBefore(oEndsj)) {
  1115 + oLp.setBc(j, iTempBcIndex, oBc);
  1116 + }
  1117 + iTempBcIndex++;
  1118 + }
  1119 + iTempBcIndex = 0;
  1120 + j++;
749 1121 }
  1122 +
750 1123 }
751 1124  
  1125 + // 2、上标线中标线之间的路牌,从最小的班次往前补充班次
  1126 +
752 1127 // 还要补充缺失的班次,差上标线几个班次要往前补上
753   - var _bccount;
754   - var j;
755   - var _qIndex;
756   - var _bIndex;
  1128 + var iBccount;
  1129 + var iQindex;
  1130 + var iBindex;
757 1131 // 补上标线到中标线之间的连班路牌的班次
758   - for (i = 0; i < _zbx_lpIndex; i++) {
759   - _lp = _internalLpArray[i];
760   - if (_lp.isBxLb() && i != 0 && i != _zbx_lpIndex) {
761   - _minbcPos = _lp.getMinBcObjPosition();
762   - _qIndex = _minbcPos[0];
763   - _bIndex = _minbcPos[1];
764   - _bccount = (_qIndex - 1) * 2 + _bIndex; // 距离上标线起始站点差几个班次
765   - for (j = 0; j < _bccount; j++) {
766   - if (_bIndex == 0) {
767   - _qIndex --;
768   - _bIndex = 1;
769   - _generateBcAndSetBc(i, _qIndex, _bIndex);
770   - } else if (_bIndex == 1) {
771   - _bIndex --;
772   - _generateBcAndSetBc(i, _qIndex, _bIndex);
  1132 + for (i = 0; i < aLbLpindexes.length; i++) {
  1133 + if (aLbLpindexes[i] > 0 && aLbLpindexes[i] < _iZbx_lpIndex) {
  1134 + oLp = _internalLpArray[aLbLpindexes[i]];
  1135 + aMinbcPos = oLp.getMinBcObjPosition();
  1136 + iQindex = aMinbcPos[0];
  1137 + iBindex = aMinbcPos[1];
  1138 + iBccount = (iQindex - 1) * 2 + iBindex; // 距离上标线起始站点差几个班次
  1139 + for (j = 0; j < iBccount; j++) {
  1140 + if (iBindex == 0) {
  1141 + iQindex --;
  1142 + iBindex = 1;
  1143 + _fnGenerateBcAndSetBc(aLbLpindexes[i], iQindex, iBindex);
  1144 + } else if (iBindex == 1) {
  1145 + iBindex --;
  1146 + _fnGenerateBcAndSetBc(aLbLpindexes[i], iQindex, iBindex);
773 1147 }
774 1148 }
  1149 +
775 1150 }
  1151 +
776 1152 }
  1153 +
  1154 + // 3、中标线之后的路牌,从最小的班次往前补充班次
  1155 +
777 1156 // 补中标线以下的连班路牌的班次
778   - for (i = _zbx_lpIndex; i < _internalLpArray.length; i++) {
779   - _lp = _internalLpArray[i];
780   - if (_lp.isBxLb() && i != 0 && i != _zbx_lpIndex) {
781   - _minbcPos = _lp.getMinBcObjPosition();
782   - _qIndex = _minbcPos[0];
783   - _bIndex = _minbcPos[1];
784   - _bccount = (_qIndex - 0) * 2 + _bIndex - 1; // 距离上标线起始站点差几个班次
785   - for (j = 0; j < _bccount; j++) {
786   - if (_bIndex == 0) {
787   - _qIndex --;
788   - _bIndex = 1;
789   - _generateBcAndSetBc(i, _qIndex, _bIndex);
790   - } else if (_bIndex == 1) {
791   - _bIndex --;
792   - _generateBcAndSetBc(i, _qIndex, _bIndex);
  1157 + for (i = 0; i < aLbLpindexes.length; i++) {
  1158 + if (aLbLpindexes[i] > _iZbx_lpIndex) {
  1159 + oLp = _internalLpArray[aLbLpindexes[i]];
  1160 + aMinbcPos = oLp.getMinBcObjPosition();
  1161 + iQindex = aMinbcPos[0];
  1162 + iBindex = aMinbcPos[1];
  1163 + iBccount = (iQindex - 0) * 2 + iBindex - 1; // 距离上标线起始站点差几个班次
  1164 + for (j = 0; j < iBccount; j++) {
  1165 + if (iBindex == 0) {
  1166 + iQindex --;
  1167 + iBindex = 1;
  1168 + _fnGenerateBcAndSetBc(aLbLpindexes[i], iQindex, iBindex);
  1169 + } else if (iBindex == 1) {
  1170 + iBindex --;
  1171 + _fnGenerateBcAndSetBc(aLbLpindexes[i], iQindex, iBindex);
793 1172 }
794 1173 }
795 1174 }
... ... @@ -798,179 +1177,454 @@ var InternalScheduleObj = function(paramObj, lpArray, factory) {
798 1177 },
799 1178  
800 1179 /**
801   - * 计算每个路牌的班型及工时对应的圈数。
802   - * 1、将连班,分班路牌分配到各个路牌上(分隔法),上标线,中标线上连班路牌
803   - * 2、确定班型的工时,其中连班路牌的工时由上标线,中标线确定好了,5休2路牌工时也确定了,
804   - * 其余分班路牌的工时由高峰低谷最大,最小发车间隔计算
  1180 + * 计算末班车(一般都落在连班班型上,因为按照现在的布局方法,分班路牌不会一直连到最后)。
  1181 + * 1、确定末班车早的班次
  1182 + * 2、从后往前找到与这个班次最匹配的班次的位置(第几个路牌,第几圈,第几个班次),然后覆盖
  1183 + * 3、从第2步找的位置,往上找与另一个末班车匹配的班次位置,然后覆盖
805 1184 */
806   - calcuLpBx_fg: function() {
807   - // 间隔法
  1185 + fnCalcuLastBc: function() {
  1186 + //-------------------- 1、确定末班车早的方向,时间 -----------------------//
  1187 + var _oLastTime;
  1188 + var _bLastIsUp;
  1189 + if (_paramObj.getUpLastDtimeObj().isBefore(_paramObj.getDownLastDTimeObj())) {
  1190 + _oLastTime = _paramObj.getUpLastDtimeObj();
  1191 + _bLastIsUp = true;
  1192 + } else {
  1193 + _oLastTime = _paramObj.getDownLastDTimeObj();
  1194 + _bLastIsUp = false;
  1195 + }
808 1196  
809   - //--------------------------- 1、间隔法分隔连班路牌 ----------------------//
  1197 + //-------------------- 2、确定比 _oLastTime 小或者等于的班次位置,并修改班次时间到末班车时间 -----------------//
  1198 + var i;
  1199 + var j;
  1200 + var _oBc;
  1201 + var _oLp;
  1202 + var _aBcIndex;
810 1203  
811   - // 除去上标线,中标线的连班路牌个数
812   - var _lblbcount = _bx_lb_lpcount - 2;
813   - // 计算由标线隔开的两个区域的路牌数比率
814   - var _p1 = (_zbx_lpIndex + 1) / (_internalLpArray.length + 1);
815   - var _p2 = (_internalLpArray.length - _zbx_lpIndex) / (_internalLpArray.length + 1);
816   - var _p1_lpcount = _lblbcount * _p1;
817   - var _p2_lpcount = _lblbcount * _p2;
818   - if (parseInt(_p1_lpcount) != _p1_lpcount) { // 没有整除
819   - _p1_lpcount = Math.floor(_p1_lpcount);
820   - _p2_lpcount = Math.floor(_p2_lpcount) + 1;
  1204 + for (i = _qCount - 1; i >= 0; i--) {
  1205 + if (_aBcIndex) {
  1206 + break;
  1207 + }
  1208 + // 从大到小找到第一个合适的班次索引
  1209 + for (j = _internalLpArray.length - 1; j >= 0; j--) {
  1210 + _oLp = _internalLpArray[j];
  1211 + if (_oLp.isBxLb()) {
  1212 + _oBc = _oLp.getBc(i, _qIsUp == _bLastIsUp ? 0 : 1);
  1213 + }
  1214 + if (_oBc != undefined && _oBc.getFcTimeObj().isBefore(_oLastTime)) {
  1215 + _aBcIndex = [];
  1216 + _aBcIndex.push(j); // 路牌索引
  1217 + _aBcIndex.push(i); // 圈索引
  1218 + _aBcIndex.push(_qIsUp == _bLastIsUp ? 0 : 1); // 班次索引
  1219 + break;
  1220 + }
  1221 + }
821 1222 }
822 1223  
823   - // 设定第一个区域的连班路牌
824   - var i;
825   - var _count = _p1_lpcount + 1;
826   - var _c1 = Math.floor(_zbx_lpIndex / _count);
827   - var _c2 = _zbx_lpIndex % _count;
828   - var _c2_start_index;
829   - for (i = 1; i <= _count - _c2; i++) {
830   - _internalLpArray[(i - 1) * _c1].setBxLb(true);
831   - _internalLpArray[(i - 1) * _c1].setBxDesc("连班");
832   - _c2_start_index = (i - 1) * _c1;
833   - }
834   - for (i = 1; i <= _c2; i++) {
835   - _internalLpArray[_c2_start_index + i * (_c1 + 1)].setBxLb(true);
836   - _internalLpArray[_c2_start_index + i * (_c1 + 1)].setBxDesc("连班");
837   - }
838   -
839   - // 设定第二个区域的连班路牌
840   - _count = _p2_lpcount + 1;
841   - _c1 = Math.floor((_internalLpArray.length - _zbx_lpIndex - 1) / _count);
842   - _c2 = (_internalLpArray.length - _zbx_lpIndex - 1) % _count;
843   - for (i = 1; i <= _count - _c2; i++) {
844   - _internalLpArray[(i - 1) * _c1 + _zbx_lpIndex].setBxLb(true);
845   - _internalLpArray[(i - 1) * _c1 + _zbx_lpIndex].setBxFb(false);
846   - _internalLpArray[(i - 1) * _c1 + _zbx_lpIndex].setBxFb5_2(false);
847   - _internalLpArray[(i - 1) * _c1 + _zbx_lpIndex].setBxDesc("连班");
848   - _c2_start_index = (i - 1) * _c1 + _zbx_lpIndex;
849   - }
850   - for (i = 1; i <= _c2; i++) {
851   - _internalLpArray[_c2_start_index + i * (_c1 + 1)].setBxLb(true);
852   - _internalLpArray[_c2_start_index + i * (_c1 + 1)].setBxFb(false);
853   - _internalLpArray[_c2_start_index + i * (_c1 + 1)].setBxFb5_2(false);
854   - _internalLpArray[_c2_start_index + i * (_c1 + 1)].setBxDesc("连班");
855   - }
856   -
857   - //---------------------------- 2、分隔法,分隔分班路牌 -------------------------//
858   -
859   - // 设定分班路牌
860   - var notlbIndexes = []; // 去除连班的路牌index列表
861   - for (i = 0; i < _internalLpArray.length; i++) {
862   - if (!_internalLpArray[i].isBxLb()) {
863   - notlbIndexes.push(i);
  1224 + //-------------------- 3、预估哪个个班次离末班最近,用末班替换,并删除后面的多余班次 -----------------//
  1225 + // 第2步找到的班次不一定是最适合的,需要把之后的班次模拟出来再比较一下
  1226 + var _aBcIndexes = []; // 里面放对象 {lpIndex,qIndex,bcIndex,fcsjTime}
  1227 + _oBc = undefined;
  1228 + for (i = _aBcIndex[0]; i < _internalLpArray.length; i++) {
  1229 + _oLp = _internalLpArray[i];
  1230 + if (_oLp.isBxLb()) {
  1231 + _oBc = _oLp.getBc(_aBcIndex[1], _aBcIndex[2]);
  1232 + if (_oBc == undefined) {
  1233 + _oBc = _fnGenerateBc(i, _aBcIndex[1], _aBcIndex[2]);
  1234 + }
  1235 + _aBcIndexes.push({
  1236 + lpIndex: i,
  1237 + qIndex: _aBcIndex[1],
  1238 + bcIndex: _aBcIndex[2],
  1239 + bcObj: _oBc
  1240 + })
864 1241 }
865 1242 }
866   - // 获取离中标线最近的分班路牌索引
867   - var _temp_fg_index;
868   - for (i = 0; i < notlbIndexes.length; i++) {
869   - if (notlbIndexes[i] == _zbx_lpIndex - 1) {
870   - _temp_fg_index = i;
  1243 + var _oBcIndex_find; // 第几个路牌离末班车最近
  1244 + for (i = _aBcIndexes.length - 1; i >= 0; i--) {
  1245 + if (_aBcIndexes[i].bcObj.getFcTimeObj().isBefore(_oLastTime)) {
  1246 + _oBcIndex_find = _aBcIndexes[i];
871 1247 break;
872 1248 }
873 1249 }
  1250 + // 替换成末班车
  1251 + _oBc = _oBcIndex_find.bcObj;
  1252 + _oBc.addMinuteToFcsj(_oLastTime.diff(_oBc.getFcTimeObj(), "m"));
  1253 + _internalLpArray[_oBcIndex_find.lpIndex].setBc(
  1254 + _oBcIndex_find.qIndex, _oBcIndex_find.bcIndex, _oBc
  1255 + );
874 1256  
875   - // 使用上面的分隔比率,分隔5休2班型
876   - _p1_lpcount = _bx_5_2_fb_lpcount * _p1;
877   - _p2_lpcount = _bx_5_2_fb_lpcount * _p2;
878   - if (parseInt(_p1_lpcount) != _p1_lpcount) { // 没有整除
879   - _p1_lpcount = Math.floor(_p1_lpcount);
880   - _p2_lpcount = Math.floor(_p2_lpcount) + 1;
881   - }
882   - // 第一个区域
883   - _count = _p1_lpcount;
884   - _c1 = Math.floor(_temp_fg_index / _count);
885   - _c2 = _temp_fg_index % _count;
886   - for (i = 1; i <= _count - _c2; i++) {
887   - _internalLpArray[notlbIndexes[(i - 1) * _c1]].setBxLb(false);
888   - _internalLpArray[notlbIndexes[(i - 1) * _c1]].setBxFb(true);
889   - _internalLpArray[notlbIndexes[(i - 1) * _c1]].setBxFb5_2(true);
890   - _internalLpArray[notlbIndexes[(i - 1) * _c1]].setBxDesc("5休2分班");
891   - _c2_start_index = (i - 1) * _c1;
892   - }
893   - for (i = 1; i <= _c2; i++) {
894   - _internalLpArray[notlbIndexes[_c2_start_index + i * (_c1 + 1)]].setBxLb(false);
895   - _internalLpArray[notlbIndexes[_c2_start_index + i * (_c1 + 1)]].setBxLb(true);
896   - _internalLpArray[notlbIndexes[_c2_start_index + i * (_c1 + 1)]].setBxFb5_2(true);
897   - _internalLpArray[notlbIndexes[_c2_start_index + i * (_c1 + 1)]].setBxDesc("5休2分班");
898   - }
899   - // 第二个区域
900   - _count = _p2_lpcount;
901   - _c1 = Math.floor((notlbIndexes.length - _temp_fg_index - 1) / _count);
902   - _c2 = (notlbIndexes.length - _temp_fg_index - 1) % _count;
903   - for (i = 1; i <= _count - _c2; i++) {
904   - _internalLpArray[notlbIndexes[(i - 1) * _c1 + _temp_fg_index + 1]].setBxLb(false);
905   - _internalLpArray[notlbIndexes[(i - 1) * _c1 + _temp_fg_index + 1]].setBxFb(true);
906   - _internalLpArray[notlbIndexes[(i - 1) * _c1 + _temp_fg_index + 1]].setBxFb5_2(true);
907   - _internalLpArray[notlbIndexes[(i - 1) * _c1 + _temp_fg_index + 1]].setBxDesc("5休2分班");
908   - _c2_start_index = (i - 1) * _c1 + _temp_fg_index + 1;
909   - }
910   - for (i = 1; i <= _c2; i++) {
911   - _internalLpArray[notlbIndexes[_c2_start_index + i * (_c1 + 1)]].setBxLb(false);
912   - _internalLpArray[notlbIndexes[_c2_start_index + i * (_c1 + 1)]].setBxFb(true);
913   - _internalLpArray[notlbIndexes[_c2_start_index + i * (_c1 + 1)]].setBxFb5_2(true);
914   - _internalLpArray[notlbIndexes[_c2_start_index + i * (_c1 + 1)]].setBxDesc("5休2分班");
915   - }
916   -
917   - //-------------------------- 3、余下班次就是其他分班类型 ----------------------//
918   -
919   - for (i = 0; i < notlbIndexes.length; i++) {
920   - if (!_internalLpArray[notlbIndexes[i]].isBxFb5_2()) {
921   - _internalLpArray[notlbIndexes[i]].setBxLb(false);
922   - _internalLpArray[notlbIndexes[i]].setBxFb(true);
923   - _internalLpArray[notlbIndexes[i]].setBxFb5_2(false);
924   - _internalLpArray[notlbIndexes[i]].setBxDesc("其他分班");
925   - }
926   - }
927   -
928   - // 测试打印
929   - var lbIndexes = [];
930   - for (i = 0; i < _internalLpArray.length; i++) {
931   - if (_internalLpArray[i].isBxLb()) {
932   - lbIndexes.push(i);
  1257 + // 删除多余班次呢
  1258 + for (i = _oBcIndex_find.lpIndex + 1; i < _internalLpArray.length; i++) {
  1259 + _internalLpArray[i].removeBc(_oBcIndex_find.qIndex, _oBcIndex_find.bcIndex);
  1260 + }
  1261 +
  1262 + //---------------------- 4、从第3步找到的位置,开始往上找,确定另一个末班车,并删除后面多余的班次 -------------//
  1263 + // 因为另一个末班车时间晚,肯定在后面,并且必须在之前的路牌
  1264 + // 如果在之后的路牌,则意味着之前那个末班车位置不对,连班连起来会有两个之前的末班车
  1265 + // 计算大的末班车时间
  1266 + if (_paramObj.getUpLastDtimeObj().isBefore(_paramObj.getDownLastDTimeObj())) {
  1267 + _oLastTime = _paramObj.getDownLastDTimeObj();
  1268 + _bLastIsUp = false;
  1269 + } else {
  1270 + _oLastTime = _paramObj.getUpLastDtimeObj();
  1271 + _bLastIsUp = true;
  1272 + }
  1273 + _aBcIndexes = [];
  1274 + for (i = _oBcIndex_find.lpIndex; i >=0; i--) {
  1275 + _oLp = _internalLpArray[i];
  1276 + if (_oLp.isBxLb()) {
  1277 + _oBc = _oLp.getBc(
  1278 + _oBcIndex_find.bcIndex == 0 ? _oBcIndex_find.qIndex : _oBcIndex_find.qIndex + 1,
  1279 + _oBcIndex_find.bcIndex == 0 ? 1 : 0
  1280 + );
  1281 + if (_oBc == undefined) {
  1282 + _oBc = _fnGenerateBc(
  1283 + i,
  1284 + _oBcIndex_find.bcIndex == 0 ? _oBcIndex_find.qIndex : _oBcIndex_find.qIndex + 1,
  1285 + _oBcIndex_find.bcIndex == 0 ? 1 : 0
  1286 + );
  1287 + }
  1288 + if (!_oBc) { // 纵向生成班次失败,用横向生成班次,发车时间取前一班次的到达时间加停战时间
  1289 + _oBc = _factory.createBcObj(
  1290 + _oLp,
  1291 + "normal",
  1292 + _bLastIsUp,
  1293 + 3,
  1294 + _oLp.getBc(_oBcIndex_find.qIndex, _oBcIndex_find.bcIndex).getArrTimeObj(),
  1295 + _paramObj
  1296 + );
  1297 +
  1298 + }
  1299 + _aBcIndexes.push({
  1300 + lpIndex: i,
  1301 + qIndex: _oBcIndex_find.bcIndex == 0 ? _oBcIndex_find.qIndex : _oBcIndex_find.qIndex + 1,
  1302 + bcIndex: _oBcIndex_find.bcIndex == 0 ? 1 : 0,
  1303 + bcObj: _oBc
  1304 + })
  1305 + }
  1306 + }
  1307 +
  1308 + console.log(_aBcIndexes);
  1309 +
  1310 + _oBcIndex_find = _aBcIndexes[0];
  1311 +
  1312 + for (i = 0; i < _aBcIndexes.length; i++) {
  1313 + if (_aBcIndexes[i].bcObj.getFcTimeObj().isBefore(_oLastTime)) {
  1314 + _oBcIndex_find = _aBcIndexes[i];
  1315 + break;
933 1316 }
934 1317 }
935   - console.log("连班路牌indexes=" + lbIndexes);
  1318 + // 替换成末班车
  1319 + _oBc = _oBcIndex_find.bcObj;
  1320 + _oBc.addMinuteToFcsj(_oLastTime.diff(_oBc.getFcTimeObj(), "m"));
  1321 + _internalLpArray[_oBcIndex_find.lpIndex].setBc(
  1322 + _oBcIndex_find.qIndex, _oBcIndex_find.bcIndex, _oBc
  1323 + );
936 1324  
937   - var _other_fbIndexes = [];
  1325 + // 删除多余班次呢
  1326 + for (i = _oBcIndex_find.lpIndex + 1; i < _internalLpArray.length; i++) {
  1327 + _internalLpArray[i].removeBc(_oBcIndex_find.qIndex, _oBcIndex_find.bcIndex);
  1328 + }
  1329 +
  1330 +
  1331 + },
  1332 +
  1333 + /**
  1334 + * 添加吃饭班次。
  1335 + */
  1336 + fnCalcuEatBc: function() {
  1337 + // 吃午饭时间范围,10:15 到 12:15
  1338 + // 吃晚饭时间范围,18:00 到 19:00
  1339 +
  1340 + if (!_paramObj.fnIsEat()) {
  1341 + return;
  1342 + }
  1343 +
  1344 + // 午饭index
  1345 + var aLEIndex;
  1346 + // 晚饭index
  1347 + var aDEIndex;
  1348 +
  1349 + // 所有吃饭都默认在一个方向,两个方向暂时不考虑
  1350 + if (_paramObj.fnIsUpEat()) {
  1351 + aLEIndex = _internalLpArray[0].getQBcIndexWithFcTime(_paramObj.toTimeObj("10:15"), true, false);
  1352 + aDEIndex = _internalLpArray[0].getQBcIndexWithFcTime(_paramObj.toTimeObj("18:00"), true, false);
  1353 + } else {
  1354 + aLEIndex = _internalLpArray[0].getQBcIndexWithFcTime(_paramObj.toTimeObj("10:15"), false, true);
  1355 + aDEIndex = _internalLpArray[0].getQBcIndexWithFcTime(_paramObj.toTimeObj("18:00"), false, true);
  1356 + }
  1357 +
  1358 + // 午饭第几圈,第几个班次
  1359 + var iLEQIndex = aLEIndex[0];
  1360 + var iLEBIndex = aLEIndex[1];
  1361 + // 晚饭第几圈,第几个班次
  1362 + var iDEQIndex = aDEIndex[0];
  1363 + var iDEBIndex = aDEIndex[1];
  1364 +
  1365 + // 注意,本模型只有连班才有吃饭
  1366 +
  1367 + var i;
  1368 + var oLp;
  1369 + var aLbIndex = []; // 连班班型的路牌索引
938 1370 for (i = 0; i < _internalLpArray.length; i++) {
939   - if (_internalLpArray[i].isBxFb() && !_internalLpArray[i].isBxFb5_2()) {
940   - _other_fbIndexes.push(i);
  1371 + oLp = _internalLpArray[i];
  1372 + if (oLp.isBxLb()) {
  1373 + aLbIndex.push(i);
  1374 + }
  1375 + }
  1376 +
  1377 + var iLTime;
  1378 + var iDtime;
  1379 + var j;
  1380 + for (i = 0; i < aLbIndex.length; i++) {
  1381 + oLp = _internalLpArray[aLbIndex[i]];
  1382 +
  1383 + // 午饭
  1384 + iLTime = oLp.fnAddEatBc(iLEQIndex, iLEBIndex, _factory, _paramObj);
  1385 + // 晚饭
  1386 + iDtime = oLp.fnAddEatBc(iDEQIndex, iDEBIndex, _factory, _paramObj);
  1387 +
  1388 + if (i == aLbIndex.length - 1) {
  1389 + for (j = aLbIndex[i]; j < _internalLpArray.length; j++) {
  1390 + oLp = _internalLpArray[j];
  1391 + if (oLp.isBxFb()) { // 5休2班型不调整
  1392 + // 修正午饭之后路牌班次的发车时间
  1393 + oLp.fnAddMinuteToBcFcsj(iLEQIndex, iLEBIndex, iLTime);
  1394 + oLp.fnAddMinuteToBcFcsj(iDEQIndex, iDEBIndex, iDtime);
  1395 + }
  1396 + }
  1397 + } else {
  1398 + for (j = aLbIndex[i]; j < aLbIndex[i + 1]; j++) {
  1399 + oLp = _internalLpArray[j];
  1400 + if (oLp.isBxFb()) {
  1401 + // 修正午饭之后路牌班次的发车时间
  1402 + oLp.fnAddMinuteToBcFcsj(iLEQIndex, iLEBIndex, iLTime);
  1403 + oLp.fnAddMinuteToBcFcsj(iDEQIndex, iDEBIndex, iDtime);
  1404 + }
  1405 + }
941 1406 }
942 1407 }
943   - console.log("其他分班路牌indexes=" + _other_fbIndexes);
944 1408  
945   - var _5_2_fbIndexes = [];
  1409 + },
  1410 +
  1411 + /**
  1412 + * 补每个路牌的其他班次(进出场,例保班次)。
  1413 + */
  1414 + fnCalcuOtherBc: function() {
  1415 + var i;
  1416 + var _lpObj;
  1417 + var _minBcIndex;
  1418 + var _maxBcIndex;
  1419 + var _minBc;
  1420 + var _maxBc;
  1421 + var _otherbc = [];
  1422 +
946 1423 for (i = 0; i < _internalLpArray.length; i++) {
947   - if (_internalLpArray[i].isBxFb() && _internalLpArray[i].isBxFb5_2()) {
948   - _5_2_fbIndexes.push(i);
  1424 + _lpObj = _internalLpArray[i];
  1425 + _minBcIndex = _lpObj.getMinBcObjPosition();
  1426 + _maxBcIndex = _lpObj.getMaxBcObjPosition();
  1427 + _minBc = _lpObj.getBc(_minBcIndex[0], _minBcIndex[1]);
  1428 + _maxBc = _lpObj.getBc(_maxBcIndex[0], _maxBcIndex[1]);
  1429 +
  1430 + _otherbc = [];
  1431 + //_otherbc.push(_factory.createBcObj(
  1432 + // _lpObj, "bd", true, 1,
  1433 + // _minBc.getFcTimeObj(),
  1434 + // _paramObj
  1435 + //));
  1436 + _otherbc.push(_factory.createBcObj(
  1437 + _lpObj, "out", true, 1,
  1438 + _minBc.getFcTimeObj(),
  1439 + _paramObj
  1440 + ));
  1441 +
  1442 + _maxBc.setArrTimeObj(_paramObj.addMinute(_maxBc.getFcTimeObj(), _maxBc.getBcTime()));
  1443 + _maxBc.setStopTime(0);
  1444 + _otherbc.push(_factory.createBcObj(
  1445 + _lpObj, "in", true, 1,
  1446 + _maxBc.getArrTimeObj(),
  1447 + _paramObj
  1448 + ));
  1449 + //_otherbc.push(_factory.createBcObj(
  1450 + // _lpObj, "lc", true, 1,
  1451 + // _maxBc.getArrTimeObj(),
  1452 + // _paramObj
  1453 + //));
  1454 +
  1455 + _lpObj.addOtherBcArray(_otherbc);
  1456 + }
  1457 +
  1458 + },
  1459 +
  1460 + /**
  1461 + * 祛除上标线有删除标记的班次。
  1462 + */
  1463 + fnRemoveDelFlagBc: function() {
  1464 + var oLp = _internalLpArray[0];
  1465 + var aMinBcIndex = oLp.getMinBcObjPosition();
  1466 + oLp.removeBc(aMinBcIndex[0], aMinBcIndex[1]);
  1467 +
  1468 + var aMaxBcIndex = oLp.getMaxBcObjPosition();
  1469 + if (oLp.getBc(aMaxBcIndex[0], aMaxBcIndex[1]).fnIsDelFlag()) {
  1470 + oLp.removeBc(aMaxBcIndex[0], aMaxBcIndex[1]);
  1471 + }
  1472 + },
  1473 +
  1474 + /**
  1475 + * 调整班次纵向间隔(发车时间调整)。
  1476 + * 1、只调整分班班次的发车时间
  1477 + * 2、调整每两个连班之间的分班班次组
  1478 + * 3、如果不是连续的班次才调整
  1479 + */
  1480 + fnAdjust_vertical_bc_interval: function() {
  1481 + var i;
  1482 + var j;
  1483 + var iBIndex = 0;
  1484 + var oLbGroup = {};
  1485 + var oLp;
  1486 + for (i = 0; i < _qCount; i++) {
  1487 + while (iBIndex <= 1) {
  1488 + oLbGroup[i + "_" + iBIndex] = [];
  1489 + for (j = 0; j < _internalLpArray.length; j++) {
  1490 + oLp = _internalLpArray[j];
  1491 + if (oLp.isBxLb()) {
  1492 + if (oLp.getBc(i, iBIndex)) {
  1493 + oLbGroup[i + "_" + iBIndex].push(j);
  1494 + }
  1495 + }
  1496 + }
  1497 + if (oLbGroup[i + "_" + iBIndex].length == 1) {
  1498 + oLbGroup[i + "_" + iBIndex] = [];
  1499 + }
  1500 +
  1501 + iBIndex ++;
  1502 + }
  1503 + iBIndex = 0;
  1504 + }
  1505 +
  1506 + //console.log(oLbGroup);
  1507 +
  1508 + var sKey;
  1509 + var iQindex;
  1510 + var iBindex;
  1511 + var aBcLb = [];
  1512 +
  1513 + var oLbGroup_m = {};
  1514 + var aLbGroup = [];
  1515 +
  1516 +
  1517 + // 计算需要调整的连班区间
  1518 + for (sKey in oLbGroup) {
  1519 + iQindex = sKey.split('_')[0];
  1520 + iBindex = sKey.split('_')[1];
  1521 + oLbGroup_m[sKey] = [];
  1522 + for (i = 0; i < oLbGroup[sKey].length - 1; i++) {
  1523 + aBcLb = [];
  1524 + for (j = oLbGroup[sKey][i] + 1; j <= oLbGroup[sKey][i + 1] - 1; j++) {
  1525 + oLp = _internalLpArray[j];
  1526 + if (oLp.getBc(iQindex, iBindex)) {
  1527 + aBcLb.push(j);
  1528 + }
  1529 + }
  1530 + if (aBcLb.length != 0 && aBcLb.length < (oLbGroup[sKey][i + 1] - oLbGroup[sKey][i] - 1)) {
  1531 + aLbGroup = [];
  1532 + aLbGroup.push(oLbGroup[sKey][i]);
  1533 + aLbGroup.push(oLbGroup[sKey][i + 1]);
  1534 + aLbGroup.push(aBcLb);
  1535 + oLbGroup_m[sKey].push(aLbGroup);
  1536 + }
  1537 + }
  1538 + }
  1539 +
  1540 + console.log(oLbGroup_m);
  1541 +
  1542 + var iStartLpIndex;
  1543 + var iEndLpIndex;
  1544 + var iDCount;
  1545 + var iDiffTime;
  1546 +
  1547 + var iC1;
  1548 + var iC2;
  1549 + var oKssj;
  1550 +
  1551 + for (sKey in oLbGroup_m) {
  1552 + iQindex = sKey.split('_')[0];
  1553 + iBindex = sKey.split('_')[1];
  1554 +
  1555 + for (i = 0; i < oLbGroup_m[sKey].length; i++) {
  1556 + aLbGroup = oLbGroup_m[sKey][i];
  1557 +
  1558 + iStartLpIndex = aLbGroup[0];
  1559 + iEndLpIndex = aLbGroup[1];
  1560 + iDCount = aLbGroup[2].length + 1;
  1561 +
  1562 + iDiffTime = _internalLpArray[iEndLpIndex].getBc(iQindex, iBindex).getFcTimeObj().diff(
  1563 + _internalLpArray[iStartLpIndex].getBc(iQindex, iBindex).getFcTimeObj(), 'm');
  1564 +
  1565 + iC1 = Math.floor(iDiffTime / iDCount);
  1566 + iC2 = iDiffTime % iDCount;
  1567 + oKssj = _internalLpArray[iStartLpIndex].getBc(iQindex, iBindex).getFcTimeObj();
  1568 +
  1569 + for (j = 1; j <= iDCount - iC2; j++) {
  1570 + if (j - 1 < aLbGroup[2].length) {
  1571 + oKssj = _paramObj.addMinute(oKssj, iC1);
  1572 + _internalLpArray[aLbGroup[2][j - 1]].getBc(
  1573 + iQindex, iBindex).setFcTimeObj(oKssj);
  1574 + }
  1575 + }
  1576 +
  1577 + for (j = 1; j < iC2; j++) {
  1578 + oKssj = _paramObj.addMinute(oKssj, iC1 + 1);
  1579 + _internalLpArray[aLbGroup[2][iDCount - iC2 + j - 1]].getBc(
  1580 + iQindex, iBindex).setFcTimeObj(oKssj);
  1581 + }
  1582 +
949 1583 }
950 1584 }
951   - console.log("5休2分班路牌indexes=" + _5_2_fbIndexes);
  1585 +
952 1586 },
953 1587  
954 1588 //------------- 其他方法 -------------//
955 1589 /**
956 1590 * 内部数据转化成显示用的班次数组。
957 1591 */
958   - toGanttBcArray: function() {
959   - var bcData = [];
960   - var lpObj;
  1592 + fnToGanttBcArray: function() {
  1593 + var aAllBc = [];
  1594 + var aLpBc = [];
  1595 + var oLp;
  1596 + var i;
  1597 + var j;
  1598 +
961 1599 for (i = 0; i < _internalLpArray.length; i++) {
962   - lpObj = _internalLpArray[i];
963   - bcData = bcData.concat(lpObj.getBcArray());
  1600 + oLp = _internalLpArray[i];
  1601 + aLpBc = [];
  1602 + aLpBc = aLpBc.concat(oLp.getOtherBcArray(), oLp.getBcArray());
  1603 + // 按照发车时间排序
  1604 + aLpBc.sort(function(o1, o2) {
  1605 + if (o1.getFcTimeObj().isBefore(o2.getFcTimeObj())) {
  1606 + return -1;
  1607 + } else {
  1608 + return 1;
  1609 + }
  1610 + });
  1611 +
  1612 + // 重新赋值fcno
  1613 + for (j = 0; j < aLpBc.length; j++) {
  1614 + aLpBc[j].fnSetFcno(j + 1);
  1615 + }
  1616 +
  1617 + aAllBc = aAllBc.concat(aLpBc);
964 1618 }
965 1619  
966   - var ganttBcData = [];
967   - for (i = 0; i < bcData.length; i++) {
968   - ganttBcData.push(bcData[i].toGanttBcObj());
  1620 + var aGanttBc = [];
  1621 + for (i = 0; i < aAllBc.length; i++) {
  1622 + aGanttBc.push(aAllBc[i].toGanttBcObj());
969 1623 }
970 1624  
971   - return ganttBcData;
  1625 + return aGanttBc;
972 1626 }
973 1627  
974   - // TODO:
975 1628 };
  1629 +
976 1630 };
977 1631 \ No newline at end of file
... ...
src/main/resources/static/pages/base/timesmodel/js/v2/main_v2.js
... ... @@ -2,6 +2,7 @@
2 2 * 主类。
3 3 */
4 4 var Main_v2 = function() {
  5 +
5 6 // 内部工厂类
6 7 var _factoryFun = function() {
7 8 return {
... ... @@ -14,20 +15,90 @@ var Main_v2 = function() {
14 15 // 创建班次对象
15 16 createBcObj: function(lpObj, bcType, isUp, fcno, fcTimeObj, paramObj) {
16 17 var _bclc = paramObj.calcuTravelLcNumber(isUp, bcType);
17   - var _bcsj = paramObj.calcuTravelTime(fcTimeObj, isUp);
18   - var _arrsj = paramObj.addMinute(fcTimeObj, _bcsj);
19   - var _stoptime = paramObj.calcuFixedStopNumber(_arrsj, !isUp);
  18 + var _fcsj = fcTimeObj;
  19 + var _bcsj = paramObj.calcuTravelTime(_fcsj, isUp);
  20 + var _arrsj = paramObj.addMinute(_fcsj, _bcsj);
  21 + var _stoptime = paramObj.fnCalcuFixedStopNumber(_arrsj, !isUp, _bcsj);
20 22 var _tccid = paramObj.getTTinfoId();
21 23 var _ttinfoid = paramObj.getTTinfoId();
22 24 var _xl = paramObj.getXlId();
23 25 var _qdz = isUp ? paramObj.getUpQdzObj().id : paramObj.getDownQdzObj().id;
24 26 var _zdz = isUp ? paramObj.getUpZdzObj().id : paramObj.getDownZdzObj().id;
25 27  
  28 + if (bcType == "bd") { // 早例保,传过来的发车时间是第一个班次的发车时间
  29 + if (isUp) { // 上行
  30 + _fcsj = paramObj.addMinute(
  31 + _fcsj,
  32 + -(paramObj.getUpOutTime() + paramObj.getLbTime()));
  33 + _bcsj = paramObj.getLbTime();
  34 + _arrsj = paramObj.addMinute(_fcsj, _bcsj);
  35 + _stoptime = 0;
  36 + } else { // 下行
  37 + _fcsj = paramObj.addMinute(
  38 + _fcsj,
  39 + -(paramObj.getDownOutTime() + paramObj.getLbTime()));
  40 + _bcsj = paramObj.getLbTime();
  41 + _arrsj = paramObj.addMinute(_fcsj, _bcsj);
  42 + _stoptime = 0;
  43 + }
  44 + } else if (bcType == "lc") { // 晚例保,传过来的发车时间是最后一个班次的到达时间
  45 + if (isUp) { // 上行
  46 + _fcsj = paramObj.addMinute(
  47 + _fcsj,
  48 + paramObj.getUpInTime());
  49 + _bcsj = paramObj.getLbTime();
  50 + _arrsj = paramObj.addMinute(_fcsj, _bcsj);
  51 + _stoptime = 0;
  52 + } else { // 下行
  53 + _fcsj = paramObj.addMinute(
  54 + _fcsj,
  55 + paramObj.getDownInTime());
  56 + _bcsj = paramObj.getLbTime();
  57 + _arrsj = paramObj.addMinute(_fcsj, _bcsj);
  58 + _stoptime = 0;
  59 + }
  60 + } else if (bcType == "out") { // 出场,传过来的发车时间是第一个班次的发车时间
  61 + if (isUp) { // 上行
  62 + _fcsj = paramObj.addMinute(
  63 + _fcsj,
  64 + -paramObj.getUpOutTime());
  65 + _bcsj = paramObj.getUpOutTime();
  66 + _arrsj = paramObj.addMinute(_fcsj, _bcsj);
  67 + _stoptime = 0;
  68 + } else { // 下行
  69 + _fcsj = paramObj.addMinute(
  70 + _fcsj,
  71 + -paramObj.getDownOutTime());
  72 + _bcsj = paramObj.getDownOutTime();
  73 + _arrsj = paramObj.addMinute(_fcsj, _bcsj);
  74 + _stoptime = 0;
  75 + }
  76 + } else if (bcType == "in") { // 进场,传过来的发车时间是最后一个班次的到达时间
  77 + if (isUp) { // 上行
  78 + _bcsj = paramObj.getUpInTime();
  79 + _arrsj = paramObj.addMinute(_fcsj, _bcsj);
  80 + _stoptime = 0;
  81 + } else { // 下行
  82 + _bcsj = paramObj.getDownInTime();
  83 + _arrsj = paramObj.addMinute(_fcsj, _bcsj);
  84 + _stoptime = 0;
  85 + }
  86 + } else if (bcType == "cf") { // 吃饭班次
  87 + // 以13:00为分界,之前的为午饭,之后的为晚饭
  88 + if (fcTimeObj.isBefore(paramObj.toTimeObj("13:00"))) {
  89 + _bcsj = paramObj.fnGetLunchTime();
  90 + } else {
  91 + _bcsj = paramObj.fnGetDinnerTime();
  92 + }
  93 + _arrsj = paramObj.addMinute(_fcsj, _bcsj);
  94 + _stoptime = 0;
  95 + }
  96 +
26 97 var bcParamObj = {};
27   - bcParamObj.bcType = bcType; // 班次类型(normal,in,out等)
  98 + bcParamObj.bcType = bcType; // 班次类型(normal,in_,out, bd, lc, cf等)
28 99 bcParamObj.isUp = isUp; // boolean是否上下行
29 100 bcParamObj.fcno = fcno; // 发车顺序号
30   - bcParamObj.fcTimeObj = fcTimeObj; // 发车时间对象
  101 + bcParamObj.fcTimeObj = _fcsj; // 发车时间对象
31 102 bcParamObj.bclc = _bclc; // 班次里程
32 103 bcParamObj.bcsj = _bcsj; // 班次历时
33 104 bcParamObj.arrtime = _arrsj; // 到达时间对象
... ... @@ -80,30 +151,41 @@ var Main_v2 = function() {
80 151  
81 152 // 1、初始化行车计划
82 153 var schedule = new InternalScheduleObj(_paramObj, lpArray, _factory);
83   - schedule.initDataWithBxLayout();
84   - // 2、计算每个路牌的班型及对应工时
85   - schedule.calcuLpBx_fg();
86   - // 3、将连班路牌的班次补足
87   - schedule.calcuLpBx_lb();
  154 + schedule.fnInitDataWithBxLayout();
  155 + // 2、将连班路牌的班次补足
  156 + schedule.fnCalcuLpBx_lb();
  157 +
  158 + // 3、修正针对初始化时生成的高峰班次,之前不足的补上,多余的删除
  159 + schedule.fnAdjustGfbc(true, true); // 修正上行早高峰
  160 + schedule.fnAdjustGfbc(true, false); // 修正下行早高峰
  161 + schedule.fnAdjustGfbc(false, true); // 修正上行晚高峰
  162 + schedule.fnAdjustGfbc(false, false); // 修正下行晚高峰
  163 +
  164 + // 4、按照车辆投入运营要求补充班次
  165 + schedule.fnCalcuLpBc_yy();
88 166  
89   - // 4、修正针对初始化时生成的高峰班次,之前不足的补上,多余的删除
90   - schedule.adjustGfbc(true, true); // 修正上行早高峰
91   - schedule.adjustGfbc(true, false); // 修正下行早高峰
92   - schedule.adjustGfbc(false, true); // 修正上行晚高峰
93   - schedule.adjustGfbc(false, false); // 修正下行晚高峰
  167 + // 5、根据班型补充所有的不足班次
  168 + schedule.fnCalcuLpBx_5_2();
  169 + schedule.fnCalcuLpBx_other();
94 170  
95   - // 5、TODO:根据班型补充所有的不足班次
96   - schedule.calcuLpBx_5_2();
  171 + // 6、补吃饭班次
  172 + schedule.fnCalcuEatBc();
97 173  
98   - // TODO:6、确定末班车
  174 + // 7、祛除有删除标记的班次
  175 + schedule.fnRemoveDelFlagBc();
99 176  
100   - // TODO:8、修正不准确的停站时间,微调发车间隔
  177 + // 8、调整纵向班次间隔
  178 + schedule.fnAdjust_vertical_bc_interval();
  179 + // TODO:横向调整
101 180  
102   - // TODO:9、补进出场报道班次
  181 + // 9、确定末班车
  182 + schedule.fnCalcuLastBc();
103 183  
  184 + // 10、补进出场例保班次
  185 + schedule.fnCalcuOtherBc();
104 186  
105 187 //-------------------- 输出ganut图上的班次,班型描述 ----------------------//
106   - var gBcData = schedule.toGanttBcArray();
  188 + var gBcData = schedule.fnToGanttBcArray();
107 189 // TODO:班型再议
108 190 return {'json':gBcData,'bxrcgs':null};
109 191  
... ...
src/main/resources/static/pages/base/timesmodel/js/v3/core/timetable_bc_obj.js 0 → 100644
  1 +/**
  2 + * 时刻表内部班次对象。
  3 + * @param iLpIndex 路牌索引
  4 + * @param iGroupIndex 圈索引
  5 + * @param oParam 其他参数对象
  6 + * @constructor
  7 + */
  8 +var TimeTableBc = function(
  9 + iLpIndex,
  10 + iGroupIndex,
  11 + oParam
  12 +) {
  13 + // 简单验证
  14 + if (isNaN(iLpIndex)) {
  15 + throw "new TimeTableBc 路牌索引" + iLpIndex + " 不是int";
  16 + }
  17 + if (isNaN(iGroupIndex)) {
  18 + throw "new TimeTableBc 圈索引" + iGroupIndex + " 不是int";
  19 + }
  20 + if (typeof oParam == "undefined") {
  21 + throw "new TimeTableBc 其他参数对象" + oParam + " 未定义";
  22 + }
  23 +
  24 + /** 路牌索引 */
  25 + this._$_iLpIndex = iLpIndex;
  26 + /** 圈索引 */
  27 + this._$_iGroupIndex = iGroupIndex;
  28 +
  29 + // 其他参数对象关联的内部参数
  30 +
  31 + /** 班次类型(normal,in,out等) */
  32 + this._$_sBcType = otherParamObj.bcType;
  33 + /** 是否上下行 */
  34 + this._$_bIsUp = otherParamObj.isUp;
  35 + /** 发车顺序号 */
  36 + this._$_iFcno = otherParamObj.fcno;
  37 + /** 发车时间对象 */
  38 + this._$_oFcsjObj = moment(otherParamObj.fcTimeObj);
  39 + /** 班次里程 */
  40 + this._$_flBclc = otherParamObj.bclc;
  41 + /** 班次历时 */
  42 + this._$_iBcsj = otherParamObj.bcsj;
  43 + /** 到达时间对象 */
  44 + this._$_oArrtime = otherParamObj.arrtime;
  45 + /** 停站时间 */
  46 + this._$_iStoptime = otherParamObj.stoptime;
  47 + /** 停车场id */
  48 + this._$_iTccid = otherParamObj.tccid;
  49 + /** 时刻表id */
  50 + this._$_iTtinfoid = otherParamObj.ttinfoid;
  51 + /** 线路id */
  52 + this._$_iXlid = otherParamObj.xl;
  53 + /** 起点站id */
  54 + this._$_iQdzid = otherParamObj.qdzid;
  55 + /** 终点站id */
  56 + this._$_iZdzid = otherParamObj.zdzid;
  57 +
  58 +};
  59 +
  60 +// TODO
0 61 \ No newline at end of file
... ...
src/main/resources/static/pages/base/timesmodel/js/v3/core/timetable_group_obj.js 0 → 100644
  1 +
  2 +// TODO
  3 +var TimeTableGroup = function() {
  4 +
  5 + /** 一圈几个班次(2个) */
  6 + this._$_iUnitBcCount = 2;
  7 + /** 是否上行(指圈的第一个班次是否上行) */
  8 + this._$_bIsUp;
  9 +
  10 + /** 圈组的开始时间(初始化一般由上标线确定,如:06:00,开始时间计算时是闭区间) */
  11 + this._$_oUnitGroupStartTime;
  12 + /** 圈组的结束时间(初始化一般由上标线确定,如:08:41,结束时间计算时是开区间) */
  13 + this._$_oUnitGroupEndTime;
  14 +
  15 + /** 圈组里圈班次可能的总数目(初始化确定,有几个路牌,一个圈组就有几圈-纵向看) */
  16 + this._$_iAllUnitCount;
  17 + /** 圈组里所有可能班次数组(二维数组,行一班表示有几个路牌,列就表示一圈2个班次) */
  18 + this._$_aAllUnitBces = new Array(this._$_iAllUnitBcCount, this._$_iUnitBcCount);
  19 +
  20 + /** 圈组里每圈之间的发车间隔值数组(第一个间隔为0,上下行一样) */
  21 + this._$_aUnitIntervalTime = new Array(this._$_iAllUnitCount);
  22 +
  23 + // TODO
  24 +};
  25 +
  26 +// TODO
0 27 \ No newline at end of file
... ...
src/main/resources/static/pages/base/timesmodel/js/v3/core/timetable_lp_obj.js 0 → 100644
  1 +
  2 +
  3 +// TODO
  4 +var TimeTableLp = function() {
  5 +
  6 + /** 班次可能的总数目(初始化确定) */
  7 + this._$_iAllBcCount;
  8 + /** 所有可能班次数组 */
  9 + this._$_aAllBces = new Array(this._$_iAllBcCount);
  10 +
  11 + /** 车次链的个数 */
  12 + this._$_iBcChainCount;
  13 + /** 车次链数组(每个车次链又是一个数组) */
  14 + this._$_aBcChaines;
  15 +
  16 + // TODO
  17 +};
  18 +
  19 +// TODO
0 20 \ No newline at end of file
... ...
src/main/resources/static/pages/base/timesmodel/js/v3/core/timetable_schedule_obj.js 0 → 100644
src/main/resources/static/pages/base/timesmodel/js/v3/main.js 0 → 100644
src/main/resources/static/pages/base/timesmodel/js/v3/param/param_wrap.js 0 → 100644
src/main/resources/static/pages/forms/calc/statisticsDaily.html 0 → 100644
  1 +<style type="text/css">
  2 + .table-bordered {
  3 + border: 1px solid; }
  4 + .table-bordered > thead > tr > th,
  5 + .table-bordered > thead > tr > td,
  6 + .table-bordered > tbody > tr > th,
  7 + .table-bordered > tbody > tr > td,
  8 + .table-bordered > tfoot > tr > th,
  9 + .table-bordered > tfoot > tr > td {
  10 + border: 1px solid; }
  11 + .table-bordered > thead > tr > th,
  12 + .table-bordered > thead > tr > td {
  13 + border-bottom-width: 2px; }
  14 +
  15 + .table > tbody + tbody {
  16 + border-top: 1px solid; }
  17 +
  18 + #forms > thead > tr> td >span{
  19 + width: 5px;
  20 + word-wrap: break-word;
  21 + letter-spacing: 20px;
  22 + }
  23 +
  24 + #forms > thead > tr> td >label{
  25 + word-break: keep-all;white-space:nowrap;
  26 + }
  27 +</style>
  28 +
  29 +<div class="page-head">
  30 + <div class="page-title">
  31 + <h1>统计日报</h1>
  32 + </div>
  33 +</div>
  34 +
  35 +<!-- <div class="row"> -->
  36 + <div class="col-md-12 portlet light porttlet-fit bordered" style="height:calc(100% - 56px)">
  37 +<!-- <div> -->
  38 + <div class="portlet-title">
  39 + <form class="form-inline" action="">
  40 + <div style="display: inline-block; " id="gsdmDiv">
  41 + <span class="item-label" style="width: 80px;">公司: </span>
  42 + <select class="form-control" name="company" id="gsdm" style="width: 180px;"></select>
  43 + </div>
  44 + <div style="display: inline-block; margin-left: 29px;" id="fgsdmDiv">
  45 + <span class="item-label" style="width: 80px;">分公司: </span>
  46 + <select class="form-control" name="subCompany" id="fgsdm" style="width: 180px;"></select>
  47 + </div>
  48 + <div style="margin-top: 2px"></div>
  49 + <div style="display: inline-block;">
  50 + <span class="item-label" style="width: 80px;">线路: </span>
  51 + <select class="form-control" name="line" id="line" style="width: 180px;"></select>
  52 + </div>
  53 + <div style="display: inline-block;margin-left: 15px;">
  54 + <span class="item-label" style="width: 80px;">开始时间: </span>
  55 + <input class="form-control" type="text" id="date" style="width: 180px;"/>
  56 + </div>
  57 + <div style="display: inline-block;margin-left: 15px;">
  58 + <span class="item-label" style="width: 80px;">结束时间: </span>
  59 + <input class="form-control" type="text" id="date2" style="width: 180px;"/>
  60 + </div>
  61 + <div class="form-group">
  62 + <input class="btn btn-default" type="button" id="query" value="查询"/>
  63 + <input class="btn btn-default" type="button" id="export" value="导出"/>
  64 + </div>
  65 + </form>
  66 + </div>
  67 + <div class="portlet-body" id="tjrbBody" style="overflow:auto;height: calc(100% - 80px)">
  68 + <div class="table-container" style="margin-top: 10px;min-width: 906px">
  69 + <label>早高峰:6:31~8:30&nbsp;&nbsp;&nbsp;&nbsp;晚高峰:16:01~18:00</label>
  70 + <table class="table table-bordered table-hover table-checkable" id="forms">
  71 + <thead>
  72 + <tr>
  73 + <th colspan="44"><label id="tjrq"></label> 线路统计日报</th>
  74 + </tr>
  75 + <tr>
  76 + <td rowspan="3"><span >路线名</span></td>
  77 + <td colspan="20">全日营运里程(公里)</td>
  78 + <td colspan="15">全日营运班次</td>
  79 + <td colspan="9">大间隔情况</td>
  80 + </tr>
  81 + <tr>
  82 + <td rowspan="2"><label>计划总</label>
  83 + <label>公里&nbsp;&nbsp;&nbsp;</label></td>
  84 + <td rowspan="2"><label>计划营</label><label>运公里</label></td>
  85 + <td rowspan="2"><label>计划空</label><label>驶公里</label></td>
  86 + <td rowspan="2"><label>实际</label><label>总公里</label></td>
  87 + <td rowspan="2"><label>实际营</label><label>运公里</label></td>
  88 + <td rowspan="2"><label>实际空</label><label>驶公里</label></td>
  89 + <td rowspan="2"><span>少驶公里</span></td>
  90 + <td rowspan="2"><span>少驶班次</span></td>
  91 + <td colspan="11">少驶原因(公里)</td>
  92 + <td rowspan="2"><span >临加公里</span></td>
  93 + <td colspan="3">计划班次</td>
  94 + <td colspan="3">实际班次</td>
  95 + <td colspan="3">临加班次</td>
  96 + <td colspan="3">放站班次</td>
  97 + <td colspan="3">调头班次</td>
  98 + <td colspan="3">发生次数</td>
  99 + <td rowspan="2">最大间隔时间(分)</td>
  100 + <td rowspan="2">原因</td>
  101 + </tr>
  102 + <tr>
  103 + <td><span >路阻</span></td>
  104 + <td><span>吊慢</span></td>
  105 + <td><span >故障</span></td>
  106 + <td><span >纠纷</span></td>
  107 + <td><span >肇事</span></td>
  108 + <td><span>缺人</span></td>
  109 + <td><span>缺车</span></td>
  110 + <td><span >客稀</span></td>
  111 + <td><span>气候</span></td>
  112 + <td><span>援外</span></td>
  113 + <td><span>其他</span></td>
  114 + <td><span>全日</span></td>
  115 + <td><span>早高峰</span></td>
  116 + <td><span>晚高峰</span></td>
  117 + <td><span>全日</span></td>
  118 + <td><span>早高峰</span></td>
  119 + <td><span>晚高峰</span></td>
  120 + <td><span>全日</span></td>
  121 + <td><span>早高峰</span></td>
  122 + <td><span>晚高峰</span></td>
  123 + <td><span>全日</span></td>
  124 + <td><span>早高峰</span></td>
  125 + <td><span>晚高峰</span></td>
  126 + <td><span>全日</span></td>
  127 + <td><span>早高峰</span></td>
  128 + <td><span>晚高峰</span></td>
  129 + <td><span>全日</span></td>
  130 + <td><span>早高峰</span></td>
  131 + <td><span>晚高峰</span></td>
  132 + </tr>
  133 + </thead>
  134 + <tbody class="statisticsDaily">
  135 +
  136 + </tbody>
  137 + </table>
  138 + </div>
  139 + </div>
  140 + </div>
  141 + </div>
  142 +</div>
  143 +
  144 +<script>
  145 + $(function(){
  146 + $('#export').attr('disabled', "true");
  147 +
  148 + // 关闭左侧栏
  149 + if (!$('body').hasClass('page-sidebar-closed'))
  150 + $('.menu-toggler.sidebar-toggler').click();
  151 +
  152 + var d = new Date();
  153 + d.setTime(d.getTime() - 1*1000*60*60*24);
  154 + var year = d.getFullYear();
  155 + var month = d.getMonth() + 1;
  156 + var day = d.getDate();
  157 + if(month < 10)
  158 + month = "0" + month;
  159 + if(day < 10)
  160 + day = "0" + day;
  161 + var dateTime = year + "-" + month + "-" + day;
  162 + $("#date").datetimepicker({
  163 + format : 'YYYY-MM-DD',
  164 + locale : 'zh-cn',
  165 + maxDate : dateTime
  166 + });
  167 + $("#date2").datetimepicker({
  168 + format : 'YYYY-MM-DD',
  169 + locale : 'zh-cn',
  170 + maxDate : dateTime
  171 + });
  172 + $("#date").val(dateTime);
  173 + $("#date2").val(dateTime);
  174 +
  175 +
  176 + var fage=false;
  177 + var obj = [];
  178 + var xlList;
  179 + $.get('/report/lineList',function(result){
  180 + xlList=result;
  181 + $.get('/user/companyData', function(result){
  182 + obj = result;
  183 + var options = '';
  184 + for(var i = 0; i < obj.length; i++){
  185 + options += '<option value="'+obj[i].companyCode+'">'+obj[i].companyName+'</option>';
  186 + }
  187 +
  188 + if(obj.length ==0){
  189 + $("#gsdmDiv").css('display','none');
  190 + }else if(obj.length ==1){
  191 + $("#gsdmDiv").css('display','none');
  192 + if(obj[0].children.length == 1 || obj[0].children.length ==0)
  193 + $('#fgsdmDiv').css('display','none');
  194 + }
  195 + $('#gsdm').html(options);
  196 + updateCompany();
  197 + });
  198 + })
  199 + $("#gsdm").on("change",updateCompany);
  200 + function updateCompany(){
  201 + var company = $('#gsdm').val();
  202 + var options = '';
  203 + for(var i = 0; i < obj.length; i++){
  204 + if(obj[i].companyCode == company){
  205 + var children = obj[i].children;
  206 + for(var j = 0; j < children.length; j++){
  207 + options += '<option value="'+children[j].code+'">'+children[j].name+'</option>';
  208 + }
  209 + }
  210 + }
  211 + $('#fgsdm').html(options);
  212 +// initXl();
  213 + }
  214 +
  215 + var tempData = {};
  216 + $.get('/report/lineList',function(xlList){
  217 + var data = [];
  218 + data.push({id: " ", text: "全部线路"});
  219 + $.get('/user/companyData', function(result){
  220 + for(var i = 0; i < result.length; i++){
  221 + var companyCode = result[i].companyCode;
  222 + var children = result[i].children;
  223 + for(var j = 0; j < children.length; j++){
  224 + var code = children[j].code;
  225 + for(var k=0;k < xlList.length;k++ ){
  226 + if(xlList[k]["fgsbm"]==code && xlList[k]["gsbm"]==companyCode){
  227 + data.push({id: xlList[k]["xlbm"], text: xlList[k]["xlname"]});
  228 + tempData[xlList[k]["xlbm"]] = companyCode+":"+code;
  229 + }
  230 + }
  231 + }
  232 + }
  233 + initPinYinSelect2('#line',data,'');
  234 +
  235 + });
  236 + });
  237 +
  238 + $("#line").on("change", function(){
  239 + if($("#line").val() == " "){
  240 + $("#gsdm").attr("disabled", false);
  241 + $("#fgsdm").attr("disabled", false);
  242 + } else {
  243 + var temp = tempData[$("#line").val()].split(":");
  244 + $("#gsdm").val(temp[0]);
  245 + updateCompany();
  246 + $("#fgsdm").val(temp[1]);
  247 + $("#gsdm").attr("disabled", true);
  248 + $("#fgsdm").attr("disabled", true);
  249 + }
  250 + });
  251 +
  252 +
  253 + var line ="";
  254 + var xlName ="";
  255 + var date = "";
  256 + var date2 ="";
  257 + var gsdm="";
  258 + var fgsdm="";
  259 + $("#query").on("click",function(){
  260 + if($("#date").val() == null || $("#date").val().trim().length == 0){
  261 + layer.msg("请选择时间范围!");
  262 + return;
  263 + }
  264 + if($("#date2").val() == null || $("#date2").val().trim().length == 0){
  265 + layer.msg("请选择时间范围!");
  266 + return;
  267 + }
  268 +// $("#tjrbBody").height($(window).height()-100);
  269 + line = $("#line").val();
  270 + xlName = $("#select2-line-container").html();
  271 + date = $("#date").val();
  272 + date2 =$("#date2").val();
  273 + gsdm =$("#gsdm").val();
  274 + fgsdm=$("#fgsdm").val();
  275 + if(line=="请选择"){
  276 + line="";
  277 + }
  278 + if(date==null || date =="" ||date2==null || date2 ==""){
  279 + layer.msg('请选择时间段.');
  280 + }else{
  281 + $("#tjrq").html(date+"至"+date2);
  282 + var params = {};
  283 + params['gsdm'] = gsdm;
  284 + params['fgsdm'] =fgsdm ;
  285 + params['line'] = line;
  286 + params['date'] = date;
  287 + params['date2'] = date2;
  288 + params['xlName'] = xlName;
  289 + params['type'] = "query";
  290 + $get('/calcWaybill/statisticsDailyTj',params,function(result){
  291 + // 把数据填充到模版中
  292 + var tbodyHtml = template('statisticsDaily',{list:result});
  293 + // 把渲染好的模版html文本追加到表格中
  294 + $('#forms .statisticsDaily').html(tbodyHtml);
  295 +
  296 + if(result.length == 0)
  297 + $("#export").attr('disabled',"true");
  298 + else
  299 + $("#export").removeAttr("disabled");
  300 + });
  301 + }
  302 +
  303 + });
  304 +// $("#tjrbBody").height($(window).height()-100);
  305 + $("#export").on("click",function(){
  306 + var params = {};
  307 + params['gsdm'] = gsdm;
  308 + params['fgsdm'] =fgsdm ;
  309 + params['line'] = line;
  310 + params['date'] = date;
  311 + params['date2'] = date2;
  312 + params['xlName'] = xlName;
  313 + params['type'] = "export";
  314 + $get('/realSchedule/statisticsDailyTj',params,function(result){
  315 + window.open("/downloadFile/download?fileName=统计日报"+moment(date).format("YYYYMMDD"));
  316 + });
  317 + });
  318 +
  319 + });
  320 +</script>
  321 +<script type="text/html" id="statisticsDaily">
  322 + {{each list as obj i}}
  323 + <tr {{if obj.zt==1}}style='color: red'{{/if}}>
  324 + <td>{{obj.xlName}}</td>
  325 + <td>{{obj.jhzlc}}</td>
  326 + <td>{{obj.jhlc}}</td>
  327 + <td>{{obj.jcclc}}</td>
  328 + <td>{{obj.sjzgl}}</td>
  329 + <td>{{obj.sjgl}}</td>
  330 + <td>{{obj.sjksgl}}</td>
  331 + <td>{{obj.ssgl}}</td>
  332 + <td>{{obj.ssbc}}</td>
  333 + <td>{{obj.ssgl_lz}}</td>
  334 + <td>{{obj.ssgl_dm}}</td>
  335 + <td>{{obj.ssgl_gz}}</td>
  336 + <td>{{obj.ssgl_jf}}</td>
  337 + <td>{{obj.ssgl_zs}}</td>
  338 + <td>{{obj.ssgl_qr}}</td>
  339 + <td>{{obj.ssgl_qc}}</td>
  340 + <td>{{obj.ssgl_kx}}</td>
  341 + <td>{{obj.ssgl_qh}}</td>
  342 + <td>{{obj.ssgl_yw}}</td>
  343 + <td>{{obj.ssgl_other}}</td>
  344 + <td>{{obj.ljgl}}</td>
  345 + <td>{{obj.jhbc}}</td>
  346 + <td>{{obj.jhbc_m}}</td>
  347 + <td>{{obj.jhbc_a}}</td>
  348 + <td>{{obj.sjbc}}</td>
  349 + <td>{{obj.sjbc_m}}</td>
  350 + <td>{{obj.sjbc_a}}</td>
  351 + <td>{{obj.ljbc}}</td>
  352 + <td>{{obj.ljbc_m}}</td>
  353 + <td>{{obj.ljbc_a}}</td>
  354 + <td>{{obj.fzbc}}</td>
  355 + <td>{{obj.fzbc_m}}</td>
  356 + <td>{{obj.fzbc_a}}</td>
  357 + <td>{{obj.dtbc}}</td>
  358 + <td>{{obj.dtbc_m}}</td>
  359 + <td>{{obj.dtbc_a}}</td>
  360 + <td>{{obj.djg}}</td>
  361 + <td>{{obj.djg_m}}</td>
  362 + <td>{{obj.djg_a}}</td>
  363 + <td>{{obj.djg_time}}</td>
  364 + <td>&nbsp;</td>
  365 + </tr>
  366 + {{/each}}
  367 + {{if list.length == 0}}
  368 + <tr>
  369 + <td colspan="44"><h6 class="muted">没有找到相关数据</h6></td>
  370 + </tr>
  371 + {{/if}}
  372 +</script>
0 373 \ No newline at end of file
... ...
src/main/resources/static/pages/forms/statement/commandState.html
... ... @@ -41,8 +41,8 @@
41 41 <select class="form-control" name="line" id="line" style="width: 180px;"></select>
42 42 </div>
43 43  
44   - <div style="display: inline-block;margin-left: 15px;">
45   - <span class="item-label" style="width: 80px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;时间: </span>
  44 + <div style="display: inline-block;margin-left: 36px;">
  45 + <span class="item-label" style="width: 80px;">时间: </span>
46 46 <input class="form-control" type="text" id="date" style="width: 180px;"/>
47 47 </div>
48 48 <div style="display:none;margin-left: 8px">
... ...
src/main/resources/static/real_control_v2/js/utils/svg_data_convert.js
... ... @@ -4,188 +4,170 @@ var gb_svg_data_convert = (function () {
4 4 * 合并上下行路由
5 5 * type 0 上行 1 下行 2 同名合并 3 异名合并
6 6 *
7   - * 因为基础的数据的各种奇葩搞法,这块打了很多补丁,有时间一定要重写
8   - *
9 7 * enableAttr: 是否启用配置信息
10 8 */
11   - function mergeRoute(routes, enableAttr, lineCode, loopLine) {
  9 + function mergeRoute(rs, enableAttr, lineCode, loopLine) {
12 10 //按上下行拆分
13   - routes = gb_common.groupBy(routes, 'directions');
14   - var up = routes[0],
15   - down = routes[1];
  11 + rs = gb_common.groupBy(rs, 'directions');
16 12 //排序
17   - up.sort(upSort);
18   - down.sort(downSort);
19   - var data = [];
20   -
21   - //根据配置处理一下数据
22   - if (enableAttr) {
23   - var svgAttr = gb_data_basic.getSvgAttr(lineCode);
24   - if (svgAttr) {
25   - up = filterByAttrs(svgAttr, up);
26   - down = filterByAttrs(svgAttr, down);
27   - }
28   - }
29   -
30   - //环线 只画上行
31   - if(loopLine){
32   - for (var j = 0; j < up.length; j++) {
33   - var upS = nvl_get(up, j);
34   - op = {
35   - name: [upS.stationName],
36   - id: [get_station_code(upS)],
37   - type: 0,
38   - stationMark: upS.stationMark
39   - };
40   - data.push(op);
  13 + sort_station_route(rs);
  14 + //模拟图配置信息
  15 + use_chart_config(enableAttr, lineCode, rs);
  16 +
  17 + if(loopLine)
  18 + rs[1]=[];
  19 + //一个萝卜一个坑
  20 + data = putTurnip(rs[0], rs[1]);
  21 + return data;
  22 + }
  23 +
  24 + var putTurnip = function (arr1, arr2) {
  25 + var data = [], a1, a2;
  26 + for(var i = 0; i < 888; i ++){
  27 + a1=arr1[i];
  28 + a2=arr2[i];
  29 + if(null != a1 && null != a2 && a1.stationName!=a2.stationName) {
  30 + //arr2 包含 a1
  31 + var ii = name_indexOf(a1, arr2);
  32 + if(ii > i){
  33 + fill_arr(arr1, i, ii - i);
  34 + i-=1;
  35 + continue;
  36 + }
  37 + //arr1 包含 a2
  38 + ii = name_indexOf(a2, arr1);
  39 + if(ii > i){
  40 + fill_arr(arr2, i, ii - i);
  41 + i-=1;
  42 + continue;
  43 + }
41 44 }
42 45  
43   - //上下行GPS容器
44   - $.each(data, function () {
45   - this.gpsUps = [];
46   - this.gpsDowns = [];
47   - });
48   -
49   - return data;
  46 + if(null==a1 && null==a2)
  47 + break;
  48 + merge(data, i, a1, a2);
50 49 }
51 50  
  51 + return data;
  52 + };
  53 +
  54 + var fill_arr = function (array, i, size) {
  55 + for(var j=0; j < size; j++){
  56 + array.splice(j + i, 0, null);
  57 + }
  58 + };
52 59  
53   - //同名站点合并
54   - for (var j = 0; j < up.length; j++) {
55   - var upS = nvl_get(up, j),
56   - downS = nvl_get(down, j),
57   - op = {
58   - name: [upS.stationName],
59   - id: [get_station_code(upS), get_station_code(downS)],
60   - type: 2,
61   - stationMark: upS.stationMark//站点标记
62   - };
63   -
64   - if (upS.stationName != downS.stationName) {
65   - //下行站点在上行路由中是否存在
66   - var dIndex = station_indexof(down, upS, j);
67   - //上行站点在下行路由中是否存在
68   - var uIndex = station_indexof(up, downS, j);
69   - if (dIndex == -1 || dIndex - j > 4) {
70   - if (uIndex == -1 && dIndex - j < 4) {
71   - op.type = 3;
72   - op.name = [upS.stationName, downS.stationName];
73   - }
74   - else {
75   - op.type = 0;
76   - op.id = [get_station_code(upS), -1];
77   - //占位
78   - down.splice(j, 0, {});
79   - }
80   - } else {
81   - for (var t = j; t < dIndex - 1; t++) {
82   - var temp = down[t];
83   - data.push({
84   - name: [temp.stationName],
85   - type: 1,
86   - id: [get_station_code(temp)]
87   - });
88   - }
89   - //delete
90   - down.splice(j, dIndex - 1 - j);
91   - j--;
92   - continue;
93   - }
  60 + var merge = function (array, i, a1, a2) {
  61 + array.splice(i, 1, createItem(a1, a2));
  62 + };
  63 +
  64 + var createItem = function (up, down) {
  65 + if(null==up && null==down)
  66 + return null;
  67 +
  68 + var names, type=2,ids,mark;
  69 + if(null==up){
  70 + type=1;
  71 + names=[down.stationName];
  72 + ids=[get_station_code(down)];
  73 + mark=down.stationMark;
  74 + }
  75 + else if(null==down) {
  76 + type=0;
  77 + names=[up.stationName];
  78 + ids=[get_station_code(up)];
  79 + mark=up.stationMark;
  80 + }
  81 + else{
  82 + names=[up.stationName];
  83 + ids=[get_station_code(up), get_station_code(down)];
  84 + mark=up.stationMark;
  85 + if(up.stationName!=down.stationName){
  86 + type=3;
  87 + names.push(down.stationName);
94 88 }
95   - data.push(op);
96 89 }
  90 + return {
  91 + name: names,
  92 + id: ids,
  93 + type: type,
  94 + stationMark: mark
  95 + };
  96 + };
97 97  
98   - //将上下行挨着的异名站点合并
99   - var len = data.length - 1,
100   - first, sec;
101   - for (var s = 0; s < len; s++) {
102   - first = data[s];
103   - sec = data[s + 1];
104   -
105   - if (first.type == 0 &&
106   - sec.type == 1) {
107   - data.splice(s, 2, {
108   - name: [first['name'][0], sec['name'][0]],
109   - type: 3,
110   - id: [first['id'][0], sec['id'][0]]
111   - });
112   - len--;
113   - } else if (first.type == 1 && sec.type == 0) {
114   - data.splice(s, 2, {
115   - name: [first['name'][0], sec['name'][0]],
116   - type: 3,
117   - id: [first['id'][0], sec['id'][0]]
118   - });
119   - len--;
120   - }
  98 + var name_indexOf = function (a1, arr) {
  99 + for(var j=0,len=arr.length;j<len;j++){
  100 + if(null != arr[j] && a1.stationName==arr[j].stationName)
  101 + return j;
121 102 }
  103 + return -1;
  104 + };
122 105  
123   - //上下行GPS容器
124   - $.each(data, function () {
125   - this.gpsUps = [];
126   - this.gpsDowns = [];
127   - });
128   - return data;
  106 + var get_station_code = function (s) {
  107 + return s.stationCode + '_' + s.directions;
129 108 };
130 109  
131   - var filterByAttrs = function (svgAttr, routes) {
132   - var hideStations = svgAttr.hideStations ? svgAttr.hideStations : [];
133   - var nicknames = svgAttr.nicknames ? svgAttr.nicknames : {};
134   - var stationCode;
135   - $.each(routes, function (i) {
136   - stationCode = this.stationCode
137   - //要隐藏的站点
138   - $.each(hideStations, function (j, hide) {
139   - if (stationCode == hide)
140   - delete routes[i];
141   - });
142   -
143   - //要重命名的站点
144   - if (nicknames[this.stationName]) {
145   - this.stationName = nicknames[this.stationName];
  110 + var use_chart_config = function (isEnable, lineCode, rs) {
  111 + if (isEnable) {
  112 + var config = gb_data_basic.getSvgAttr(lineCode);
  113 + if (config) {
  114 + rs[0] = filterByAttr(config, rs[0]);
  115 + rs[1] = filterByAttr(config, rs[1]);
146 116 }
147   - });
148   -
  117 + }
  118 + //路由首尾标记一下
  119 + rs[0][0].stationMark='B';
  120 + rs[0][rs[0].length-1].stationMark='E';
  121 + rs[1][0].stationMark='B';
  122 + rs[1][rs[1].length-1].stationMark='E';
  123 + };
  124 +
  125 + var filterByAttr = function (svgAttr, rs) {
  126 + var hsArray = svgAttr.hideStations ? svgAttr.hideStations : [];
  127 + var nsArray = svgAttr.nicknames ? svgAttr.nicknames : {};
149 128 var newRoutes = [];
150   - $.each(routes, function (i, station) {
151   - if(station)
152   - newRoutes.push(station);
153   - });
154 129  
  130 + for (var i = 0, s; s = rs[i++];) {
  131 + if (isHidden(s.stationCode, hsArray))
  132 + continue;
  133 +
  134 + if (nsArray[s.stationName])
  135 + s.stationName = nsArray[s.stationName];
  136 +
  137 + newRoutes.push(s);
  138 + }
155 139 return newRoutes;
156 140 };
157 141  
158   - var upSort = function (a, b) {
159   - return a.stationRouteCode - b.stationRouteCode;
160   - };
  142 + var isHidden = function (code, array) {
  143 + for (var i = 0, temp; temp = array[i++];) {
  144 + if (code == temp)
  145 + return true;
  146 + }
161 147  
162   - var downSort = function (a, b) {
163   - return b.stationRouteCode - a.stationRouteCode;
  148 + return false;
164 149 };
165 150  
166   - var station_indexof = function (array, station, start) {
167   - var res = -1;
168   - for (var i = start, obj; obj = array[i++];) {
169   - if (obj.stationName == station.stationName) {
170   - res = i;
171   - break;
172   - }
  151 + var sort_station_route = function (routes) {
  152 + try{
  153 + routes[0].sort(upSort);
  154 + routes[1].sort(downSort);
  155 + }catch (e){
  156 + console.log(e);
  157 + notify_err('有站点路由数据异常!');
173 158 }
174   - return res;
175 159 };
176 160  
177   - var get_station_code = function (station) {
178   - return station.stationCode + '_' + station.directions;
  161 + var upSort = function (a, b) {
  162 + return a.stationRouteCode - b.stationRouteCode;
179 163 };
180 164  
181   - var nvl_get = function (list, index) {
182   - return list[index] == null ? {} : list[index];
  165 + var downSort = function (a, b) {
  166 + return b.stationRouteCode - a.stationRouteCode;
183 167 };
184 168  
185 169 var groupByStationAndUpdown = function (data) {
186   - //gb_common.groupBy(data, 'stopNo')
187   - var rs = {},
188   - key;
  170 + var rs = {}, key;
189 171 $.each(data, function () {
190 172 key = this['stopNo'] + '_' + this['upDown'];
191 173 if (!rs[key])
... ...
src/main/resources/static/real_control_v2/js/utils/svg_data_convert_bf.js 0 → 100644
  1 +var gb_svg_data_convert = (function () {
  2 +
  3 + /**
  4 + * 合并上下行路由
  5 + * type 0 上行 1 下行 2 同名合并 3 异名合并
  6 + *
  7 + * enableAttr: 是否启用配置信息
  8 + */
  9 + function mergeRoute(routes, enableAttr, lineCode, loopLine) {
  10 + console.log('routesroutes', routes);
  11 + //按上下行拆分
  12 + routes = gb_common.groupBy(routes, 'directions');
  13 + var up = routes[0],
  14 + down = routes[1];
  15 + //排序
  16 + up.sort(upSort);
  17 + down.sort(downSort);
  18 + var data = [];
  19 +
  20 + //根据配置处理一下数据
  21 + if (enableAttr) {
  22 + var svgAttr = gb_data_basic.getSvgAttr(lineCode);
  23 + if (svgAttr) {
  24 + up = filterByAttrs(svgAttr, up);
  25 + down = filterByAttrs(svgAttr, down);
  26 + }
  27 + }
  28 +
  29 + //环线 只画上行
  30 + if(loopLine){
  31 + for (var j = 0; j < up.length; j++) {
  32 + var upS = nvl_get(up, j);
  33 + op = {
  34 + name: [upS.stationName],
  35 + id: [get_station_code(upS)],
  36 + type: 0,
  37 + stationMark: upS.stationMark
  38 + };
  39 + data.push(op);
  40 + }
  41 +
  42 + //上下行GPS容器
  43 + $.each(data, function () {
  44 + this.gpsUps = [];
  45 + this.gpsDowns = [];
  46 + });
  47 +
  48 + return data;
  49 + }
  50 +
  51 +
  52 + //同名站点合并
  53 + for (var j = 0; j < up.length; j++) {
  54 + var upS = nvl_get(up, j),
  55 + downS = nvl_get(down, j),
  56 + op = {
  57 + name: [upS.stationName],
  58 + id: [get_station_code(upS), get_station_code(downS)],
  59 + type: 2,
  60 + stationMark: upS.stationMark//站点标记
  61 + };
  62 +
  63 + if (upS.stationName != downS.stationName) {
  64 + //下行站点在上行路由中是否存在
  65 + var dIndex = station_indexof(down, upS, j);
  66 + //上行站点在下行路由中是否存在
  67 + var uIndex = station_indexof(up, downS, j);
  68 + if (dIndex == -1 || dIndex - j > 4) {
  69 + if (uIndex == -1 && dIndex - j < 4) {
  70 + op.type = 3;
  71 + op.name = [upS.stationName, downS.stationName];
  72 + }
  73 + else {
  74 + op.type = 0;
  75 + op.id = [get_station_code(upS), -1];
  76 + //占位
  77 + down.splice(j, 0, {});
  78 + }
  79 + } else {
  80 + for (var t = j; t < dIndex - 1; t++) {
  81 + var temp = down[t];
  82 + data.push({
  83 + name: [temp.stationName],
  84 + type: 1,
  85 + id: [get_station_code(temp)]
  86 + });
  87 + }
  88 + //delete
  89 + down.splice(j, dIndex - 1 - j);
  90 + j--;
  91 + continue;
  92 + }
  93 + }
  94 + data.push(op);
  95 + }
  96 +
  97 + //将上下行挨着的异名站点合并
  98 + var len = data.length - 1,
  99 + first, sec;
  100 + for (var s = 0; s < len; s++) {
  101 + first = data[s];
  102 + sec = data[s + 1];
  103 +
  104 + if (first.type == 0 &&
  105 + sec.type == 1) {
  106 + data.splice(s, 2, {
  107 + name: [first['name'][0], sec['name'][0]],
  108 + type: 3,
  109 + id: [first['id'][0], sec['id'][0]]
  110 + });
  111 + len--;
  112 + } else if (first.type == 1 && sec.type == 0) {
  113 + data.splice(s, 2, {
  114 + name: [first['name'][0], sec['name'][0]],
  115 + type: 3,
  116 + id: [first['id'][0], sec['id'][0]]
  117 + });
  118 + len--;
  119 + }
  120 + }
  121 +
  122 + //上下行GPS容器
  123 + $.each(data, function () {
  124 + this.gpsUps = [];
  125 + this.gpsDowns = [];
  126 + });
  127 + return data;
  128 + };
  129 +
  130 + var filterByAttrs = function (svgAttr, routes) {
  131 + var hideStations = svgAttr.hideStations ? svgAttr.hideStations : [];
  132 + var nicknames = svgAttr.nicknames ? svgAttr.nicknames : {};
  133 + var stationCode;
  134 + $.each(routes, function (i) {
  135 + stationCode = this.stationCode
  136 + //要隐藏的站点
  137 + $.each(hideStations, function (j, hide) {
  138 + if (stationCode == hide)
  139 + delete routes[i];
  140 + });
  141 +
  142 + //要重命名的站点
  143 + if (nicknames[this.stationName]) {
  144 + this.stationName = nicknames[this.stationName];
  145 + }
  146 + });
  147 +
  148 + var newRoutes = [];
  149 + $.each(routes, function (i, station) {
  150 + if(station)
  151 + newRoutes.push(station);
  152 + });
  153 +
  154 + return newRoutes;
  155 + };
  156 +
  157 + var upSort = function (a, b) {
  158 + return a.stationRouteCode - b.stationRouteCode;
  159 + };
  160 +
  161 + var downSort = function (a, b) {
  162 + return b.stationRouteCode - a.stationRouteCode;
  163 + };
  164 +
  165 + var station_indexof = function (array, station, start) {
  166 + var res = -1;
  167 + for (var i = start, obj; obj = array[i++];) {
  168 + if (obj.stationName == station.stationName) {
  169 + res = i;
  170 + break;
  171 + }
  172 + }
  173 + return res;
  174 + };
  175 +
  176 + var get_station_code = function (station) {
  177 + return station.stationCode + '_' + station.directions;
  178 + };
  179 +
  180 + var nvl_get = function (list, index) {
  181 + return list[index] == null ? {} : list[index];
  182 + };
  183 +
  184 + var groupByStationAndUpdown = function (data) {
  185 + //gb_common.groupBy(data, 'stopNo')
  186 + var rs = {},
  187 + key;
  188 + $.each(data, function () {
  189 + key = this['stopNo'] + '_' + this['upDown'];
  190 + if (!rs[key])
  191 + rs[key] = [];
  192 +
  193 + rs[key].push(this);
  194 + });
  195 +
  196 + return rs;
  197 + };
  198 + return {mergeRoute: mergeRoute, groupByStationAndUpdown: groupByStationAndUpdown};
  199 +})();
... ...
src/main/resources/static/real_control_v2/mapmonitor/fragments/map_infowindow.html
... ... @@ -38,6 +38,7 @@
38 38 {{if expectStopTime!=null}}
39 39 <a href="javascript:;" style="color: #07D;margin-right: 7px;">预计 {{expectStopTime}} 分钟到达终点</a>
40 40 {{/if}}
  41 + <a href="javascript:;" style="float: left;" onclick="javascript:window.open('http://180.166.5.82:9005/transport_server/dvr_monitor1.jsp?userid=4&deviceid={{deviceId}}');">DVR</a>
41 42 <a href="javascript:;" style="float: right;" onclick="javascript:gb_map_play_back.initParams('{{deviceId}}', '{{nbbm}}');">轨迹回放</a>
42 43 </div>
43 44 </script>
... ...